diff --git a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp index fc0331eac6..4190164a35 100644 --- a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp +++ b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp @@ -389,7 +389,7 @@ namespace dawn_native { namespace d3d12 { descriptorD3D12.DepthStencilState = ComputeDepthStencilDesc(GetDepthStencilStateDescriptor()); - descriptorD3D12.SampleMask = UINT_MAX; + descriptorD3D12.SampleMask = GetSampleMask(); descriptorD3D12.PrimitiveTopologyType = D3D12PrimitiveTopologyType(GetPrimitiveTopology()); descriptorD3D12.SampleDesc.Count = GetSampleCount(); descriptorD3D12.SampleDesc.Quality = 0; diff --git a/src/dawn_native/opengl/BackendGL.cpp b/src/dawn_native/opengl/BackendGL.cpp index 5ce73d88b5..2d3685980e 100644 --- a/src/dawn_native/opengl/BackendGL.cpp +++ b/src/dawn_native/opengl/BackendGL.cpp @@ -162,6 +162,7 @@ namespace dawn_native { namespace opengl { mFunctions.Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX); mFunctions.Enable(GL_MULTISAMPLE); mFunctions.Enable(GL_FRAMEBUFFER_SRGB); + mFunctions.Enable(GL_SAMPLE_MASK); mPCIInfo.name = reinterpret_cast(mFunctions.GetString(GL_RENDERER)); diff --git a/src/dawn_native/opengl/RenderPipelineGL.cpp b/src/dawn_native/opengl/RenderPipelineGL.cpp index b16783ce90..441df88f8c 100644 --- a/src/dawn_native/opengl/RenderPipelineGL.cpp +++ b/src/dawn_native/opengl/RenderPipelineGL.cpp @@ -257,6 +257,8 @@ namespace dawn_native { namespace opengl { ApplyDepthStencilState(gl, GetDepthStencilStateDescriptor(), &persistentPipelineState); + gl.SampleMaski(0, GetSampleMask()); + for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) { ApplyColorState(gl, attachmentSlot, GetColorStateDescriptor(attachmentSlot)); } diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index 4e3edfd3fe..3c17acdad9 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -525,9 +525,8 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DArrayTexture) { // Test using one multisampled color attachment with resolve target can render correctly // with a non-default sample mask. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMask) { - // TODO(dawn:491): Remove this condition after enabling sampleMask usage in those - // backends. - DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12()); + // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal. + DAWN_SKIP_TEST_IF(IsMetal()); constexpr bool kTestDepth = false; // 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 // with the final sample mask empty. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithEmptyFinalSampleMask) { - // TODO(dawn:491): Remove this condition after enabling sampleMask usage in those - // backends. - DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12()); + // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal. + DAWN_SKIP_TEST_IF(IsMetal()); constexpr bool kTestDepth = false; // 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 // mask. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMask) { - // TODO(dawn:491): Remove this condition after enabling sampleMask usage in those - // backends. - DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12()); + // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal. + DAWN_SKIP_TEST_IF(IsMetal()); wgpu::TextureView multisampledColorView2 = 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_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndSampleMask) { - // TODO(dawn:491): Remove this condition after enabling sampleMask usage in those - // backends. - DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12()); + // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal. + DAWN_SKIP_TEST_IF(IsMetal()); // TODO(dawn:491): Find out why this test doesn't work on Windows Intel Vulkan. 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 // with non-default sample mask and shader-output mask. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOutputMask) { - // TODO(dawn:491): Remove this condition after enabling sampleMask usage in those - // backends. - DAWN_SKIP_TEST_IF(IsOpenGL() || IsMetal() || IsD3D12()); + // TODO(dawn:491): Remove this condition after enabling sampleMask usage in Metal. + DAWN_SKIP_TEST_IF(IsMetal()); + + // TODO(dawn:491): Remove this when SPIRV-cross adds support for SV_Coverage in HLSL. + DAWN_SKIP_TEST_IF(IsD3D12()); constexpr bool kTestDepth = false; wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();