]> git.tdb.fi Git - libs/gl.git/blobdiff - tests/glsl/keep_empty_loop_with_side_effects.glsl
Remove conditional and iteration statements with no effect from GLSL
[libs/gl.git] / tests / glsl / keep_empty_loop_with_side_effects.glsl
diff --git a/tests/glsl/keep_empty_loop_with_side_effects.glsl b/tests/glsl/keep_empty_loop_with_side_effects.glsl
new file mode 100644 (file)
index 0000000..b0c1626
--- /dev/null
@@ -0,0 +1,44 @@
+uniform sampler2D tex;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 vertex;
+layout(location=1) in vec2 texcoord;
+void main()
+{
+       gl_Position = vertex;
+       passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out float result;
+void main()
+{
+       float value = texture(tex, texcoord).r;
+       float pot;
+       for(pot=0; pot<value; pot*=2) { }
+       result = pot;
+}
+
+/* Expected output: vertex
+layout(location=0) in vec4 vertex;
+layout(location=1) in vec2 texcoord;
+layout(location=0) out vec2 _vs_out_texcoord;
+void main()
+{
+       gl_Position = vertex;
+       _vs_out_texcoord = texcoord;
+}
+*/
+
+/* Expected output: fragment
+layout(location=0, binding=71) uniform sampler2D tex;
+layout(location=0) out float result;
+layout(location=0) in vec2 _vs_out_texcoord;
+void main()
+{
+       float value = texture(tex, _vs_out_texcoord).r;
+       float pot;
+       for(pot = 0.0; pot<value; pot *= 2.0) { }
+       result = pot;
+}
+*/