From 1cfc6f0a51fd719b0ed7b2e621ba21df951f1325 Mon Sep 17 00:00:00 2001 From: Shahbaz Youssefi Date: Mon, 20 Jul 2020 16:03:38 -0400 Subject: [PATCH] Add test for deferred clear + attachment gaps This test makes sure the list of clear values given to the render pass (for deferred clears) are correctly passed. Bug: angleproject:4862 Change-Id: I4830a72a6f2b01570f6d4427ffb025429b5aa03c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2309109 Commit-Queue: Shahbaz Youssefi Reviewed-by: Jonah Ryan-Davis --- src/tests/gl_tests/DrawBuffersTest.cpp | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/tests/gl_tests/DrawBuffersTest.cpp b/src/tests/gl_tests/DrawBuffersTest.cpp index bd07cc76ee0..8bf09f08c6c 100644 --- a/src/tests/gl_tests/DrawBuffersTest.cpp +++ b/src/tests/gl_tests/DrawBuffersTest.cpp @@ -280,6 +280,47 @@ TEST_P(DrawBuffersTest, Gaps) glDeleteProgram(program); } +// Test that clear works with gaps +TEST_P(DrawBuffersTest, ClearWithGaps) +{ + // TODO(syoussefi): Qualcomm driver crashes in the presence of VK_ATTACHMENT_UNUSED. + // http://anglebug.com/3423 + ANGLE_SKIP_TEST_IF(IsVulkan() && IsAndroid()); + + ANGLE_SKIP_TEST_IF(!setupTest()); + + glGetIntegerv(GL_MAX_DRAW_BUFFERS, &mMaxDrawBuffers); + ASSERT_GE(mMaxDrawBuffers, 4); + + glBindTexture(GL_TEXTURE_2D, mTextures[0]); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[0], 0); + + glBindTexture(GL_TEXTURE_2D, mTextures[1]); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, mTextures[1], 0); + + const GLenum bufs[] = {GL_COLOR_ATTACHMENT0, GL_NONE, GL_NONE, GL_COLOR_ATTACHMENT3}; + + bool flags[8] = {true, false, false, true}; + GLuint program; + setupMRTProgram(flags, &program); + + setDrawBuffers(4, bufs); + + glClearColor(1.0f, 1.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + + // A bogus draw to make sure clears are done with a render pass in the Vulkan backend. + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_ONE); + drawQuad(program, positionAttrib(), 0.5); + EXPECT_GL_NO_ERROR(); + + verifyAttachment2DColor(0, mTextures[0], GL_TEXTURE_2D, 0, GLColor::yellow); + verifyAttachment2DColor(3, mTextures[1], GL_TEXTURE_2D, 0, GLColor::yellow); + + EXPECT_GL_NO_ERROR(); +} + TEST_P(DrawBuffersTest, FirstAndLast) { ANGLE_SKIP_TEST_IF(!setupTest());