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

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

Issue 671023002: Added varying struct (Closed) Base URL: https://skia.googlesource.com/skia.git@gp_emit_struct
Patch Set: cleanup Created 6 years, 2 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/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 a628febb6962336b0165dd750a1577f76686e5d1..28d15174238d8ad198cc6a3dee39866cb2ef4a8a 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -126,13 +126,19 @@ GrGLProgramBuilder::GrGLProgramBuilder(GrGpuGL* gpu,
, fUniforms(kVarsPerBlock) {
}
-void GrGLProgramBuilder::addVarying(GrSLType type,
- const char* name,
- const char** vsOutName,
- const char** fsInName,
+void GrGLProgramBuilder::addVarying(const char* name,
+ GrGLVarying* varying,
GrGLShaderVar::Precision fsPrecision) {
- SkString* fsInputName = fVS.addVarying(type, name, vsOutName);
- fFS.addVarying(type, fsInputName->c_str(), fsInName, fsPrecision);
+ SkASSERT(varying);
+ if (varying->vsVarying()) {
+ fVS.addVarying(name, varying);
+ }
+ if (fOptState.hasGeometryProcessor() && fOptState.getGeometryProcessor()->willUseGeoShader()) {
+ fGS.addVarying(name, varying);
+ }
+ if (varying->fsVarying()) {
+ fFS.addVarying(varying, fsPrecision);
+ }
}
void GrGLProgramBuilder::nameVariable(SkString* out, char prefix, const char* name) {
@@ -362,9 +368,8 @@ void GrGLProgramBuilder::emitTransforms(const GrFragmentStage& effectStage,
suffixedVaryingName.appendf("_%i", t);
varyingName = suffixedVaryingName.c_str();
}
- const char* vsVaryingName;
- const char* fsVaryingName;
- this->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName);
+ GrGLVertToFrag v(varyingType);
+ this->addVarying(varyingName, &v);
const GrGLShaderVar& coords =
kPosition_GrCoordSet == effect->coordTransform(t).sourceCoords() ?
@@ -375,13 +380,13 @@ void GrGLProgramBuilder::emitTransforms(const GrFragmentStage& effectStage,
SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType);
if (kVec2f_GrSLType == varyingType) {
fVS.codeAppendf("%s = (%s * vec3(%s, 1)).xy;",
- vsVaryingName, uniName, coords.c_str());
+ v.vsOut(), uniName, coords.c_str());
} else {
fVS.codeAppendf("%s = %s * vec3(%s, 1);",
- vsVaryingName, uniName, coords.c_str());
+ v.vsOut(), uniName, coords.c_str());
}
SkNEW_APPEND_TO_TARRAY(outCoords, GrGLProcessor::TransformedCoords,
- (SkString(fsVaryingName), varyingType));
+ (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