// 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 <algorithm> #include <limits> #include <string> #include <vector> #include "dawn/common/Math.h" #include "dawn/common/Platform.h" #include "dawn/tests/DawnTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { class MaxLimitTests : public DawnTest { … }; // Test using the maximum amount of workgroup memory works TEST_P(MaxLimitTests, MaxComputeWorkgroupStorageSize) { … } // Test using the maximum uniform/storage buffer binding size works TEST_P(MaxLimitTests, MaxBufferBindingSize) { … } // Test using the maximum number of dynamic uniform and storage buffers TEST_P(MaxLimitTests, MaxDynamicBuffers) { … } // Test using the maximum number of storage buffers per shader stage. TEST_P(MaxLimitTests, MaxStorageBuffersPerShaderStage) { … } // Test that creating a large bind group, with each binding type at the max count, works and can be // used correctly. The test loads a different value from each binding, and writes 1 to a storage // buffer if all values are correct. TEST_P(MaxLimitTests, ReallyLargeBindGroup) { … } // Verifies that devices can write to the limits specified for fragment outputs. This test // exercises an internal Vulkan maxFragmentCombinedOutputResources limit and makes sure that the // sub parts of the limit work as intended. TEST_P(MaxLimitTests, WriteToMaxFragmentCombinedOutputResources) { … } // Verifies that supported buffer limits do not exceed maxBufferSize. TEST_P(MaxLimitTests, MaxBufferSizes) { … } DAWN_INSTANTIATE_TEST(MaxLimitTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); // Verifies the limits maxInterStageShaderVariables and maxInterStageShaderComponents work correctly class MaxInterStageLimitTests : public MaxLimitTests { … }; // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with no built-in variables. TEST_P(MaxInterStageLimitTests, NoBuiltins) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with @builtin(sample_mask). On D3D SV_Coverage doesn't consume an independent float4 // register. TEST_P(MaxInterStageLimitTests, SampleMask) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with @builtin(sample_index). On D3D SV_SampleIndex consumes an independent float4 // register. TEST_P(MaxInterStageLimitTests, SampleIndex) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with @builtin(front_facing). On D3D SV_IsFrontFace consumes an independent float4 // register. TEST_P(MaxInterStageLimitTests, FrontFacing) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with @builtin(front_facing). On D3D SV_IsFrontFace and SV_SampleIndex consume one // independent float4 register. TEST_P(MaxInterStageLimitTests, SampleIndex_FrontFacing) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with @builtin(sample_mask), // @builtin(sample_index) and @builtin(front_facing). TEST_P(MaxInterStageLimitTests, SampleMask_SampleIndex_FrontFacing) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with PointList primitive topology. On Vulkan when the primitive topology is PointList, // the SPIR-V builtin PointSize must be declared in vertex shader, which will consume 1 inter-stage // shader component. TEST_P(MaxInterStageLimitTests, RenderPointList) { … } // Tests that both maxInterStageShaderComponents and maxInterStageShaderVariables work for a render // pipeline with PointList primitive topology, @builtin(sample_mask), // @builtin(sample_index) and @builtin(front_facing). TEST_P(MaxInterStageLimitTests, RenderPointList_SampleMask_SampleIndex_FrontFacing) { … } DAWN_INSTANTIATE_TEST(MaxInterStageLimitTests, D3D11Backend(), D3D12Backend({ … }; // Verifies the limit maxVertexAttributes work correctly on the creation of render pipelines. class MaxVertexAttributesPipelineCreationTests : public MaxLimitTests { … }; // Tests that maxVertexAttributes work for the creation of the render pipelines with no built-in // input variables. TEST_P(MaxVertexAttributesPipelineCreationTests, NoBuiltinInputs) { … } // Tests that maxVertexAttributes work for the creation of the render pipelines with // @builtin(vertex_index). TEST_P(MaxVertexAttributesPipelineCreationTests, VertexIndex) { … } // Tests that maxVertexAttributes work for the creation of the render pipelines with // @builtin(instance_index). TEST_P(MaxVertexAttributesPipelineCreationTests, InstanceIndex) { … } // Tests that maxVertexAttributes work for the creation of the render pipelines with // @builtin(vertex_index) and @builtin(instance_index). TEST_P(MaxVertexAttributesPipelineCreationTests, VertexIndex_InstanceIndex) { … } DAWN_INSTANTIATE_TEST(MaxVertexAttributesPipelineCreationTests, D3D11Backend(), D3D12Backend({ … }; } // anonymous namespace } // namespace dawn