src/third_party/angle/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp
// Tests that masked color/depth/stencil clears don't break the RP.
Tests that masked color/depth/stencil clears don't break the RP.
Tests that masked color / depth / stencil clears don ' t break the RP .
TEST_P(VulkanPerformanceCounterTest, MaskedClearDoesNotBreakRenderPass)
{
    const rx::vk::PerfCounters &counters = hackANGLE();
    constexpr GLsizei kSize = 64;
    GLTexture texture;
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    GLRenderbuffer renderbuffer;
    glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, kSize, kSize);
    GLFramebuffer framebuffer;
    glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
                              renderbuffer);
    ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    ASSERT_GL_NO_ERROR();
    uint32_t expectedRenderPassCount = counters.renderPasses + 1;
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_STENCIL_TEST);
    ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Passthrough(), essl1_shaders::fs::UniformColor());
    glUseProgram(program);
    GLint colorUniformLocation =
        glGetUniformLocation(program, angle::essl1_shaders::ColorUniform());
    ASSERT_NE(-1, colorUniformLocation);
    ASSERT_GL_NO_ERROR();
    glViewport(0, 0, kSize, kSize);
    glDepthFunc(GL_ALWAYS);
    glStencilFunc(GL_ALWAYS, 0x55, 0xFF);
    glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
    glUniform4f(colorUniformLocation, 1.0f, 0.0f, 0.0f, 1.0f);
    drawQuad(program, essl1_shaders::PositionAttrib(), 1.0f);
    glClearColor(0.25f, 1.0f, 0.25f, 1.25f);
    glClearDepthf(0.0f);
    glClearStencil(0x3F);
    glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);
    glStencilMask(0xF0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    EXPECT_EQ(expectedRenderPassCount, counters.renderPasses);
    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 / 2, kSize / 2, GLColor::yellow);
    glDisable(GL_SCISSOR_TEST);
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    glStencilMask(0xFF);
    glDepthFunc(GL_GREATER);
    glStencilFunc(GL_EQUAL, 0x35, 0xFF);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    glUniform4f(colorUniformLocation, 0.0f, 0.0f, 1.0f, 1.0f);
    drawQuad(program, essl1_shaders::PositionAttrib(), 0.05f);
    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 / 2, kSize / 2, GLColor::blue);
}
TEST_P ( VulkanPerformanceCounterTest , MaskedClearDoesNotBreakRenderPass ) { const rx :: vk :: PerfCounters & counters = hackANGLE ( ) ; constexpr GLsizei kSize = 64 ; GLTexture texture ; glBindTexture ( GL_TEXTURE_2D , texture ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , kSize , kSize , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; GLRenderbuffer renderbuffer ; glBindRenderbuffer ( GL_RENDERBUFFER , renderbuffer ) ; glRenderbufferStorage ( GL_RENDERBUFFER , GL_DEPTH24_STENCIL8 , kSize , kSize ) ; GLFramebuffer framebuffer ; glBindFramebuffer ( GL_FRAMEBUFFER , framebuffer ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , texture , 0 ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_DEPTH_STENCIL_ATTACHMENT , GL_RENDERBUFFER , renderbuffer ) ; ASSERT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; ASSERT_GL_NO_ERROR ( ) ; uint32_t expectedRenderPassCount = counters . renderPasses + 1 ; glEnable ( GL_DEPTH_TEST ) ; glEnable ( GL_STENCIL_TEST ) ; ANGLE_GL_PROGRAM ( program , essl1_shaders :: vs :: Passthrough ( ) , essl1_shaders :: fs :: UniformColor ( ) ) ; glUseProgram ( program ) ; GLint colorUniformLocation = glGetUniformLocation ( program , angle :: essl1_shaders :: ColorUniform ( ) ) ; ASSERT_NE ( -1 , colorUniformLocation ) ; ASSERT_GL_NO_ERROR ( ) ; glViewport ( 0 , 0 , kSize , kSize ) ; glDepthFunc ( GL_ALWAYS ) ; glStencilFunc ( GL_ALWAYS , 0x55 , 0xFF ) ; glStencilOp ( GL_REPLACE , GL_REPLACE , GL_REPLACE ) ; glUniform4f ( colorUniformLocation , 1.0f , 0.0f , 0.0f , 1.0f ) ; drawQuad ( program , essl1_shaders :: PositionAttrib ( ) , 1.0f ) ; glClearColor ( 0.25f , 1.0f , 0.25f , 1.25f ) ; glClearDepthf ( 0.0f ) ; glClearStencil ( 0x3F ) ; glColorMask ( GL_FALSE , GL_TRUE , GL_FALSE , GL_FALSE ) ; glStencilMask ( 0xF0 ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; EXPECT_EQ ( expectedRenderPassCount , counters . renderPasses ) ; 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 / 2 , kSize / 2 , GLColor :: yellow ) ; glDisable ( GL_SCISSOR_TEST ) ; glColorMask ( GL_TRUE , GL_TRUE , GL_TRUE , GL_TRUE ) ; glStencilMask ( 0xFF ) ; glDepthFunc ( GL_GREATER ) ; glStencilFunc ( GL_EQUAL , 0x35 , 0xFF ) ; glStencilOp ( GL_KEEP , GL_KEEP , GL_KEEP ) ; glUniform4f ( colorUniformLocation , 0.0f , 0.0f , 1.0f , 1.0f ) ; drawQuad ( program , essl1_shaders :: PositionAttrib ( ) , 0.05f ) ; 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 / 2 , kSize / 2 , GLColor :: blue ) ; }
Tests that masked color/depth/stencil clears don't break the RP.
Tests that masked color / depth / stencil clears don ' t break the RP .
// Clear the framebuffer with a draw call to start a render pass. // Issue a masked clear. // Make sure the render pass wasn't broken. // Verify that clear was done correctly. // Make sure depth = 0.0f, stencil = 0x35