skia2/resources/sksl/shared/MatrixConstructorsES3.sksl
John Stiles 21fe518fbb Revert "Disallow matrix ctors which overflow a column."
This reverts commit eb68973c2f.

Reason for revert: ES2 conformance test checks this

Original change's description:
> Disallow matrix ctors which overflow a column.
>
> The GLSL spec allows matrix constructors containing vectors that would
> split between multiple columns of the matrix. However, in practice, this
> does not actually work well on a lot of GPUs!
>
> - "cast not allowed", "internal error":
> 	Tegra 3
> 	Quadro P400
> 	GTX 660
> 	GTX 960
> - Compiles, but generates wrong result:
> 	RadeonR9M470X
> 	RadeonHD7770
>
> Since this isn't a pattern we expect to see in user code, we now report
> it as an error at compile time. mat2(vec4) is treated as an exceptional
> case and still allowed.
>
> Change-Id: Id6925984a2d1ec948aec4defcc790a197a96cf86
> Bug: skia:12443
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449518
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

Bug: skia:12443
Change-Id: I5a32744c88b9b830ad657488824c8c7dd0b0a652
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/458056
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2021-10-14 01:30:08 +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;
}