This patch supports GPU OIDN denoising in the compositor. A new compositor performance option was added to allow choosing between CPU, GPU, and Auto device selection. Auto will use whatever the compositor is using for execution. The code is two folds, first, denoising code was adapted to use buffers as opposed to passing in pointers to filters directly, this is needed to support GPU devices. Second, device creation is now a bit more involved, it tries to choose the device is being used by the compositor for execution. Matching GPU devices is done by choosing the OIDN device that matches the UUID or LUID of the active GPU platform. We need both UUID and LUID because not all platforms support both. UUID is supported on all platforms except MacOS Metal, while LUID is only supported on Window and MacOS metal. If there is no active GPU device or matching is unsuccessful, we let OIDN choose the best device, which is typically the fastest. To support this case, UUID and LUID identifiers were added to the GPUPlatformGlobal and are initialized by the GPU backend if supported. OpenGL now requires GL_EXT_memory_object and GL_EXT_memory_object_win32 to support this use case, but it should function without it. Pull Request: https://projects.blender.org/blender/blender/pulls/136660
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#ifdef WITH_OPENIMAGEDENOISE
|
|
|
|
# include "BLI_span.hh"
|
|
|
|
# include "COM_context.hh"
|
|
|
|
# include <OpenImageDenoise/oidn.hpp>
|
|
|
|
namespace blender::compositor {
|
|
|
|
/* Create an appropriate device based on the device preferences in the given context. Special
|
|
* attention is given to GPU devices, as multiple GPUs could exist, so the same GPU device used in
|
|
* the active GPU context is chosen. If no GPU context is active, OIDN chooses the best device,
|
|
* which is typically the fastest in the system. Such device selection makes execution more
|
|
* predictable and allows interoperability across APIs. */
|
|
oidn::DeviceRef create_oidn_device(const Context &context);
|
|
|
|
/* Creates a buffer on the given device that represents the given image. If the device can access
|
|
* host-side data, the returned buffer is a simple wrapper around the data, otherwise, the data is
|
|
* copied to a device-only buffer. It is thus expected that the given image data will outlive the
|
|
* returned buffer. */
|
|
oidn::BufferRef create_oidn_buffer(const oidn::DeviceRef &device, const MutableSpan<float> image);
|
|
|
|
} // namespace blender::compositor
|
|
|
|
#endif
|