Add the inline keyword to top-level FPs that use an explicit return.
This CL also updates the GrMagnifierEffect to use `return` instead of
`sk_OutColor` in order to test the results in a large, rarely-used FP
that would not naturally be a very good candidate for inlining.
FPs that use a return statement can generate code that is very similar
to before. The visible differences:
- Variable/uniform names are slightly longer (extra `_c0`)
- The input coordinates are NOT copied to a temp variable.
- The result of the inline function is copied from a temp variable to
output_Stage1.
A diff for the curious: http://screen/9rRDmvXYCPnkjRZ
Change-Id: Icdbf22f047d944de7c018ca33970dd629dd4b7b0
Bug: skia:10549
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313152
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index d5b12af..4b144c1 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -179,10 +179,12 @@
output.c_str(),
input.c_str(),
"_coords",
- coords);
+ coords,
+ /*forceInline=*/true);
if (fp.usesExplicitReturn()) {
- // FPs that explicitly return their output color must be in a helper function
+ // FPs that explicitly return their output color must be in a helper function, but we inline
+ // it if at all possible.
args.fInputColor = "_input";
args.fOutputColor = "_output";
auto name = fFS.writeProcessorFunction(&glslFP, args);