skia2/tests/sksl/intrinsics/Inverse.glsl
John Stiles b01c18625e Implement compile-time optimization for inverse().
$squareMat inverse($squareMat m);
$squareHMat inverse($squareHMat m);

Change-Id: I1a2b067dd276bb999107712c38d0124811b95e39
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412937
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-27 13:57:00 +00:00

11 lines
647 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
mat2 inv2x2 = mat2(-2.0, 1.0, 1.5, -0.5);
mat3 inv3x3 = mat3(-24.0, 18.0, 5.0, 20.0, -15.0, -4.0, -5.0, 4.0, 1.0);
mat4 inv4x4 = mat4(-2.0, -0.5, 1.0, 0.5, 1.0, 0.5, 0.0, -0.5, -8.0, -1.0, 2.0, 2.0, 3.0, 0.5, -1.0, -0.5);
return ((mat2(-2.0, 1.0, 1.5, -0.5) == inv2x2 && mat3(-24.0, 18.0, 5.0, 20.0, -15.0, -4.0, -5.0, 4.0, 1.0) == inv3x3) && mat4(-2.0, -0.5, 1.0, 0.5, 1.0, 0.5, 0.0, -0.5, -8.0, -1.0, 2.0, 2.0, 3.0, 0.5, -1.0, -0.5) == inv4x4) && inverse(mat3(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) != inv3x3 ? colorGreen : colorRed;
}