[Bf-blender-cvs] [cfd0e96e47e] blender-v3.0-release: Fix T93125: Cycles wrong remaining render time with high number of samples

Brecht Van Lommel noreply at git.blender.org
Tue Nov 16 21:16:34 CET 2021


Commit: cfd0e96e47ed34888077b989854ba5a557bac43b
Author: Brecht Van Lommel
Date:   Tue Nov 16 20:44:31 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rBcfd0e96e47ed34888077b989854ba5a557bac43b

Fix T93125: Cycles wrong remaining render time with high number of samples

Avoid integer overflow.

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

M	intern/cycles/blender/session.cpp
M	intern/cycles/blender/session.h
M	intern/cycles/integrator/path_trace.cpp
M	intern/cycles/session/session.cpp
M	intern/cycles/util/progress.h

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

diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp
index b7fd862bffd..c786b29d442 100644
--- a/intern/cycles/blender/session.cpp
+++ b/intern/cycles/blender/session.cpp
@@ -129,7 +129,7 @@ void BlenderSession::create_session()
   /* reset status/progress */
   last_status = "";
   last_error = "";
-  last_progress = -1.0f;
+  last_progress = -1.0;
   start_resize_time = 0.0;
 
   /* create session */
@@ -854,7 +854,7 @@ void BlenderSession::get_status(string &status, string &substatus)
   session->progress.get_status(status, substatus);
 }
 
-void BlenderSession::get_progress(float &progress, double &total_time, double &render_time)
+void BlenderSession::get_progress(double &progress, double &total_time, double &render_time)
 {
   session->progress.get_time(total_time, render_time);
   progress = session->progress.get_progress();
@@ -862,7 +862,7 @@ void BlenderSession::get_progress(float &progress, double &total_time, double &r
 
 void BlenderSession::update_bake_progress()
 {
-  float progress = session->progress.get_progress();
+  double progress = session->progress.get_progress();
 
   if (progress != last_progress) {
     b_engine.update_progress(progress);
@@ -874,7 +874,7 @@ void BlenderSession::update_status_progress()
 {
   string timestatus, status, substatus;
   string scene_status = "";
-  float progress;
+  double progress;
   double total_time, remaining_time = 0, render_time;
   float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
   float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;
diff --git a/intern/cycles/blender/session.h b/intern/cycles/blender/session.h
index fa24b5f7467..f837e97c17c 100644
--- a/intern/cycles/blender/session.h
+++ b/intern/cycles/blender/session.h
@@ -82,7 +82,7 @@ class BlenderSession {
   void tag_redraw();
   void tag_update();
   void get_status(string &status, string &substatus);
-  void get_progress(float &progress, double &total_time, double &render_time);
+  void get_progress(double &progress, double &total_time, double &render_time);
   void test_cancel();
   void update_status_progress();
   void update_bake_progress();
@@ -108,7 +108,7 @@ class BlenderSession {
 
   string last_status;
   string last_error;
-  float last_progress;
+  double last_progress;
   double last_status_time;
 
   int width, height;
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index f3a08b1659c..92bf8e69d19 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -847,7 +847,8 @@ void PathTrace::progress_update_if_needed(const RenderWork &render_work)
 {
   if (progress_ != nullptr) {
     const int2 tile_size = get_render_tile_size();
-    const int num_samples_added = tile_size.x * tile_size.y * render_work.path_trace.num_samples;
+    const uint64_t num_samples_added = uint64_t(tile_size.x) * tile_size.y *
+                                       render_work.path_trace.num_samples;
     const int current_sample = render_work.path_trace.start_sample +
                                render_work.path_trace.num_samples;
     progress_->add_samples(num_samples_added, current_sample);
diff --git a/intern/cycles/session/session.cpp b/intern/cycles/session/session.cpp
index b228939689c..170af5c70b6 100644
--- a/intern/cycles/session/session.cpp
+++ b/intern/cycles/session/session.cpp
@@ -504,7 +504,7 @@ void Session::set_display_driver(unique_ptr<DisplayDriver> driver)
 
 double Session::get_estimated_remaining_time() const
 {
-  const float completed = progress.get_progress();
+  const double completed = progress.get_progress();
   if (completed == 0.0f) {
     return 0.0;
   }
@@ -573,7 +573,7 @@ void Session::update_status_time(bool show_pause, bool show_done)
   }
 
   /* Sample. */
-  if (num_samples == Integrator::MAX_SAMPLES) {
+  if (!params.background && num_samples == Integrator::MAX_SAMPLES) {
     substatus = status_append(substatus, string_printf("Sample %d", current_sample));
   }
   else {
diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h
index 4b0ff08aa7e..f2d80e49ab8 100644
--- a/intern/cycles/util/progress.h
+++ b/intern/cycles/util/progress.h
@@ -200,12 +200,12 @@ class Progress {
     total_pixel_samples = total_pixel_samples_;
   }
 
-  float get_progress() const
+  double get_progress() const
   {
     thread_scoped_lock lock(progress_mutex);
 
     if (total_pixel_samples > 0) {
-      return ((float)pixel_samples) / total_pixel_samples;
+      return ((double)pixel_samples) / (double)total_pixel_samples;
     }
     return 0.0f;
   }



More information about the Bf-blender-cvs mailing list