Commit 18a2fb3a by Corentin Wallez

ValidateDrawElements: check count > 0 then compute the index range

Otherwise glDrawElements(GL_TRIANGLES, -1, nullptr) would crash. This was found by an ASSERT in ComputeIndexRange triggered by dEQP-GLES2.functional.negative_api.vertex_array.draw_elements BUG= Change-Id: I5269031fa35aa6403c844561e04158361ee7950f Reviewed-on: https://chromium-review.googlesource.com/292710Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b195643c
...@@ -1406,7 +1406,7 @@ bool ValidateCopyTexImageParametersBase(gl::Context *context, GLenum target, GLi ...@@ -1406,7 +1406,7 @@ bool ValidateCopyTexImageParametersBase(gl::Context *context, GLenum target, GLi
return true; return true;
} }
static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsizei maxVertex, GLsizei primcount) static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsizei primcount)
{ {
switch (mode) switch (mode)
{ {
...@@ -1471,12 +1471,6 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1471,12 +1471,6 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
return false; return false;
} }
// Buffer validations
if (!ValidateDrawAttribs(context, primcount, maxVertex))
{
return false;
}
// Uniform buffer validation // Uniform buffer validation
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++) for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++)
{ {
...@@ -1531,7 +1525,12 @@ bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei coun ...@@ -1531,7 +1525,12 @@ bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei coun
return false; return false;
} }
if (!ValidateDrawBase(context, mode, count, count, primcount)) if (!ValidateDrawBase(context, mode, count, primcount))
{
return false;
}
if (!ValidateDrawAttribs(context, primcount, count))
{ {
return false; return false;
} }
...@@ -1664,6 +1663,11 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t ...@@ -1664,6 +1663,11 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t
return false; return false;
} }
if (!ValidateDrawBase(context, mode, count, primcount))
{
return false;
}
// Use max index to validate if our vertex buffers are large enough for the pull. // Use max index to validate if our vertex buffers are large enough for the pull.
// TODO: offer fast path, with disabled index validation. // TODO: offer fast path, with disabled index validation.
// TODO: also disable index checking on back-ends that are robust to out-of-range accesses. // TODO: also disable index checking on back-ends that are robust to out-of-range accesses.
...@@ -1682,7 +1686,7 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t ...@@ -1682,7 +1686,7 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t
*indexRangeOut = ComputeIndexRange(type, indices, count); *indexRangeOut = ComputeIndexRange(type, indices, count);
} }
if (!ValidateDrawBase(context, mode, count, static_cast<GLsizei>(indexRangeOut->end), primcount)) if (!ValidateDrawAttribs(context, primcount, static_cast<GLsizei>(indexRangeOut->end)))
{ {
return false; return false;
} }
......
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