Fix bad FP codegen when sample() calls are inlined.
Previously, temp variables created by sample() calls were named after
the offset of the sample() call within the code. This was
straightforward but would fail if the sample() call were duplicated via
inlining of helper functions.
FP sample() temp variables are now named using a counter, starting from
zero and counting upwards.
Change-Id: I16f9a3426117677c0df13d15772320def99cc0d6
Bug: skia:10858
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331415
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/effects/generated/GrMixerEffect.cpp b/src/gpu/effects/generated/GrMixerEffect.cpp
index aca71b6..32fb8f4 100644
--- a/src/gpu/effects/generated/GrMixerEffect.cpp
+++ b/src/gpu/effects/generated/GrMixerEffect.cpp
@@ -28,18 +28,18 @@
(void)weight;
weightVar = args.fUniformHandler->addUniform(&_outer, kFragment_GrShaderFlag,
kHalf_GrSLType, "weight");
- SkString _sample1099 = this->invokeChild(0, args);
+ SkString _sample0 = this->invokeChild(0, args);
fragBuilder->codeAppendf(
- R"SkSL(half4 inColor = %s;)SkSL", _sample1099.c_str());
- SkString _input1138("inColor");
- SkString _sample1138 = this->invokeChild(1, _input1138.c_str(), args);
- SkString _input1160("inColor");
- SkString _sample1160 = this->invokeChild(2, _input1160.c_str(), args);
+ R"SkSL(half4 inColor = %s;)SkSL", _sample0.c_str());
+ SkString _input1("inColor");
+ SkString _sample1 = this->invokeChild(1, _input1.c_str(), args);
+ SkString _input2("inColor");
+ SkString _sample2 = this->invokeChild(2, _input2.c_str(), args);
fragBuilder->codeAppendf(
R"SkSL(
%s = mix(%s, %s, %s);
)SkSL",
- args.fOutputColor, _sample1138.c_str(), _sample1160.c_str(),
+ args.fOutputColor, _sample1.c_str(), _sample2.c_str(),
args.fUniformHandler->getUniformCStr(weightVar));
}