Improve codegen for gradients.
Replacing `sk_OutColor = x` with `return x` in single-exit FP functions
results in fewer scratch variables in the final post-inliner output.
Change-Id: I81c081a78d0fb7dfad5230e3044027901673236c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324377
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/gradients/generated/GrLinearGradientLayout.cpp b/src/gpu/gradients/generated/GrLinearGradientLayout.cpp
index 505d98a..0ff8a9a 100644
--- a/src/gpu/gradients/generated/GrLinearGradientLayout.cpp
+++ b/src/gpu/gradients/generated/GrLinearGradientLayout.cpp
@@ -26,9 +26,9 @@
(void)_outer;
fragBuilder->codeAppendf(
R"SkSL(half t = half(%s.x) + 9.9999997473787516e-06;
-%s = half4(t, 1.0, 0.0, 0.0);
+return half4(t, 1.0, 0.0, 0.0);
)SkSL",
- args.fSampleCoord, args.fOutputColor);
+ args.fSampleCoord);
}
private:
@@ -45,7 +45,7 @@
(void)that;
return true;
}
-bool GrLinearGradientLayout::usesExplicitReturn() const { return false; }
+bool GrLinearGradientLayout::usesExplicitReturn() const { return true; }
GrLinearGradientLayout::GrLinearGradientLayout(const GrLinearGradientLayout& src)
: INHERITED(kGrLinearGradientLayout_ClassID, src.optimizationFlags()) {
this->cloneAndRegisterAllChildProcessors(src);