2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2011-04-27 11:58:34 +00: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 "device/cuda/device.h"
|
2025-01-03 11:15:01 +01:00
|
|
|
#include "device/device.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
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/log.h"
|
2011-04-27 11:58:34 +00: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
|
|
|
#ifdef WITH_CUDA
|
|
|
|
|
# include "device/cuda/device_impl.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
# include "integrator/denoiser_oidn_gpu.h" // IWYU pragma: keep
|
2024-01-24 08:19:39 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
# include "util/string.h"
|
2024-12-26 17:53:59 +01:00
|
|
|
# ifdef _WIN32
|
|
|
|
|
# include "util/windows.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
|
|
|
#endif /* WITH_CUDA */
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2020-02-11 18:54:50 +01:00
|
|
|
CCL_NAMESPACE_BEGIN
|
2017-02-14 05:50:29 -05:00
|
|
|
|
2018-11-09 12:01:38 +01:00
|
|
|
bool device_cuda_init()
|
2014-08-05 13:57:50 +06: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 !defined(WITH_CUDA)
|
|
|
|
|
return false;
|
|
|
|
|
#elif defined(WITH_CUDA_DYNLOAD)
|
2014-08-05 13:57:50 +06:00
|
|
|
static bool initialized = false;
|
|
|
|
|
static bool result = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (initialized) {
|
2014-08-05 13:57:50 +06:00
|
|
|
return result;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-08-05 13:57:50 +06:00
|
|
|
initialized = true;
|
2018-02-06 14:54:18 +01:00
|
|
|
int cuew_result = cuewInit(CUEW_INIT_CUDA);
|
2015-03-28 00:15:15 +05:00
|
|
|
if (cuew_result == CUEW_SUCCESS) {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "CUEW initialization succeeded";
|
2014-11-16 01:58:55 +05:00
|
|
|
if (CUDADevice::have_precompiled_kernels()) {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Found precompiled kernels";
|
2014-08-05 13:57:50 +06:00
|
|
|
result = true;
|
2014-11-16 01:58:55 +05:00
|
|
|
}
|
2024-12-26 17:53:55 +01:00
|
|
|
else if (cuewCompilerPath() != nullptr) {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Found CUDA compiler " << cuewCompilerPath();
|
2014-08-05 13:57:50 +06:00
|
|
|
result = true;
|
2014-11-16 01:58:55 +05:00
|
|
|
}
|
|
|
|
|
else {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Neither precompiled kernels nor CUDA compiler was found,"
|
|
|
|
|
<< " unable to use CUDA";
|
2014-11-16 01:58:55 +05:00
|
|
|
}
|
2014-08-05 13:57:50 +06:00
|
|
|
}
|
2014-11-16 01:58:55 +05:00
|
|
|
else {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_WARNING << "CUEW initialization failed: "
|
|
|
|
|
<< ((cuew_result == CUEW_ERROR_ATEXIT_FAILED) ?
|
|
|
|
|
"Error setting up atexit() handler" :
|
|
|
|
|
"Error opening the library");
|
2014-11-16 01:58:55 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-08-05 13:57:50 +06:00
|
|
|
return result;
|
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
|
|
|
#else /* WITH_CUDA_DYNLOAD */
|
2016-01-14 12:24:09 +05:00
|
|
|
return true;
|
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
|
|
|
#endif /* WITH_CUDA_DYNLOAD */
|
2014-08-05 13:57:50 +06:00
|
|
|
}
|
|
|
|
|
|
2024-12-29 23:13:45 +01:00
|
|
|
unique_ptr<Device> device_cuda_create(const DeviceInfo &info,
|
|
|
|
|
Stats &stats,
|
|
|
|
|
Profiler &profiler,
|
|
|
|
|
bool headless)
|
2011-04-27 11:58:34 +00: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
|
|
|
#ifdef WITH_CUDA
|
2024-12-29 23:13:45 +01:00
|
|
|
return make_unique<CUDADevice>(info, stats, profiler, headless);
|
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
|
|
|
#else
|
|
|
|
|
(void)info;
|
|
|
|
|
(void)stats;
|
|
|
|
|
(void)profiler;
|
2024-06-07 17:53:44 +02:00
|
|
|
(void)headless;
|
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
|
|
|
|
|
|
|
|
LOG(FATAL) << "Request to create CUDA device without compiled-in support. Should never happen.";
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
#endif
|
2012-01-04 18:06:32 +00: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
|
|
|
#ifdef WITH_CUDA
|
2017-08-20 22:44:17 +02:00
|
|
|
static CUresult device_cuda_safe_init()
|
2012-01-04 18:06:32 +00:00
|
|
|
{
|
2020-02-12 14:05:00 +01:00
|
|
|
# ifdef _WIN32
|
2017-08-20 22:44:17 +02:00
|
|
|
__try
|
|
|
|
|
{
|
|
|
|
|
return cuInit(0);
|
|
|
|
|
}
|
|
|
|
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
|
{
|
|
|
|
|
/* Ignore crashes inside the CUDA driver and hope we can
|
|
|
|
|
* survive even with corrupted CUDA installs. */
|
|
|
|
|
fprintf(stderr, "Cycles CUDA: driver crashed, continuing without CUDA.\n");
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-20 22:44:17 +02:00
|
|
|
return CUDA_ERROR_NO_DEVICE;
|
2020-02-12 14:05:00 +01:00
|
|
|
# else
|
2017-08-20 22:44:17 +02:00
|
|
|
return cuInit(0);
|
2020-02-12 14:05:00 +01:00
|
|
|
# endif
|
2017-08-20 22:44:17 +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
|
|
|
#endif /* WITH_CUDA */
|
2012-01-04 18:06:32 +00:00
|
|
|
|
2017-08-20 22:44:17 +02:00
|
|
|
void device_cuda_info(vector<DeviceInfo> &devices)
|
|
|
|
|
{
|
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
|
|
|
#ifdef WITH_CUDA
|
2017-08-20 22:44:17 +02:00
|
|
|
CUresult result = device_cuda_safe_init();
|
2012-11-21 01:00:03 +00:00
|
|
|
if (result != CUDA_SUCCESS) {
|
2023-09-17 09:01:48 +10:00
|
|
|
if (result != CUDA_ERROR_NO_DEVICE) {
|
2014-08-05 13:57:50 +06:00
|
|
|
fprintf(stderr, "CUDA cuInit: %s\n", cuewErrorString(result));
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2012-01-04 18:06:32 +00:00
|
|
|
return;
|
2012-11-21 01:00:03 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-20 22:44:17 +02:00
|
|
|
int count = 0;
|
2012-11-21 01:00:03 +00:00
|
|
|
result = cuDeviceGetCount(&count);
|
|
|
|
|
if (result != CUDA_SUCCESS) {
|
2014-08-05 13:57:50 +06:00
|
|
|
fprintf(stderr, "CUDA cuDeviceGetCount: %s\n", cuewErrorString(result));
|
2012-01-04 18:06:32 +00:00
|
|
|
return;
|
2012-11-21 01:00:03 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
vector<DeviceInfo> display_devices;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
for (int num = 0; num < count; num++) {
|
|
|
|
|
char name[256];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-19 11:26:10 +02:00
|
|
|
result = cuDeviceGetName(name, 256, num);
|
|
|
|
|
if (result != CUDA_SUCCESS) {
|
|
|
|
|
fprintf(stderr, "CUDA cuDeviceGetName: %s\n", cuewErrorString(result));
|
2012-01-04 18:06:32 +00:00
|
|
|
continue;
|
2017-10-19 11:26:10 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-11-04 14:49:54 +01:00
|
|
|
int major;
|
|
|
|
|
cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, num);
|
2018-02-17 16:15:07 +01:00
|
|
|
if (major < 3) {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Ignoring device \"" << name
|
|
|
|
|
<< "\", this graphics card is no longer supported.";
|
2015-06-20 17:34:12 +02:00
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
DeviceInfo info;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
info.type = DEVICE_CUDA;
|
|
|
|
|
info.description = string(name);
|
2015-06-27 15:11:46 +02:00
|
|
|
info.num = num;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-29 22:58:19 +02:00
|
|
|
info.has_nanovdb = true;
|
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
|
|
|
info.denoisers = 0;
|
|
|
|
|
|
|
|
|
|
info.has_gpu_queue = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-08 17:16:10 +02:00
|
|
|
/* Check if the device has P2P access to any other device in the system. */
|
|
|
|
|
for (int peer_num = 0; peer_num < count && !info.has_peer_memory; peer_num++) {
|
|
|
|
|
if (num != peer_num) {
|
|
|
|
|
int can_access = 0;
|
|
|
|
|
cuDeviceCanAccessPeer(&can_access, num, peer_num);
|
|
|
|
|
info.has_peer_memory = (can_access != 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
int pci_location[3] = {0, 0, 0};
|
|
|
|
|
cuDeviceGetAttribute(&pci_location[0], CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, num);
|
|
|
|
|
cuDeviceGetAttribute(&pci_location[1], CU_DEVICE_ATTRIBUTE_PCI_BUS_ID, num);
|
|
|
|
|
cuDeviceGetAttribute(&pci_location[2], CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, num);
|
2016-11-22 16:38:37 +01:00
|
|
|
info.id = string_printf("CUDA_%s_%04x:%02x:%02x",
|
|
|
|
|
name,
|
|
|
|
|
(unsigned int)pci_location[0],
|
|
|
|
|
(unsigned int)pci_location[1],
|
|
|
|
|
(unsigned int)pci_location[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-01-24 08:19:39 +01:00
|
|
|
# if defined(WITH_OPENIMAGEDENOISE)
|
2024-05-07 14:07:39 +02:00
|
|
|
# if OIDN_VERSION >= 20300
|
|
|
|
|
if (oidnIsCUDADeviceSupported(num)) {
|
|
|
|
|
# else
|
2024-01-24 08:19:39 +01:00
|
|
|
if (OIDNDenoiserGPU::is_device_supported(info)) {
|
2024-05-07 14:07:39 +02:00
|
|
|
# endif
|
2024-01-24 08:19:39 +01:00
|
|
|
info.denoisers |= DENOISER_OPENIMAGEDENOISE;
|
|
|
|
|
}
|
|
|
|
|
# endif
|
|
|
|
|
|
2017-10-08 19:08:44 +02:00
|
|
|
/* If device has a kernel timeout and no compute preemption, we assume
|
|
|
|
|
* it is connected to a display and will freeze the display while doing
|
|
|
|
|
* computations. */
|
|
|
|
|
int timeout_attr = 0, preempt_attr = 0;
|
|
|
|
|
cuDeviceGetAttribute(&timeout_attr, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, num);
|
|
|
|
|
cuDeviceGetAttribute(&preempt_attr, CU_DEVICE_ATTRIBUTE_COMPUTE_PREEMPTION_SUPPORTED, num);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
# ifdef _WIN32
|
2019-06-18 18:30:48 +02:00
|
|
|
/* The CUDA driver reports compute preemption as not being available on
|
|
|
|
|
* Windows 10 even when it is, due to an issue in application profiles.
|
|
|
|
|
* Detect case where we expect it to be available and override. */
|
|
|
|
|
if (preempt_attr == 0 && (major >= 6) && system_windows_version_at_least(10, 17134)) {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Assuming device has compute preemption on Windows 10.";
|
2019-06-18 18:30:48 +02:00
|
|
|
preempt_attr = 1;
|
|
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
# endif
|
2019-06-18 18:30:48 +02:00
|
|
|
|
2017-10-08 19:08:44 +02:00
|
|
|
if (timeout_attr && !preempt_attr) {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Device is recognized as display.";
|
2016-06-03 11:52:08 +02:00
|
|
|
info.description += " (Display)";
|
2012-01-04 18:06:32 +00:00
|
|
|
info.display_device = true;
|
2012-01-09 16:58:01 +00:00
|
|
|
display_devices.push_back(info);
|
|
|
|
|
}
|
2017-10-08 19:08:44 +02:00
|
|
|
else {
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Device has compute preemption or is not used for display.";
|
2012-01-09 16:58:01 +00:00
|
|
|
devices.push_back(info);
|
2017-10-08 19:08:44 +02:00
|
|
|
}
|
2024-02-06 23:33:22 +01:00
|
|
|
VLOG_INFO << "Added device \"" << info.description << "\" with id \"" << info.id << "\".";
|
2024-02-06 23:40:37 +01:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
if (info.denoisers & DENOISER_OPENIMAGEDENOISE) {
|
2024-03-15 09:52:47 +01:00
|
|
|
VLOG_INFO << "Device with id \"" << info.id << "\" supports "
|
2024-02-06 23:40:37 +01:00
|
|
|
<< denoiserTypeToHumanReadable(DENOISER_OPENIMAGEDENOISE) << ".";
|
2024-12-26 17:53:59 +01:00
|
|
|
}
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!display_devices.empty()) {
|
2012-01-09 16:58:01 +00:00
|
|
|
devices.insert(devices.end(), display_devices.begin(), display_devices.end());
|
2023-09-17 09:01:48 +10: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
|
|
|
#else /* WITH_CUDA */
|
|
|
|
|
(void)devices;
|
|
|
|
|
#endif /* WITH_CUDA */
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-09 12:01:38 +01:00
|
|
|
string device_cuda_capabilities()
|
2015-01-06 14:13:21 +05: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
|
|
|
#ifdef WITH_CUDA
|
2017-08-20 22:44:17 +02:00
|
|
|
CUresult result = device_cuda_safe_init();
|
2015-01-06 14:13:21 +05:00
|
|
|
if (result != CUDA_SUCCESS) {
|
|
|
|
|
if (result != CUDA_ERROR_NO_DEVICE) {
|
|
|
|
|
return string("Error initializing CUDA: ") + cuewErrorString(result);
|
|
|
|
|
}
|
2015-06-05 14:13:59 +02:00
|
|
|
return "No CUDA device found\n";
|
2015-01-06 14:13:21 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-06 14:13:21 +05:00
|
|
|
int count;
|
|
|
|
|
result = cuDeviceGetCount(&count);
|
|
|
|
|
if (result != CUDA_SUCCESS) {
|
|
|
|
|
return string("Error getting devices: ") + cuewErrorString(result);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
string capabilities;
|
2015-01-06 14:13:21 +05:00
|
|
|
for (int num = 0; num < count; num++) {
|
|
|
|
|
char name[256];
|
|
|
|
|
if (cuDeviceGetName(name, 256, num) != CUDA_SUCCESS) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
capabilities += string("\t") + name + "\n";
|
|
|
|
|
int value;
|
2020-02-12 14:05:00 +01:00
|
|
|
# define GET_ATTR(attr) \
|
|
|
|
|
{ \
|
|
|
|
|
if (cuDeviceGetAttribute(&value, CU_DEVICE_ATTRIBUTE_##attr, num) == CUDA_SUCCESS) { \
|
|
|
|
|
capabilities += string_printf("\t\tCU_DEVICE_ATTRIBUTE_" #attr "\t\t\t%d\n", value); \
|
|
|
|
|
} \
|
2015-01-06 14:13:21 +05:00
|
|
|
} \
|
2020-02-12 14:05:00 +01:00
|
|
|
(void)0
|
2015-01-06 14:13:21 +05:00
|
|
|
/* TODO(sergey): Strip all attributes which are not useful for us
|
|
|
|
|
* or does not depend on the driver.
|
|
|
|
|
*/
|
|
|
|
|
GET_ATTR(MAX_THREADS_PER_BLOCK);
|
|
|
|
|
GET_ATTR(MAX_BLOCK_DIM_X);
|
|
|
|
|
GET_ATTR(MAX_BLOCK_DIM_Y);
|
|
|
|
|
GET_ATTR(MAX_BLOCK_DIM_Z);
|
|
|
|
|
GET_ATTR(MAX_GRID_DIM_X);
|
|
|
|
|
GET_ATTR(MAX_GRID_DIM_Y);
|
|
|
|
|
GET_ATTR(MAX_GRID_DIM_Z);
|
|
|
|
|
GET_ATTR(MAX_SHARED_MEMORY_PER_BLOCK);
|
|
|
|
|
GET_ATTR(SHARED_MEMORY_PER_BLOCK);
|
|
|
|
|
GET_ATTR(TOTAL_CONSTANT_MEMORY);
|
|
|
|
|
GET_ATTR(WARP_SIZE);
|
|
|
|
|
GET_ATTR(MAX_PITCH);
|
|
|
|
|
GET_ATTR(MAX_REGISTERS_PER_BLOCK);
|
|
|
|
|
GET_ATTR(REGISTERS_PER_BLOCK);
|
|
|
|
|
GET_ATTR(CLOCK_RATE);
|
|
|
|
|
GET_ATTR(TEXTURE_ALIGNMENT);
|
|
|
|
|
GET_ATTR(GPU_OVERLAP);
|
|
|
|
|
GET_ATTR(MULTIPROCESSOR_COUNT);
|
|
|
|
|
GET_ATTR(KERNEL_EXEC_TIMEOUT);
|
|
|
|
|
GET_ATTR(INTEGRATED);
|
|
|
|
|
GET_ATTR(CAN_MAP_HOST_MEMORY);
|
|
|
|
|
GET_ATTR(COMPUTE_MODE);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE1D_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE3D_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE3D_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE3D_DEPTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_LAYERED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_LAYERED_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_LAYERED_LAYERS);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_ARRAY_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_ARRAY_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES);
|
|
|
|
|
GET_ATTR(SURFACE_ALIGNMENT);
|
|
|
|
|
GET_ATTR(CONCURRENT_KERNELS);
|
|
|
|
|
GET_ATTR(ECC_ENABLED);
|
|
|
|
|
GET_ATTR(TCC_DRIVER);
|
|
|
|
|
GET_ATTR(MEMORY_CLOCK_RATE);
|
|
|
|
|
GET_ATTR(GLOBAL_MEMORY_BUS_WIDTH);
|
|
|
|
|
GET_ATTR(L2_CACHE_SIZE);
|
|
|
|
|
GET_ATTR(MAX_THREADS_PER_MULTIPROCESSOR);
|
|
|
|
|
GET_ATTR(ASYNC_ENGINE_COUNT);
|
|
|
|
|
GET_ATTR(UNIFIED_ADDRESSING);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE1D_LAYERED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE1D_LAYERED_LAYERS);
|
|
|
|
|
GET_ATTR(CAN_TEX2D_GATHER);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_GATHER_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_GATHER_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE3D_WIDTH_ALTERNATE);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE3D_HEIGHT_ALTERNATE);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE3D_DEPTH_ALTERNATE);
|
|
|
|
|
GET_ATTR(TEXTURE_PITCH_ALIGNMENT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURECUBEMAP_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURECUBEMAP_LAYERED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURECUBEMAP_LAYERED_LAYERS);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE1D_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE2D_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE2D_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE3D_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE3D_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE3D_DEPTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE1D_LAYERED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE1D_LAYERED_LAYERS);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE2D_LAYERED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE2D_LAYERED_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACE2D_LAYERED_LAYERS);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACECUBEMAP_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACECUBEMAP_LAYERED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_SURFACECUBEMAP_LAYERED_LAYERS);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE1D_LINEAR_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_LINEAR_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_LINEAR_HEIGHT);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_LINEAR_PITCH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_MIPMAPPED_WIDTH);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE2D_MIPMAPPED_HEIGHT);
|
|
|
|
|
GET_ATTR(COMPUTE_CAPABILITY_MAJOR);
|
|
|
|
|
GET_ATTR(COMPUTE_CAPABILITY_MINOR);
|
|
|
|
|
GET_ATTR(MAXIMUM_TEXTURE1D_MIPMAPPED_WIDTH);
|
|
|
|
|
GET_ATTR(STREAM_PRIORITIES_SUPPORTED);
|
|
|
|
|
GET_ATTR(GLOBAL_L1_CACHE_SUPPORTED);
|
|
|
|
|
GET_ATTR(LOCAL_L1_CACHE_SUPPORTED);
|
|
|
|
|
GET_ATTR(MAX_SHARED_MEMORY_PER_MULTIPROCESSOR);
|
|
|
|
|
GET_ATTR(MAX_REGISTERS_PER_MULTIPROCESSOR);
|
|
|
|
|
GET_ATTR(MANAGED_MEMORY);
|
|
|
|
|
GET_ATTR(MULTI_GPU_BOARD);
|
|
|
|
|
GET_ATTR(MULTI_GPU_BOARD_GROUP_ID);
|
2020-02-12 14:05:00 +01:00
|
|
|
# undef GET_ATTR
|
2015-01-06 14:13:21 +05:00
|
|
|
capabilities += "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return capabilities;
|
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
|
|
|
|
|
|
|
|
#else /* WITH_CUDA */
|
|
|
|
|
return "";
|
|
|
|
|
#endif /* WITH_CUDA */
|
2015-01-06 14:13:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|