From f8a1041e99af4b86f7c550b736f87e8586df1a74 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Mon, 6 May 2019 01:10:16 +0000 Subject: [PATCH] Check OpenGL passed fences with glClientWaitSync() This patch fixes an issue in the check of passed OpenGL fences. Currently Dawn checks if an OpenGL fence is passed with glGetSynciv(sync, GL_SYNC_CONDITION, sizeof(GLint), &length, &status), which always returns GL_SYNC_GPU_COMMANDS_COMPLETE and is meaningless. This patch uses glClientWaitSync() to check if a fence is passed instead. BUG=dawn:137 Change-Id: Iff6b18bcc7155b06bde98ff68c7ed104a27bfe55 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6800 Reviewed-by: Kai Ninomiya Reviewed-by: Corentin Wallez Commit-Queue: Jiawei Shao --- src/dawn_native/opengl/DeviceGL.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/dawn_native/opengl/DeviceGL.cpp b/src/dawn_native/opengl/DeviceGL.cpp index dcaf9169ae..a287f48409 100644 --- a/src/dawn_native/opengl/DeviceGL.cpp +++ b/src/dawn_native/opengl/DeviceGL.cpp @@ -125,15 +125,11 @@ namespace dawn_native { namespace opengl { GLsync sync = mFencesInFlight.front().first; Serial fenceSerial = mFencesInFlight.front().second; - GLint status = 0; - GLsizei length; - glGetSynciv(sync, GL_SYNC_CONDITION, sizeof(GLint), &length, &status); - ASSERT(length == 1); - // Fence are added in order, so we can stop searching as soon // as we see one that's not ready. - if (!status) { - return; + GLenum result = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0); + if (result == GL_TIMEOUT_EXPIRED) { + continue; } glDeleteSync(sync);