Skip testing of stencil textures where non-readable.

Readback of stencil is not supported on vanilla ES, so we introduce a toggle to disable it. NVidia GLES drivers support NV_stencil_read and NV_depth_stencil_read extensions, so we use those where available.

It turns out ANGLE supports NV_stencil_read but not NV_depth_stencil_read (for reading from the packed depth/stencil buffers which Dawn uses), so that's the extension we check for.

Bug: dawn:667 dawn:634
Change-Id: I136674d3d47fecee2b8b390d5d219bab07e3bb64
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41141
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/tests/end2end/DepthStencilCopyTests.cpp b/src/tests/end2end/DepthStencilCopyTests.cpp
index 799eb9b..2fd7258 100644
--- a/src/tests/end2end/DepthStencilCopyTests.cpp
+++ b/src/tests/end2end/DepthStencilCopyTests.cpp
@@ -330,8 +330,9 @@
 
 // Test copying the stencil-only aspect into a buffer.
 TEST_P(DepthStencilCopyTests, FromStencilAspect) {
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around the fact that some platforms are unable to read
+    // stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     constexpr uint32_t kWidth = 4;
     constexpr uint32_t kHeight = 4;
@@ -358,8 +359,8 @@
     // It passes on AMD Radeon Pro and Intel HD Graphics 630.
     DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
 
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around some platforms' inability to read back stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     wgpu::Texture depthStencilTexture = CreateDepthStencilTexture(
         9, 9, wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc, 2);
@@ -403,8 +404,8 @@
     // T2TBothAspectsThenCopyNonRenderableStencil does not use RenderAttachment and works correctly.
     DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
 
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around some platforms' inability to read back stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     constexpr uint32_t kWidth = 4;
     constexpr uint32_t kHeight = 4;
@@ -427,8 +428,8 @@
 // Test that part of a non-renderable stencil aspect can be copied. Notably,
 // this test has different behavior on some platforms than T2TBothAspectsThenCopyStencil.
 TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyNonRenderableStencil) {
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around some platforms' inability to read back stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     constexpr uint32_t kWidth = 4;
     constexpr uint32_t kHeight = 4;
@@ -456,8 +457,8 @@
     // T2TBothAspectsThenCopyNonRenderableStencil works correctly.
     DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
 
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around some platforms' inability to read back stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     wgpu::Texture texture = CreateInitializeDepthStencilTextureAndCopyT2T(
         0.1f, 0.3f, 1u, 3u, 9, 9, wgpu::TextureUsage::CopySrc, 1);
@@ -508,8 +509,8 @@
 
 // Test copying both aspects in a T2T copy, then copying stencil, then copying depth
 TEST_P(DepthStencilCopyTests, T2TBothAspectsThenCopyStencilThenDepth) {
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around some platforms' inability to read back stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     constexpr uint32_t kWidth = 4;
     constexpr uint32_t kHeight = 4;
@@ -547,8 +548,9 @@
     // T2TBothAspectsThenCopyStencilThenDepth which checks stencil first also passes.
     DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
 
-    // TODO(crbug.com/dawn/634): Diagnose and fix ANGLE failure.
-    DAWN_SKIP_TEST_IF(IsANGLE());
+    // TODO(crbug.com/dawn/667): Work around the fact that some platforms are unable to read
+    // stencil.
+    DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_depth_stencil_read"));
 
     constexpr uint32_t kWidth = 4;
     constexpr uint32_t kHeight = 4;