From 2a0181587955d00aa66605b126dd01fad1b0772f Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Fri, 8 Jun 2018 15:59:26 -0700 Subject: [PATCH] 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 Reviewed-by: Geoff Lang --- extensions/ANGLE_client_arrays.txt | 15 ++++++++------ src/libANGLE/validationES.cpp | 6 +++--- src/tests/gl_tests/WebGLCompatibilityTest.cpp | 20 +++++++++++++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/extensions/ANGLE_client_arrays.txt b/extensions/ANGLE_client_arrays.txt index 1922b34b2..c8074b5a3 100644 --- a/extensions/ANGLE_client_arrays.txt +++ b/extensions/ANGLE_client_arrays.txt @@ -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 diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp index 14cc06781..d3519fc0e 100644 --- a/src/libANGLE/validationES.cpp +++ b/src/libANGLE/validationES.cpp @@ -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; } diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp index 3249c4b29..e55cba701 100644 --- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp +++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp @@ -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) {