Debian Codegraph @

third_party/spirv-cross/shaders/frag/for-loop-init.frag

raw
1 #version 310 es
2 precision mediump float;
3 layout(location = 0) out int FragColor;
4
5 void main()
6 {
7 FragColor = 16;
8
9 // Basic loop variable.
10 for (int i = 0; i < 25; i++)
11 FragColor += 10;
12
13 // Multiple loop variables.
14 for (int i = 1, j = 4; i < 30; i++, j += 4)
15 FragColor += 11;
16
17 // A potential loop variables, but we access it outside the loop,
18 // so cannot be one.
19 int k = 0;
20 for (; k < 20; k++)
21 FragColor += 12;
22 k += 3;
23 FragColor += k;
24
25 // Potential loop variables, but the dominator is not trivial.
26 int l;
27 if (k == 40)
28 {
29 for (l = 0; l < 40; l++)
30 FragColor += 13;
31 return;
32 }
33 else
34 {
35 l = k;
36 FragColor += l;
37 }
38
39 // Vectors cannot be loop variables
40 for (ivec2 i = ivec2(0); i.x < 10; i.x += 4)
41 {
42 FragColor += i.y;
43 }
44
45 // Check that static expressions can be used before the loop header.
46 int m = 0;
47 m = k;
48 int o = m;
49 for (; m < 40; m++)
50 FragColor += m;
51 FragColor += o;
52 }