src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
// Tests clearing a multisampled depth buffer.
Tests clearing a multisampled depth buffer.
Tests clearing a multisampled depth buffer .
TEST_P(BlitFramebufferTest, MultisampleDepthClear)
{
    ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL());
    ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES());
    GLRenderbuffer depthMS;
    glBindRenderbuffer(GL_RENDERBUFFER, depthMS.get());
    glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256);
    GLRenderbuffer colorMS;
    glBindRenderbuffer(GL_RENDERBUFFER, colorMS.get());
    glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_RGBA8, 256, 256);
    GLRenderbuffer colorResolved;
    glBindRenderbuffer(GL_RENDERBUFFER, colorResolved.get());
    glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 256, 256);
    GLFramebuffer framebufferMS;
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferMS.get());
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthMS.get());
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorMS.get());
    glClearDepthf(0.5f);
    glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    glFlush();
    ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_EQUAL);
    drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.0f);
    GLFramebuffer framebufferResolved;
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferResolved.get());
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
                              colorResolved.get());
    glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferMS.get());
    glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    glBindFramebuffer(GL_FRAMEBUFFER, framebufferResolved.get());
    ASSERT_GL_NO_ERROR();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(255, 0, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(0, 255, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(255, 255, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(127, 127, GLColor::red);
    ASSERT_GL_NO_ERROR();
}
TEST_P ( BlitFramebufferTest , MultisampleDepthClear ) { ANGLE_SKIP_TEST_IF ( IsLinux ( ) && IsIntel ( ) && IsDesktopOpenGL ( ) ) ; ANGLE_SKIP_TEST_IF ( IsAndroid ( ) && IsOpenGLES ( ) ) ; GLRenderbuffer depthMS ; glBindRenderbuffer ( GL_RENDERBUFFER , depthMS . get ( ) ) ; glRenderbufferStorageMultisample ( GL_RENDERBUFFER , 2 , GL_DEPTH_COMPONENT24 , 256 , 256 ) ; GLRenderbuffer colorMS ; glBindRenderbuffer ( GL_RENDERBUFFER , colorMS . get ( ) ) ; glRenderbufferStorageMultisample ( GL_RENDERBUFFER , 2 , GL_RGBA8 , 256 , 256 ) ; GLRenderbuffer colorResolved ; glBindRenderbuffer ( GL_RENDERBUFFER , colorResolved . get ( ) ) ; glRenderbufferStorage ( GL_RENDERBUFFER , GL_RGBA8 , 256 , 256 ) ; GLFramebuffer framebufferMS ; glBindFramebuffer ( GL_FRAMEBUFFER , framebufferMS . get ( ) ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , GL_RENDERBUFFER , depthMS . get ( ) ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_RENDERBUFFER , colorMS . get ( ) ) ; glClearDepthf ( 0.5f ) ; glClearColor ( 0.0f , 1.0f , 0.0f , 1.0f ) ; glClear ( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ) ; glFlush ( ) ; ANGLE_GL_PROGRAM ( drawRed , essl3_shaders :: vs :: Simple ( ) , essl3_shaders :: fs :: Red ( ) ) ; glEnable ( GL_DEPTH_TEST ) ; glDepthFunc ( GL_EQUAL ) ; drawQuad ( drawRed . get ( ) , essl3_shaders :: PositionAttrib ( ) , 0.0f ) ; GLFramebuffer framebufferResolved ; glBindFramebuffer ( GL_FRAMEBUFFER , framebufferResolved . get ( ) ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_RENDERBUFFER , colorResolved . get ( ) ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , framebufferMS . get ( ) ) ; glBlitFramebuffer ( 0 , 0 , 256 , 256 , 0 , 0 , 256 , 256 , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; glBindFramebuffer ( GL_FRAMEBUFFER , framebufferResolved . get ( ) ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 255 , 0 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 255 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 255 , 255 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 127 , 127 , GLColor :: red ) ; ASSERT_GL_NO_ERROR ( ) ; }
Tests clearing a multisampled depth buffer.
Tests clearing a multisampled depth buffer .
// clearDepth && !maskDepth fails on Intel Ubuntu 19.04 Mesa 19.0.2 GL. http://anglebug.com/3614 // http://anglebug.com/4092 // Clear depth buffer to 0.5 and color to green. // Draw red into the multisampled color buffer. // Resolve the color buffer to make sure the above draw worked correctly, which in turn implies // that the multisampled depth clear worked.