Implement sampleMask in D3D12 and OpenGL.

Some tests are not enabled in D3D12 yet because SPIRV-Cross lacks
support for gl_SampleMask.

Bug: dawn:491

Change-Id: I6cce56b5d0ab883f39b8d58987246c08a23b6410
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/25580
Reviewed-by: Tomek Ponitka <tommek@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-07-23 16:26:16 +00:00 committed by Commit Bot service account
parent 4d9cadd58a
commit c7ae7a0012
4 changed files with 17 additions and 16 deletions

View File

@ -389,7 +389,7 @@ namespace dawn_native { namespace d3d12 {
descriptorD3D12.DepthStencilState = descriptorD3D12.DepthStencilState =
ComputeDepthStencilDesc(GetDepthStencilStateDescriptor()); ComputeDepthStencilDesc(GetDepthStencilStateDescriptor());
descriptorD3D12.SampleMask = UINT_MAX; descriptorD3D12.SampleMask = GetSampleMask();
descriptorD3D12.PrimitiveTopologyType = D3D12PrimitiveTopologyType(GetPrimitiveTopology()); descriptorD3D12.PrimitiveTopologyType = D3D12PrimitiveTopologyType(GetPrimitiveTopology());
descriptorD3D12.SampleDesc.Count = GetSampleCount(); descriptorD3D12.SampleDesc.Count = GetSampleCount();
descriptorD3D12.SampleDesc.Quality = 0; descriptorD3D12.SampleDesc.Quality = 0;

View File

@ -162,6 +162,7 @@ namespace dawn_native { namespace opengl {
mFunctions.Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX); mFunctions.Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
mFunctions.Enable(GL_MULTISAMPLE); mFunctions.Enable(GL_MULTISAMPLE);
mFunctions.Enable(GL_FRAMEBUFFER_SRGB); mFunctions.Enable(GL_FRAMEBUFFER_SRGB);
mFunctions.Enable(GL_SAMPLE_MASK);
mPCIInfo.name = reinterpret_cast<const char*>(mFunctions.GetString(GL_RENDERER)); mPCIInfo.name = reinterpret_cast<const char*>(mFunctions.GetString(GL_RENDERER));

View File

@ -257,6 +257,8 @@ namespace dawn_native { namespace opengl {
ApplyDepthStencilState(gl, GetDepthStencilStateDescriptor(), &persistentPipelineState); ApplyDepthStencilState(gl, GetDepthStencilStateDescriptor(), &persistentPipelineState);
gl.SampleMaski(0, GetSampleMask());
for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) { for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) {
ApplyColorState(gl, attachmentSlot, GetColorStateDescriptor(attachmentSlot)); ApplyColorState(gl, attachmentSlot, GetColorStateDescriptor(attachmentSlot));
} }

View File

@ -525,9 +525,8 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DArrayTexture) {
// Test using one multisampled color attachment with resolve target can render correctly // Test using one multisampled color attachment with resolve target can render correctly
// with a non-default sample mask. // with a non-default sample mask.
TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMask) { TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMask) {
// TODO(dawn:491): Remove this condition after enabling sampleMask usage in those // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal.
// backends. DAWN_SKIP_TEST_IF(IsMetal());
DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12());
constexpr bool kTestDepth = false; constexpr bool kTestDepth = false;
// The second and third samples are included, // The second and third samples are included,
@ -559,9 +558,8 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMask) {
// Test using one multisampled color attachment with resolve target can render correctly // Test using one multisampled color attachment with resolve target can render correctly
// with the final sample mask empty. // with the final sample mask empty.
TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithEmptyFinalSampleMask) { TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithEmptyFinalSampleMask) {
// TODO(dawn:491): Remove this condition after enabling sampleMask usage in those // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal.
// backends. DAWN_SKIP_TEST_IF(IsMetal());
DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12());
constexpr bool kTestDepth = false; constexpr bool kTestDepth = false;
// The third and fourth samples are included, // The third and fourth samples are included,
@ -593,9 +591,8 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithEmptyFinalSampleMask)
// Test doing MSAA resolve into multiple resolve targets works correctly with a non-default sample // Test doing MSAA resolve into multiple resolve targets works correctly with a non-default sample
// mask. // mask.
TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMask) { TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMask) {
// TODO(dawn:491): Remove this condition after enabling sampleMask usage in those // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal.
// backends. DAWN_SKIP_TEST_IF(IsMetal());
DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12());
wgpu::TextureView multisampledColorView2 = wgpu::TextureView multisampledColorView2 =
CreateTextureForOutputAttachment(kColorFormat, kSampleCount).CreateView(); CreateTextureForOutputAttachment(kColorFormat, kSampleCount).CreateView();
@ -635,9 +632,8 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMas
// Test multisampled rendering with depth test works correctly with a non-default sample mask. // Test multisampled rendering with depth test works correctly with a non-default sample mask.
TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndSampleMask) { TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndSampleMask) {
// TODO(dawn:491): Remove this condition after enabling sampleMask usage in those // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal.
// backends. DAWN_SKIP_TEST_IF(IsMetal());
DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12());
// TODO(dawn:491): Find out why this test doesn't work on Windows Intel Vulkan. // TODO(dawn:491): Find out why this test doesn't work on Windows Intel Vulkan.
DAWN_SKIP_TEST_IF(IsWindows() && IsIntel() && IsVulkan()); DAWN_SKIP_TEST_IF(IsWindows() && IsIntel() && IsVulkan());
@ -702,9 +698,11 @@ TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndSampleMas
// Test using one multisampled color attachment with resolve target can render correctly // Test using one multisampled color attachment with resolve target can render correctly
// with non-default sample mask and shader-output mask. // with non-default sample mask and shader-output mask.
TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOutputMask) { TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOutputMask) {
// TODO(dawn:491): Remove this condition after enabling sampleMask usage in those // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal.
// backends. DAWN_SKIP_TEST_IF(IsMetal());
DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12());
// TODO(dawn:491): Remove this when SPIRV-cross adds support for SV_Coverage in HLSL.
DAWN_SKIP_TEST_IF(IsD3D12());
constexpr bool kTestDepth = false; constexpr bool kTestDepth = false;
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();