aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLShaderBuilder.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-06 20:19:56 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-06 20:19:56 +0000
commita91f03165335267bda7cf04ae5ffb60c1362f017 (patch)
tree64d7c0e9a4cc83b0b1e9725dd97e55361f497ed9 /src/gpu/gl/GrGLShaderBuilder.cpp
parente65d76f0fce19bcff44e1179ef1eec5874a2a145 (diff)
Add a requiresVertexShader method to GrGLEffect
Adds requiresVertexShader to GrGLEffect and updates the necessary effects to override it and return true. Also reworks GrGLProgram and GrGLShaderBuilder so the program creates all the GL effects at the beginning, and determines if it needs a vertex shader before creating the shader builder. R=bsalomon@google.com Author: cdalton@nvidia.com Review URL: https://chromiumcodereview.appspot.com/23471008 git-svn-id: http://skia.googlecode.com/svn/trunk@11140 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLShaderBuilder.cpp')
-rw-r--r--src/gpu/gl/GrGLShaderBuilder.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index e62bfdebe8..5e00d7f1bb 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 needsVertexShader)
+ bool hasVertexShaderEffects)
: fUniforms(kVarsPerBlock)
, fCtxInfo(ctxInfo)
, fUniformManager(uniformManager)
@@ -106,9 +106,8 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo,
const GrGLProgramDesc::KeyHeader& header = desc.getHeader();
- if (needsVertexShader) {
- fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
- }
+ // TODO: go vertexless when possible.
+ fVertexBuilder.reset(SkNEW_ARGS(VertexBuilder, (this, desc)));
// Emit code to read the dst copy textue if necessary.
if (kNoDstRead_DstReadKey != header.fDstReadKey &&
@@ -217,7 +216,7 @@ void GrGLShaderBuilder::nameVariable(SkString* out, char prefix, const char* nam
const char* GrGLShaderBuilder::dstColor() {
if (fCodeStage.inStageCode()) {
- const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
+ const GrEffectRef& effect = *fCodeStage.effect();
if (!effect->willReadDstColor()) {
GrDebugCrash("GrGLEffect asked for dst color but its generating GrEffect "
"did not request access.");
@@ -363,7 +362,7 @@ GrGLUniformManager::UniformHandle GrGLShaderBuilder::addUniformArray(uint32_t vi
const char* GrGLShaderBuilder::fragmentPosition() {
if (fCodeStage.inStageCode()) {
- const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect();
+ const GrEffectRef& effect = *fCodeStage.effect();
if (!effect->willReadFragmentPosition()) {
GrDebugCrash("GrGLEffect asked for frag position but its generating GrEffect "
"did not request access.");
@@ -500,24 +499,23 @@ void GrGLShaderBuilder::finished(GrGLuint programID) {
}
void GrGLShaderBuilder::emitEffects(
- const GrEffectStage* effectStages[],
+ GrGLEffect* const glEffects[],
+ const GrDrawEffect drawEffects[],
const GrBackendEffectFactory::EffectKey effectKeys[],
int effectCnt,
SkString* fsInOutColor,
GrSLConstantVec* fsInOutColorKnownValue,
- SkTArray<GrGLUniformManager::UniformHandle, true>* effectSamplerHandles[],
- GrGLEffect* glEffects[]) {
+ SkTArray<GrGLUniformManager::UniformHandle, true>* effectSamplerHandles[]) {
bool effectEmitted = false;
SkString inColor = *fsInOutColor;
SkString outColor;
for (int e = 0; e < effectCnt; ++e) {
- SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect());
- const GrEffectStage& stage = *effectStages[e];
- const GrEffectRef& effect = *stage.getEffect();
+ const GrDrawEffect& drawEffect = drawEffects[e];
+ const GrEffectRef& effect = *drawEffect.effect();
- CodeStage::AutoStageRestore csar(&fCodeStage, &stage);
+ CodeStage::AutoStageRestore csar(&fCodeStage, &effect);
int numTextures = effect->numTextures();
SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
@@ -526,11 +524,9 @@ 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 = stage.getVertexAttribIndexCount();
- const int* attributeIndices = stage.getVertexAttribIndices();
+ int numAttributes = drawEffect.getVertexAttribIndexCount();
+ const int* attributeIndices = drawEffect.getVertexAttribIndices();
SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames;
for (int a = 0; a < numAttributes; ++a) {
// TODO: Make addAttribute mangle the name.
@@ -542,8 +538,6 @@ 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");