xref: /aosp_15_r20/external/skia/resources/sksl/shared/MatrixConstructorsES2.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Workeruniform half4 colorGreen, colorRed;
2*c8dee2aaSAndroid Build Coastguard Workeruniform float2x2 testMatrix2x2;  // equals (1, 2, 3, 4)
3*c8dee2aaSAndroid Build Coastguard Worker
4*c8dee2aaSAndroid Build Coastguard Workerhalf4 main(float2 coords) {
5*c8dee2aaSAndroid Build Coastguard Worker    float4 f4 = float4(testMatrix2x2);
6*c8dee2aaSAndroid Build Coastguard Worker
7*c8dee2aaSAndroid Build Coastguard Worker    // These matrices are intentionally assembled off-kilter; the vectors shouldn't line up with the
8*c8dee2aaSAndroid Build Coastguard Worker    // natural matrix stride. Metal and SPIR-V will need to reorder the data to make it fit.
9*c8dee2aaSAndroid Build Coastguard Worker    bool ok = float2x2(f4.xyz, 4)                       == float2x2(1, 2, 3, 4);
10*c8dee2aaSAndroid Build Coastguard Worker    ok = ok && float3x3(f4.xy, f4.zw, f4.xyzw, f4.x)    == float3x3(1, 2, 3, 4, 1, 2, 3, 4, 1);
11*c8dee2aaSAndroid Build Coastguard Worker    ok = ok && float4x4(f4.xyz, f4.wxy, f4.zwxy, f4.zw, f4.xyzw) == float4x4(1, 2, 3, 4,
12*c8dee2aaSAndroid Build Coastguard Worker                                                                             1, 2, 3, 4,
13*c8dee2aaSAndroid Build Coastguard Worker                                                                             1, 2, 3, 4,
14*c8dee2aaSAndroid Build Coastguard Worker                                                                             1, 2, 3, 4);
15*c8dee2aaSAndroid Build Coastguard Worker    return ok ? colorGreen : colorRed;
16*c8dee2aaSAndroid Build Coastguard Worker}
17