From 1aae14c92bfe5d5c45a6d47dc7635adc62029c9d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 20 Jun 2019 19:34:27 -0700 Subject: 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 Reviewed-by: Timothy Arceri --- ...nroll-do-while-false-loop-only-once.shader_test | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/spec/glsl-es-1.00/execution/unroll-do-while-false-loop-only-once.shader_test 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 -- cgit v1.2.3