[Bf-blender-cvs] [b81d88a8e24] master: Compositor: Fix memory leaks when initializing tiles multi-threaded

Manuel Castilla noreply at git.blender.org
Tue Aug 10 16:26:16 CEST 2021


Commit: b81d88a8e24574028e5a5c01e8decf6ae80a7de5
Author: Manuel Castilla
Date:   Tue Aug 10 15:24:38 2021 +0200
Branches: master
https://developer.blender.org/rBb81d88a8e24574028e5a5c01e8decf6ae80a7de5

Compositor: Fix memory leaks when initializing tiles multi-threaded

It was only affecting tiled fallback on full frame mode. If tiles from a
constant operation were multi-thread initialized, its buffer
was inflated multiple times.

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

M	source/blender/compositor/intern/COM_BufferOperation.cc
M	source/blender/compositor/intern/COM_BufferOperation.h

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

diff --git a/source/blender/compositor/intern/COM_BufferOperation.cc b/source/blender/compositor/intern/COM_BufferOperation.cc
index e1f566b19db..cafdff89c8e 100644
--- a/source/blender/compositor/intern/COM_BufferOperation.cc
+++ b/source/blender/compositor/intern/COM_BufferOperation.cc
@@ -41,20 +41,32 @@ const float *BufferOperation::get_constant_elem()
   return buffer_->getBuffer();
 }
 
+void BufferOperation::initExecution()
+{
+  if (buffer_->is_a_single_elem()) {
+    initMutex();
+  }
+}
+
 void *BufferOperation::initializeTileData(rcti * /*rect*/)
 {
   if (buffer_->is_a_single_elem() == false) {
     return buffer_;
   }
 
+  lockMutex();
   if (!inflated_buffer_) {
     inflated_buffer_ = buffer_->inflate();
   }
+  unlockMutex();
   return inflated_buffer_;
 }
 
 void BufferOperation::deinitExecution()
 {
+  if (buffer_->is_a_single_elem()) {
+    deinitMutex();
+  }
   delete inflated_buffer_;
 }
 
diff --git a/source/blender/compositor/intern/COM_BufferOperation.h b/source/blender/compositor/intern/COM_BufferOperation.h
index 705264c37b7..b4cbc0a56b6 100644
--- a/source/blender/compositor/intern/COM_BufferOperation.h
+++ b/source/blender/compositor/intern/COM_BufferOperation.h
@@ -32,6 +32,7 @@ class BufferOperation : public ConstantOperation {
 
   const float *get_constant_elem() override;
   void *initializeTileData(rcti *rect) override;
+  void initExecution() override;
   void deinitExecution() override;
   void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
   void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]) override;



More information about the Bf-blender-cvs mailing list