19 : headless_(
params.headless),
20 background_(
params.background),
21 pixel_size_(
params.pixel_size),
22 tile_manager_(tile_manager),
23 default_start_resolution_divider_(
params.use_resolution_divider ? pixel_size_ * 8 : 0)
107 return state_.num_rendered_samples;
123 state_.resolution_divider = 1;
131 state_.num_rendered_samples = 0;
132 state_.last_display_update_time = 0.0;
133 state_.last_display_update_sample = -1;
135 state_.last_rebalance_time = 0.0;
136 state_.num_rebalance_requested = 0;
137 state_.num_rebalance_changes = 0;
138 state_.last_rebalance_changed =
false;
139 state_.need_rebalance_at_next_work =
false;
143 state_.adaptive_sampling_threshold = 0.4f;
145 state_.last_work_tile_was_denoised =
false;
146 state_.tile_result_was_written =
false;
147 state_.postprocess_work_scheduled =
false;
148 state_.full_frame_work_scheduled =
false;
149 state_.full_frame_was_written =
false;
151 state_.path_trace_finished =
false;
153 state_.start_render_time = 0.0;
154 state_.end_render_time = 0.0;
155 state_.time_limit_reached =
false;
157 state_.occupancy_num_samples = 0;
188 state_.path_trace_finished =
true;
190 bool denoiser_delayed, denoiser_ready_to_display;
213 state_.adaptive_sampling_threshold =
max(
state_.adaptive_sampling_threshold / 2,
228 VLOG_WORK <<
"Schedule work for cancel.";
239 const bool tile_write = render_work.
tile.
write;
240 const bool full_write = render_work.
full.
write;
249 if (!
state_.tile_result_was_written && has_rendered_samples) {
253 if (!
state_.full_frame_was_written) {
266 if (has_rendered_samples && !
state_.full_frame_was_written) {
277 if (
state_.path_trace_finished ||
state_.time_limit_reached) {
288 const double time_now =
time_dt();
299 state_.end_render_time = time_now;
311 state_.num_rendered_samples = 0;
312 state_.last_display_update_sample = -1;
334 bool denoiser_delayed, denoiser_ready_to_display;
353 const double time_now =
time_dt();
356 state_.last_rebalance_time = time_now;
357 ++
state_.num_rebalance_requested;
363 state_.last_display_update_time = time_now;
364 state_.last_display_update_sample =
state_.num_rendered_samples;
374 if (
state_.postprocess_work_scheduled) {
377 state_.postprocess_work_scheduled =
true;
379 bool any_scheduled =
false;
383 any_scheduled =
true;
388 any_scheduled =
true;
391 if (!
state_.tile_result_was_written) {
393 any_scheduled =
true;
400 return any_scheduled;
405 if (
state_.full_frame_work_scheduled) {
419 if (
state_.full_frame_was_written) {
423 state_.full_frame_work_scheduled =
true;
438 return time * resolution_divider_sq;
556 bool balance_changed)
566 if (balance_changed) {
567 ++
state_.num_rebalance_changes;
570 state_.last_rebalance_changed = balance_changed;
577 const double render_wall_time =
state_.end_render_time -
state_.start_render_time;
580 string result =
"\nRender Scheduler Summary\n\n";
591 mode =
"Interactive";
593 result +=
"Mode: " + mode +
"\n";
599 result +=
"\nAdaptive sampling:\n";
607 result +=
"\nDenoiser:\n";
613 string passes =
"Color";
615 passes +=
", Albedo";
618 passes +=
", Normal";
621 result +=
" Passes: " + passes +
"\n";
624 if (
state_.num_rebalance_requested) {
625 result +=
"\nRebalancer:\n";
632 result +=
"\nTime (in seconds):\n";
656 if (
state_.num_rebalance_requested) {
686 int num_rendered_samples)
const
692 const double remaining_render_time =
max(0.0,
695 update_interval =
min(update_interval, remaining_render_time);
698 return update_interval;
704 int num_rendered_samples)
const
711 if (
state_.need_rebalance_at_next_work) {
714 if (
state_.last_rebalance_changed) {
736 if (render_time < 1) {
739 if (render_time < 2) {
742 if (render_time < 4) {
755 if (time_per_sample_average == 0.0) {
763 return max(
int(num_samples_in_second * update_interval_in_seconds), 1);
786 const uint num_samples_down = num_samples_up - (num_samples_up >> 1);
791 if (delta_up <= delta_down) {
792 return num_samples_up;
795 return num_samples_down;
807 if (
state_.num_rendered_samples == 0) {
824 int num_samples_to_render =
min(num_samples_pot, max_num_samples_to_render);
831 int num_samples_to_occupy =
state_.occupancy_num_samples;
832 if (
state_.occupancy < 0.5f) {
833 num_samples_to_occupy = lround(
state_.occupancy_num_samples * 0.7f /
state_.occupancy);
845 const double remaining_render_time =
max(
848 const double predicted_render_time = num_samples_to_occupy * time_per_sample_average;
850 if (predicted_render_time > remaining_render_time) {
851 num_samples_to_occupy = lround(num_samples_to_occupy *
852 (remaining_render_time / predicted_render_time));
856 num_samples_to_render =
max(num_samples_to_render,
857 min(num_samples_to_occupy, max_num_samples_to_render));
863 return num_samples_to_render;
871 num_samples_to_render);
926 ready_to_display =
true;
956 state_.num_rendered_samples :
967 ready_to_display =
false;
988 if (denoiser_delayed) {
1001 if (
done() ||
state_.last_display_update_sample == -1) {
1019 state_.last_display_update_sample);
1020 return (
time_dt() -
state_.last_display_update_time) > update_interval;
1027 static const double kRebalanceIntervalInSeconds = 1;
1040 if (
state_.num_rendered_samples == 0) {
1041 state_.need_rebalance_at_next_work =
true;
1045 if (
state_.need_rebalance_at_next_work) {
1046 state_.need_rebalance_at_next_work =
false;
1050 if (
state_.last_rebalance_changed) {
1054 return (
time_dt() -
state_.last_rebalance_time) > kRebalanceIntervalInSeconds;
1076 const double desired_update_interval_in_seconds =
1087 desired_update_interval_in_seconds * 1.4, actual_time_per_update);
1157 if (
state_.start_render_time == 0.0) {
1162 const double current_time =
time_dt();
1169 state_.time_limit_reached =
true;
1170 state_.end_render_time = current_time;
1193 actual_time /= 4.0 * pre_resolution_division_samples / post_resolution_division_samples;
1201 if (resolution == INT_MAX) {
1205 int resolution_divider = 1;
1206 while (
width *
height > resolution * resolution) {
1210 resolution_divider <<= 1;
1213 return resolution_divider;
1219 const int resolution = lround(
sqrt(pixel_area));
1221 return resolution / resolution_divider;
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
bool need_filter(int sample) const
int align_samples(int start_sample, int num_samples) const
double get_average() const
void add_average(double time, int num_measurements=1)
void add_wall(double time)
int calculate_resolution_divider_for_time(double desired_time, double actual_time)
AdaptiveSampling adaptive_sampling_
DenoiseParams denoiser_params_
void update_state_for_render_work(const RenderWork &render_work)
void report_display_update_time(const RenderWork &render_work, double time)
float work_adaptive_threshold() const
int calculate_num_samples_per_update() const
int get_rendered_sample() const
void set_time_limit(double time_limit)
bool work_need_update_display(const bool denoiser_delayed)
BufferParams buffer_params_
bool work_need_rebalance()
void set_sample_offset(int sample_offset)
struct RenderScheduler::@1247 first_render_time_
void report_adaptive_filter_time(const RenderWork &render_work, double time, bool is_cancelled)
void set_need_schedule_rebalance(bool need_schedule_rebalance)
double guess_display_update_interval_in_seconds() const
void reset_for_next_tile()
bool work_need_denoise(bool &delayed, bool &ready_to_display)
bool work_need_adaptive_filter() const
struct RenderScheduler::@1246 state_
int get_num_rendered_samples() const
string full_report() const
bool need_schedule_rebalance_works_
void reset(const BufferParams &buffer_params, int num_samples, int sample_offset)
bool is_denoise_active_during_update() const
int get_num_samples_during_navigation(int resolution_divier) const
bool set_postprocess_render_work(RenderWork *render_work)
void report_rebalance_time(const RenderWork &render_work, double time, bool balance_changed)
double get_time_limit() const
double guess_display_update_interval_in_seconds_for_num_samples_no_limit(int num_rendered_samples) const
bool work_is_usable_for_first_render_estimation(const RenderWork &render_work)
void report_denoise_time(const RenderWork &render_work, double time)
bool is_adaptive_sampling_used() const
void set_denoiser_params(const DenoiseParams ¶ms)
bool use_progressive_noise_floor_
double guess_display_update_interval_in_seconds_for_num_samples(int num_rendered_samples) const
bool render_work_reschedule_on_idle(RenderWork &render_work)
int get_num_samples() const
TimeWithAverage adaptive_filter_time_
TimeWithAverage rebalance_time_
int get_sample_offset() const
int default_start_resolution_divider_
void report_path_trace_time(const RenderWork &render_work, double time, bool is_cancelled)
TimeWithAverage display_update_time_
void set_full_frame_render_work(RenderWork *render_work)
double guess_viewport_navigation_update_interval_in_seconds() const
void update_start_resolution_divider()
void set_num_samples(int num_samples)
void report_path_trace_occupancy(const RenderWork &render_work, float occupancy)
void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling)
int start_resolution_divider_
bool render_work_reschedule_on_converge(RenderWork &render_work)
TileManager & tile_manager_
bool work_report_reset_average(const RenderWork &render_work)
TimeWithAverage path_trace_time_
bool need_schedule_cryptomatte_
void set_start_sample(int start_sample)
void check_time_limit_reached()
int get_start_sample_to_path_trace() const
int get_num_samples_to_path_trace() const
void render_work_reschedule_on_cancel(RenderWork &render_work)
void report_work_begin(const RenderWork &render_work)
TimeWithAverage denoise_time_
void set_need_schedule_cryptomatte(bool need_schedule_cryptomatte)
int get_start_sample() const
RenderWork get_render_work()
RenderScheduler(TileManager &tile_manager, const SessionParams ¶ms)
bool is_background() const
struct RenderWork::@1244 full
struct RenderWork::@1245 display
struct RenderWork::@1242 cryptomatte
struct RenderWork::@1241 adaptive_sampling
struct RenderWork::@1240 path_trace
struct RenderWork::@1243 tile
bool has_multiple_tiles() const
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN const char * denoiserTypeToHumanReadable(DenoiserType type)
static const char * to_string(const Interpolation &interp)
ccl_gpu_kernel_postfix ccl_global float int int int int ccl_global const float int int int int int int int int int int int int num_samples
int calculate_resolution_divider_for_resolution(int width, int height, int resolution)
static double approximate_final_time(const RenderWork &render_work, double time)
static uint round_num_samples_to_power_of_2(const uint num_samples)
int calculate_resolution_for_divider(int width, int height, int resolution_divider)
string string_from_bool(bool var)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
CCL_NAMESPACE_BEGIN double time_dt()
ccl_device_inline uint next_power_of_two(uint x)
ccl_device_inline bool is_power_of_two(size_t x)