Blender V4.3
denoiser_optix.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#ifdef WITH_OPTIX
8
10
11# include "device/optix/util.h"
12
14
15/* Implementation of denoising API which uses the OptiX denoiser. */
16class OptiXDenoiser : public DenoiserGPU {
17 public:
18 OptiXDenoiser(Device *denoiser_device, const DenoiseParams &params);
19 ~OptiXDenoiser();
20
21 static bool is_device_supported(const DeviceInfo &device);
22
23 protected:
24 virtual uint get_device_type_mask() const override;
25
26 private:
27 virtual bool denoise_buffer(const DenoiseTask &task) override;
28
29 /* Set fake albedo pixels in the albedo guiding pass storage.
30 * After this point only passes which do not need albedo for denoising can be processed. */
31 bool denoise_filter_guiding_set_fake_albedo(const DenoiseContext &context);
32
33 /* Create OptiX denoiser descriptor if needed.
34 * Will do nothing if the current OptiX descriptor is usable for the given parameters.
35 * If the OptiX denoiser descriptor did re-allocate here it is left unconfigured. */
36 virtual bool denoise_create_if_needed(DenoiseContext &context) override;
37
38 /* Configure existing OptiX denoiser descriptor for the use for the given task. */
39 virtual bool denoise_configure_if_needed(DenoiseContext &context) override;
40
41 /* Run configured denoiser. */
42 virtual bool denoise_run(const DenoiseContext &context, const DenoisePass &pass) override;
43
44 OptixDenoiser optix_denoiser_ = nullptr;
45
46 /* Configuration size, as provided to `optixDenoiserSetup`.
47 * If the `optixDenoiserSetup()` was never used on the current `optix_denoiser` the
48 * `is_configured` will be false. */
49 bool is_configured_ = false;
50 int2 configured_size_ = make_int2(0, 0);
51
52 /* OptiX denoiser state and scratch buffers, stored in a single memory buffer.
53 * The memory layout goes as following: [denoiser state][scratch buffer]. */
55 OptixDenoiserSizes sizes_ = {};
56
57 bool use_pass_albedo_ = false;
58 bool use_pass_normal_ = false;
59 bool use_pass_motion_ = false;
60};
61
63
64#endif
unsigned int uint
bool denoise_filter_guiding_set_fake_albedo(const DenoiseContext &context)
virtual bool denoise_run(const DenoiseContext &context, const DenoisePass &pass)=0
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
virtual bool denoise_configure_if_needed(DenoiseContext &context)=0
virtual uint get_device_type_mask() const =0
#define CCL_NAMESPACE_END
ccl_device_forceinline int2 make_int2(const int x, const int y)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]