skia2/resources/sksl/inliner/NoInline.sksl
John Stiles 0dd1a77e12 Add noinline keyword to SkSL.
As you might expect, a function tagged with `noinline` will never be
considered as a candidate for inlining.

Change-Id: Ia098f8974e6de251d78bb2a76cd71db8a86bc19c
Bug: skia:11362
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/382337
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-03-10 15:39:48 +00:00

26 lines
453 B
Plaintext

uniform half4 color;
noinline half singleuse() {
return 1.25;
}
noinline half add(half a, half b) {
half c = a + b;
return c;
}
noinline half mul(half a, half b) {
return a * b;
}
noinline half fma(half a, half b, half c) {
return add(mul(a, b), c);
}
void main() {
// Functions used multiple times:
sk_FragColor = fma(color.x, color.y, color.z).xxxx;
// Functions used only once:
sk_FragColor *= singleuse();
}