xref: /aosp_15_r20/external/skia/DATA/skia_resources/sksl/folding/IntFoldingES3.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorRed, colorGreen;
2
3bool test() {
4    bool ok = true;
5    int x = 12 | 6;
6    ok = ok && (x == 14);
7    x = 254 & 7;
8    ok = ok && (x == 6);
9    x = 2 ^ 7;
10    ok = ok && (x == 5);
11    x = 1 << 4;
12    ok = ok && (x == 16);
13    x = ~~~x;
14    ok = ok && (x == ~16);
15    x = ~~~~x;
16    ok = ok && (x == ~16);
17
18    int3 v = ~int3(12, 34, 56);
19    ok = ok && (v == int3(~12, ~34, ~56));
20
21    // Left-shifting a negative integer is undefined in C++, but allowed in GPU shading languages.
22    // https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29093
23    x = -2 << 2;
24    ok = ok && (x == -8);
25    x = 128 >> 2;
26    ok = ok && (x == 32);
27    x = 123 % 45;
28    ok = ok && (x == 33);
29    return ok;
30}
31
32half4 main(float2 coords) {
33    return test() ? colorGreen : colorRed;
34}
35