src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
// Test resolving a multisampled stencil buffer.
Test resolving a multisampled stencil buffer.
Test resolving a multisampled stencil buffer .
TEST_P(BlitFramebufferTest, MultisampleStencil)
{
    ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows());
    ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel() && IsOSX());
    GLRenderbuffer renderbuf;
    glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
    glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256);
    ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
    GLFramebuffer framebuffer;
    glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
                              renderbuf.get());
    ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
    glStencilFunc(GL_ALWAYS, 0x1, 0xFF);
    glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
    glEnable(GL_STENCIL_TEST);
    drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
    GLTexture destColorbuf;
    glBindTexture(GL_TEXTURE_2D, destColorbuf.get());
    glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
    GLRenderbuffer destRenderbuf;
    glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
    glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 256, 256);
    GLFramebuffer resolved;
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                           destColorbuf.get(), 0);
    glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
                              destRenderbuf.get());
    glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get());
    glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
    glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
    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);
    glStencilFunc(GL_EQUAL, 0x1, 0xFF);
    drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
    ASSERT_GL_NO_ERROR();
}
TEST_P ( BlitFramebufferTest , MultisampleStencil ) { ANGLE_SKIP_TEST_IF ( IsAMD ( ) && IsOpenGL ( ) && IsWindows ( ) ) ; ANGLE_SKIP_TEST_IF ( IsMetal ( ) && IsIntel ( ) && IsOSX ( ) ) ; GLRenderbuffer renderbuf ; glBindRenderbuffer ( GL_RENDERBUFFER , renderbuf . get ( ) ) ; glRenderbufferStorageMultisample ( GL_RENDERBUFFER , 2 , GL_STENCIL_INDEX8 , 256 , 256 ) ; ANGLE_GL_PROGRAM ( drawRed , essl3_shaders :: vs :: Simple ( ) , essl3_shaders :: fs :: Red ( ) ) ; GLFramebuffer framebuffer ; glBindFramebuffer ( GL_FRAMEBUFFER , framebuffer . get ( ) ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_STENCIL_ATTACHMENT , GL_RENDERBUFFER , renderbuf . get ( ) ) ; ASSERT_GLENUM_EQ ( GL_FRAMEBUFFER_COMPLETE , glCheckFramebufferStatus ( GL_FRAMEBUFFER ) ) ; glStencilFunc ( GL_ALWAYS , 0x1 , 0xFF ) ; glStencilOp ( GL_REPLACE , GL_REPLACE , GL_REPLACE ) ; glEnable ( GL_STENCIL_TEST ) ; drawQuad ( drawRed . get ( ) , essl3_shaders :: PositionAttrib ( ) , 0.5f ) ; GLTexture destColorbuf ; glBindTexture ( GL_TEXTURE_2D , destColorbuf . get ( ) ) ; glTexStorage2D ( GL_TEXTURE_2D , 1 , GL_RGBA8 , 256 , 256 ) ; GLRenderbuffer destRenderbuf ; glBindRenderbuffer ( GL_RENDERBUFFER , destRenderbuf . get ( ) ) ; glRenderbufferStorage ( GL_RENDERBUFFER , GL_STENCIL_INDEX8 , 256 , 256 ) ; GLFramebuffer resolved ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , resolved . get ( ) ) ; glFramebufferTexture2D ( GL_DRAW_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , destColorbuf . get ( ) , 0 ) ; glFramebufferRenderbuffer ( GL_DRAW_FRAMEBUFFER , GL_STENCIL_ATTACHMENT , GL_RENDERBUFFER , destRenderbuf . get ( ) ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , framebuffer . get ( ) ) ; glBlitFramebuffer ( 0 , 0 , 256 , 256 , 0 , 0 , 256 , 256 , GL_STENCIL_BUFFER_BIT , GL_NEAREST ) ; glBindFramebuffer ( GL_FRAMEBUFFER , resolved . get ( ) ) ; 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 ) ; glStencilFunc ( GL_EQUAL , 0x1 , 0xFF ) ; drawQuad ( drawRed . get ( ) , essl3_shaders :: PositionAttrib ( ) , 0.5f ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: red ) ; ASSERT_GL_NO_ERROR ( ) ; }
Test resolving a multisampled stencil buffer.
Test resolving a multisampled stencil buffer .
// Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486 // http://anglebug.com/5106 // fill the stencil buffer with 0x1 // Clear to green // Draw red if the stencil is 0x1, which should be true after the resolve.