Commit aa086d68 by Geoff Lang Committed by Commit Bot

Refactor glVertexAttribIPointer validation.

BUG=angleproject:1523 BUG=chromium:668223 Change-Id: I51eca98ad14d8be6f5009149ed6c0daecf569178 Reviewed-on: https://chromium-review.googlesource.com/458106Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 4063e209
...@@ -2266,4 +2266,68 @@ bool ValidateRenderbufferStorageMultisample(ValidationContext *context, ...@@ -2266,4 +2266,68 @@ bool ValidateRenderbufferStorageMultisample(ValidationContext *context,
return true; return true;
} }
bool ValidateVertexAttribIPointer(ValidationContext *context,
GLuint index,
GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(Error(GL_INVALID_OPERATION,
"glVertexAttribIPointer requires OpenGL ES 3.0 or higher."));
return false;
}
if (index >= MAX_VERTEX_ATTRIBS)
{
context->handleError(
Error(GL_INVALID_VALUE, "Index must be less than MAX_VERTEX_ATTRIBS."));
return false;
}
if (size < 1 || size > 4)
{
context->handleError(Error(GL_INVALID_VALUE, "Size must be between 1 and 4."));
return false;
}
switch (type)
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
break;
default:
context->handleError(Error(GL_INVALID_ENUM, "Unknown vertex attribute type."));
return false;
}
if (stride < 0)
{
context->handleError(Error(GL_INVALID_VALUE, "Stride cannot be negative."));
return false;
}
// [OpenGL ES 3.0.2] Section 2.8 page 24:
// An INVALID_OPERATION error is generated when a non-zero vertex array object
// is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
// and the pointer argument is not NULL.
if (context->getGLState().getVertexArrayId() != 0 &&
context->getGLState().getArrayBufferId() == 0 && pointer != nullptr)
{
context->handleError(
Error(GL_INVALID_OPERATION,
"Client data cannot be used with a non-default vertex array object."));
return false;
}
return true;
}
} // namespace gl } // namespace gl
...@@ -377,6 +377,13 @@ bool ValidateRenderbufferStorageMultisample(ValidationContext *context, ...@@ -377,6 +377,13 @@ bool ValidateRenderbufferStorageMultisample(ValidationContext *context,
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
bool ValidateVertexAttribIPointer(ValidationContext *context,
GLuint index,
GLint size,
GLenum type,
GLsizei stride,
const GLvoid *pointer);
} // namespace gl } // namespace gl
#endif // LIBANGLE_VALIDATION_ES3_H_ #endif // LIBANGLE_VALIDATION_ES3_H_
...@@ -821,53 +821,9 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs ...@@ -821,53 +821,9 @@ void GL_APIENTRY VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLs
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientMajorVersion() < 3) if (!context->skipValidation() &&
{ !ValidateVertexAttribIPointer(context, index, size, type, stride, pointer))
context->handleError(Error(GL_INVALID_OPERATION));
return;
}
if (index >= MAX_VERTEX_ATTRIBS)
{
context->handleError(Error(GL_INVALID_VALUE));
return;
}
if (size < 1 || size > 4)
{
context->handleError(Error(GL_INVALID_VALUE));
return;
}
switch (type)
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
break;
default:
context->handleError(Error(GL_INVALID_ENUM));
return;
}
if (stride < 0)
{
context->handleError(Error(GL_INVALID_VALUE));
return;
}
// [OpenGL ES 3.0.2] Section 2.8 page 24:
// An INVALID_OPERATION error is generated when a non-zero vertex array object
// is bound, zero is bound to the ARRAY_BUFFER buffer object binding point,
// and the pointer argument is not NULL.
if (context->getGLState().getVertexArray()->id() != 0 &&
context->getGLState().getArrayBufferId() == 0 && pointer != NULL)
{ {
context->handleError(Error(GL_INVALID_OPERATION));
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment