skia2/tests/sksl/intrinsics/MatrixCompMult.glsl
John Stiles 598c5e5b07 Implement compile-time optimization for matrixCompMult().
$mat matrixCompMult($mat x, $mat y);
$hmat matrixCompMult($hmat x, $hmat y);

This required some minor changes to `evaluate_n_way_intrinsic_of_type`
to allow the inputs to be matrices instead of vectors. Fortunately, most
of the moving parts were already generic/flexible enough that this just
worked, but some explicit checks for `x.isVector` needed to become
`!x.isScalar()`, and `columns` needed to become `slotCount`.

Change-Id: I1e22ecad37a7e187a7171e1f590a720f07cf9832
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414436
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-01 19:35:23 +00:00

17 lines
717 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
mat3 a;
mat3 b;
mat4 c;
mat4 d;
void main() {
mat2 h22 = mat2(0.0, 5.0, 10.0, 15.0);
mat4 h44 = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 5.5, 0.0, 0.0, 0.0, 0.0, 8.0);
mat4x3 f43 = mat4x3(12.0, 22.0, 30.0, 36.0, 40.0, 42.0, 42.0, 40.0, 36.0, 30.0, 22.0, 12.0);
sk_FragColor.xyz = matrixCompMult(a, b)[0];
sk_FragColor = matrixCompMult(c, d)[0];
sk_FragColor = (h22 == mat2(0.0, 5.0, 10.0, 15.0) && h44 == mat4(0.5, 0.0, 0.0, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 5.5, 0.0, 0.0, 0.0, 0.0, 8.0)) && f43 == mat4x3(12.0, 22.0, 30.0, 36.0, 40.0, 42.0, 42.0, 40.0, 36.0, 30.0, 22.0, 12.0) ? colorGreen : colorRed;
}