Revert "Put top level FPs into their own functions"
This reverts commit 4e7ee6e0af49dc6acc7fbeee96af3a31a74c3d0a.
Bug: chromium: 1073106
Change-Id: Ifb02fef97560d2eaf3070b6d0daf130c8bff11a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285105
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 9b031f2..851bf4d 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -165,6 +165,11 @@
AutoStageAdvance adv(this);
this->nameExpression(&output, "output");
+ // Enclose custom code in a block to avoid namespace conflicts
+ SkString openBrace;
+ openBrace.printf("{ // Stage %d, %s\n", fStageIndex, fp.name());
+ fFS.codeAppend(openBrace.c_str());
+
GrGLSLFragmentProcessor* fragProc = fp.createGLSLInstance();
SkSTArray<4, SamplerHandle> texSamplers;
@@ -188,19 +193,19 @@
this->uniformHandler(),
this->shaderCaps(),
fp,
- "_output",
- "_input",
+ output.c_str(),
+ input.c_str(),
coords,
textureSamplers);
- auto name = fFS.writeProcessorFunction(fragProc, args);
- fFS.codeAppendf("%s = %s(%s);", output.c_str(), name.c_str(), input.c_str());
+ fragProc->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
// asks for dst color, then the emit code needs to follow suit
SkDEBUGCODE(verify(fp);)
glslFragmentProcessors->emplace_back(fragProc);
+ fFS.codeAppend("}");
return output;
}