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

Unified Diff: src/gpu/gl/builders/GrGLProgramBuilder.cpp

Issue 678953002: Default geometry processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 1 month 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/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLProgramBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 8fc60201211e0a85c7189dfd717bca5ea7b9657f..62032f89c662b3c82c9f98c64fba6d5be41719ad 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -57,9 +57,11 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
bool hasVertexShader = !(header.fUseNvpr &&
gpu->glPathRendering()->texturingMode() ==
GrGLPathRendering::FixedFunction_TexturingMode);
+
if (hasVertexShader) {
- pb->fVS.setupLocalCoords();
- pb->fVS.transformGLToSkiaCoords();
+ pb->fVS.setupUniformViewMatrix();
+ pb->fVS.setupPositionAndLocalCoords();
+
if (header.fEmitsPointSize) {
pb->fVS.codeAppend("gl_PointSize = 1.0;");
}
@@ -75,10 +77,10 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
// remove this cast to a vec4.
GrGLSLExpr4 inputCoverageVec4 = GrGLSLExpr4::VectorCast(inputCoverage);
- pb->emitAndInstallProcs(optState, &inputColor, &inputCoverageVec4);
+ pb->emitAndInstallProcs(&inputColor, &inputCoverageVec4);
if (hasVertexShader) {
- pb->fVS.transformSkiaToGLCoords();
+ pb->fVS.transformToNormalizedDeviceSpace();
}
// write the secondary color output if necessary
@@ -171,7 +173,17 @@ GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray(uint32
UniformInfo& uni = fUniforms.push_back();
uni.fVariable.setType(type);
uni.fVariable.setTypeModifier(GrGLShaderVar::kUniform_TypeModifier);
- this->nameVariable(uni.fVariable.accessName(), 'u', name);
+ // TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
+ // the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
+ // exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
+ // the names will mismatch. I think the correct solution is to have all GPs which need the
+ // uniform view matrix, they should upload the view matrix in their setData along with regular
+ // uniforms.
+ char prefix = 'u';
+ if ('u' == name[0]) {
+ prefix = '\0';
+ }
+ this->nameVariable(uni.fVariable.accessName(), prefix, name);
uni.fVariable.setArrayCount(count);
uni.fVisibility = visibility;
@@ -230,14 +242,13 @@ void GrGLProgramBuilder::setupUniformColorAndCoverageIfNeeded(GrGLSLExpr4* input
}
}
-void GrGLProgramBuilder::emitAndInstallProcs(const GrOptDrawState& optState,
- GrGLSLExpr4* inputColor,
+void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor,
GrGLSLExpr4* inputCoverage) {
fFragmentProcessors.reset(SkNEW(GrGLInstalledFragProcs));
- int numProcs = optState.numFragmentStages();
- this->emitAndInstallFragProcs(0, optState.numColorStages(), inputColor);
- if (optState.hasGeometryProcessor()) {
- const GrGeometryProcessor& gp = *optState.getGeometryProcessor();
+ int numProcs = fOptState.numFragmentStages();
+ this->emitAndInstallFragProcs(0, fOptState.numColorStages(), inputColor);
+ if (fOptState.hasGeometryProcessor()) {
+ const GrGeometryProcessor& gp = *fOptState.getGeometryProcessor();
fVS.emitAttributes(gp);
ProcKeyProvider keyProvider(&fDesc,
ProcKeyProvider::kGeometry_ProcessorType,
@@ -246,7 +257,7 @@ void GrGLProgramBuilder::emitAndInstallProcs(const GrOptDrawState& optState,
this->emitAndInstallProc<GrGeometryProcessor>(gp, 0, keyProvider, *inputCoverage, &output);
*inputCoverage = output;
}
- this->emitAndInstallFragProcs(optState.numColorStages(), numProcs, inputCoverage);
+ this->emitAndInstallFragProcs(fOptState.numColorStages(), numProcs, inputCoverage);
}
void GrGLProgramBuilder::emitAndInstallFragProcs(int procOffset, int numProcs, GrGLSLExpr4* inOut) {
@@ -272,9 +283,14 @@ void GrGLProgramBuilder::emitAndInstallProc(const Proc& proc,
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
- // create var to hold stage result
+ // create var to hold stage result. If we already have a valid output name, just use that
+ // otherwise create a new mangled one.
SkString outColorName;
- this->nameVariable(&outColorName, '\0', "output");
+ if (output->isValid()) {
+ outColorName = output->c_str();
+ } else {
+ this->nameVariable(&outColorName, '\0', "output");
+ }
fFS.codeAppendf("vec4 %s;", outColorName.c_str());
*output = outColorName;
@@ -315,8 +331,8 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentStage& fs,
void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp,
const GrProcessorKey& key,
- const char* outColor,
- const char* inColor) {
+ const char* outCoverage,
+ const char* inCoverage) {
SkASSERT(!fGeometryProcessor);
fGeometryProcessor = SkNEW(GrGLInstalledGeoProc);
@@ -325,7 +341,7 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrGeometryProcessor& gp,
SkSTArray<4, GrGLProcessor::TextureSampler> samplers(gp.numTextures());
this->emitSamplers(gp, &samplers, fGeometryProcessor);
- GrGLGeometryProcessor::EmitArgs args(this, gp, key, outColor, inColor, samplers);
+ GrGLGeometryProcessor::EmitArgs args(this, gp, key, outCoverage, inCoverage, samplers);
fGeometryProcessor->fGLProc->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
@@ -374,23 +390,13 @@ void GrGLProgramBuilder::emitTransforms(const GrFragmentStage& effectStage,
suffixedVaryingName.appendf("_%i", t);
varyingName = suffixedVaryingName.c_str();
}
+ const char* coords = kPosition_GrCoordSet == effect->coordTransform(t).sourceCoords() ?
+ fVS.positionAttribute().c_str() :
+ fVS.localCoordsAttribute().c_str();
GrGLVertToFrag v(varyingType);
- this->addVarying(varyingName, &v);
-
- const GrGLShaderVar& coords =
- kPosition_GrCoordSet == effect->coordTransform(t).sourceCoords() ?
- fVS.positionAttribute() :
- fVS.localCoordsAttribute();
+ this->addCoordVarying(varyingName, &v, uniName, coords);
- // varying = matrix * coords (logically)
SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
- if (kVec2f_GrSLType == varyingType) {
- fVS.codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
- v.vsOut(), uniName, coords.c_str());
- } else {
- fVS.codeAppendf("%s = %s * vec3(%s, 1);",
- v.vsOut(), uniName, coords.c_str());
- }
SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
(SkString(v.fsIn()), varyingType));
}
« no previous file with comments | « src/gpu/gl/builders/GrGLProgramBuilder.h ('k') | src/gpu/gl/builders/GrGLVertexShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698