skia2/tests/sksl/intrinsics/Distance.glsl
John Stiles e1c2beb3be Implement compile-time optimization for distance().
float distance($genType p0, $genType p1);
half distance($genHType p0, $genHType p1);

Change-Id: I492a90c0fe5c950c878752d45c3b2dc6f2cd866e
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412379
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-05-26 14:11:58 +00:00

11 lines
473 B
GLSL

out vec4 sk_FragColor;
uniform vec4 pos1;
uniform vec4 pos2;
uniform vec4 colorGreen;
uniform vec4 colorRed;
vec4 main() {
vec4 expected = vec4(3.0, 3.0, 5.0, 13.0);
return ((((((distance(pos1.x, pos2.x) == expected.x && distance(pos1.xy, pos2.xy) == expected.y) && distance(pos1.xyz, pos2.xyz) == expected.z) && distance(pos1, pos2) == expected.w) && 3.0 == expected.x) && 3.0 == expected.y) && 5.0 == expected.z) && 13.0 == expected.w ? colorGreen : colorRed;
}