opengl translator: add vertex attrib index validation.
Fixed conformance test issue.
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 7e749a2..afb1ae4 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -433,6 +433,7 @@
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 glEnableVertexAttribArray(GLuint index){
GET_CTX();
+ SET_ERROR_IF(!(GLESv2Validate::arrayIndex(ctx,index)),GL_INVALID_VALUE);
ctx->enableArr(index,true);
ctx->dispatcher().glEnableVertexAttribArray(index);
}
@@ -849,8 +851,9 @@
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(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) {
*pointer = const_cast<void *>( p->getBufferData());
@@ -1249,6 +1252,7 @@
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);
}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
index ea8cbfd..429877c 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
@@ -136,3 +136,7 @@
}
return false;
}
+
+bool GLESv2Validate::arrayIndex(GLEScontext * ctx,GLuint index) {
+ return index < (GLuint)ctx->getCaps()->maxVertexAttribs;
+}
diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
index 6338914..f6212e8 100644
--- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
+++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.h
@@ -32,6 +32,7 @@
static bool readPixelFrmt(GLenum format);
static bool shaderType(GLenum type);
static bool precisionType(GLenum type);
+static bool arrayIndex(GLEScontext * ctx,GLuint index);
};
#endif