skia2/tests/sksl/intrinsics/Sqrt.glsl
John Stiles 443fa19832 Implement compile-time optimization for sqrt(constant).
Change-Id: I3427fbaf57787c3051db95ec5882c9292d7985cf
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411312
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-25 04:43:10 +00:00

11 lines
655 B
GLSL

out vec4 sk_FragColor;
uniform vec4 input;
uniform vec4 expected;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
const vec4 negativeVal = vec4(-1.0, -4.0, -16.0, -64.0);
return ((((((((((sqrt(input.x) == expected.x && sqrt(input.xy) == expected.xy) && sqrt(input.xyz) == expected.xyz) && sqrt(input) == expected) && 1.0 == expected.x) && vec2(1.0, 2.0) == expected.xy) && vec3(1.0, 2.0, 4.0) == expected.xyz) && vec4(1.0, 2.0, 4.0, 8.0) == expected) && sqrt(-1.0) == expected.x) && sqrt(vec2(-1.0, -4.0)) == expected.xy) && sqrt(vec3(-1.0, -4.0, -16.0)) == expected.xyz) && sqrt(negativeVal) == expected ? colorGreen : colorRed;
}