skia2/resources/sksl/intrinsics/LessThan.sksl
John Stiles a5f1697d05 Optimize intrinsic vector comparisons of constants.
If every argument passed to lessThan/greaterThan/lessThanEqual/
greaterThanEqual/equal/notEqual() is a compile-time constant, we now
detect this and optimize away the function call entirely.

Change-Id: I3415d21be6ef51b38b682a792bd118fad51957f5
Bug: skia:10835
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404776
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-05-06 14:00:27 +00:00

13 lines
417 B
Plaintext

uniform half4 a, b;
uniform uint2 c, d;
uniform int3 e, f;
void main() {
bool4 expectTTFF = lessThan(half4(1, 2, 2.5, 2.75), half4(2.25));
bool4 expectFFTT = lessThan(int4(0), int4(-50, 0, 50, 100));
sk_FragColor.x = lessThan(a, b).x ? 1 : 0;
sk_FragColor.y = lessThan(c, d).y ? 1 : 0;
sk_FragColor.z = lessThan(e, f).z ? 1 : 0;
sk_FragColor.w = any(expectTTFF) || any(expectFFTT) ? 1 : 0;
}