// 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 <tuple> #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 { class GpuMemorySyncTests : public DawnTest { … }; // Clear storage buffer with zero. Then read data, add one, and write the result to storage buffer // in compute pass. Iterate this read-add-write steps per compute pass a few time. The successive // iteration reads the result in buffer from last iteration, which makes the iterations a data // dependency chain. The test verifies that data in buffer among iterations in compute passes is // correctly synchronized. TEST_P(GpuMemorySyncTests, ComputePass) { … } // Clear storage buffer with zero. Then read data, add one, and write the result to storage buffer // in render pass. Iterate this read-add-write steps per render pass a few time. The successive // iteration reads the result in buffer from last iteration, which makes the iterations a data // dependency chain. In addition, color output by fragment shader depends on the data in storage // buffer, so we can check color in render target to verify that data in buffer among iterations in // render passes is correctly synchronized. TEST_P(GpuMemorySyncTests, RenderPass) { … } // Write into a storage buffer in a render pass. Then read that data in a compute // pass. And verify the data flow is correctly synchronized. TEST_P(GpuMemorySyncTests, RenderPassToComputePass) { … } // Write into a storage buffer in a compute pass. Then read that data in a render // pass. And verify the data flow is correctly synchronized. TEST_P(GpuMemorySyncTests, ComputePassToRenderPass) { … } DAWN_INSTANTIATE_TEST(…); class StorageToUniformSyncTests : public DawnTest { … }; // Write into a storage buffer in compute pass in a command buffer. Then read that data in a render // pass. The two passes use the same command buffer. TEST_P(StorageToUniformSyncTests, ReadAfterWriteWithSameCommandBuffer) { … } // Write into a storage buffer in compute pass in a command buffer. Then read that data in a render // pass. The two passes use the different command buffers. The command buffers are submitted to the // queue in one shot. TEST_P(StorageToUniformSyncTests, ReadAfterWriteWithDifferentCommandBuffers) { … } // Write into a storage buffer in compute pass in a command buffer. Then read that data in a render // pass. The two passes use the different command buffers. The command buffers are submitted to the // queue separately. TEST_P(StorageToUniformSyncTests, ReadAfterWriteWithDifferentQueueSubmits) { … } DAWN_INSTANTIATE_TEST(StorageToUniformSyncTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); constexpr int kRTSize = …; constexpr int kVertexBufferStride = …; class MultipleWriteThenMultipleReadTests : public DawnTest { … }; // Write into a few storage buffers in compute pass. Then read that data in a render pass. The // readonly buffers in render pass include vertex buffer, index buffer, uniform buffer, and readonly // storage buffer. Data to be read in all of these buffers in render pass depend on the write // operation in compute pass. TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) { … } // Write into a storage buffer in compute pass. Then read that data in buffer in a render pass. The // buffer is composed of vertices, indices, uniforms and readonly storage. Data to be read in the // buffer in render pass depend on the write operation in compute pass. TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) { … } DAWN_INSTANTIATE_TEST(MultipleWriteThenMultipleReadTests, D3D11Backend(), D3D12Backend(), MetalBackend(), OpenGLBackend(), OpenGLESBackend(), VulkanBackend()); } // anonymous namespace } // namespace dawn