skia2/tests/sksl/intrinsics/Length.glsl
John Stiles 9b2baac1d6 Implement compile-time optimization for length().
float length($genType x);
half length($genHType x);

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

10 lines
418 B
GLSL

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