[Bf-blender-cvs] [a65509e4497] cycles-x: Fix synchronization time included into constant time render in Cycles X

Sergey Sharybin noreply at git.blender.org
Mon Jul 26 15:18:57 CEST 2021


Commit: a65509e4497f71626fd9a9d5799cf0846e8bd2db
Author: Sergey Sharybin
Date:   Mon Jul 26 15:16:32 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBa65509e4497f71626fd9a9d5799cf0846e8bd2db

Fix synchronization time included into constant time render in Cycles X

The first work is scheduled prior to scene update, and the scene update
might take a while first time (loading kernels, building all the internal
structures and so on).

Made it so the path tracer reports explicitly when it actually starts to
work, so that the scheduler can take proper decision about when to stop,

===================================================================

M	intern/cycles/integrator/path_trace.cpp
M	intern/cycles/integrator/render_scheduler.cpp
M	intern/cycles/integrator/render_scheduler.h

===================================================================

diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index d0894ca6b62..c09af6c4f44 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -159,6 +159,8 @@ void PathTrace::render_pipeline(RenderWork render_work)
 
   render_init_kernel_execution();
 
+  render_scheduler_.report_work_begin(render_work);
+
   init_render_buffers(render_work);
 
   rebalance(render_work);
diff --git a/intern/cycles/integrator/render_scheduler.cpp b/intern/cycles/integrator/render_scheduler.cpp
index 2e6bf739bd9..2afb99ae73c 100644
--- a/intern/cycles/integrator/render_scheduler.cpp
+++ b/intern/cycles/integrator/render_scheduler.cpp
@@ -241,8 +241,6 @@ RenderWork RenderScheduler::get_render_work()
     state_.last_display_update_sample = -1;
   }
 
-  set_start_render_time_if_needed();
-
   render_work.resolution_divider = state_.resolution_divider;
 
   render_work.path_trace.start_sample = get_start_sample_to_path_trace();
@@ -324,6 +322,20 @@ static double approximate_final_time(const RenderWork &render_work, double time)
   return time * resolution_divider_sq;
 }
 
+void RenderScheduler::report_work_begin(const RenderWork &render_work)
+{
+  /* Start counting render time when rendering sampels at their final resolution.
+   *
+   * NOTE: The work might have the path trace part be all zero: this happens when a post-processing
+   * work is scheduled after the path tracing. Checking for just a start sample doesn't work here
+   * because it might be wrongly 0. Check for whether path tracing is actually happening as it is
+   * expected to happen in the first work. */
+  if (render_work.resolution_divider == pixel_size_ && render_work.path_trace.num_samples != 0 &&
+      render_work.path_trace.start_sample == get_start_sample()) {
+    state_.start_render_time = time_dt();
+  }
+}
+
 void RenderScheduler::report_path_trace_time(const RenderWork &render_work,
                                              double time,
                                              bool is_cancelled)
@@ -952,14 +964,6 @@ bool RenderScheduler::work_report_reset_average(const RenderWork &render_work)
   return render_work.resolution_divider != pixel_size_;
 }
 
-void RenderScheduler::set_start_render_time_if_needed()
-{
-  /* Start counting render time when rendering sampels at their final resolution. */
-  if (state_.resolution_divider == pixel_size_ && get_num_rendered_samples() == 0) {
-    state_.start_render_time = time_dt();
-  }
-}
-
 void RenderScheduler::check_time_limit_reached()
 {
   if (time_limit_ == 0.0) {
diff --git a/intern/cycles/integrator/render_scheduler.h b/intern/cycles/integrator/render_scheduler.h
index d5f32e8a6e0..6aa3e81dace 100644
--- a/intern/cycles/integrator/render_scheduler.h
+++ b/intern/cycles/integrator/render_scheduler.h
@@ -142,6 +142,9 @@ class RenderScheduler {
 
   RenderWork get_render_work();
 
+  /* Report that the path tracer started to work, after scene update and loading kernels. */
+  void report_work_begin(const RenderWork &render_work);
+
   /* Report time (in seconds) which corresponding part of work took. */
   void report_path_trace_time(const RenderWork &render_work, double time, bool is_cancelled);
   void report_adaptive_filter_time(const RenderWork &render_work, double time, bool is_cancelled);
@@ -218,8 +221,6 @@ class RenderScheduler {
   /* Check whether timing report about the given work need to reset accumulated average time. */
   bool work_report_reset_average(const RenderWork &render_work);
 
-  void set_start_render_time_if_needed();
-
   /* CHeck whether render time limit has been reached (or exceeded), and if so store related
    * information in the state so that rendering is considered finished, and is possible to report
    * average render time information. */



More information about the Bf-blender-cvs mailing list