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.vfx@gmail.com>2013-01-21 12:49:42 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-01-21 12:49:42 +0400
commit86991fbcb0e8a1c65acff5aed85ce55f8b108baa (patch)
treee39d2b4203e18052fea58691d3920093905f47dc /source/blender/compositor/operations
parent2b9ab8781d95609f529c2d5dcf770c82d23afe17 (diff)
Fixed render time regression in Blender Internal
It was caused by image threading safe commit and it was noticeable only on really multi-core CPU (like dual-socket Xeon stations), was not visible on core i7 machine. The reason of slowdown was spinlock around image buffer referencing, which lead to lots of cores waiting for single core and using image buffer after it was referenced was not so much longer than doing reference itself. The most clear solution here seemed to be introducing Image Pool which will contain list of loaded and referenced image buffers, so all threads could skip lock if the pool is used for reading only. Lock only needed in cases when buffer for requested image user is missing in the pool. This lock will happen only once per image so overall amount of locks is much less that it was before. To operate with pool: - BKE_image_pool_new() creates new pool - BKE_image_pool_free() destroys pool and dereferences all image buffers which were loaded to it - BKE_image_pool_acquire_ibuf() returns image buffer for given image and user. Pool could be NULL and in this case fallback to BKE_image_acquire_ibuf will happen. This helps to avoid lots to if(poll) checks in image sampling code. - BKE_image_pool_release_ibuf releases image buffer. In fact, it will only do something if pool is NULL, in all other case it'll equal to DoNothing operation.
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index f8d6c0cfc01..23a3abe61ee 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -23,6 +23,7 @@
#include "COM_TextureOperation.h"
#include "BLI_listbase.h"
+#include "BKE_image.h"
TextureBaseOperation::TextureBaseOperation() : NodeOperation()
{
@@ -46,11 +47,14 @@ void TextureBaseOperation::initExecution()
{
this->m_inputOffset = getInputSocketReader(0);
this->m_inputSize = getInputSocketReader(1);
+ this->m_pool = BKE_image_pool_new();
}
void TextureBaseOperation::deinitExecution()
{
this->m_inputSize = NULL;
this->m_inputOffset = NULL;
+ BKE_image_pool_free(this->m_pool);
+ this->m_pool = NULL;
}
void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
@@ -95,7 +99,7 @@ void TextureBaseOperation::executePixel(float output[4], float x, float y, Pixel
vec[1] = textureSize[1] * (v + textureOffset[1]);
vec[2] = textureSize[2] * textureOffset[2];
- retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres);
+ retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres, m_pool);
if (texres.talpha)
output[3] = texres.ta;
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index f8435ecdaa2..227ad37579a 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -45,6 +45,7 @@ private:
const RenderData *m_rd;
SocketReader *m_inputSize;
SocketReader *m_inputOffset;
+ struct ImagePool *m_pool;
protected: