summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/glslang/src/Test/loops.frag
blob: 44f13bcd8032726386378e1216dbbffc2f844003 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#version 130
uniform vec4 bigColor;
uniform vec4 bigColor1_1;
uniform vec4 bigColor1_2;
uniform vec4 bigColor1_3;
uniform vec4 bigColor2;
uniform vec4 bigColor3;
uniform vec4 bigColor4;
uniform vec4 bigColor5;
uniform vec4 bigColor6;
uniform vec4 bigColor7;
uniform vec4 bigColor8;

varying vec4 BaseColor;

uniform float d;
uniform float d2;
uniform float d3;
uniform float d4;
uniform float d5;
uniform float d6;
uniform float d7;
uniform float d8;
uniform float d9;
uniform float d10;
uniform float d11;
uniform float d12;
uniform float d13;
uniform float d14;
uniform float d15;
uniform float d16;
uniform float d17;
uniform float d18;
uniform float d19;
uniform float d20;
uniform float d21;
uniform float d22;
uniform float d23;
uniform float d24;
uniform float d25;
uniform float d26;
uniform float d27;
uniform float d28;
uniform float d29;
uniform float d30;
uniform float d31;
uniform float d32;
uniform float d33;
uniform float d34;

uniform int Count;

void main()
{
    vec4 color = BaseColor;

    // Not a real loop
    while (true) {
        if (color.x < 0.33) {
            color += vec4(0.33);
            break;
        }
        if (color.x < 0.66) {
            color += vec4(0.66);
            break;
        }

        color += vec4(0.33);
        break;
    }

    // While
    while (color.x < d) {
        color += bigColor;
    }

    // While (latchy)
    while (color.z < d) {
        color += bigColor1_1;
        if (color.w < d)
            continue;

        color += bigColor1_1;
    }

    // While (constant)
    while (color.x < 42.0) {
        ++color;
    }

    // While (complicated-conditional)
    while (color.w < d2 && color.y < d3) {
        color += bigColor1_2;
    }

    // While (multi-exit)
    while (color.z < d3) {
        color += bigColor1_3;
        if (color.y < d4)
            break;
        color += bigColor1_3;
    }

    // For (dynamic)
    for (int i = 0; i < Count; ++i) {
        color += bigColor2;
    }

    // Do while
    do {
        color += bigColor3;
    } while (color.x < d2);

    // For (static)
    for (int i = 0; i < 42; ++i) {
        color.z += d3;
    }

    // For (static) flow-control
    for (int i = 0; i < 100; ++i) {
        if (color.z < 20.0)
            color.x++;
        else
            color.y++;
        if (color.w < 20.0)
            if (color.z > color.y)
                0;              // do nothing
    }

    // For (static) flow-control with latch merge
    for (int i = 0; i < 120; ++i) {
        if (color.z < 20.0)
            color.x++;
        else
            color.y++;
    }

    // For (static) latchy
    for (int i = 0; i < 42; ++i) {
        color.z += d3;
        if (color.x < d4)
            continue;
        ++color.w;
    }

    // For (static) multi-exit
    for (int i = 0; i < 42; ++i) {
        color.z += d3;
        if (color.x < d4)
            break;
        ++color.w;
    }

    // Latchy
    do {
        color += bigColor4;
        if (color.x < d4)
            continue;
        if (color.y < d4)
            color.y += d4;
        else
            color.x += d4;
    } while (color.z < d4);

    // Do while flow control
    do {
        color += bigColor5;
        if (color.y < d5)
            color.y += d5;
    } while (color.x < d5);

    // If then loop
    if (color.x < d6) {
        while (color.y < d6)
            color += bigColor6;
    } else {
        while (color.z < d6)
            color.z += bigColor6.z;
    }

    // If then multi-exit
    if (color.x < d6) {
        while (color.y < d6) {
            color += bigColor6;
            if (d7 < 1.0)
                break;
        }

    } else {
        while (color.z < d6)
            color.z += bigColor6.z;
    }


    // Multi-exit
    do {
       if (d7 < 0.0)
           break;

       color += bigColor7;

       if (d7 < 1.0) {
           color.z++;
           break;
       }

       color += BaseColor;

    } while (true);


    // Multi-exit2
    do {
        // invariant conditional break at the top of the loop. This could be a
        // situation where unswitching the loop has no real increases in code
        // size.
       if (d8 < 0.0)
           break;

       color += bigColor7;

       if (d8 < 1.0) {
           color.z++;
           if (d8 < 2.0) {
               color.y++;
           } else {
               color.x++;
           }
           break;
       }

       color += BaseColor;

    } while (color.z < d8);

    // Deep exit
    while (color.w < d9) {
        if (d9 > d8) {
            if (color.x <= d7) {
                if (color.z == 5.0)
                    color.w++;
                else
                    break;
            }
        }

    }

    // No end loop-back.
    while (color.z < d10) {
        color.y++;
        if (color.y < d11) {
            color.z++;
            if (color.w < d12)
                color.w++;
            else
                color.x++;
            continue;
        }

        color++;
        break;
    }

    // Multi-continue
    while (color.x < 10.0) {
        color += bigColor8;

        if (color.z < d8)
            if (color.w < d6)
                continue;

        color.y += bigColor8.x;
    }

    color++;
    gl_FragColor = color;

    // Early Return
    while (color.x < d14) {
        if (color.y < d15) {
            return;
        }
        else
            color++;
    }

    color++;

    while (color.w < d16) {
        color.w++;
    }


    // While (complicated-conditional)
    while (color.w < d2 && color.y < d3) {
        color += bigColor1_2;
        if (color.z < d3)
            return;
    }


    do {
        if (color.y < d18)
            return;
        color++;
    } while (color.x < d17);

    // Early Discard
    while (color.y < d16) {
        if (color.w < d16) {
            discard;
        } else
            color++;
    }

    color++;

    gl_FragColor = color;
}