src/third_party/angle/src/tests/gl_tests/MultisampledRenderToTextureTest.cpp
// Checking against invalid parameters for FramebufferTexture2DMultisampleEXT.
Checking against invalid parameters for FramebufferTexture2DMultisampleEXT.
Checking against invalid parameters for FramebufferTexture2DMultisampleEXT .
TEST_P(MultisampledRenderToTextureTest, Texture2DParameterCheck)
{
    ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_multisampled_render_to_texture"));
    bool isES3 = getClientMajorVersion() >= 3;
    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();
    GLTexture depthTexture;
    if (isES3)
    {
        glBindTexture(GL_TEXTURE_2D, depthTexture);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 64, 64, 0, GL_DEPTH_STENCIL,
                     GL_UNSIGNED_INT_24_8_OES, nullptr);
    }
    GLFramebuffer fbo;
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                         texture, 0, 4);
    ASSERT_GL_NO_ERROR();
    EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,
                                         texture, 0, 4);
    assertErrorIfNotMSRTT2(GL_INVALID_ENUM);
    if (isES3)
    {
        glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
                                             depthTexture, 0, 4);
        assertErrorIfNotMSRTT2(GL_INVALID_ENUM);
        glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
                                             depthTexture, 0, 4);
        assertErrorIfNotMSRTT2(GL_INVALID_ENUM);
        glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
                                             GL_TEXTURE_2D, depthTexture, 0, 4);
        assertErrorIfNotMSRTT2(GL_INVALID_ENUM);
        glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D,
                                             depthTexture, 0, 4);
        assertErrorIfNotMSRTT2(GL_INVALID_ENUM);
    }
    glFramebufferTexture2DMultisampleEXT(GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                         texture, 0, 4);
    ASSERT_GL_ERROR(GL_INVALID_ENUM);
    GLint samples;
    glGetIntegerv(GL_MAX_SAMPLES_EXT, &samples);
    ASSERT_GL_NO_ERROR();
    EXPECT_GE(samples, 1);
    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                         texture, 0, samples + 1);
    ASSERT_GL_ERROR(GL_INVALID_VALUE);
    glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                         texture, 0, 4);
    GLint param = 0;
    glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                          GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT, &param);
    EXPECT_GE(param, 4);
}
TEST_P ( MultisampledRenderToTextureTest , Texture2DParameterCheck ) { ANGLE_SKIP_TEST_IF ( ! EnsureGLExtensionEnabled ( " " ) ) ; bool isES3 = getClientMajorVersion ( ) >= 3 ; 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 ( ) ; GLTexture depthTexture ; if ( isES3 ) { glBindTexture ( GL_TEXTURE_2D , depthTexture ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_DEPTH24_STENCIL8 , 64 , 64 , 0 , GL_DEPTH_STENCIL , GL_UNSIGNED_INT_24_8_OES , nullptr ) ; } GLFramebuffer fbo ; glBindFramebuffer ( GL_FRAMEBUFFER , fbo ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , texture , 0 , 4 ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_GL_FRAMEBUFFER_COMPLETE ( GL_FRAMEBUFFER ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT1 , GL_TEXTURE_2D , texture , 0 , 4 ) ; assertErrorIfNotMSRTT2 ( GL_INVALID_ENUM ) ; if ( isES3 ) { glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_DEPTH_ATTACHMENT , GL_TEXTURE_2D , depthTexture , 0 , 4 ) ; assertErrorIfNotMSRTT2 ( GL_INVALID_ENUM ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_STENCIL_ATTACHMENT , GL_TEXTURE_2D , depthTexture , 0 , 4 ) ; assertErrorIfNotMSRTT2 ( GL_INVALID_ENUM ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_DEPTH_STENCIL_ATTACHMENT , GL_TEXTURE_2D , depthTexture , 0 , 4 ) ; assertErrorIfNotMSRTT2 ( GL_INVALID_ENUM ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT1 , GL_TEXTURE_2D , depthTexture , 0 , 4 ) ; assertErrorIfNotMSRTT2 ( GL_INVALID_ENUM ) ; } glFramebufferTexture2DMultisampleEXT ( GL_RENDERBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , texture , 0 , 4 ) ; ASSERT_GL_ERROR ( GL_INVALID_ENUM ) ; GLint samples ; glGetIntegerv ( GL_MAX_SAMPLES_EXT , & samples ) ; ASSERT_GL_NO_ERROR ( ) ; EXPECT_GE ( samples , 1 ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , texture , 0 , samples + 1 ) ; ASSERT_GL_ERROR ( GL_INVALID_VALUE ) ; glFramebufferTexture2DMultisampleEXT ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , texture , 0 , 4 ) ; GLint param = 0 ; glGetFramebufferAttachmentParameteriv ( GL_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT , & param ) ; EXPECT_GE ( param , 4 ) ; }
Checking against invalid parameters for FramebufferTexture2DMultisampleEXT.
Checking against invalid parameters for FramebufferTexture2DMultisampleEXT .
// Positive test case // Attachment not COLOR_ATTACHMENT0.  Allowed only in EXT_multisampled_render_to_texture2 // Depth/stencil attachment.  Allowed only in EXT_multisampled_render_to_texture2 // Target not framebuffer // Samples too large // Retrieving samples // GE because samples may vary base on implementation. Spec says "the resulting value for // TEXTURE_SAMPLES_EXT is guaranteed to be greater than or equal to samples and no more than the // next larger sample count supported by the implementation"