// 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 <algorithm> #include <array> #include <cstdint> #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/WGPUHelpers.h" namespace dawn { namespace { constexpr static unsigned int kRTSize = …; constexpr wgpu::TextureFormat kDefaultFormat = …; constexpr uint32_t kBytesPerTexel = …; class TextureViewTestBase : public DawnTest { … }; wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) { … } class TextureViewSamplingTest : public TextureViewTestBase { … }; // Test drawing a rect with a 2D array texture. TEST_P(TextureViewSamplingTest, Default2DArrayTexture) { … } // Test sampling a 2D array with negative signed array index. TEST_P(TextureViewSamplingTest, 2DArrayTextureSignedNegativeIndex) { … } // Test sampling cube array with negative signed array index. TEST_P(TextureViewSamplingTest, CubeArrayTextureSignedNegativeIndex) { … } // Test sampling from a 2D texture view created on a 2D array texture. TEST_P(TextureViewSamplingTest, Texture2DViewOn2DArrayTexture) { … } // Test sampling from a 2D array texture view created on a 2D array texture. TEST_P(TextureViewSamplingTest, Texture2DArrayViewOn2DArrayTexture) { … } // Test sampling from a 2D array texture view created on a 2D texture with one layer. // Regression test for crbug.com/dawn/1309. TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnSingleLayer2DTexture) { … } // Test sampling from a 2D texture view created on a mipmap level of a 2D texture. TEST_P(TextureViewSamplingTest, Texture2DViewOnOneLevelOf2DTexture) { … } // Test sampling from a 2D texture view created on a mipmap level of a 2D array texture layer. TEST_P(TextureViewSamplingTest, Texture2DViewOnOneLevelOf2DArrayTexture) { … } // Test sampling from a 2D array texture view created on a mipmap level of a 2D array texture. TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnOneLevelOf2DArrayTexture) { … } // Test that an RGBA8 texture may be interpreted as RGBA8UnormSrgb and sampled from. // More extensive color value checks and format tests are left for the CTS. TEST_P(TextureViewSamplingTest, SRGBReinterpretation) { … } // Test sampling from a cube map texture view that covers a whole 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapOnWholeTexture) { … } // Test sampling from a cube map texture view that covers a sub part of a 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapViewOnPartOfTexture) { … } // Test sampling from a cube map texture view that covers the last layer of a 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapViewCoveringLastLayer) { … } // Test sampling from a cube map texture array view that covers a whole 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapArrayOnWholeTexture) { … } // Test sampling from a cube map texture array view that covers a sub part of a 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapArrayViewOnPartOfTexture) { … } // Test sampling from a cube map texture array view that covers the last layer of a 2D array // texture. TEST_P(TextureViewSamplingTest, TextureCubeMapArrayViewCoveringLastLayer) { … } // Test sampling from a cube map array texture view that only has a single cube map. TEST_P(TextureViewSamplingTest, TextureCubeMapArrayViewSingleCubeMap) { … } class TextureViewRenderingTest : public TextureViewTestBase { … }; // Test rendering into a 2D texture view created on a mipmap level of a 2D texture. TEST_P(TextureViewRenderingTest, Texture2DViewOnALevelOf2DTextureAsColorAttachment) { … } // Test rendering into a 2D texture view created on a mipmap level of a rectangular 2D texture. TEST_P(TextureViewRenderingTest, Texture2DViewOnALevelOfRectangular2DTextureAsColorAttachment) { … } // Test rendering into a 2D texture view created on a layer of a 2D array texture. TEST_P(TextureViewRenderingTest, Texture2DViewOnALayerOf2DArrayTextureAsColorAttachment) { … } // Test rendering into a 1-layer 2D array texture view created on a mipmap level of a 2D texture. TEST_P(TextureViewRenderingTest, Texture2DArrayViewOnALevelOf2DTextureAsColorAttachment) { … } // Test rendering into a 1-layer 2D array texture view created on a layer of a 2D array texture. TEST_P(TextureViewRenderingTest, Texture2DArrayViewOnALayerOf2DArrayTextureAsColorAttachment) { … } // Test that an RGBA8 texture may be interpreted as RGBA8UnormSrgb and rendered to. // More extensive color value checks and format tests are left for the CTS. TEST_P(TextureViewRenderingTest, SRGBReinterpretationRenderAttachment) { … } // Test that an RGBA8 texture may be interpreted as RGBA8UnormSrgb and resolved to. // More extensive color value checks and format tests are left for the CTS. // This test samples the RGBA8Unorm texture into an RGBA8Unorm multisample texture viewed as SRGB, // and resolves it into an RGBA8Unorm texture, viewed as SRGB. TEST_P(TextureViewRenderingTest, SRGBReinterpretionResolveAttachment) { … } DAWN_INSTANTIATE_TEST(TextureViewSamplingTest, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); DAWN_INSTANTIATE_TEST(TextureViewRenderingTest, D3D11Backend(), D3D12Backend(), D3D12Backend({ … }; class TextureViewTest : public DawnTest { … }; // This is a regression test for crbug.com/dawn/399 where creating a texture view with only copy // usage would cause the Vulkan validation layers to warn TEST_P(TextureViewTest, OnlyCopySrcDst) { … } // Test that a texture view can be created from a destroyed texture without // backend errors. TEST_P(TextureViewTest, DestroyedTexture) { … } DAWN_INSTANTIATE_TEST(TextureViewTest, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); class TextureView3DTest : public TextureViewTestBase { … }; // Test that 3D textures and 3D texture views can be created successfully TEST_P(TextureView3DTest, BasicTest) { … } DAWN_INSTANTIATE_TEST(TextureView3DTest, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); class TextureView1DTest : public DawnTest { … }; // Test that it is possible to create a 1D texture view and sample from it. TEST_P(TextureView1DTest, Sampling) { … } DAWN_INSTANTIATE_TEST(TextureView1DTest, D3D11Backend(), D3D12Backend(), MetalBackend(), VulkanBackend(), OpenGLBackend(), OpenGLESBackend()); } // anonymous namespace } // namespace dawn