diff --git a/third_party/angle/src/common/utilities_unittest.cpp b/third_party/angle/src/common/utilities_unittest.cpp index 0000000000..0000000000 100644 --- a/third_party/angle/src/common/utilities_unittest.cpp +++ b/third_party/angle/src/common/utilities_unittest.cpp @@ -253,6 +253,16 @@ TEST(Utilities, IndexRanges) EXPECT_EQ(ComputeIndexRange(b, vertices2, 2, false), gl::IndexRange(255, 255)); EXPECT_EQ(ComputeIndexRange(b, vertices2, 3, true), gl::IndexRange(2, 2)); EXPECT_EQ(ComputeIndexRange(b, vertices2, 3, false), gl::IndexRange(2, 255)); + + constexpr auto ui = gl::DrawElementsType::UnsignedInt; + uint32_t vertices3[] = {0u, 0xffffffffu}; + gl::IndexRange fullUintRange = ComputeIndexRange(ui, vertices3, 2, false); + EXPECT_FALSE(fullUintRange.isEmpty()); + if (!fullUintRange.isEmpty()) + { + EXPECT_EQ(0u, fullUintRange.start()); + EXPECT_EQ(0xffffffffu, fullUintRange.end()); + } } } // anonymous namespace diff --git a/third_party/angle/src/tests/gl_tests/DrawElementsTest.cpp b/third_party/angle/src/tests/gl_tests/DrawElementsTest.cpp index 0000000000..0000000000 100644 --- a/third_party/angle/src/tests/gl_tests/DrawElementsTest.cpp +++ b/third_party/angle/src/tests/gl_tests/DrawElementsTest.cpp @@ -793,6 +793,45 @@ TEST_P(WebGLDrawElementsTest, DrawElementsTypeAlignment) EXPECT_GL_ERROR(GL_INVALID_OPERATION); } +// Regression test for unsigned-int index ranges that cover the full uint32_t domain. +// With primitive restart disabled, 0xffffffff is a real WebGL1 index when +// OES_element_index_uint is enabled. This must not be treated as an empty range. +TEST_P(WebGLDrawElementsTest, MixedUintMaxIndexRangeIsNotEmpty) +{ + ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_OES_element_index_uint")); + + constexpr char kVS[] = + "attribute vec3 a_pos;\n" + "void main()\n" + "{\n" + " gl_Position = vec4(a_pos, 1.0);\n" + " gl_PointSize = 1.0;\n" + "}\n"; + + ANGLE_GL_PROGRAM(program, kVS, essl1_shaders::fs::Blue()); + + GLint posLocation = glGetAttribLocation(program, "a_pos"); + ASSERT_NE(-1, posLocation); + glUseProgram(program); + + const GLfloat vertices[] = {0.0f, 0.0f, 0.0f}; + + GLBuffer vertexBuffer; + glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + + glVertexAttribPointer(posLocation, 3, GL_FLOAT, GL_FALSE, 0, 0); + glEnableVertexAttribArray(posLocation); + + GLBuffer indexBuffer; + const GLuint indices[] = {0u, 0xffffffffu}; + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); + + glDrawElements(GL_POINTS, 2, GL_UNSIGNED_INT, nullptr); + EXPECT_GL_ERROR(GL_INVALID_OPERATION); +} + class WebGLDrawElementsTest3 : public WebGLDrawElementsTest {}; // Test one element buffer bind to two vertexArrays and switch vertexArray should draw correctly.