src/third_party/angle/src/tests/gl_tests/MultisampledRenderToTextureTest.cpp
// Draw, then blit depth/stencil with renderbuffers.  This test makes sure depth/stencil resolve is
// correctly implemented.  Note that this test doesn't apply to depth/stencil textures as they are
// explicitly autoinvalidated between render passes.
Draw, then blit depth/stencil with renderbuffers.  This test makes sure depth/stencil resolve is
correctly implemented.  Note that this test doesn't apply to depth/stencil textures as they are
explicitly autoinvalidated between render passes.
Draw then blit depth / stencil with renderbuffers . This test makes sure depth / stencil resolve is correctly implemented . Note that this test doesn ' t apply to depth / stencil textures as they are explicitly autoinvalidated between render passes .
TEST_P(MultisampledRenderToTextureES3Test, RenderbufferDrawThenBlitDepthStencil)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_multisampled_render_to_texture"));
    ANGLE_SKIP_TEST_IF(IsVulkan() &&
                       (isSwiftshader() || IsAndroid() || IsAMD() || (IsWindows7() && IsNVIDIA())));
    ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsVulkan());
    constexpr GLsizei kSize = 64;
    GLFramebuffer fboMS;
    glBindFramebuffer(GL_FRAMEBUFFER, fboMS);
    GLTexture color;
    glBindTexture(GL_TEXTURE_2D, color);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color,
                                         0, 4);
    GLRenderbuffer depthStencilMS;
    glBindRenderbuffer(GL_RENDERBUFFER, depthStencilMS);
    glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, kSize, kSize);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
                              depthStencilMS);
    ASSERT_GL_NO_ERROR();
    EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    ANGLE_GL_PROGRAM(drawColor, essl1_shaders::vs::Simple(), essl1_shaders::fs::UniformColor());
    glUseProgram(drawColor);
    GLint colorUniformLocation =
        glGetUniformLocation(drawColor, angle::essl1_shaders::ColorUniform());
    ASSERT_NE(colorUniformLocation, -1);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_ALWAYS);
    glEnable(GL_STENCIL_TEST);
    glStencilFunc(GL_ALWAYS, 0x55, 0xFF);
    glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
    glStencilMask(0xFF);
    glUniform4f(colorUniformLocation, 0.0f, 0.0f, 1.0f, 1.0f);
    drawQuad(drawColor, essl1_shaders::PositionAttrib(), 1.0f);
    ASSERT_GL_NO_ERROR();
    GLFramebuffer fbo;
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color, 0);
    GLRenderbuffer depthStencil;
    glBindRenderbuffer(GL_RENDERBUFFER, depthStencil);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, kSize, kSize);
    glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
                              depthStencil);
    ASSERT_GL_NO_ERROR();
    EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_DRAW_FRAMEBUFFER);
    glBlitFramebuffer(0, 0, kSize, kSize, 0, 0, kSize, kSize,
                      GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
    glDepthFunc(GL_LESS);
    glStencilFunc(GL_EQUAL, 0x55, 0xFF);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    glStencilMask(0xFF);
    glUniform4f(colorUniformLocation, 1.0f, 0.0f, 0.0f, 1.0f);
    drawQuad(drawColor, essl1_shaders::PositionAttrib(), 0.0f);
    ASSERT_GL_NO_ERROR();
    EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, GLColor::red);
}
TEST_P ( MultisampledRenderToTextureES3Test , RenderbufferDrawThenBlitDepthStencil ) { ANGLE_SKIP_TEST_IF ( ! EnsureGLExtensionEnabled ( " " ) ) ; ANGLE_SKIP_TEST_IF ( IsVulkan ( ) && ( isSwiftshader ( ) || IsAndroid ( ) || IsAMD ( ) || ( IsWindows7 ( ) && IsNVIDIA ( ) ) ) ) ; ANGLE_SKIP_TEST_IF ( IsLinux ( ) && IsIntel ( ) && IsVulkan ( ) ) ; constexpr GLsizei kSize = 64 ; GLFramebuffer fboMS ; glBindFramebuffer ( GL_FRAMEBUFFER , fboMS ) ; GLTexture color ; glBindTexture ( GL_TEXTURE_2D , color ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , kSize , kSize , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , color , 0 , 4 ) ; GLRenderbuffer depthStencilMS ; glBindRenderbuffer ( GL_RENDERBUFFER , depthStencilMS ) ; glRenderbufferStorageMultisampleEXT ( GL_RENDERBUFFER , 4 , GL_DEPTH24_STENCIL8 , kSize , kSize ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_DEPTH_STENCIL_ATTACHMENT , GL_RENDERBUFFER , depthStencilMS ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; ANGLE_GL_PROGRAM ( drawColor , essl1_shaders :: vs :: Simple ( ) , essl1_shaders :: fs :: UniformColor ( ) ) ; glUseProgram ( drawColor ) ; GLint colorUniformLocation = glGetUniformLocation ( drawColor , angle :: essl1_shaders :: ColorUniform ( ) ) ; ASSERT_NE ( colorUniformLocation , -1 ) ; glEnable ( GL_DEPTH_TEST ) ; glDepthFunc ( GL_ALWAYS ) ; glEnable ( GL_STENCIL_TEST ) ; glStencilFunc ( GL_ALWAYS , 0x55 , 0xFF ) ; glStencilOp ( GL_REPLACE , GL_REPLACE , GL_REPLACE ) ; glStencilMask ( 0xFF ) ; glUniform4f ( colorUniformLocation , 0.0f , 0.0f , 1.0f , 1.0f ) ; drawQuad ( drawColor , essl1_shaders :: PositionAttrib ( ) , 1.0f ) ; ASSERT_GL_NO_ERROR ( ) ; GLFramebuffer fbo ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , fbo ) ; glFramebufferTexture2D ( GL_DRAW_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , color , 0 ) ; GLRenderbuffer depthStencil ; glBindRenderbuffer ( GL_RENDERBUFFER , depthStencil ) ; glRenderbufferStorage ( GL_RENDERBUFFER , GL_DEPTH24_STENCIL8 , kSize , kSize ) ; glFramebufferRenderbuffer ( GL_DRAW_FRAMEBUFFER , GL_DEPTH_STENCIL_ATTACHMENT , GL_RENDERBUFFER , depthStencil ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_DRAW_FRAMEBUFFER ) ; glBlitFramebuffer ( 0 , 0 , kSize , kSize , 0 , 0 , kSize , kSize , GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT , GL_NEAREST ) ; glDepthFunc ( GL_LESS ) ; glStencilFunc ( GL_EQUAL , 0x55 , 0xFF ) ; glStencilOp ( GL_KEEP , GL_KEEP , GL_KEEP ) ; glStencilMask ( 0xFF ) ; glUniform4f ( colorUniformLocation , 1.0f , 0.0f , 0.0f , 1.0f ) ; drawQuad ( drawColor , essl1_shaders :: PositionAttrib ( ) , 0.0f ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , 0 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , 0 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( 0 , kSize - 1 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( kSize - 1 , kSize - 1 , GLColor :: red ) ; }
Draw, then blit depth/stencil with renderbuffers.
Draw then blit depth / stencil with renderbuffers .
// Skip on configurations that don't support VK_KHR_depth_stencil_resolve.  See comment // in RenderbufferClearThenBlitDepthStencil. // http://anglebug.com/5096 // Create framebuffer to draw into, with both color and depth/stencil attachments. // Set up program // Output depth/stencil through draw // Draw blue // Create framebuffer as blit target. // Blit depth/stencil // Draw into the framebuffer that was the destination of blit, verifying that depth and stencil // values are correct. // If depth is not 1, rendering would fail. // If stencil is not 0x55, rendering would fail. // Draw red // Verify that the texture is now red