Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/render_scheduler.cpp
| Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | void RenderScheduler::reset(const BufferParams &buffer_params, int num_samples) | ||||
| state_.full_frame_was_written = false; | state_.full_frame_was_written = false; | ||||
| state_.path_trace_finished = false; | state_.path_trace_finished = false; | ||||
| state_.start_render_time = 0.0; | state_.start_render_time = 0.0; | ||||
| state_.end_render_time = 0.0; | state_.end_render_time = 0.0; | ||||
| state_.time_limit_reached = false; | state_.time_limit_reached = false; | ||||
| state_.occupancy_num_samples = 0; | |||||
| state_.occupancy = 1.0f; | |||||
| first_render_time_.path_trace_per_sample = 0.0; | first_render_time_.path_trace_per_sample = 0.0; | ||||
| first_render_time_.denoise_time = 0.0; | first_render_time_.denoise_time = 0.0; | ||||
| first_render_time_.display_update_time = 0.0; | first_render_time_.display_update_time = 0.0; | ||||
| path_trace_time_.reset(); | path_trace_time_.reset(); | ||||
| denoise_time_.reset(); | denoise_time_.reset(); | ||||
| adaptive_filter_time_.reset(); | adaptive_filter_time_.reset(); | ||||
| display_update_time_.reset(); | display_update_time_.reset(); | ||||
| ▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | if (work_report_reset_average(render_work)) { | ||||
| path_trace_time_.reset_average(); | path_trace_time_.reset_average(); | ||||
| } | } | ||||
| path_trace_time_.add_average(final_time_approx, render_work.path_trace.num_samples); | path_trace_time_.add_average(final_time_approx, render_work.path_trace.num_samples); | ||||
| VLOG(4) << "Average path tracing time: " << path_trace_time_.get_average() << " seconds."; | VLOG(4) << "Average path tracing time: " << path_trace_time_.get_average() << " seconds."; | ||||
| } | } | ||||
| void RenderScheduler::report_path_trace_occupancy(const RenderWork &render_work, float occupancy) | |||||
| { | |||||
| state_.occupancy_num_samples = render_work.path_trace.num_samples; | |||||
| state_.occupancy = occupancy; | |||||
| VLOG(4) << "Measured path tracing occupancy: " << occupancy; | |||||
| } | |||||
| void RenderScheduler::report_adaptive_filter_time(const RenderWork &render_work, | void RenderScheduler::report_adaptive_filter_time(const RenderWork &render_work, | ||||
| double time, | double time, | ||||
| bool is_cancelled) | bool is_cancelled) | ||||
| { | { | ||||
| adaptive_filter_time_.add_wall(time); | adaptive_filter_time_.add_wall(time); | ||||
| if (is_cancelled) { | if (is_cancelled) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | int RenderScheduler::get_num_samples_to_path_trace() const | ||||
| /* Round number of samples to a power of two, so that division of path states into tiles goes in | /* Round number of samples to a power of two, so that division of path states into tiles goes in | ||||
| * a more integer manner. | * a more integer manner. | ||||
| * This might make it so updates happens more rarely due to rounding up. In the test scenes this | * This might make it so updates happens more rarely due to rounding up. In the test scenes this | ||||
| * is not huge deal because it is not seen that more than 8 samples can be rendered between | * is not huge deal because it is not seen that more than 8 samples can be rendered between | ||||
| * updates. If that becomes a problem we can add some extra rules like never allow to round up | * updates. If that becomes a problem we can add some extra rules like never allow to round up | ||||
| * more than N samples. */ | * more than N samples. */ | ||||
| const int num_samples_pot = round_num_samples_to_power_of_2(num_samples_per_update); | const int num_samples_pot = round_num_samples_to_power_of_2(num_samples_per_update); | ||||
| const int num_samples_to_render = min(num_samples_pot, | const int max_num_samples_to_render = start_sample_ + num_samples_ - path_trace_start_sample; | ||||
| start_sample_ + num_samples_ - path_trace_start_sample); | const int num_samples_to_render = min(num_samples_pot, max_num_samples_to_render); | ||||
| /* If adaptive sampling is not use, render as many samples per update as possible, keeping the | /* If adaptive sampling is not use, render as many samples per update as possible, keeping the | ||||
| * device fully occupied, without much overhead of display updates. */ | * device fully occupied, without much overhead of display updates. */ | ||||
| if (!adaptive_sampling_.use) { | if (!adaptive_sampling_.use) { | ||||
| if (!state_.occupancy_num_samples) { | |||||
| /* No occupancy information yet, use number of samples based on an update interval. */ | |||||
| return num_samples_to_render; | return num_samples_to_render; | ||||
| } | } | ||||
| /* For the viewport and preview renders prefer more faster updates. */ | |||||
| if (!background_) { | |||||
| return num_samples_to_render; | |||||
| } | |||||
| /* Keep occupancy at about 0.5 (this is more of an empirical figure which seems to match scenes | |||||
| * with good performance without forcing occupancy to be higher). */ | |||||
| int num_samples_to_occupy = state_.occupancy_num_samples; | |||||
| if (state_.occupancy < 0.5f) { | |||||
| num_samples_to_occupy = lround(state_.occupancy_num_samples * 0.7f / state_.occupancy); | |||||
| } | |||||
| return min(max(num_samples_to_occupy, num_samples_to_render), max_num_samples_to_render); | |||||
| } | |||||
| /* TODO(sergey): Add extra "clamping" here so that none of the filtering points is missing. This | /* TODO(sergey): Add extra "clamping" here so that none of the filtering points is missing. This | ||||
| * is to ensure that the final render is pixel-matched regardless of how many samples per second | * is to ensure that the final render is pixel-matched regardless of how many samples per second | ||||
| * compute device can do. */ | * compute device can do. */ | ||||
| return adaptive_sampling_.align_samples(path_trace_start_sample, num_samples_to_render); | return adaptive_sampling_.align_samples(path_trace_start_sample, num_samples_to_render); | ||||
| } | } | ||||
| int RenderScheduler::get_num_samples_during_navigation(int resolution_divider) const | int RenderScheduler::get_num_samples_during_navigation(int resolution_divider) const | ||||
| ▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines | |||||