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 <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Stephen White 2021-02-10 02:28:17 +00:00 committed by Commit Bot service account
parent 39b478df0c
commit 02fd17c754
4 changed files with 16 additions and 4 deletions

View File

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

View File

@ -42,6 +42,7 @@ namespace dawn_native {
DisableIndexedDrawBuffers,
DisableSnormRead,
DisableDepthStencilRead,
DisableSampleVariables,
UseD3D12SmallShaderVisibleHeapForTesting,
UseDXC,
DisableRobustness,

View File

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

View File

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