OSDN Git Service

glVertexAttribPointer validation
authorAlexis Hetu <sugoi@google.com>
Wed, 15 Nov 2017 15:50:10 +0000 (10:50 -0500)
committerAlexis Hétu <sugoi@google.com>
Wed, 15 Nov 2017 16:07:46 +0000 (16:07 +0000)
GL_INVALID_OPERATION is generated if a non-zero vertex array object
is bound, zero is bound to the GL_ARRAY_BUFFER buffer object binding
point and the pointer argument is not NULL.

Change-Id: I48e73dca96bac2bd0496c202785e46e7d754dc11
Reviewed-on: https://swiftshader-review.googlesource.com/13830
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
src/OpenGL/libGLESv2/libGLESv2.cpp
src/OpenGL/libGLESv2/libGLESv3.cpp

index ffac13a..049b245 100644 (file)
@@ -26,6 +26,7 @@
 #include "Texture.h"
 #include "Query.h"
 #include "TransformFeedback.h"
+#include "VertexArray.h"
 #include "common/debug.h"
 #include "Common/Version.h"
 
@@ -6186,6 +6187,14 @@ void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normal
 
        if(context)
        {
+               es2::VertexArray* vertexArray = context->getCurrentVertexArray();
+               if((context->getArrayBufferName() == 0) && vertexArray && (vertexArray->name != 0) && ptr)
+               {
+                       // GL_INVALID_OPERATION is generated if a non-zero vertex array object is bound, zero is bound
+                       // to the GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.
+                       return error(GL_INVALID_OPERATION);
+               }
+
                context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr);
        }
 }
index 8b9116c..7a939b2 100644 (file)
@@ -24,6 +24,7 @@
 #include "Texture.h"
 #include "mathutil.h"
 #include "TransformFeedback.h"
+#include "VertexArray.h"
 #include "common/debug.h"
 
 #include <GLES3/gl3.h>
@@ -2068,6 +2069,14 @@ GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLe
 
        if(context)
        {
+               es2::VertexArray* vertexArray = context->getCurrentVertexArray();
+               if((context->getArrayBufferName() == 0) && vertexArray && (vertexArray->name != 0) && pointer)
+               {
+                       // GL_INVALID_OPERATION is generated if a non-zero vertex array object is bound, zero is bound
+                       // to the GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.
+                       return error(GL_INVALID_OPERATION);
+               }
+
                context->setVertexAttribState(index, context->getArrayBuffer(), size, type, false, stride, pointer);
        }
 }