diff options
Diffstat (limited to 'intern/cycles/device/device.cpp')
-rw-r--r-- | intern/cycles/device/device.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 263d3d24b13..73415d5f9c6 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -603,6 +603,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices, info.has_osl = true; info.has_profiling = true; info.has_peer_memory = false; + info.denoisers = DENOISER_ALL; foreach (const DeviceInfo &device, subdevices) { /* Ensure CPU device does not slow down GPU. */ @@ -647,6 +648,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices, info.has_osl &= device.has_osl; info.has_profiling &= device.has_profiling; info.has_peer_memory |= device.has_peer_memory; + info.denoisers &= device.denoisers; } return info; @@ -667,4 +669,43 @@ void Device::free_memory() network_devices.free_memory(); } +/* DeviceInfo */ + +void DeviceInfo::add_denoising_devices(DenoiserType denoiser_type) +{ + assert(denoising_devices.empty()); + + if (denoiser_type == DENOISER_OPTIX && type != DEVICE_OPTIX) { + vector<DeviceInfo> optix_devices = Device::available_devices(DEVICE_MASK_OPTIX); + if (!optix_devices.empty()) { + /* Convert to a special multi device with separate denoising devices. */ + if (multi_devices.empty()) { + multi_devices.push_back(*this); + } + + /* Try to use the same physical devices for denoising. */ + for (const DeviceInfo &cuda_device : multi_devices) { + if (cuda_device.type == DEVICE_CUDA) { + for (const DeviceInfo &optix_device : optix_devices) { + if (cuda_device.num == optix_device.num) { + id += optix_device.id; + denoising_devices.push_back(optix_device); + break; + } + } + } + } + + if (denoising_devices.empty()) { + /* Simply use the first available OptiX device. */ + const DeviceInfo optix_device = optix_devices.front(); + id += optix_device.id; /* Uniquely identify this special multi device. */ + denoising_devices.push_back(optix_device); + } + + denoisers = denoiser_type; + } + } +} + CCL_NAMESPACE_END |