GL: Optimize multi-view layered Clear* commands
Until this patch multi-view layered framebuffers used to be cleared by
attaching a single layer of each attachment to a framebuffer and calling
the Clear* command for that internal framebuffer.
According to the GL 4.1+ specifications, Clear* commands clear all of
the layers of an attached 2D texture array. If all of the layers are
active for a multi-view layered framebuffer, then we can directly call
the corresponding Clear* command instead of iterating over each layer
and clearing it.
BUG=angleproject:2062
TEST=angle_end2end_tests
Change-Id: Ie4dfd9fff47715b502f358272bfc47c0373c4e91
Reviewed-on: https://chromium-review.googlesource.com/649209
Commit-Queue: Martin Radev <mradev@nvidia.com>
Reviewed-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/tests/gl_tests/FramebufferMultiviewTest.cpp b/src/tests/gl_tests/FramebufferMultiviewTest.cpp
index 0165f49..182a5ae 100644
--- a/src/tests/gl_tests/FramebufferMultiviewTest.cpp
+++ b/src/tests/gl_tests/FramebufferMultiviewTest.cpp
@@ -1327,6 +1327,25 @@
EXPECT_GL_NO_ERROR();
}
+// Test that glClear clears the contents of the color buffer whenever all layers of a 2D texture
+// array are attached. The test is added because a special fast code path is used for this case.
+TEST_P(FramebufferMultiviewLayeredClearTest, ColorBufferClearAllLayersAttached)
+{
+ if (!requestMultiviewExtension())
+ {
+ return;
+ }
+
+ initializeFBOs(1, 1, 2, 0, 2, 1, false, false);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, mMultiviewFBO);
+ glClearColor(0, 1, 0, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ EXPECT_EQ(GLColor::green, getLayerColor(0, GL_COLOR_ATTACHMENT0));
+ EXPECT_EQ(GLColor::green, getLayerColor(1, GL_COLOR_ATTACHMENT0));
+}
+
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewTest, ES3_OPENGL());
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewSideBySideClearTest, ES3_OPENGL(), ES3_D3D11());
ANGLE_INSTANTIATE_TEST(FramebufferMultiviewLayeredClearTest, ES3_OPENGL(), ES3_D3D11());
\ No newline at end of file