skia2/resources/sksl/shared/MatrixConstructorsES3.sksl
John Stiles 7d19065eef Add test of off-kilter matrix constructors.
This exposes a bug in the Metal code generator which will be resolved
in a followup CL.

Change-Id: If073835dbee474ea9a805eb92b42dc1fca2afbd0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448378
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-09-14 13:01:26 +00:00

19 lines
1.0 KiB
Plaintext

uniform half4 colorGreen, colorRed;
uniform float2x2 testMatrix2x2; // equals (1, 2, 3, 4)
half4 main(float2 coords) {
float4 f4 = float4(testMatrix2x2);
// These matrices are intentionally assembled off-kilter; the vectors shouldn't line up with the
// natural matrix stride. Metal and SPIR-V will need to reorder the data to make it fit.
bool ok = float2x3(f4.xyzw, f4.xy) == float2x3(1, 2, 3, 4, 1, 2);
ok = ok && float2x4(f4.xyz, f4.wxyz, f4.w) == float2x4(1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float3x3(f4.xy, f4.zw, f4.xyzw, f4.x) == float3x3(1, 2, 3, 4, 1, 2, 3, 4, 1);
ok = ok && float4x2(f4.xyz, f4.wxyz, f4.w) == float4x2(1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float4x3(f4.x, f4.yzwx, f4.yzwx, f4.yzw) == float4x3(1, 2, 3,
4, 1, 2,
3, 4, 1,
2, 3, 4);
return ok ? colorGreen : colorRed;
}