summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/spec/glsl-es-1.00/execution/unroll-do-while-false-loop-only-once.shader_test47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/spec/glsl-es-1.00/execution/unroll-do-while-false-loop-only-once.shader_test b/tests/spec/glsl-es-1.00/execution/unroll-do-while-false-loop-only-once.shader_test
new file mode 100644
index 000000000..9f4edd660
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/execution/unroll-do-while-false-loop-only-once.shader_test
@@ -0,0 +1,47 @@
+[require]
+GL ES >= 2.0
+GLSL ES >= 1.00
+
+[vertex shader passthrough]
+
+[fragment shader]
+precision mediump float;
+
+uniform float x[4];
+
+void main()
+{
+ float data[4];
+
+ for (int i = 0; i < 4; i++)
+ data[i] = x[i];
+
+ for (int i = 0; i < 3; i++) {
+ bool doSwap = data[i] > data[i + 1];
+
+ /* Per bugzilla 110953, a do-while-false loop that starts with
+ * an if-statement can be unrolled twice instead of once.
+ */
+ do {
+ if (doSwap) {
+ float temp = data[i];
+ data[i] = data[i + 1];
+ data[i + 1] = temp;
+ }
+ } while (false);
+ }
+
+ if (data[0] == 3. && data[1] == 2. && data[2] == 1. && data[3] == 4.)
+ gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+ else
+ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform float x[0] 4.0
+uniform float x[1] 3.0
+uniform float x[2] 2.0
+uniform float x[3] 1.0
+
+draw rect -1 -1 2 2
+probe all rgba 0 1 0 1