Skip to content

Commit aec25ae

Browse files
authored
Merge pull request #144 from beasterio/baikal-next
fix linux build + merge with rpr branch + TileRender + AOV
2 parents 7eb024d + 8921def commit aec25ae

24 files changed

+1495
-1185
lines changed

App/App.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ project "App"
1818
if os.is("windows") then
1919
includedirs { "../3rdparty/glew/include", "../3rdparty/freeglut/include",
2020
"../3rdparty/oiio/include", "../3rdparty/glfw/include"}
21-
links {"RadeonRays"}
21+
links {"RadeonRays", "glfw3"}
2222
if not _OPTIONS["benchmark"] then
2323
links {"glew", "OpenGL32", "glfw3"}
2424
end
@@ -39,7 +39,7 @@ project "App"
3939
buildoptions "-std=c++11"
4040
links {"OpenImageIO", "pthread"}
4141
if not _OPTIONS["benchmark"] then
42-
links{"GLEW", "GL", "glfw3"}
42+
links{"GLEW", "GL", "glfw"}
4343
end
4444
os.execute("rm -rf obj");
4545
end
@@ -70,7 +70,7 @@ project "App"
7070
if _OPTIONS["benchmark"] then
7171
defines{"APP_BENCHMARK"}
7272
removefiles{"../App/main.cpp",
73-
"../App/shader_manager.cpp",}
73+
"../App/Utils/shader_manager.cpp",}
7474
else
7575
removefiles {"../App/main_benchmark.cpp"}
7676
end

App/CL/bxdf.cl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ THE SOFTWARE.
2626
#include <../App/CL/texture.cl>
2727
#include <../App/CL/payload.cl>
2828

29-
#define DENOM_EPS 0.0f
29+
#define DENOM_EPS 1e-8f
3030
#define ROUGHNESS_EPS 0.0001f
3131

3232

@@ -338,7 +338,12 @@ float3 MicrofacetGGX_Evaluate(
338338
float denom = (4.f * costhetao * costhetai);
339339

340340
// F(eta) * D * G * ks / (4 * cosa * cosi)
341-
return denom > 0.f ? F * ks * MicrofacetDistribution_GGX_G(roughness, wi, wo, wh) * MicrofacetDistribution_GGX_D(roughness, wh) / denom : 0.f;
341+
//return denom > 0.f ? F * ks * MicrofacetDistribution_GGX_G(roughness, wi, wo, wh) * MicrofacetDistribution_GGX_D(roughness, wh) / denom : 0.f;
342+
343+
float3 res = denom > 0.f ? F * ks * MicrofacetDistribution_GGX_G(roughness, wi, wo, wh) * MicrofacetDistribution_GGX_D(roughness, wh) / denom : 0.f;
344+
if (length(res) < 0.1f)
345+
res = 0.f;
346+
return res;
342347
}
343348

344349

App/Core/renderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ namespace Baikal
128128
float primary_rays_time_in_ms;
129129
float secondary_rays_time_in_ms;
130130
float shadow_rays_time_in_ms;
131+
//msamples per second
132+
float samples_pes_sec;
131133
};
132134

133135
virtual void RunBenchmark(Scene1 const& scene, std::uint32_t num_passes, BenchmarkStats& stats) {}

App/Renderers/PT/ptrenderer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,5 +866,16 @@ namespace Baikal
866866

867867
//
868868
m_context.Flush(0);
869+
870+
//samples statisticks
871+
output->Clear(0.f);
872+
start = std::chrono::high_resolution_clock::now();
873+
for (auto i = 0U; i < num_passes; ++i)
874+
{
875+
Render(scene);
876+
}
877+
delta = std::chrono::high_resolution_clock::now() - start;
878+
879+
stats.samples_pes_sec = output->width() * output->height() / ((float)std::chrono::duration_cast<std::chrono::milliseconds>(delta).count() / num_passes) / 1000.f;
869880
}
870881
}

App/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ THE SOFTWARE.
2323

2424
#ifdef __APPLE__
2525
#include <OpenCL/OpenCL.h>
26+
<<<<<<< HEAD
27+
// #define GLFW_INCLUDE_GL3
28+
// #define GLFW_NO_GLU
29+
//#include "GLFW/glfw3.h"
30+
=======
2631
#define GLFW_INCLUDE_GLCOREARB
2732
#define GLFW_NO_GLU
2833
#include "GLFW/glfw3.h"
34+
>>>>>>> github/baikal-next
2935
#elif WIN32
3036
#define NOMINMAX
3137
#include <Windows.h>
@@ -38,7 +44,6 @@ THE SOFTWARE.
3844
#include "GLFW/glfw3.h"
3945
#endif
4046

