Blender V5.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 virtual bool denoise_buffer(const BufferParams &buffer_params,
22 const BufferParams &denoised_buffer_params,
23 RenderBuffers *render_buffers,
24 int num_samples,
25 bool allow_inplace_modification,
26 float2 pixel_jitter) override;
27
28 static bool is_device_supported(const DeviceInfo &device);
29
30 private:
31 /* Set fake albedo pixels in the albedo guiding pass storage.
32 * After this point only passes which do not need albedo for denoising can be processed. */
33 bool denoise_filter_guiding_set_fake_albedo(const DenoiseContext &context);
34
35 /* Create OptiX denoiser descriptor if needed.
36 * Will do nothing if the current OptiX descriptor is usable for the given parameters.
37 * If the OptiX denoiser descriptor did re-allocate here it is left unconfigured. */
38 virtual bool denoise_create_if_needed(DenoiseContext &context) override;
39
40 /* Configure existing OptiX denoiser descriptor for the use for the given task. */
41 virtual bool denoise_configure_if_needed(DenoiseContext &context) override;
42
43 /* Run configured denoiser. */
44 virtual bool denoise_run(const DenoiseContext &context, const DenoisePass &pass) override;
45
46 OptixDenoiser optix_denoiser_ = nullptr;
47
48 /* Configuration size, as provided to `optixDenoiserSetup`.
49 * If the `optixDenoiserSetup()` was never used on the current `optix_denoiser` the
50 * `is_configured` will be false. */
51 bool is_configured_ = false;
52 int2 configured_size_ = make_int2(0, 0);
53
54 /* OptiX denoiser state and scratch buffers, stored in a single memory buffer.
55 * The memory layout goes as following: [denoiser state][scratch buffer]. */
56 device_only_memory<unsigned char> state_;
57 OptixDenoiserSizes sizes_ = {};
58
59 bool use_pass_albedo_ = false;
60 bool use_pass_normal_ = false;
61 bool use_pass_motion_ = false;
62 bool use_upscale_model_ = false;
63};
64
66
67#endif
#define CCL_NAMESPACE_END
ccl_device_forceinline int2 make_int2(const int x, const int y)
VecBase< float, 2 > float2
VecBase< int, 2 > int2