src/third_party/angle/src/tests/gl_tests/MultisampledRenderToTextureTest.cpp
// Checking for framebuffer completeness using extension methods.
Checking for framebuffer completeness using extension methods.
Checking for framebuffer completeness using extension methods .
TEST_P(MultisampledRenderToTextureTest, FramebufferCompleteness)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_multisampled_render_to_texture"));
    GLTexture texture;
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    ASSERT_GL_NO_ERROR();
    GLFramebuffer FBO;
    glBindFramebuffer(GL_FRAMEBUFFER, FBO);
    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                         texture, 0, 4);
    EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    GLsizei maxSamples = 0;
    glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
    GLRenderbuffer dsRenderbuffer;
    glBindRenderbuffer(GL_RENDERBUFFER, dsRenderbuffer);
    glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, maxSamples, GL_DEPTH_COMPONENT16, 64, 64);
    ASSERT_GL_NO_ERROR();
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, dsRenderbuffer);
    if (maxSamples > 4)
    {
        EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
                         glCheckFramebufferStatus(GL_FRAMEBUFFER));
    }
    else
    {
        EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    }
    GLRenderbuffer colorRenderbuffer;
    glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
    glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, maxSamples, GL_RGBA4, 64, 64);
    ASSERT_GL_NO_ERROR();
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
                              colorRenderbuffer);
    EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    ANGLE_SKIP_TEST_IF(IsD3D());
    if (getClientMajorVersion() >= 3)
    {
        GLTexture texture2;
        glBindTexture(GL_TEXTURE_2D, texture2);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
        ASSERT_GL_NO_ERROR();
        glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,
                                             texture, 0, 4);
        if (maxSamples > 4)
        {
            EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
                             glCheckFramebufferStatus(GL_FRAMEBUFFER));
        }
        else
        {
            EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
        }
        glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,
                                             texture, 0, maxSamples);
        EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    }
}
TEST_P ( MultisampledRenderToTextureTest , FramebufferCompleteness ) { ANGLE_SKIP_TEST_IF ( ! EnsureGLExtensionEnabled ( " " ) ) ; GLTexture texture ; glBindTexture ( GL_TEXTURE_2D , texture ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , 64 , 64 , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; ASSERT_GL_NO_ERROR ( ) ; GLFramebuffer FBO ; glBindFramebuffer ( GL_FRAMEBUFFER , FBO ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , texture , 0 , 4 ) ; EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; GLsizei maxSamples = 0 ; glGetIntegerv ( GL_MAX_SAMPLES , & maxSamples ) ; GLRenderbuffer dsRenderbuffer ; glBindRenderbuffer ( GL_RENDERBUFFER , dsRenderbuffer ) ; glRenderbufferStorageMultisampleEXT ( GL_RENDERBUFFER , maxSamples , GL_DEPTH_COMPONENT16 , 64 , 64 ) ; ASSERT_GL_NO_ERROR ( ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , GL_RENDERBUFFER , dsRenderbuffer ) ; if ( maxSamples > 4 ) { EXPECT_GLENUM_EQ ( GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE , glCheckFramebufferStatus ( GL_FRAMEBUFFER ) ) ; } else { EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; } GLRenderbuffer colorRenderbuffer ; glBindRenderbuffer ( GL_RENDERBUFFER , colorRenderbuffer ) ; glRenderbufferStorageMultisampleEXT ( GL_RENDERBUFFER , maxSamples , GL_RGBA4 , 64 , 64 ) ; ASSERT_GL_NO_ERROR ( ) ; glFramebufferRenderbuffer ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_RENDERBUFFER , colorRenderbuffer ) ; EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; ANGLE_SKIP_TEST_IF ( IsD3D ( ) ) ; if ( getClientMajorVersion ( ) >= 3 ) { GLTexture texture2 ; glBindTexture ( GL_TEXTURE_2D , texture2 ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA , 64 , 64 , 0 , GL_RGBA , GL_UNSIGNED_BYTE , nullptr ) ; ASSERT_GL_NO_ERROR ( ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT1 , GL_TEXTURE_2D , texture , 0 , 4 ) ; if ( maxSamples > 4 ) { EXPECT_GLENUM_EQ ( GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE , glCheckFramebufferStatus ( GL_FRAMEBUFFER ) ) ; } else { EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; } glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT1 , GL_TEXTURE_2D , texture , 0 , maxSamples ) ; EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; } }
Checking for framebuffer completeness using extension methods.
Checking for framebuffer completeness using extension methods .
// Checking that Renderbuffer and texture2d having different number of samples results // in a FRAMEBUFFER_INCOMPLETE_MULTISAMPLE // Texture attachment for color attachment 0.  Framebuffer should be complete. // Depth/stencil renderbuffer, potentially with a different sample count. // Color renderbuffer for color attachment 0. // D3D backend doesn't implement multisampled render to texture renderbuffers correctly. // http://anglebug.com/3107 // Texture attachment for color attachment 1. // Attach with a potentially different number of samples. // Attach with same number of samples.