Commit 2da5356e by Jamie Madill Committed by Commit Bot

Final cleanup to ValidateDrawAttribs.

This moves the client attribs check into a shared place. This cleans up some of the surrounding code. Also get rid of the vertex count parameter. Bug: angleproject:1391 Change-Id: I9c688895c2cc5650d7b395497d69033093916f21 Reviewed-on: https://chromium-review.googlesource.com/1150517 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent a2d1d2db
......@@ -81,8 +81,7 @@ bool DifferenceCanOverflow(GLint a, GLint b)
bool ValidateDrawClientAttribs(Context *context)
{
if (!context->getStateCache().hasAnyEnabledClientAttrib())
return true;
ASSERT(context->getStateCache().hasAnyEnabledClientAttrib());
const gl::State &state = context->getGLState();
......@@ -107,18 +106,10 @@ bool ValidateDrawClientAttribs(Context *context)
return true;
}
bool ValidateDrawAttribs(Context *context, GLint primcount, GLint maxVertex, GLint vertexCount)
bool ValidateDrawAttribs(Context *context, GLint primcount, GLint maxVertex)
{
if (!ValidateDrawClientAttribs(context))
{
return false;
}
// If we're drawing zero vertices, we have enough data.
if (vertexCount <= 0 || primcount <= 0)
{
return true;
}
ASSERT(primcount > 0);
if (maxVertex <= context->getStateCache().getNonInstancedVertexElementLimit() &&
(primcount - 1) <= context->getStateCache().getInstancedVertexElementLimit())
......@@ -2690,6 +2681,14 @@ bool ValidateDrawBase(Context *context, PrimitiveMode mode, GLsizei count)
return false;
}
if (context->getStateCache().hasAnyEnabledClientAttrib())
{
if (!ValidateDrawClientAttribs(context))
{
return false;
}
}
// If we are running GLES1, there is no current program.
if (context->getClientVersion() >= Version(2, 0))
{
......@@ -2892,7 +2891,7 @@ bool ValidateDrawArraysCommon(Context *context,
// - if count < 0, skip validating no-op draw calls.
// From this we know maxVertex will be positive, and only need to check if it overflows GLint.
ASSERT(first >= 0);
if (count > 0)
if (count > 0 && primcount > 0)
{
int64_t maxVertex = static_cast<int64_t>(first) + static_cast<int64_t>(count) - 1;
if (maxVertex > static_cast<int64_t>(std::numeric_limits<GLint>::max()))
......@@ -2901,7 +2900,7 @@ bool ValidateDrawArraysCommon(Context *context,
return false;
}
if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(maxVertex), count))
if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(maxVertex)))
{
return false;
}
......@@ -3107,15 +3106,7 @@ bool ValidateDrawElementsCommon(Context *context,
}
}
if (context->getExtensions().robustBufferAccessBehavior || count == 0)
{
// Special checks are needed for client attribs. But we don't need to validate overflows.
if (!ValidateDrawClientAttribs(context))
{
return false;
}
}
else
if (!context->getExtensions().robustBufferAccessBehavior && count > 0 && primcount > 0)
{
// Use the parameter buffer to retrieve and cache the index range.
const DrawCallParams &params = context->getParams<DrawCallParams>();
......@@ -3131,8 +3122,7 @@ bool ValidateDrawElementsCommon(Context *context,
return false;
}
if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRange.end),
static_cast<GLint>(indexRange.vertexCount())))
if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRange.end)))
{
return false;
}
......
......@@ -195,10 +195,9 @@ TEST_P(UniformBufferTest, UniformBufferBindings)
EXPECT_PIXEL_EQ(px, py, 10, 20, 30, 40);
}
// Test that ANGLE handles used but unbound UBO.
// TODO: A test case shouldn't depend on the error code of an undefined behaviour. Move this to unit
// tests of the validation layer.
TEST_P(UniformBufferTest, UnboundUniformBuffer)
// Test that ANGLE handles used but unbound UBO. Assumes we are running on ANGLE and produce
// optional but not mandatory errors.
TEST_P(UniformBufferTest, ANGLEUnboundUniformBuffer)
{
glUniformBlockBinding(mProgram, mUniformBufferIndex, 0);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, 0);
......
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