41-
4247
#include "ImGUI/imgui.h"
4348
#include "ImGUI/imgui_impl_glfw_gl3.h"
4449

App/main_benchmark.cpp

Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ THE SOFTWARE.
4949

5050
#include "math/mathutils.h"
5151

52-
#include "tiny_obj_loader.h"
53-
#include "perspective_camera.h"
54-
#include "Scene/scene.h"
55-
#include "PT/ptrenderer.h"
56-
#include "AO/aorenderer.h"
52+
#include "Utils/tiny_obj_loader.h"
53+
#include "SceneGraph/camera.h"
54+
#include "SceneGraph/scene1.h"
55+
#include "Renderers/PT/ptrenderer.h"
56+
#include "Renderers/AO/aorenderer.h"
5757
#include "CLW/clwoutput.h"
58-
#include "config_manager.h"
58+
#include "Utils/config_manager.h"
59+
#include "SceneGraph/IO/scene_io.h"
5960

6061
using namespace RadeonRays;
6162

@@ -64,7 +65,11 @@ char const* kHelpMessage =
6465
"App [-p path_to_models][-f model_name][-b][-r][-ns number_of_shadow_rays][-ao ao_radius][-w window_width][-h window_height][-nb number_of_indirect_bounces]";
6566
char const* g_path =
6667
"../Resources/bmw";
67-
char const* g_modelname = "i8.obj";
68+
//"../Resources/CornellBox";
69+
70+
char const* g_modelname =
71+
"i8.obj";
72+
//"orig.objm";
6873

6974
int g_window_width = 800;
7075
int g_window_height = 600;
@@ -91,7 +96,7 @@ float g_camera_aperture = 0.f;
9196

9297

9398
bool g_recording_enabled = false;
94-
int g_frame_count = 200;
99+
int g_pass_count = 200;
95100

96101
ConfigManager::Mode g_mode = ConfigManager::Mode::kUseSingleGpu;
97102

@@ -122,7 +127,8 @@ std::vector<std::thread> g_renderthreads;
122127
int g_primary = -1;
123128

124129

125-
std::unique_ptr<Baikal::Scene> g_scene;
130+
std::unique_ptr<Baikal::Scene1> g_scene;
131+
std::unique_ptr<Baikal::PerspectiveCamera> g_camera;
126132

127133
// CLW stuff
128134
CLWImage2D g_cl_interop_image;
@@ -171,30 +177,31 @@ void InitData()
171177
basepath += "/";
172178
std::string filename = basepath + g_modelname;
173179

174-
g_scene.reset(Baikal::Scene::LoadFromObj(filename, basepath));
180+
std::unique_ptr<Baikal::SceneIo> scene_io(Baikal::SceneIo::CreateSceneIoObj());
181+
g_scene.reset(scene_io->LoadScene(filename, basepath));
175182

