src/third_party/angle/src/tests/gl_tests/OcclusionQueriesTest.cpp
// Test that glClear should not be counted by occlusion query.
Test that glClear should not be counted by occlusion query.
Test that glClear should not be counted by occlusion query .
TEST_P(OcclusionQueriesTest, ClearNotCounted)
{
    ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 &&
                       !IsGLExtensionEnabled("GL_EXT_occlusion_query_boolean"));
    ANGLE_SKIP_TEST_IF(IsWindows() && IsAMD() && IsVulkan());
    ANGLE_SKIP_TEST_IF(IsD3D11());
    glDepthMask(GL_TRUE);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    EXPECT_GL_NO_ERROR();
    GLuint query[2] = {0};
    glGenQueriesEXT(2, query);
    glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query[0]);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glViewport(0, 0, getWindowWidth() / 2, getWindowHeight());
    glScissor(0, 0, getWindowWidth() / 2, getWindowHeight());
    glEnable(GL_SCISSOR_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
    EXPECT_GL_NO_ERROR();
    glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query[1]);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glViewport(0, 0, getWindowWidth() / 2, getWindowHeight());
    glScissor(0, 0, getWindowWidth() / 2, getWindowHeight());
    glEnable(GL_SCISSOR_TEST);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    drawQuad(mProgram, essl1_shaders::PositionAttrib(), 0.8f, 0.5f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    drawQuad(mProgram, essl1_shaders::PositionAttrib(), 0.8f, 1.0);
    glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
    EXPECT_GL_NO_ERROR();
    swapBuffers();
    GLuint result[2] = {GL_TRUE, GL_TRUE};
    glGetQueryObjectuivEXT(query[0], GL_QUERY_RESULT_EXT,
                           &result[0]);  
    glGetQueryObjectuivEXT(query[1], GL_QUERY_RESULT_EXT,
                           &result[1]);  
    EXPECT_GL_NO_ERROR();
    glDeleteQueriesEXT(2, query);
    EXPECT_GL_FALSE(result[0]);
    EXPECT_GL_TRUE(result[1]);
}
TEST_P ( OcclusionQueriesTest , ClearNotCounted ) { ANGLE_SKIP_TEST_IF ( getClientMajorVersion ( ) < 3 && ! IsGLExtensionEnabled ( " " ) ) ; ANGLE_SKIP_TEST_IF ( IsWindows ( ) && IsAMD ( ) && IsVulkan ( ) ) ; ANGLE_SKIP_TEST_IF ( IsD3D11 ( ) ) ; glDepthMask ( GL_TRUE ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; EXPECT_GL_NO_ERROR ( ) ; GLuint query [ 2 ] = { 0 } ; glGenQueriesEXT ( 2 , query ) ; glBeginQueryEXT ( GL_ANY_SAMPLES_PASSED_EXT , query [ 0 ] ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glViewport ( 0 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) ) ; glScissor ( 0 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) ) ; glEnable ( GL_SCISSOR_TEST ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glEndQueryEXT ( GL_ANY_SAMPLES_PASSED_EXT ) ; EXPECT_GL_NO_ERROR ( ) ; glBeginQueryEXT ( GL_ANY_SAMPLES_PASSED_EXT , query [ 1 ] ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; glViewport ( 0 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) ) ; glScissor ( 0 , 0 , getWindowWidth ( ) / 2 , getWindowHeight ( ) ) ; glEnable ( GL_SCISSOR_TEST ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; drawQuad ( mProgram , essl1_shaders :: PositionAttrib ( ) , 0.8f , 0.5f ) ; glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ) ; drawQuad ( mProgram , essl1_shaders :: PositionAttrib ( ) , 0.8f , 1.0 ) ; glEndQueryEXT ( GL_ANY_SAMPLES_PASSED_EXT ) ; EXPECT_GL_NO_ERROR ( ) ; swapBuffers ( ) ; GLuint result [ 2 ] = { GL_TRUE , GL_TRUE } ; glGetQueryObjectuivEXT ( query [ 0 ] , GL_QUERY_RESULT_EXT , & result [ 0 ] ) ; glGetQueryObjectuivEXT ( query [ 1 ] , GL_QUERY_RESULT_EXT , & result [ 1 ] ) ; EXPECT_GL_NO_ERROR ( ) ; glDeleteQueriesEXT ( 2 , query ) ; EXPECT_GL_FALSE ( result [ 0 ] ) ; EXPECT_GL_TRUE ( result [ 1 ] ) ; }
Test that glClear should not be counted by occlusion query.
Test that glClear should not be counted by occlusion query .
// TODO(syoussefi): Using render pass ops to clear the framebuffer attachment results in // AMD/Windows misbehaving in this test.  http://anglebug.com/3286 // http://anglebug.com/4925 // First query // Full screen clear // View port clear // Second query // View port clear // View port clear // this quad should not be occluded // Clear again // this quad should not be occluded // will block waiting for result // will block waiting for result