use mutexes to prevent threads from interfering with each other while sharing shaders

This commit is contained in:
itsmattkc
2019-12-10 01:45:39 +11:00
parent da3ff98774
commit 1f5ae6f9bd
3 changed files with 22 additions and 2 deletions
+7 -2
View File
@@ -157,6 +157,8 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const NodeValueDatabase
buffer_.Bind();
// Lock the shader so no other thread interferes as we set parameters and draw (and we don't interfere with any others)
shader->Lock();
shader->bind();
unsigned int input_texture_count = 0;
@@ -266,6 +268,11 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const NodeValueDatabase
// Blit this texture through this shader
olive::gl::Blit(shader);
// Make sure all OpenGL functions are complete by this point before unlocking the shader (or another thread may
// change its parameters before our drawing in this thread is done)
functions_->glFinish();
shader->Unlock();
// Release any textures we bound before
while (input_texture_count > 0) {
input_texture_count--;
@@ -281,8 +288,6 @@ void OpenGLWorker::RunNodeAccelerated(const Node *node, const NodeValueDatabase
buffer_.Detach();
functions_->glFinish();
output_params->Push(NodeParam::kTexture, QVariant::fromValue(output));
}