// Copyright 2021 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 <limits> #include <sstream> #include <string> #include <vector> #include "dawn/tests/DawnTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { enum class CheckIndex : uint32_t { … }; } // namespace dawn template <> struct wgpu::IsWGPUBitmask<dawn::CheckIndex> { … }; namespace dawn { namespace { constexpr uint32_t kRTSize = …; enum class DrawMode { … }; bool IsIndirectDraw(DrawMode mode) { … } } // anonymous namespace namespace { class FirstIndexOffsetTests : public DawnTest { … }; void FirstIndexOffsetTests::TestVertexIndex(DrawMode mode, uint32_t firstVertex) { … } void FirstIndexOffsetTests::TestInstanceIndex(DrawMode mode, uint32_t firstInstance) { … } void FirstIndexOffsetTests::TestBothIndices(DrawMode mode, uint32_t firstVertex, uint32_t firstInstance) { … } // Conditionally tests if first/baseVertex and/or firstInstance have been correctly passed to the // vertex shader. Since vertex shaders can't write to storage buffers, we pass vertex/instance // indices to a fragment shader via u32 attributes. The fragment shader runs once and writes the // values to a storage buffer. If vertex index is used, the vertex buffer is padded with 0s. void FirstIndexOffsetTests::TestImpl(DrawMode mode, CheckIndex checkIndex, uint32_t firstVertex, uint32_t firstInstance) { … } // Test that vertex_index starts at 7 when drawn using Draw() TEST_P(FirstIndexOffsetTests, NonIndexedVertexOffset) { … } // Test that instance_index starts at 11 when drawn using Draw() TEST_P(FirstIndexOffsetTests, NonIndexedInstanceOffset) { … } // Test that vertex_index and instance_index start at 7 and 11 respectively when drawn using Draw() TEST_P(FirstIndexOffsetTests, NonIndexedBothOffset) { … } // Test that vertex_index starts at 7 when drawn using DrawIndexed() TEST_P(FirstIndexOffsetTests, IndexedVertex) { … } // Test that instance_index starts at 11 when drawn using DrawIndexed() TEST_P(FirstIndexOffsetTests, IndexedInstance) { … } // Test that vertex_index and instance_index start at 7 and 11 respectively when drawn using // DrawIndexed() TEST_P(FirstIndexOffsetTests, IndexedBothOffset) { … } // Test that vertex_index starts at 7 when drawn using DrawIndirect() TEST_P(FirstIndexOffsetTests, NonIndexedIndirectVertexOffset) { … } // Test that instance_index starts at 11 when drawn using DrawIndirect() TEST_P(FirstIndexOffsetTests, NonIndexedIndirectInstanceOffset) { … } // Test that vertex_index and instance_index start at 7 and 11 respectively when drawn using // DrawIndirect() TEST_P(FirstIndexOffsetTests, NonIndexedIndirectBothOffset) { … } // Test that vertex_index starts at 7 when drawn using DrawIndexedIndirect() TEST_P(FirstIndexOffsetTests, IndexedIndirectVertex) { … } // Test that instance_index starts at 11 when drawn using DrawIndexed() TEST_P(FirstIndexOffsetTests, IndexedIndirectInstance) { … } // Test that vertex_index and instance_index start at 7 and 11 respectively when drawn using // DrawIndexed() TEST_P(FirstIndexOffsetTests, IndexedIndirectBothOffset) { … } DAWN_INSTANTIATE_TEST(FirstIndexOffsetTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); } // anonymous namespace } // namespace dawn