src/third_party/angle/src/tests/gl_tests/VulkanPerformanceCounterTest.cpp
// Test resolving a multisampled texture with blit doesn't break the render pass so a subpass can be
// used
Test resolving a multisampled texture with blit doesn't break the render pass so a subpass can be
used
Test resolving a multisampled texture with blit doesn ' t break the render pass so a subpass can be used
TEST_P(VulkanPerformanceCounterTest_ES31, MultisampleResolveWithBlit)
{
    constexpr int kSize = 16;
    glViewport(0, 0, kSize, kSize);
    GLFramebuffer msaaFBO;
    glBindFramebuffer(GL_FRAMEBUFFER, msaaFBO.get());
    GLTexture texture;
    glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture.get());
    glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, kSize, kSize, false);
    ASSERT_GL_NO_ERROR();
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
                           texture.get(), 0);
    ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    ANGLE_GL_PROGRAM(gradientProgram, essl31_shaders::vs::Passthrough(),
                     essl31_shaders::fs::RedGreenGradient());
    drawQuad(gradientProgram, essl31_shaders::PositionAttrib(), 0.5f, 1.0f, true);
    ASSERT_GL_NO_ERROR();
    GLTexture resolveTexture;
    GLFramebuffer resolveFBO;
    glBindTexture(GL_TEXTURE_2D, resolveTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glBindFramebuffer(GL_FRAMEBUFFER, resolveFBO);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, resolveTexture, 0);
    EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
    glBindFramebuffer(GL_READ_FRAMEBUFFER, msaaFBO);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolveFBO);
    glBlitFramebuffer(0, 0, kSize, kSize, 0, 0, kSize, kSize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    ASSERT_GL_NO_ERROR();
    const rx::vk::PerfCounters &counters = hackANGLE();
    EXPECT_EQ(counters.resolveImageCommands, 0u);
    glBindFramebuffer(GL_READ_FRAMEBUFFER, resolveFBO);
    EXPECT_PIXEL_NEAR(0, 0, 0, 0, 0, 255, 1.0);                      
    EXPECT_PIXEL_NEAR(kSize - 1, 1, 239, 0, 0, 255, 1.0);            
    EXPECT_PIXEL_NEAR(0, kSize - 1, 0, 239, 0, 255, 1.0);            
    EXPECT_PIXEL_NEAR(kSize - 1, kSize - 1, 239, 239, 0, 255, 1.0);  
}
TEST_P ( VulkanPerformanceCounterTest_ES31 , MultisampleResolveWithBlit ) { constexpr int kSize = 16 ; glViewport ( 0 , 0 , kSize , kSize ) ; GLFramebuffer msaaFBO ; glBindFramebuffer ( GL_FRAMEBUFFER , msaaFBO . get ( ) ) ; GLTexture texture ; glBindTexture ( GL_TEXTURE_2D_MULTISAMPLE , texture . get ( ) ) ; glTexStorage2DMultisample ( GL_TEXTURE_2D_MULTISAMPLE , 4 , GL_RGBA8 , kSize , kSize , false ) ; ASSERT_GL_NO_ERROR ( ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D_MULTISAMPLE , texture . get ( ) , 0 ) ; ASSERT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; ANGLE_GL_PROGRAM ( gradientProgram , essl31_shaders :: vs :: Passthrough ( ) , essl31_shaders :: fs :: RedGreenGradient ( ) ) ; drawQuad ( gradientProgram , essl31_shaders :: PositionAttrib ( ) , 0.5f , 1.0f , true ) ; ASSERT_GL_NO_ERROR ( ) ; GLTexture resolveTexture ; GLFramebuffer resolveFBO ; glBindTexture ( GL_TEXTURE_2D , resolveTexture ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , kSize , kSize , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_LINEAR ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_LINEAR ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE ) ; glBindFramebuffer ( GL_FRAMEBUFFER , resolveFBO ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , resolveTexture , 0 ) ; EXPECT_GLENUM_EQ ( GL_FRAMEBUFFER_COMPLETE , glCheckFramebufferStatus ( GL_FRAMEBUFFER ) ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , msaaFBO ) ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , resolveFBO ) ; glBlitFramebuffer ( 0 , 0 , kSize , kSize , 0 , 0 , kSize , kSize , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; ASSERT_GL_NO_ERROR ( ) ; const rx :: vk :: PerfCounters & counters = hackANGLE ( ) ; EXPECT_EQ ( counters . resolveImageCommands , 0u ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , resolveFBO ) ; EXPECT_PIXEL_NEAR ( 0 , 0 , 0 , 0 , 0 , 255 , 1.0 ) ; EXPECT_PIXEL_NEAR ( kSize - 1 , 1 , 239 , 0 , 0 , 255 , 1.0 ) ; EXPECT_PIXEL_NEAR ( 0 , kSize - 1 , 0 , 239 , 0 , 255 , 1.0 ) ; EXPECT_PIXEL_NEAR ( kSize - 1 , kSize - 1 , 239 , 239 , 0 , 255 , 1.0 ) ; }
Test resolving a multisampled texture with blit doesn't break the render pass so a subpass can be
used
Test resolving a multisampled texture with blit doesn ' t break the render pass so a subpass can be used
// Create another FBO to resolve the multisample buffer into. // Black // Red // Green // Yellow