// 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 <vector> #include "dawn/common/Math.h" #include "dawn/tests/DawnTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/TestUtils.h" #include "dawn/utils/WGPUHelpers.h" namespace dawn { namespace { #define EXPECT_LAZY_CLEAR(N, statement) … struct BufferZeroInitInCopyT2BSpec { … }; class BufferZeroInitTest : public DawnTest { … }; // Test that calling writeBuffer to overwrite the entire buffer doesn't need to lazily initialize // the destination buffer. TEST_P(BufferZeroInitTest, WriteBufferToEntireBuffer) { … } // Test that calling writeBuffer to overwrite a part of buffer needs to lazily initialize the // destination buffer. TEST_P(BufferZeroInitTest, WriteBufferToSubBuffer) { … } // Test that the code path of CopyBufferToBuffer clears the source buffer correctly when it is the // first use of the source buffer. TEST_P(BufferZeroInitTest, CopyBufferToBufferSource) { … } // Test that the code path of CopyBufferToBuffer clears the destination buffer correctly when it is // the first use of the destination buffer. TEST_P(BufferZeroInitTest, CopyBufferToBufferDestination) { … } // Test that the code path of readable buffer mapping clears the buffer correctly when it is the // first use of the buffer. TEST_P(BufferZeroInitTest, MapAsync_Read) { … } // Test that the code path of writable buffer mapping clears the buffer correctly when it is the // first use of the buffer. TEST_P(BufferZeroInitTest, MapAsync_Write) { … } // Test that the code path of creating a buffer with BufferDescriptor.mappedAtCreation == true // clears the buffer correctly at the creation of the buffer. TEST_P(BufferZeroInitTest, MappedAtCreation) { … } // Test that the code path of CopyBufferToTexture clears the source buffer correctly when it is the // first use of the buffer. TEST_P(BufferZeroInitTest, CopyBufferToTexture) { … } // Test that the code path of CopyTextureToBuffer clears the destination buffer correctly when it is // the first use of the buffer and the texture is a 2D non-array texture. TEST_P(BufferZeroInitTest, Copy2DTextureToBuffer) { … } // Test that the code path of CopyTextureToBuffer clears the destination buffer correctly when it is // the first use of the buffer and the texture is a 2D array texture. TEST_P(BufferZeroInitTest, Copy2DArrayTextureToBuffer) { … } // Test that the buffer will be lazy initialized correctly when its first use is to be bound as a // uniform buffer. TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) { … } // Test that the buffer will be lazy initialized correctly when its first use is to be bound as a // read-only storage buffer. TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) { … } // Test that the buffer will be lazy initialized correctly when its first use is to be bound as a // storage buffer. TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) { … } // Test the buffer will be lazily initialized correctly when its first use is in SetVertexBuffer. TEST_P(BufferZeroInitTest, SetVertexBuffer) { … } // Test for crbug.com/dawn/837. // Test that the padding after a buffer allocation is initialized to 0. // This test makes an unaligned vertex buffer which should be padded in the backend // allocation. It then tries to index off the end of the vertex buffer in an indexed // draw call. A backend which implements robust buffer access via clamping should // still see zeros at the end of the buffer. TEST_P(BufferZeroInitTest, PaddingInitialized) { … } // Test the buffer will be lazily initialized correctly when its first use is in SetIndexBuffer. TEST_P(BufferZeroInitTest, SetIndexBuffer) { … } // Test the buffer will be lazily initialized correctly when its first use is an indirect buffer for // DrawIndirect. TEST_P(BufferZeroInitTest, IndirectBufferForDrawIndirect) { … } // Test the buffer will be lazily initialized correctly when its first use is an indirect buffer for // DrawIndexedIndirect. TEST_P(BufferZeroInitTest, IndirectBufferForDrawIndexedIndirect) { … } // Test the buffer will be lazily initialized correctly when its first use is an indirect buffer for // DispatchIndirect. TEST_P(BufferZeroInitTest, IndirectBufferForDispatchIndirect) { … } // Test the buffer will be lazily initialized correctly when its first use is in resolveQuerySet TEST_P(BufferZeroInitTest, ResolveQuerySet) { … } DAWN_INSTANTIATE_TEST(BufferZeroInitTest, D3D11Backend({ … }; } // anonymous namespace } // namespace dawn