102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_reusable_sync 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_reusable_sync 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Acorn Pooley 1202f4aeb0Sopenharmony_ci Gary King 1302f4aeb0Sopenharmony_ci Gregory Prisament 1402f4aeb0Sopenharmony_ci Jon Leech 1502f4aeb0Sopenharmony_ci Robert Palmer 1602f4aeb0Sopenharmony_ci 1702f4aeb0Sopenharmony_ciContacts 1802f4aeb0Sopenharmony_ci 1902f4aeb0Sopenharmony_ci Acorn Pooley, NVIDIA Corporation (apooley 'at' nvidia.com) 2002f4aeb0Sopenharmony_ci Gary King, NVIDIA Corporation (gking 'at' nvidia.com) 2102f4aeb0Sopenharmony_ci Gregory Prisament, NVIDIA Corporation (gprisament 'at' nvidia.com) 2202f4aeb0Sopenharmony_ci Jon Leech (jon 'at' alumni.caltech.edu) 2302f4aeb0Sopenharmony_ci Robert Palmer (robert.palmer 'at' nokia.com) 2402f4aeb0Sopenharmony_ci 2502f4aeb0Sopenharmony_ciNotice 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ci Copyright (c) 2006-2013 The Khronos Group Inc. Copyright terms at 2802f4aeb0Sopenharmony_ci http://www.khronos.org/registry/speccopyright.html 2902f4aeb0Sopenharmony_ci 3002f4aeb0Sopenharmony_ciStatus 3102f4aeb0Sopenharmony_ci 3202f4aeb0Sopenharmony_ci Complete. 3302f4aeb0Sopenharmony_ci Approved by the Khronos Board of Promoters on August 28, 2009. 3402f4aeb0Sopenharmony_ci 3502f4aeb0Sopenharmony_ciVersion 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ci Version 22, January 31, 2014 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ciNumber 4002f4aeb0Sopenharmony_ci 4102f4aeb0Sopenharmony_ci EGL Extension #6 4202f4aeb0Sopenharmony_ci 4302f4aeb0Sopenharmony_ciDependencies 4402f4aeb0Sopenharmony_ci 4502f4aeb0Sopenharmony_ci Requires EGL 1.1 4602f4aeb0Sopenharmony_ci 4702f4aeb0Sopenharmony_ci This extension is written against the wording of the EGL 1.2 4802f4aeb0Sopenharmony_ci Specification. 4902f4aeb0Sopenharmony_ci 5002f4aeb0Sopenharmony_ciOverview 5102f4aeb0Sopenharmony_ci 5202f4aeb0Sopenharmony_ci This extension introduces the concept of "sync objects" into EGL. 5302f4aeb0Sopenharmony_ci Sync objects are a synchronization primitive, representing events 5402f4aeb0Sopenharmony_ci whose completion can be tested or waited upon. This extension 5502f4aeb0Sopenharmony_ci borrows from the GL_ARB_sync extension but introduces a type of sync 5602f4aeb0Sopenharmony_ci object known as "reusable sync object" comparable to an OS 5702f4aeb0Sopenharmony_ci semaphore. The specification is designed to allow additional types of 5802f4aeb0Sopenharmony_ci sync objects to be easily introduced in later extensions. 5902f4aeb0Sopenharmony_ci 6002f4aeb0Sopenharmony_ci Reusable sync objects may be used to synchronize activity between 6102f4aeb0Sopenharmony_ci threads or between client APIs. Synchronization is accomplished by 6202f4aeb0Sopenharmony_ci explicitly changing the status of a reusable object using EGL API 6302f4aeb0Sopenharmony_ci commands. 6402f4aeb0Sopenharmony_ci 6502f4aeb0Sopenharmony_ciNew Types 6602f4aeb0Sopenharmony_ci 6702f4aeb0Sopenharmony_ci /* 6802f4aeb0Sopenharmony_ci * EGLSyncKHR is an opaque handle to an EGL sync object 6902f4aeb0Sopenharmony_ci */ 7002f4aeb0Sopenharmony_ci typedef void* EGLSyncKHR; 7102f4aeb0Sopenharmony_ci 7202f4aeb0Sopenharmony_ci /* 7302f4aeb0Sopenharmony_ci * EGLTimeKHR is a 64-bit unsigned integer representing intervals 7402f4aeb0Sopenharmony_ci * in nanoseconds. 7502f4aeb0Sopenharmony_ci */ 7602f4aeb0Sopenharmony_ci #include <khrplatform.h> 7702f4aeb0Sopenharmony_ci typedef khronos_utime_nanoseconds_t EGLTimeKHR; 7802f4aeb0Sopenharmony_ci 7902f4aeb0Sopenharmony_ci 8002f4aeb0Sopenharmony_ciNew Procedures and Functions 8102f4aeb0Sopenharmony_ci 8202f4aeb0Sopenharmony_ci EGLSyncKHR eglCreateSyncKHR( 8302f4aeb0Sopenharmony_ci EGLDisplay dpy, 8402f4aeb0Sopenharmony_ci EGLenum type, 8502f4aeb0Sopenharmony_ci const EGLint *attrib_list); 8602f4aeb0Sopenharmony_ci 8702f4aeb0Sopenharmony_ci EGLBoolean eglDestroySyncKHR( 8802f4aeb0Sopenharmony_ci EGLDisplay dpy, 8902f4aeb0Sopenharmony_ci EGLSyncKHR sync); 9002f4aeb0Sopenharmony_ci 9102f4aeb0Sopenharmony_ci EGLint eglClientWaitSyncKHR( 9202f4aeb0Sopenharmony_ci EGLDisplay dpy, 9302f4aeb0Sopenharmony_ci EGLSyncKHR sync, 9402f4aeb0Sopenharmony_ci EGLint flags, 9502f4aeb0Sopenharmony_ci EGLTimeKHR timeout); 9602f4aeb0Sopenharmony_ci 9702f4aeb0Sopenharmony_ci EGLBoolean eglSignalSyncKHR( 9802f4aeb0Sopenharmony_ci EGLDisplay dpy, 9902f4aeb0Sopenharmony_ci EGLSyncKHR sync, 10002f4aeb0Sopenharmony_ci EGLenum mode); 10102f4aeb0Sopenharmony_ci 10202f4aeb0Sopenharmony_ci EGLBoolean eglGetSyncAttribKHR( 10302f4aeb0Sopenharmony_ci EGLDisplay dpy, 10402f4aeb0Sopenharmony_ci EGLSyncKHR sync, 10502f4aeb0Sopenharmony_ci EGLint attribute, 10602f4aeb0Sopenharmony_ci EGLint *value); 10702f4aeb0Sopenharmony_ci 10802f4aeb0Sopenharmony_ci 10902f4aeb0Sopenharmony_ciNew Tokens 11002f4aeb0Sopenharmony_ci 11102f4aeb0Sopenharmony_ci Accepted by the <type> parameter of eglCreateSyncKHR, and returned 11202f4aeb0Sopenharmony_ci in <value> when eglGetSyncAttribKHR is called with <attribute> 11302f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR: 11402f4aeb0Sopenharmony_ci 11502f4aeb0Sopenharmony_ci EGL_SYNC_REUSABLE_KHR 0x30FA 11602f4aeb0Sopenharmony_ci 11702f4aeb0Sopenharmony_ci Accepted by the <attribute> parameter of eglGetSyncAttribKHR: 11802f4aeb0Sopenharmony_ci 11902f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR 0x30F7 12002f4aeb0Sopenharmony_ci EGL_SYNC_STATUS_KHR 0x30F1 12102f4aeb0Sopenharmony_ci 12202f4aeb0Sopenharmony_ci Accepted by the <mode> parameter of eglSignalSyncKHR and returned in 12302f4aeb0Sopenharmony_ci <value> when eglGetSyncAttribKHR is called with <attribute> 12402f4aeb0Sopenharmony_ci EGL_SYNC_STATUS_KHR: 12502f4aeb0Sopenharmony_ci 12602f4aeb0Sopenharmony_ci EGL_SIGNALED_KHR 0x30F2 12702f4aeb0Sopenharmony_ci EGL_UNSIGNALED_KHR 0x30F3 12802f4aeb0Sopenharmony_ci 12902f4aeb0Sopenharmony_ci Accepted in the <flags> parameter of eglClientWaitSyncKHR: 13002f4aeb0Sopenharmony_ci 13102f4aeb0Sopenharmony_ci EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 13202f4aeb0Sopenharmony_ci 13302f4aeb0Sopenharmony_ci Accepted in the <timeout> parameter of eglClientWaitSyncKHR: 13402f4aeb0Sopenharmony_ci 13502f4aeb0Sopenharmony_ci EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull 13602f4aeb0Sopenharmony_ci 13702f4aeb0Sopenharmony_ci Returned by eglClientWaitSyncKHR: 13802f4aeb0Sopenharmony_ci 13902f4aeb0Sopenharmony_ci EGL_TIMEOUT_EXPIRED_KHR 0x30F5 14002f4aeb0Sopenharmony_ci EGL_CONDITION_SATISFIED_KHR 0x30F6 14102f4aeb0Sopenharmony_ci 14202f4aeb0Sopenharmony_ci Returned by eglCreateSyncKHR in the event of an error: 14302f4aeb0Sopenharmony_ci 14402f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR ((EGLSyncKHR)0) 14502f4aeb0Sopenharmony_ci 14602f4aeb0Sopenharmony_ciChanges to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors) 14702f4aeb0Sopenharmony_ci 14802f4aeb0Sopenharmony_ci Add a new subsection at the end of Section 3.8, page 43 14902f4aeb0Sopenharmony_ci (Synchronization Primitives) 15002f4aeb0Sopenharmony_ci 15102f4aeb0Sopenharmony_ci "3.8.1 Sync Objects 15202f4aeb0Sopenharmony_ci 15302f4aeb0Sopenharmony_ci In addition to the aforementioned synchronization functions, which 15402f4aeb0Sopenharmony_ci provide an efficient means of serializing client and native API 15502f4aeb0Sopenharmony_ci operations within a thread, <sync objects> are provided to enable 15602f4aeb0Sopenharmony_ci synchronization of client API operations between threads and/or 15702f4aeb0Sopenharmony_ci between API contexts. Sync objects may be tested or waited upon by 15802f4aeb0Sopenharmony_ci application threads. 15902f4aeb0Sopenharmony_ci 16002f4aeb0Sopenharmony_ci Sync objects have a status with two possible states: <signaled> and 16102f4aeb0Sopenharmony_ci <unsignaled>. Initially, sync objects are unsignaled. EGL may be 16202f4aeb0Sopenharmony_ci asked to wait for a sync object to become signaled, or a sync 16302f4aeb0Sopenharmony_ci object's status may be queried. 16402f4aeb0Sopenharmony_ci 16502f4aeb0Sopenharmony_ci Depending on the type of a sync object, its status may be changed 16602f4aeb0Sopenharmony_ci either by an external event, or by explicitly signaling and 16702f4aeb0Sopenharmony_ci unsignaling the sync. 16802f4aeb0Sopenharmony_ci 16902f4aeb0Sopenharmony_ci Sync objects are associated with an EGLDisplay when they are 17002f4aeb0Sopenharmony_ci created, and have <attributes> defining additional aspects of the 17102f4aeb0Sopenharmony_ci sync object. All sync objects include attributes for their type and 17202f4aeb0Sopenharmony_ci their status. Additional attributes are discussed below 17302f4aeb0Sopenharmony_ci for different types of sync objects. 17402f4aeb0Sopenharmony_ci 17502f4aeb0Sopenharmony_ci <Reusable sync objects> are created in the unsignaled state, and may 17602f4aeb0Sopenharmony_ci be signaled and/or unsignaled repeatedly. Every transition of a 17702f4aeb0Sopenharmony_ci reusable sync object's status from unsignaled to signaled will 17802f4aeb0Sopenharmony_ci release any threads waiting on that sync object. 17902f4aeb0Sopenharmony_ci 18002f4aeb0Sopenharmony_ci The command 18102f4aeb0Sopenharmony_ci 18202f4aeb0Sopenharmony_ci EGLSyncKHR eglCreateSyncKHR( 18302f4aeb0Sopenharmony_ci EGLDisplay dpy, 18402f4aeb0Sopenharmony_ci EGLenum type, 18502f4aeb0Sopenharmony_ci const EGLint *attrib_list); 18602f4aeb0Sopenharmony_ci 18702f4aeb0Sopenharmony_ci creates a sync object of the specified <type> associated with the 18802f4aeb0Sopenharmony_ci specified display <dpy>, and returns a handle to the new object. 18902f4aeb0Sopenharmony_ci <attrib_list> is an attribute-value list specifying other attributes 19002f4aeb0Sopenharmony_ci of the sync object, terminated by an attribute entry EGL_NONE. 19102f4aeb0Sopenharmony_ci Attributes not specified in the list will be assigned their default 19202f4aeb0Sopenharmony_ci values. 19302f4aeb0Sopenharmony_ci 19402f4aeb0Sopenharmony_ci If <type> is EGL_SYNC_REUSABLE_KHR, a reusable sync object is 19502f4aeb0Sopenharmony_ci created. In this case <attrib_list> must be NULL or empty 19602f4aeb0Sopenharmony_ci (containing only EGL_NONE). Attributes of the reusable sync object 19702f4aeb0Sopenharmony_ci are set as follows: 19802f4aeb0Sopenharmony_ci 19902f4aeb0Sopenharmony_ci Attribute Name Initial Attribute Value(s) 20002f4aeb0Sopenharmony_ci --------------- -------------------------- 20102f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR EGL_SYNC_REUSABLE_KHR 20202f4aeb0Sopenharmony_ci EGL_SYNC_STATUS_KHR EGL_UNSIGNALED_KHR 20302f4aeb0Sopenharmony_ci 20402f4aeb0Sopenharmony_ci Errors 20502f4aeb0Sopenharmony_ci ------ 20602f4aeb0Sopenharmony_ci 20702f4aeb0Sopenharmony_ci * If <dpy> is not the name of a valid, initialized EGLDisplay, 20802f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is 20902f4aeb0Sopenharmony_ci generated. 21002f4aeb0Sopenharmony_ci * If <attrib_list> is neither NULL nor empty (containing only 21102f4aeb0Sopenharmony_ci EGL_NONE), EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE 21202f4aeb0Sopenharmony_ci error is generated. 21302f4aeb0Sopenharmony_ci * If <type> is not a supported type of sync object, 21402f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is 21502f4aeb0Sopenharmony_ci generated. 21602f4aeb0Sopenharmony_ci 21702f4aeb0Sopenharmony_ci The command 21802f4aeb0Sopenharmony_ci 21902f4aeb0Sopenharmony_ci EGLint eglClientWaitSyncKHR( 22002f4aeb0Sopenharmony_ci EGLDisplay dpy, 22102f4aeb0Sopenharmony_ci EGLSyncKHR sync, 22202f4aeb0Sopenharmony_ci EGLint flags, 22302f4aeb0Sopenharmony_ci EGLTimeKHR timeout); 22402f4aeb0Sopenharmony_ci 22502f4aeb0Sopenharmony_ci blocks the calling thread until the specified sync object <sync> is 22602f4aeb0Sopenharmony_ci signaled, or until <timeout> nanoseconds have passed. 22702f4aeb0Sopenharmony_ci 22802f4aeb0Sopenharmony_ci More than one eglClientWaitSyncKHR may be outstanding on the same 22902f4aeb0Sopenharmony_ci <sync> at any given time. When there are multiple threads blocked on 23002f4aeb0Sopenharmony_ci the same <sync> and the sync object is signaled, all such threads 23102f4aeb0Sopenharmony_ci are released, but the order in which they are released is not 23202f4aeb0Sopenharmony_ci defined. 23302f4aeb0Sopenharmony_ci 23402f4aeb0Sopenharmony_ci If the value of <timeout> is zero, then eglClientWaitSyncKHR simply 23502f4aeb0Sopenharmony_ci tests the current status of <sync>. If the value of <timeout> is the 23602f4aeb0Sopenharmony_ci special value EGL_FOREVER_KHR, then eglClientWaitSyncKHR does not 23702f4aeb0Sopenharmony_ci time out. For all other values, <timeout> is adjusted to the closest 23802f4aeb0Sopenharmony_ci value allowed by the implementation-dependent timeout accuracy, 23902f4aeb0Sopenharmony_ci which may be substantially longer than one nanosecond. 24002f4aeb0Sopenharmony_ci 24102f4aeb0Sopenharmony_ci eglClientWaitSyncKHR returns one of three status values describing 24202f4aeb0Sopenharmony_ci the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR 24302f4aeb0Sopenharmony_ci indicates that the specified timeout period expired before <sync> 24402f4aeb0Sopenharmony_ci was signaled, or if <timeout> is zero, indicates that <sync> is 24502f4aeb0Sopenharmony_ci not signaled. A return value of EGL_CONDITION_SATISFIED_KHR 24602f4aeb0Sopenharmony_ci indicates that <sync> was signaled before the timeout expired, which 24702f4aeb0Sopenharmony_ci includes the case when <sync> was already signaled when 24802f4aeb0Sopenharmony_ci eglClientWaitSyncKHR was called. If an error occurs then an error is 24902f4aeb0Sopenharmony_ci generated and EGL_FALSE is returned. 25002f4aeb0Sopenharmony_ci 25102f4aeb0Sopenharmony_ci If the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR bit is set in 25202f4aeb0Sopenharmony_ci <flags>, and <sync> is unsignaled when eglClientWaitSyncKHR is 25302f4aeb0Sopenharmony_ci called, then the equivalent of Flush() will be performed for the 25402f4aeb0Sopenharmony_ci current API context (i.e., the context returned by 25502f4aeb0Sopenharmony_ci eglGetCurrentContext()) before blocking on <sync>. If no context is 25602f4aeb0Sopenharmony_ci current for the bound API, the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR bit 25702f4aeb0Sopenharmony_ci is ignored. 25802f4aeb0Sopenharmony_ci 25902f4aeb0Sopenharmony_ci If a sync object is destroyed while an eglClientWaitSyncKHR is 26002f4aeb0Sopenharmony_ci blocking on that object, eglClientWaitSyncKHR will unblock and 26102f4aeb0Sopenharmony_ci return immediately, just as if the sync object had been signaled 26202f4aeb0Sopenharmony_ci prior to being destroyed. 26302f4aeb0Sopenharmony_ci 26402f4aeb0Sopenharmony_ci Errors 26502f4aeb0Sopenharmony_ci ------ 26602f4aeb0Sopenharmony_ci 26702f4aeb0Sopenharmony_ci * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is 26802f4aeb0Sopenharmony_ci returned and an EGL_BAD_PARAMETER error is generated. 26902f4aeb0Sopenharmony_ci * If <dpy> does not match the EGLDisplay passed to 27002f4aeb0Sopenharmony_ci eglCreateSyncKHR when <sync> was created, the behaviour is 27102f4aeb0Sopenharmony_ci undefined. 27202f4aeb0Sopenharmony_ci 27302f4aeb0Sopenharmony_ci 27402f4aeb0Sopenharmony_ci The command 27502f4aeb0Sopenharmony_ci 27602f4aeb0Sopenharmony_ci EGLBoolean eglSignalSyncKHR( 27702f4aeb0Sopenharmony_ci EGLDisplay dpy, 27802f4aeb0Sopenharmony_ci EGLSyncKHR sync, 27902f4aeb0Sopenharmony_ci EGLenum mode); 28002f4aeb0Sopenharmony_ci 28102f4aeb0Sopenharmony_ci signals or unsignals the reusable sync object <sync> by changing its 28202f4aeb0Sopenharmony_ci status to <mode>, which must be one of the values in table 3.bb. If 28302f4aeb0Sopenharmony_ci as a result of calling eglSignalSyncKHR the status of <sync> 28402f4aeb0Sopenharmony_ci transitions from unsignaled to signaled, any eglClientWaitSyncKHR 28502f4aeb0Sopenharmony_ci commands blocking on <sync> will unblock. 28602f4aeb0Sopenharmony_ci 28702f4aeb0Sopenharmony_ci Assuming no errors are generated, EGL_TRUE is returned. 28802f4aeb0Sopenharmony_ci 28902f4aeb0Sopenharmony_ci Mode Effect 29002f4aeb0Sopenharmony_ci ------------------ ------------- 29102f4aeb0Sopenharmony_ci EGL_SIGNALED_KHR Set the status of <sync> to signaled 29202f4aeb0Sopenharmony_ci EGL_UNSIGNALED_KHR Set the status of <sync> to unsignaled 29302f4aeb0Sopenharmony_ci 29402f4aeb0Sopenharmony_ci Table 3.bb Modes Accepted by eglSignalSyncKHR Command 29502f4aeb0Sopenharmony_ci 29602f4aeb0Sopenharmony_ci Errors 29702f4aeb0Sopenharmony_ci ------ 29802f4aeb0Sopenharmony_ci 29902f4aeb0Sopenharmony_ci * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is 30002f4aeb0Sopenharmony_ci returned and an EGL_BAD_PARAMETER error is generated. 30102f4aeb0Sopenharmony_ci * If the type of <sync> is not EGL_SYNC_REUSABLE_KHR, EGL_FALSE is 30202f4aeb0Sopenharmony_ci returned and an EGL_BAD_MATCH error is generated. 30302f4aeb0Sopenharmony_ci * If <dpy> does not match the EGLDisplay passed to 30402f4aeb0Sopenharmony_ci eglCreateSyncKHR when <sync> was created, the behaviour is 30502f4aeb0Sopenharmony_ci undefined. 30602f4aeb0Sopenharmony_ci 30702f4aeb0Sopenharmony_ci 30802f4aeb0Sopenharmony_ci The command 30902f4aeb0Sopenharmony_ci 31002f4aeb0Sopenharmony_ci EGLBoolean eglGetSyncAttribKHR( 31102f4aeb0Sopenharmony_ci EGLDisplay dpy, 31202f4aeb0Sopenharmony_ci EGLSyncKHR sync, 31302f4aeb0Sopenharmony_ci EGLint attribute, 31402f4aeb0Sopenharmony_ci EGLint *value); 31502f4aeb0Sopenharmony_ci 31602f4aeb0Sopenharmony_ci is used to query attributes of the sync object <sync>. Legal values 31702f4aeb0Sopenharmony_ci for <attribute> depend on the type of sync object, as shown in table 31802f4aeb0Sopenharmony_ci 3.cc. Assuming no errors are generated, EGL_TRUE is returned and the 31902f4aeb0Sopenharmony_ci value of the queried attribute is returned in <value>. 32002f4aeb0Sopenharmony_ci 32102f4aeb0Sopenharmony_ci Attribute Description Supported Sync Objects 32202f4aeb0Sopenharmony_ci ----------------- ----------------------- ---------------------- 32302f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR Type of the sync object All 32402f4aeb0Sopenharmony_ci EGL_SYNC_STATUS_KHR Status of the sync object All 32502f4aeb0Sopenharmony_ci 32602f4aeb0Sopenharmony_ci Table 3.cc Attributes Accepted by eglGetSyncAttribKHR Command 32702f4aeb0Sopenharmony_ci 32802f4aeb0Sopenharmony_ci Errors 32902f4aeb0Sopenharmony_ci ------ 33002f4aeb0Sopenharmony_ci 33102f4aeb0Sopenharmony_ci * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is 33202f4aeb0Sopenharmony_ci returned and an EGL_BAD_PARAMETER error is generated. 33302f4aeb0Sopenharmony_ci * If <dpy> does not match the display passed to eglCreateSyncKHR 33402f4aeb0Sopenharmony_ci when <sync> was created, the behaviour is undefined. 33502f4aeb0Sopenharmony_ci * If <attribute> is not one of the attributes in table 3.cc, 33602f4aeb0Sopenharmony_ci EGL_FALSE is returned and an EGL_BAD_ATTRIBUTE error is 33702f4aeb0Sopenharmony_ci generated. 33802f4aeb0Sopenharmony_ci * If <attribute> is not supported for the type of sync object 33902f4aeb0Sopenharmony_ci passed in <sync>, EGL_FALSE is returned and an EGL_BAD_MATCH 34002f4aeb0Sopenharmony_ci error is generated. 34102f4aeb0Sopenharmony_ci 34202f4aeb0Sopenharmony_ci If any error occurs, <*value> is not modified. 34302f4aeb0Sopenharmony_ci 34402f4aeb0Sopenharmony_ci The command 34502f4aeb0Sopenharmony_ci 34602f4aeb0Sopenharmony_ci EGLBoolean eglDestroySyncKHR( 34702f4aeb0Sopenharmony_ci EGLDisplay dpy, 34802f4aeb0Sopenharmony_ci EGLSyncKHR sync); 34902f4aeb0Sopenharmony_ci 35002f4aeb0Sopenharmony_ci is used to destroy an existing sync object. If any 35102f4aeb0Sopenharmony_ci eglClientWaitSyncKHR commands are blocking on <sync> when 35202f4aeb0Sopenharmony_ci eglDestroySyncKHR is called, they will be woken up, as if <sync> 35302f4aeb0Sopenharmony_ci were signaled. 35402f4aeb0Sopenharmony_ci 35502f4aeb0Sopenharmony_ci If no errors are generated, EGL_TRUE is returned, and <sync> will no 35602f4aeb0Sopenharmony_ci longer be the handle of a valid sync object. 35702f4aeb0Sopenharmony_ci 35802f4aeb0Sopenharmony_ci Errors 35902f4aeb0Sopenharmony_ci ------ 36002f4aeb0Sopenharmony_ci 36102f4aeb0Sopenharmony_ci * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is 36202f4aeb0Sopenharmony_ci returned and an EGL_BAD_PARAMETER error is generated. 36302f4aeb0Sopenharmony_ci * If <dpy> does not match the display passed to eglCreateSyncKHR 36402f4aeb0Sopenharmony_ci when <sync> was created, the behaviour is undefined." 36502f4aeb0Sopenharmony_ci 36602f4aeb0Sopenharmony_ciIssues 36702f4aeb0Sopenharmony_ci 36802f4aeb0Sopenharmony_ci Note about the Issues 36902f4aeb0Sopenharmony_ci --------------------- 37002f4aeb0Sopenharmony_ci The wording for this extension was originally written as a single 37102f4aeb0Sopenharmony_ci extension defining two types of sync object; a "reusable sync 37202f4aeb0Sopenharmony_ci object" and a "fence sync object". That extension was split to 37302f4aeb0Sopenharmony_ci produce standalone extensions for each type of sync object, and 37402f4aeb0Sopenharmony_ci references to the other type removed from the specification 37502f4aeb0Sopenharmony_ci language. This issues list has been simplied to remove references to 37602f4aeb0Sopenharmony_ci fence sync objects but is otherwise very similar to the 37702f4aeb0Sopenharmony_ci EGL_KHR_fence_sync extension issues list. 37802f4aeb0Sopenharmony_ci 37902f4aeb0Sopenharmony_ci 1. Explain the key choices made in this extension. 38002f4aeb0Sopenharmony_ci 38102f4aeb0Sopenharmony_ci RESPONSE: This extension has been written to enable adoption to be 38202f4aeb0Sopenharmony_ci as wide as possible, and to behave as similarly as possible to 38302f4aeb0Sopenharmony_ci synchronization primitives available in desktop OpenGL (e.g., 38402f4aeb0Sopenharmony_ci NV_fence, ARB_sync). 38502f4aeb0Sopenharmony_ci 38602f4aeb0Sopenharmony_ci In the interest of enabling widespread adoption, this extension 38702f4aeb0Sopenharmony_ci (following the ARB_sync model) has foregone the inclusion of 38802f4aeb0Sopenharmony_ci synchronization primitives and synchronization tests which may be 38902f4aeb0Sopenharmony_ci performed entirely inside client API command streams, instead 39002f4aeb0Sopenharmony_ci performing synchronization tests (eglClientWaitSyncKHR) inside the 39102f4aeb0Sopenharmony_ci application & host CPU. 39202f4aeb0Sopenharmony_ci 39302f4aeb0Sopenharmony_ci In the interest of maintaining similarity with previous 39402f4aeb0Sopenharmony_ci synchronization primitives, this extension attempts to copy the 39502f4aeb0Sopenharmony_ci ARB_sync specification wherever possible (both functionally and 39602f4aeb0Sopenharmony_ci stylistically), only making changes where needed to operate inside 39702f4aeb0Sopenharmony_ci EGL (rather than a client API context) and match EGL naming 39802f4aeb0Sopenharmony_ci conventions. 39902f4aeb0Sopenharmony_ci 40002f4aeb0Sopenharmony_ci 2. Why place this behavior in EGL, rather than in the client APIs? 40102f4aeb0Sopenharmony_ci 40202f4aeb0Sopenharmony_ci RESPONSE: Ultimately, synchronization between multiple asynchronous 40302f4aeb0Sopenharmony_ci client API contexts (potentially executing in different threads) is 40402f4aeb0Sopenharmony_ci a problem which affects or will affect all EGL client APIs. Rather 40502f4aeb0Sopenharmony_ci than creating separate synchronization primitives in each of the 40602f4aeb0Sopenharmony_ci client APIs (and then wrapping them in an EGL container), in the 40702f4aeb0Sopenharmony_ci interest of developer simplicity & consistency this behavior is 40802f4aeb0Sopenharmony_ci being placed inside EGL. 40902f4aeb0Sopenharmony_ci 41002f4aeb0Sopenharmony_ci 3. What does this extension provide that can not be accomplished 41102f4aeb0Sopenharmony_ci with the existing, more efficient eglWaitClient and eglWaitNative 41202f4aeb0Sopenharmony_ci API functions? 41302f4aeb0Sopenharmony_ci 41402f4aeb0Sopenharmony_ci RESPONSE: eglWaitClient and eglWaitNative may be implemented in 41502f4aeb0Sopenharmony_ci extremely lightweight manners, in some cases not blocking the 41602f4aeb0Sopenharmony_ci calling thread at all; however, they can not be used to synchronize 41702f4aeb0Sopenharmony_ci between client API contexts and native APIs executing in separate 41802f4aeb0Sopenharmony_ci threads (or simply between client API contexts executing in separate 41902f4aeb0Sopenharmony_ci threads), such as between a thread with an active OpenGL context and 42002f4aeb0Sopenharmony_ci a second thread performing video decode. 42102f4aeb0Sopenharmony_ci 42202f4aeb0Sopenharmony_ci 4. [REMOVED - found in the fence_sync extension.] 42302f4aeb0Sopenharmony_ci 42402f4aeb0Sopenharmony_ci 5. Should integration with native platform synchronization objects 42502f4aeb0Sopenharmony_ci be included in this extension, or reserved for future 42602f4aeb0Sopenharmony_ci (platform-specific) extensions? 42702f4aeb0Sopenharmony_ci 42802f4aeb0Sopenharmony_ci RESOLVED: Integration with native platform synchronization objects 42902f4aeb0Sopenharmony_ci should not be part of this extension, but can be added as future 43002f4aeb0Sopenharmony_ci layered extensions if needed. These layered extensions can be 43102f4aeb0Sopenharmony_ci platform-specific, or perhaps OpenKODE based. 43202f4aeb0Sopenharmony_ci 43302f4aeb0Sopenharmony_ci Originally, this extension included the ability to create native 43402f4aeb0Sopenharmony_ci platform synchronization objects from EGLSync objects. This feature 43502f4aeb0Sopenharmony_ci was removed for a few reasons: 43602f4aeb0Sopenharmony_ci 43702f4aeb0Sopenharmony_ci i) The proposed mechanism suggested mapping EGLSync objects to 43802f4aeb0Sopenharmony_ci pthread conditional variables on platforms with pthread support. 43902f4aeb0Sopenharmony_ci However, pthread conditional variables require an associated 44002f4aeb0Sopenharmony_ci mutex and there was no mechanism to relay this associated mutex 44102f4aeb0Sopenharmony_ci to the application. 44202f4aeb0Sopenharmony_ci 44302f4aeb0Sopenharmony_ci ii) On certain platforms support for converting to native 44402f4aeb0Sopenharmony_ci platform synchronization objects adds great complexity to the 44502f4aeb0Sopenharmony_ci implementation. 44602f4aeb0Sopenharmony_ci 44702f4aeb0Sopenharmony_ci iii) Now that OpenKODE is more mature, it would be better to 44802f4aeb0Sopenharmony_ci allow conversion from EGLSyncKHR objects to OpenKODE 44902f4aeb0Sopenharmony_ci synchronization primitives rather than platform-specific ones. 45002f4aeb0Sopenharmony_ci We suggest that this functionality, if needed, be added as a 45102f4aeb0Sopenharmony_ci layered extension instead of being included here. This way, 45202f4aeb0Sopenharmony_ci EGL_KHR_sync remains minimal and easy to implement on a variety 45302f4aeb0Sopenharmony_ci of platforms. 45402f4aeb0Sopenharmony_ci 45502f4aeb0Sopenharmony_ci 6. Please provide a more detailed description of how 45602f4aeb0Sopenharmony_ci eglClientWaitSyncKHR behaves. 45702f4aeb0Sopenharmony_ci 45802f4aeb0Sopenharmony_ci RESOLVED: eglClientWaitSyncKHR blocks until the status of the sync 45902f4aeb0Sopenharmony_ci object transitions to the signaled state. Sync object status is 46002f4aeb0Sopenharmony_ci either signaled or unsignaled. More detailed rules describing 46102f4aeb0Sopenharmony_ci signalling follow (these may need to be imbedded into the actual 46202f4aeb0Sopenharmony_ci spec language): 46302f4aeb0Sopenharmony_ci 46402f4aeb0Sopenharmony_ci * A reusable sync object has two possible status values: signaled 46502f4aeb0Sopenharmony_ci or unsignaled. 46602f4aeb0Sopenharmony_ci * When created, the status of the sync object is unsignaled by 46702f4aeb0Sopenharmony_ci default. 46802f4aeb0Sopenharmony_ci * A reusable sync can be set to signaled or unsignaled 46902f4aeb0Sopenharmony_ci status using eglSignalSyncKHR. 47002f4aeb0Sopenharmony_ci * A wait function called on a sync object in the unsignaled state 47102f4aeb0Sopenharmony_ci will block. It unblocks (note, not "returns to the application") 47202f4aeb0Sopenharmony_ci when the sync object transitions to the signaled state. 47302f4aeb0Sopenharmony_ci * A wait function called on a sync object in the signaled state 47402f4aeb0Sopenharmony_ci will return immediately. 47502f4aeb0Sopenharmony_ci 47602f4aeb0Sopenharmony_ci 7. Should the 'flags' argument to eglClientWaitSyncKHR be 47702f4aeb0Sopenharmony_ci EGLint or EGLuint? 47802f4aeb0Sopenharmony_ci 47902f4aeb0Sopenharmony_ci RESOLVED: EGLint, setting a precedent for explicit bitmask types 48002f4aeb0Sopenharmony_ci in EGL going forward. We don't have an EGLuint type and it is 48102f4aeb0Sopenharmony_ci overkill for this purposes when other bitmasks (surface type 48202f4aeb0Sopenharmony_ci and api type) are already using EGLint attribute fields. 48302f4aeb0Sopenharmony_ci 48402f4aeb0Sopenharmony_ci 8. Can multiple WaitSyncs be placed on the same sync object? 48502f4aeb0Sopenharmony_ci 48602f4aeb0Sopenharmony_ci RESOLVED: Yes. This has been allowed all along but we now state it 48702f4aeb0Sopenharmony_ci more clearly in the spec language. However, there is some concern 48802f4aeb0Sopenharmony_ci that this is hard to implement and of limited use, and we might 48902f4aeb0Sopenharmony_ci remove this capability before approving the extension. 49002f4aeb0Sopenharmony_ci 49102f4aeb0Sopenharmony_ci One way to do this while allowing multiple waiters at some future 49202f4aeb0Sopenharmony_ci point is to expose it through the API to developers as either a sync 49302f4aeb0Sopenharmony_ci attribute allowing multiple waits (default not allowing it), or a 49402f4aeb0Sopenharmony_ci parameter to WaitSync, which initially must be something like 49502f4aeb0Sopenharmony_ci EGL_SINGLE_WAIT_ONLY. 49602f4aeb0Sopenharmony_ci 49702f4aeb0Sopenharmony_ci 9. Should eglDestroySyncKHR release all WaitSyncs placed on a 49802f4aeb0Sopenharmony_ci reusable sync object? 49902f4aeb0Sopenharmony_ci 50002f4aeb0Sopenharmony_ci RESOLVED: Yes. It is safest to release all threads waiting on a 50102f4aeb0Sopenharmony_ci reusable object when the sync object is deleted so that waiting 50202f4aeb0Sopenharmony_ci threads do not wait forever. 50302f4aeb0Sopenharmony_ci 50402f4aeb0Sopenharmony_ciRevision History 50502f4aeb0Sopenharmony_ci 50602f4aeb0Sopenharmony_ci#22 (Jon Leech, January 31, 2014) 50702f4aeb0Sopenharmony_ci - Clarify return value of ClientWaitSyncKHR when called with <timeout> 50802f4aeb0Sopenharmony_ci of zero for an unsignaled <sync> (Bug 11576). 50902f4aeb0Sopenharmony_ci#21 (Jon Leech, April 23, 2013) 51002f4aeb0Sopenharmony_ci - Simplify issues list to remove issues specific to fence sync 51102f4aeb0Sopenharmony_ci objects. 51202f4aeb0Sopenharmony_ci#20 (Jon Leech, September 8, 2009) 51302f4aeb0Sopenharmony_ci - Change status to complete and note approval by the Promoters. 51402f4aeb0Sopenharmony_ci Minor formatting changes. 51502f4aeb0Sopenharmony_ci#19 (Robert Palmer, July 14, 2009) 51602f4aeb0Sopenharmony_ci - Branch wording from draft KHR_sync specification. Remove ability 51702f4aeb0Sopenharmony_ci to create "fence sync objects and all tokens/wording specific to 51802f4aeb0Sopenharmony_ci them. 51902f4aeb0Sopenharmony_ci#18 (Robert Palmer, July 8, 2009) 52002f4aeb0Sopenharmony_ci - Issues 8 and 9 declared resolved in EGL meeting 2009-07-08 52102f4aeb0Sopenharmony_ci#17 (Robert Palmer, July 8, 2009) 52202f4aeb0Sopenharmony_ci - Update eglDestroySyncKHR to special-case deletion of fence sync 52302f4aeb0Sopenharmony_ci objects. This is explained in issue 9. 52402f4aeb0Sopenharmony_ci - Corrected EGL_REUSABLE_SYNC_KHR -> EGL_SYNC_REUSABLE_KHR 52502f4aeb0Sopenharmony_ci - Define value for EGL_SYNC_REUSABLE_KHR 52602f4aeb0Sopenharmony_ci - Fix typo and whitespace 52702f4aeb0Sopenharmony_ci#16 (Jon Leech, July 7, 2009) 52802f4aeb0Sopenharmony_ci - Update description of new tokens to match changes to the 52902f4aeb0Sopenharmony_ci eglCreateSyncKHR entry point in revision 15. 53002f4aeb0Sopenharmony_ci#15 (Jon Leech, June 16, 2009) 53102f4aeb0Sopenharmony_ci - Define separate one-time fence sync and reusable sync extensions 53202f4aeb0Sopenharmony_ci and corresponding extension strings. Remove AUTO_RESET and 53302f4aeb0Sopenharmony_ci eglFenceKHR. Rename eglCreateFenceSyncKHR to eglCreateSyncKHR and 53402f4aeb0Sopenharmony_ci change initial status of reusable syncs to unsignaled. Clarify 53502f4aeb0Sopenharmony_ci which functions apply to which types of sync objects. Update 53602f4aeb0Sopenharmony_ci issues list. 53702f4aeb0Sopenharmony_ci#14 (Jon Leech, April 29, 2009) 53802f4aeb0Sopenharmony_ci - Clarify that all waiters are woken up on signalling a sync. 53902f4aeb0Sopenharmony_ci Remove tabs to cleanup some formatting issues. 54002f4aeb0Sopenharmony_ci#13 (Acorn Pooley, April 2, 2009) 54102f4aeb0Sopenharmony_ci - Renamed 54202f4aeb0Sopenharmony_ci GL_OES_egl_sync -> GL_OES_EGL_sync 54302f4aeb0Sopenharmony_ci VG_KHR_egl_sync -> VG_KHR_EGL_sync 54402f4aeb0Sopenharmony_ci#12 (Jon Leech, April 1, 2009) 54502f4aeb0Sopenharmony_ci - Changed sync flags type from EGLuint to EGLint and add issue 7. 54602f4aeb0Sopenharmony_ci#11 (Acorn Pooley, February 4, 2009) 54702f4aeb0Sopenharmony_ci - add error case to eglGetSyncAttribKHR. 54802f4aeb0Sopenharmony_ci - fix year on rev 8-10 (2008->2009) 54902f4aeb0Sopenharmony_ci#10 (Acorn Pooley, February 4, 2009) 55002f4aeb0Sopenharmony_ci - clarify some error message descriptions 55102f4aeb0Sopenharmony_ci#9 (Greg Prisament, January 15, 2009) 55202f4aeb0Sopenharmony_ci - Destroy now wakes up all waits (eglClientWaitSyncKHR) 55302f4aeb0Sopenharmony_ci - Add EGLDisplay <dpy> as first parameter to all commands 55402f4aeb0Sopenharmony_ci - Split into 3 extension strings, EGL_KHR_sync, GL_OES_egl_sync, 55502f4aeb0Sopenharmony_ci VG_KHR_egl_sync, all described in this document. 55602f4aeb0Sopenharmony_ci - Add attribute AUTO_RESET_KHR 55702f4aeb0Sopenharmony_ci - Time type uses the type from khrplatform.h 55802f4aeb0Sopenharmony_ci - Remove EGL_ALREADY_SIGNALLED 55902f4aeb0Sopenharmony_ci#8 (Jon Leech, November 11, 2009) 56002f4aeb0Sopenharmony_ci - Assign enum values 56102f4aeb0Sopenharmony_ci#7 (Acorn Pooley, October 30, 2008) 56202f4aeb0Sopenharmony_ci - Fix typos 56302f4aeb0Sopenharmony_ci - remove obsolete wording about Native sync objects (see issue 5) 56402f4aeb0Sopenharmony_ci - formatting: remove tabs, 80 columns 56502f4aeb0Sopenharmony_ci#6 (Acorn Pooley, October 27, 2008) 56602f4aeb0Sopenharmony_ci - Corrected 'enum' to 'EGLenum' in prototypes. 56702f4aeb0Sopenharmony_ci#5 (Jon Leech, September 9, 2008) 56802f4aeb0Sopenharmony_ci - Removed native sync support (eglCreateNativeSyncKHR and 56902f4aeb0Sopenharmony_ci EGL_SYNC_NATIVE_SYNC_KHR), and re-flowed spec to fit in 80 columns. 57002f4aeb0Sopenharmony_ci#4 (Jon Leech, November 20, 2007) 57102f4aeb0Sopenharmony_ci - Corrected 'enum' to 'EGLenum' in prototypes. 57202f4aeb0Sopenharmony_ci#3 (Jon Leech, April 5, 2007) 57302f4aeb0Sopenharmony_ci - Added draft Status and TBD Number 57402f4aeb0Sopenharmony_ci#2 (November 27, 2006) 57502f4aeb0Sopenharmony_ci - Changed OES token to KHR 576