Change Validation For Indexed Draw Without ELEMENT_ARRAY_BUFFER

Changed WebGL Validation to return INVALID_OPERATION any time an
indexed draw call is made without a bound ELEMENT_ARRAY_BUFFER. Spec
was changed to no longer require count > 0 in order to cause error.
Make same spec change to GL_ANGLE_client_arrays extension.

BUG:angleproject:2639
Change-Id: I23963f357119d081890aa5387b2863e1d42b92a5
Reviewed-on: https://chromium-review.googlesource.com/1093984
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Brandon Jones
2018-06-08 15:59:26 -07:00
committed by Commit Bot
parent 7df52383cf
commit 2a01815879
3 changed files with 32 additions and 9 deletions

View File

@@ -70,9 +70,9 @@ Additions to the OpenGL ES Specification
Add to the end of section 2.9.2 "Array Indices in Buffer Objects":
Rendering commands that draw more than 0 primitives using index data when
no buffer is bound to the ELEMENT_ARRAY_BUFFER binding point when
CLIENT_ARRAYS_ANGLE is TRUE generate an INVALID_OPERATION error.
Rendering commands that draw using index data when no buffer is bound to
the ELEMENT_ARRAY_BUFFER binding point when CLIENT_ARRAYS_ANGLE is TRUE
generate an INVALID_OPERATION error.
New State
@@ -95,6 +95,9 @@ Issues
Revision History
Rev. Date Author Changes
---- ------------- --------- ----------------------------------------
1 Feb 13, 2016 geofflang Initial version
Rev. Date Author Changes
---- ------------- --------- ----------------------------------------
2 Jun 12, 2018 Brandon Jones (Intel) Remove primitives > 0 requirement to error
when doing an indexed draw with no bound
ELEMENT_ARRAY_BUFFER
1 Feb 13, 2016 geofflang Initial version

View File

@@ -3055,11 +3055,11 @@ bool ValidateDrawElementsCommon(Context *context,
if (context->getExtensions().webglCompatibility ||
!context->getGLState().areClientArraysEnabled())
{
if (!elementArrayBuffer && count > 0)
if (!elementArrayBuffer)
{
// [WebGL 1.0] Section 6.2 No Client Side Arrays
// If drawElements is called with a count greater than zero, and no WebGLBuffer is bound
// to the ELEMENT_ARRAY_BUFFER binding point, an INVALID_OPERATION error is generated.
// If an indexed draw command (drawElements) is called and no WebGLBuffer is bound to
// the ELEMENT_ARRAY_BUFFER binding point, an INVALID_OPERATION error is generated.
ANGLE_VALIDATION_ERR(context, InvalidOperation(), MustHaveElementArrayBinding);
return false;
}

View File

@@ -1470,6 +1470,26 @@ TEST_P(WebGLCompatibilityTest, DrawArraysBufferOutOfBoundsNonInstanced)
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test for drawing with a null index buffer
TEST_P(WebGLCompatibilityTest, NullIndexBuffer)
{
const std::string &vert =
"attribute float a_pos;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(a_pos, a_pos, a_pos, 1.0);\n"
"}\n";
ANGLE_GL_PROGRAM(program, vert, essl1_shaders::fs::Red());
glUseProgram(program.get());
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnableVertexAttribArray(0);
glDrawElements(GL_TRIANGLES, 0, GL_UNSIGNED_BYTE, 0);
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test the checks for OOB reads in the vertex buffers, instanced version
TEST_P(WebGL2CompatibilityTest, DrawArraysBufferOutOfBoundsInstanced)
{