Chromium Code Reviews| Index: src/gpu/gl/GrGLShaderBuilder.cpp |
| diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp |
| index f73520c363f268a7666689d2a4b26404afbcaea0..0d09606ddcfbbb7d9bdc351ecd4a817c1a71a2e4 100644 |
| --- a/src/gpu/gl/GrGLShaderBuilder.cpp |
| +++ b/src/gpu/gl/GrGLShaderBuilder.cpp |
| @@ -102,12 +102,21 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, |
| , fFSInputs(kVarsPerBlock) |
| , fFSOutputs(kMaxFSOutputs) |
| , fSetupFragPosition(false) |
| - , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFragPosKey) { |
| + , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFragPosKey) |
| + , fNumTexGenUnits(0) { |
| const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); |
| - // TODO: go vertexless when possible. |
| - fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc))); |
| + // We only go without a vertex shader if every effect supports vertexless mode, the context |
| + // has fixed function/path rendering support, and position is the only vertex attribute. |
| + if (hasVertexShaderEffects || |
| + !ctxInfo.caps()->fixedFunctionSupport() || |
| + !ctxInfo.caps()->pathStencilingSupport() || |
| + -1 != header.fLocalCoordAttributeIndex || |
| + -1 != header.fColorAttributeIndex || |
| + -1 != header.fCoverageAttributeIndex) { |
| + fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc))); |
| + } |
| // Emit code to read the dst copy textue if necessary. |
| if (kNoDstRead_DstReadKey != header.fDstReadKey && |
| @@ -434,6 +443,23 @@ void GrGLShaderBuilder::fsEmitFunction(GrSLType returnType, |
| fFSFunctions.append("}\n\n"); |
| } |
| +void GrGLShaderBuilder::addTexGenUnit(GrSLType type, |
| + SkString* fsInName, |
| + int* unitIdx, |
| + int* numComponents) |
| +{ |
|
bsalomon
2013/09/10 13:51:06
style nit: { up on prev line
|
| + const int index = fNumTexGenUnits++; |
| + if (fsInName) { |
| + fsInName->printf("%s(gl_TexCoord[%u])", GrGLSLTypeString(type), index); |
| + } |
| + if (unitIdx) { |
| + *unitIdx = index; |
| + } |
| + if (numComponents) { |
| + *numComponents = GrSLTypeToVecLength(type); |
| + } |
| +} |
| + |
| namespace { |
| inline void append_default_precision_qualifier(GrGLShaderVar::Precision p, |