102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_wait_sync 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_wait_sync 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Jon Leech 1202f4aeb0Sopenharmony_ci Tom Cooksey 1302f4aeb0Sopenharmony_ci Alon Or-bach 1402f4aeb0Sopenharmony_ci 1502f4aeb0Sopenharmony_ciContacts 1602f4aeb0Sopenharmony_ci 1702f4aeb0Sopenharmony_ci Jon Leech (jon 'at' alumni.caltech.edu) 1802f4aeb0Sopenharmony_ci 1902f4aeb0Sopenharmony_ciNotice 2002f4aeb0Sopenharmony_ci 2102f4aeb0Sopenharmony_ci Copyright (c) 2012-2014 The Khronos Group Inc. Copyright terms at 2202f4aeb0Sopenharmony_ci http://www.khronos.org/registry/speccopyright.html 2302f4aeb0Sopenharmony_ci 2402f4aeb0Sopenharmony_ciStatus 2502f4aeb0Sopenharmony_ci 2602f4aeb0Sopenharmony_ci Complete. 2702f4aeb0Sopenharmony_ci Approved by the Khronos Board of Promoters on October 26, 2012. 2802f4aeb0Sopenharmony_ci 2902f4aeb0Sopenharmony_ciVersion 3002f4aeb0Sopenharmony_ci 3102f4aeb0Sopenharmony_ci Version 7, March 12, 2014 3202f4aeb0Sopenharmony_ci 3302f4aeb0Sopenharmony_ciNumber 3402f4aeb0Sopenharmony_ci 3502f4aeb0Sopenharmony_ci EGL Extension #43 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ciDependencies 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ci EGL 1.1 is required. 4002f4aeb0Sopenharmony_ci 4102f4aeb0Sopenharmony_ci EGL_KHR_fence_sync is required. 4202f4aeb0Sopenharmony_ci 4302f4aeb0Sopenharmony_ci EGL_KHR_reusable_sync is affected by this extension. 4402f4aeb0Sopenharmony_ci 4502f4aeb0Sopenharmony_ci This extension is written against the wording of the EGL 1.4 4602f4aeb0Sopenharmony_ci Specification. 4702f4aeb0Sopenharmony_ci 4802f4aeb0Sopenharmony_ciOverview 4902f4aeb0Sopenharmony_ci 5002f4aeb0Sopenharmony_ci This extension adds the ability to wait for signaling of sync objects 5102f4aeb0Sopenharmony_ci in the server for a client API context, rather than in the application 5202f4aeb0Sopenharmony_ci thread bound to that context. This form of wait does not necessarily 5302f4aeb0Sopenharmony_ci block the application thread which issued the wait (unlike 5402f4aeb0Sopenharmony_ci eglClientWaitSyncKHR), so the application may continue to issue commands 5502f4aeb0Sopenharmony_ci to the client API context or perform other work in parallel, leading to 5602f4aeb0Sopenharmony_ci increased performance. The best performance is likely to be achieved by 5702f4aeb0Sopenharmony_ci implementations which can perform this new wait operation in GPU 5802f4aeb0Sopenharmony_ci hardware, although this is not required. 5902f4aeb0Sopenharmony_ci 6002f4aeb0Sopenharmony_ciNew Types 6102f4aeb0Sopenharmony_ci 6202f4aeb0Sopenharmony_ci None 6302f4aeb0Sopenharmony_ci 6402f4aeb0Sopenharmony_ciNew Procedures and Functions 6502f4aeb0Sopenharmony_ci 6602f4aeb0Sopenharmony_ci EGLint eglWaitSyncKHR( 6702f4aeb0Sopenharmony_ci EGLDisplay dpy, 6802f4aeb0Sopenharmony_ci EGLSyncKHR sync, 6902f4aeb0Sopenharmony_ci EGLint flags) 7002f4aeb0Sopenharmony_ci 7102f4aeb0Sopenharmony_ciNew Tokens 7202f4aeb0Sopenharmony_ci 7302f4aeb0Sopenharmony_ci None 7402f4aeb0Sopenharmony_ci 7502f4aeb0Sopenharmony_ciChanges to Chapter 3 of the EGL 1.4 Specification (EGL Functions and Errors) 7602f4aeb0Sopenharmony_ci 7702f4aeb0Sopenharmony_ci Add to section 3.8.1 "Sync Objects" (as already modified 7802f4aeb0Sopenharmony_ci by EGL_KHR_fence_sync and/or EGL_KHR_reusable_sync): 7902f4aeb0Sopenharmony_ci 8002f4aeb0Sopenharmony_ci Following the description of eglClientWaitSyncKHR, add: 8102f4aeb0Sopenharmony_ci 8202f4aeb0Sopenharmony_ci "The command 8302f4aeb0Sopenharmony_ci 8402f4aeb0Sopenharmony_ci EGLint eglWaitSyncKHR(EGLDisplay dpy, 8502f4aeb0Sopenharmony_ci EGLSyncKHR sync, 8602f4aeb0Sopenharmony_ci EGLint flags) 8702f4aeb0Sopenharmony_ci 8802f4aeb0Sopenharmony_ci is similar to eglClientWaitSyncKHR, but instead of blocking and not 8902f4aeb0Sopenharmony_ci returning to the application until <sync> is signaled, eglWaitSyncKHR 9002f4aeb0Sopenharmony_ci returns immediately. On success, EGL_TRUE is returned, and the server 9102f4aeb0Sopenharmony_ci for the client API context [fn1] will block until <sync> is signaled 9202f4aeb0Sopenharmony_ci [fn2]. 9302f4aeb0Sopenharmony_ci [fn1 - the server may choose to wait either in the CPU executing 9402f4aeb0Sopenharmony_ci server-side code, or in the GPU hardware if it supports this 9502f4aeb0Sopenharmony_ci operation.] 9602f4aeb0Sopenharmony_ci [fn2 - eglWaitSyncKHR allows applications to continue to queue 9702f4aeb0Sopenharmony_ci commands from the application in anticipation of the sync being 9802f4aeb0Sopenharmony_ci signaled, potentially increasing parallelism between application, 9902f4aeb0Sopenharmony_ci client API server code, and the GPU. The server only blocks 10002f4aeb0Sopenharmony_ci execution of commands for the specific context on which 10102f4aeb0Sopenharmony_ci eglWaitSyncKHR was issued; other contexts implemented by the same 10202f4aeb0Sopenharmony_ci server are not affected.] 10302f4aeb0Sopenharmony_ci 10402f4aeb0Sopenharmony_ci <sync> has the same meaning as for eglClientWaitSyncKHR. 10502f4aeb0Sopenharmony_ci 10602f4aeb0Sopenharmony_ci <flags> must be 0. 10702f4aeb0Sopenharmony_ci 10802f4aeb0Sopenharmony_ci Errors 10902f4aeb0Sopenharmony_ci ------ 11002f4aeb0Sopenharmony_ci eglWaitSyncKHR returns EGL_FALSE on failure and generates an error as 11102f4aeb0Sopenharmony_ci specified below, but does not cause the server for the client API 11202f4aeb0Sopenharmony_ci context to block. 11302f4aeb0Sopenharmony_ci 11402f4aeb0Sopenharmony_ci * If the current context for the currently bound client API does not 11502f4aeb0Sopenharmony_ci support the client API extension indicating it can perform server 11602f4aeb0Sopenharmony_ci waits, an EGL_BAD_MATCH error is generated. 11702f4aeb0Sopenharmony_ci * If no context is current for the currently bound client API (i.e., 11802f4aeb0Sopenharmony_ci eglGetCurrentContext returns EGL_NO_CONTEXT), an EGL_BAD_MATCH error 11902f4aeb0Sopenharmony_ci is generated. 12002f4aeb0Sopenharmony_ci * If <dpy> does not match the EGLDisplay passed to eglCreateSyncKHR 12102f4aeb0Sopenharmony_ci when <sync> was created, the behavior is undefined. 12202f4aeb0Sopenharmony_ci * If <sync> is not a valid sync object for <dpy>, an EGL_BAD_PARAMETER 12302f4aeb0Sopenharmony_ci error is generated. 12402f4aeb0Sopenharmony_ci * If <flags> is not 0, an EGL_BAD_PARAMETER error is generated. 12502f4aeb0Sopenharmony_ci 12602f4aeb0Sopenharmony_ci Each client API which supports eglWaitSyncKHR indicates this support in 12702f4aeb0Sopenharmony_ci the form of a client API extension. If the GL_OES_EGL_sync extension is 12802f4aeb0Sopenharmony_ci supported by any version of OpenGL ES, a server wait may be performed 12902f4aeb0Sopenharmony_ci when the currently bound API is OpenGL ES. If the VG_KHR_EGL_sync 13002f4aeb0Sopenharmony_ci extension is supported by OpenVG, a server wait may be performed when 13102f4aeb0Sopenharmony_ci the currently bound API is OpenVG." 13202f4aeb0Sopenharmony_ci 13302f4aeb0Sopenharmony_ci Add new subsubsection following eglWaitSyncKHR: 13402f4aeb0Sopenharmony_ci 13502f4aeb0Sopenharmony_ci "Multiple Waiters 13602f4aeb0Sopenharmony_ci ---------------- 13702f4aeb0Sopenharmony_ci 13802f4aeb0Sopenharmony_ci It is possible for the application thread calling a client API to be 13902f4aeb0Sopenharmony_ci blocked on a sync object in a eglClientWaitSyncKHR command, the server 14002f4aeb0Sopenharmony_ci for that client API context to be blocked as the result of a previous 14102f4aeb0Sopenharmony_ci eglWaitSyncKHR command, and for additional eglWaitSyncKHR commands to be 14202f4aeb0Sopenharmony_ci queued in the server, all for a single sync object. When the sync object 14302f4aeb0Sopenharmony_ci is signaled in this situation, the client will be unblocked, the server 14402f4aeb0Sopenharmony_ci will be unblocked, and all such queued eglWaitSyncKHR commands will 14502f4aeb0Sopenharmony_ci continue immediately when they are reached. 14602f4aeb0Sopenharmony_ci 14702f4aeb0Sopenharmony_ci Sync objects may be waited on or signaled from multiple contexts of 14802f4aeb0Sopenharmony_ci different client API types in multiple threads simultaneously, although 14902f4aeb0Sopenharmony_ci some client APIs may not support eglWaitSyncKHR. This support is 15002f4aeb0Sopenharmony_ci determined by client API-specific extensions." 15102f4aeb0Sopenharmony_ci 15202f4aeb0Sopenharmony_ci Additions to the EGL_KHR_reusable_sync extension, modifying the description 15302f4aeb0Sopenharmony_ci of eglSignalSyncKHR to include both client and server syncs: 15402f4aeb0Sopenharmony_ci 15502f4aeb0Sopenharmony_ci "... If as a result of calling eglSignalSyncKHR the status of <sync> 15602f4aeb0Sopenharmony_ci transitions from unsignaled to signaled, any eglClientWaitSyncKHR 15702f4aeb0Sopenharmony_ci * or eglWaitSyncKHR * 15802f4aeb0Sopenharmony_ci commands blocking on <sync> will unblock. ..." 15902f4aeb0Sopenharmony_ci 16002f4aeb0Sopenharmony_ci Additions to the EGL_KHR_reusable_sync extension, modifying the description 16102f4aeb0Sopenharmony_ci of eglDestroySyncKHR to include both client and server syncs: 16202f4aeb0Sopenharmony_ci 16302f4aeb0Sopenharmony_ci "... If any eglClientWaitSyncKHR 16402f4aeb0Sopenharmony_ci * or eglWaitSyncKHR * 16502f4aeb0Sopenharmony_ci commands are blocking on <sync> when eglDestroySyncKHR is called, they 16602f4aeb0Sopenharmony_ci will be woken up, as if <sync> were signaled." 16702f4aeb0Sopenharmony_ci 16802f4aeb0Sopenharmony_ci 16902f4aeb0Sopenharmony_ci Additions to the EGL_KHR_fence_sync extension, modifying the description 17002f4aeb0Sopenharmony_ci of eglCreateSyncKHR to include both client and server syncs: 17102f4aeb0Sopenharmony_ci 17202f4aeb0Sopenharmony_ci "... causing any eglClientWaitSyncKHR 17302f4aeb0Sopenharmony_ci * or eglWaitSyncKHR * 17402f4aeb0Sopenharmony_ci commands (see below) blocking on <sync> to unblock ..." 17502f4aeb0Sopenharmony_ci 17602f4aeb0Sopenharmony_ci Additions to the EGL_KHR_fence_sync extension, modifying the description 17702f4aeb0Sopenharmony_ci of eglDestroySyncKHR to include both client and server syncs: 17802f4aeb0Sopenharmony_ci 17902f4aeb0Sopenharmony_ci "... If any eglClientWaitSyncKHR 18002f4aeb0Sopenharmony_ci * or eglWaitSyncKHR * 18102f4aeb0Sopenharmony_ci commands are blocking on <sync> when eglDestroySyncKHR is called, <sync> 18202f4aeb0Sopenharmony_ci is flagged for deletion and will be deleted when it is no longer 18302f4aeb0Sopenharmony_ci associated with any fence command and is no longer blocking any 18402f4aeb0Sopenharmony_ci eglClientWaitSyncKHR or eglWaitSyncKHR commands." 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci 18702f4aeb0Sopenharmony_ciIssues 18802f4aeb0Sopenharmony_ci 18902f4aeb0Sopenharmony_ci 1. Explain the key choices made in this extension. 19002f4aeb0Sopenharmony_ci 19102f4aeb0Sopenharmony_ci RESPONSE: This extension has been written to behave as similarly as 19202f4aeb0Sopenharmony_ci possible to the glWaitSync functionality available in desktop OpenGL. 19302f4aeb0Sopenharmony_ci Server waits are functionality which was only available in GL syncs 19402f4aeb0Sopenharmony_ci until now. 19502f4aeb0Sopenharmony_ci 19602f4aeb0Sopenharmony_ci In the interest of maintaining similarity with OpenGL sync objects, this 19702f4aeb0Sopenharmony_ci extension attempts to copy the glWaitSync functionality of OpenGL 19802f4aeb0Sopenharmony_ci wherever possible (both functionally and stylistically), only making 19902f4aeb0Sopenharmony_ci changes where needed to operate inside EGL (rather than a client API 20002f4aeb0Sopenharmony_ci context) and match EGL naming conventions. 20102f4aeb0Sopenharmony_ci 20202f4aeb0Sopenharmony_ci 2. Must all EGL client APIs support server waits? 20302f4aeb0Sopenharmony_ci 20402f4aeb0Sopenharmony_ci PROPOSED: Only if the client APIs also support fence syncs, which also 20502f4aeb0Sopenharmony_ci interacts with the server for that client API. The same client API 20602f4aeb0Sopenharmony_ci extensions defining fence sync support (GL_OES_EGL_sync and 20702f4aeb0Sopenharmony_ci VG_KHR_EGL_sync) are used here to indicate server wait ability for those 20802f4aeb0Sopenharmony_ci client APIs. 20902f4aeb0Sopenharmony_ci 21002f4aeb0Sopenharmony_ci Reusable syncs in EGL_KHR_reusable_sync do not have this dependency, 21102f4aeb0Sopenharmony_ci because it is (at least in principle) possible for eglClientWaitSyncKHR 21202f4aeb0Sopenharmony_ci to be performed entirely within the EGL implementation. However, 21302f4aeb0Sopenharmony_ci eglWaitSyncKHR requires cooperation of the client API, whether fence 21402f4aeb0Sopenharmony_ci syncs or reusable syncs are being waited upon. 21502f4aeb0Sopenharmony_ci 21602f4aeb0Sopenharmony_ci It would be possible to completely decouple fence syncs and the ability 21702f4aeb0Sopenharmony_ci to do server waits, but this would require new client API extensions. 21802f4aeb0Sopenharmony_ci 21902f4aeb0Sopenharmony_ci 3. What is the relationship between EGL sync objects and OpenGL / OpenGL 22002f4aeb0Sopenharmony_ci ES sync objects? 22102f4aeb0Sopenharmony_ci 22202f4aeb0Sopenharmony_ci RESPONSE: There is no direct relationship. GL and ES servers may not 22302f4aeb0Sopenharmony_ci even implement sync objects as defined by some versions of those APIs. 22402f4aeb0Sopenharmony_ci However, EGL sync objects are intended to be functionally equivalent to 22502f4aeb0Sopenharmony_ci GL sync objects, and the language describing them is drawn from the GL 22602f4aeb0Sopenharmony_ci specifications. Implementations supporting both forms of sync object 22702f4aeb0Sopenharmony_ci will probably use the same implementation internally. 22802f4aeb0Sopenharmony_ci 22902f4aeb0Sopenharmony_ci 4. Should eglWaitSyncKHR take a timeout as a parameter as its equivalent 23002f4aeb0Sopenharmony_ci in OpenGL / OpenGL ES and eglWaitClientKHR does? 23102f4aeb0Sopenharmony_ci 23202f4aeb0Sopenharmony_ci PROPOSED: No. A timeout is of limited use to a well-behaved application. 23302f4aeb0Sopenharmony_ci If a timeout was added, the result of it expiring is likely to be a 23402f4aeb0Sopenharmony_ci corrupted output. Adding a timeout would likely necessitate a way to 23502f4aeb0Sopenharmony_ci query if the wait completed because the condition was signaled or 23602f4aeb0Sopenharmony_ci because of a timeout. There doesn't seem to be an obvious, elegant API 23702f4aeb0Sopenharmony_ci mechanism to do that. If a timeout is needed in the future, it can be 23802f4aeb0Sopenharmony_ci added via an additional extension with a new entry-point. 23902f4aeb0Sopenharmony_ci 24002f4aeb0Sopenharmony_ci 5. What happens if an application issues a server-side wait on a fence 24102f4aeb0Sopenharmony_ci which never gets signaled? 24202f4aeb0Sopenharmony_ci 24302f4aeb0Sopenharmony_ci RESPONSE: Further rendering in the context which issued the server-side 24402f4aeb0Sopenharmony_ci wait will not progress. Any additional behavior is undefined and is 24502f4aeb0Sopenharmony_ci likely to be different depending on a particular implementation. Could 24602f4aeb0Sopenharmony_ci be handled in the same way as an extremely long-running GLSL shader. 24702f4aeb0Sopenharmony_ci 24802f4aeb0Sopenharmony_ci 6. Does this extension affect the destruction behavior? 24902f4aeb0Sopenharmony_ci 25002f4aeb0Sopenharmony_ci RESOLVED: No. The behavior of eglDestroySyncKHR is determined by the type 25102f4aeb0Sopenharmony_ci of sync object, and is not affected by this extension. 25202f4aeb0Sopenharmony_ci 25302f4aeb0Sopenharmony_ciRevision History 25402f4aeb0Sopenharmony_ci 25502f4aeb0Sopenharmony_ci#7 (Alon Or-bach, March 12, 2014) 25602f4aeb0Sopenharmony_ci - Clarified that eglDestroySyncKHR behavior is set in 25702f4aeb0Sopenharmony_ci EGL_KHR_fence_sync / EGL_KHR_reusable_sync and is not modified by this 25802f4aeb0Sopenharmony_ci extension (bug 11458). 25902f4aeb0Sopenharmony_ci#6 (Jon Leech, January 24, 2013) 26002f4aeb0Sopenharmony_ci - eglWaitSyncKHR causes a server wait in OpenGL ES when GL_OES_EGL_sync 26102f4aeb0Sopenharmony_ci is supported, not a client wait as formerly specified (Bug 9493). 26202f4aeb0Sopenharmony_ci#5 (Jon Leech, October 31, 2012) 26302f4aeb0Sopenharmony_ci - Change return type of eglWaitSyncKHR in spec body to EGLint to match 26402f4aeb0Sopenharmony_ci New Functions section, and rearrange description of return type and 26502f4aeb0Sopenharmony_ci errors section for clarity. 26602f4aeb0Sopenharmony_ci#4 (Tom Cooksey, August 16, 2012) 26702f4aeb0Sopenharmony_ci - Removed timeout parameter and text relating to it. Add issue 4 26802f4aeb0Sopenharmony_ci discussing timeout parameter. Add issue 5 explaining the behavior of 26902f4aeb0Sopenharmony_ci waiting on a never-signaled fence. Minor corrections to use US English. 27002f4aeb0Sopenharmony_ci#3 (Jon Leech, June 26, 2012) 27102f4aeb0Sopenharmony_ci - Fix typos (bug 9137). 27202f4aeb0Sopenharmony_ci#2 (Jon Leech, June 20, 2012) 27302f4aeb0Sopenharmony_ci - Clarifications and language cleanup (Bug 9137). Some paragraph 27402f4aeb0Sopenharmony_ci reflowing. Note that eglWaitSyncKHR only blocks the server for the 27502f4aeb0Sopenharmony_ci specific context on which the wait was issued. Add issue 3 discussing 27602f4aeb0Sopenharmony_ci relationship to GL/ES sync objects. 27702f4aeb0Sopenharmony_ci#1 (Jon Leech, June 6, 2012) 27802f4aeb0Sopenharmony_ci - Initial draft branched from GL 4.x API spec language. 279