src/third_party/angle/src/tests/gl_tests/MultisampleTest.cpp
// Test that alpha to coverage is enabled works properly along with early fragment test.
Test that alpha to coverage is enabled works properly along with early fragment test.
Test that alpha to coverage is enabled works properly along with early fragment test .
TEST_P(MultisampleTest, AlphaToSampleCoverage)
{
    ANGLE_SKIP_TEST_IF(!mMultisampledConfigExists);
    ANGLE_SKIP_TEST_IF(IsMetal());
    constexpr char kFS[] =
        "precision highp float;\n"
        "void main()\n"
        "{\n"
        "    gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);\n"
        "}\n";
    ANGLE_GL_PROGRAM(transparentRedProgram, essl1_shaders::vs::Simple(), kFS);
    glUseProgram(transparentRedProgram);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LESS);
    glClearDepthf(1.0f);
    glClearColor(0.0f, 1.0f, 0.0f, 1.0f);  
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
    glEnable(GL_SAMPLE_COVERAGE);
    drawQuad(transparentRedProgram, essl1_shaders::PositionAttrib(), 0.0f);
    glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
    glDisable(GL_SAMPLE_COVERAGE);
    glDepthFunc(GL_GREATER);
    ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue());
    drawQuad(blueProgram, essl1_shaders::PositionAttrib(), 0.5f);
    EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::green);
    ASSERT_GL_NO_ERROR();
}
TEST_P ( MultisampleTest , AlphaToSampleCoverage ) { ANGLE_SKIP_TEST_IF ( ! mMultisampledConfigExists ) ; ANGLE_SKIP_TEST_IF ( IsMetal ( ) ) ; constexpr char kFS [ ] = " \n " " \n " " \n " " \n " " \n " ; ANGLE_GL_PROGRAM ( transparentRedProgram , essl1_shaders :: vs :: Simple ( ) , kFS ) ; glUseProgram ( transparentRedProgram ) ; glEnable ( GL_DEPTH_TEST ) ; glDepthFunc ( GL_LESS ) ; glClearDepthf ( 1.0f ) ; glClearColor ( 0.0f , 1.0f , 0.0f , 1.0f ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; glEnable ( GL_SAMPLE_ALPHA_TO_COVERAGE ) ; glEnable ( GL_SAMPLE_COVERAGE ) ; drawQuad ( transparentRedProgram , essl1_shaders :: PositionAttrib ( ) , 0.0f ) ; glDisable ( GL_SAMPLE_ALPHA_TO_COVERAGE ) ; glDisable ( GL_SAMPLE_COVERAGE ) ; glDepthFunc ( GL_GREATER ) ; ANGLE_GL_PROGRAM ( blueProgram , essl1_shaders :: vs :: Simple ( ) , essl1_shaders :: fs :: Blue ( ) ) ; drawQuad ( blueProgram , essl1_shaders :: PositionAttrib ( ) , 0.5f ) ; EXPECT_PIXEL_COLOR_EQ ( 1 , 1 , GLColor :: green ) ; ASSERT_GL_NO_ERROR ( ) ; }
Test that alpha to coverage is enabled works properly along with early fragment test.
Test that alpha to coverage is enabled works properly along with early fragment test .
// http://anglebug.com/5087 // clear to green // This should pass depth test, but because of the alpha to coverage enabled, and alpha is 0, // the fragment should be discarded. If early fragment test is disabled, no depth will be // written. depth buffer should be 1.0. // There was a bug in ANGLE that we are checking sampler coverage enabled or not instead of // alpha to sample coverage enabled or not. This is specically try to trick ANGLE so that it // will enable early fragment test. When early fragment test is accidentally enabled, then the // depth test will occur before fragment shader, and depth buffer maybe written with value // (0.0+1.0)/2.0=0.5. // Now draw with blue color but to test against 0.0f. This should fail depth test // Zd = 0.5f means (0.5+1.0)/2.0=0.75. Depends on early fragment on or off this will pass or // fail depth test.