Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2022-02-18 16:31:39 +0300
committerSergey Sharybin <sergey@blender.org>2022-02-18 17:26:15 +0300
commite4b7d52fe4fe3076f5f68ff575c200f5cf16e416 (patch)
tree28f9117767819d302ee27a57c0df79452a143fab /intern/cycles/integrator
parent02f4d63dcc7b74fbacfb4e5bcdd01766563573f5 (diff)
Fix graphics interop resources leak in Cycles
When new display driver is given to the PathTrace ensure that there are no GPU resources used from it by the work. This solves graphics interop descriptors leak. This aqlso fixes Invalid graphics context in cuGraphicsUnregisterResource error when doing final render on the display GPU. Fixes T95837: Regression: GPU memory accumulation in Cycles render Fixes T95733: Cycles Cuda/Optix error message with multi GPU devices. (Invalid graphics context in cuGraphicsUnregisterResource) Fixes T95651: GPU error (Invalid graphics context in cuGraphicsUnregisterResource) Fixes T95631: VRAM is not being freed when rendering (Invalid graphics context in cuGraphicsUnregisterResource) Fixes T89747: Cycles Render - Textures Disappear then Crashes the Render Maniphest Tasks: T95837, T95733, T95651, T95631, T89747 Differential Revision: https://developer.blender.org/D14146
Diffstat (limited to 'intern/cycles/integrator')
-rw-r--r--intern/cycles/integrator/path_trace.cpp26
-rw-r--r--intern/cycles/integrator/path_trace.h3
2 files changed, 21 insertions, 8 deletions
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index fd697836f52..d8ee1883a06 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -67,14 +67,7 @@ PathTrace::PathTrace(Device *device,
PathTrace::~PathTrace()
{
- /* Destroy any GPU resource which was used for graphics interop.
- * Need to have access to the PathTraceDisplay as it is the only source of drawing context which
- * is used for interop. */
- if (display_) {
- for (auto &&path_trace_work : path_trace_works_) {
- path_trace_work->destroy_gpu_resources(display_.get());
- }
- }
+ destroy_gpu_resources();
}
void PathTrace::load_kernels()
@@ -572,6 +565,11 @@ void PathTrace::set_output_driver(unique_ptr<OutputDriver> driver)
void PathTrace::set_display_driver(unique_ptr<DisplayDriver> driver)
{
+ /* The display driver is the source of the drawing context which might be used by
+ * path trace works. Make sure there is no graphics interop using resources from
+ * the old display, as it might no longer be available after this call. */
+ destroy_gpu_resources();
+
if (driver) {
display_ = make_unique<PathTraceDisplay>(move(driver));
}
@@ -1088,6 +1086,18 @@ bool PathTrace::has_denoised_result() const
return render_state_.has_denoised_result;
}
+void PathTrace::destroy_gpu_resources()
+{
+ /* Destroy any GPU resource which was used for graphics interop.
+ * Need to have access to the PathTraceDisplay as it is the only source of drawing context which
+ * is used for interop. */
+ if (display_) {
+ for (auto &&path_trace_work : path_trace_works_) {
+ path_trace_work->destroy_gpu_resources(display_.get());
+ }
+ }
+}
+
/* --------------------------------------------------------------------
* Report generation.
*/
diff --git a/intern/cycles/integrator/path_trace.h b/intern/cycles/integrator/path_trace.h
index bb41c8c3210..7849d69b646 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -239,6 +239,9 @@ class PathTrace {
void progress_set_status(const string &status, const string &substatus = "");
+ /* Destroy GPU resources (such as graphics interop) used by work. */
+ void destroy_gpu_resources();
+
/* Pointer to a device which is configured to be used for path tracing. If multiple devices
* are configured this is a `MultiDevice`. */
Device *device_ = nullptr;