From ef8dee90a7e6e5531ad95c758f33bc7c5fe9691f Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Mon, 9 Dec 2019 21:35:38 +0000 Subject: [PATCH] Implement readonly storage buffer on Metal backend BUG=dawn:180, dawn:284 Change-Id: I07358e5817faa85a0695a7c44db7b6472307d101 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14360 Commit-Queue: Yunchao He Reviewed-by: Austin Eng --- src/dawn_native/metal/CommandBufferMTL.mm | 4 ++-- src/dawn_native/metal/PipelineLayoutMTL.mm | 2 +- src/tests/end2end/GpuMemorySynchronizationTests.cpp | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index 38294dd63c..3f935872eb 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -453,7 +453,8 @@ namespace dawn_native { namespace metal { switch (layout.types[bindingIndex]) { case wgpu::BindingType::UniformBuffer: - case wgpu::BindingType::StorageBuffer: { + case wgpu::BindingType::StorageBuffer: + case wgpu::BindingType::ReadonlyStorageBuffer: { const BufferBinding& binding = group->GetBindingAsBufferBinding(bindingIndex); const id buffer = ToBackend(binding.buffer)->GetMTLBuffer(); @@ -527,7 +528,6 @@ namespace dawn_native { namespace metal { } break; case wgpu::BindingType::StorageTexture: - case wgpu::BindingType::ReadonlyStorageBuffer: UNREACHABLE(); break; } diff --git a/src/dawn_native/metal/PipelineLayoutMTL.mm b/src/dawn_native/metal/PipelineLayoutMTL.mm index dc528915c3..1d3e22088d 100644 --- a/src/dawn_native/metal/PipelineLayoutMTL.mm +++ b/src/dawn_native/metal/PipelineLayoutMTL.mm @@ -41,6 +41,7 @@ namespace dawn_native { namespace metal { switch (groupInfo.types[binding]) { case wgpu::BindingType::UniformBuffer: case wgpu::BindingType::StorageBuffer: + case wgpu::BindingType::ReadonlyStorageBuffer: mIndexInfo[stage][group][binding] = bufferIndex; bufferIndex++; break; @@ -53,7 +54,6 @@ namespace dawn_native { namespace metal { textureIndex++; break; case wgpu::BindingType::StorageTexture: - case wgpu::BindingType::ReadonlyStorageBuffer: UNREACHABLE(); break; } diff --git a/src/tests/end2end/GpuMemorySynchronizationTests.cpp b/src/tests/end2end/GpuMemorySynchronizationTests.cpp index 69f506ba46..8bc5b342ea 100644 --- a/src/tests/end2end/GpuMemorySynchronizationTests.cpp +++ b/src/tests/end2end/GpuMemorySynchronizationTests.cpp @@ -688,4 +688,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) { EXPECT_PIXEL_RGBA8_EQ(RGBA8::kYellow, renderPass.color, max, max); } -DAWN_INSTANTIATE_TEST(MultipleWriteThenMultipleReadTests, D3D12Backend, VulkanBackend); +DAWN_INSTANTIATE_TEST(MultipleWriteThenMultipleReadTests, + D3D12Backend, + MetalBackend, + VulkanBackend);