Fix Clear validation assert for default FBOs
The validation was iterating over maxDrawBuffers attachments when
default framebuffers only have one attachment. Use the framebuffer's
drawBufferCount instead.
Also adds a regression test in the form of a WebGLComptibility test for
glClearBuffer with the default framebuffer.
BUG=angleproject:2091
Change-Id: I07ee524db1fcb8a99dab4043248c0885100fd216
diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
index 3f9b385..22b3368 100644
--- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp
+++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
@@ -2317,8 +2317,8 @@
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
-// Verify that errors are generated when there isn not a defined conversion between the clear type
-// and the buffer type.
+// Verify that errors are generated when there isn't a defined conversion between the clear type and
+// the buffer type.
TEST_P(WebGL2CompatibilityTest, ClearBufferTypeCompatibity)
{
if (IsD3D11())
@@ -2413,6 +2413,29 @@
EXPECT_GL_NO_ERROR();
}
+// Test the interaction of WebGL compatibility clears with default framebuffers
+TEST_P(WebGL2CompatibilityTest, ClearBufferDefaultFramebuffer)
+{
+ constexpr float clearFloat[] = {0.0f, 0.0f, 0.0f, 0.0f};
+ constexpr int clearInt[] = {0, 0, 0, 0};
+ constexpr unsigned int clearUint[] = {0, 0, 0, 0};
+
+ // glClear works as usual, this is also a regression test for a bug where we
+ // iterated on maxDrawBuffers for default framebuffers, triggering an assert
+ glClear(GL_COLOR_BUFFER_BIT);
+ EXPECT_GL_NO_ERROR();
+
+ // Default framebuffers are normalized uints, so only glClearBufferfv works.
+ glClearBufferfv(GL_COLOR, 0, clearFloat);
+ EXPECT_GL_NO_ERROR();
+
+ glClearBufferiv(GL_COLOR, 0, clearInt);
+ EXPECT_GL_ERROR(GL_INVALID_OPERATION);
+
+ glClearBufferuiv(GL_COLOR, 0, clearUint);
+ EXPECT_GL_ERROR(GL_INVALID_OPERATION);
+}
+
// Verify that errors are generate when trying to blit from an image to itself
TEST_P(WebGL2CompatibilityTest, BlitFramebufferSameImage)
{