gl_graphics_pipeline: Make built_fence access threadsafe

This commit is contained in:
ameerj
2022-02-27 17:12:33 -05:00
parent 19b24b1b7a
commit cb9d3c78c5

View File

@@ -251,9 +251,13 @@ GraphicsPipeline::GraphicsPipeline(
break;
}
}
built_fence.Create();
// Flush this context to ensure compilation commands and fence are in the GPU pipe.
glFlush();
{
std::lock_guard lock{built_mutex};
built_fence.Create();
// Flush this context to ensure compilation commands and fence are in the GPU pipe.
glFlush();
built_condvar.notify_one();
}
if (shader_notify) {
shader_notify->MarkShaderComplete();
}
@@ -572,6 +576,10 @@ void GraphicsPipeline::GenerateTransformFeedbackState() {
}
void GraphicsPipeline::WaitForBuild() {
if (built_fence.handle == 0) {
std::unique_lock lock{built_mutex};
built_condvar.wait(lock, [this] { return built_fence.handle != 0; });
}
ASSERT(glClientWaitSync(built_fence.handle, 0, GL_TIMEOUT_IGNORED) != GL_WAIT_FAILED);
is_built = true;
}