]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/binding_mismatch.glsl
Validate location overlap and type matching for GLSL interfaces
[libs/gl.git] / tests / glsl / binding_mismatch.glsl
diff --git a/tests/glsl/binding_mismatch.glsl b/tests/glsl/binding_mismatch.glsl
new file mode 100644 (file)
index 0000000..fa88bf1
--- /dev/null
@@ -0,0 +1,43 @@
+#pragma MSP stage(vertex)
+layout(binding=0) uniform Transform
+{
+       mat4 model;
+       mat4 vp;
+};
+layout(binding=1) uniform Lighting
+{
+       vec3 position;
+} light;
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+void main()
+{
+       vec4 world_pos = model*position;
+       gl_Position = vp*world_pos;
+       out vec3 light_dir = world_pos.xyz-light.position;
+       passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(binding=1) uniform Lighting
+{
+       vec4 color;
+} light;
+layout(binding=0) uniform Material
+{
+       vec4 color;
+};
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = color*vec4(vec3(max(dot(normalize(normal), normalize(light_dir)), 0.0)), 1.0);
+}
+
+/* Expected error:
+<test>:23: Mismatched struct type for binding 1 'Lighting'
+<test>:8: Previously used here
+<test>:27: Overlapping binding 0 for 'Material'
+<test>:3: Previously used here for 'Transform'
+<test>:27: Mismatched struct type for binding 0 'Material'
+<test>:3: Previously used here
+*/