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/GrTwoPointConicalGradientLayout.cpp b/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp
index 453189f..3e7becc 100644
--- a/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp
+++ b/src/gpu/gradients/generated/GrTwoPointConicalGradientLayout.cpp
@@ -109,7 +109,7 @@
}
break;
}
-%s = half4(half(t), v, 0.0, 0.0);
+return half4(half(t), v, 0.0, 0.0);
)SkSL",
(int)_outer.type, args.fUniformHandler->getUniformCStr(focalParamsVar),
args.fSampleCoord, args.fSampleCoord, args.fSampleCoord,
@@ -125,8 +125,7 @@
args.fSampleCoord, (_outer.isWellBehaved ? "true" : "false"),
(_outer.isRadiusIncreasing ? "true" : "false"),
(_outer.isNativelyFocal ? "true" : "false"),
- (_outer.isNativelyFocal ? "true" : "false"), (_outer.isSwapped ? "true" : "false"),
- args.fOutputColor);
+ (_outer.isNativelyFocal ? "true" : "false"), (_outer.isSwapped ? "true" : "false"));
}
private:
@@ -169,7 +168,7 @@
if (focalParams != that.focalParams) return false;
return true;
}
-bool GrTwoPointConicalGradientLayout::usesExplicitReturn() const { return false; }
+bool GrTwoPointConicalGradientLayout::usesExplicitReturn() const { return true; }
GrTwoPointConicalGradientLayout::GrTwoPointConicalGradientLayout(
const GrTwoPointConicalGradientLayout& src)
: INHERITED(kGrTwoPointConicalGradientLayout_ClassID, src.optimizationFlags())