// Copyright 2017 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 "dawn/tests/DawnTest.h" #include "dawn/common/Assert.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { constexpr uint32_t kRTSize = …; class IndexFormatTest : public DawnTest { … }; // Test that the Uint32 index format is correctly interpreted TEST_P(IndexFormatTest, Uint32) { … } // Test that the Uint16 index format is correctly interpreted TEST_P(IndexFormatTest, Uint16) { … } // Test that the index format used is the format of the last set pipeline. This is to // prevent a case in D3D12 where the index format would be captured from the last // pipeline on SetIndexBuffer. TEST_P(IndexFormatTest, ChangePipelineAfterSetIndexBuffer) { … } // Test that setting the index buffer before the pipeline works, this is important // for backends where the index format is passed inside the call to SetIndexBuffer // because it needs to be done lazily (to query the format from the last pipeline). TEST_P(IndexFormatTest, SetIndexBufferBeforeSetPipeline) { … } // Test that index buffers of multiple formats can be used with a pipeline that // doesn't use strip primitive topology. TEST_P(IndexFormatTest, SetIndexBufferDifferentFormats) { … } // Tests for primitive restart use vertices like in the drawing and draw the following // indices: 0 1 2 PRIM_RESTART 3 4 5. Then A and B should be written but not C. // |--------------| // | 0---1 | // | \ B| | // | \| | // | 3 C 2 | // | |\ | // | |A \ | // | 4---5 | // |--------------| class TriangleStripPrimitiveRestartTests : public IndexFormatTest { … }; // Test use of primitive restart with an Uint32 index format TEST_P(TriangleStripPrimitiveRestartTests, Uint32PrimitiveRestart) { … } // Same as the above test, but uses an OOB index to emulate primitive restart being disabled, // causing point C to be written to. TEST_P(TriangleStripPrimitiveRestartTests, Uint32WithoutPrimitiveRestart) { … } // Test use of primitive restart with an Uint16 index format TEST_P(TriangleStripPrimitiveRestartTests, Uint16PrimitiveRestart) { … } // Tests for primitive restart use vertices like in the drawing and draw the following // indices: 0 1 PRIM_RESTART 2 3. Then 1 and 2 should be written but not A. // |--------------| // | 3 0| // | | || // | | || // | 2 A 1| // | | // | | // | | // |--------------| class LineStripPrimitiveRestartTests : public IndexFormatTest { … }; TEST_P(LineStripPrimitiveRestartTests, Uint32PrimitiveRestart) { … } // Same as the above test, but uses an OOB index to emulate primitive restart being disabled, // causing point A to be written to. TEST_P(LineStripPrimitiveRestartTests, Uint32WithoutPrimitiveRestart) { … } TEST_P(LineStripPrimitiveRestartTests, Uint16PrimitiveRestart) { … } DAWN_INSTANTIATE_TEST(IndexFormatTest, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); DAWN_INSTANTIATE_TEST(TriangleStripPrimitiveRestartTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); DAWN_INSTANTIATE_TEST(LineStripPrimitiveRestartTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); } // anonymous namespace } // namespace dawn