// Copyright 2019 The Dawn & Tint Authors // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <algorithm> #include <array> #include <vector> #include "dawn/common/Assert.h" #include "dawn/native/DawnNative.h" #include "dawn/tests/DawnTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { enum class PipelineMultisampleLoadOp { … }; PipelineMultisampleLoadOps; class MultisampledRenderingTest : public DawnTest { … }; // Test using one multisampled color attachment with resolve target can render correctly. TEST_P(MultisampledRenderingTest, ResolveInto2DTexture) { … } // Test multisampled rendering with depth test works correctly. TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTest) { … } // Test rendering into a multisampled color attachment and doing MSAA resolve in another render pass // works correctly. TEST_P(MultisampledRenderingTest, ResolveInAnotherRenderPass) { … } // Test doing MSAA resolve into multiple resolve targets works correctly. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargets) { … } // Test that resolving only one of multiple MSAA targets works correctly. (dawn:1550) TEST_P(MultisampledRenderingTest, ResolveOneOfMultipleTargets) { … } // Test that resolving a single render target at a non-zero location works correctly. TEST_P(MultisampledRenderingTest, ResolveIntoNonZeroLocation) { … } // Test doing MSAA resolve on one multisampled texture twice works correctly. TEST_P(MultisampledRenderingTest, ResolveOneMultisampledTextureTwice) { … } // Test using a layer of a 2D texture as resolve target works correctly. TEST_P(MultisampledRenderingTest, ResolveIntoOneMipmapLevelOf2DTexture) { … } // Test using a level or a layer of a 2D array texture as resolve target works correctly. 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) { … } // Test using one multisampled color attachment with resolve target can render correctly // with the final sample mask empty. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithEmptyFinalSampleMask) { … } // Test doing MSAA resolve into multiple resolve targets works correctly with a non-default sample // mask. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMask) { … } // Test multisampled rendering with depth test works correctly with a non-default sample mask. TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndSampleMask) { … } // 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) { … } // Test doing MSAA resolve into multiple resolve targets works correctly with a non-default // shader-output mask. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOutputMask) { … } // Test using one multisampled color attachment with resolve target can render correctly // with alphaToCoverageEnabled. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithAlphaToCoverage) { … } // Test doing MSAA resolve into multiple resolve targets works correctly with // alphaToCoverage. The alphaToCoverage mask is computed based on the alpha // component of the first color render attachment. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithAlphaToCoverage) { … } // Test multisampled rendering with depth test works correctly with alphaToCoverage. TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndAlphaToCoverage) { … } // Test using one multisampled color attachment with resolve target can render correctly // with alphaToCoverageEnabled and a sample mask. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithAlphaToCoverageAndSampleMask) { … } // Test using one multisampled color attachment with resolve target can render correctly // with alphaToCoverageEnabled and a rasterization mask. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithAlphaToCoverageAndRasterizationMask) { … } class MultisampledRenderingWithTransientAttachmentTest : public MultisampledRenderingTest { … }; // Test using one multisampled color transient attachment with resolve target can render correctly. TEST_P(MultisampledRenderingWithTransientAttachmentTest, ResolveTransientAttachmentInto2DTexture) { … } class MultisampledRenderToSingleSampledTest : public MultisampledRenderingTest { … }; // Test rendering into a color attachment and start another render pass with LoadOp::Load // will have the content preserved. TEST_P(MultisampledRenderToSingleSampledTest, DrawThenLoad) { … } // Test clear a color attachment (without implicit sample count) and start another render pass (with // implicit sample count) with LoadOp::Load plus additional drawing works correctly. The final // result should contain the combination of the loaded content from 1st pass and the 2nd pass. TEST_P(MultisampledRenderToSingleSampledTest, ClearThenLoadThenDraw) { … } // Test multisampled rendering with depth test works correctly. TEST_P(MultisampledRenderToSingleSampledTest, DrawWithDepthTest) { … } class DawnLoadResolveTextureTest : public MultisampledRenderingTest { … }; // Test rendering into a resolve texture then start another render pass with // LoadOp::ExpandResolveTexture. The resolve texture will have its content preserved between // passes. TEST_P(DawnLoadResolveTextureTest, DrawThenLoad) { … } // Test using ExpandResolveTexture load op for non-zero indexed attachment. TEST_P(DawnLoadResolveTextureTest, DrawThenLoadNonZeroIndexedAttachment) { … } // Test rendering into 2 attachments. The 1st attachment will use // LoadOp::ExpandResolveTexture. TEST_P(DawnLoadResolveTextureTest, TwoOutputsDrawThenLoadColor0) { … } // Test rendering into 2 attachments. The 2nd attachment will use // LoadOp::ExpandResolveTexture. TEST_P(DawnLoadResolveTextureTest, TwoOutputsDrawThenLoadColor1) { … } // Test rendering into 2 attachments. The both attachments will use // LoadOp::ExpandResolveTexture. TEST_P(DawnLoadResolveTextureTest, TwoOutputsDrawThenLoadColor0AndColor1) { … } // Test ExpandResolveTexture load op rendering with depth test works correctly. TEST_P(DawnLoadResolveTextureTest, DrawWithDepthTest) { … } // Test ExpandResolveTexture load op rendering with depth test works correctly with // two outputs both use ExpandResolveTexture load op. TEST_P(DawnLoadResolveTextureTest, TwoOutputsDrawWithDepthTestColor0AndColor1) { … } // Test rendering into a layer of a 2D array texture and load op=LoadOp::ExpandResolveTexture. TEST_P(DawnLoadResolveTextureTest, DrawThenLoad2DArrayTextureLayer) { … } // Test RenderPassDescriptorExpandResolveRect works correctly when rendering with // LoadOp::ExpandResolveTexture. TEST_P(DawnLoadResolveTextureTest, ClearThenLoadAndDrawWithRect) { … } // Test RenderPassDescriptorExpandResolveRect works correctly with StoreOp::Discard; TEST_P(DawnLoadResolveTextureTest, StoreOpDiscardWithRect) { … } DAWN_INSTANTIATE_TEST(MultisampledRenderingTest, D3D11Backend(), D3D12Backend(), D3D12Backend({ … }; DAWN_INSTANTIATE_TEST(MultisampledRenderingWithTransientAttachmentTest, D3D11Backend(), D3D12Backend(), D3D12Backend({ … }; DAWN_INSTANTIATE_TEST(MultisampledRenderToSingleSampledTest, D3D11Backend(), D3D12Backend(), D3D12Backend({ … }; DAWN_INSTANTIATE_TEST(DawnLoadResolveTextureTest, D3D11Backend(), D3D12Backend(), D3D12Backend({ … }; } // anonymous namespace } // namespace dawn