1 # From the GLSL 4.40 spec, section 6.4 (Jumps):
3 # The continue jump is used only in loops. It skips the remainder
4 # of the body of the inner most loop of which it is inside. For
5 # while and do-while loops, this jump is to the next evaluation of
6 # the loop condition-expression from which the loop continues as
9 # One way that do-while loops might be implemented is to convert them
10 # to infinite loops that terminate in a conditional break (this is
11 # what Mesa does). In such an implementation, an easy way to
12 # implement the proper behaviour of "continue" in a do-while loop is
13 # to replicate the conditional break at the site of the "continue".
14 # For example, this code:
23 # } while (condition);
25 # would get translated to:
40 # However, we must be careful in making this transformation if the
41 # "continue" occurs inside a switch statement, since "break" inside a
42 # switch statement normally exits the switch statement, not the
45 # This test verifies that "continue" behaves properly when invoked
46 # inside a switch statement which is itself inside a do-while loop.
55 gl_Position = gl_Vertex;
66 do { // 1st iteration 2nd iteration
68 switch (w) { // Jump to case 1 Jump to case 2
73 continue; // Jump to (w < 2)
75 ++y; // (this case is never executed)
78 ++z; // z <- 1 skipped
79 } while (w < 2); // true false
81 // The loop should execute for two iterations, so w should be 2. X
82 // should be incremented on the first iteration only, so it should
83 // be 1. Y should never be incremented (since w never reaches 3),
84 // so it should be 0. The "continue" should skip ++z on the second
85 // iteration, so z should be 1.
86 if (w == 2 && x == 1 && y == 0 && z == 1)
87 gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
89 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
94 probe all rgba 0.0 1.0 0.0 1.0