src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
// Tests resolving a multisample depth buffer.
Tests resolving a multisample depth buffer.
Tests resolving a multisample depth buffer .
TEST_P(BlitFramebufferTest, MultisampleDepth)
{
    ANGLE_SKIP_TEST_IF(IsOpenGL() && IsOSX());
    GLRenderbuffer renderbuf;
    glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
    glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256);
    GLFramebuffer framebuffer;
    glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
                              renderbuf.get());
    ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
    glClearDepthf(0.5f);
    glClear(GL_DEPTH_BUFFER_BIT);
    GLRenderbuffer destRenderbuf;
    glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 256, 256);
    GLFramebuffer resolved;
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
    glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
                              destRenderbuf.get());
    glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get());
    glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
    glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
    GLTexture colorbuf;
    glBindTexture(GL_TEXTURE_2D, colorbuf.get());
    glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuf.get(), 0);
    ASSERT_GL_NO_ERROR();
    glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
    ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
    glEnable(GL_DEPTH_TEST);
    glDepthMask(false);
    glDepthFunc(GL_LESS);
    drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), -0.01f);
    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);
    ANGLE_GL_PROGRAM(drawBlue, essl3_shaders::vs::Simple(), essl3_shaders::fs::Blue());
    glEnable(GL_DEPTH_TEST);
    glDepthMask(false);
    glDepthFunc(GL_GREATER);
    drawQuad(drawBlue.get(), essl3_shaders::PositionAttrib(), 0.01f);
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(255, 0, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(0, 255, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(255, 255, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(127, 127, GLColor::blue);
    ASSERT_GL_NO_ERROR();
}
TEST_P ( BlitFramebufferTest , MultisampleDepth ) { ANGLE_SKIP_TEST_IF ( IsOpenGL ( ) && IsOSX ( ) ) ; GLRenderbuffer renderbuf ; glBindRenderbuffer ( GL_RENDERBUFFER , renderbuf . get ( ) ) ; glRenderbufferStorageMultisample ( GL_RENDERBUFFER , 2 , GL_DEPTH_COMPONENT24 , 256 , 256 ) ; GLFramebuffer framebuffer ; glBindFramebuffer ( GL_FRAMEBUFFER , framebuffer . get ( ) ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , GL_RENDERBUFFER , renderbuf . get ( ) ) ; ASSERT_GLENUM_EQ ( GL_FRAMEBUFFER_COMPLETE , glCheckFramebufferStatus ( GL_FRAMEBUFFER ) ) ; glClearDepthf ( 0.5f ) ; glClear ( GL_DEPTH_BUFFER_BIT ) ; GLRenderbuffer destRenderbuf ; glBindRenderbuffer ( GL_RENDERBUFFER , destRenderbuf . get ( ) ) ; glRenderbufferStorage ( GL_RENDERBUFFER , GL_DEPTH_COMPONENT24 , 256 , 256 ) ; GLFramebuffer resolved ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , resolved . get ( ) ) ; glFramebufferRenderbuffer ( GL_DRAW_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , GL_RENDERBUFFER , destRenderbuf . get ( ) ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , framebuffer . get ( ) ) ; glBlitFramebuffer ( 0 , 0 , 256 , 256 , 0 , 0 , 256 , 256 , GL_DEPTH_BUFFER_BIT , GL_NEAREST ) ; glBindFramebuffer ( GL_FRAMEBUFFER , resolved . get ( ) ) ; GLTexture colorbuf ; glBindTexture ( GL_TEXTURE_2D , colorbuf . get ( ) ) ; glTexStorage2D ( GL_TEXTURE_2D , 1 , GL_RGBA8 , 256 , 256 ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , colorbuf . get ( ) , 0 ) ; ASSERT_GL_NO_ERROR ( ) ; glClearColor ( 0.0f , 1.0f , 0.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: green ) ; ANGLE_GL_PROGRAM ( drawRed , essl3_shaders :: vs :: Simple ( ) , essl3_shaders :: fs :: Red ( ) ) ; glEnable ( GL_DEPTH_TEST ) ; glDepthMask ( false ) ; glDepthFunc ( GL_LESS ) ; drawQuad ( drawRed . get ( ) , essl3_shaders :: PositionAttrib ( ) , -0.01f ) ; 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 ) ; ANGLE_GL_PROGRAM ( drawBlue , essl3_shaders :: vs :: Simple ( ) , essl3_shaders :: fs :: Blue ( ) ) ; glEnable ( GL_DEPTH_TEST ) ; glDepthMask ( false ) ; glDepthFunc ( GL_GREATER ) ; drawQuad ( drawBlue . get ( ) , essl3_shaders :: PositionAttrib ( ) , 0.01f ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 255 , 0 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 255 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 255 , 255 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( 127 , 127 , GLColor :: blue ) ; ASSERT_GL_NO_ERROR ( ) ; }
Tests resolving a multisample depth buffer.
Tests resolving a multisample depth buffer .
// TODO(oetuaho@nvidia.com): http://crbug.com/837717 // Clear to green // Make sure resulting depth is near 0.5f.