src/third_party/angle/src/tests/gl_tests/DrawBuffersTest.cpp
// Test draw buffer state change followed scissored clear
Test draw buffer state change followed scissored clear
Test draw buffer state change followed scissored clear
TEST_P(ColorMaskForDrawBuffersTest, ScissoredClear)
{
    ANGLE_SKIP_TEST_IF(!setupTest());
    setupColorMaskForDrawBuffersTest();
    drawBuffers[1] = GL_COLOR_ATTACHMENT1;
    setDrawBuffers(4, drawBuffers);
    GLfloat *clearColor = GLColor::blue.toNormalizedVector().data();
    glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
    glScissor(0, 0, getWindowWidth() / 2, getWindowHeight() / 2);
    glEnable(GL_SCISSOR_TEST);
    glClear(GL_COLOR_BUFFER_BIT);
    resetDrawBuffers();
    clearColor = GLColor::magenta.toNormalizedVector().data();
    glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
    glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight() / 2);
    glClear(GL_COLOR_BUFFER_BIT);
    EXPECT_GL_NO_ERROR();
    glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[0],
                           0);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() / 4, GLColor::magenta);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() * 3 / 4, GLColor::red);
    glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[1],
                           0);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::blue);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() / 4, GLColor::magenta);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() * 3 / 4, GLColor::green);
    EXPECT_GL_NO_ERROR();
}
TEST_P ( ColorMaskForDrawBuffersTest , ScissoredClear ) { ANGLE_SKIP_TEST_IF ( ! setupTest ( ) ) ; setupColorMaskForDrawBuffersTest ( ) ; drawBuffers [ 1 ] = GL_COLOR_ATTACHMENT1 ; setDrawBuffers ( 4 , drawBuffers ) ; GLfloat * clearColor = GLColor :: blue . toNormalizedVector ( ) . data ( ) ; glClearColor ( clearColor [ 0 ] , clearColor [ 1 ] , clearColor [ 2 ] , clearColor [ 3 ] ) ; glScissor ( 0 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) / 2 ) ; glEnable ( GL_SCISSOR_TEST ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; resetDrawBuffers ( ) ; clearColor = GLColor :: magenta . toNormalizedVector ( ) . data ( ) ; glClearColor ( clearColor [ 0 ] , clearColor [ 1 ] , clearColor [ 2 ] , clearColor [ 3 ] ) ; glScissor ( getWindowWidth ( ) / 2 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) / 2 ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; EXPECT_GL_NO_ERROR ( ) ; glFramebufferTexture2D ( GL_READ_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , mTextures [ 0 ] , 0 ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) / 4 , getWindowHeight ( ) / 4 , GLColor :: red ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) * 3 / 4 , getWindowHeight ( ) / 4 , GLColor :: magenta ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) / 4 , getWindowHeight ( ) * 3 / 4 , GLColor :: red ) ; glFramebufferTexture2D ( GL_READ_FRAMEBUFFER , GL_COLOR_ATTACHMENT0 , GL_TEXTURE_2D , mTextures [ 1 ] , 0 ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) / 4 , getWindowHeight ( ) / 4 , GLColor :: blue ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) * 3 / 4 , getWindowHeight ( ) / 4 , GLColor :: magenta ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) / 4 , getWindowHeight ( ) * 3 / 4 , GLColor :: green ) ; EXPECT_GL_NO_ERROR ( ) ; }
Test draw buffer state change followed scissored clear
Test draw buffer state change followed scissored clear
// Clear attachment1. Buffer0 should retain red and buffer1 should be blue