glVertexAttribPointer validation
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>
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index ffac13a..049b245 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -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 @@
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);
}
}
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index 8b9116c..7a939b2 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -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 @@
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);
}
}