176-
g_scene->camera_.reset(new PerspectiveCamera(
183+
g_camera.reset(new Baikal::PerspectiveCamera(
177184
g_camera_pos
178185
, g_camera_at
179186
, g_camera_up));
180-
187+
g_scene->SetCamera(g_camera.get());
181188
// Adjust sensor size based on current aspect ratio
182189
float aspect = (float)g_window_width / g_window_height;
183190
g_camera_sensor_size.y = g_camera_sensor_size.x / aspect;
184191

185-
g_scene->camera_->SetSensorSize(g_camera_sensor_size);
186-
g_scene->camera_->SetDepthRange(g_camera_zcap);
187-
g_scene->camera_->SetFocalLength(g_camera_focal_length);
188-
g_scene->camera_->SetFocusDistance(g_camera_focus_distance);
189-
g_scene->camera_->SetAperture(g_camera_aperture);
192+
g_camera->SetSensorSize(g_camera_sensor_size);
193+
g_camera->SetDepthRange(g_camera_zcap);
194+
g_camera->SetFocalLength(g_camera_focal_length);
195+
g_camera->SetFocusDistance(g_camera_focus_distance);
196+
g_camera->SetAperture(g_camera_aperture);
190197

191-
std::cout << "Camera type: " << (g_scene->camera_->GetAperture() > 0.f ? "Physical" : "Pinhole") << "\n";
192-
std::cout << "Lens focal length: " << g_scene->camera_->GetFocalLength() * 1000.f << "mm\n";
193-
std::cout << "Lens focus distance: " << g_scene->camera_->GetFocusDistance() << "m\n";
194-
std::cout << "F-Stop: " << 1.f / (g_scene->camera_->GetAperture() * 10.f) << "\n";
198+
std::cout << "Camera type: " << (g_camera->GetAperture() > 0.f ? "Physical" : "Pinhole") << "\n";
199+
std::cout << "Lens focal length: " << g_camera->GetFocalLength() * 1000.f << "mm\n";
200+
std::cout << "Lens focus distance: " << g_camera->GetFocusDistance() << "m\n";
201+
std::cout << "F-Stop: " << 1.f / (g_camera->GetAperture() * 10.f) << "\n";
195202
std::cout << "Sensor size: " << g_camera_sensor_size.x * 1000.f << "x" << g_camera_sensor_size.y * 1000.f << "mm\n";
196203

197-
g_scene->SetEnvironment("../Resources/Textures/studio015.hdr", "", g_envmapmul);
204+
//g_scene->SetEnvironment("../Resources/Textures/studio015.hdr", "", g_envmapmul);
198205

199206
#pragma omp parallel for
200207
for (int i = 0; i < g_cfgs.size(); ++i)
@@ -263,10 +270,8 @@ Baikal::Renderer::BenchmarkStats Update()
263270
}
264271

265272
{
266-
auto const kNumBenchmarkPasses = 100U;
267-
268273
Baikal::Renderer::BenchmarkStats stats;
269-
g_cfgs[g_primary].renderer->RunBenchmark(*g_scene.get(), kNumBenchmarkPasses, stats);
274+
g_cfgs[g_primary].renderer->RunBenchmark(*g_scene.get(), g_pass_count, stats);
270275

271276
return stats;
272277
}
@@ -380,8 +385,8 @@ int main(int argc, char * argv[])
380385
g_cspeed = cspeed ? (atof(cspeed) > 0) : g_cspeed;
381386

382387

383-
char* frame_count = GetCmdOption(argv, argv + argc, "-fc");
384-
g_frame_count = frame_count ? (atoi(frame_count)) : g_frame_count;
388+
char* pass_count = GetCmdOption(argv, argv + argc, "-fc");
389+
g_pass_count = pass_count ? (atoi(pass_count)) : g_pass_count;
385390

386391
char* cfg = GetCmdOption(argv, argv + argc, "-config");
387392

@@ -419,24 +424,15 @@ int main(int argc, char * argv[])
419424
StartRenderThreads();
420425

421426
Baikal::Renderer::BenchmarkStats stats = Update();
422-
for (int i = 1; i < g_frame_count; ++i)
423-
{
424-
Baikal::Renderer::BenchmarkStats iter_stats = Update();
425-
stats.primary_rays_time_in_ms += iter_stats.primary_rays_time_in_ms;
426-
stats.secondary_rays_time_in_ms += iter_stats.secondary_rays_time_in_ms;
427-
stats.shadow_rays_time_in_ms += iter_stats.shadow_rays_time_in_ms;
428-
}
429-
stats.primary_rays_time_in_ms /= g_frame_count;
430-
stats.secondary_rays_time_in_ms /= g_frame_count;
431-
stats.shadow_rays_time_in_ms /= g_frame_count;
432427

433428
auto numrays = stats.resolution.x * stats.resolution.y;
434429
std::cout << "Baikal renderer benchmark\n";
435-
std::cout << "Iterations: " << g_frame_count << std::endl;
430+
std::cout << "Iterations: " << g_pass_count << std::endl;
436431
std::cout << "Number of primary rays: " << numrays << std::endl;
437432
std::cout << "Primary rays: " << (float)(numrays / (stats.primary_rays_time_in_ms * 0.001f) * 0.000001f) << "mrays/s ( " << stats.primary_rays_time_in_ms << "ms )\n";
438433
std::cout << "Secondary rays: " << (float)(numrays / (stats.secondary_rays_time_in_ms * 0.001f) * 0.000001f) << "mrays/s ( " << stats.secondary_rays_time_in_ms << "ms )\n";
439434
std::cout << "Shadow rays: " << (float)(numrays / (stats.shadow_rays_time_in_ms * 0.001f) * 0.000001f) << "mrays/s ( " << stats.shadow_rays_time_in_ms << "ms )\n";
435+
std::cout << "Samples: " << stats.samples_pes_sec << "msamples/s\n";
440436
}
441437
catch (std::runtime_error& err)
442438
{

0 commit comments

Comments
 (0)