1# This tests unrolling of a loop with two exit point where the trip count 2# of one of the exits is known and the other unknown (conditional on uniform). 3# 4# Here we test that control flow that comes before the terminators is properly 5# inserted into the unrolled loop. 6[require] 7GLSL >= 1.10 8 9[vertex shader] 10uniform int a; 11 12void main() 13{ 14 gl_Position = gl_Vertex; 15 16 vec4 colour = vec4(1.0, 0.0, 0.0, 1.0); 17 18 int i = 0; 19 int j = 0; 20 do { 21 if (i == 2) { 22 colour = vec4(0.0, 0.0, 1.0, 1.0); 23 j++; // we use this so the if doesn't get reduced to a series of bcsel 24 } else { 25 colour = vec4(0.0, 1.0, 0.0, 1.0); 26 } 27 28 i++; 29 j++; 30 31 if (i >= 3) { 32 if (j != 4) 33 colour = vec4(1.0, 0.0, 0.0, 1.0); 34 break; 35 } 36 } while (a == 1); 37 38 gl_FrontColor = colour; 39} 40 41[fragment shader] 42void main() 43{ 44 gl_FragColor = gl_Color; 45} 46 47[test] 48clear color 0.5 0.5 0.5 0.5 49 50uniform int a 0 51draw rect -1 -1 2 2 52probe all rgba 0.0 1.0 0.0 1.0 53 54uniform int a 1 55draw rect -1 -1 2 2 56probe all rgba 0.0 0.0 1.0 1.0 57