Merge branch 'master' into blender2.8
[blender.git] / intern / cycles / render / session.cpp
index db13564037ef5d87541d0e9853ead7097306f3e0..3854a14f02c7357468df9f4725521ed46ecf91a4 100644 (file)
@@ -250,7 +250,9 @@ void Session::run_gpu()
                if(!no_tiles) {
                        /* update scene */
                        scoped_timer update_timer;
-                       update_scene();
+                       if(update_scene()) {
+                               stats.profiler.reset(scene->shaders.size(), scene->objects.size());
+                       }
                        progress.add_skip_time(update_timer, params.background);
 
                        if(!device->error_message().empty())
@@ -585,7 +587,9 @@ void Session::run_cpu()
 
                        /* update scene */
                        scoped_timer update_timer;
-                       update_scene();
+                       if(update_scene()) {
+                               stats.profiler.reset(scene->shaders.size(), scene->objects.size());
+                       }
                        progress.add_skip_time(update_timer, params.background);
 
                        if(!device->error_message().empty())
@@ -729,6 +733,10 @@ void Session::run()
        /* load kernels */
        load_kernels();
 
+       if(params.use_profiling && (params.device.type == DEVICE_CPU)) {
+               stats.profiler.start();
+       }
+
        /* session thread loop */
        progress.set_status("Waiting for render to start");
 
@@ -743,6 +751,8 @@ void Session::run()
                        run_cpu();
        }
 
+       stats.profiler.stop();
+
        /* progress update */
        if(progress.get_cancel())
                progress.set_status("Cancel", progress.get_cancel_message());
@@ -825,7 +835,7 @@ void Session::wait()
        session_thread = NULL;
 }
 
-void Session::update_scene()
+bool Session::update_scene()
 {
        thread_scoped_lock scene_lock(scene->mutex);
 
@@ -876,7 +886,10 @@ void Session::update_scene()
 
                progress.set_status("Updating Scene");
                MEM_GUARDED_CALL(&progress, scene->device_update, device, progress);
+
+               return true;
        }
+       return false;
 }
 
 void Session::update_status_time(bool show_pause, bool show_done)
@@ -1052,6 +1065,14 @@ void Session::device_free()
         */
 }
 
+void Session::collect_statistics(RenderStats *render_stats)
+{
+       scene->collect_statistics(render_stats);
+       if(params.use_profiling && (params.device.type == DEVICE_CPU)) {
+               render_stats->collect_profiling(scene, &stats);
+       }
+}
+
 int Session::get_max_closure_count()
 {
        int max_closures = 0;