diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-10 16:24:38 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-10 17:16:23 +0300 |
commit | b81d88a8e24574028e5a5c01e8decf6ae80a7de5 (patch) | |
tree | 335139ad04af96e38bd1dadd6bb82289ec8324ff /source | |
parent | 1a9b9dd64df72401df0263ca1e30306e5c675c6d (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/compositor/intern/COM_BufferOperation.cc | 12 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_BufferOperation.h | 1 |
2 files changed, 13 insertions, 0 deletions
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; |