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 <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2019-05-06 01:10:16 +00:00 committed by Commit Bot service account
parent f54bb68f47
commit f8a1041e99
1 changed files with 3 additions and 7 deletions

View File

@ -125,15 +125,11 @@ namespace dawn_native { namespace opengl {
GLsync sync = mFencesInFlight.front().first; GLsync sync = mFencesInFlight.front().first;
Serial fenceSerial = mFencesInFlight.front().second; 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 // Fence are added in order, so we can stop searching as soon
// as we see one that's not ready. // as we see one that's not ready.
if (!status) { GLenum result = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
return; if (result == GL_TIMEOUT_EXPIRED) {
continue;
} }
glDeleteSync(sync); glDeleteSync(sync);