GL: enable ANGLE's EGLContext hardening.

This is a subset of EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE that
should improve robustness but not limit functionality.

Bug: 517307966
Change-Id: Iae5a10f7aa628cb993e7209802c74087b44fe127
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/313135
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/dawn/native/opengl/ContextEGL.cpp b/src/dawn/native/opengl/ContextEGL.cpp
index 0bc3be5..5e94123 100644
--- a/src/dawn/native/opengl/ContextEGL.cpp
+++ b/src/dawn/native/opengl/ContextEGL.cpp
@@ -50,10 +50,15 @@
 #endif
 
 // https://chromium.googlesource.com/angle/angle/+/main/extensions/EGL_ANGLE_context_virtualization.txt
-#ifndef EGL_ANGLE_context_virtualization
+#ifndef EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE
 #define EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE 0x3481
 #endif
 
+// https://chromium.googlesource.com/angle/angle/+/main/extensions/EGL_ANGLE_create_context_webgl_compatibility.txt
+#ifndef EGL_CONTEXT_HARDENED_ANGLE
+#define EGL_CONTEXT_HARDENED_ANGLE 0x34F8
+#endif
+
 namespace dawn::native::opengl {
 
 namespace {
@@ -191,6 +196,10 @@
         AddAttrib(EGL_CONTEXT_VIRTUALIZATION_GROUP_ANGLE, angleVirtualizationGroup);
     }
 
+    if (egl.HasExt(EGLExt::ANGLECreateContextWebGLCompatibility)) {
+        AddAttrib(EGL_CONTEXT_HARDENED_ANGLE, EGL_TRUE);
+    }
+
     // The attrib list is finished with an EGL_NONE tag.
     attribs.push_back(EGL_NONE);
 
diff --git a/src/dawn/native/opengl/EGLFunctions.cpp b/src/dawn/native/opengl/EGLFunctions.cpp
index 0f65edc..9e812b8 100644
--- a/src/dawn/native/opengl/EGLFunctions.cpp
+++ b/src/dawn/native/opengl/EGLFunctions.cpp
@@ -97,6 +97,8 @@
      NeverPromoted, ExtType::Display},
     {EGLExt::ANGLEContextVirtualization, "EGL_ANGLE_context_virtualization", NeverPromoted,
      ExtType::Display},
+    {EGLExt::ANGLECreateContextWebGLCompatibility, "EGL_ANGLE_create_context_webgl_compatibility",
+     NeverPromoted, ExtType::Display},
     //
 }};
 
diff --git a/src/dawn/native/opengl/EGLFunctions.h b/src/dawn/native/opengl/EGLFunctions.h
index 4e95914..e0cbab8 100644
--- a/src/dawn/native/opengl/EGLFunctions.h
+++ b/src/dawn/native/opengl/EGLFunctions.h
@@ -69,6 +69,7 @@
     ANGLECreateContextBackwardsCompatible,  // EGL_ANGLE_create_context_backwards_compatible
     ANGLECreateContextExtensionsEnabled,    // EGL_ANGLE_create_context_extensions_enabled
     ANGLEContextVirtualization,             // EGL_ANGLE_context_virtualization
+    ANGLECreateContextWebGLCompatibility,   // EGL_ANGLE_create_context_webgl_compatibility
 
     EnumCount,
 };