]> git.tdb.fi Git - libs/gl.git/commitdiff
Clear the empty name flag after emitting a member access
authorMikko Rasa <tdb@tdb.fi>
Sat, 10 Apr 2021 00:46:29 +0000 (03:46 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 10 Apr 2021 00:47:27 +0000 (03:47 +0300)
source/glsl/output.cpp
tests/glsl/struct_in_anonymous_block.glsl [new file with mode: 0644]

index c15c8c0421b9aae64add279cf11b9c05a03753f6..50b60c1411d34a67ec5aae4d20a7b5dab233a881 100644 (file)
@@ -171,6 +171,7 @@ void Formatter::visit(MemberAccess &memacc)
        if(!r_empty_name)
                append('.');
        append(memacc.member);
+       r_empty_name = false;
 }
 
 void Formatter::visit(Swizzle &swizzle)
diff --git a/tests/glsl/struct_in_anonymous_block.glsl b/tests/glsl/struct_in_anonymous_block.glsl
new file mode 100644 (file)
index 0000000..03d6af4
--- /dev/null
@@ -0,0 +1,54 @@
+struct MaterialParameters
+{
+       vec4 color;
+};
+uniform Material
+{
+       MaterialParameters material;
+};
+uniform Transform
+{
+       mat4 mvp;
+};
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void main()
+{
+       gl_Position = mvp*position;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = material.color;
+}
+
+/* Expected output: vertex
+layout(binding=48) uniform Transform
+{
+       mat4 mvp;
+};
+layout(location=0) in vec4 position;
+void main()
+{
+       gl_Position = mvp*position;
+}
+*/
+
+/* Expected output: fragment
+struct MaterialParameters
+{
+       vec4 color;
+};
+layout(binding=64) uniform Material
+{
+       MaterialParameters material;
+};
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = material.color;
+}
+*/