skia2/resources/sksl/intrinsics/Atan.sksl
John Stiles e4ac484ac0 Implement compile-time optimization for atan().
This is one of the few compile-time constant functions with a variable
number of arguments, but it's otherwise pretty normal as intrinsics go.

$genType  atan($genType  y, $genType  x);
$genHType atan($genHType y, $genHType x);
$genType  atan($genType  y_over_x);
$genHType atan($genHType y_over_x);

Change-Id: Ie852e10f37d73d53f69e806550872bc015f802d6
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/413439
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-06-01 15:16:43 +00:00

24 lines
1.3 KiB
Plaintext

uniform half4 input, expected;
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
const half4 constVal1 = half4(0);
const half4 constVal2 = half4(1);
return (atan(input.x) == expected.x &&
atan(input.xy) == expected.xy &&
atan(input.xyz) == expected.xyz &&
atan(input.xyzw) == expected.xyzw &&
atan(constVal1.x) == expected.x &&
atan(constVal1.xy) == expected.xy &&
atan(constVal1.xyz) == expected.xyz &&
atan(constVal1.xyzw) == expected.xyzw &&
atan(input.x, constVal2.x) == expected.x &&
atan(input.xy, constVal2.xy) == expected.xy &&
atan(input.xyz, constVal2.xyz) == expected.xyz &&
atan(input.xyzw, constVal2.xyzw) == expected.xyzw &&
atan(constVal1.x, constVal2.x) == expected.x &&
atan(constVal1.xy, constVal2.xy) == expected.xy &&
atan(constVal1.xyz, constVal2.xyz) == expected.xyz &&
atan(constVal1.xyzw, constVal2.xyzw) == expected.xyzw) ? colorGreen : colorRed;
}