// Copyright 2019 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 <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 { // The helper struct to configure the copies between buffers and textures. struct CopyConfig { … }; TextureFormat; DAWN_TEST_PARAM_STRUCT(…); class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureFormatTestParams> { … }; // Test copying into the whole texture with 2x2 blocks and sampling from it. TEST_P(CompressedTextureFormatTest, Basic) { … } // Test copying into the whole cube texture with 2x2 blocks and sampling from it. // Made for compatibility mode. TEST_P(CompressedTextureFormatTest, Cube) { … } // Test copying into a sub-region of a texture works correctly. TEST_P(CompressedTextureFormatTest, CopyIntoSubRegion) { … } // Test copying into the non-zero layer of a 2D array texture works correctly. TEST_P(CompressedTextureFormatTest, CopyIntoNonZeroArrayLayer) { … } // Test copying into a non-zero mipmap level of a texture. TEST_P(CompressedTextureFormatTest, CopyBufferIntoNonZeroMipmapLevel) { … } // Test texture-to-texture whole-size copies. TEST_P(CompressedTextureFormatTest, CopyWholeTextureSubResourceIntoNonZeroMipmapLevel) { … } // Test texture-to-texture partial copies where the physical size of the destination subresource is // different from its virtual size. TEST_P(CompressedTextureFormatTest, CopyIntoSubresourceWithPhysicalSizeNotEqualToVirtualSize) { … } // Test texture-to-texture partial copies where the physical size of the source subresource is // different from its virtual size. TEST_P(CompressedTextureFormatTest, CopyFromSubresourceWithPhysicalSizeNotEqualToVirtualSize) { … } // Test recording two texture-to-texture partial copies where the physical size of the source // subresource is different from its virtual size into one command buffer. TEST_P(CompressedTextureFormatTest, MultipleCopiesWithPhysicalSizeNotEqualToVirtualSize) { … } // A regression test for a bug for the toggle UseTemporaryBufferInCompressedTextureToTextureCopy on // Vulkan backend: test texture-to-texture partial copies with multiple array layers where the // physical size of the source subresource is different from its virtual size. TEST_P(CompressedTextureFormatTest, CopyWithMultipleLayerAndPhysicalSizeNotEqualToVirtualSize) { … } // Test the special case of the B2T copies on the D3D12 backend that the buffer offset and texture // extent exactly fit the RowPitch. TEST_P(CompressedTextureFormatTest, BufferOffsetAndExtentFitRowPitch) { … } // Test the special case of the B2T copies on the D3D12 backend that the buffer offset exceeds the // slice pitch (slicePitch = bytesPerRow * (rowsPerImage / blockHeightInTexels)). On D3D12 // backend the texelOffset.y will be greater than 0 after calcuting the texelOffset in the function // ComputeTexelOffsets(). TEST_P(CompressedTextureFormatTest, BufferOffsetExceedsSlicePitch) { … } // Test the special case of the B2T copies on the D3D12 backend that the buffer offset and texture // extent exceed the RowPitch. On D3D12 backend two copies are required for this case. TEST_P(CompressedTextureFormatTest, CopyWithBufferOffsetAndExtentExceedRowPitch) { … } // Test the special case of the B2T copies on the D3D12 backend that the slicePitch is equal to the // bytesPerRow. On D3D12 backend the texelOffset.z will be greater than 0 after calcuting the // texelOffset in the function ComputeTexelOffsets(). TEST_P(CompressedTextureFormatTest, RowPitchEqualToSlicePitch) { … } // Test the workaround in the B2T copies when (bufferSize - bufferOffset < bytesPerImage * // copyExtent.depthOrArrayLayers) on Metal backends. As copyExtent.depthOrArrayLayers can only be 1 // for compressed formats, on Metal backend we will use two copies to implement such copy. TEST_P(CompressedTextureFormatTest, LargeImageHeight) { … } // Test the workaround in the B2T copies when (bufferSize - bufferOffset < bytesPerImage * // copyExtent.depthOrArrayLayers) and copyExtent needs to be clamped. TEST_P(CompressedTextureFormatTest, LargeImageHeightAndClampedCopyExtent) { … } // Test copying a whole 2D array texture with array layer count > 1 in one copy command works with // compressed formats. TEST_P(CompressedTextureFormatTest, CopyWhole2DArrayTexture) { … } // Test copying a multiple 2D texture array layers in one copy command works. TEST_P(CompressedTextureFormatTest, CopyMultiple2DArrayLayers) { … } DAWN_INSTANTIATE_TEST_P(…); // Suite of regression tests that target specific compression types. class CompressedTextureFormatSpecificTest : public DawnTest { … }; // Testing a special code path: clearing a non-renderable texture when DynamicUploader // is unaligned doesn't throw validation errors. TEST_P(CompressedTextureFormatSpecificTest, BC1RGBAUnorm_UnalignedDynamicUploader) { … } DAWN_INSTANTIATE_TEST(…); class CompressedTextureWriteTextureTest : public CompressedTextureFormatTest { … }; // Test WriteTexture to a 2D texture with all parameters non-defaults. TEST_P(CompressedTextureWriteTextureTest, Basic) { … } // Test writing to multiple 2D texture array layers. TEST_P(CompressedTextureWriteTextureTest, WriteMultiple2DArrayLayers) { … } // Test writing textures where the physical size of the destination subresource is different from // its virtual size. TEST_P(CompressedTextureWriteTextureTest, WriteIntoSubresourceWithPhysicalSizeNotEqualToVirtualSize) { … } DAWN_INSTANTIATE_TEST_P(…); } // anonymous namespace } // namespace dawn