30 device_scene_(device_scene),
31 render_scheduler_(render_scheduler),
32 tile_manager_(tile_manager)
47 path_trace_device, film, device_scene, &
render_cancel_.is_requested);
70 display_->graphics_interop_activate();
76 display_->graphics_interop_deactivate();
84 path_trace_work->alloc_work_memory();
114 const bool reset_rendering)
127 display_->reset(big_tile_params, reset_rendering);
143 path_trace_work->get_render_buffers()->reset(empty_params);
222 path_trace_work->init_execution();
229 template<
typename Callback>
236 const int num_works = path_trace_works.size();
240 for (
int i = 0; i < num_works; ++i) {
241 const double weight = work_balance_infos[i].weight;
242 const int slice_window_full_y = buffer_params.
full_y + buffer_params.
window_y + current_y;
243 const int slice_window_height =
max(lround(window_height * weight), 1);
247 const int remaining_window_height =
max(0, window_height - current_y);
251 slice_params.
full_y =
max(slice_window_full_y - overscan, buffer_params.
full_y);
252 slice_params.
window_y = slice_window_full_y - slice_params.
full_y;
254 if (i < num_works - 1) {
255 slice_params.
window_height =
min(slice_window_height, remaining_window_height);
267 callback(path_trace_works[i].get(), slice_params);
298 scaled_params.
full_x =
params.full_x / resolution_divider;
299 scaled_params.
full_y =
params.full_y / resolution_divider;
305 return scaled_params;
320 scaled_big_tile_params,
324 scaled_full_params, scaled_big_tile_params,
params);
327 render_state_.effective_big_tile_params = scaled_big_tile_params;
352 path_trace_work->zero_render_buffers();
368 const double start_time =
time_dt();
375 const double work_start_time =
time_dt();
386 const double work_time =
time_dt() - work_start_time;
392 <<
" seconds per sample), occupancy: " << statistics.
occupancy;
395 float occupancy_accum = 0.0f;
397 occupancy_accum += balance_info.occupancy;
399 const float occupancy = occupancy_accum / num_works;
412 bool did_reschedule_on_idle =
false;
415 VLOG_WORK <<
"Will filter adaptive stopping buffer, threshold "
418 VLOG_WORK <<
"Will re-calculate convergency flag for currently converged pixels.";
421 const double start_time =
time_dt();
425 const uint num_active_pixels_in_work =
426 path_trace_work->adaptive_sampling_converge_filter_count_active(
428 if (num_active_pixels_in_work) {
441 VLOG_WORK <<
"Continuing with lower threshold.";
443 else if (did_reschedule_on_idle) {
453 VLOG_WORK <<
"Rescheduling is not possible: final threshold is reached.";
456 VLOG_WORK <<
"Rescheduling lower threshold.";
457 did_reschedule_on_idle =
true;
476 if (old_denoiser_params.
type ==
params.type) {
500 VLOG_WORK <<
"Perform cryptomatte work.";
503 path_trace_work->cryptomatte_postproces();
520 const double start_time =
time_dt();
523 bool allow_inplace_modification =
false;
540 allow_inplace_modification =
true;
551 allow_inplace_modification)) {
571 display_ = make_unique<PathTraceDisplay>(move(driver));
615 VLOG_WORK <<
"Skipping PathTraceDisplay update due to 0 size of the render buffer.";
619 const double start_time =
time_dt();
622 VLOG_WORK <<
"Invoke buffer update callback.";
629 VLOG_WORK <<
"Perform copy to GPUDisplay work.";
631 const int texture_width =
render_state_.effective_big_tile_params.window_width;
632 const int texture_height =
render_state_.effective_big_tile_params.window_height;
633 if (!
display_->update_begin(texture_width, texture_height)) {
634 LOG(ERROR) <<
"Error beginning GPUDisplay update.";
669 if (num_works == 1) {
670 VLOG_WORK <<
"Ignoring rebalance work due to single device render.";
674 const double start_time =
time_dt();
678 VLOG_WORK <<
"Per-device path tracing time (seconds):";
679 for (
int i = 0; i < num_works; ++i) {
688 VLOG_WORK <<
"Calculated per-device weights for works:";
689 for (
int i = 0; i < num_works; ++i) {
695 if (!did_rebalance) {
696 VLOG_WORK <<
"Balance in path trace works did not change.";
733 if (!has_multiple_tiles) {
734 VLOG_WORK <<
"Write tile result via buffer write callback.";
740 VLOG_WORK <<
"Write tile result to disk.";
751 VLOG_WORK <<
"Handle full-frame render buffer work.";
822 path_trace_work->copy_render_buffers_from_device();
830 path_trace_work->copy_render_buffers_to_device();
842 if (num_rendered_samples == 0) {
859 buffers = &big_tile_cpu_buffers;
926 if (!path_trace_work->copy_render_buffers_from_device()) {
954 VLOG_WORK <<
"Processing full frame buffer file " << filename;
962 const string error_message =
"Error reading tiles from file";
968 LOG(ERROR) << error_message;
977 if (denoise_params.
use) {
989 denoiser_->denoise_buffer(full_frame_buffers.
params, &full_frame_buffers, 0,
false);
1025 bool success =
true;
1031 if (!path_trace_work->get_render_tile_pixels(pass_accessor, destination)) {
1042 bool success =
true;
1048 if (!path_trace_work->set_render_tile_pixels(pass_accessor, source)) {
1103 path_trace_work->destroy_gpu_resources(
display_.get());
1147 string full_description = device_info.
description;
1152 full_description +=
" (display)";
1159 full_description +=
" [" + device_info.
id +
"]";
1161 return full_description;
1179 string result =
"\n" + message +
": ";
1180 const string pad(message.length() + 2,
' ');
1187 bool is_first =
true;
1206 for (
auto &&path_trace_work : path_trace_works) {
1207 device_info.
multi_devices.push_back(path_trace_work->get_device()->info);
1224 if (!denoiser_device) {
1233 string result =
"\nFull path tracing report\n";
_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 type
ATOMIC_INLINE unsigned int atomic_add_and_fetch_u(unsigned int *p, unsigned int x)
int pad[32 - sizeof(int)]
int get_pass_offset(PassType type, PassMode mode=PassMode::NOISY) const
void update_offset_stride()
bool modified(const BufferParams &other) const
static unique_ptr< Denoiser > create(Device *path_trace_device, const DenoiseParams ¶ms)
Device * get_denoiser_device() const
const DenoiseParams & get_params() const
vector< DeviceInfo > multi_devices
virtual void foreach_device(const function< void(Device *)> &callback)
virtual void set_error(const string &error)
bool get_render_tile_pixels(const RenderBuffers *render_buffers, const Destination &destination) const
RenderBuffers * get_render_buffers()
void set_effective_buffer_params(const BufferParams &effective_full_params, const BufferParams &effective_big_tile_params, const BufferParams &effective_buffer_params)
virtual void render_samples(RenderStatistics &statistics, int start_sample, int samples_num, int sample_offset)=0
static unique_ptr< PathTraceWork > create(Device *device, Film *film, DeviceScene *device_scene, bool *cancel_requested_flag)
function< void(void)> progress_update_cb
void denoise(const RenderWork &render_work)
int2 get_render_tile_size() const
void finalize_full_buffer_on_disk(const RenderWork &render_work)
void process_full_buffer_from_disk(string_view filename)
struct PathTrace::@1234 render_state_
unique_ptr< Denoiser > denoiser_
void update_effective_work_buffer_params(const RenderWork &render_work)
BufferParams full_params_
void rebalance(const RenderWork &render_work)
bool is_cancel_requested()
PathTrace(Device *device, Film *film, DeviceScene *device_scene, RenderScheduler &render_scheduler, TileManager &tile_manager)
void init_render_buffers(const RenderWork &render_work)
void copy_to_render_buffers(RenderBuffers *render_buffers)
void destroy_gpu_resources()
void set_progress(Progress *progress)
vector< unique_ptr< PathTraceWork > > path_trace_works_
void copy_from_render_buffers(RenderBuffers *render_buffers)
void set_denoiser_params(const DenoiseParams ¶ms)
void progress_update_if_needed(const RenderWork &render_work)
void update_display(const RenderWork &render_work)
void progress_set_status(const string &status, const string &substatus="")
void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling)
void set_output_driver(unique_ptr< OutputDriver > driver)
void reset(const BufferParams &full_params, const BufferParams &big_tile_params, bool reset_rendering)
DeviceScene * device_scene_
bool get_render_tile_pixels(const PassAccessor &pass_accessor, const PassAccessor::Destination &destination)
struct PathTrace::@1236 full_frame_state_
int2 get_render_tile_offset() const
unique_ptr< Device > cpu_device_
void tile_buffer_write_to_disk()
void set_display_driver(unique_ptr< DisplayDriver > driver)
void path_trace(RenderWork &render_work)
void render_pipeline(RenderWork render_work)
unique_ptr< OutputDriver > output_driver_
unique_ptr< PathTraceDisplay > display_
vector< WorkBalanceInfo > work_balance_infos_
RenderBuffers * render_buffers
bool copy_render_tile_from_device()
bool did_draw_after_reset_
void render_init_kernel_execution()
int2 get_render_size() const
TileManager & tile_manager_
unique_ptr< PathTraceWork > big_tile_denoise_work_
void update_work_buffer_params_if_needed(const RenderWork &render_work)
struct PathTrace::@1235 render_cancel_
BufferParams big_tile_params_
void write_tile_buffer(const RenderWork &render_work)
bool set_render_tile_pixels(PassAccessor &pass_accessor, const PassAccessor::Source &source)
void render(const RenderWork &render_work)
string full_report() const
void adaptive_sample(RenderWork &render_work)
const BufferParams & get_render_tile_params() const
int get_num_render_tile_samples() const
RenderScheduler & render_scheduler_
int get_num_samples_in_buffer()
void cryptomatte_postprocess(const RenderWork &render_work)
void update_allocated_work_buffer_params()
void set_cancel(const string &cancel_message_)
void set_status(const string &status_, const string &substatus_="")
void add_samples(uint64_t pixel_samples_, int tile_sample)
void set_error(const string &error_message_)
void reset(const BufferParams ¶ms)
void report_display_update_time(const RenderWork &render_work, double time)
void report_adaptive_filter_time(const RenderWork &render_work, double time, bool is_cancelled)
void set_need_schedule_rebalance(bool need_schedule_rebalance)
int get_num_rendered_samples() const
string full_report() const
void report_rebalance_time(const RenderWork &render_work, double time, bool balance_changed)
void report_denoise_time(const RenderWork &render_work, double time)
void set_denoiser_params(const DenoiseParams ¶ms)
bool render_work_reschedule_on_idle(RenderWork &render_work)
void report_path_trace_time(const RenderWork &render_work, double time, bool is_cancelled)
void report_path_trace_occupancy(const RenderWork &render_work, float occupancy)
void set_adaptive_sampling(const AdaptiveSampling &adaptive_sampling)
bool render_work_reschedule_on_converge(RenderWork &render_work)
void report_work_begin(const RenderWork &render_work)
void set_need_schedule_cryptomatte(bool need_schedule_cryptomatte)
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
bool has_written_tiles() const
const int2 get_size() const
const Tile & get_current_tile() const
bool write_tile(const RenderBuffers &tile_buffers)
bool read_full_buffer_from_disk(string_view filename, RenderBuffers *buffers, DenoiseParams *denoise_params)
void finish_write_tiles()
int get_tile_overscan() const
#define CCL_NAMESPACE_END
DEGForeachIDComponentCallback callback
void device_cpu_info(vector< DeviceInfo > &devices)
CCL_NAMESPACE_BEGIN Device * device_cpu_create(const DeviceInfo &info, Stats &stats, Profiler &profiler)
static const char * to_string(const Interpolation &interp)
ccl_global const KernelWorkTile * tile
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int int ccl_global uint * num_active_pixels
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
#define VLOG_IS_ON(severity)
#define DCHECK(expression)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
void parallel_for_each(Range &range, const Function &function)
static string device_info_list_report(const string &message, const DeviceInfo &device_info)
static void foreach_sliced_buffer_params(const vector< unique_ptr< PathTraceWork >> &path_trace_works, const vector< WorkBalanceInfo > &work_balance_infos, const BufferParams &buffer_params, const int overscan, const Callback &callback)
static string path_trace_devices_report(const vector< unique_ptr< PathTraceWork >> &path_trace_works)
static const char * device_type_for_description(const DeviceType type)
static string full_device_info_description(const DeviceInfo &device_info)
static BufferParams scale_buffer_params(const BufferParams ¶ms, int resolution_divider)
static string get_layer_view_name(const RenderBuffers &buffers)
static string denoiser_device_report(const Denoiser *denoiser)
unsigned __int64 uint64_t
static void thread_capture_fp_settings()
std::unique_lock< std::mutex > thread_scoped_lock
CCL_NAMESPACE_BEGIN double time_dt()
CCL_NAMESPACE_BEGIN void work_balance_do_initial(vector< WorkBalanceInfo > &work_balance_infos)
bool work_balance_do_rebalance(vector< WorkBalanceInfo > &work_balance_infos)