Revert r7901 & r7899 to allow DEPS roll
git-svn-id: http://skia.googlecode.com/svn/trunk@7909 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 781e15f..0ca84bc 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -35,14 +35,6 @@
inline const char* dual_source_output_name() { return "dualSourceOut"; }
}
-const GrGLProgram::AttribLayout GrGLProgram::kAttribLayouts[kGrVertexAttribTypeCount] = {
- {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType
- {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType
- {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType
- {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType
- {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType
-};
-
void GrGLProgram::BuildDesc(const GrDrawState& drawState,
bool isPoints,
GrDrawState::BlendOptFlags blendOpts,
@@ -60,24 +52,24 @@
GrDrawState::kEmitCoverage_BlendOptFlag));
// The descriptor is used as a cache key. Thus when a field of the
- // descriptor will not affect program generation (because of the attribute
- // bindings in use or other descriptor field settings) it should be set
+ // descriptor will not affect program generation (because of the vertex
+ // layout in use or other descriptor field settings) it should be set
// to a canonical value to avoid duplicate programs with different keys.
// Must initialize all fields or cache will have false negatives!
- desc->fAttribBindings = drawState.getAttribBindings();
+ desc->fVertexLayout = drawState.getVertexLayout();
desc->fEmitsPointSize = isPoints;
bool requiresAttributeColors = !skipColor &&
- SkToBool(desc->fAttribBindings & GrDrawState::kColor_AttribBindingsBit);
+ SkToBool(desc->fVertexLayout & GrDrawState::kColor_VertexLayoutBit);
bool requiresAttributeCoverage = !skipCoverage &&
- SkToBool(desc->fAttribBindings & GrDrawState::kCoverage_AttribBindingsBit);
+ SkToBool(desc->fVertexLayout & GrDrawState::kCoverage_VertexLayoutBit);
// fColorInput/fCoverageInput records how colors are specified for the program So we strip the
- // bits from the bindings to avoid false negatives when searching for an existing program in the
+ // bits from the layout to avoid false negatives when searching for an existing program in the
// cache.
- desc->fAttribBindings &= ~(GrDrawState::kColor_AttribBindingsBit | GrDrawState::kCoverage_AttribBindingsBit);
+ desc->fVertexLayout &= ~(GrDrawState::kColor_VertexLayoutBit | GrDrawState::kCoverage_VertexLayoutBit);
desc->fColorFilterXfermode = skipColor ?
SkXfermode::kDst_Mode :
@@ -85,8 +77,8 @@
// no reason to do edge aa or look at per-vertex coverage if coverage is ignored
if (skipCoverage) {
- desc->fAttribBindings &= ~(GrDrawState::kEdge_AttribBindingsBit |
- GrDrawState::kCoverage_AttribBindingsBit);
+ desc->fVertexLayout &= ~(GrDrawState::kEdge_VertexLayoutBit |
+ GrDrawState::kCoverage_VertexLayoutBit);
}
bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendOptFlag);
@@ -116,7 +108,7 @@
int lastEnabledStage = -1;
- if (!skipCoverage && (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit)) {
+ if (!skipCoverage && (desc->fVertexLayout & GrDrawState::kEdge_VertexLayoutBit)) {
desc->fVertexEdgeType = drawState.getVertexEdgeType();
desc->fDiscardIfOutsideEdge = drawState.getStencil().doesWrite();
} else {
@@ -163,7 +155,7 @@
// other coverage inputs
if (!hasCoverage) {
hasCoverage = requiresAttributeCoverage ||
- (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit);
+ (desc->fVertexLayout & GrDrawState::kEdge_VertexLayoutBit);
}
if (hasCoverage) {
@@ -190,43 +182,6 @@
}
}
}
-
- desc->fPositionAttributeIndex = drawState.getAttribIndex(GrDrawState::kPosition_AttribIndex);
- if (requiresAttributeColors) {
- desc->fColorAttributeIndex = drawState.getAttribIndex(GrDrawState::kColor_AttribIndex);
- } else {
- desc->fColorAttributeIndex = GrDrawState::kColorOverrideAttribIndexValue;
- }
- if (requiresAttributeCoverage) {
- desc->fCoverageAttributeIndex = drawState.getAttribIndex(GrDrawState::kCoverage_AttribIndex);
- } else {
- desc->fCoverageAttributeIndex = GrDrawState::kCoverageOverrideAttribIndexValue;
- }
- desc->fEdgeAttributeIndex = drawState.getAttribIndex(GrDrawState::kEdge_AttribIndex);
- desc->fTexCoordAttributeIndex = drawState.getAttribIndex(GrDrawState::kTexCoord_AttribIndex);
-
-#if GR_DEBUG
- // verify valid vertex attribute state
- const GrVertexAttrib* vertexAttribs = drawState.getVertexAttribs();
- GrAssert(desc->fPositionAttributeIndex < GrDrawState::kVertexAttribCnt);
- GrAssert(kAttribLayouts[vertexAttribs[desc->fPositionAttributeIndex].fType].fCount == 2);
- if (requiresAttributeColors) {
- GrAssert(desc->fColorAttributeIndex < GrDrawState::kVertexAttribCnt);
- GrAssert(kAttribLayouts[vertexAttribs[desc->fColorAttributeIndex].fType].fCount == 4);
- }
- if (requiresAttributeCoverage) {
- GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt);
- GrAssert(kAttribLayouts[vertexAttribs[desc->fCoverageAttributeIndex].fType].fCount == 4);
- }
- if (desc->fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
- GrAssert(desc->fEdgeAttributeIndex < GrDrawState::kVertexAttribCnt);
- GrAssert(kAttribLayouts[vertexAttribs[desc->fEdgeAttributeIndex].fType].fCount == 4);
- }
- if (GrDrawState::AttributesBindExplicitTexCoords(desc->fAttribBindings)) {
- GrAssert(desc->fTexCoordAttributeIndex < GrDrawState::kVertexAttribCnt);
- GrAssert(kAttribLayouts[vertexAttribs[desc->fTexCoordAttributeIndex].fType].fCount == 2);
- }
-#endif
}
GrGLProgram* GrGLProgram::Create(const GrGLContext& gl,
@@ -411,7 +366,7 @@
bool GrGLProgram::genEdgeCoverage(SkString* coverageVar,
GrGLShaderBuilder* builder) const {
- if (fDesc.fAttribBindings & GrDrawState::kEdge_AttribBindingsBit) {
+ if (fDesc.fVertexLayout & GrDrawState::kEdge_VertexLayoutBit) {
const char *vsName, *fsName;
builder->addVarying(kVec4f_GrSLType, "Edge", &vsName, &fsName);
builder->fVSAttrs.push_back().set(kVec4f_GrSLType,
@@ -690,7 +645,7 @@
GrAssert(0 == fProgramID);
GrGLShaderBuilder builder(fContext.info(), fUniformManager);
- const GrAttribBindings& attribBindings = fDesc.fAttribBindings;
+ const uint32_t& layout = fDesc.fVertexLayout;
#if GR_GL_EXPERIMENTAL_GS
builder.fUsesGS = fDesc.fExperimentalGS;
@@ -771,7 +726,7 @@
}
// add texture coordinates that are used to the list of vertex attr decls
- if (GrDrawState::AttributesBindExplicitTexCoords(attribBindings)) {
+ if (GrDrawState::VertexUsesTexCoords(layout)) {
builder.fVSAttrs.push_back().set(kVec2f_GrSLType,
GrGLShaderVar::kAttribute_TypeModifier,
TEX_ATTR_NAME);
@@ -793,7 +748,7 @@
const char* inCoords;
// figure out what our input coords are
- if (!GrDrawState::StageBindsExplicitTexCoords(attribBindings, s)) {
+ if (!GrDrawState::StageUsesTexCoords(layout, s)) {
inCoords = builder.positionAttribute().c_str();
} else {
// must have input tex coordinates if stage is enabled.
@@ -887,7 +842,7 @@
const char* inCoords;
// figure out what our input coords are
- if (!GrDrawState::StageBindsExplicitTexCoords(attribBindings, s)) {
+ if (!GrDrawState::StageUsesTexCoords(layout, s)) {
inCoords = builder.positionAttribute().c_str();
} else {
// must have input tex coordinates if stage is
@@ -1011,18 +966,13 @@
// Bind the attrib locations to same values for all shaders
GL_CALL(BindAttribLocation(fProgramID,
- fDesc.fPositionAttributeIndex,
+ kPositionAttributeIndex,
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::kEdge_AttribBindingsBit) {
- GL_CALL(BindAttribLocation(fProgramID, fDesc.fEdgeAttributeIndex, EDGE_ATTR_NAME));
- }
- if (GrDrawState::AttributesBindExplicitTexCoords(fDesc.fAttribBindings)) {
- GL_CALL(BindAttribLocation(fProgramID, fDesc.fTexCoordAttributeIndex, TEX_ATTR_NAME));
- }
-
+ GL_CALL(BindAttribLocation(fProgramID, kTexCoordAttributeIndex, TEX_ATTR_NAME));
+ GL_CALL(BindAttribLocation(fProgramID, kColorAttributeIndex, COL_ATTR_NAME));
+ GL_CALL(BindAttribLocation(fProgramID, kCoverageAttributeIndex, COV_ATTR_NAME));
+ GL_CALL(BindAttribLocation(fProgramID, kEdgeAttributeIndex, EDGE_ATTR_NAME));
+
GL_CALL(LinkProgram(fProgramID));
GrGLint linked = GR_GL_INIT_ZERO;
@@ -1110,14 +1060,14 @@
void GrGLProgram::setColor(const GrDrawState& drawState,
GrColor color,
SharedGLState* sharedState) {
- if (!(drawState.getAttribBindings() & GrDrawState::kColor_AttribBindingsBit)) {
+ if (!(drawState.getVertexLayout() & GrDrawState::kColor_VertexLayoutBit)) {
switch (fDesc.fColorInput) {
case GrGLProgram::Desc::kAttribute_ColorInput:
if (sharedState->fConstAttribColor != color) {
// OpenGL ES only supports the float varieties of glVertexAttrib
GrGLfloat c[4];
GrColorToRGBAFloat(color, c);
- GL_CALL(VertexAttrib4fv(fDesc.fColorAttributeIndex, c));
+ GL_CALL(VertexAttrib4fv(kColorAttributeIndex, c));
sharedState->fConstAttribColor = color;
}
break;
@@ -1144,14 +1094,14 @@
void GrGLProgram::setCoverage(const GrDrawState& drawState,
GrColor coverage,
SharedGLState* sharedState) {
- if (!(drawState.getAttribBindings() & GrDrawState::kCoverage_AttribBindingsBit)) {
+ if (!(drawState.getVertexLayout() & GrDrawState::kCoverage_VertexLayoutBit)) {
switch (fDesc.fCoverageInput) {
case Desc::kAttribute_ColorInput:
if (sharedState->fConstAttribCoverage != coverage) {
// OpenGL ES only supports the float varieties of glVertexAttrib
GrGLfloat c[4];
GrColorToRGBAFloat(coverage, c);
- GL_CALL(VertexAttrib4fv(fDesc.fCoverageAttributeIndex, c));
+ GL_CALL(VertexAttrib4fv(kCoverageAttributeIndex, c));
sharedState->fConstAttribCoverage = coverage;
}
break;