2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-12-26 17:53:56 +01:00
|
|
|
#pragma once
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-12-26 17:53:55 +01:00
|
|
|
#include <functional>
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Progress
|
|
|
|
|
*
|
|
|
|
|
* Simple class to communicate progress status messages, timing information,
|
|
|
|
|
* update notifications from a job running in another thread. All methods
|
|
|
|
|
* except for the constructor/destructor are thread safe. */
|
|
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/string.h"
|
|
|
|
|
#include "util/thread.h"
|
|
|
|
|
#include "util/time.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
class Progress {
|
|
|
|
|
public:
|
|
|
|
|
Progress()
|
|
|
|
|
{
|
2012-01-09 16:57:46 +00:00
|
|
|
start_time = time_dt();
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
render_start_time = time_dt();
|
2011-04-27 11:58:34 +00:00
|
|
|
status = "Initializing";
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Progress(Progress &progress)
|
|
|
|
|
{
|
|
|
|
|
*this = progress;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Progress &operator=(Progress &progress)
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress.progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
progress.get_status(status, substatus);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
pixel_samples = progress.pixel_samples;
|
|
|
|
|
total_pixel_samples = progress.total_pixel_samples;
|
|
|
|
|
current_tile_sample = progress.get_current_sample();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return *this;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
void reset()
|
|
|
|
|
{
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
pixel_samples = 0;
|
|
|
|
|
total_pixel_samples = 0;
|
|
|
|
|
current_tile_sample = 0;
|
2017-05-19 03:27:38 +02:00
|
|
|
rendered_tiles = 0;
|
|
|
|
|
denoised_tiles = 0;
|
2012-11-09 08:46:53 +00:00
|
|
|
start_time = time_dt();
|
2015-01-14 23:06:10 +05:00
|
|
|
render_start_time = time_dt();
|
2022-08-11 19:35:45 +02:00
|
|
|
time_limit = 0.0;
|
2017-07-25 01:35:33 +02:00
|
|
|
end_time = 0.0;
|
2012-11-09 08:46:53 +00:00
|
|
|
status = "Initializing";
|
|
|
|
|
substatus = "";
|
|
|
|
|
sync_status = "";
|
|
|
|
|
sync_substatus = "";
|
|
|
|
|
cancel = false;
|
|
|
|
|
cancel_message = "";
|
2014-12-05 21:17:48 +05:00
|
|
|
error = false;
|
|
|
|
|
error_message = "";
|
2012-11-09 08:46:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* cancel */
|
|
|
|
|
void set_cancel(const string &cancel_message_)
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2011-04-27 11:58:34 +00:00
|
|
|
cancel_message = cancel_message_;
|
|
|
|
|
cancel = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
bool get_cancel() const
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!cancel && cancel_cb) {
|
2011-04-27 11:58:34 +00:00
|
|
|
cancel_cb();
|
2024-12-26 17:53:59 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return cancel;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
string get_cancel_message() const
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2011-04-27 11:58:34 +00:00
|
|
|
return cancel_message;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:55 +01:00
|
|
|
void set_cancel_callback(std::function<void()> function)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
cancel_cb = function;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-12-05 21:17:48 +05:00
|
|
|
/* error */
|
|
|
|
|
void set_error(const string &error_message_)
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2014-12-05 21:17:48 +05:00
|
|
|
error_message = error_message_;
|
|
|
|
|
error = true;
|
|
|
|
|
/* If error happens we also stop rendering. */
|
|
|
|
|
cancel_message = error_message_;
|
|
|
|
|
cancel = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
bool get_error() const
|
2014-12-05 21:17:48 +05:00
|
|
|
{
|
|
|
|
|
return error;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
string get_error_message() const
|
2014-12-05 21:17:48 +05:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2014-12-05 21:17:48 +05:00
|
|
|
return error_message;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
/* tile and timing information */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
void set_start_time()
|
2012-01-09 16:57:46 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
start_time = time_dt();
|
2017-07-25 01:35:33 +02:00
|
|
|
end_time = 0.0;
|
2012-01-09 16:57:46 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
void set_render_start_time()
|
2015-01-14 23:06:10 +05:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
render_start_time = time_dt();
|
2015-01-14 23:06:10 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-01 18:15:54 +01:00
|
|
|
void set_time_limit(const double time_limit_)
|
2022-08-11 19:35:45 +02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2022-08-11 19:35:45 +02:00
|
|
|
|
|
|
|
|
time_limit = time_limit_;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
void add_skip_time(const scoped_timer &start_timer, bool only_render)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const double skip_time = time_dt() - start_timer.get_start();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
render_start_time += skip_time;
|
|
|
|
|
if (!only_render) {
|
|
|
|
|
start_time += skip_time;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
void get_time(double &total_time_, double &render_time_) const
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const double time = (end_time > 0) ? end_time : time_dt();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-07-25 01:35:33 +02:00
|
|
|
total_time_ = time - start_time;
|
|
|
|
|
render_time_ = time - render_start_time;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-07-25 01:35:33 +02:00
|
|
|
void set_end_time()
|
|
|
|
|
{
|
|
|
|
|
end_time = time_dt();
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
void reset_sample()
|
2015-06-17 11:56:19 +02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
pixel_samples = 0;
|
|
|
|
|
current_tile_sample = 0;
|
2017-05-19 03:27:38 +02:00
|
|
|
rendered_tiles = 0;
|
|
|
|
|
denoised_tiles = 0;
|
2015-06-17 11:56:19 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-01 18:15:54 +01:00
|
|
|
void set_total_pixel_samples(const uint64_t total_pixel_samples_)
|
2012-09-04 13:29:07 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
total_pixel_samples = total_pixel_samples_;
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-11-16 20:44:31 +01:00
|
|
|
double get_progress() const
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2020-03-09 16:52:34 +01:00
|
|
|
|
2022-08-11 19:35:45 +02:00
|
|
|
if (pixel_samples > 0) {
|
|
|
|
|
double progress_percent = (double)pixel_samples / (double)total_pixel_samples;
|
|
|
|
|
if (time_limit != 0.0) {
|
2024-12-29 17:32:00 +01:00
|
|
|
const double time_since_render_start = time_dt() - render_start_time;
|
2024-12-26 17:53:59 +01:00
|
|
|
progress_percent = fmax(progress_percent, time_since_render_start / time_limit);
|
2022-08-11 19:35:45 +02:00
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
return fmin(1.0, progress_percent);
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
}
|
2021-11-17 17:22:05 +01:00
|
|
|
return 0.0;
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-01 18:15:54 +01:00
|
|
|
void add_samples(const uint64_t pixel_samples_, int tile_sample)
|
2012-09-04 13:29:07 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
pixel_samples += pixel_samples_;
|
|
|
|
|
current_tile_sample = tile_sample;
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-01 18:15:54 +01:00
|
|
|
void add_samples_update(const uint64_t pixel_samples_, int tile_sample)
|
2014-07-22 18:41:01 -03:00
|
|
|
{
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
add_samples(pixel_samples_, tile_sample);
|
2014-07-22 18:41:01 -03:00
|
|
|
set_update();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-19 03:27:38 +02:00
|
|
|
void add_finished_tile(bool denoised)
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-19 03:27:38 +02:00
|
|
|
if (denoised) {
|
|
|
|
|
denoised_tiles++;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
rendered_tiles++;
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
int get_current_sample() const
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
/* Note that the value here always belongs to the last tile that updated,
|
|
|
|
|
* so it's only useful if there is only one active tile. */
|
|
|
|
|
return current_tile_sample;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
int get_rendered_tiles() const
|
2017-05-19 03:27:38 +02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2017-05-19 03:27:38 +02:00
|
|
|
return rendered_tiles;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
int get_denoised_tiles() const
|
2012-09-04 13:29:07 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2017-05-19 03:27:38 +02:00
|
|
|
return denoised_tiles;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* status messages */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void set_status(const string &status_, const string &substatus_ = "")
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2011-04-27 11:58:34 +00:00
|
|
|
status = status_;
|
|
|
|
|
substatus = substatus_;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
set_update();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void set_substatus(const string &substatus_)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2011-04-27 11:58:34 +00:00
|
|
|
substatus = substatus_;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
set_update();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-28 12:37:20 +00:00
|
|
|
void set_sync_status(const string &status_, const string &substatus_ = "")
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2012-09-28 12:37:20 +00:00
|
|
|
sync_status = status_;
|
|
|
|
|
sync_substatus = substatus_;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-28 12:37:20 +00:00
|
|
|
set_update();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-28 12:37:20 +00:00
|
|
|
void set_sync_substatus(const string &substatus_)
|
|
|
|
|
{
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2012-09-28 12:37:20 +00:00
|
|
|
sync_substatus = substatus_;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-28 12:37:20 +00:00
|
|
|
set_update();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
void get_status(string &status_, string &substatus_) const
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(progress_mutex);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!sync_status.empty()) {
|
2012-09-28 12:37:20 +00:00
|
|
|
status_ = sync_status;
|
|
|
|
|
substatus_ = sync_substatus;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
status_ = status;
|
|
|
|
|
substatus_ = substatus;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* callback */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void set_update()
|
|
|
|
|
{
|
2012-05-08 19:57:56 +00:00
|
|
|
if (update_cb) {
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(update_mutex);
|
2011-04-27 11:58:34 +00:00
|
|
|
update_cb();
|
2012-05-08 19:57:56 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:55 +01:00
|
|
|
void set_update_callback(std::function<void()> function)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
update_cb = function;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
protected:
|
2021-09-24 16:16:16 +02:00
|
|
|
mutable thread_mutex progress_mutex;
|
|
|
|
|
mutable thread_mutex update_mutex;
|
2024-12-26 17:53:55 +01:00
|
|
|
std::function<void()> update_cb = nullptr;
|
|
|
|
|
std::function<void()> cancel_cb = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
/* pixel_samples counts how many samples have been rendered over all pixel, not just per pixel.
|
|
|
|
|
* This makes the progress estimate more accurate when tiles with different sizes are used.
|
|
|
|
|
*
|
|
|
|
|
* total_pixel_samples is the total amount of pixel samples that will be rendered. */
|
2024-12-26 17:53:59 +01:00
|
|
|
uint64_t pixel_samples = 0, total_pixel_samples = 0;
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
/* Stores the current sample count of the last tile that called the update function.
|
|
|
|
|
* It's used to display the sample count if only one tile is active. */
|
2024-12-26 17:53:59 +01:00
|
|
|
int current_tile_sample = 0;
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
/* Stores the number of tiles that's already finished.
|
2019-05-01 21:14:11 +10:00
|
|
|
* Used to determine whether all but the last tile are finished rendering,
|
|
|
|
|
* in which case the current_tile_sample is displayed. */
|
2024-12-26 17:53:59 +01:00
|
|
|
int rendered_tiles = 0, denoised_tiles = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
double start_time = 0.0, render_start_time = 0.0, time_limit = 0.0;
|
2017-07-25 01:35:33 +02:00
|
|
|
/* End time written when render is done, so it doesn't keep increasing on redraws. */
|
2024-12-26 17:53:59 +01:00
|
|
|
double end_time = 0.0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
string status;
|
|
|
|
|
string substatus;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-28 12:37:20 +00:00
|
|
|
string sync_status;
|
|
|
|
|
string sync_substatus;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
volatile bool cancel = false;
|
2011-04-27 11:58:34 +00:00
|
|
|
string cancel_message;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
volatile bool error = false;
|
2014-12-05 21:17:48 +05:00
|
|
|
string error_message;
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|