102f4aeb0Sopenharmony_ciName 202f4aeb0Sopenharmony_ci 302f4aeb0Sopenharmony_ci KHR_cl_event 402f4aeb0Sopenharmony_ci 502f4aeb0Sopenharmony_ciName Strings 602f4aeb0Sopenharmony_ci 702f4aeb0Sopenharmony_ci EGL_KHR_cl_event 802f4aeb0Sopenharmony_ci 902f4aeb0Sopenharmony_ciContributors 1002f4aeb0Sopenharmony_ci 1102f4aeb0Sopenharmony_ci Jon Leech, Khronos 1202f4aeb0Sopenharmony_ci Alon Or-bach, Samsung Electronics 1302f4aeb0Sopenharmony_ci 1402f4aeb0Sopenharmony_ciContact 1502f4aeb0Sopenharmony_ci 1602f4aeb0Sopenharmony_ci Jon Leech (jon 'at' alumni.caltech.edu) 1702f4aeb0Sopenharmony_ci 1802f4aeb0Sopenharmony_ciIP Status 1902f4aeb0Sopenharmony_ci 2002f4aeb0Sopenharmony_ci No known claims. 2102f4aeb0Sopenharmony_ci 2202f4aeb0Sopenharmony_ciNotice 2302f4aeb0Sopenharmony_ci 2402f4aeb0Sopenharmony_ci Copyright (c) 2010-2013 The Khronos Group Inc. Copyright terms at 2502f4aeb0Sopenharmony_ci http://www.khronos.org/registry/speccopyright.html 2602f4aeb0Sopenharmony_ci 2702f4aeb0Sopenharmony_ciStatus 2802f4aeb0Sopenharmony_ci 2902f4aeb0Sopenharmony_ci This extension is obsolete and has been replaced by EGL_KHR_cl_event2. 3002f4aeb0Sopenharmony_ci Khronos recommends implementers who support this extension also 3102f4aeb0Sopenharmony_ci implement cl_event2, and begin transitioning developers to using that 3202f4aeb0Sopenharmony_ci extension. See issue 17 for the reason. 3302f4aeb0Sopenharmony_ci 3402f4aeb0Sopenharmony_ci Complete. Approved by the EGL Working Group on 2013/05/15. 3502f4aeb0Sopenharmony_ci Approved by the Khronos Board of Promoters on 2013/07/19. 3602f4aeb0Sopenharmony_ci 3702f4aeb0Sopenharmony_ciVersion 3802f4aeb0Sopenharmony_ci 3902f4aeb0Sopenharmony_ci Version 10, December 4, 2013 4002f4aeb0Sopenharmony_ci 4102f4aeb0Sopenharmony_ciNumber 4202f4aeb0Sopenharmony_ci 4302f4aeb0Sopenharmony_ci EGL Extension #60 4402f4aeb0Sopenharmony_ci 4502f4aeb0Sopenharmony_ciDependencies 4602f4aeb0Sopenharmony_ci 4702f4aeb0Sopenharmony_ci EGL 1.4 and the EGL_KHR_fence_sync extension are required. 4802f4aeb0Sopenharmony_ci 4902f4aeb0Sopenharmony_ci This extension is written against the language added to EGL 1.2 by 5002f4aeb0Sopenharmony_ci the EGL_KHR_fence_sync extension. 5102f4aeb0Sopenharmony_ci 5202f4aeb0Sopenharmony_ci An OpenCL implementation supporting sharing OpenCL event objects 5302f4aeb0Sopenharmony_ci with EGL is required. 5402f4aeb0Sopenharmony_ci 5502f4aeb0Sopenharmony_ciOverview 5602f4aeb0Sopenharmony_ci 5702f4aeb0Sopenharmony_ci This extension allows creating an EGL fence sync object linked to an 5802f4aeb0Sopenharmony_ci OpenCL event object, potentially improving efficiency of sharing 5902f4aeb0Sopenharmony_ci images between the two APIs. The companion cl_khr_egl_event 6002f4aeb0Sopenharmony_ci extension provides the complementary functionality of creating an 6102f4aeb0Sopenharmony_ci OpenCL event object from an EGL fence sync object. 6202f4aeb0Sopenharmony_ci 6302f4aeb0Sopenharmony_ciNew Types 6402f4aeb0Sopenharmony_ci 6502f4aeb0Sopenharmony_ci None. However, event handles of type cl_event, defined in the OpenCL 6602f4aeb0Sopenharmony_ci header files, may be included in the attribute list passed to 6702f4aeb0Sopenharmony_ci eglCreateSyncKHR. 6802f4aeb0Sopenharmony_ci 6902f4aeb0Sopenharmony_ciNew Procedures and Functions 7002f4aeb0Sopenharmony_ci 7102f4aeb0Sopenharmony_ci None 7202f4aeb0Sopenharmony_ci 7302f4aeb0Sopenharmony_ciNew Tokens 7402f4aeb0Sopenharmony_ci 7502f4aeb0Sopenharmony_ci Accepted as attribute names in the <attrib_list> argument 7602f4aeb0Sopenharmony_ci of eglCreateSyncKHR: 7702f4aeb0Sopenharmony_ci 7802f4aeb0Sopenharmony_ci EGL_CL_EVENT_HANDLE_KHR 0x309C 7902f4aeb0Sopenharmony_ci 8002f4aeb0Sopenharmony_ci Returned in <values> for eglGetSyncAttribKHR <attribute> 8102f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR: 8202f4aeb0Sopenharmony_ci 8302f4aeb0Sopenharmony_ci EGL_SYNC_CL_EVENT_KHR 0x30FE 8402f4aeb0Sopenharmony_ci 8502f4aeb0Sopenharmony_ci Returned in <values> for eglGetSyncAttribKHR <attribute> 8602f4aeb0Sopenharmony_ci EGL_SYNC_CONDITION_KHR: 8702f4aeb0Sopenharmony_ci 8802f4aeb0Sopenharmony_ci EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF 8902f4aeb0Sopenharmony_ci 9002f4aeb0Sopenharmony_ciChanges to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors) 9102f4aeb0Sopenharmony_ci 9202f4aeb0Sopenharmony_ci Add following the description of fence sync objects in section 3.8.1 9302f4aeb0Sopenharmony_ci (e.g. following the paragraph beginning "<Fence sync objects> are 9402f4aeb0Sopenharmony_ci created..." 9502f4aeb0Sopenharmony_ci 9602f4aeb0Sopenharmony_ci "A <CL event sync object> reflects the status of a corresponding 9702f4aeb0Sopenharmony_ci OpenCL event object to which the sync object is linked. This 9802f4aeb0Sopenharmony_ci provides another method of coordinating sharing of images between 9902f4aeb0Sopenharmony_ci EGL and OpenCL (see Chapter 9 of the OpenCL 1.0 Specification and 10002f4aeb0Sopenharmony_ci the cl_khr_egl_sharing extension). Waiting on such a sync object is 10102f4aeb0Sopenharmony_ci equivalent to waiting for completion of the linked CL event object." 10202f4aeb0Sopenharmony_ci 10302f4aeb0Sopenharmony_ci Add following the description of fence sync objects (prior to the 10402f4aeb0Sopenharmony_ci "Errors" section for eglCreateSyncKHR): 10502f4aeb0Sopenharmony_ci 10602f4aeb0Sopenharmony_ci "If <type> is EGL_SYNC_CL_EVENT_KHR, a CL event sync object is 10702f4aeb0Sopenharmony_ci created. In this case <attrib_list> must contain the attribute 10802f4aeb0Sopenharmony_ci EGL_CL_EVENT_HANDLE_KHR, set to a valid OpenCL event. Note that 10902f4aeb0Sopenharmony_ci EGL_CL_EVENT_HANDLE_KHR is not a queriable property of a sync 11002f4aeb0Sopenharmony_ci object. Attributes of the CL event sync objects are set as follows: 11102f4aeb0Sopenharmony_ci 11202f4aeb0Sopenharmony_ci Attribute Name Initial Attribute Value(s) 11302f4aeb0Sopenharmony_ci ------------- -------------------------- 11402f4aeb0Sopenharmony_ci EGL_SYNC_TYPE_KHR EGL_SYNC_CL_EVENT_KHR 11502f4aeb0Sopenharmony_ci EGL_SYNC_STATUS_KHR Depends on status of <event> 11602f4aeb0Sopenharmony_ci EGL_SYNC_CONDITION_KHR EGL_SYNC_CL_EVENT_COMPLETE_KHR 11702f4aeb0Sopenharmony_ci 11802f4aeb0Sopenharmony_ci The status of such a sync object depends on <event>. When the status 11902f4aeb0Sopenharmony_ci of <event> is CL_QUEUED, CL_SUBMITTED, or CL_RUNNING, the status of 12002f4aeb0Sopenharmony_ci the linked sync object will be EGL_UNSIGNALED_KHR. When the status 12102f4aeb0Sopenharmony_ci of <event> changes to CL_COMPLETE, the status of the linked sync 12202f4aeb0Sopenharmony_ci object will become EGL_SIGNALED_KHR. 12302f4aeb0Sopenharmony_ci 12402f4aeb0Sopenharmony_ci Creating a linked sync object places a reference on the linked 12502f4aeb0Sopenharmony_ci OpenCL event object. When the sync object is deleted, the reference 12602f4aeb0Sopenharmony_ci will be removed from the event object. 12702f4aeb0Sopenharmony_ci 12802f4aeb0Sopenharmony_ci However, implementations are not required to validate the OpenCL 12902f4aeb0Sopenharmony_ci event, and passing an invalid event handle in <attrib_list> may 13002f4aeb0Sopenharmony_ci result in undefined behavior up to and including program 13102f4aeb0Sopenharmony_ci termination." 13202f4aeb0Sopenharmony_ci 13302f4aeb0Sopenharmony_ci Add to the "Errors" section for eglCreateSyncKHR: 13402f4aeb0Sopenharmony_ci 13502f4aeb0Sopenharmony_ci "* If <type> is EGL_SYNC_CL_EVENT_KHR then 13602f4aeb0Sopenharmony_ci 13702f4aeb0Sopenharmony_ci ** If EGL_CL_EVENT_HANDLE_KHR is not specified in <attrib_list> 13802f4aeb0Sopenharmony_ci or is not a valid OpenCL event handle returned by a call to 13902f4aeb0Sopenharmony_ci clEnqueueReleaseGLObjects or clEnqueueReleaseEGLObjects, then 14002f4aeb0Sopenharmony_ci EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is 14102f4aeb0Sopenharmony_ci generated. 14202f4aeb0Sopenharmony_ci 14302f4aeb0Sopenharmony_ci Replace the EGL_SYNC_CONDITION_KHR row of table 3.cc with: 14402f4aeb0Sopenharmony_ci 14502f4aeb0Sopenharmony_ci "Attribute Description Supported Sync Objects 14602f4aeb0Sopenharmony_ci ----------------- ----------------------- ---------------------- 14702f4aeb0Sopenharmony_ci EGL_SYNC_CONDITION_KHR Signaling condition EGL_SYNC_FENCE_KHR or 14802f4aeb0Sopenharmony_ci EGL_SYNC_CL_EVENT_KHR 14902f4aeb0Sopenharmony_ci 15002f4aeb0Sopenharmony_ci Table 3.cc Attributes Accepted by eglGetSyncAttribKHR Command" 15102f4aeb0Sopenharmony_ci 15202f4aeb0Sopenharmony_ci 15302f4aeb0Sopenharmony_ci Replace the second paragraph describing eglDestroySync with: 15402f4aeb0Sopenharmony_ci 15502f4aeb0Sopenharmony_ci "If any eglClientWaitSyncKHR commands are blocking on <sync> when 15602f4aeb0Sopenharmony_ci eglDestroySyncKHR is called, <sync> is flagged for deletion and will 15702f4aeb0Sopenharmony_ci be deleted when the associated fence command or CL event object has 15802f4aeb0Sopenharmony_ci completed, and <sync> is no longer blocking any eglClientWaitSyncKHR 15902f4aeb0Sopenharmony_ci command. Otherwise, the sync object is destroyed immediately." 16002f4aeb0Sopenharmony_ci 16102f4aeb0Sopenharmony_ciSample Code 16202f4aeb0Sopenharmony_ci 16302f4aeb0Sopenharmony_ci None 16402f4aeb0Sopenharmony_ci 16502f4aeb0Sopenharmony_ciConformance Tests 16602f4aeb0Sopenharmony_ci 16702f4aeb0Sopenharmony_ci None yet 16802f4aeb0Sopenharmony_ci 16902f4aeb0Sopenharmony_ciIssues 17002f4aeb0Sopenharmony_ci 17102f4aeb0Sopenharmony_ci 1) Does this extension need to introduce eglWaitSync 17202f4aeb0Sopenharmony_ci functionality? 17302f4aeb0Sopenharmony_ci 17402f4aeb0Sopenharmony_ci RESOLVED: The EGL_KHR_wait_sync extension introduces this, to allow 17502f4aeb0Sopenharmony_ci server-side synchronization, without blocking the client from issuing 17602f4aeb0Sopenharmony_ci commands. Whilst this is not a required dependency, GPU-to-GPU 17702f4aeb0Sopenharmony_ci synchronization is the most likely use of this extension. 17802f4aeb0Sopenharmony_ci 17902f4aeb0Sopenharmony_ci 2) What should the command to create a sync object linked to an 18002f4aeb0Sopenharmony_ci OpenCL event look like? 18102f4aeb0Sopenharmony_ci 18202f4aeb0Sopenharmony_ci RESOLVED: We reuse the general attribute list mechanism rather than 18302f4aeb0Sopenharmony_ci having a constructor specific to CL events. This was intended in the 18402f4aeb0Sopenharmony_ci sync object design from the start. 18502f4aeb0Sopenharmony_ci 18602f4aeb0Sopenharmony_ci 3) How will the OpenCL header dependencies interact with 18702f4aeb0Sopenharmony_ci specifying the API for this extension? 18802f4aeb0Sopenharmony_ci 18902f4aeb0Sopenharmony_ci DISCUSSION: To use this extension, OpenCL event handles of type cl_event 19002f4aeb0Sopenharmony_ci are specified in the attribute lists passed to eglCreateSyncKHR. Because 19102f4aeb0Sopenharmony_ci no formal parameters are of type cl_event, the EGL headers do not need 19202f4aeb0Sopenharmony_ci to define this type. Applications must #include the appropriate OpenCL 19302f4aeb0Sopenharmony_ci header files as well as <EGL/eglext.h> when using this extension. 19402f4aeb0Sopenharmony_ci 19502f4aeb0Sopenharmony_ci This issue resolution is consistent with the equivalent issue for 19602f4aeb0Sopenharmony_ci GL_ARB_cl_event. 19702f4aeb0Sopenharmony_ci 19802f4aeb0Sopenharmony_ci 4) Should all possible statuses of the CL event be reflected through to the 19902f4aeb0Sopenharmony_ci state of the sync object? 20002f4aeb0Sopenharmony_ci 20102f4aeb0Sopenharmony_ci DISCUSSION: CL event objects have four execution statuses: 20202f4aeb0Sopenharmony_ci CL_QUEUED, CL_SUBMITTED, CL_RUNNING, and CL_COMPLETE. GL sync 20302f4aeb0Sopenharmony_ci objects have only two statuses: UNSIGNALED and SIGNALED. The 20402f4aeb0Sopenharmony_ci cl_khr_gl_event extension maps UNSIGNALED into CL_SUBMITTED, and 20502f4aeb0Sopenharmony_ci SIGNALED into CL_COMPLETE. 20602f4aeb0Sopenharmony_ci 20702f4aeb0Sopenharmony_ci RESOLVED: Invert the cl_khr_egl_event mapping. CL_QUEUED, 20802f4aeb0Sopenharmony_ci CL_SUBMITTED, and CL_RUNNING all map into UNSIGNALED. 20902f4aeb0Sopenharmony_ci CL_COMPLETE maps into SIGNALED. 21002f4aeb0Sopenharmony_ci 21102f4aeb0Sopenharmony_ci This issue resolution is consistent with the equivalent issue for 21202f4aeb0Sopenharmony_ci GL_ARB_cl_event. 21302f4aeb0Sopenharmony_ci 21402f4aeb0Sopenharmony_ci 5) Are there any restrictions on the use of a sync object linked to a CL 21502f4aeb0Sopenharmony_ci event object? 21602f4aeb0Sopenharmony_ci 21702f4aeb0Sopenharmony_ci RESOLVED: No restrictions. 21802f4aeb0Sopenharmony_ci 21902f4aeb0Sopenharmony_ci 6) How are sync object lifetimes defined? 22002f4aeb0Sopenharmony_ci 22102f4aeb0Sopenharmony_ci RESOLVED: A sync object linked to a CL event object places a single 22202f4aeb0Sopenharmony_ci reference on the event. Deleting the sync object removes that reference. 22302f4aeb0Sopenharmony_ci 22402f4aeb0Sopenharmony_ci eglDestroySync has a dependency on the completion of the linked event 22502f4aeb0Sopenharmony_ci object, and will not delete the sync objectwhile the event object has not 22602f4aeb0Sopenharmony_ci yet completed. This is equivalent to behavior of deleting a fence sync 22702f4aeb0Sopenharmony_ci object, where deletion of the object will be deferred until the underlying 22802f4aeb0Sopenharmony_ci fence command has completed. 22902f4aeb0Sopenharmony_ci 23002f4aeb0Sopenharmony_ci This issue resolution is consistent with the equivalent issue for 23102f4aeb0Sopenharmony_ci GL_ARB_cl_event. 23202f4aeb0Sopenharmony_ci 23302f4aeb0Sopenharmony_ci 7) Should all OpenCL events be supported? 23402f4aeb0Sopenharmony_ci 23502f4aeb0Sopenharmony_ci RESOLVED: No. Only events returned by clEnqueueReleaseGLObjects, or 23602f4aeb0Sopenharmony_ci clEnqueueReleaseEGLObjects since those are the only known use cases for 23702f4aeb0Sopenharmony_ci this extension. 23802f4aeb0Sopenharmony_ci 23902f4aeb0Sopenharmony_ci 8) Why has this extension been obsoleted and replaced by 24002f4aeb0Sopenharmony_ci EGL_KHR_cl_event2? 24102f4aeb0Sopenharmony_ci 24202f4aeb0Sopenharmony_ci RESOLVED: Starting with the December 4, 2013 release of EGL 1.4, EGLint 24302f4aeb0Sopenharmony_ci is defined to be the same size as the native platform "int" type. Handle 24402f4aeb0Sopenharmony_ci and pointer attribute values *cannot* be represented in attribute lists 24502f4aeb0Sopenharmony_ci on platforms where sizeof(handle/pointer) > sizeof(int). Existing 24602f4aeb0Sopenharmony_ci extensions which assume this functionality are being replaced with new 24702f4aeb0Sopenharmony_ci extensions specifying new entry points to work around this issue. See 24802f4aeb0Sopenharmony_ci the latest EGL 1.4 Specification for more details. 24902f4aeb0Sopenharmony_ci 25002f4aeb0Sopenharmony_ciRevision History 25102f4aeb0Sopenharmony_ci 25202f4aeb0Sopenharmony_ci Version 10, 2013/12/04 (Jon Leech) - add issue 8 explaining that OpenCL 25302f4aeb0Sopenharmony_ci event handles cannot be safely passed in attribute lists on 64-bit 25402f4aeb0Sopenharmony_ci platforms, and suggest using EGL_KHR_cl_event2 instead. 25502f4aeb0Sopenharmony_ci 25602f4aeb0Sopenharmony_ci Version 9, 2013/08/12 (Jon Leech) - remove unused cl_event type from the 25702f4aeb0Sopenharmony_ci extension and from <EGL/eglext.h> (Bug 10661). 25802f4aeb0Sopenharmony_ci 25902f4aeb0Sopenharmony_ci Version 8, 2013/07/19 (Jon Leech) - assign extension number and 26002f4aeb0Sopenharmony_ci missing enum value, and clean up a few typos for publication. 26102f4aeb0Sopenharmony_ci 26202f4aeb0Sopenharmony_ci Version 7, 2013/07/08 (Jon Leech) - assign enums (Bug 10490). 26302f4aeb0Sopenharmony_ci 26402f4aeb0Sopenharmony_ci Version 6, 2013/06/11 (Alon Or-bach) - typo correction 26502f4aeb0Sopenharmony_ci 26602f4aeb0Sopenharmony_ci Version 5, 2013/05/30 (Alon Or-bach) - wording cleanup 26702f4aeb0Sopenharmony_ci 26802f4aeb0Sopenharmony_ci Version 4, 2013/05/15 (Alon Or-bach) - updated issue resolutions as agreed, 26902f4aeb0Sopenharmony_ci consistent with GL_ARB_cl_event, including using typedef for cl_event 27002f4aeb0Sopenharmony_ci 27102f4aeb0Sopenharmony_ci Version 3, 2013/04/25 (Alon Or-bach) - remove use of CL context, 27202f4aeb0Sopenharmony_ci accept events from clEnqueueAcquireEGLObjects and minor cleanup 27302f4aeb0Sopenharmony_ci 27402f4aeb0Sopenharmony_ci Version 2, 2012/06/26 (Jon Leech) - update link to complementary CL 27502f4aeb0Sopenharmony_ci extension. 27602f4aeb0Sopenharmony_ci 27702f4aeb0Sopenharmony_ci Version 1, 2010/05/18 (Jon Leech) - initial version based on 27802f4aeb0Sopenharmony_ci equivalent GL_ARB_cl_event extension. 279