src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
// Test blitting from a stencil buffer with non-zero base.
Test blitting from a stencil buffer with non-zero base.
Test blitting from a stencil buffer with non - zero base .
TEST_P(BlitFramebufferTest, NonZeroBaseSourceStencil)
{
    ANGLE_SKIP_TEST_IF(IsOpenGL() && IsIntel() && IsOSX());
    ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel() && IsOSX());
    ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
    GLTexture stencilTexture;
    glBindTexture(GL_TEXTURE_2D, stencilTexture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 256, 256, 0, GL_DEPTH_STENCIL,
                 GL_UNSIGNED_INT_24_8, nullptr);
    glTexImage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, 256, 256, 0, GL_DEPTH_STENCIL,
                 GL_UNSIGNED_INT_24_8, nullptr);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
    GLFramebuffer srcFramebuffer;
    glBindFramebuffer(GL_FRAMEBUFFER, srcFramebuffer);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, stencilTexture, 1);
    ASSERT_GL_FRAMEBUFFER_COMPLETE(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 colorTexture;
    glBindTexture(GL_TEXTURE_2D, colorTexture);
    glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
    GLRenderbuffer renderbuf;
    glBindRenderbuffer(GL_RENDERBUFFER, renderbuf);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 256, 256);
    GLFramebuffer dstFramebuffer;
    glBindFramebuffer(GL_FRAMEBUFFER, dstFramebuffer);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderbuf);
    ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    glBindFramebuffer(GL_READ_FRAMEBUFFER, srcFramebuffer);
    glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
    glBindFramebuffer(GL_FRAMEBUFFER, dstFramebuffer);
    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 , NonZeroBaseSourceStencil ) { ANGLE_SKIP_TEST_IF ( IsOpenGL ( ) && IsIntel ( ) && IsOSX ( ) ) ; ANGLE_SKIP_TEST_IF ( IsMetal ( ) && IsIntel ( ) && IsOSX ( ) ) ; ANGLE_GL_PROGRAM ( drawRed , essl3_shaders :: vs :: Simple ( ) , essl3_shaders :: fs :: Red ( ) ) ; GLTexture stencilTexture ; glBindTexture ( GL_TEXTURE_2D , stencilTexture ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_DEPTH24_STENCIL8 , 256 , 256 , 0 , GL_DEPTH_STENCIL , GL_UNSIGNED_INT_24_8 , nullptr ) ; glTexImage2D ( GL_TEXTURE_2D , 1 , GL_DEPTH24_STENCIL8 , 256 , 256 , 0 , GL_DEPTH_STENCIL , GL_UNSIGNED_INT_24_8 , nullptr ) ; glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_BASE_LEVEL , 1 ) ; GLFramebuffer srcFramebuffer ; glBindFramebuffer ( GL_FRAMEBUFFER , srcFramebuffer ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_STENCIL_ATTACHMENT , GL_TEXTURE_2D , stencilTexture , 1 ) ; ASSERT_GL_FRAMEBUFFER_COMPLETE ( 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 colorTexture ; glBindTexture ( GL_TEXTURE_2D , colorTexture ) ; glTexStorage2D ( GL_TEXTURE_2D , 1 , GL_RGBA8 , 256 , 256 ) ; GLRenderbuffer renderbuf ; glBindRenderbuffer ( GL_RENDERBUFFER , renderbuf ) ; glRenderbufferStorage ( GL_RENDERBUFFER , GL_DEPTH24_STENCIL8 , 256 , 256 ) ; GLFramebuffer dstFramebuffer ; glBindFramebuffer ( GL_FRAMEBUFFER , dstFramebuffer ) ; glFramebufferTexture2D ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , colorTexture , 0 ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_STENCIL_ATTACHMENT , GL_RENDERBUFFER , renderbuf ) ; ASSERT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , srcFramebuffer ) ; glBlitFramebuffer ( 0 , 0 , 256 , 256 , 0 , 0 , 256 , 256 , GL_STENCIL_BUFFER_BIT , GL_NEAREST ) ; glBindFramebuffer ( GL_FRAMEBUFFER , dstFramebuffer ) ; 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 blitting from a stencil buffer with non-zero base.
Test blitting from a stencil buffer with non - zero base .
// http://anglebug.com/5001 // http://anglebug.com/5106 // Create a framebuffer with an attachment that has non-zero base // fill the stencil buffer with 0x1 // Create a framebuffer with an attachment that has non-zero base // Blit stencil. // Clear to green // Draw red if the stencil is 0x1, which should be true after the blit.