Commit 71dfb369 by Olli Etuaho

Add validation for DrawRangeElements end < start

end < start must generate an INVALID_VALUE error. Before this patch INVALID_OPERATION was generated from the check which validated the actual index range against end and start in this case. BUG=angleproject:1101 TEST=dEQP-GLES3.functional.negative_api.vertex_array.* (few more subtests pass) Change-Id: Ida9c5a8bc9dc416f1955e9012e5715c0848a0307 Reviewed-on: https://chromium-review.googlesource.com/332143Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent b5aa26bd
...@@ -1388,6 +1388,42 @@ bool ValidateClearBuffer(ValidationContext *context) ...@@ -1388,6 +1388,42 @@ bool ValidateClearBuffer(ValidationContext *context)
return true; return true;
} }
bool ValidateDrawRangeElements(Context *context,
GLenum mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const GLvoid *indices,
IndexRange *indexRange)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
return false;
}
if (end < start)
{
context->recordError(Error(GL_INVALID_VALUE, "end < start"));
return false;
}
if (!ValidateDrawElements(context, mode, count, type, indices, 0, indexRange))
{
return false;
}
if (indexRange->end > end || indexRange->start < start)
{
// GL spec says that behavior in this case is undefined - generating an error is fine.
context->recordError(
Error(GL_INVALID_OPERATION, "Indices are out of the start, end range."));
return false;
}
return true;
}
bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint* params) bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint* params)
{ {
if (context->getClientVersion() < 3) if (context->getClientVersion() < 3)
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
namespace gl namespace gl
{ {
class Context; class Context;
struct IndexRange;
class ValidationContext; class ValidationContext;
bool ValidateES3TexImageParametersBase(ValidationContext *context, bool ValidateES3TexImageParametersBase(ValidationContext *context,
...@@ -162,6 +163,15 @@ bool ValidateInvalidateFramebuffer(Context *context, GLenum target, GLsizei numA ...@@ -162,6 +163,15 @@ bool ValidateInvalidateFramebuffer(Context *context, GLenum target, GLsizei numA
bool ValidateClearBuffer(ValidationContext *context); bool ValidateClearBuffer(ValidationContext *context);
bool ValidateDrawRangeElements(Context *context,
GLenum mode,
GLuint start,
GLuint end,
GLsizei count,
GLenum type,
const GLvoid *indices,
IndexRange *indexRange);
bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint* params); bool ValidateGetUniformuiv(Context *context, GLuint program, GLint location, GLuint* params);
bool ValidateReadBuffer(Context *context, GLenum mode); bool ValidateReadBuffer(Context *context, GLenum mode);
......
...@@ -52,21 +52,11 @@ void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize ...@@ -52,21 +52,11 @@ void GL_APIENTRY DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
IndexRange indexRange; IndexRange indexRange;
if (!ValidateDrawElements(context, mode, count, type, indices, 0, &indexRange)) if (!context->skipValidation() &&
{ !ValidateDrawRangeElements(context, mode, start, end, count, type, indices,
return; &indexRange))
}
if (indexRange.end > end || indexRange.start < start)
{ {
// GL spec says that behavior in this case is undefined - generating an error is fine.
context->recordError(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