src/third_party/angle/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp
// Ensures repeated clears of various kind (all attachments, some attachments, scissored, masked
// etc) don't break the render pass.
Ensures repeated clears of various kind (all attachments, some attachments, scissored, masked
etc) don't break the render pass.
Ensures repeated clears of various kind ( all attachments some attachments scissored masked etc ) don ' t break the render pass .
TEST_P(VulkanPerformanceCounterTest, ClearAfterClearDoesNotBreakRenderPass)
{
    const rx::vk::PerfCounters &counters = hackANGLE();
    uint32_t expectedRenderPassCount     = counters.renderPasses + 1;
    GLFramebuffer FBO;
    glBindFramebuffer(GL_FRAMEBUFFER, FBO);
    constexpr GLsizei kSize = 6;
    GLTexture color;
    glBindTexture(GL_TEXTURE_2D, color);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    GLTexture depth;
    glBindTexture(GL_TEXTURE_2D, depth);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, kSize, kSize, 0, GL_DEPTH_STENCIL,
                 GL_UNSIGNED_INT_24_8_OES, nullptr);
    GLFramebuffer fbo;
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color, 0);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depth, 0);
    ASSERT_GL_NO_ERROR();
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepthf(0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
    glClearStencil(0x11);
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glClearDepthf(0.1f);
    glClearStencil(0x22);
    glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glClearDepthf(0.2f);
    glClearColor(0.1f, 1.0f, 0.0f, 1.0f);
    glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    glClearStencil(0x33);
    glStencilMask(0xF0);
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glClearDepthf(0.3f);
    glClearStencil(0x44);
    glStencilMask(0xFF);
    glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glEnable(GL_SCISSOR_TEST);
    glScissor(kSize / 3, kSize / 3, kSize / 3, kSize / 3);
    glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    glClearDepthf(1.0f);
    glClearStencil(0x55);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    EXPECT_EQ(counters.renderPasses, expectedRenderPassCount);
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kSize / 3, kSize / 3, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(2 * kSize / 3 - 1, kSize / 3, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(kSize / 3, 2 * kSize / 3 - 1, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(2 * kSize / 3 - 1, 2 * kSize / 3 - 1, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::red);
    glViewport(0, 0, kSize, kSize);
    glDisable(GL_SCISSOR_TEST);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glEnable(GL_STENCIL_TEST);
    glStencilFunc(GL_EQUAL, 0x55, 0xFF);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    glStencilMask(0xFF);
    ANGLE_GL_PROGRAM(drawColor, essl1_shaders::vs::Simple(), essl1_shaders::fs::UniformColor());
    glUseProgram(drawColor);
    GLint colorUniformLocation =
        glGetUniformLocation(drawColor, angle::essl1_shaders::ColorUniform());
    ASSERT_NE(colorUniformLocation, -1);
    glUniform4f(colorUniformLocation, 0.0f, 1.0f, 0.0f, 1.0f);
    drawQuad(drawColor, essl1_shaders::PositionAttrib(), 0.95f);
    ASSERT_GL_NO_ERROR();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(kSize / 3, kSize / 3, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(2 * kSize / 3 - 1, kSize / 3, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(kSize / 3, 2 * kSize / 3 - 1, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(2 * kSize / 3 - 1, 2 * kSize / 3 - 1, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::green);
    glDepthFunc(GL_LESS);
    glStencilFunc(GL_EQUAL, 0x44, 0xFF);
    glUniform4f(colorUniformLocation, 1.0f, 1.0f, 0.0f, 1.0f);
    drawQuad(drawColor, essl1_shaders::PositionAttrib(), -0.5f);
    ASSERT_GL_NO_ERROR();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, GLColor::yellow);
    EXPECT_PIXEL_COLOR_EQ(kSize / 3, kSize / 3, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(2 * kSize / 3 - 1, kSize / 3, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(kSize / 3, 2 * kSize / 3 - 1, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(2 * kSize / 3 - 1, 2 * kSize / 3 - 1, GLColor::green);
    EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::green);
}
TEST_P ( VulkanPerformanceCounterTest , ClearAfterClearDoesNotBreakRenderPass ) { const rx :: vk :: PerfCounters & counters = hackANGLE ( ) ; uint32_t expectedRenderPassCount = counters . renderPasses + 1 ; GLFramebuffer FBO ; glBindFramebuffer ( GL_FRAMEBUFFER , FBO ) ; constexpr GLsizei kSize = 6 ; GLTexture color ; glBindTexture ( GL_TEXTURE_2D , color ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , kSize , kSize , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; GLTexture depth ; glBindTexture ( GL_TEXTURE_2D , depth ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_DEPTH24_STENCIL8 , kSize , kSize , 0 , GL_DEPTH_STENCIL , GL_UNSIGNED_INT_24_8_OES , nullptr ) ; GLFramebuffer fbo ; glBindFramebuffer ( GL_FRAMEBUFFER , fbo ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , color , 0 ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_DEPTH_STENCIL_ATTACHMENT , GL_TEXTURE_2D , depth , 0 ) ; ASSERT_GL_NO_ERROR ( ) ; glClearColor ( 0.0f , 0.0f , 0.0f , 0.0f ) ; glClearDepthf ( 0.0f ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; glClearColor ( 1.0f , 0.0f , 0.0f , 0.0f ) ; glClearStencil ( 0x11 ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glClearDepthf ( 0.1f ) ; glClearStencil ( 0x22 ) ; glClear ( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glClearDepthf ( 0.2f ) ; glClearColor ( 0.1f , 1.0f , 0.0f , 1.0f ) ; glColorMask ( GL_FALSE , GL_TRUE , GL_FALSE , GL_FALSE ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; glClearColor ( 0.0f , 0.0f , 1.0f , 1.0f ) ; glColorMask ( GL_TRUE , GL_TRUE , GL_TRUE , GL_TRUE ) ; glClearStencil ( 0x33 ) ; glStencilMask ( 0xF0 ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glClearDepthf ( 0.3f ) ; glClearStencil ( 0x44 ) ; glStencilMask ( 0xFF ) ; glClear ( GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glEnable ( GL_SCISSOR_TEST ) ; glScissor ( kSize / 3 , kSize / 3 , kSize / 3 , kSize / 3 ) ; glClearColor ( 1.0f , 0.0f , 0.0f , 1.0f ) ; glClearDepthf ( 1.0f ) ; glClearStencil ( 0x55 ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; EXPECT_EQ ( counters . renderPasses , expectedRenderPassCount ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , kSize - 1 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , kSize - 1 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 3 , kSize / 3 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 2 * kSize / 3 - 1 , kSize / 3 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 3 , 2 * kSize / 3 - 1 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 2 * kSize / 3 - 1 , 2 * kSize / 3 - 1 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 2 , kSize / 2 , GLColor :: red ) ; glViewport ( 0 , 0 , kSize , kSize ) ; glDisable ( GL_SCISSOR_TEST ) ; glEnable ( GL_DEPTH_TEST ) ; glDepthFunc ( GL_LESS ) ; glEnable ( GL_STENCIL_TEST ) ; glStencilFunc ( GL_EQUAL , 0x55 , 0xFF ) ; glStencilOp ( GL_KEEP , GL_KEEP , GL_KEEP ) ; glStencilMask ( 0xFF ) ; ANGLE_GL_PROGRAM ( drawColor , essl1_shaders :: vs :: Simple ( ) , essl1_shaders :: fs :: UniformColor ( ) ) ; glUseProgram ( drawColor ) ; GLint colorUniformLocation = glGetUniformLocation ( drawColor , angle :: essl1_shaders :: ColorUniform ( ) ) ; ASSERT_NE ( colorUniformLocation , -1 ) ; glUniform4f ( colorUniformLocation , 0.0f , 1.0f , 0.0f , 1.0f ) ; drawQuad ( drawColor , essl1_shaders :: PositionAttrib ( ) , 0.95f ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , kSize - 1 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , kSize - 1 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 3 , kSize / 3 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( 2 * kSize / 3 - 1 , kSize / 3 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 3 , 2 * kSize / 3 - 1 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( 2 * kSize / 3 - 1 , 2 * kSize / 3 - 1 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 2 , kSize / 2 , GLColor :: green ) ; glDepthFunc ( GL_LESS ) ; glStencilFunc ( GL_EQUAL , 0x44 , 0xFF ) ; glUniform4f ( colorUniformLocation , 1.0f , 1.0f , 0.0f , 1.0f ) ; drawQuad ( drawColor , essl1_shaders :: PositionAttrib ( ) , -0.5f ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , 0 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , kSize - 1 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , kSize - 1 , GLColor :: yellow ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 3 , kSize / 3 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( 2 * kSize / 3 - 1 , kSize / 3 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 3 , 2 * kSize / 3 - 1 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( 2 * kSize / 3 - 1 , 2 * kSize / 3 - 1 , GLColor :: green ) ; EXPECT_PIXEL_COLOR_EQ ( kSize / 2 , kSize / 2 , GLColor :: green ) ; }
Ensures repeated clears of various kind (all attachments, some attachments, scissored, masked
etc) don't break the render pass.
Ensures repeated clears of various kind ( all attachments some attachments scissored masked etc ) don ' t break the render pass .
// Create a framebuffer to clear with both color and depth/stencil attachments. // Clear color and depth, but not stencil. // Clear color and stencil, but not depth. // Clear depth and stencil, but not color. // Clear masked color, and unmasked depth. // Clear unmasked color, and masked stencil. // Clear unmasked depth and stencil. // Clear with scissor. // Verify render pass count. // Make sure the result is correct.  The border of the image should be blue with depth 0.3f and // stencil 0x44.  The center is red with depth 1.0f and stencil 0x55. // Center: If depth is not cleared to 1, rendering would fail. // Center: If stencil is not clear to 0x55, rendering would fail. // Set up program // Draw green // Verify that only the center has changed // Border: If depth is not cleared to 0.3f, rendering would fail. // Center: If stencil is not clear to 0x44, rendering would fail. // Draw yellow // Verify that only the border has changed