summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2019-06-20 19:34:27 -0700
committerIan Romanick <ian.d.romanick@intel.com>2019-06-24 14:19:24 -0700
commit1aae14c92bfe5d5c45a6d47dc7635adc62029c9d (patch)
tree681814bff177cf47bbac7fa61ea64bea8230019c
parent5bdd8f9d92c8439b6c5ae3c9286ed7f4af3db831 (diff)
glsl-es-1.00: Only unroll a do-while-false loop once
This was the smallest test case that I could make that would reproduce the bug, generate actual instructions (instead of constant folding to nothing), and be small enough to run on any GPU supported by Mesa that has GLES 2.0 (i.e., i915). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110953 Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
-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