Merge "opengl translator: add vertex attrib index validation."

This commit is contained in:
David Turner
2011-07-03 04:42:48 -07:00
committed by Android Code Review
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){
GET_CTX();
SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
ctx->enableArr(index,false);
ctx->dispatcher().glDisableVertexAttribArray(index);
}
@@ -471,6 +472,7 @@ GL_APICALL void GL_APIENTRY glEnable(GLenum cap){
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray(GLuint index){
GET_CTX();
SET_ERROR_IF(!(GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
ctx->enableArr(index,true);
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){
GET_CTX();
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);
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){
GET_CTX();
SET_ERROR_IF((!GLESv2Validate::arrayIndex(ctx,indx)),GL_INVALID_VALUE);
if (type == GL_HALF_FLOAT_OES) type = GL_HALF_FLOAT;
ctx->setPointer(indx,size,type,stride,ptr,normalized);
}

View File

@@ -136,3 +136,7 @@ bool GLESv2Validate::precisionType(GLenum type){
}
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 shaderType(GLenum type);
static bool precisionType(GLenum type);
static bool arrayIndex(GLEScontext * ctx,GLuint index);
};
#endif