skia2/resources/sksl/intrinsics/Length.sksl
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

17 lines
608 B
Plaintext

uniform half4 input;
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
const half4 constVal = half4(3, 0, 4, 12);
half4 expected = half4(3, 3, 5, 13);
return (length(input.x) == expected.x &&
length(input.xy) == expected.y &&
length(input.xyz) == expected.z &&
length(input.xyzw) == expected.w &&
length(constVal.x) == expected.x &&
length(constVal.xy) == expected.y &&
length(constVal.xyz) == expected.z &&
length(constVal.xyzw) == expected.w) ? colorGreen : colorRed;
}