aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLProgramBuilder.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-05-04 13:10:59 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-04 13:11:09 +0000
commit421fe443f833c916e6c3616f92570c8920b030f9 (patch)
treef71a0ee54350b5ad77512976f0363b8e62476028 /src/gpu/glsl/GrGLSLProgramBuilder.cpp
parent5c1b360a89f85accd7dc446670f6f062c73e7e77 (diff)
Revert "Revert "Revert "eliminated GrGLSLExpr"""
This reverts commit 796001c82eca5651bc6a221204f6186918781daf. Reason for revert: looks to be causing problems in Chrome (https://storage.googleapis.com/chromium-layout-test-archives/WebKit_Linux_Trusty__dbg_/1553/layout-test-results/results.html) Original change's description: > Revert "Revert "eliminated GrGLSLExpr"" > > This reverts commit 5e550ab57e0204bfadd2cb69c47d2a85e38d6a4c. > > Bug: skia: > Change-Id: I4705e47dbd209aa8f43db3d28c856bd3aa9e49ab > Reviewed-on: https://skia-review.googlesource.com/15187 > Reviewed-by: Ethan Nicholas <ethannicholas@google.com> > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > TBR=ethannicholas@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I6455a4f16b2dc0d6d1265541f7117e0cfb8dd91c Reviewed-on: https://skia-review.googlesource.com/15309 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/glsl/GrGLSLProgramBuilder.cpp')
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 3094f194ec..12e7ca2c1d 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -53,24 +53,24 @@ void GrGLSLProgramBuilder::addFeature(GrShaderFlags shaders,
}
}
-bool GrGLSLProgramBuilder::emitAndInstallProcs() {
+bool GrGLSLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor,
+ GrGLSLExpr4* inputCoverage) {
// First we loop over all of the installed processors and collect coord transforms. These will
// be sent to the GrGLSLPrimitiveProcessor in its emitCode function
const GrPrimitiveProcessor& primProc = this->primitiveProcessor();
- SkString inputColor;
- SkString inputCoverage;
- this->emitAndInstallPrimProc(primProc, &inputColor, &inputCoverage);
- this->emitAndInstallFragProcs(&inputColor, &inputCoverage);
- this->emitAndInstallXferProc(inputColor, inputCoverage);
+ this->emitAndInstallPrimProc(primProc, inputColor, inputCoverage);
+
+ this->emitAndInstallFragProcs(inputColor, inputCoverage);
+ this->emitAndInstallXferProc(*inputColor, *inputCoverage);
this->emitFSOutputSwizzle(this->pipeline().getXferProcessor().hasSecondaryOutput());
return this->checkSamplerCounts() && this->checkImageStorageCounts();
}
void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& proc,
- SkString* outputColor,
- SkString* outputCoverage) {
+ GrGLSLExpr4* outputColor,
+ GrGLSLExpr4* outputCoverage) {
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
this->nameExpression(outputColor, "outputColor");
@@ -139,16 +139,16 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
fFS.codeAppend("}");
}
-void GrGLSLProgramBuilder::emitAndInstallFragProcs(SkString* color, SkString* coverage) {
+void GrGLSLProgramBuilder::emitAndInstallFragProcs(GrGLSLExpr4* color, GrGLSLExpr4* coverage) {
int transformedCoordVarsIdx = 0;
- SkString** inOut = &color;
+ GrGLSLExpr4** inOut = &color;
for (int i = 0; i < this->pipeline().numFragmentProcessors(); ++i) {
if (i == this->pipeline().numColorFragmentProcessors()) {
inOut = &coverage;
}
- SkString output;
+ GrGLSLExpr4 output;
const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
- output = this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, output);
+ this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, &output);
GrFragmentProcessor::Iter iter(&fp);
while (const GrFragmentProcessor* fp = iter.next()) {
transformedCoordVarsIdx += fp->numCoordTransforms();
@@ -158,16 +158,15 @@ void GrGLSLProgramBuilder::emitAndInstallFragProcs(SkString* color, SkString* co
}
// TODO Processors cannot output zeros because an empty string is all 1s
-// the fix is to allow effects to take the SkString directly
-SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
- int index,
- int transformedCoordVarsIdx,
- const SkString& input,
- SkString output) {
- SkASSERT(input.size());
+// the fix is to allow effects to take the GrGLSLExpr4 directly
+void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
+ int index,
+ int transformedCoordVarsIdx,
+ const GrGLSLExpr4& input,
+ GrGLSLExpr4* output) {
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
- this->nameExpression(&output, "output");
+ this->nameExpression(output, "output");
// Enclose custom code in a block to avoid namespace conflicts
SkString openBrace;
@@ -194,8 +193,8 @@ SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor&
this->uniformHandler(),
this->shaderCaps(),
fp,
- output.c_str(),
- input.c_str(),
+ output->c_str(),
+ input.isOnes() ? nullptr : input.c_str(),
coords,
textureSamplers,
bufferSamplers,
@@ -210,11 +209,10 @@ SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor&
fFragmentProcessors.push_back(fragProc);
fFS.codeAppend("}");
- return output;
}
-void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
- const SkString& coverageIn) {
+void GrGLSLProgramBuilder::emitAndInstallXferProc(const GrGLSLExpr4& colorIn,
+ const GrGLSLExpr4& coverageIn) {
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
@@ -251,8 +249,8 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
this->uniformHandler(),
this->shaderCaps(),
xp,
- colorIn.size() ? colorIn.c_str() : "vec4(1)",
- coverageIn.size() ? coverageIn.c_str() : "vec4(1)",
+ colorIn.c_str(),
+ coverageIn.c_str(),
fFS.getPrimaryColorOutputName(),
fFS.getSecondaryColorOutputName(),
dstTextureSamplerHandle,
@@ -447,12 +445,12 @@ void GrGLSLProgramBuilder::nameVariable(SkString* out, char prefix, const char*
}
}
-void GrGLSLProgramBuilder::nameExpression(SkString* output, const char* baseName) {
+void GrGLSLProgramBuilder::nameExpression(GrGLSLExpr4* output, const char* baseName) {
// create var to hold stage result. If we already have a valid output name, just use that
// otherwise create a new mangled one. This name is only valid if we are reordering stages
// and have to tell stage exactly where to put its output.
SkString outName;
- if (output->size()) {
+ if (output->isValid()) {
outName = output->c_str();
} else {
this->nameVariable(&outName, '\0', baseName);