Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/integrator/path_trace.cpp
| Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | bool PathTrace::ready_to_reset() | ||||
| if (did_draw_after_reset_) { | if (did_draw_after_reset_) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void PathTrace::reset(const BufferParams &big_tile_params) | void PathTrace::reset(const BufferParams &full_params, const BufferParams &big_tile_params) | ||||
| { | { | ||||
| if (big_tile_params_.modified(big_tile_params)) { | if (big_tile_params_.modified(big_tile_params)) { | ||||
| big_tile_params_ = big_tile_params; | big_tile_params_ = big_tile_params; | ||||
| render_state_.need_reset_params = true; | render_state_.need_reset_params = true; | ||||
| } | } | ||||
| full_params_ = full_params; | |||||
| /* NOTE: GPU display checks for buffer modification and avoids unnecessary re-allocation. | |||||
| * It is requires to inform about reset whenever it happens, so that the redraw state tracking is | |||||
| * properly updated. */ | |||||
| if (gpu_display_) { | if (gpu_display_) { | ||||
| gpu_display_->reset(big_tile_params); | gpu_display_->reset(full_params); | ||||
sergey: This is a bad modification: prevents redraw to happen as often as it should in viewport. I'll… | |||||
| } | } | ||||
| render_state_.has_denoised_result = false; | render_state_.has_denoised_result = false; | ||||
| did_draw_after_reset_ = false; | did_draw_after_reset_ = false; | ||||
| } | } | ||||
| void PathTrace::set_progress(Progress *progress) | void PathTrace::set_progress(Progress *progress) | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | static BufferParams scale_buffer_params(const BufferParams ¶ms, int resolution_divider) | ||||
| return scaled_params; | return scaled_params; | ||||
| } | } | ||||
| void PathTrace::update_effective_work_buffer_params(const RenderWork &render_work) | void PathTrace::update_effective_work_buffer_params(const RenderWork &render_work) | ||||
| { | { | ||||
| const int resolution_divider = render_work.resolution_divider; | const int resolution_divider = render_work.resolution_divider; | ||||
| const BufferParams scaled_full_params = scale_buffer_params(full_params_, resolution_divider); | |||||
| const BufferParams scaled_big_tile_params = scale_buffer_params(big_tile_params_, | const BufferParams scaled_big_tile_params = scale_buffer_params(big_tile_params_, | ||||
| resolution_divider); | resolution_divider); | ||||
| foreach_sliced_buffer_params(path_trace_works_, | foreach_sliced_buffer_params(path_trace_works_, | ||||
| work_balance_infos_, | work_balance_infos_, | ||||
| scaled_big_tile_params, | scaled_big_tile_params, | ||||
| [&](PathTraceWork *path_trace_work, const BufferParams params) { | [&](PathTraceWork *path_trace_work, const BufferParams params) { | ||||
| path_trace_work->set_effective_buffer_params( | path_trace_work->set_effective_buffer_params( | ||||
| scaled_big_tile_params, params); | scaled_full_params, scaled_big_tile_params, params); | ||||
| }); | }); | ||||
| render_state_.effective_big_tile_params = scaled_big_tile_params; | render_state_.effective_big_tile_params = scaled_big_tile_params; | ||||
| } | } | ||||
| void PathTrace::update_work_buffer_params_if_needed(const RenderWork &render_work) | void PathTrace::update_work_buffer_params_if_needed(const RenderWork &render_work) | ||||
| { | { | ||||
| if (render_state_.need_reset_params) { | if (render_state_.need_reset_params) { | ||||
| ▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | if (!gpu_display_) { | ||||
| } | } | ||||
| else { | else { | ||||
| VLOG(3) << "Ignore display update."; | VLOG(3) << "Ignore display update."; | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| VLOG(3) << "Perform copy to GPUDisplay work."; | if (full_params_.width == 0 || full_params_.height == 0) { | ||||
| VLOG(3) << "Skipping GPUDisplay update due to 0 size of the render buffer."; | |||||
| const double start_time = time_dt(); | |||||
| const int width = render_state_.effective_big_tile_params.width; | |||||
| const int height = render_state_.effective_big_tile_params.height; | |||||
| if (width == 0 || height == 0) { | |||||
| return; | return; | ||||
| } | } | ||||
| const int num_samples = get_num_samples_in_buffer(); | VLOG(3) << "Perform copy to GPUDisplay work."; | ||||
| const double start_time = time_dt(); | |||||
| if (!gpu_display_->update_begin(width, height)) { | const int resolution_divider = render_work.resolution_divider; | ||||
| const int texture_width = max(1, full_params_.width / resolution_divider); | |||||
| const int texture_height = max(1, full_params_.height / resolution_divider); | |||||
| if (!gpu_display_->update_begin(texture_width, texture_height)) { | |||||
| LOG(ERROR) << "Error beginning GPUDisplay update."; | LOG(ERROR) << "Error beginning GPUDisplay update."; | ||||
| return; | return; | ||||
| } | } | ||||
| const PassMode pass_mode = render_state_.has_denoised_result ? PassMode::DENOISED : | const PassMode pass_mode = render_state_.has_denoised_result ? PassMode::DENOISED : | ||||
| PassMode::NOISY; | PassMode::NOISY; | ||||
| /* TODO(sergey): When using multi-device rendering map the GPUDisplay once and copy data from all | /* TODO(sergey): When using multi-device rendering map the GPUDisplay once and copy data from all | ||||
| * works in parallel. */ | * works in parallel. */ | ||||
| const int num_samples = get_num_samples_in_buffer(); | |||||
| for (auto &&path_trace_work : path_trace_works_) { | for (auto &&path_trace_work : path_trace_works_) { | ||||
| path_trace_work->copy_to_gpu_display(gpu_display_.get(), pass_mode, num_samples); | path_trace_work->copy_to_gpu_display(gpu_display_.get(), pass_mode, num_samples); | ||||
| } | } | ||||
| gpu_display_->update_end(); | gpu_display_->update_end(); | ||||
| render_scheduler_.report_display_update_time(render_work, time_dt() - start_time); | render_scheduler_.report_display_update_time(render_work, time_dt() - start_time); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 325 Lines • Show Last 20 Lines | |||||
This is a bad modification: prevents redraw to happen as often as it should in viewport. I'll revert this change before commit and add explanation so we don't break things again.