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/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp
index 2d53489..33e23dc 100644
--- a/src/dawn_native/Toggles.cpp
+++ b/src/dawn_native/Toggles.cpp
@@ -129,6 +129,11 @@
{"disable_snorm_read",
"Disables reading from Snorm textures which is unsupported on some platforms.",
"https://crbug.com/dawn/667"}},
+ {Toggle::DisableDepthStencilRead,
+ {"disable_depth_stencil_read",
+ "Disables reading from depth/stencil textures which is unsupported on some "
+ "platforms.",
+ "https://crbug.com/dawn/667"}},
{Toggle::UseD3D12SmallShaderVisibleHeapForTesting,
{"use_d3d12_small_shader_visible_heap",
"Enable use of a small D3D12 shader visible heap, instead of using a large one by "
diff --git a/src/dawn_native/Toggles.h b/src/dawn_native/Toggles.h
index 6988210..65537a5 100644
--- a/src/dawn_native/Toggles.h
+++ b/src/dawn_native/Toggles.h
@@ -41,6 +41,7 @@
DisableBaseInstance,
DisableIndexedDrawBuffers,
DisableSnormRead,
+ DisableDepthStencilRead,
UseD3D12SmallShaderVisibleHeapForTesting,
UseDXC,
DisableRobustness,
diff --git a/src/dawn_native/opengl/DeviceGL.cpp b/src/dawn_native/opengl/DeviceGL.cpp
index 49256a2..89ddd28 100644
--- a/src/dawn_native/opengl/DeviceGL.cpp
+++ b/src/dawn_native/opengl/DeviceGL.cpp
@@ -71,6 +71,9 @@
bool supportsSnormRead =
gl.IsAtLeastGL(4, 4) || gl.IsGLExtensionSupported("GL_EXT_render_snorm");
+ bool supportsDepthStencilRead =
+ gl.IsAtLeastGL(3, 0) || gl.IsGLExtensionSupported("GL_NV_read_depth_stencil");
+
// TODO(crbug.com/dawn/343): We can support the extension variants, but need to load the EXT
// procs without the extension suffix.
// We'll also need emulation of shader builtins gl_BaseVertex and gl_BaseInstance.
@@ -90,6 +93,7 @@
SetToggle(Toggle::DisableBaseInstance, !supportsBaseInstance);
SetToggle(Toggle::DisableIndexedDrawBuffers, !supportsIndexedDrawBuffers);
SetToggle(Toggle::DisableSnormRead, !supportsSnormRead);
+ SetToggle(Toggle::DisableDepthStencilRead, !supportsDepthStencilRead);
SetToggle(Toggle::FlushBeforeClientWaitSync, gl.GetVersion().IsES());
}
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;