xref: /aosp_15_r20/external/skia/resources/sksl/runtime/Commutative.rts (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1#version 300
2
3/*#pragma settings DebugTrace*/
4
5uniform half4 colorGreen, colorRed;
6uniform float2x2 testMatrix2x2;
7
8half4 main(float2 xy) {
9    bool ok = true;
10    int   a = int(testMatrix2x2[0][0]), b = int(testMatrix2x2[0][1]);
11    float c =    (testMatrix2x2[1][0]), d =    (testMatrix2x2[1][1]);
12
13    int a_and_b = a & b;
14    int b_and_a = b & a;
15    ok = ok && (a_and_b == b_and_a);
16
17    int a_or_b = a | b;
18    int b_or_a = b | a;
19    ok = ok && (a_or_b == b_or_a);
20
21    int a_xor_b = a ^ b;
22    int b_xor_a = b ^ a;
23    ok = ok && (a_xor_b == b_xor_a);
24
25    bool a_eq_b = a == b;
26    bool b_eq_a = b == a;
27    ok = ok && (a_eq_b == b_eq_a);
28
29    bool a_neq_b = a != b;
30    bool b_neq_a = b != a;
31    ok = ok && (a_neq_b == b_neq_a);
32
33    int a_add_b = a + b;
34    int b_add_a = b + a;
35    ok = ok && (a_add_b == b_add_a);
36
37    float c_add_d = c + d;
38    float d_add_c = d + c;
39    ok = ok && (c_add_d == d_add_c);
40
41    int a_mul_b = a * b;
42    int b_mul_a = b * a;
43    ok = ok && (a_mul_b == b_mul_a);
44
45    float c_mul_d = c * d;
46    float d_mul_c = d * c;
47    ok = ok && (c_mul_d == d_mul_c);
48
49    return ok ? colorGreen : colorRed;
50}
51