From a4acf12a9353ffc834d2c6ee673be447487963c9 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Mon, 30 Sep 2013 15:13:58 +0000 Subject: Revert "Add a requiresVertexShader method to GrGLEffect" This reverts commit 1a30a3af805b7ea688d4a0f0bfe373c204085a27. We're going to take a different direction for vertexless shaders. R=bsalomon@google.com Author: cdalton@nvidia.com Review URL: https://codereview.chromium.org/23464082 git-svn-id: http://skia.googlecode.com/svn/trunk@11521 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGLShaderBuilder.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/gpu/gl/GrGLShaderBuilder.cpp') diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index f73520c363..d11394a7b3 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -94,7 +94,7 @@ static const char kDstCopyColorName[] = "_dstColor"; GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, GrGLUniformManager& uniformManager, const GrGLProgramDesc& desc, - bool hasVertexShaderEffects) + bool needsVertexShader) : fUniforms(kVarsPerBlock) , fCtxInfo(ctxInfo) , fUniformManager(uniformManager) @@ -106,8 +106,9 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, const GrGLProgramDesc::KeyHeader& header = desc.getHeader(); - // TODO: go vertexless when possible. - fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc))); + if (needsVertexShader) { + fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc))); + } // Emit code to read the dst copy textue if necessary. if (kNoDstRead_DstReadKey != header.fDstReadKey && @@ -216,7 +217,7 @@ void GrGLShaderBuilder::nameVariable(SkString* out, char prefix, const char* nam const char* GrGLShaderBuilder::dstColor() { if (fCodeStage.inStageCode()) { - const GrEffectRef& effect = *fCodeStage.effect(); + const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect(); if (!effect->willReadDstColor()) { GrDebugCrash("GrGLEffect asked for dst color but its generating GrEffect " "did not request access."); @@ -362,7 +363,7 @@ GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi const char* GrGLShaderBuilder::fragmentPosition() { if (fCodeStage.inStageCode()) { - const GrEffectRef& effect = *fCodeStage.effect(); + const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect(); if (!effect->willReadFragmentPosition()) { GrDebugCrash("GrGLEffect asked for frag position but its generating GrEffect " "did not request access."); @@ -499,23 +500,24 @@ void GrGLShaderBuilder::finished(GrGLuint programID) { } void GrGLShaderBuilder::emitEffects( - GrGLEffect* const glEffects[], - const GrDrawEffect drawEffects[], + const GrEffectStage* effectStages[], const GrBackendEffectFactory::EffectKey effectKeys[], int effectCnt, SkString* fsInOutColor, GrSLConstantVec* fsInOutColorKnownValue, - SkTArray* effectSamplerHandles[]) { + SkTArray* effectSamplerHandles[], + GrGLEffect* glEffects[]) { bool effectEmitted = false; SkString inColor = *fsInOutColor; SkString outColor; for (int e = 0; e < effectCnt; ++e) { - const GrDrawEffect& drawEffect = drawEffects[e]; - const GrEffectRef& effect = *drawEffect.effect(); + SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()); + const GrEffectStage& stage = *effectStages[e]; + const GrEffectRef& effect = *stage.getEffect(); - CodeStage::AutoStageRestore csar(&fCodeStage, &effect); + CodeStage::AutoStageRestore csar(&fCodeStage, &stage); int numTextures = effect->numTextures(); SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; @@ -524,9 +526,11 @@ void GrGLShaderBuilder::emitEffects( textureSamplers[t].init(this, &effect->textureAccess(t), t); effectSamplerHandles[e]->push_back(textureSamplers[t].fSamplerUniform); } + GrDrawEffect drawEffect(stage, fVertexBuilder.get() + && fVertexBuilder->hasExplicitLocalCoords()); - int numAttributes = drawEffect.getVertexAttribIndexCount(); - const int* attributeIndices = drawEffect.getVertexAttribIndices(); + int numAttributes = stage.getVertexAttribIndexCount(); + const int* attributeIndices = stage.getVertexAttribIndices(); SkSTArray attributeNames; for (int a = 0; a < numAttributes; ++a) { // TODO: Make addAttribute mangle the name. @@ -538,6 +542,8 @@ void GrGLShaderBuilder::emitEffects( attributeName); } + glEffects[e] = effect->getFactory().createGLInstance(drawEffect); + if (kZeros_GrSLConstantVec == *fsInOutColorKnownValue) { // Effects have no way to communicate zeros, they treat an empty string as ones. this->nameVariable(&inColor, '\0', "input"); -- cgit v1.2.3