EGL_KHR_fence_sync

Supported Hardware

Series5, Series5XT, Series6, Series6XE, Series6XT

Valid APIs

EGL 1.1, 1.2, 1.3, 1.4

Description

This extension introduces sync objects to EGL and provides application developers with a mechanism of notifying the CPU when a GPU operation has completed. Fence sync objects are inserted into the GL command stream immediately after the call which the user wants to be notified about or wait on. Any thread can then make a call to eglClientWaitSync() to wait for the GPU to finish what it's doing, with a user specified timeout. A timeout of 0 equates to simply querying whether it's complete yet, similar to how queries work in later versions of OpenGL ES. A common use case for this is to be loading resources on one thread and informing the CPU when it can start submitting calls on another thread that can actually draw with them. The benefits of such multi-threaded rendering can allow developers to create games with seamless loading. To actually interact with client APIs such as OpenGL ES, the client API needs to have an extension that specifies it will be inserted into the same command stream. For OpenGL ES this is GL_OES_EGL_sync.

Note

This functionality is core to EGL 1.5, so the extension is no longer needed.

Registry Link

http://www.khronos.org/registry/gles/extensions/OES/EGL_KHR_fence_sync.txt

Example

// Create a fence sync object - there are no valid attributes that can be passed in so pass  
// NULL or an attribute list containing only EGL_NONE. 
EGLSyncKHR eglFenceSync = eglCreateSyncKHR(eglDisplay, EGL_SYNC_FENCE_KHR, NULL); 
/* 
    Wait for the sync object, flushing the context so it definitely completes in finite time. 
    This call will wait forever until the context finishes what it's doing. 
    This also works as a more flexible and guaranteed version of glFlush/glFinish, as you can  
    specify a timeout. 
*/ 
EGLint waitResult = eglClientWaitSyncKHR(eglDisplay, eglFenceSync, EGL_SYNCH_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR); 
// Destroy the fence sync object once we're done with it. 
EGLBoolean success = eglDestroySyncKHR(eglDisplay, eglFenceSync);