[Bf-blender-cvs] [c0db8e3b41e] master: Fix T91660: Cycles remaining render time does not take into account time limit

Brecht Van Lommel noreply at git.blender.org
Fri Sep 24 16:34:21 CEST 2021


Commit: c0db8e3b41e21bb6f8327a038601827a0d20a9cc
Author: Brecht Van Lommel
Date:   Fri Sep 24 16:16:16 2021 +0200
Branches: master
https://developer.blender.org/rBc0db8e3b41e21bb6f8327a038601827a0d20a9cc

Fix T91660: Cycles remaining render time does not take into account time limit

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

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/render/session.cpp
M	intern/cycles/render/session.h
M	intern/cycles/util/util_progress.h

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 33092129ddf..ef1bc038a87 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -993,8 +993,9 @@ void BlenderSession::update_status_progress()
   get_status(status, substatus);
   get_progress(progress, total_time, render_time);
 
-  if (progress > 0)
-    remaining_time = (1.0 - (double)progress) * (render_time / (double)progress);
+  if (progress > 0) {
+    remaining_time = session->get_estimated_remaining_time();
+  }
 
   if (background) {
     if (scene)
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index a8957b8def6..56d92fb0ad8 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -519,6 +519,25 @@ void Session::set_gpu_display(unique_ptr<GPUDisplay> gpu_display)
   path_trace_->set_gpu_display(move(gpu_display));
 }
 
+double Session::get_estimated_remaining_time() const
+{
+  const float completed = progress.get_progress();
+  if (completed == 0.0f) {
+    return 0.0;
+  }
+
+  double total_time, render_time;
+  progress.get_time(total_time, render_time);
+  double remaining = (1.0 - (double)completed) * (render_time / (double)completed);
+
+  const double time_limit = render_scheduler_.get_time_limit();
+  if (time_limit != 0.0) {
+    remaining = min(remaining, max(time_limit - render_time, 0.0));
+  }
+
+  return remaining;
+}
+
 void Session::wait()
 {
   if (session_thread_) {
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index 5623604bfe8..e3056e7778b 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -145,6 +145,8 @@ class Session {
 
   void set_gpu_display(unique_ptr<GPUDisplay> gpu_display);
 
+  double get_estimated_remaining_time() const;
+
   void device_free();
 
   /* Returns the rendering progress or 0 if no progress can be determined
diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index dca8d3d0ab5..176ee11e1e9 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -100,7 +100,7 @@ class Progress {
     cancel = true;
   }
 
-  bool get_cancel()
+  bool get_cancel() const
   {
     if (!cancel && cancel_cb)
       cancel_cb();
@@ -108,7 +108,7 @@ class Progress {
     return cancel;
   }
 
-  string get_cancel_message()
+  string get_cancel_message() const
   {
     thread_scoped_lock lock(progress_mutex);
     return cancel_message;
@@ -130,12 +130,12 @@ class Progress {
     cancel = true;
   }
 
-  bool get_error()
+  bool get_error() const
   {
     return error;
   }
 
-  string get_error_message()
+  string get_error_message() const
   {
     thread_scoped_lock lock(progress_mutex);
     return error_message;
@@ -168,7 +168,7 @@ class Progress {
     }
   }
 
-  void get_time(double &total_time_, double &render_time_)
+  void get_time(double &total_time_, double &render_time_) const
   {
     thread_scoped_lock lock(progress_mutex);
 
@@ -200,7 +200,7 @@ class Progress {
     total_pixel_samples = total_pixel_samples_;
   }
 
-  float get_progress()
+  float get_progress() const
   {
     thread_scoped_lock lock(progress_mutex);
 
@@ -236,7 +236,7 @@ class Progress {
     }
   }
 
-  int get_current_sample()
+  int get_current_sample() const
   {
     thread_scoped_lock lock(progress_mutex);
     /* Note that the value here always belongs to the last tile that updated,
@@ -244,13 +244,13 @@ class Progress {
     return current_tile_sample;
   }
 
-  int get_rendered_tiles()
+  int get_rendered_tiles() const
   {
     thread_scoped_lock lock(progress_mutex);
     return rendered_tiles;
   }
 
-  int get_denoised_tiles()
+  int get_denoised_tiles() const
   {
     thread_scoped_lock lock(progress_mutex);
     return denoised_tiles;
@@ -300,7 +300,7 @@ class Progress {
     set_update();
   }
 
-  void get_status(string &status_, string &substatus_)
+  void get_status(string &status_, string &substatus_) const
   {
     thread_scoped_lock lock(progress_mutex);
 
@@ -330,8 +330,8 @@ class Progress {
   }
 
  protected:
-  thread_mutex progress_mutex;
-  thread_mutex update_mutex;
+  mutable thread_mutex progress_mutex;
+  mutable thread_mutex update_mutex;
   function<void()> update_cb;
   function<void()> cancel_cb;



More information about the Bf-blender-cvs mailing list