skia2/resources/sksl/intrinsics/MatrixCompMultES2.sksl
John Stiles b701fa0ac0 Add non-square MatrixCompMult support to public SkSL in ES3 mode.
We already had a test case here, but it wasn't actually in operation.
The test has been split into ES2 (square) and ES3 (non-square) halves,
returns the color like a proper runtime effect, and it's now running in
dm.

Also, Metal doesn't natively support matrixCompMult, so it injects a
helper function; I tweaked the helper so it no longer requires an extra
result variable.

Change-Id: Ie79242768966fcbe879ad73461d17b4fb8e55670
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/448117
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-14 18:15:23 +00:00

19 lines
912 B
Plaintext

uniform half4 colorGreen, colorRed;
uniform float2x2 testMatrix2x2;
uniform half3x3 testMatrix3x3;
half4 main(float2 coords) {
half2x2 h22 = matrixCompMult(half2x2(5, 5, 5, 5), half2x2(0, 1, 2, 3));
const half4x4 h44 = matrixCompMult(half4x4(0.5), half4x4(1, 2, 3, 4,
5, 6, 7, 8,
9, 10,11,12,
13,14,15,16));
float2x2 f22 = matrixCompMult(testMatrix2x2, float2x2(1));
half3x3 h33 = matrixCompMult(testMatrix3x3, half3x3(2,2,2,2,2,2,2,2,2));
return (h22 == half2x2(0, 5, 10, 15) &&
f22 == float2x2(1, 0, 0, 4) &&
h33 == half3x3(2, 4, 6, 8, 10, 12, 14, 16, 18) &&
h44 == half4x4(0.5, 0, 0, 0, 0, 3, 0, 0, 0, 0, 5.5, 0, 0, 0, 0, 8))
? colorGreen : colorRed;
}