From 8c3558d65e5d8b54cee5be124d12f5e293f6dd1a Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 4 Dec 2021 19:00:39 -0500 Subject: [PATCH] hal/gles: try robustness extension first before the core --- wgpu-hal/src/gles/egl.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 96bf0d81a..b131aa072 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -416,15 +416,21 @@ impl Inner { } } if needs_robustness { - if version >= (1, 5) { - log::info!("\tEGL context: +robust access"); - context_attributes.push(egl::CONTEXT_OPENGL_ROBUST_ACCESS); - context_attributes.push(egl::TRUE as _); - } else if display_extensions.contains("EGL_EXT_create_context_robustness") { + //Note: we specifically check the extension first, and then the core. + // This is because the core version can fail if robustness is not supported + // (regardless of whether the extension is supported!). + // In fact, Angle does precisely that awful behavior. + if display_extensions.contains("EGL_EXT_create_context_robustness") { log::info!("\tEGL context: +robust access EXT"); context_attributes.push(EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT); context_attributes.push(egl::TRUE as _); + } else if version >= (1, 5) { + log::info!("\tEGL context: +robust access"); + context_attributes.push(egl::CONTEXT_OPENGL_ROBUST_ACCESS); + context_attributes.push(egl::TRUE as _); } else { + //Note: we aren't trying `EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR` + // because it's for desktop GL only, not GLES. log::warn!("\tEGL context: -robust access"); }