aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLEffect.cpp6
-rw-r--r--src/gpu/gl/GrGLEffect.h16
-rw-r--r--src/gpu/gl/GrGLProgram.cpp38
-rw-r--r--src/gpu/gl/GrGLProgram.h7
-rw-r--r--src/gpu/gl/GrGLShaderBuilder.cpp6
-rw-r--r--src/gpu/gl/GrGLShaderBuilder.h6
-rw-r--r--src/gpu/gl/GrGpuGL_program.cpp8
7 files changed, 43 insertions, 44 deletions
diff --git a/src/gpu/gl/GrGLEffect.cpp b/src/gpu/gl/GrGLEffect.cpp
index 3f8417c448..b53a1cf9bb 100644
--- a/src/gpu/gl/GrGLEffect.cpp
+++ b/src/gpu/gl/GrGLEffect.cpp
@@ -20,12 +20,12 @@ GrGLEffect::~GrGLEffect() {
void GrGLEffect::setData(const GrGLUniformManager&, const GrEffect&) {
}
-GrGLEffect::StageKey GrGLEffect::GenTextureKey(const GrEffect& effect,
+GrGLEffect::EffectKey GrGLEffect::GenTextureKey(const GrEffect& effect,
const GrGLCaps& caps) {
- StageKey key = 0;
+ EffectKey key = 0;
for (int index = 0; index < effect.numTextures(); ++index) {
const GrTextureAccess& access = effect.textureAccess(index);
- StageKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) << index;
+ EffectKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) << index;
GrAssert(0 == (value & key)); // keys for each access ought not to overlap
key |= value;
}
diff --git a/src/gpu/gl/GrGLEffect.h b/src/gpu/gl/GrGLEffect.h
index 404f275b30..132c3d78de 100644
--- a/src/gpu/gl/GrGLEffect.h
+++ b/src/gpu/gl/GrGLEffect.h
@@ -23,7 +23,7 @@ class GrGLTexture;
include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitting the
GLSL code that implements a GrEffect and for uploading uniforms at draw time. They also
must have a function:
- static inline StageKey GenKey(const GrEffect&, const GrGLCaps&)
+ static inline EffectKey GenKey(const GrEffect&, const GrGLCaps&)
that is used to implement a program cache. When two GrEffects produce the same key this means
that their GrGLEffects would emit the same GLSL code.
@@ -33,10 +33,10 @@ class GrGLTexture;
class GrGLEffect {
public:
- typedef GrEffect::StageKey StageKey;
+ typedef GrEffect::EffectKey EffectKey;
enum {
- // the number of bits in StageKey available to GenKey
- kProgramStageKeyBits = GrBackendEffectFactory::kProgramStageKeyBits,
+ // the number of bits in EffectKey available to GenKey
+ kEffectKeyBits = GrBackendEffectFactory::kEffectKeyBits,
};
typedef GrGLShaderBuilder::TextureSamplerArray TextureSamplerArray;
@@ -51,7 +51,7 @@ public:
@param builder Interface used to emit code in the shaders.
@param effect The effect that generated this program stage.
- @param key The key that was computed by StageKey() from the generating GrEffect.
+ @param key The key that was computed by EffectKey() from the generating GrEffect.
@param vertexCoords A vec2 of texture coordinates in the VS, which may be altered. This will
be removed soon and stages will be responsible for computing their own
coords.
@@ -68,7 +68,7 @@ public:
*/
virtual void emitCode(GrGLShaderBuilder* builder,
const GrEffect& effect,
- StageKey key,
+ EffectKey key,
const char* vertexCoords,
const char* outputColor,
const char* inputColor,
@@ -81,7 +81,7 @@ public:
const char* name() const { return fFactory.name(); }
- static StageKey GenTextureKey(const GrEffect&, const GrGLCaps&);
+ static EffectKey GenTextureKey(const GrEffect&, const GrGLCaps&);
protected:
@@ -107,7 +107,7 @@ public:
virtual void emitCode(GrGLShaderBuilder* builder,
const GrEffect&,
- StageKey,
+ EffectKey,
const char* vertexCoords,
const char* outputColor,
const char* inputColor,
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index cbcd2d5057..fd01e0d233 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -80,7 +80,7 @@ GrGLProgram::GrGLProgram(const GrGLContextInfo& gl,
fRTHeight = -1;
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
- fProgramStage[s] = NULL;
+ fEffects[s] = NULL;
fTextureMatrices[s] = GrMatrix::InvalidMatrix();
// this is arbitrary, just initialize to something
fTextureOrientation[s] = GrGLTexture::kBottomUp_Orientation;
@@ -104,7 +104,7 @@ GrGLProgram::~GrGLProgram() {
}
for (int i = 0; i < GrDrawState::kNumStages; ++i) {
- delete fProgramStage[i];
+ delete fEffects[i];
}
}
@@ -624,13 +624,13 @@ bool GrGLProgram::genProgram(const GrEffect** effects) {
}
builder.setCurrentStage(s);
- fProgramStage[s] = GenStageCode(effects[s],
- fDesc.fStages[s],
- &fUniforms.fStages[s],
- inColor.size() ? inColor.c_str() : NULL,
- outColor.c_str(),
- inCoords,
- &builder);
+ fEffects[s] = GenStageCode(effects[s],
+ fDesc.fStages[s],
+ &fUniforms.fStages[s],
+ inColor.size() ? inColor.c_str() : NULL,
+ outColor.c_str(),
+ inCoords,
+ &builder);
builder.setNonStage();
inColor = outColor;
}
@@ -729,13 +729,13 @@ bool GrGLProgram::genProgram(const GrEffect** effects) {
inCoverage.append("4");
}
builder.setCurrentStage(s);
- fProgramStage[s] = GenStageCode(effects[s],
- fDesc.fStages[s],
- &fUniforms.fStages[s],
- inCoverage.size() ? inCoverage.c_str() : NULL,
- outCoverage.c_str(),
- inCoords,
- &builder);
+ fEffects[s] = GenStageCode(effects[s],
+ fDesc.fStages[s],
+ &fUniforms.fStages[s],
+ inCoverage.size() ? inCoverage.c_str() : NULL,
+ outCoverage.c_str(),
+ inCoords,
+ &builder);
builder.setNonStage();
inCoverage = outCoverage;
}
@@ -957,7 +957,7 @@ GrGLEffect* GrGLProgram::GenStageCode(const GrEffect* effect,
builder->fFSCode.appendf("\t{ // %s \n", glStage->name());
glStage->emitCode(builder,
*effect,
- desc.fCustomStageKey,
+ desc.fEffectKey,
varyingVSName,
fsOutColor,
fsInColor,
@@ -975,10 +975,10 @@ void GrGLProgram::setData(const GrDrawState& drawState) {
fRTHeight = rtHeight;
}
for (int s = 0; s < GrDrawState::kNumStages; ++s) {
- if (NULL != fProgramStage[s]) {
+ if (NULL != fEffects[s]) {
const GrSamplerState& sampler = drawState.getSampler(s);
GrAssert(NULL != sampler.getEffect());
- fProgramStage[s]->setData(fUniformManager, *sampler.getEffect());
+ fEffects[s]->setData(fUniformManager, *sampler.getEffect());
}
}
}
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index 57c6d22a63..8adcd6278d 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -96,9 +96,8 @@ public:
uint8_t fOptFlags;
- /** Non-zero if user-supplied code will write the stage's
- contribution to the fragment shader. */
- GrBackendEffectFactory::StageKey fCustomStageKey;
+ /** Non-zero if this stage has an effect */
+ GrBackendEffectFactory::EffectKey fEffectKey;
inline bool isEnabled() const {
return SkToBool(fOptFlags & kIsEnabled_OptFlagBit);
@@ -254,7 +253,7 @@ private:
GrMatrix fTextureMatrices[GrDrawState::kNumStages];
GrGLTexture::Orientation fTextureOrientation[GrDrawState::kNumStages];
- GrGLEffect* fProgramStage[GrDrawState::kNumStages];
+ GrGLEffect* fEffects[GrDrawState::kNumStages];
Desc fDesc;
const GrGLContextInfo& fContextInfo;
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp
index a915cfa1ac..e736231ee9 100644
--- a/src/gpu/gl/GrGLShaderBuilder.cpp
+++ b/src/gpu/gl/GrGLShaderBuilder.cpp
@@ -153,9 +153,9 @@ void GrGLShaderBuilder::appendTextureLookupAndModulate(
GrGLSLModulate4f(out, modulation, lookup.c_str());
}
-GrEffect::StageKey GrGLShaderBuilder::KeyForTextureAccess(const GrTextureAccess& access,
- const GrGLCaps& caps) {
- GrEffect::StageKey key = 0;
+GrEffect::EffectKey GrGLShaderBuilder::KeyForTextureAccess(const GrTextureAccess& access,
+ const GrGLCaps& caps) {
+ GrEffect::EffectKey key = 0;
// Assume that swizzle support implies that we never have to modify a shader to adjust
// for texture format/swizzle settings.
diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h
index d60f33f7a3..fa68268576 100644
--- a/src/gpu/gl/GrGLShaderBuilder.h
+++ b/src/gpu/gl/GrGLShaderBuilder.h
@@ -119,11 +119,11 @@ public:
const char* body,
SkString* outName);
- /** Generates a StageKey for the shader code based on the texture access parameters and the
+ /** Generates a EffectKey for the shader code based on the texture access parameters and the
capabilities of the GL context. This is useful for keying the shader programs that may
have multiple representations, based on the type/format of textures used. */
- static GrEffect::StageKey KeyForTextureAccess(const GrTextureAccess& access,
- const GrGLCaps& caps);
+ static GrEffect::EffectKey KeyForTextureAccess(const GrTextureAccess& access,
+ const GrGLCaps& caps);
/** If texture swizzling is available using tex parameters then it is preferred over mangling
the generated shader code. This potentially allows greater reuse of cached shaders. */
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index dfb1123a3a..d0b7b57b6d 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -573,10 +573,10 @@ void setup_effect(GrGLProgram::Desc::StageDesc* stage,
const GrEffect* effect = sampler.getEffect();
if (effect) {
const GrBackendEffectFactory& factory = effect->getFactory();
- stage->fCustomStageKey = factory.glStageKey(*effect, caps);
+ stage->fEffectKey = factory.glEffectKey(*effect, caps);
effects[index] = effect;
} else {
- stage->fCustomStageKey = 0;
+ stage->fEffectKey = 0;
effects[index] = NULL;
}
}
@@ -695,8 +695,8 @@ void GrGpuGL::buildProgram(bool isPoints,
setup_effect(&stage, sampler, this->glCaps(), effects, fCurrentProgram.get(), s);
} else {
- stage.fOptFlags = 0;
- stage.fCustomStageKey = 0;
+ stage.fOptFlags = 0;
+ stage.fEffectKey = 0;
effects[s] = NULL;
}
}