// Copyright 2022 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 <memory> #include <string_view> #include "dawn/tests/DawnTest.h" #include "dawn/tests/mocks/platform/CachingInterfaceMock.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { NiceMock; // TODO(dawn:549) Add some sort of pipeline descriptor repository to test more caching. static constexpr std::string_view kComputeShaderDefault = …; static constexpr std::string_view kComputeShaderMultipleEntryPoints = …; static constexpr std::string_view kVertexShaderDefault = …; static constexpr std::string_view kVertexShaderMultipleEntryPoints = …; static constexpr std::string_view kFragmentShaderDefault = …; static constexpr std::string_view kFragmentShaderMultipleOutput = …; static constexpr std::string_view kFragmentShaderBindGroup00Uniform = …; static constexpr std::string_view kFragmentShaderBindGroup01Uniform = …; class PipelineCachingTests : public DawnTest { … }; class SinglePipelineCachingTests : public PipelineCachingTests { … }; // Tests that pipeline creation works fine even if the cache is disabled. // Note: This tests needs to use more than 1 device since the frontend cache on each device // will prevent going out to the blob cache. TEST_P(SinglePipelineCachingTests, ComputePipelineNoCache) { … } // Tests that pipeline creation on the same device uses frontend cache when possible. TEST_P(SinglePipelineCachingTests, ComputePipelineFrontedCache) { … } // Tests that pipeline creation hits the cache when it is enabled. // Note: This test needs to use more than 1 device since the frontend cache on each device // will prevent going out to the blob cache. TEST_P(SinglePipelineCachingTests, ComputePipelineBlobCache) { … } // Tests that pipeline creation hits the cache when using the same pipeline but with explicit // layout. TEST_P(SinglePipelineCachingTests, ComputePipelineBlobCacheExplictLayout) { … } // Tests that pipeline creation wouldn't hit the cache if the pipelines are not exactly the same. TEST_P(SinglePipelineCachingTests, ComputePipelineBlobCacheShaderNegativeCases) { … } // Tests that pipeline creation does not hits the cache when it is enabled but we use different // isolation keys. TEST_P(SinglePipelineCachingTests, ComputePipelineBlobCacheIsolationKey) { … } // Tests that pipeline creation works fine even if the cache is disabled. // Note: This tests needs to use more than 1 device since the frontend cache on each device // will prevent going out to the blob cache. TEST_P(SinglePipelineCachingTests, RenderPipelineNoCache) { … } // Tests that pipeline creation on the same device uses frontend cache when possible. TEST_P(SinglePipelineCachingTests, RenderPipelineFrontedCache) { … } // Tests that pipeline creation hits the cache when it is enabled. // Note: This test needs to use more than 1 device since the frontend cache on each device // will prevent going out to the blob cache. TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCache) { … } // Tests that pipeline creation hits the cache when using the same pipeline but with explicit // layout. TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCacheExplictLayout) { … } // Tests that pipeline creation wouldn't hit the cache if the pipelines have different state set in // the descriptor. TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCacheDescriptorNegativeCases) { … } // Tests that pipeline creation wouldn't hit the cache if the pipelines are not exactly the same in // terms of shader. TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCacheShaderNegativeCases) { … } // Tests that pipeline creation wouldn't hit the cache if the pipelines are not exactly the same // (fragment color targets differences). TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCacheNegativeCasesFragmentColorTargets) { … } // Tests that pipeline creation hits the cache for shaders, but not the pipeline if the // shaders aren't impacted by the layout. This test is a bit change detecting - but all // cached backends currently remap shader bindings based on the layout. It can be split // per-backend as needed. TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCacheLayout) { … } // Tests that pipeline creation does not hits the cache when it is enabled but we use different // isolation keys. TEST_P(SinglePipelineCachingTests, RenderPipelineBlobCacheIsolationKey) { … } DAWN_INSTANTIATE_TEST(SinglePipelineCachingTests, D3D11Backend(), D3D12Backend(), D3D12Backend({ … }; } // anonymous namespace } // namespace dawn