// Copyright 2020 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 <string> #include <vector> #include "dawn/common/Assert.h" #include "dawn/common/Constants.h" #include "dawn/common/Math.h" #include "dawn/tests/DawnTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/TestUtils.h" #include "dawn/utils/TextureUtils.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { class StorageTextureTests : public DawnTest { … }; // Test that write-only storage textures are supported in compute shader. TEST_P(StorageTextureTests, WriteonlyStorageTextureInComputeShader) { … } // Test that write-only storage textures are supported in fragment shader. TEST_P(StorageTextureTests, WriteonlyStorageTextureInFragmentShader) { … } // Verify 2D array and 3D write-only storage textures work correctly. TEST_P(StorageTextureTests, Writeonly2DArrayOr3DStorageTexture) { … } // Verify 1D write-only storage textures work correctly. TEST_P(StorageTextureTests, Writeonly1DStorageTexture) { … } // Test that multiple dispatches to increment values by ping-ponging between a sampled texture and // a write-only storage texture are synchronized in one pass. TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) { … } DAWN_INSTANTIATE_TEST(StorageTextureTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); class BGRA8UnormStorageTextureTests : public StorageTextureTests { … }; // Test that BGRA8Unorm is supported to be used as storage texture in compute shaders when the // optional feature 'bgra8unorm-storage' is supported. TEST_P(BGRA8UnormStorageTextureTests, WriteonlyStorageTextureInComputeShader) { … } // Test that BGRA8Unorm is supported to be used as storage texture in fragment shaders when the // optional feature 'bgra8unorm-storage' is supported. TEST_P(BGRA8UnormStorageTextureTests, WriteonlyStorageTextureInFragmentShader) { … } DAWN_INSTANTIATE_TEST(BGRA8UnormStorageTextureTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); class R8UnormStorageTextureTests : public StorageTextureTests { … }; // Test that R8Unorm is supported to be used as storage texture in compute shaders when the // optional feature 'r8unorm-storage' is supported. TEST_P(R8UnormStorageTextureTests, WriteonlyStorageTextureInComputeShader) { … } // Test that R8Unorm is supported to be used as storage texture in fragment shaders when the // optional feature 'r8unorm-storage' is supported. TEST_P(R8UnormStorageTextureTests, WriteonlyStorageTextureInFragmentShader) { … } DAWN_INSTANTIATE_TEST(R8UnormStorageTextureTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); class StorageTextureZeroInitTests : public StorageTextureTests { … }; // Verify that the texture is correctly cleared to 0 before its first usage as a write-only storage // storage texture in a render pass. TEST_P(StorageTextureZeroInitTests, WriteonlyStorageTextureClearsToZeroInRenderPass) { … } // Verify that the texture is correctly cleared to 0 before its first usage as a write-only storage // texture in a compute pass. TEST_P(StorageTextureZeroInitTests, WriteonlyStorageTextureClearsToZeroInComputePass) { … } DAWN_INSTANTIATE_TEST(…); class ReadWriteStorageTextureTests : public StorageTextureTests { … }; // Verify read-write storage texture can work correctly in compute shaders. TEST_P(ReadWriteStorageTextureTests, ReadWriteStorageTextureInComputeShader) { … } // Verify read-write storage texture can work correctly in fragment shaders. TEST_P(ReadWriteStorageTextureTests, ReadWriteStorageTextureInFragmentShader) { … } // Verify read-only storage texture can work correctly in compute shaders. TEST_P(ReadWriteStorageTextureTests, ReadOnlyStorageTextureInComputeShader) { … } // Verify read-only storage texture can work correctly in vertex shaders. TEST_P(ReadWriteStorageTextureTests, ReadOnlyStorageTextureInVertexShader) { … } // Verify read-only storage texture can work correctly in fragment shaders. TEST_P(ReadWriteStorageTextureTests, ReadOnlyStorageTextureInFragmentShader) { … } // Verify using read-write storage texture access in pipeline layout is compatible with write-only // storage texture access in shader. TEST_P(ReadWriteStorageTextureTests, ReadWriteInPipelineLayoutAndWriteOnlyInShader) { … } DAWN_INSTANTIATE_TEST(ReadWriteStorageTextureTests, D3D11Backend(), D3D12Backend(), OpenGLBackend(), OpenGLESBackend(), MetalBackend(), VulkanBackend()); } // anonymous namespace } // namespace dawn