]> git.tdb.fi Git - libs/gl.git/commitdiff
Add a couple more test cases
authorMikko Rasa <tdb@tdb.fi>
Fri, 9 Apr 2021 14:44:53 +0000 (17:44 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 10 Apr 2021 00:47:27 +0000 (03:47 +0300)
tests/glsl/invalid_return.glsl [new file with mode: 0644]
tests/glsl/swizzle_assignment.glsl [new file with mode: 0644]

diff --git a/tests/glsl/invalid_return.glsl b/tests/glsl/invalid_return.glsl
new file mode 100644 (file)
index 0000000..9a25259
--- /dev/null
@@ -0,0 +1,15 @@
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+float func()
+{
+}
+void main()
+{
+       gl_Position = position*func();
+       return 0;
+}
+
+/* Expected error:
+<test>:3: Missing return statement at the end of a function not returning 'void'
+<test>:9: Return expression type 'int' is incompatible with declared return type 'void'
+*/
diff --git a/tests/glsl/swizzle_assignment.glsl b/tests/glsl/swizzle_assignment.glsl
new file mode 100644 (file)
index 0000000..521a8c4
--- /dev/null
@@ -0,0 +1,67 @@
+uniform sampler2D tex;
+uniform Transform
+{
+       mat4 model_matrix;
+       mat4 vp_matrix;
+};
+uniform Lighting
+{
+       vec3 light_dir;
+       vec3 light_color;
+};
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec2 texcoord;
+void main()
+{
+       passthrough;
+       out vec3 world_normal = mat3(model_matrix)*normal;
+       gl_Position = vp_matrix*model_matrix*position;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = texture(tex, texcoord);
+       frag_color.rgb *= max(dot(normalize(world_normal), light_dir), 0.0)*light_color;
+}
+
+/* Expected output: vertex
+layout(binding=48) uniform Transform
+{
+  mat4 model_matrix;
+  mat4 vp_matrix;
+};
+layout(location=0) in vec4 position;
+layout(location=1) in vec3 normal;
+layout(location=2) in vec2 texcoord;
+layout(location=0) out vec2 _vs_out_texcoord;
+layout(location=1) out vec3 world_normal;
+void main()
+{
+  _vs_out_texcoord = texcoord;
+  mat4 _temp = model_matrix;
+  world_normal = mat3(_temp[0].xyz, _temp[1].xyz, _temp[2].xyz)*normal;
+  gl_Position = vp_matrix*model_matrix*position;
+}
+*/
+
+/* Expected output: fragment
+layout(location=0, binding=71) uniform sampler2D tex;
+layout(binding=5) uniform Lighting
+{
+  vec3 light_dir;
+  vec3 light_color;
+};
+layout(location=0) out vec4 frag_color;
+layout(location=0) in vec2 _vs_out_texcoord;
+layout(location=1) in vec3 world_normal;
+void main()
+{
+  frag_color = texture(tex, _vs_out_texcoord);
+  frag_color.rgb *= max(dot(normalize(world_normal), light_dir), 0.0)*light_color;
+}
+*/