2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
#include "integrator/denoiser.h"
|
|
|
|
|
|
|
|
|
|
#include "device/device.h"
|
2024-03-08 16:26:52 +01:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
#include "integrator/denoiser_oidn.h"
|
2023-11-20 11:12:41 +01:00
|
|
|
#ifdef WITH_OPENIMAGEDENOISE
|
|
|
|
|
# include "integrator/denoiser_oidn_gpu.h"
|
|
|
|
|
#endif
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
#include "integrator/denoiser_optix.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "session/buffers.h"
|
2024-03-08 16:26:52 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/log.h"
|
2024-03-08 16:26:52 +01:00
|
|
|
#include "util/openimagedenoise.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/progress.h"
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
unique_ptr<Denoiser> Denoiser::create(Device *path_trace_device, const DenoiseParams ¶ms)
|
|
|
|
|
{
|
|
|
|
|
DCHECK(params.use);
|
|
|
|
|
|
2023-11-20 11:12:41 +01:00
|
|
|
#ifdef WITH_OPENIMAGEDENOISE
|
2024-03-08 16:26:52 +01:00
|
|
|
/* If available and allowed, then we will use OpenImageDenoise on GPU. */
|
2024-02-06 17:46:21 +01:00
|
|
|
if (params.type == DENOISER_OPENIMAGEDENOISE && params.use_gpu &&
|
|
|
|
|
path_trace_device->info.type != DEVICE_CPU &&
|
2023-12-13 21:38:19 +01:00
|
|
|
OIDNDenoiserGPU::is_device_supported(path_trace_device->info))
|
|
|
|
|
{
|
2023-11-20 11:12:41 +01:00
|
|
|
return make_unique<OIDNDenoiserGPU>(path_trace_device, params);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-03-08 16:26:52 +01:00
|
|
|
#ifdef WITH_OPTIX
|
|
|
|
|
/* Use OptiX on GPU if supported. */
|
|
|
|
|
if (params.type == DENOISER_OPTIX && Device::available_devices(DEVICE_MASK_OPTIX).size()) {
|
|
|
|
|
return make_unique<OptiXDenoiser>(path_trace_device, params);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Always fallback to OIDN on CPU. */
|
2021-11-09 19:07:10 +01:00
|
|
|
DenoiseParams oidn_params = params;
|
|
|
|
|
oidn_params.type = DENOISER_OPENIMAGEDENOISE;
|
|
|
|
|
return make_unique<OIDNDenoiser>(path_trace_device, oidn_params);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
}
|
|
|
|
|
|
2024-03-08 16:26:52 +01:00
|
|
|
DenoiserType Denoiser::automatic_viewport_denoiser_type(const DeviceInfo &path_trace_device_info)
|
|
|
|
|
{
|
2024-03-11 12:58:46 +01:00
|
|
|
#ifdef WITH_OPENIMAGEDENOISE
|
2024-03-11 12:54:45 +01:00
|
|
|
if (path_trace_device_info.type != DEVICE_CPU &&
|
|
|
|
|
OIDNDenoiserGPU::is_device_supported(path_trace_device_info))
|
|
|
|
|
{
|
2024-03-08 16:26:52 +01:00
|
|
|
return DENOISER_OPENIMAGEDENOISE;
|
|
|
|
|
}
|
2024-03-11 12:58:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_OPTIX
|
|
|
|
|
if (!Device::available_devices(DEVICE_MASK_OPTIX).empty()) {
|
2024-03-08 16:26:52 +01:00
|
|
|
return DENOISER_OPTIX;
|
|
|
|
|
}
|
2024-03-11 12:58:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_OPENIMAGEDENOISE
|
|
|
|
|
if (openimagedenoise_supported()) {
|
2024-03-08 16:26:52 +01:00
|
|
|
return DENOISER_OPENIMAGEDENOISE;
|
|
|
|
|
}
|
2024-03-11 12:58:46 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return DENOISER_NONE;
|
2024-03-08 16:26:52 +01:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
Denoiser::Denoiser(Device *path_trace_device, const DenoiseParams ¶ms)
|
|
|
|
|
: path_trace_device_(path_trace_device), params_(params)
|
|
|
|
|
{
|
|
|
|
|
DCHECK(params.use);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Denoiser::set_params(const DenoiseParams ¶ms)
|
|
|
|
|
{
|
|
|
|
|
DCHECK_EQ(params.type, params_.type);
|
|
|
|
|
|
|
|
|
|
if (params.type == params_.type) {
|
|
|
|
|
params_ = params;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
LOG(ERROR) << "Attempt to change denoiser type.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DenoiseParams &Denoiser::get_params() const
|
|
|
|
|
{
|
|
|
|
|
return params_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Denoiser::load_kernels(Progress *progress)
|
|
|
|
|
{
|
|
|
|
|
const Device *denoiser_device = ensure_denoiser_device(progress);
|
|
|
|
|
|
|
|
|
|
if (!denoiser_device) {
|
|
|
|
|
path_trace_device_->set_error("No device available to denoise on");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_WORK << "Will denoise on " << denoiser_device->info.description << " ("
|
|
|
|
|
<< denoiser_device->info.id << ")";
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Device *Denoiser::get_denoiser_device() const
|
|
|
|
|
{
|
|
|
|
|
return denoiser_device_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check whether given device is single (not a MultiDevice) and supports requested denoiser. */
|
2024-02-09 15:02:46 +01:00
|
|
|
static bool is_single_supported_device(const Device *device,
|
|
|
|
|
const uint device_type_mask,
|
|
|
|
|
const DenoiserType type)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
2024-02-09 15:02:46 +01:00
|
|
|
if (!(device_type_mask & (1 << device->info.type))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (device->info.type == DEVICE_MULTI) {
|
|
|
|
|
/* Assume multi-device is never created with a single sub-device.
|
|
|
|
|
* If one requests such configuration it should be checked on the session level. */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!device->info.multi_devices.empty()) {
|
|
|
|
|
/* Some configurations will use multi_devices, but keep the type of an individual device.
|
2022-03-13 00:49:41 -05:00
|
|
|
* This does simplify checks for homogeneous setups, but here we really need a single device.
|
|
|
|
|
*/
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check the denoiser type is supported. */
|
|
|
|
|
return (device->info.denoisers & type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find best suitable device to perform denoiser on. Will iterate over possible sub-devices of
|
|
|
|
|
* multi-device.
|
|
|
|
|
*
|
|
|
|
|
* If there is no device available which supports given denoiser type nullptr is returned. */
|
2024-02-09 15:02:46 +01:00
|
|
|
static Device *find_best_device(Device *device,
|
|
|
|
|
const uint device_type_mask,
|
|
|
|
|
const DenoiserType type)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
Device *best_device = nullptr;
|
|
|
|
|
|
|
|
|
|
device->foreach_device([&](Device *sub_device) {
|
2024-02-09 15:02:46 +01:00
|
|
|
if (!(device_type_mask & (1 << sub_device->info.type))) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if ((sub_device->info.denoisers & type) == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-12 15:49:30 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!best_device) {
|
|
|
|
|
best_device = sub_device;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2022-08-12 15:49:30 +02:00
|
|
|
/* Prefer a device that can use graphics interop for faster display update. */
|
|
|
|
|
if (sub_device->should_use_graphics_interop() && !best_device->should_use_graphics_interop())
|
|
|
|
|
{
|
|
|
|
|
best_device = sub_device;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* TODO(sergey): Choose fastest device from available ones. Taking into account performance
|
|
|
|
|
* of the device and data transfer cost. */
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return best_device;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-28 13:25:23 +01:00
|
|
|
static DeviceInfo find_best_denoiser_device_info(const vector<DeviceInfo> &device_infos,
|
2024-02-09 15:02:46 +01:00
|
|
|
const DenoiserType denoiser_type)
|
2022-01-28 13:25:23 +01:00
|
|
|
{
|
|
|
|
|
for (const DeviceInfo &device_info : device_infos) {
|
|
|
|
|
if ((device_info.denoisers & denoiser_type) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-20 11:12:41 +01:00
|
|
|
/* TODO(sergey): Use one of the already configured devices, so that GPU denoising can happen
|
|
|
|
|
* on a physical device which is already used for rendering. */
|
2022-01-28 13:25:23 +01:00
|
|
|
|
|
|
|
|
/* TODO(sergey): Choose fastest device for denoising. */
|
|
|
|
|
|
|
|
|
|
return device_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DeviceInfo none_device;
|
|
|
|
|
none_device.type = DEVICE_NONE;
|
|
|
|
|
return none_device;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
static unique_ptr<Device> create_denoiser_device(Device *path_trace_device,
|
2022-01-28 13:25:23 +01:00
|
|
|
const uint device_type_mask,
|
2024-02-09 15:02:46 +01:00
|
|
|
const DenoiserType denoiser_type)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
const vector<DeviceInfo> device_infos = Device::available_devices(device_type_mask);
|
|
|
|
|
if (device_infos.empty()) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-28 13:25:23 +01:00
|
|
|
const DeviceInfo denoiser_device_info = find_best_denoiser_device_info(device_infos,
|
|
|
|
|
denoiser_type);
|
|
|
|
|
if (denoiser_device_info.type == DEVICE_NONE) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
unique_ptr<Device> denoiser_device(
|
|
|
|
|
Device::create(denoiser_device_info, path_trace_device->stats, path_trace_device->profiler));
|
|
|
|
|
|
|
|
|
|
if (!denoiser_device) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (denoiser_device->have_error()) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Only need denoising feature, everything else is unused. */
|
|
|
|
|
if (!denoiser_device->load_kernels(KERNEL_FEATURE_DENOISING)) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return denoiser_device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Device *Denoiser::ensure_denoiser_device(Progress *progress)
|
|
|
|
|
{
|
|
|
|
|
/* The best device has been found already, avoid sequential lookups.
|
|
|
|
|
* Additionally, avoid device re-creation if it has failed once. */
|
|
|
|
|
if (denoiser_device_ || device_creation_attempted_) {
|
|
|
|
|
return denoiser_device_;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-09 15:02:46 +01:00
|
|
|
const uint device_type_mask = get_device_type_mask();
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Simple case: rendering happens on a single device which also supports denoiser. */
|
2024-02-09 15:02:46 +01:00
|
|
|
if (is_single_supported_device(path_trace_device_, device_type_mask, params_.type)) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
denoiser_device_ = path_trace_device_;
|
|
|
|
|
return denoiser_device_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find best device from the ones which are already used for rendering. */
|
2024-02-09 15:02:46 +01:00
|
|
|
denoiser_device_ = find_best_device(path_trace_device_, device_type_mask, params_.type);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (denoiser_device_) {
|
|
|
|
|
return denoiser_device_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (progress) {
|
|
|
|
|
progress->set_status("Loading denoising kernels (may take a few minutes the first time)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
device_creation_attempted_ = true;
|
|
|
|
|
|
2022-01-28 13:25:23 +01:00
|
|
|
local_denoiser_device_ = create_denoiser_device(
|
|
|
|
|
path_trace_device_, device_type_mask, params_.type);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
denoiser_device_ = local_denoiser_device_.get();
|
|
|
|
|
|
|
|
|
|
return denoiser_device_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|