// Copyright 2018 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 <array> #include <vector> #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { class TextureViewValidationTest : public ValidationTest { … }; constexpr uint32_t kWidth = …; constexpr uint32_t kHeight = …; constexpr uint32_t kDepth = …; constexpr uint32_t kDefaultMipLevels = …; constexpr wgpu::TextureFormat kDefaultTextureFormat = …; wgpu::Texture Create2DArrayTexture(wgpu::Device& device, uint32_t arrayLayerCount, uint32_t width = kWidth, uint32_t height = kHeight, uint32_t mipLevelCount = kDefaultMipLevels, uint32_t sampleCount = 1) { … } wgpu::Texture Create3DTexture(wgpu::Device& device) { … } wgpu::Texture Create1DTexture(wgpu::Device& device) { … } wgpu::Texture CreateDepthStencilTexture(wgpu::Device& device, wgpu::TextureFormat format) { … } wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) { … } // Test creating texture view on a 2D non-array texture TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2D) { … } // Test creating texture view on a 2D array texture TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) { … } // Test creating texture view on a 3D texture TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture3D) { … } // Test creating texture view on a 1D texture TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture1D) { … } // Test creating texture view on a multisampled 2D texture TEST_F(TextureViewValidationTest, CreateTextureViewOnMultisampledTexture2D) { … } // Using the "none" ("default") values validates the same as explicitly // specifying the values they're supposed to default to. // Variant for a 2D texture with more than 1 array layer. TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaults2DArray) { … } // Using the "none" ("default") values validates the same as explicitly // specifying the values they're supposed to default to. // Variant for a 2D texture with only 1 array layer. TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaults2DNonArray) { … } // Using the "none" ("default") values validates the same as explicitly // specifying the values they're supposed to default to. // Variant for a 3D texture. TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaults3D) { … } // Regression test for crbug.com/1314049. Format default depends on the aspect. // Test that computing the default does not crash if the aspect is invalid. TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsInvalidAspect) { … } // Test creating cube map texture view TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) { … } // Test the format compatibility rules when creating a texture view. TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) { … } // Test that it's valid to create a texture view from a destroyed texture TEST_F(TextureViewValidationTest, DestroyCreateTextureView) { … } // Test that the selected TextureAspects must exist in the texture format TEST_F(TextureViewValidationTest, AspectMustExist) { … } // Test that CreateErrorView creates an invalid texture view but doesn't produce an error. TEST_F(TextureViewValidationTest, CreateErrorView) { … } class D32S8TextureViewValidationTests : public ValidationTest { … }; // Test that the selected TextureAspects must exist in the Depth32FloatStencil8 texture format TEST_F(D32S8TextureViewValidationTests, AspectMustExist) { … } // Test the format compatibility rules when creating a texture view. TEST_F(D32S8TextureViewValidationTests, TextureViewFormatCompatibility) { … } } // anonymous namespace } // namespace dawn