Ensure all vertex attributes (except zero that we always use) are disabled after a resetContext.
Review URL: http://codereview.appspot.com/5309043/ git-svn-id: http://skia.googlecode.com/svn/trunk@2494 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7a17e3a34f
commit
b5b5eaff47
@ -61,7 +61,7 @@ public:
|
|||||||
void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const;
|
void overrideBlend(GrBlendCoeff* srcCoeff, GrBlendCoeff* dstCoeff) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute indices
|
* Attribute indices. These should not overlap. Matrices consume 3 slots.
|
||||||
*/
|
*/
|
||||||
static int PositionAttributeIdx() { return 0; }
|
static int PositionAttributeIdx() { return 0; }
|
||||||
static int TexCoordAttributeIdx(int tcIdx) { return 1 + tcIdx; }
|
static int TexCoordAttributeIdx(int tcIdx) { return 1 + tcIdx; }
|
||||||
@ -72,10 +72,10 @@ public:
|
|||||||
static int EdgeAttributeIdx() { return 3 + GrDrawTarget::kMaxTexCoords; }
|
static int EdgeAttributeIdx() { return 3 + GrDrawTarget::kMaxTexCoords; }
|
||||||
|
|
||||||
static int ViewMatrixAttributeIdx() {
|
static int ViewMatrixAttributeIdx() {
|
||||||
return 2 + GrDrawTarget::kMaxTexCoords;
|
return 4 + GrDrawTarget::kMaxTexCoords;
|
||||||
}
|
}
|
||||||
static int TextureMatrixAttributeIdx(int stage) {
|
static int TextureMatrixAttributeIdx(int stage) {
|
||||||
return 5 + GrDrawTarget::kMaxTexCoords + 3 * stage;
|
return 7 + GrDrawTarget::kMaxTexCoords + 3 * stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -325,6 +325,8 @@ GrGpuGLShaders::GrGpuGLShaders(const GrGLInterface* gl)
|
|||||||
this->hasExtension("GL_OES_standard_derivatives");
|
this->hasExtension("GL_OES_standard_derivatives");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GR_GL_GetIntegerv(gl, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttribs);
|
||||||
|
|
||||||
fProgramData = NULL;
|
fProgramData = NULL;
|
||||||
fProgramCache = new ProgramCache(gl, glslVersion);
|
fProgramCache = new ProgramCache(gl, glslVersion);
|
||||||
|
|
||||||
@ -361,14 +363,27 @@ void GrGpuGLShaders::recordHWSamplerMatrix(int stage, const GrMatrix& matrix) {
|
|||||||
void GrGpuGLShaders::resetContext() {
|
void GrGpuGLShaders::resetContext() {
|
||||||
INHERITED::resetContext();
|
INHERITED::resetContext();
|
||||||
|
|
||||||
fHWGeometryState.fVertexLayout = 0;
|
|
||||||
fHWGeometryState.fVertexOffset = ~0;
|
fHWGeometryState.fVertexOffset = ~0;
|
||||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::ColorAttributeIdx()));
|
|
||||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::EdgeAttributeIdx()));
|
// Third party GL code may have left vertex attributes enabled. Some GL
|
||||||
for (int t = 0; t < kMaxTexCoords; ++t) {
|
// implementations (osmesa) may read vetex attributes that are not required
|
||||||
GL_CALL(DisableVertexAttribArray(GrGLProgram::TexCoordAttributeIdx(t)));
|
// by the current shader. Therefore, we have to ensure that only the
|
||||||
|
// attributes we require for the current draw are enabled or we may cause an
|
||||||
|
// invalid read.
|
||||||
|
|
||||||
|
// Disable all vertex layout bits so that next flush will assume all
|
||||||
|
// optional vertex attributes are disabled.
|
||||||
|
fHWGeometryState.fVertexLayout = 0;
|
||||||
|
|
||||||
|
// We always use the this attribute and assume it is always enabled.
|
||||||
|
int posAttrIdx = GrGLProgram::PositionAttributeIdx();
|
||||||
|
GL_CALL(EnableVertexAttribArray(posAttrIdx));
|
||||||
|
// Disable all other vertex attributes.
|
||||||
|
for (int va = 0; va < fMaxVertexAttribs; ++va) {
|
||||||
|
if (va != posAttrIdx) {
|
||||||
|
GL_CALL(DisableVertexAttribArray(va));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
GL_CALL(EnableVertexAttribArray(GrGLProgram::PositionAttributeIdx()));
|
|
||||||
|
|
||||||
fHWProgramID = 0;
|
fHWProgramID = 0;
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,9 @@ private:
|
|||||||
CachedData* fProgramData;
|
CachedData* fProgramData;
|
||||||
GrGLuint fHWProgramID;
|
GrGLuint fHWProgramID;
|
||||||
GrGLProgram fCurrentProgram;
|
GrGLProgram fCurrentProgram;
|
||||||
|
// If we get rid of fixed function subclass this should move
|
||||||
|
// to the GLCaps struct in parent class
|
||||||
|
GrGLint fMaxVertexAttribs;
|
||||||
|
|
||||||
typedef GrGpuGL INHERITED;
|
typedef GrGpuGL INHERITED;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user