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
|
|
|
|
|
|
|
|
#ifdef WITH_CUDA
|
|
|
|
|
|
|
|
|
|
# include "device/cuda/graphics_interop.h"
|
|
|
|
|
|
|
|
|
|
# include "device/cuda/device_impl.h"
|
|
|
|
|
# include "device/cuda/util.h"
|
|
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
# include "session/display_driver.h"
|
|
|
|
|
|
|
|
|
|
# ifdef _WIN32
|
|
|
|
|
# include "util/windows.h"
|
|
|
|
|
# else
|
|
|
|
|
# include <unistd.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
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
CUDADeviceGraphicsInterop::CUDADeviceGraphicsInterop(CUDADeviceQueue *queue)
|
|
|
|
|
: queue_(queue), device_(static_cast<CUDADevice *>(queue->device))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CUDADeviceGraphicsInterop::~CUDADeviceGraphicsInterop()
|
|
|
|
|
{
|
|
|
|
|
CUDAContextScope scope(device_);
|
2025-04-12 14:24:08 +02:00
|
|
|
free();
|
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
|
|
|
}
|
|
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
void CUDADeviceGraphicsInterop::set_buffer(GraphicsInteropBuffer &interop_buffer)
|
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
|
|
|
{
|
2025-05-08 22:38:55 +02:00
|
|
|
CUDAContextScope scope(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
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
if (interop_buffer.is_empty()) {
|
|
|
|
|
free();
|
|
|
|
|
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
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
need_zero_ |= interop_buffer.take_zero();
|
2025-04-12 14:24:08 +02:00
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
if (!interop_buffer.has_new_handle()) {
|
|
|
|
|
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
|
|
|
}
|
2025-04-12 14:24:08 +02:00
|
|
|
free();
|
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
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
switch (interop_buffer.get_type()) {
|
2025-04-12 14:24:08 +02:00
|
|
|
case GraphicsInteropDevice::OPENGL: {
|
2025-05-08 22:38:55 +02:00
|
|
|
const CUresult result = cuGraphicsGLRegisterBuffer(&cu_graphics_resource_,
|
|
|
|
|
interop_buffer.take_handle(),
|
|
|
|
|
CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE);
|
2025-04-12 14:24:08 +02:00
|
|
|
if (result != CUDA_SUCCESS) {
|
2025-07-10 19:44:14 +02:00
|
|
|
LOG_ERROR << "Error registering OpenGL buffer: " << cuewErrorString(result);
|
2025-05-08 22:38:55 +02:00
|
|
|
break;
|
2025-04-12 14:24:08 +02:00
|
|
|
}
|
2025-05-08 22:38:55 +02:00
|
|
|
|
|
|
|
|
buffer_size_ = interop_buffer.get_size();
|
2025-04-12 14:24:08 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2025-04-12 14:34:39 +02:00
|
|
|
case GraphicsInteropDevice::VULKAN: {
|
|
|
|
|
CUDA_EXTERNAL_MEMORY_HANDLE_DESC external_memory_handle_desc = {};
|
|
|
|
|
# ifdef _WIN32
|
2025-05-08 22:38:55 +02:00
|
|
|
/* cuImportExternalMemory will not take ownership of the handle. */
|
|
|
|
|
vulkan_windows_handle_ = interop_buffer.take_handle();
|
2025-04-12 14:34:39 +02:00
|
|
|
external_memory_handle_desc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32;
|
|
|
|
|
external_memory_handle_desc.handle.win32.handle = reinterpret_cast<void *>(
|
2025-05-08 22:38:55 +02:00
|
|
|
vulkan_windows_handle_);
|
2025-04-12 14:34:39 +02:00
|
|
|
# else
|
2025-05-08 22:38:55 +02:00
|
|
|
/* cuImportExternalMemory will take ownership of the handle. */
|
2025-04-12 14:34:39 +02:00
|
|
|
external_memory_handle_desc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD;
|
2025-05-08 22:38:55 +02:00
|
|
|
external_memory_handle_desc.handle.fd = interop_buffer.take_handle();
|
2025-04-12 14:34:39 +02:00
|
|
|
# endif
|
2025-05-08 22:38:55 +02:00
|
|
|
external_memory_handle_desc.size = interop_buffer.get_size();
|
2025-04-12 14:34:39 +02:00
|
|
|
|
2025-06-19 15:21:11 +02:00
|
|
|
CUresult result = cuImportExternalMemory(&cu_external_memory_, &external_memory_handle_desc);
|
2025-04-12 14:34:39 +02:00
|
|
|
if (result != CUDA_SUCCESS) {
|
2025-05-08 22:38:55 +02:00
|
|
|
# ifdef _WIN32
|
|
|
|
|
CloseHandle(HANDLE(vulkan_windows_handle_));
|
|
|
|
|
vulkan_windows_handle_ = 0;
|
|
|
|
|
# else
|
|
|
|
|
close(external_memory_handle_desc.handle.fd);
|
|
|
|
|
# endif
|
2025-07-10 19:44:14 +02:00
|
|
|
LOG_ERROR << "Error importing Vulkan memory: " << cuewErrorString(result);
|
2025-04-12 14:34:39 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
buffer_size_ = interop_buffer.get_size();
|
|
|
|
|
|
2025-04-12 14:34:39 +02:00
|
|
|
CUDA_EXTERNAL_MEMORY_BUFFER_DESC external_memory_buffer_desc = {};
|
|
|
|
|
external_memory_buffer_desc.size = external_memory_handle_desc.size;
|
|
|
|
|
external_memory_buffer_desc.offset = 0;
|
|
|
|
|
|
|
|
|
|
CUdeviceptr external_memory_device_ptr = 0;
|
2025-06-19 15:21:11 +02:00
|
|
|
result = cuExternalMemoryGetMappedBuffer(
|
|
|
|
|
&external_memory_device_ptr, cu_external_memory_, &external_memory_buffer_desc);
|
|
|
|
|
if (result != CUDA_SUCCESS) {
|
|
|
|
|
if (external_memory_device_ptr) {
|
|
|
|
|
cuMemFree(external_memory_device_ptr);
|
|
|
|
|
external_memory_device_ptr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-10 19:44:14 +02:00
|
|
|
LOG_ERROR << "Error mapping Vulkan memory: " << cuewErrorString(result);
|
2025-06-19 15:21:11 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-12 14:34:39 +02:00
|
|
|
cu_external_memory_ptr_ = external_memory_device_ptr;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-04-14 14:06:58 +02:00
|
|
|
case GraphicsInteropDevice::METAL:
|
2025-04-12 14:24:08 +02:00
|
|
|
case GraphicsInteropDevice::NONE:
|
|
|
|
|
break;
|
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_ptr CUDADeviceGraphicsInterop::map()
|
|
|
|
|
{
|
2025-04-12 14:34:39 +02:00
|
|
|
CUdeviceptr cu_buffer = 0;
|
|
|
|
|
|
2025-04-12 14:24:08 +02:00
|
|
|
if (cu_graphics_resource_) {
|
|
|
|
|
/* OpenGL buffer needs mapping. */
|
|
|
|
|
CUDAContextScope scope(device_);
|
|
|
|
|
size_t bytes;
|
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
|
|
|
|
2025-04-12 14:24:08 +02:00
|
|
|
cuda_device_assert(device_,
|
|
|
|
|
cuGraphicsMapResources(1, &cu_graphics_resource_, queue_->stream()));
|
|
|
|
|
cuda_device_assert(
|
|
|
|
|
device_, cuGraphicsResourceGetMappedPointer(&cu_buffer, &bytes, cu_graphics_resource_));
|
2025-04-12 14:34:39 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Vulkan buffer is always mapped. */
|
|
|
|
|
cu_buffer = cu_external_memory_ptr_;
|
|
|
|
|
}
|
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
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
if (cu_buffer && need_zero_) {
|
|
|
|
|
cuda_device_assert(device_, cuMemsetD8Async(cu_buffer, 0, buffer_size_, queue_->stream()));
|
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
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
need_zero_ = 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
|
|
|
}
|
|
|
|
|
|
2025-04-12 14:34:39 +02:00
|
|
|
return static_cast<device_ptr>(cu_buffer);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUDADeviceGraphicsInterop::unmap()
|
|
|
|
|
{
|
2025-04-12 14:24:08 +02:00
|
|
|
if (cu_graphics_resource_) {
|
|
|
|
|
CUDAContextScope scope(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
|
|
|
|
2025-04-12 14:24:08 +02:00
|
|
|
cuda_device_assert(device_,
|
|
|
|
|
cuGraphicsUnmapResources(1, &cu_graphics_resource_, queue_->stream()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CUDADeviceGraphicsInterop::free()
|
|
|
|
|
{
|
|
|
|
|
if (cu_graphics_resource_) {
|
|
|
|
|
cuda_device_assert(device_, cuGraphicsUnregisterResource(cu_graphics_resource_));
|
|
|
|
|
cu_graphics_resource_ = nullptr;
|
|
|
|
|
}
|
2025-04-12 14:34:39 +02:00
|
|
|
|
2025-06-18 19:27:44 +02:00
|
|
|
if (cu_external_memory_ptr_) {
|
|
|
|
|
cuda_device_assert(device_, cuMemFree(cu_external_memory_ptr_));
|
|
|
|
|
cu_external_memory_ptr_ = 0;
|
|
|
|
|
}
|
2025-05-08 22:38:55 +02:00
|
|
|
|
2025-06-19 15:21:11 +02:00
|
|
|
if (cu_external_memory_) {
|
|
|
|
|
cuda_device_assert(device_, cuDestroyExternalMemory(cu_external_memory_));
|
|
|
|
|
cu_external_memory_ = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-08 22:38:55 +02:00
|
|
|
# ifdef _WIN32
|
|
|
|
|
if (vulkan_windows_handle_) {
|
|
|
|
|
CloseHandle(HANDLE(vulkan_windows_handle_));
|
|
|
|
|
vulkan_windows_handle_ = 0;
|
|
|
|
|
}
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
buffer_size_ = 0;
|
|
|
|
|
|
|
|
|
|
need_zero_ = 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
|
|
#endif
|