skia2/resources/sksl/intrinsics/Inverse.sksl
John Stiles fdcf153f6c Fix crash when inverse() is passed a constant variable.
Optimization for inverse() uses some custom logic which neglected to
look up the value of a constant variable before assuming it was a
FloatLiteral; our tests were not exercising this case.

Change-Id: Idc8f2cc24f6a8df7234062f5f15e8c39a08457e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440260
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 21:11:24 +00:00

15 lines
630 B
Plaintext

uniform half4 colorGreen, colorRed;
half4 main(float2 xy) {
const half2x2 mat2x2 = half2x2(1, 2, 3, 4);
half2x2 inv2x2 = half2x2(-2, 1, 1.5, -0.5);
half3x3 inv3x3 = half3x3(-24, 18, 5, 20, -15, -4, -5, 4, 1);
half4x4 inv4x4 = half4x4(-2, -0.5, 1, 0.5, 1, 0.5, 0, -0.5, -8, -1, 2, 2, 3, 0.5, -1, -0.5);
return (inverse(mat2x2) == inv2x2 &&
inverse(half3x3(1, 2, 3, 0, 1, 4, 5, 6, 0)) == inv3x3 &&
inverse(half4x4(1, 0, 0, 1, 0, 2, 1, 2, 2, 1, 0, 1, 2, 0, 1, 4)) == inv4x4 &&
inverse(half3x3(1, 2, 3, 4, 5, 6, 7, 8, 9)) != inv3x3)
? colorGreen : colorRed;
}