From 02fd17c75403a399672c65aa98e577c7c2ae9010 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Wed, 10 Feb 2021 02:28:17 +0000 Subject: [PATCH] Implement a toggle to disable sample variables. Sample mask variables and all functionality introduced by GL_OES_sample_variables was not made core until ES 3.2. Implement a toggle to disable the functionality if not supported by the backend. Bug: dawn:673 Change-Id: I7a5ec61fb57da343f0f72ffd3b0c69031eaaff8f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41142 Commit-Queue: Stephen White Reviewed-by: Corentin Wallez --- src/dawn_native/Toggles.cpp | 5 +++++ src/dawn_native/Toggles.h | 1 + src/dawn_native/opengl/DeviceGL.cpp | 4 ++++ src/tests/end2end/MultisampledRenderingTests.cpp | 10 ++++++---- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp index 33e23dc735..28d4777c29 100644 --- a/src/dawn_native/Toggles.cpp +++ b/src/dawn_native/Toggles.cpp @@ -134,6 +134,11 @@ namespace dawn_native { "Disables reading from depth/stencil textures which is unsupported on some " "platforms.", "https://crbug.com/dawn/667"}}, + {Toggle::DisableSampleVariables, + {"disable_sample_variables", + "Disables gl_SampleMask and related functionality which is unsupported on some " + "platforms.", + "https://crbug.com/dawn/673"}}, {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 65537a54d2..b173dd2b0c 100644 --- a/src/dawn_native/Toggles.h +++ b/src/dawn_native/Toggles.h @@ -42,6 +42,7 @@ namespace dawn_native { DisableIndexedDrawBuffers, DisableSnormRead, DisableDepthStencilRead, + DisableSampleVariables, UseD3D12SmallShaderVisibleHeapForTesting, UseDXC, DisableRobustness, diff --git a/src/dawn_native/opengl/DeviceGL.cpp b/src/dawn_native/opengl/DeviceGL.cpp index 89ddd28a68..ef7be64d3e 100644 --- a/src/dawn_native/opengl/DeviceGL.cpp +++ b/src/dawn_native/opengl/DeviceGL.cpp @@ -74,6 +74,9 @@ namespace dawn_native { namespace opengl { bool supportsDepthStencilRead = gl.IsAtLeastGL(3, 0) || gl.IsGLExtensionSupported("GL_NV_read_depth_stencil"); + bool supportsSampleVariables = gl.IsAtLeastGL(4, 0) || gl.IsAtLeastGLES(3, 2) || + gl.IsGLExtensionSupported("GL_OES_sample_variables"); + // 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. @@ -94,6 +97,7 @@ namespace dawn_native { namespace opengl { SetToggle(Toggle::DisableIndexedDrawBuffers, !supportsIndexedDrawBuffers); SetToggle(Toggle::DisableSnormRead, !supportsSnormRead); SetToggle(Toggle::DisableDepthStencilRead, !supportsDepthStencilRead); + SetToggle(Toggle::DisableSampleVariables, !supportsSampleVariables); SetToggle(Toggle::FlushBeforeClientWaitSync, gl.GetVersion().IsES()); } diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index f72938efda..ca65619833 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -736,8 +736,9 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOut // TODO(crbug.com/tint/372): Support sample mask builtin. DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator")); - // TODO(crbug.com/dawn/644): Diagnose and fix this ANGLE failure. - DAWN_SKIP_TEST_IF(IsANGLE()); + // TODO(crbug.com/dawn/672): Work around or enforce via validation that sample variables are not + // supported on some platforms. + DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_sample_variables")); constexpr bool kTestDepth = false; wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); @@ -785,8 +786,9 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut // TODO(crbug.com/tint/372): Support sample mask builtin. DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator")); - // TODO(crbug.com/dawn/644): Diagnose and fix this ANGLE failure. - DAWN_SKIP_TEST_IF(IsANGLE()); + // TODO(crbug.com/dawn/672): Work around or enforce via validation that sample variables are not + // supported on some platforms. + DAWN_SKIP_TEST_IF(HasToggleEnabled("disable_sample_variables")); wgpu::TextureView multisampledColorView2 = CreateTextureForRenderAttachment(kColorFormat, kSampleCount).CreateView();