xref: /aosp_15_r20/external/skia/resources/sksl/shared/SwizzleIndexLookup.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorGreen, colorRed;
2uniform float3x3 testMatrix3x3;
3uniform float4x4 testMatrix4x4;
4
5bool test3x3() {
6    float3 expected = float3(3, 2, 1);
7    for (int c=0; c<3; ++c) {
8        float3 vec = testMatrix3x3[c];
9        for (int r=0; r<3; ++r) {
10            if (vec.zyx[r] != expected[r]) {
11                return false;
12            }
13        }
14        expected += 3;
15    }
16    return true;
17}
18
19bool test4x4() {
20    float4 expected = float4(4, 3, 2, 1);
21    for (int c=0; c<4; ++c) {
22        float4 vec = testMatrix4x4[c];
23        for (int r=0; r<4; ++r) {
24            if (vec.wzyx[r] != expected[r]) {
25                return false;
26            }
27        }
28        expected += 4;
29    }
30    return true;
31}
32
33half4 main(float2 coords) {
34    return test3x3() && test4x4() ? colorGreen : colorRed;
35}
36