[Bf-blender-cvs] [3ad2bf1327c] blender-v3.0-release: Cycles: Fix command line render overshooting time limit

Sergey Sharybin noreply at git.blender.org
Thu Nov 18 14:27:52 CET 2021


Commit: 3ad2bf1327cac5f036d763e1cc690b1b2da8e1c4
Author: Sergey Sharybin
Date:   Thu Nov 18 11:25:39 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB3ad2bf1327cac5f036d763e1cc690b1b2da8e1c4

Cycles: Fix command line render overshooting time limit

The calculation based on preserving device occupancy was conflicting
with the fact that time limit needs to render less samples at the last
round of render work.

For example, rendering BMW27 for 30sec on i9-11900k was actually
rendering for almost a minute. Now the render time limit is respected
much more close.

Differential Revision: https://developer.blender.org/D13269

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

M	intern/cycles/integrator/render_scheduler.cpp

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

diff --git a/intern/cycles/integrator/render_scheduler.cpp b/intern/cycles/integrator/render_scheduler.cpp
index f776d01ef67..276453f7aec 100644
--- a/intern/cycles/integrator/render_scheduler.cpp
+++ b/intern/cycles/integrator/render_scheduler.cpp
@@ -827,6 +827,26 @@ int RenderScheduler::get_num_samples_to_path_trace() const
       num_samples_to_occupy = lround(state_.occupancy_num_samples * 0.7f / state_.occupancy);
     }
 
+    /* When time limit is used clamp the calculated number of samples to keep occupancy.
+     * This is because time limit causes the last render iteration to happen with less number of
+     * samples, which conflicts with the occupancy (lower number of samples causes lower
+     * occupancy, also the calculation is based on number of previously rendered samples).
+     *
+     * When time limit is not used the number of samples per render iteration is either increasing
+     * or stays the same, so there is no need to clamp number of samples calculated for occupancy.
+     */
+    if (time_limit_ && state_.start_render_time) {
+      const double remaining_render_time = max(
+          0.0, time_limit_ - (time_dt() - state_.start_render_time));
+      const double time_per_sample_average = path_trace_time_.get_average();
+      const double predicted_render_time = num_samples_to_occupy * time_per_sample_average;
+
+      if (predicted_render_time > remaining_render_time) {
+        num_samples_to_occupy = lround(num_samples_to_occupy *
+                                       (remaining_render_time / predicted_render_time));
+      }
+    }
+
     num_samples_to_render = max(num_samples_to_render,
                                 min(num_samples_to_occupy, max_num_samples_to_render));
   }



More information about the Bf-blender-cvs mailing list