skia2/resources/sksl/intrinsics/Pow.sksl
John Stiles c3ff098020 Implement compile-time optimization for pow().
Change-Id: I1630cf6ecab6a1a18a7318c247f8263d87e2cda9
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412662
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-05-26 19:54:09 +00:00

17 lines
834 B
Plaintext

uniform half4 testInputs;
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
half4 expected = half4(-1.5625, 0, 0.75, 3.375);
const half4 constVal = half4(-1.25, 0, 0.75, 2.25);
const half4 exponents = half4(2, 3, 1, 1.5);
return (pow(testInputs.x, exponents.x) == expected.x &&
pow(testInputs.xy, exponents.xy) == expected.xy &&
pow(testInputs.xyz, exponents.xyz) == expected.xyz &&
pow(testInputs.xyzw, exponents.xyzw) == expected.xyzw &&
pow(constVal.x, exponents.x) == expected.x &&
pow(constVal.xy, exponents.xy) == expected.xy &&
pow(constVal.xyz, exponents.xyz) == expected.xyz &&
pow(constVal.xyzw, exponents.xyzw) == expected.xyzw) ? colorGreen : colorRed;
}