Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: src/gpu/gl/GrGLProgram.cpp

Issue 14925010: Move loops that chain together effects into GrGLShaderBuilder from GrGLProgram. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Address comments and fix for emitting code for skipped effects Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLEffectMatrix.cpp ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLProgram.cpp
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 1b4baa40ea0c956a33d9d6112efc29633aebb829..1b9c3a293a266d281506d9096f3d4455141fec0b 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -485,35 +485,21 @@ bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
bool needColor, needFilterColor;
need_blend_inputs(filterColorCoeff, colorCoeff, &needFilterColor, &needColor);
+ // used in order for builder to return the per-stage uniform handles.
+ SkTArray<GrGLUniformManager::UniformHandle, true>* stageUniformArrays[GrDrawState::kNumStages];
+
if (needColor) {
- ///////////////////////////////////////////////////////////////////////////
- // compute the color
- // if we have color stages string them together, feeding the output color
- // of each to the next and generating code for each stage.
- SkString outColor;
for (int s = 0; s < fDesc.fFirstCoverageStage; ++s) {
- if (GrGLEffect::kNoEffectKey != fDesc.fEffectKeys[s]) {
- if (kZeros_GrSLConstantVec == knownColorValue) {
- // Effects have no way to communicate zeros, they treat an empty string as ones.
- inColor = "initialColor";
- builder.fsCodeAppendf("\tvec4 %s = %s;\n", inColor.c_str(), GrGLSLZerosVecf(4));
- }
- // create var to hold stage result
- outColor = "color";
- outColor.appendS32(s);
- builder.fsCodeAppendf("\tvec4 %s;\n", outColor.c_str());
-
- builder.setCurrentStage(s);
- fEffects[s] = builder.createAndEmitGLEffect(*stages[s],
- fDesc.fEffectKeys[s],
- inColor.size() ? inColor.c_str() : NULL,
- outColor.c_str(),
- &fUniformHandles.fEffectSamplerUnis[s]);
- builder.setNonStage();
- inColor = outColor;
- knownColorValue = kNone_GrSLConstantVec;
- }
+ stageUniformArrays[s] = &fUniformHandles.fEffectSamplerUnis[s];
}
+
+ builder.emitEffects(stages,
+ fDesc.fEffectKeys,
+ fDesc.fFirstCoverageStage,
+ &inColor,
+ &knownColorValue,
+ stageUniformArrays,
+ fEffects);
}
// Insert the color filter. This will soon be replaced by a color effect.
@@ -540,37 +526,21 @@ bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
///////////////////////////////////////////////////////////////////////////
// compute the partial coverage
-
- // incoming coverage to current stage being processed.
SkString inCoverage;
GrSLConstantVec knownCoverageValue = this->genInputCoverage(&builder, &inCoverage);
- SkString outCoverage;
- for (int s = fDesc.fFirstCoverageStage; s < GrDrawState::kNumStages; ++s) {
- if (fDesc.fEffectKeys[s]) {
- if (kZeros_GrSLConstantVec == knownCoverageValue) {
- // Effects have no way to communicate zeros, they treat an empty string as ones.
- inCoverage = "initialCoverage";
- builder.fsCodeAppendf("\tvec4 %s = %s;\n", inCoverage.c_str(), GrGLSLZerosVecf(4));
- }
- // create var to hold stage output
- outCoverage = "coverage";
- outCoverage.appendS32(s);
- builder.fsCodeAppendf("\tvec4 %s;\n", outCoverage.c_str());
-
- builder.setCurrentStage(s);
- fEffects[s] = builder.createAndEmitGLEffect(
- *stages[s],
- fDesc.fEffectKeys[s],
- inCoverage.size() ? inCoverage.c_str() : NULL,
- outCoverage.c_str(),
- &fUniformHandles.fEffectSamplerUnis[s]);
- builder.setNonStage();
- inCoverage = outCoverage;
- knownCoverageValue = kNone_GrSLConstantVec;
- }
+ for (int s = fDesc.fFirstCoverageStage, i = 0; s < GrDrawState::kNumStages; ++s, ++i) {
+ stageUniformArrays[i] = &fUniformHandles.fEffectSamplerUnis[s];
}
+ builder.emitEffects(stages + fDesc.fFirstCoverageStage,
+ fDesc.fEffectKeys + fDesc.fFirstCoverageStage,
+ GrDrawState::kNumStages - fDesc.fFirstCoverageStage,
+ &inCoverage,
+ &knownCoverageValue,
+ stageUniformArrays,
+ fEffects + fDesc.fFirstCoverageStage);
+
// discard if coverage is zero
if (fDesc.fDiscardIfZeroCoverage && kOnes_GrSLConstantVec != knownCoverageValue) {
if (kZeros_GrSLConstantVec == knownCoverageValue) {
« no previous file with comments | « src/gpu/gl/GrGLEffectMatrix.cpp ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698