Blender V5.0
denoiser_oidn_gpu.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#if defined(WITH_OPENIMAGEDENOISE)
8
10# include "util/openimagedenoise.h" // IWYU pragma: keep
11
13
14/* Implementation of a GPU denoiser which uses OpenImageDenoise library. */
15class OIDNDenoiserGPU : public DenoiserGPU {
16 friend class OIDNDenoiseContext;
17
18 public:
19 /* Forwardly declared state which might be using compile-flag specific fields, such as
20 * OpenImageDenoise device and filter handles. */
21 class State;
22
23 OIDNDenoiserGPU(Device *denoiser_device, const DenoiseParams &params);
24 ~OIDNDenoiserGPU() override;
25
26 bool denoise_buffer(const BufferParams &buffer_params,
27 RenderBuffers *render_buffers,
28 const int num_samples,
29 bool allow_inplace_modification) override;
30
31 static bool is_device_supported(const DeviceInfo &device);
32
33 protected:
34 enum class ExecMode {
35 SYNC,
36 ASYNC,
37 };
38
39 uint get_device_type_mask() const override;
40
41 /* Create OIDN denoiser descriptor if needed.
42 * Will do nothing if the current OIDN descriptor is usable for the given parameters.
43 * If the OIDN denoiser descriptor did re-allocate here it is left unconfigured. */
44 bool denoise_create_if_needed(DenoiseContext &context) override;
45
46 /* Configure existing OIDN denoiser descriptor for the use for the given task. */
47 bool denoise_configure_if_needed(DenoiseContext &context) override;
48
49 /* Run configured denoiser. */
50 bool denoise_run(const DenoiseContext &context, const DenoisePass &pass) override;
51
52 OIDNFilter create_filter();
53 bool commit_and_execute_filter(OIDNFilter filter, ExecMode mode = ExecMode::SYNC);
54
55 void set_filter_pass(OIDNFilter filter,
56 const char *name,
58 const int format,
59 const int width,
60 const int height,
61 const size_t offset_in_bytes,
62 const size_t pixel_stride_in_bytes,
63 size_t row_stride_in_bytes);
64
65 /* Delete all allocated OIDN objects. */
66 void release_all_resources();
67
68 OIDNDevice oidn_device_ = nullptr;
69 OIDNFilter oidn_filter_ = nullptr;
70 OIDNFilter albedo_filter_ = nullptr;
71 OIDNFilter normal_filter_ = nullptr;
72
73 bool is_configured_ = false;
74 int2 configured_size_ = make_int2(0, 0);
75
76 vector<uint8_t> custom_weights;
77
78 bool use_pass_albedo_ = false;
79 bool use_pass_normal_ = false;
81
82 /* Filter memory usage limit if we ran out of memory with OIDN's default limit. */
83 int max_mem_ = 768;
84};
85
87
88#endif
unsigned int uint
virtual bool denoise_run(const DenoiseContext &context, const DenoisePass &pass)=0
virtual bool denoise_create_if_needed(DenoiseContext &context)=0
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
DenoiserQuality
Definition denoise.h:41
@ DENOISER_QUALITY_HIGH
Definition denoise.h:42
#define CCL_NAMESPACE_END
ccl_device_forceinline int2 make_int2(const int x, const int y)
#define filter
VecBase< int, 2 > int2
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
format
const char * name
uint64_t device_ptr
Definition types_base.h:44
PointerRNA * ptr
Definition wm_files.cc:4238