src/third_party/angle/src/tests/gl_tests/BlitFramebufferANGLETest.cpp
// Test blitFramebuffer size overflow checks. WebGL 2.0 spec section 5.41. Similar to above test,
// but this test more accurately duplicates the behavior of the WebGL test
// conformance2/rendering/blitframebuffer-size-overflow.html, which covers a few more edge cases.
Test blitFramebuffer size overflow checks.
Test blitFramebuffer size overflow checks .
TEST_P(BlitFramebufferTest, BlitFramebufferSizeOverflow2)
{
    GLTexture textures[2];
    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
    glBindTexture(GL_TEXTURE_2D, textures[1]);
    glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
    GLFramebuffer framebuffers[2];
    glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]);
    ASSERT_GL_NO_ERROR();
    glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
                           0);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1],
                           0);
    ASSERT_GL_NO_ERROR();
    GLint width  = 8;
    GLint height = 8;
    GLTexture tex0;
    glBindTexture(GL_TEXTURE_2D, tex0);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
    GLFramebuffer fb0;
    glBindFramebuffer(GL_READ_FRAMEBUFFER, fb0);
    glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex0, 0);
    GLTexture tex1;
    glBindTexture(GL_TEXTURE_2D, tex1);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
    GLFramebuffer fb1;
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb1);
    glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex1, 0);
    GLint max = std::numeric_limits<GLint>::max();
    glBlitFramebuffer(0, 0, max, max, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    glBlitFramebuffer(0, 0, width, height, 0, 0, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    glBlitFramebuffer(0, 0, max, max, 0, 0, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_NO_ERROR();
    glBlitFramebuffer(-1, -1, max - 1, max - 1, 0, 0, width, height, GL_COLOR_BUFFER_BIT,
                      GL_NEAREST);
    glBlitFramebuffer(0, 0, width, height, -1, -1, max - 1, max - 1, GL_COLOR_BUFFER_BIT,
                      GL_NEAREST);
    glBlitFramebuffer(-1, -1, max - 1, max - 1, -1, -1, max - 1, max - 1, GL_COLOR_BUFFER_BIT,
                      GL_NEAREST);
    EXPECT_GL_NO_ERROR();
    glBlitFramebuffer(-1, -1, max, max, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_ERROR(GL_INVALID_VALUE);
    glBlitFramebuffer(max, max, -1, -1, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_ERROR(GL_INVALID_VALUE);
    glBlitFramebuffer(0, 0, width, height, -1, -1, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_ERROR(GL_INVALID_VALUE);
    glBlitFramebuffer(0, 0, width, height, max, max, -1, -1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_ERROR(GL_INVALID_VALUE);
    glBlitFramebuffer(-1, -1, max, max, -1, -1, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_ERROR(GL_INVALID_VALUE);
    glBlitFramebuffer(-max - 1, -max - 1, max, max, -max - 1, -max - 1, max, max,
                      GL_COLOR_BUFFER_BIT, GL_NEAREST);
    EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
TEST_P ( BlitFramebufferTest , BlitFramebufferSizeOverflow2 ) { GLTexture textures [ 2 ] ; glBindTexture ( GL_TEXTURE_2D , textures [ 0 ] ) ; glTexStorage2D ( GL_TEXTURE_2D , 3 , GL_RGBA8 , 4 , 4 ) ; glBindTexture ( GL_TEXTURE_2D , textures [ 1 ] ) ; glTexStorage2D ( GL_TEXTURE_2D , 3 , GL_RGBA8 , 4 , 4 ) ; GLFramebuffer framebuffers [ 2 ] ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , framebuffers [ 0 ] ) ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , framebuffers [ 1 ] ) ; ASSERT_GL_NO_ERROR ( ) ; glFramebufferTexture2D ( GL_READ_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , textures [ 0 ] , 0 ) ; glFramebufferTexture2D ( GL_DRAW_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , textures [ 1 ] , 0 ) ; ASSERT_GL_NO_ERROR ( ) ; GLint width = 8 ; GLint height = 8 ; GLTexture tex0 ; glBindTexture ( GL_TEXTURE_2D , tex0 ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA8 , width , height , 0 , GL_RGBA , GL_UNSIGNED_BYTE , 0 ) ; GLFramebuffer fb0 ; glBindFramebuffer ( GL_READ_FRAMEBUFFER , fb0 ) ; glFramebufferTexture2D ( GL_READ_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , tex0 , 0 ) ; GLTexture tex1 ; glBindTexture ( GL_TEXTURE_2D , tex1 ) ; glTexImage2D ( GL_TEXTURE_2D , 0 , GL_RGBA8 , width , height , 0 , GL_RGBA , GL_UNSIGNED_BYTE , 0 ) ; GLFramebuffer fb1 ; glBindFramebuffer ( GL_DRAW_FRAMEBUFFER , fb1 ) ; glFramebufferTexture2D ( GL_DRAW_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , tex1 , 0 ) ; GLint max = std :: numeric_limits < GLint > :: max ( ) ; glBlitFramebuffer ( 0 , 0 , max , max , 0 , 0 , width , height , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; glBlitFramebuffer ( 0 , 0 , width , height , 0 , 0 , max , max , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; glBlitFramebuffer ( 0 , 0 , max , max , 0 , 0 , max , max , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_NO_ERROR ( ) ; glBlitFramebuffer ( -1 , -1 , max - 1 , max - 1 , 0 , 0 , width , height , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; glBlitFramebuffer ( 0 , 0 , width , height , -1 , -1 , max - 1 , max - 1 , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; glBlitFramebuffer ( -1 , -1 , max - 1 , max - 1 , -1 , -1 , max - 1 , max - 1 , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_NO_ERROR ( ) ; glBlitFramebuffer ( -1 , -1 , max , max , 0 , 0 , width , height , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_ERROR ( GL_INVALID_VALUE ) ; glBlitFramebuffer ( max , max , -1 , -1 , 0 , 0 , width , height , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_ERROR ( GL_INVALID_VALUE ) ; glBlitFramebuffer ( 0 , 0 , width , height , -1 , -1 , max , max , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_ERROR ( GL_INVALID_VALUE ) ; glBlitFramebuffer ( 0 , 0 , width , height , max , max , -1 , -1 , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_ERROR ( GL_INVALID_VALUE ) ; glBlitFramebuffer ( -1 , -1 , max , max , -1 , -1 , max , max , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_ERROR ( GL_INVALID_VALUE ) ; glBlitFramebuffer ( - max - 1 , - max - 1 , max , max , - max - 1 , - max - 1 , max , max , GL_COLOR_BUFFER_BIT , GL_NEAREST ) ; EXPECT_GL_ERROR ( GL_INVALID_VALUE ) ; }
Test blitFramebuffer size overflow checks.
Test blitFramebuffer size overflow checks .
// Using max 32-bit integer as blitFramebuffer parameter should succeed. // Using blitFramebuffer parameters where calculated width/height matches max 32-bit integer // should succeed // Using source width/height greater than max 32-bit integer should fail. // Using source width/height greater than max 32-bit integer should fail. // Using destination width/height greater than max 32-bit integer should fail. // Using destination width/height greater than max 32-bit integer should fail. // Using both source and destination width/height greater than max 32-bit integer should fail. // Using minimum and maximum integers for all boundaries should fail.