Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2021-11-16 22:44:31 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-11-16 22:49:32 +0300
commitcfd0e96e47ed34888077b989854ba5a557bac43b (patch)
tree0afe6d7a14af81482266ba581336143c61f57fc6
parent7293c1b3578e015a00e8b1e282baa62f51c5b4c4 (diff)
Fix T93125: Cycles wrong remaining render time with high number of samples
Avoid integer overflow.
-rw-r--r--intern/cycles/blender/session.cpp8
-rw-r--r--intern/cycles/blender/session.h4
-rw-r--r--intern/cycles/integrator/path_trace.cpp3
-rw-r--r--intern/cycles/session/session.cpp4
-rw-r--r--intern/cycles/util/progress.h4
5 files changed, 12 insertions, 11 deletions
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;
}