xref: /aosp_15_r20/external/skia/resources/sksl/shared/MatrixToVectorCast.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 colorGreen, colorRed;
2uniform half2x2 testMatrix2x2;
3
4half4 main(float2 coords) {
5    const half2x2 mat1234 = half2x2(1, 2, 3, 4);
6    const half2x2 bmat1234 = half2x2(1, 0, 1, 0);
7
8    bool ok = true;
9
10    ok = ok && half4(testMatrix2x2)        == half4(1, 2, 3, 4);
11    ok = ok && half4(half2x2(1, 2, 3, 4))  == half4(1, 2, 3, 4);
12    ok = ok && half4(mat1234)              == half4(1, 2, 3, 4);
13    ok = ok && half4(half2x2(2))           == half4(2, 0, 0, 2);
14    ok = ok && half4(half2x2(2, 2, 2, 2))  == half4(2);
15
16    ok = ok && float4(testMatrix2x2)       == float4(1, 2, 3, 4);
17    ok = ok && float4(half2x2(1, 2, 3, 4)) == float4(1, 2, 3, 4);
18    ok = ok && float4(mat1234)             == float4(1, 2, 3, 4);
19    ok = ok && float4(float2x2(4))         == float4(4, 0, 0, 4);
20    ok = ok && float4(float2x2(2, 2, 2, 2)) == float4(2);
21
22    ok = ok && int4(testMatrix2x2)         == int4(1, 2, 3, 4);
23    ok = ok && int4(half2x2(1, 2, 3, 4))   == int4(1, 2, 3, 4);
24    ok = ok && int4(mat1234)               == int4(1, 2, 3, 4);
25    ok = ok && int4(float2x2(8))           == int4(8, 0, 0, 8);
26    ok = ok && int4(float2x2(8, 8, 8, 8))  == int4(8);
27
28    ok = ok && bool4(testMatrix2x2)        == bool4(true, true, true, true);
29    ok = ok && bool4(half2x2(0, 1, 0, 1))  == bool4(false, true, false, true);
30    ok = ok && bool4(bmat1234)             == bool4(true, false, true, false);
31    ok = ok && bool4(half2x2(1))           == bool4(true, false, false, true);
32    ok = ok && bool4(half2x2(1, 1, 1, 1))  == bool4(true);
33
34    return ok ? colorGreen : colorRed;
35}
36