5#ifdef WITH_OPENIMAGEDENOISE
18# include <OpenImageDenoise/oidn.hpp>
22static oidn::DeviceRef create_oidn_gpu_device(
const Context &context)
28 return oidn::newDevice(oidn::DeviceType::Default);
35 const int devices_count = oidn::getNumPhysicalDevices();
36 for (
int i = 0;
i < devices_count;
i++) {
37 oidn::PhysicalDeviceRef physical_device(
i);
38 if (!physical_device.get<
bool>(
"luidSupported")) {
42 oidn::LUID luid = physical_device.get<oidn::LUID>(
"luid");
44 if (platform_luid == Span<uint8_t>(luid.bytes,
sizeof(luid.bytes)) &&
45 platform_luid_node_mask == luid_node_mask)
47 return physical_device.newDevice();
57 for (
int i = 0;
i < devices_count;
i++) {
58 oidn::PhysicalDeviceRef physical_device(
i);
59 if (!physical_device.get<
bool>(
"uuidSupported")) {
63 oidn::UUID uuid = physical_device.get<oidn::UUID>(
"uuid");
64 if (platform_uuid == Span<uint8_t>(uuid.bytes,
sizeof(uuid.bytes))) {
65 return physical_device.newDevice();
69 return oidn::newDevice(oidn::DeviceType::Default);
72oidn::DeviceRef create_oidn_device(
const Context &context)
75 context.get_render_data().compositor_denoise_device);
77 switch (preferred_denoise_device) {
79 return oidn::newDevice(oidn::DeviceType::CPU);
81 return create_oidn_gpu_device(context);
84 return oidn::newDevice(oidn::DeviceType::CPU);
87 return create_oidn_gpu_device(context);
92 return oidn::newDevice(oidn::DeviceType::Default);
95oidn::BufferRef create_oidn_buffer(
const oidn::DeviceRef &device,
const MutableSpan<float> image)
98 const bool can_access_host_memory = device.get<
bool>(
"systemMemorySupported");
99 if (can_access_host_memory) {
104 oidn::BufferRef buffer = device.newBuffer(image.
size_in_bytes(), oidn::Storage::Device);
#define BLI_assert_unreachable()
@ SCE_COMPOSITOR_DENOISE_DEVICE_GPU
@ SCE_COMPOSITOR_DENOISE_DEVICE_AUTO
@ SCE_COMPOSITOR_DENOISE_DEVICE_CPU
constexpr T * data() const
constexpr int64_t size_in_bytes() const
int context(const bContext *C, const char *member, bContextDataResult *result)