From c6ce5785d0215c679798a4a71dc0bbc705c65cf6 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Thu, 28 Oct 2021 11:49:28 +0000 Subject: [PATCH] GLSL: don't emit "set=" layout qualifier. Only Vulkan-flavoured GLSL has these. Dawn will have to pack everything into the binding= decoration for OpenGL. Bug: 1223 Change-Id: I7ffdbc1b2f37e176411c41e4ff65b93b8f0f5ec6 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67640 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Stephen White --- src/writer/glsl/generator_impl.cc | 6 ++--- .../glsl/generator_impl_function_test.cc | 18 +++++++-------- .../generator_impl_member_accessor_test.cc | 22 +++++++++---------- .../glsl/generator_impl_sanitizer_test.cc | 6 ++--- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index 1b2422b31c..80db771f28 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -1553,8 +1553,7 @@ bool GeneratorImpl::EmitUniformVariable(const sem::Variable* var) { return false; } ast::VariableBindingPoint bp = decl->BindingPoint(); - line() << "layout (set = " << bp.group->value - << ", binding = " << bp.binding->value << ") uniform " + line() << "layout (binding = " << bp.binding->value << ") uniform " << UniqueIdentifier(StructName(str)) << " {"; EmitStructMembers(current_buffer_, str); auto name = builder_.Symbols().NameFor(decl->symbol); @@ -1573,8 +1572,7 @@ bool GeneratorImpl::EmitStorageVariable(const sem::Variable* var) { return false; } ast::VariableBindingPoint bp = decl->BindingPoint(); - line() << "layout (set = " << bp.group->value - << ", binding = " << bp.binding->value << ") buffer " + line() << "layout (binding = " << bp.binding->value << ") buffer " << UniqueIdentifier(StructName(str)) << " {"; EmitStructMembers(current_buffer_, str); auto name = builder_.Symbols().NameFor(decl->symbol); diff --git a/src/writer/glsl/generator_impl_function_test.cc b/src/writer/glsl/generator_impl_function_test.cc index c8d9279efb..0cd8b97aa2 100644 --- a/src/writer/glsl/generator_impl_function_test.cc +++ b/src/writer/glsl/generator_impl_function_test.cc @@ -434,7 +434,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) uniform UBO_1 { +layout (binding = 0) uniform UBO_1 { vec4 coord; } ubo; @@ -484,7 +484,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) uniform Uniforms_1 { +layout (binding = 0) uniform Uniforms_1 { vec4 coord; } uniforms; @@ -535,7 +535,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { int a; float b; } coord; @@ -587,7 +587,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { int a; float b; } coord; @@ -635,7 +635,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { int a; float b; } coord; @@ -684,7 +684,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { int a; float b; } coord; @@ -735,7 +735,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) uniform S_1 { +layout (binding = 0) uniform S_1 { float x; } coord; @@ -791,7 +791,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 1, binding = 0) buffer S_1 { +layout (binding = 0) buffer S_1 { float x; } coord; @@ -1057,7 +1057,7 @@ TEST_F(GlslGeneratorImplTest_Function, precision mediump float; -layout (set = 0, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { float d; } data; diff --git a/src/writer/glsl/generator_impl_member_accessor_test.cc b/src/writer/glsl/generator_impl_member_accessor_test.cc index a17ed153fb..cf5b9b7f6f 100644 --- a/src/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/writer/glsl/generator_impl_member_accessor_test.cc @@ -297,7 +297,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_Matrix_Empty) { precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { int a; mat2x3 b; } data; @@ -343,7 +343,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { float z; mat4x3 a; } data; @@ -387,7 +387,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { float z; int a[5]; } data; @@ -432,7 +432,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { float z; int a[5]; } data; @@ -474,7 +474,7 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, StorageBuffer_Store_ToArray) { precision mediump float; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { float z; int a[5]; } data; @@ -531,7 +531,7 @@ struct Inner { vec3 b; }; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { Inner c[4]; } data; @@ -590,7 +590,7 @@ struct Inner { vec3 b; }; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { Inner c[4]; } data; @@ -649,7 +649,7 @@ struct Inner { vec3 b; }; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { Inner c[4]; } data; @@ -708,7 +708,7 @@ struct Inner { vec3 b; }; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { Inner c[4]; } data; @@ -763,7 +763,7 @@ struct Inner { vec3 b; }; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { Inner c[4]; } data; @@ -822,7 +822,7 @@ struct Inner { vec3 b; }; -layout (set = 1, binding = 0) buffer Data_1 { +layout (binding = 0) buffer Data_1 { Inner c[4]; } data; diff --git a/src/writer/glsl/generator_impl_sanitizer_test.cc b/src/writer/glsl/generator_impl_sanitizer_test.cc index 4c030d0923..b85bde6f2e 100644 --- a/src/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/writer/glsl/generator_impl_sanitizer_test.cc @@ -52,7 +52,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) { precision mediump float; -layout (set = 2, binding = 1) buffer my_struct_1 { +layout (binding = 1) buffer my_struct_1 { float a[0]; } b; @@ -103,7 +103,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { precision mediump float; -layout (set = 2, binding = 1) buffer my_struct_1 { +layout (binding = 1) buffer my_struct_1 { float z; float a[0]; } b; @@ -157,7 +157,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { precision mediump float; -layout (set = 2, binding = 1) buffer my_struct_1 { +layout (binding = 1) buffer my_struct_1 { float a[0]; } b;