am d1018f5d: am 0e475161: Merge "opengl translator: add vertex attrib index validation."

* commit 'd1018f5df87a12c00c0bf35a28ce676c4b5efeca':
  opengl translator: add vertex attrib index validation.
This commit is contained in:
David Turner
2011-07-06 07:43:18 -07:00
committed by Android Git Automerger
3 changed files with 11 additions and 2 deletions

View File

@@ -433,6 +433,7 @@ GL_APICALL void GL_APIENTRY glDisable(GLenum cap){
GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index){ GL_APICALL void GL_APIENTRY glDisableVertexAttribArray(GLuint index){
GET_CTX(); GET_CTX();
SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
ctx->enableArr(index,false); ctx->enableArr(index,false);
ctx->dispatcher().glDisableVertexAttribArray(index); ctx->dispatcher().glDisableVertexAttribArray(index);
} }
@@ -471,6 +472,7 @@ GL_APICALL void GL_APIENTRY glEnable(GLenum cap){
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index){ GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index){
GET_CTX(); GET_CTX();
SET_ERROR_IF(!(GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
ctx->enableArr(index,true); ctx->enableArr(index,true);
ctx->dispatcher().glEnableVertexAttribArray(index); ctx->dispatcher().glEnableVertexAttribArray(index);
} }
@@ -850,6 +852,7 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLi
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){ GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer){
GET_CTX(); GET_CTX();
SET_ERROR_IF(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER,GL_INVALID_ENUM); SET_ERROR_IF(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER,GL_INVALID_ENUM);
SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
const GLESpointer* p = ctx->getPointer(index); const GLESpointer* p = ctx->getPointer(index);
if(p) { if(p) {
@@ -1249,6 +1252,7 @@ GL_APICALL void GL_APIENTRY glVertexAttrib4fv(GLuint indx, const GLfloat* value
GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){ GL_APICALL void GL_APIENTRY glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr){
GET_CTX(); GET_CTX();
SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,indx)),GL_INVALID_VALUE);
if (type == GL_HALF_FLOAT_OES) type = GL_HALF_FLOAT; if (type == GL_HALF_FLOAT_OES) type = GL_HALF_FLOAT;
ctx->setPointer(indx,size,type,stride,ptr,normalized); ctx->setPointer(indx,size,type,stride,ptr,normalized);
} }

View File

@@ -136,3 +136,7 @@ bool GLESv2Validate::precisionType(GLenum type){
} }
return false; return false;
} }
bool GLESv2Validate::arrayIndex(GLEScontext * ctx,GLuint index) {
return index < (GLuint)ctx->getCaps()->maxVertexAttribs;
}

View File

@@ -32,6 +32,7 @@ static bool pixelStoreParam(GLenum param);
static bool readPixelFrmt(GLenum format); static bool readPixelFrmt(GLenum format);
static bool shaderType(GLenum type); static bool shaderType(GLenum type);
static bool precisionType(GLenum type); static bool precisionType(GLenum type);
static bool arrayIndex(GLEScontext * ctx,GLuint index);
}; };
#endif #endif