diff --git a/src/dawn/native/Toggles.cpp b/src/dawn/native/Toggles.cpp index 8f229703f1..f9f39a789d 100644 --- a/src/dawn/native/Toggles.cpp +++ b/src/dawn/native/Toggles.cpp @@ -142,6 +142,14 @@ namespace dawn::native { {"disable_snorm_read", "Disables reading from Snorm textures which is unsupported on some platforms.", "https://crbug.com/dawn/667"}}, + {Toggle::DisableDepthRead, + {"disable_depth_read", + "Disables reading from depth textures which is unsupported on some platforms.", + "https://crbug.com/dawn/667"}}, + {Toggle::DisableStencilRead, + {"disable_stencil_read", + "Disables reading from stencil 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 " diff --git a/src/dawn/native/Toggles.h b/src/dawn/native/Toggles.h index 0b47221d51..d9748fb45a 100644 --- a/src/dawn/native/Toggles.h +++ b/src/dawn/native/Toggles.h @@ -44,6 +44,8 @@ namespace dawn::native { DisableBaseInstance, DisableIndexedDrawBuffers, DisableSnormRead, + DisableDepthRead, + DisableStencilRead, DisableDepthStencilRead, DisableBGRARead, DisableSampleVariables, diff --git a/src/dawn/native/opengl/DeviceGL.cpp b/src/dawn/native/opengl/DeviceGL.cpp index 3d95b1b663..c520ab1c25 100644 --- a/src/dawn/native/opengl/DeviceGL.cpp +++ b/src/dawn/native/opengl/DeviceGL.cpp @@ -71,6 +71,12 @@ namespace dawn::native::opengl { bool supportsSnormRead = gl.IsAtLeastGL(4, 4) || gl.IsGLExtensionSupported("GL_EXT_render_snorm"); + bool supportsDepthRead = + gl.IsAtLeastGL(3, 0) || gl.IsGLExtensionSupported("GL_NV_read_depth"); + + bool supportsStencilRead = + gl.IsAtLeastGL(3, 0) || gl.IsGLExtensionSupported("GL_NV_read_stencil"); + bool supportsDepthStencilRead = gl.IsAtLeastGL(3, 0) || gl.IsGLExtensionSupported("GL_NV_read_depth_stencil"); @@ -100,6 +106,8 @@ namespace dawn::native::opengl { SetToggle(Toggle::DisableBaseInstance, !supportsBaseInstance); SetToggle(Toggle::DisableIndexedDrawBuffers, !supportsIndexedDrawBuffers); SetToggle(Toggle::DisableSnormRead, !supportsSnormRead); + SetToggle(Toggle::DisableDepthRead, !supportsDepthRead); + SetToggle(Toggle::DisableStencilRead, !supportsStencilRead); SetToggle(Toggle::DisableDepthStencilRead, !supportsDepthStencilRead); SetToggle(Toggle::DisableBGRARead, !supportsBGRARead); SetToggle(Toggle::DisableSampleVariables, !supportsSampleVariables); diff --git a/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp b/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp index 365b150e1d..2b98552765 100644 --- a/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp +++ b/src/dawn/tests/end2end/NonzeroTextureCreationTests.cpp @@ -108,11 +108,22 @@ namespace { GetParam().mMipCount > 1 && HasToggleEnabled("disable_r8_rg8_mipmaps")); - // TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support - // reading from depth/stencil. + // TODO(crbug.com/dawn/667): ANGLE claims to support NV_read_stencil, but won't read + // correctly from a DEPTH32F_STENCIL8 texture. DAWN_SUPPRESS_TEST_IF(GetParam().mFormat == wgpu::TextureFormat::Depth24PlusStencil8 && GetParam().mAspect == wgpu::TextureAspect::StencilOnly && - HasToggleEnabled("disable_depth_stencil_read")); + IsANGLE()); + + // TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support + // reading depth. + DAWN_TEST_UNSUPPORTED_IF(GetParam().mAspect == wgpu::TextureAspect::DepthOnly && + HasToggleEnabled("disable_depth_read")); + + // TODO(crbug.com/dawn/667): Work around the fact that some platforms do not support + // reading stencil. + DAWN_TEST_UNSUPPORTED_IF(GetParam().mAspect == wgpu::TextureAspect::StencilOnly && + HasToggleEnabled("disable_stencil_read")); + // GL may support the feature, but reading data back is not implemented. DAWN_TEST_UNSUPPORTED_IF(GetParam().mFormat == wgpu::TextureFormat::BC1RGBAUnorm && (IsOpenGL() || IsOpenGLES())); @@ -362,7 +373,7 @@ DAWN_INSTANTIATE_TEST_P(NonzeroDepthTextureCreationTests, VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}, {"lazy_clear_resource_on_first_use"})}, {wgpu::TextureFormat::Depth32Float}, - {wgpu::TextureAspect::All}, + {wgpu::TextureAspect::DepthOnly}, {wgpu::TextureUsage(wgpu::TextureUsage::RenderAttachment | wgpu::TextureUsage::CopySrc), wgpu::TextureUsage::CopySrc},