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 <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Yunchao He 2019-12-09 23:59:28 +00:00 committed by Commit Bot service account
parent ef8dee90a7
commit 56b12422da
4 changed files with 6 additions and 5 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -691,4 +691,5 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
DAWN_INSTANTIATE_TEST(MultipleWriteThenMultipleReadTests,
D3D12Backend,
MetalBackend,
OpenGLBackend,
VulkanBackend);