src/third_party/angle/src/tests/gl_tests/DrawBuffersTest.cpp
// Test draw buffer state change followed draw call
Test draw buffer state change followed draw call
Test draw buffer state change followed draw call
TEST_P(ColorMaskForDrawBuffersTest, DrawQuad)
{
    ANGLE_SKIP_TEST_IF(!setupTest());
    setupColorMaskForDrawBuffersTest();
    drawBuffers[0] = GL_COLOR_ATTACHMENT0;
    setDrawBuffers(4, drawBuffers);
    glUniform4fv(color0UniformLocation, 1, GLColor::blue.toNormalizedVector().data());
    glUniform4fv(color1UniformLocation, 1, GLColor::cyan.toNormalizedVector().data());
    glViewport(0, 0, getWindowWidth() / 2, getWindowHeight() / 2);
    drawQuad(program, positionAttrib(), 0.5);
    resetDrawBuffers();
    glUniform4fv(color0UniformLocation, 1, GLColor::magenta.toNormalizedVector().data());
    glUniform4fv(color1UniformLocation, 1, GLColor::white.toNormalizedVector().data());
    glViewport(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight() / 2);
    drawQuad(program, positionAttrib(), 0.5);
    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::blue);
    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::green);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() * 3 / 4, getWindowHeight() / 4, GLColor::white);
    EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() * 3 / 4, GLColor::green);
    EXPECT_GL_NO_ERROR();
}
TEST_P ( ColorMaskForDrawBuffersTest , DrawQuad ) { ANGLE_SKIP_TEST_IF ( ! setupTest ( ) ) ; setupColorMaskForDrawBuffersTest ( ) ; drawBuffers [ 0 ] = GL_COLOR_ATTACHMENT0 ; setDrawBuffers ( 4 , drawBuffers ) ; glUniform4fv ( color0UniformLocation , 1 , GLColor :: blue . toNormalizedVector ( ) . data ( ) ) ; glUniform4fv ( color1UniformLocation , 1 , GLColor :: cyan . toNormalizedVector ( ) . data ( ) ) ; glViewport ( 0 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) / 2 ) ; drawQuad ( program , positionAttrib ( ) , 0.5 ) ; resetDrawBuffers ( ) ; glUniform4fv ( color0UniformLocation , 1 , GLColor :: magenta . toNormalizedVector ( ) . data ( ) ) ; glUniform4fv ( color1UniformLocation , 1 , GLColor :: white . toNormalizedVector ( ) . data ( ) ) ; glViewport ( getWindowWidth ( ) / 2 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) / 2 ) ; drawQuad ( program , positionAttrib ( ) , 0.5 ) ; 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 :: blue ) ; 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 :: green ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) * 3 / 4 , getWindowHeight ( ) / 4 , GLColor :: white ) ; EXPECT_PIXEL_COLOR_EQ ( getWindowWidth ( ) / 4 , getWindowHeight ( ) * 3 / 4 , GLColor :: green ) ; EXPECT_GL_NO_ERROR ( ) ; }
Test draw buffer state change followed draw call
Test draw buffer state change followed draw call
// Draw blue into attachment0. Buffer0 should be blue and buffer1 should remain green