[Bf-blender-cvs] [5ae9e4e08d3] cycles-x: Fix wrong order of graphics interop destruction

Sergey Sharybin noreply at git.blender.org
Wed Apr 28 19:50:12 CEST 2021


Commit: 5ae9e4e08d37227a847bfedd3a670d9dd1c7e5e2
Author: Sergey Sharybin
Date:   Wed Apr 28 19:47:41 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB5ae9e4e08d37227a847bfedd3a670d9dd1c7e5e2

Fix wrong order of graphics interop destruction

The GPU display needs to be destroyed after path trace works, otherwise
the CUDA interop resource destruction will error with an invalid graphics
context.

Additionally, added guards to ensure the CUDA graphics interop object is
never copied.

===================================================================

M	intern/cycles/device/cuda/device_impl.cpp
M	intern/cycles/integrator/path_trace.h

===================================================================

diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp
index 28cb0bd9596..0e7f88291cc 100644
--- a/intern/cycles/device/cuda/device_impl.cpp
+++ b/intern/cycles/device/cuda/device_impl.cpp
@@ -1333,6 +1333,9 @@ class CUDADeviceGraphicsInterop : public DeviceGraphicsInterop {
   {
   }
 
+  CUDADeviceGraphicsInterop(const CUDADeviceGraphicsInterop &other) = delete;
+  CUDADeviceGraphicsInterop(CUDADeviceGraphicsInterop &&other) noexcept = delete;
+
   ~CUDADeviceGraphicsInterop()
   {
     CUDAContextScope scope(device_);
@@ -1342,6 +1345,9 @@ class CUDADeviceGraphicsInterop : public DeviceGraphicsInterop {
     }
   }
 
+  CUDADeviceGraphicsInterop &operator=(const CUDADeviceGraphicsInterop &other) = delete;
+  CUDADeviceGraphicsInterop &operator=(CUDADeviceGraphicsInterop &&other) = delete;
+
   virtual void set_destination(const DeviceGraphicsInteropDestination &destination) override
   {
     const int64_t new_buffer_area = int64_t(destination.buffer_width) * destination.buffer_height;
diff --git a/intern/cycles/integrator/path_trace.h b/intern/cycles/integrator/path_trace.h
index f1ef4fc6396..a4f1fa4df4c 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -170,6 +170,8 @@ class PathTrace {
 
   RenderScheduler &render_scheduler_;
 
+  unique_ptr<GPUDisplay> gpu_display_;
+
   /* Per-compute device descriptors of work which is responsible for path tracing on its configured
    * device. */
   vector<unique_ptr<PathTraceWork>> path_trace_works_;
@@ -218,8 +220,6 @@ class PathTrace {
     thread_condition_variable condition;
   } render_cancel_;
 
-  unique_ptr<GPUDisplay> gpu_display_;
-
   /* Indicates whether a render result was drawn after latest session reset.
    * Used by `ready_to_reset()` to implement logic which feels the most interactive. */
   bool did_draw_after_reset_ = true;



More information about the Bf-blender-cvs mailing list