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

Unified Diff: src/gpu/gl/GrGLProgram.cpp

Issue 13296005: Revise attribute binding interface (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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
Index: src/gpu/gl/GrGLProgram.cpp
===================================================================
--- src/gpu/gl/GrGLProgram.cpp (revision 8436)
+++ src/gpu/gl/GrGLProgram.cpp (working copy)
@@ -417,9 +417,7 @@
bool GrGLProgram::genProgram(const GrEffectStage* stages[]) {
GrAssert(0 == fProgramID);
- const GrAttribBindings& attribBindings = fDesc.fAttribBindings;
- bool hasExplicitLocalCoords =
- SkToBool(attribBindings & GrDrawState::kLocalCoords_AttribBindingsBit);
+ bool hasExplicitLocalCoords = -1 != fDesc.fLocalCoordAttributeIndex;
GrGLShaderBuilder builder(fContext.info(), fUniformManager, hasExplicitLocalCoords);
#if GR_GL_EXPERIMENTAL_GS
@@ -705,14 +703,17 @@
GL_CALL(BindAttribLocation(fProgramID,
fDesc.fPositionAttributeIndex,
builder.positionAttribute().c_str()));
- GL_CALL(BindAttribLocation(fProgramID, fDesc.fColorAttributeIndex, COL_ATTR_NAME));
- GL_CALL(BindAttribLocation(fProgramID, fDesc.fCoverageAttributeIndex, COV_ATTR_NAME));
-
- if (fDesc.fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) {
+ if (-1 != fDesc.fLocalCoordAttributeIndex) {
GL_CALL(BindAttribLocation(fProgramID,
- fDesc.fLocalCoordsAttributeIndex,
+ fDesc.fLocalCoordAttributeIndex,
builder.localCoordsAttribute().c_str()));
}
+ if (-1 != fDesc.fColorAttributeIndex) {
+ GL_CALL(BindAttribLocation(fProgramID, fDesc.fColorAttributeIndex, COL_ATTR_NAME));
+ }
+ if (-1 != fDesc.fCoverageAttributeIndex) {
+ GL_CALL(BindAttribLocation(fProgramID, fDesc.fCoverageAttributeIndex, COV_ATTR_NAME));
+ }
const GrGLShaderBuilder::AttributePair* attribEnd = builder.getEffectAttributes().end();
for (const GrGLShaderBuilder::AttributePair* attrib = builder.getEffectAttributes().begin();
@@ -791,8 +792,7 @@
const GrEffectStage& stage = drawState.getStage(s);
GrAssert(NULL != stage.getEffect());
- bool explicitLocalCoords =
- (fDesc.fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit);
+ bool explicitLocalCoords = -1 != fDesc.fLocalCoordAttributeIndex;
GrDrawEffect drawEffect(stage, explicitLocalCoords);
fEffects[s]->setData(fUniformManager, drawEffect);
int numSamplers = fUniformHandles.fSamplerUnis[s].count();
@@ -812,15 +812,23 @@
void GrGLProgram::setColor(const GrDrawState& drawState,
GrColor color,
SharedGLState* sharedState) {
- if (!(drawState.getAttribBindings() & GrDrawState::kColor_AttribBindingsBit)) {
+ if (!drawState.hasColorVertexAttribute()) {
switch (fDesc.fColorInput) {
case GrGLProgramDesc::kAttribute_ColorInput:
- if (sharedState->fConstAttribColor != color) {
+ GrAssert(-1 != fDesc.fColorAttributeIndex);
+ if (sharedState->fConstAttribColor != color ||
+ sharedState->fConstAttribColorIndex != fDesc.fColorAttributeIndex) {
// OpenGL ES only supports the float varieties of glVertexAttrib
GrGLfloat c[4];
GrColorToRGBAFloat(color, c);
GL_CALL(VertexAttrib4fv(fDesc.fColorAttributeIndex, c));
sharedState->fConstAttribColor = color;
+ sharedState->fConstAttribColorIndex = fDesc.fColorAttributeIndex;
+ // Reset const coverage if it previously had the same index as us
+ if (sharedState->fConstAttribColorIndex ==
+ sharedState->fConstAttribCoverageIndex) {
+ sharedState->fConstAttribCoverageIndex = -1;
+ }
}
break;
case GrGLProgramDesc::kUniform_ColorInput:
@@ -846,15 +854,22 @@
void GrGLProgram::setCoverage(const GrDrawState& drawState,
GrColor coverage,
SharedGLState* sharedState) {
- if (!(drawState.getAttribBindings() & GrDrawState::kCoverage_AttribBindingsBit)) {
+ if (!drawState.hasCoverageVertexAttribute()) {
switch (fDesc.fCoverageInput) {
case GrGLProgramDesc::kAttribute_ColorInput:
- if (sharedState->fConstAttribCoverage != coverage) {
+ if (sharedState->fConstAttribCoverage != coverage ||
+ sharedState->fConstAttribCoverageIndex != fDesc.fCoverageAttributeIndex) {
// OpenGL ES only supports the float varieties of glVertexAttrib
GrGLfloat c[4];
GrColorToRGBAFloat(coverage, c);
GL_CALL(VertexAttrib4fv(fDesc.fCoverageAttributeIndex, c));
sharedState->fConstAttribCoverage = coverage;
+ sharedState->fConstAttribCoverageIndex = fDesc.fCoverageAttributeIndex;
+ // Reset const color if it previously had the same index as us
+ if (sharedState->fConstAttribCoverageIndex ==
+ sharedState->fConstAttribColorIndex) {
+ sharedState->fConstAttribColorIndex = -1;
+ }
}
break;
case GrGLProgramDesc::kUniform_ColorInput:

Powered by Google App Engine
This is Rietveld 408576698