diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-03 13:59:20 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-03 14:02:31 +0300 |
commit | 8c113a95e3536dfa0be37c9e2e924ea8172bb613 (patch) | |
tree | fc71fffa34bc552168f79efccd5bd02b14700556 /source/blender/compositor/operations/COM_TextureOperation.cpp | |
parent | ba7eb0c7b9d93987173780d5b819c7f2ec79b96e (diff) |
Make texture node threaded
Quite trivial idea -- just pass tread ID to the texture sampling function.
Implemented as a TLS to avoid passing huge amount of extra contexts around.
Should be working on all platforms, but compilation test is required.
Reviewers: juicyfruit, campbellbarton
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D1831
Diffstat (limited to 'source/blender/compositor/operations/COM_TextureOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_TextureOperation.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp index 7d1d24a9747..665bffc2c1c 100644 --- a/source/blender/compositor/operations/COM_TextureOperation.cpp +++ b/source/blender/compositor/operations/COM_TextureOperation.cpp @@ -21,6 +21,7 @@ */ #include "COM_TextureOperation.h" +#include "COM_WorkScheduler.h" #include "BLI_listbase.h" #include "BLI_threads.h" @@ -30,9 +31,7 @@ extern "C" { #include "BKE_node.h" } -static ThreadMutex mutex_lock = BLI_MUTEX_INITIALIZER; - -TextureBaseOperation::TextureBaseOperation() : SingleThreadedOperation() +TextureBaseOperation::TextureBaseOperation() : NodeOperation() { this->addInputSocket(COM_DT_VECTOR); //offset this->addInputSocket(COM_DT_VECTOR); //size @@ -63,7 +62,7 @@ void TextureBaseOperation::initExecution() { ntreeTexBeginExecTree(this->m_texture->nodetree); } - SingleThreadedOperation::initExecution(); + NodeOperation::initExecution(); } void TextureBaseOperation::deinitExecution() { @@ -78,7 +77,7 @@ void TextureBaseOperation::deinitExecution() { ntreeTexEndExecTree(this->m_texture->nodetree->execdata); } - SingleThreadedOperation::deinitExecution(); + NodeOperation::deinitExecution(); } void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]) @@ -121,12 +120,16 @@ void TextureBaseOperation::executePixelSampled(float output[4], float x, float y vec[1] = textureSize[1] * (v + textureOffset[1]); vec[2] = textureSize[2] * textureOffset[2]; - /* TODO(sergey): Need to pass thread ID to the multitex code, - * then we can avoid having mutex here. - */ - BLI_mutex_lock(&mutex_lock); - retval = multitex_ext(this->m_texture, vec, NULL, NULL, 0, &texres, m_pool, m_sceneColorManage, false); - BLI_mutex_unlock(&mutex_lock); + const int thread_id = WorkScheduler::current_thread_id(); + retval = multitex_ext(this->m_texture, + vec, + NULL, NULL, + 0, + &texres, + thread_id, + m_pool, + m_sceneColorManage, + false); if (texres.talpha) output[3] = texres.ta; |