OpenGL: skip depth and stencil tests if readback is unsupported.

Add appropriate toggles.

Change-Id: I99906d1622f4c30b364ba8a9d7d808faa0203e1d
Bug: dawn:667
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88360
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White 2022-04-29 11:57:45 +00:00 committed by Dawn LUCI CQ
parent 2fb28e008d
commit a734f81922
4 changed files with 33 additions and 4 deletions

View File

@ -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 "

View File

@ -44,6 +44,8 @@ namespace dawn::native {
DisableBaseInstance,
DisableIndexedDrawBuffers,
DisableSnormRead,
DisableDepthRead,
DisableStencilRead,
DisableDepthStencilRead,
DisableBGRARead,
DisableSampleVariables,

View File

@ -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);

View File

@ -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},