// 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 <vector> #include "dawn/common/Assert.h" #include "dawn/tests/DawnTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" #include "partition_alloc/pointers/raw_ptr.h" namespace dawn { namespace { // Primitive topology tests work by drawing the following vertices with all the different primitive // topology states: // ------------------------------------- // | | // | 1 2 5 | // | | // | | // | | // | | // | 0 3 4 | // | | // ------------------------------------- // // Points: This case looks exactly like above // // Lines // ------------------------------------- // | | // | 1 2 5 | // | | | | | // | | | | | // | | | | | // | | | | | // | 0 3 4 | // | | // ------------------------------------- // // Line Strip // ------------------------------------- // | | // | 1--------2 5 | // | | | | | // | | | | | // | | | | | // | | | | | // | 0 3--------4 | // | | // ------------------------------------- // // Triangle // ------------------------------------- // | | // | 1--------2 5 | // | |xxxxxxx x| | // | |xxxxx xxx| | // | |xxx xxxxx| | // | |x xxxxxxx| | // | 0 3--------4 | // | | // ------------------------------------- // // Triangle Strip // ------------------------------------- // | | // | 1--------2 5 | // | |xxxxxxxxx x| | // | |xxxxxxxxxxx xxx| | // | |xxx xxxxxxxxxxx| | // | |x xxxxxxxxxx| | // | 0 3--------4 | // | | // ------------------------------------- // // Each of these different states is a superset of some of the previous states, // so for every state, we check any new added test locations that are not contained in previous // states We also check that the test locations of subsequent states are untouched constexpr static unsigned int kRTSize = …; struct TestLocation { … }; constexpr TestLocation GetMidpoint(const TestLocation& a, const TestLocation& b) noexcept { … } constexpr TestLocation GetCentroid(const TestLocation& a, const TestLocation& b, const TestLocation& c) noexcept { … } // clang-format off // Offset towards one corner to avoid x or y symmetry false positives constexpr static unsigned int kOffset = …; constexpr static TestLocation kPointTestLocations[] = …; constexpr static TestLocation kLineTestLocations[] = …; constexpr static TestLocation kLineStripTestLocations[] = …; constexpr static TestLocation kTriangleTestLocations[] = …; constexpr static TestLocation kTriangleStripTestLocations[] = …; constexpr static float kRTSizef = …; constexpr static float kVertices[] = …; // clang-format on class PrimitiveTopologyTest : public DawnTest { … }; // Test Point primitive topology TEST_P(PrimitiveTopologyTest, PointList) { … } // Test Line primitive topology TEST_P(PrimitiveTopologyTest, LineList) { … } // Test LineStrip primitive topology TEST_P(PrimitiveTopologyTest, LineStrip) { … } // Test Triangle primitive topology TEST_P(PrimitiveTopologyTest, TriangleList) { … } // Test TriangleStrip primitive topology TEST_P(PrimitiveTopologyTest, TriangleStrip) { … } DAWN_INSTANTIATE_TEST(PrimitiveTopologyTest, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); } // anonymous namespace } // namespace dawn