]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/empty_conditional_removal.glsl
Remove conditional and iteration statements with no effect from GLSL
[libs/gl.git] / tests / glsl / empty_conditional_removal.glsl
diff --git a/tests/glsl/empty_conditional_removal.glsl b/tests/glsl/empty_conditional_removal.glsl
new file mode 100644 (file)
index 0000000..e40d176
--- /dev/null
@@ -0,0 +1,63 @@
+uniform Lighting
+{
+       vec3 light_dir;
+       mat4 shadow_matrix;
+       int shadow_enabled;
+};
+uniform Transform
+{
+       mat4 vp;
+       mat4 model;
+};
+uniform sampler2DShadow shadow_map;
+const bool use_light = false;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 vertex;
+layout(location=1) in vec3 normal;
+void main()
+{
+       vec4 world_vertex = model*vertex;
+       out vec3 world_normal = mat3(model)*normal;
+       gl_Position = vp*world_vertex;
+       if(shadow_enabled!=0)
+       {
+               out vec3 shadow_coord = (shadow_matrix*world_vertex).xyz;
+       }
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       vec3 color = vec3(1.0);
+       if(use_light)
+       {
+               float intensity = max(dot(normalize(world_normal), light_dir), 0.0);
+               if(shadow_enabled!=0)
+                       intensity *= texture(shadow_map, shadow_coord);
+               color *= intensity;
+       }
+       frag_color = vec4(color, 1.0);
+}
+
+/* Expected output: vertex
+layout(binding=48) uniform Transform
+{
+       mat4 vp;
+       mat4 model;
+};
+layout(location=0) in vec4 vertex;
+void main()
+{
+       gl_Position = vp*model*vertex;
+}
+*/
+
+/* Expected output: fragment
+layout(location=0) out vec4 frag_color;
+void main()
+{
+       frag_color = vec4(vec3(1.0), 1.0);
+}
+*/