summaryrefslogtreecommitdiff
path: root/tests/spec/glsl-es-1.00/execution/unroll-do-while-false-loop-only-once.shader_test
blob: 9f4edd660a25a693343b2e93b182fd735ee7b0ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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