From 56b12422da681856cf978b45f69127c392cabeb8 Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Mon, 9 Dec 2019 23:59:28 +0000 Subject: [PATCH] Implement readonly storage buffer on OpenGL backend Note that storage buffer and readonly storage buffer may not be supported in vertex shader on OpenGL backend. In OpenGL Spec 4.6, the minimum value of MAX_VERTEX_SHADER_STORAGE_BLOCKS is 0. BUG=dawn:180, dawn:284 Change-Id: Ib637a61e4eee0a0996c0da33f492e075fd94e1e7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14380 Commit-Queue: Yunchao He Reviewed-by: Austin Eng --- src/dawn_native/opengl/CommandBufferGL.cpp | 4 ++-- src/dawn_native/opengl/PipelineGL.cpp | 4 ++-- src/dawn_native/opengl/PipelineLayoutGL.cpp | 2 +- src/tests/end2end/GpuMemorySynchronizationTests.cpp | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 3993d5f107..b8052d2270 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -288,7 +288,8 @@ namespace dawn_native { namespace opengl { } } break; - case wgpu::BindingType::StorageBuffer: { + case wgpu::BindingType::StorageBuffer: + case wgpu::BindingType::ReadonlyStorageBuffer: { BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex); GLuint buffer = ToBackend(binding.buffer)->GetHandle(); GLuint ssboIndex = indices[bindingIndex]; @@ -304,7 +305,6 @@ namespace dawn_native { namespace opengl { } break; case wgpu::BindingType::StorageTexture: - case wgpu::BindingType::ReadonlyStorageBuffer: UNREACHABLE(); break; diff --git a/src/dawn_native/opengl/PipelineGL.cpp b/src/dawn_native/opengl/PipelineGL.cpp index e727e9b29d..e2808758fd 100644 --- a/src/dawn_native/opengl/PipelineGL.cpp +++ b/src/dawn_native/opengl/PipelineGL.cpp @@ -123,7 +123,8 @@ namespace dawn_native { namespace opengl { } } break; - case wgpu::BindingType::StorageBuffer: { + case wgpu::BindingType::StorageBuffer: + case wgpu::BindingType::ReadonlyStorageBuffer: { GLuint location = gl.GetProgramResourceIndex( mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str()); if (location != GL_INVALID_INDEX) { @@ -139,7 +140,6 @@ namespace dawn_native { namespace opengl { break; case wgpu::BindingType::StorageTexture: - case wgpu::BindingType::ReadonlyStorageBuffer: UNREACHABLE(); break; diff --git a/src/dawn_native/opengl/PipelineLayoutGL.cpp b/src/dawn_native/opengl/PipelineLayoutGL.cpp index 2884dfa557..530e7d0f83 100644 --- a/src/dawn_native/opengl/PipelineLayoutGL.cpp +++ b/src/dawn_native/opengl/PipelineLayoutGL.cpp @@ -50,12 +50,12 @@ namespace dawn_native { namespace opengl { break; case wgpu::BindingType::StorageBuffer: + case wgpu::BindingType::ReadonlyStorageBuffer: mIndexInfo[group][binding] = ssboIndex; ssboIndex++; 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 8bc5b342ea..2917ee8ebd 100644 --- a/src/tests/end2end/GpuMemorySynchronizationTests.cpp +++ b/src/tests/end2end/GpuMemorySynchronizationTests.cpp @@ -691,4 +691,5 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) { DAWN_INSTANTIATE_TEST(MultipleWriteThenMultipleReadTests, D3D12Backend, MetalBackend, + OpenGLBackend, VulkanBackend);