GFXFence::FenceStatus GFXGLAppleFence::getStatus() const { if(!mIssued) return GFXFence::Unset; GLboolean res = glTestFenceAPPLE(mHandle); return res ? GFXFence::Processed : GFXFence::Pending; }
static void opengl_fence(int command) { #ifdef USE_GLES #else if (command == FENCE_SET) { if (g_has_nv_fence) { //printf("...\n"); glSetFenceNV(g_fence, GL_ALL_COMPLETED_NV); CHECK_GL_ERROR_MSG("glSetFenceNV(g_fence, GL_ALL_COMPLETED_NV)"); } else if (g_has_apple_fence) { glSetFenceAPPLE(g_fence); CHECK_GL_ERROR_MSG("glSetFenceAPPLE(g_fence)"); } else if (g_has_arb_sync) { g_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); CHECK_GL_ERROR_MSG("glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)"); } } else if (command == FENCE_WAIT) { if (g_has_nv_fence) { //printf("-- f --\n"); //glFinishFenceNV(g_fence); //int64_t t1 = fs_get_monotonic_time(); //fs_ml_usleep(10000); while (!glTestFenceNV(g_fence)) { CHECK_GL_ERROR_MSG("glTestFenceNV(g_fence)"); //printf("-> %lld\n", fs_get_monotonic_time() - t1); //printf("%d\n", glGetError()); fs_ml_usleep(1000); //printf("-> %lld\n", fs_get_monotonic_time() - t1); } CHECK_GL_ERROR_MSG("glTestFenceNV(g_fence)"); } else if (g_has_apple_fence) { while (!glTestFenceAPPLE(g_fence)) { CHECK_GL_ERROR_MSG("glTestFenceAPPLE(g_fence)"); fs_ml_usleep(1000); } CHECK_GL_ERROR_MSG("glTestFenceAPPLE(g_fence)"); } else if (g_has_arb_sync) { int flags = GL_SYNC_FLUSH_COMMANDS_BIT; while (glClientWaitSync(g_sync, flags, 0) == GL_TIMEOUT_EXPIRED) { CHECK_GL_ERROR_MSG("glClientWaitSync(g_sync, flags, 0)"); flags = 0; fs_ml_usleep(1000); } CHECK_GL_ERROR_MSG("glClientWaitSync(g_sync, flags, 0)"); } } #endif }
bool CRendererVTB::NeedBuffer(int idx) { YUVBUFFER &buf = m_buffers[idx]; VTB::CVideoBufferVTB *vb = dynamic_cast<VTB::CVideoBufferVTB*>(buf.videoBuffer); if (!vb) { return false; } if (vb->m_fence && glIsFenceAPPLE(vb->m_fence)) { if (!glTestFenceAPPLE(vb->m_fence)) return true; } return false; }
static enum wined3d_event_query_result wined3d_event_query_test(const struct wined3d_event_query *query, const struct wined3d_device *device) { struct wined3d_context *context; const struct wined3d_gl_info *gl_info; enum wined3d_event_query_result ret; BOOL fence_result; TRACE("(%p) : device %p\n", query, device); if (!query->context) { TRACE("Query not started\n"); return WINED3D_EVENT_QUERY_NOT_STARTED; } if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId()) { WARN("Event query tested from wrong thread\n"); return WINED3D_EVENT_QUERY_WRONG_THREAD; } context = context_acquire(device, query->context->current_rt); gl_info = context->gl_info; if (gl_info->supported[ARB_SYNC]) { GLenum gl_ret = GL_EXTCALL(glClientWaitSync(query->object.sync, 0, 0)); checkGLcall("glClientWaitSync"); switch (gl_ret) { case GL_ALREADY_SIGNALED: case GL_CONDITION_SATISFIED: ret = WINED3D_EVENT_QUERY_OK; break; case GL_TIMEOUT_EXPIRED: ret = WINED3D_EVENT_QUERY_WAITING; break; case GL_WAIT_FAILED: default: ERR("glClientWaitSync returned %#x.\n", gl_ret); ret = WINED3D_EVENT_QUERY_ERROR; } } else if (gl_info->supported[APPLE_FENCE]) { fence_result = GL_EXTCALL(glTestFenceAPPLE(query->object.id)); checkGLcall("glTestFenceAPPLE"); if (fence_result) ret = WINED3D_EVENT_QUERY_OK; else ret = WINED3D_EVENT_QUERY_WAITING; } else if (gl_info->supported[NV_FENCE]) { fence_result = GL_EXTCALL(glTestFenceNV(query->object.id)); checkGLcall("glTestFenceNV"); if (fence_result) ret = WINED3D_EVENT_QUERY_OK; else ret = WINED3D_EVENT_QUERY_WAITING; } else { ERR("Event query created despite lack of GL support\n"); ret = WINED3D_EVENT_QUERY_ERROR; } context_release(context); return ret; }
bool CGLMQuery::IsDone( void ) { m_ctx->MakeCurrent(); Assert(m_started); Assert(m_stopped); if(!m_done) // you can ask more than once, but we only check until it comes back as done. { // on occlusion: glGetQueryObjectivARB - large cost on pre SLGU, cheap after // on fence: glTestFenceAPPLE on the fence switch(m_params.m_type) { case EOcclusion: // just test the fence that was set after the query begin { if (m_nullQuery) { // do almost nothing.. but claim work is complete m_done = true; } else { // prepare to pay a big price on drivers prior to 10.6.4+SLGU GLint available = 0; glGetQueryObjectivARB(m_name, GL_QUERY_RESULT_AVAILABLE_ARB, &available ); GLenum errorcode = GetQueryError(); if (errorcode) { const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); printf( "\nCGLMQuery::IsDone saw %s error (%d) from glGetQueryObjectivARB(a2) name=%d", decodedStr, errorcode, m_name ); } m_done = (available != 0); } } break; case EFence: { m_done = glTestFenceAPPLE( m_name ); GLenum errorcode = GetQueryError(); if (errorcode) { const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); printf( "\nCGLMQuery::IsDone saw %s error (%d) from glTestFenceAPPLE(b) name=%d", decodedStr, errorcode, m_name ); } if (m_done) { glFinishFenceAPPLE( m_name ); // no set fence goes un-finished errorcode = GetQueryError(); if (errorcode) { const char *decodedStr = GLMDecode( eGL_ERROR, errorcode ); printf( "\nCGLMQuery::IsDone saw %s error (%d) from glFinishFenceAPPLE(b) name=%d", decodedStr, errorcode, m_name ); } } } break; } } return m_done; }