]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/return_type_conversion.glsl
Apply implicit conversion to return expressions in GLSL functions
[libs/gl.git] / tests / glsl / return_type_conversion.glsl
diff --git a/tests/glsl/return_type_conversion.glsl b/tests/glsl/return_type_conversion.glsl
new file mode 100644 (file)
index 0000000..3467311
--- /dev/null
@@ -0,0 +1,78 @@
+uniform Shadow
+{
+       mat4 shadow_matrix;
+};
+uniform Camera
+{
+       mat4 viewproj_matrix;
+};
+uniform Surface
+{
+       vec4 color;
+};
+uniform mat4 model_matrix;
+uniform sampler2DShadow shadow_map;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void main()
+{
+       out vec4 world_position = model_matrix*position;
+       gl_Position = viewproj_matrix*world_position;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_out;
+float get_shadow()
+{
+       vec3 shadow_coord = (shadow_matrix*world_position).xyz;
+       if(shadow_coord.x>=0 && shadow_coord.x<=1 && shadow_coord.y>=0 && shadow_coord.y<=1)
+               return texture(shadow_map, shadow_coord);
+       else
+               return 1;
+}
+void main()
+{
+       frag_out = vec4(color.rgb*get_shadow(), color.a);
+}
+
+/* Expected output: vertex
+layout(binding=72) uniform Camera
+{
+       mat4 viewproj_matrix;
+};
+layout(location=0) uniform mat4 model_matrix;
+layout(location=0) in vec4 position;
+layout(location=0) out vec4 world_position;
+void main()
+{
+       world_position = model_matrix*position;
+       gl_Position = viewproj_matrix*world_position;
+}
+*/
+
+/* Expected output: fragment
+layout(binding=71) uniform Shadow
+{
+       mat4 shadow_matrix;
+};
+layout(binding=77) uniform Surface
+{
+       vec4 color;
+};
+layout(location=4, binding=73) uniform sampler2DShadow shadow_map;
+layout(location=0) out vec4 frag_out;
+layout(location=0) in vec4 world_position;
+float get_shadow()
+{
+       vec3 shadow_coord = (shadow_matrix*world_position).xyz;
+       if(shadow_coord.x>=0.0&&shadow_coord.x<=1.0&&shadow_coord.y>=0.0&&shadow_coord.y<=1.0)
+               return texture(shadow_map, shadow_coord);
+       else
+               return 1.0;
+}
+void main()
+{
+       frag_out = vec4(color.rgb*get_shadow(), color.a);
+}
+*/