32 const int num_samples,
33 bool allow_inplace_modification)
36 if (!denoiser_device) {
42 task.num_samples = num_samples;
43 task.buffer_params = buffer_params;
44 task.allow_inplace_modification = allow_inplace_modification;
47 bool local_buffer_used =
false;
51 local_buffer_used =
false;
52 task.render_buffers = render_buffers;
55 VLOG_WORK <<
"Creating temporary buffer on denoiser device.";
62 local_buffer_used =
true;
66 local_render_buffers.
reset(buffer_params);
73 sizeof(
float) * local_render_buffers.
buffer.
size());
77 task.render_buffers = &local_render_buffers;
78 task.allow_inplace_modification =
true;
83 if (local_buffer_used) {
87 render_buffers, buffer_params, &local_render_buffers, local_render_buffers.
params);
92 return denoise_result;
104 LOG(ERROR) <<
"Error preprocessing guiding passes.";
121 LOG(ERROR) <<
"GPU denoiser creation has failed.";
126 LOG(ERROR) <<
"GPU denoiser configuration has failed.";
135 const BufferParams &buffer_params = context.buffer_params;
140 &context.guiding_params.pass_stride,
141 &context.guiding_params.pass_albedo,
142 &context.guiding_params.pass_normal,
143 &context.guiding_params.pass_flow,
144 &context.render_buffers->buffer.device_pointer,
148 &context.pass_sample_count,
149 &context.pass_denoising_albedo,
150 &context.pass_denoising_normal,
151 &context.pass_motion,
154 &buffer_params.
width,
156 &context.num_samples);
162 : denoise_params(task.
params),
163 render_buffers(task.render_buffers),
164 buffer_params(task.buffer_params),
165 guiding_buffer(device,
"denoiser guiding passes buffer",
true),
166 num_samples(task.num_samples)
196 if (task.allow_inplace_modification) {
235 const BufferParams &buffer_params = context.buffer_params;
242 &buffer_params.
width,
247 &context.num_samples,
249 &pass.denoised_offset,
250 &context.pass_sample_count,
251 &pass.num_components,
252 &pass.use_compositing);
260 const BufferParams &buffer_params = context.buffer_params;
267 &buffer_params.
width,
272 &pass.denoised_offset);
279 const BufferParams &buffer_params = context.buffer_params;
284 &context.guiding_params.pass_stride,
285 &context.guiding_params.pass_albedo,
286 &buffer_params.
width,
295 pass_access_info.
type = pass.type;
297 pass_access_info.
offset = pass.noisy_offset;
312 destination.d_pixels = context.render_buffers->buffer.device_pointer;
313 destination.num_components = 3;
314 destination.pixel_offset = pass.denoised_offset;
315 destination.pixel_stride = context.buffer_params.pass_stride;
328 const BufferParams &buffer_params = context.buffer_params;
340 if (pass.use_denoising_albedo) {
341 if (context.albedo_replaced_with_fake) {
342 LOG(ERROR) <<
"Pass which requires albedo is denoised after fake albedo has been set.";
346 else if (context.use_guiding_passes && !context.albedo_replaced_with_fake) {
347 context.albedo_replaced_with_fake =
true;
349 LOG(ERROR) <<
"Error replacing real albedo with the fake one.";
357 LOG(ERROR) <<
"Error converting denoising passes to RGB buffer.";
362 LOG(ERROR) <<
"Error running denoiser.";
370 LOG(ERROR) <<
"Error copying denoiser result to the denoised pass.";
void render_buffers_host_copy_denoised(RenderBuffers *dst, const BufferParams &dst_params, const RenderBuffers *src, const BufferParams &src_params, const size_t src_offset)
int get_pass_offset(PassType type, PassMode mode=PassMode::NOISY) const
int pass_denoising_normal
DenoiseContext(Device *device, const DenoiseTask &task)
const BufferParams & buffer_params
const DenoiseParams & denoise_params
struct DenoiserGPU::DenoiseContext::@1421 guiding_params
struct DenoiserGPU::DenoiseContext::@1420 prev_output
device_only_memory< float > guiding_buffer
int pass_denoising_albedo
RenderBuffers * render_buffers
bool denoise_filter_guiding_set_fake_albedo(const DenoiseContext &context)
virtual bool denoise_run(const DenoiseContext &context, const DenoisePass &pass)=0
DenoiserGPU(Device *denoiser_device, const DenoiseParams ¶ms)
virtual bool denoise_ensure(DenoiseContext &context)
bool denoise_filter_color_postprocess(const DenoiseContext &context, const DenoisePass &pass)
bool denoise_filter_color_preprocess(const DenoiseContext &context, const DenoisePass &pass)
bool denoise_filter_guiding_preprocess(const DenoiseContext &context)
virtual bool denoise_create_if_needed(DenoiseContext &context)=0
virtual bool denoise_buffer(const BufferParams &buffer_params, RenderBuffers *render_buffers, const int num_samples, bool allow_inplace_modification) override
unique_ptr< DeviceQueue > denoiser_queue_
void denoise_pass(DenoiseContext &context, PassType pass_type)
void denoise_color_read(const DenoiseContext &context, const DenoisePass &pass)
virtual bool denoise_configure_if_needed(DenoiseContext &context)=0
Device * get_denoiser_device() const
Device * denoiser_device_
virtual unique_ptr< DeviceQueue > gpu_queue_create()
bool use_approximate_shadow_catcher
bool use_approximate_shadow_catcher_background
bool get_render_tile_pixels(const RenderBuffers *render_buffers, const Destination &destination) const
device_vector< float > buffer
void reset(const BufferParams ¶ms)
device_ptr device_pointer
void alloc_to_device(size_t num, bool shrink_to_fit=true)
#define CCL_NAMESPACE_END
ccl_gpu_kernel_postfix ccl_global const int ccl_global float const int work_size
@ PASS_SHADOW_CATCHER_MATTE
@ PASS_DENOISING_PREVIOUS
@ DEVICE_KERNEL_FILTER_COLOR_PREPROCESS
@ DEVICE_KERNEL_FILTER_GUIDING_SET_FAKE_ALBEDO
@ DEVICE_KERNEL_FILTER_COLOR_POSTPROCESS
@ DEVICE_KERNEL_FILTER_GUIDING_PREPROCESS
#define DCHECK(expression)
CCL_NAMESPACE_BEGIN const char * pass_type_as_string(const PassType type)