From 8413f80efbea65d4a8bda9dfd81108c876a2380b Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Sun, 27 Feb 2022 20:28:05 -0500 Subject: [PATCH] gl_graphics_pipeline: Replace GetSync calls with non-blocking waits The spec states that a ClientWait on a Fence object ensures the changes propagate to the calling context --- .../renderer_opengl/gl_graphics_pipeline.cpp | 10 ++++++---- src/video_core/renderer_opengl/gl_graphics_pipeline.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp index 93f8b0d3f0..9e6732abd4 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp @@ -587,16 +587,18 @@ void GraphicsPipeline::WaitForBuild() { is_built = true; } -bool GraphicsPipeline::IsBuilt() const noexcept { +bool GraphicsPipeline::IsBuilt() noexcept { if (is_built) { return true; } if (built_fence.handle == 0) { return false; } - GLint sync_status{}; - glGetSynciv(built_fence.handle, GL_SYNC_STATUS, 1, nullptr, &sync_status); - return sync_status == GL_SIGNALED; + // Timeout of zero means this is non-blocking + const auto sync_status = glClientWaitSync(built_fence.handle, 0, 0); + ASSERT(sync_status != GL_WAIT_FAILED); + is_built = sync_status != GL_TIMEOUT_EXPIRED; + return is_built; } } // namespace OpenGL diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.h b/src/video_core/renderer_opengl/gl_graphics_pipeline.h index 2aea43ac9e..311d49f3ff 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.h +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.h @@ -100,7 +100,7 @@ public: return writes_global_memory; } - [[nodiscard]] bool IsBuilt() const noexcept; + [[nodiscard]] bool IsBuilt() noexcept; template static auto MakeConfigureSpecFunc() {