@@ -49,13 +49,14 @@ THE SOFTWARE.
49
49
50
50
#include " math/mathutils.h"
51
51
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"
57
57
#include " CLW/clwoutput.h"
58
- #include " config_manager.h"
58
+ #include " Utils/config_manager.h"
59
+ #include " SceneGraph/IO/scene_io.h"
59
60
60
61
using namespace RadeonRays ;
61
62
@@ -64,7 +65,11 @@ char const* kHelpMessage =
64
65
" 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]" ;
65
66
char const * g_path =
66
67
" ../Resources/bmw" ;
67
- char const * g_modelname = " i8.obj" ;
68
+ // "../Resources/CornellBox";
69
+
70
+ char const * g_modelname =
71
+ " i8.obj" ;
72
+ // "orig.objm";
68
73
69
74
int g_window_width = 800 ;
70
75
int g_window_height = 600 ;
@@ -91,7 +96,7 @@ float g_camera_aperture = 0.f;
91
96
92
97
93
98
bool g_recording_enabled = false ;
94
- int g_frame_count = 200 ;
99
+ int g_pass_count = 200 ;
95
100
96
101
ConfigManager::Mode g_mode = ConfigManager::Mode::kUseSingleGpu ;
97
102
@@ -122,7 +127,8 @@ std::vector<std::thread> g_renderthreads;
122
127
int g_primary = -1 ;
123
128
124
129
125
- std::unique_ptr<Baikal::Scene> g_scene;
130
+ std::unique_ptr<Baikal::Scene1> g_scene;
131
+ std::unique_ptr<Baikal::PerspectiveCamera> g_camera;
126
132
127
133
// CLW stuff
128
134
CLWImage2D g_cl_interop_image;
@@ -171,30 +177,31 @@ void InitData()
171
177
basepath += " /" ;
172
178
std::string filename = basepath + g_modelname;
173
179
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));
175
182
176
- g_scene-> camera_ .reset (new PerspectiveCamera (
183
+ g_camera .reset (new Baikal:: PerspectiveCamera (
177
184
g_camera_pos
178
185
, g_camera_at
179
186
, g_camera_up));
180
-
187
+ g_scene-> SetCamera (g_camera. get ());
181
188
// Adjust sensor size based on current aspect ratio
182
189
float aspect = (float )g_window_width / g_window_height;
183
190
g_camera_sensor_size.y = g_camera_sensor_size.x / aspect;
184
191
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);
190
197
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 " ;
195
202
std::cout << " Sensor size: " << g_camera_sensor_size.x * 1000 .f << " x" << g_camera_sensor_size.y * 1000 .f << " mm\n " ;
196
203
197
- g_scene->SetEnvironment (" ../Resources/Textures/studio015.hdr" , " " , g_envmapmul);
204
+ // g_scene->SetEnvironment("../Resources/Textures/studio015.hdr", "", g_envmapmul);
198
205
199
206
#pragma omp parallel for
200
207
for (int i = 0 ; i < g_cfgs.size (); ++i)
@@ -263,10 +270,8 @@ Baikal::Renderer::BenchmarkStats Update()
263
270
}
264
271
265
272
{
266
- auto const kNumBenchmarkPasses = 100U ;
267
-
268
273
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);
270
275
271
276
return stats;
272
277
}
@@ -380,8 +385,8 @@ int main(int argc, char * argv[])
380
385
g_cspeed = cspeed ? (atof (cspeed) > 0 ) : g_cspeed;
381
386
382
387
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 ;
385
390
386
391
char * cfg = GetCmdOption (argv, argv + argc, " -config" );
387
392
@@ -419,24 +424,15 @@ int main(int argc, char * argv[])
419
424
StartRenderThreads ();
420
425
421
426
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;
432
427
433
428
auto numrays = stats.resolution .x * stats.resolution .y ;
434
429
std::cout << " Baikal renderer benchmark\n " ;
435
- std::cout << " Iterations: " << g_frame_count << std::endl;
430
+ std::cout << " Iterations: " << g_pass_count << std::endl;
436
431
std::cout << " Number of primary rays: " << numrays << std::endl;
437
432
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 " ;
438
433
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 " ;
439
434
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 " ;
440
436
}
441
437
catch (std::runtime_error& err)
442
438
{
0 commit comments