Workaround ANGLE hang with a glFlush().

Change-Id: Idce1b71bdb132a1b96836d270eb2ab53fd0086f8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/36700
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Stephen White 2021-01-15 16:35:49 +00:00 committed by Commit Bot service account
parent 5a6fda1a6f
commit 54449966dd
3 changed files with 11 additions and 0 deletions

View File

@ -152,6 +152,10 @@ namespace dawn_native {
{Toggle::UseTintInspector,
{"use_tint_inspector", "Use Tint instead of SPRIV-cross for shader reflection.",
"https://crbug.com/dawn/578"}},
{Toggle::FlushBeforeClientWaitSync,
{"flush_before_client_wait_sync",
"Call glFlush before glClientWaitSync to work around bugs in the latter",
"https://crbug.com/dawn/633"}},
// Dummy comment to separate the }} so it is clearer what to copy-paste to add a toggle.
}};

View File

@ -47,6 +47,7 @@ namespace dawn_native {
DisallowUnsafeAPIs,
UseTintGenerator,
UseTintInspector,
FlushBeforeClientWaitSync,
EnumCount,
InvalidEnum = EnumCount,

View File

@ -86,6 +86,7 @@ namespace dawn_native { namespace opengl {
SetToggle(Toggle::DisableBaseVertex, !supportsBaseVertex);
SetToggle(Toggle::DisableBaseInstance, !supportsBaseInstance);
SetToggle(Toggle::DisableIndexedDrawBuffers, !supportsIndexedDrawBuffers);
SetToggle(Toggle::FlushBeforeClientWaitSync, gl.GetVersion().IsES());
}
const GLFormat& Device::GetGLFormat(const Format& format) {
@ -173,6 +174,11 @@ namespace dawn_native { namespace opengl {
// Fence are added in order, so we can stop searching as soon
// as we see one that's not ready.
// TODO(crbug.com/dawn/633): Remove this workaround after the deadlock issue is fixed.
if (IsToggleEnabled(Toggle::FlushBeforeClientWaitSync)) {
gl.Flush();
}
GLenum result = gl.ClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
if (result == GL_TIMEOUT_EXPIRED) {
return fenceSerial;