102f4aeb0Sopenharmony_ciName
202f4aeb0Sopenharmony_ci
302f4aeb0Sopenharmony_ci    NV_cuda_event
402f4aeb0Sopenharmony_ci
502f4aeb0Sopenharmony_ciName Strings
602f4aeb0Sopenharmony_ci
702f4aeb0Sopenharmony_ci    EGL_NV_cuda_event
802f4aeb0Sopenharmony_ci
902f4aeb0Sopenharmony_ciContributors
1002f4aeb0Sopenharmony_ci
1102f4aeb0Sopenharmony_ci    Debalina Bhattacharjee
1202f4aeb0Sopenharmony_ci    Michael Chock
1302f4aeb0Sopenharmony_ci    James Jones
1402f4aeb0Sopenharmony_ci    Daniel Kartch
1502f4aeb0Sopenharmony_ci
1602f4aeb0Sopenharmony_ciContact
1702f4aeb0Sopenharmony_ci
1802f4aeb0Sopenharmony_ci    Michael Chock (mchock 'at' nvidia.com)
1902f4aeb0Sopenharmony_ci
2002f4aeb0Sopenharmony_ciStatus
2102f4aeb0Sopenharmony_ci
2202f4aeb0Sopenharmony_ci    Complete
2302f4aeb0Sopenharmony_ci
2402f4aeb0Sopenharmony_ciVersion
2502f4aeb0Sopenharmony_ci
2602f4aeb0Sopenharmony_ci    Version 2, June 28, 2018
2702f4aeb0Sopenharmony_ci
2802f4aeb0Sopenharmony_ciNumber
2902f4aeb0Sopenharmony_ci
3002f4aeb0Sopenharmony_ci    EGL Extension #75
3102f4aeb0Sopenharmony_ci
3202f4aeb0Sopenharmony_ciExtension Type
3302f4aeb0Sopenharmony_ci
3402f4aeb0Sopenharmony_ci    EGL display extension
3502f4aeb0Sopenharmony_ci
3602f4aeb0Sopenharmony_ciDependencies
3702f4aeb0Sopenharmony_ci
3802f4aeb0Sopenharmony_ci    This extension is written against the language of EGL 1.5 and the
3902f4aeb0Sopenharmony_ci    EGL_EXT_sync_reuse extension.
4002f4aeb0Sopenharmony_ci
4102f4aeb0Sopenharmony_ci    Either EGL_KHR_fence_sync and the EGLAttrib type or EGL 1.5 are
4202f4aeb0Sopenharmony_ci    required.
4302f4aeb0Sopenharmony_ci
4402f4aeb0Sopenharmony_ci    This extension interacts with, but does not require,
4502f4aeb0Sopenharmony_ci    EGL_EXT_sync_reuse.
4602f4aeb0Sopenharmony_ci
4702f4aeb0Sopenharmony_ci    This extension interacts with EGL_NV_device_cuda.
4802f4aeb0Sopenharmony_ci
4902f4aeb0Sopenharmony_ciOverview
5002f4aeb0Sopenharmony_ci
5102f4aeb0Sopenharmony_ci    This extension allows creating an EGL sync object linked to a CUDA
5202f4aeb0Sopenharmony_ci    event object, potentially improving efficiency of sharing images and
5302f4aeb0Sopenharmony_ci    compute results between the two APIs.
5402f4aeb0Sopenharmony_ci
5502f4aeb0Sopenharmony_ciIP Status
5602f4aeb0Sopenharmony_ci
5702f4aeb0Sopenharmony_ci    No known claims.
5802f4aeb0Sopenharmony_ci
5902f4aeb0Sopenharmony_ciNew Types
6002f4aeb0Sopenharmony_ci
6102f4aeb0Sopenharmony_ci    A pointer to type cudaEvent_t, defined in the CUDA header files, may
6202f4aeb0Sopenharmony_ci    be included in the attribute list passed to eglCreateSync.
6302f4aeb0Sopenharmony_ci
6402f4aeb0Sopenharmony_ciNew Procedures and Functions
6502f4aeb0Sopenharmony_ci
6602f4aeb0Sopenharmony_ci    None.
6702f4aeb0Sopenharmony_ci
6802f4aeb0Sopenharmony_ciNew Tokens
6902f4aeb0Sopenharmony_ci
7002f4aeb0Sopenharmony_ci    Accepted as attribute names in the <attrib_list> argument
7102f4aeb0Sopenharmony_ci    of eglCreateSync:
7202f4aeb0Sopenharmony_ci
7302f4aeb0Sopenharmony_ci        EGL_CUDA_EVENT_HANDLE_NV        0x323B
7402f4aeb0Sopenharmony_ci
7502f4aeb0Sopenharmony_ci    Returned in <values> for eglGetSyncAttrib <attribute>
7602f4aeb0Sopenharmony_ci    EGL_SYNC_TYPE:
7702f4aeb0Sopenharmony_ci
7802f4aeb0Sopenharmony_ci        EGL_SYNC_CUDA_EVENT_NV          0x323C
7902f4aeb0Sopenharmony_ci
8002f4aeb0Sopenharmony_ci    Returned in <values> for eglGetSyncAttrib <attribute>
8102f4aeb0Sopenharmony_ci    EGL_SYNC_CONDITION:
8202f4aeb0Sopenharmony_ci
8302f4aeb0Sopenharmony_ci        EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D
8402f4aeb0Sopenharmony_ci
8502f4aeb0Sopenharmony_ciAdd to section 3.8.1 (Sync Objects) of the EGL 1.5 specification, after
8602f4aeb0Sopenharmony_cithe sixth paragraph:
8702f4aeb0Sopenharmony_ci
8802f4aeb0Sopenharmony_ci    Likewise, a <CUDA event sync object> reflects the status of a
8902f4aeb0Sopenharmony_ci    corresponding CUDA object. Waiting on this type of sync object is
9002f4aeb0Sopenharmony_ci    equivalent to waiting for completion of the corresponding linked
9102f4aeb0Sopenharmony_ci    CUDA event object.
9202f4aeb0Sopenharmony_ci
9302f4aeb0Sopenharmony_ciAdd a new section following section 3.8.1.2 (Creating and Signaling
9402f4aeb0Sopenharmony_ciOpenCL Event Sync Objects):
9502f4aeb0Sopenharmony_ci
9602f4aeb0Sopenharmony_ci    Section 3.8.1.X Creating and Signaling CUDA Event Sync Objects
9702f4aeb0Sopenharmony_ci
9802f4aeb0Sopenharmony_ci    If <type> is EGL_SYNC_CUDA_EVENT_NV, a CUDA event sync object is
9902f4aeb0Sopenharmony_ci    created. The <attrib_list> may contain the attribute
10002f4aeb0Sopenharmony_ci    EGL_CUDA_EVENT_HANDLE_NV, set to a pointer to a cudaEvent_t object.
10102f4aeb0Sopenharmony_ci    If it does not contain this attribute, the sync object will start in
10202f4aeb0Sopenharmony_ci    the signaled state, and an event attribute must be provided the
10302f4aeb0Sopenharmony_ci    first time eglUnsignalSyncEXT is called. Otherwise, a call to
10402f4aeb0Sopenharmony_ci    eglUnsignalSyncEXT may replace this event attribute or leave it
10502f4aeb0Sopenharmony_ci    unspecified, causing the previous object to be reused.
10602f4aeb0Sopenharmony_ci
10702f4aeb0Sopenharmony_ci    A cudaEvent_t object provided to eglCreateSync or eglUnsignalSyncEXT
10802f4aeb0Sopenharmony_ci    must be properly initialized and recorded by the CUDA API (using
10902f4aeb0Sopenharmony_ci    cudaEventCreate and cudaEventRecord), and the CUDA device
11002f4aeb0Sopenharmony_ci    used to create the event must correspond to <dpy>[fn1]. Note that
11102f4aeb0Sopenharmony_ci    EGL_CUDA_EVENT_HANDLE_NV is not a queryable property of a sync
11202f4aeb0Sopenharmony_ci    object.
11302f4aeb0Sopenharmony_ci
11402f4aeb0Sopenharmony_ci    [fn1] If EGL_NV_device_cuda is supported, it is sufficient that the
11502f4aeb0Sopenharmony_ci          CUDA device used to create the CUDA event matches the
11602f4aeb0Sopenharmony_ci          EGL_CUDA_DEVICE_NV attribute of <dpy>'s underlying EGL
11702f4aeb0Sopenharmony_ci          device.
11802f4aeb0Sopenharmony_ci
11902f4aeb0Sopenharmony_ci    Attributes of the CUDA event sync object are set as follows:
12002f4aeb0Sopenharmony_ci
12102f4aeb0Sopenharmony_ci        Attribute Name          Initial Attribute Value(s)
12202f4aeb0Sopenharmony_ci        -------------           --------------------------
12302f4aeb0Sopenharmony_ci        EGL_SYNC_TYPE           EGL_SYNC_CUDA_EVENT_NV
12402f4aeb0Sopenharmony_ci        EGL_SYNC_STATUS         Depends on status of <event>
12502f4aeb0Sopenharmony_ci        EGL_SYNC_CONDITION      EGL_SYNC_CUDA_EVENT_COMPLETE_NV
12602f4aeb0Sopenharmony_ci
12702f4aeb0Sopenharmony_ci    If an <event> is linked to the sync object, the status of this type
12802f4aeb0Sopenharmony_ci    of sync object depends on the state of <event> evaluated at the time
12902f4aeb0Sopenharmony_ci    of the most recent call to eglCreateSync or eglUnsignalSyncEXT. If
13002f4aeb0Sopenharmony_ci    all device work preceding the most recent call to cudaEventRecord on
13102f4aeb0Sopenharmony_ci    the event has not yet completed, the status of the linked sync
13202f4aeb0Sopenharmony_ci    object will be EGL_UNSIGNALED. If all such work has completed, the
13302f4aeb0Sopenharmony_ci    status of the linked sync object will be EGL_SIGNALED. Calling
13402f4aeb0Sopenharmony_ci    cudaEventRecord to modify an event has no effect on the sync object
13502f4aeb0Sopenharmony_ci    while its status is EGL_UNSIGNALED, but will have an effect if the
13602f4aeb0Sopenharmony_ci    event is reevaluated at a subsequent eglUnsignalSyncEXT call.
13702f4aeb0Sopenharmony_ci
13802f4aeb0Sopenharmony_ci    The only condition supported for CUDA event sync objects is
13902f4aeb0Sopenharmony_ci    EGL_SYNC_CUDA_EVENT_COMPLETE_NV. It is satisfied when all device
14002f4aeb0Sopenharmony_ci    work prior to the most recent call to cudaEventRecord at sync
14102f4aeb0Sopenharmony_ci    unsignaling time has completed.
14202f4aeb0Sopenharmony_ci
14302f4aeb0Sopenharmony_ciIf EGL_EXT_sync_reuse is not present, then change the second sentence of
14402f4aeb0Sopenharmony_ci3.8.1.X above to "The <attrib_list> must contain ..." and omit the
14502f4aeb0Sopenharmony_ciremaining sentences in the paragraph. Omit all references to
14602f4aeb0Sopenharmony_cieglUnsignalSyncEXT.
14702f4aeb0Sopenharmony_ci
14802f4aeb0Sopenharmony_ciIn 3.8.1 (Sync Objects), if EGL_EXT_sync_reuse is present, then add the
14902f4aeb0Sopenharmony_cifollowing to the error list for eglUnsignalSyncEXT. Otherwise add it to
15002f4aeb0Sopenharmony_cithe error list for eglCreateSync:
15102f4aeb0Sopenharmony_ci
15202f4aeb0Sopenharmony_ci    If <type> is EGL_SYNC_CUDA_EVENT_NV and a EGL_CUDA_EVENT_HANDLE_NV
15302f4aeb0Sopenharmony_ci    is not linked to the sync object, then an EGL_BAD_ATTRIBUTE error is
15402f4aeb0Sopenharmony_ci    generated. If its attribute value is not a valid CUDA event pointer
15502f4aeb0Sopenharmony_ci    or has not been initialized as described above, then
15602f4aeb0Sopenharmony_ci    EGL_BAD_ATTRIBUTE may be generated, but the results are undefined
15702f4aeb0Sopenharmony_ci    and may include program termination.
15802f4aeb0Sopenharmony_ci
15902f4aeb0Sopenharmony_ciModify the third paragraph of section 3.8.1.4 (Querying Sync Object
16002f4aeb0Sopenharmony_ciAttributes):
16102f4aeb0Sopenharmony_ci
16202f4aeb0Sopenharmony_ci    If any eglClientWaitSync or eglWaitSync commands are blocking on
16302f4aeb0Sopenharmony_ci    <sync> when eglDestroySync is called, <sync> is flagged for deletion
16402f4aeb0Sopenharmony_ci    and will be deleted when the associated fence command, OpenCL event
16502f4aeb0Sopenharmony_ci    object, or CUDA event object has completed, and <sync> is no longer
16602f4aeb0Sopenharmony_ci    blocking any such egl*WaitSync command. Otherwise, the sync object
16702f4aeb0Sopenharmony_ci    is destroyed immediately.
16802f4aeb0Sopenharmony_ci
16902f4aeb0Sopenharmony_ciReplace the EGL_SYNC_CONDITION row of table 3.9 with:
17002f4aeb0Sopenharmony_ci
17102f4aeb0Sopenharmony_ci    Attribute           Description              Supported Sync Objects
17202f4aeb0Sopenharmony_ci    ------------------  -----------------------  ----------------------
17302f4aeb0Sopenharmony_ci    EGL_SYNC_CONDITION  Signaling condition      EGL_SYNC_FENCE,
17402f4aeb0Sopenharmony_ci                                                 EGL_SYNC_CL_EVENT, or
17502f4aeb0Sopenharmony_ci                                                 EGL_SYNC_CUDA_EVENT_NV
17602f4aeb0Sopenharmony_ci
17702f4aeb0Sopenharmony_ci    Table 3.9  Attributes Accepted by eglGetSyncAttrib
17802f4aeb0Sopenharmony_ci
17902f4aeb0Sopenharmony_ci
18002f4aeb0Sopenharmony_ciInteractions with EGL versions prior to 1.5
18102f4aeb0Sopenharmony_ci
18202f4aeb0Sopenharmony_ci    This extension may be used with earlier versions of EGL, provided
18302f4aeb0Sopenharmony_ci    that the EGL_KHR_fence_sync extension is supported. In this case,
18402f4aeb0Sopenharmony_ci    replace all references to sync functions and tokens with
18502f4aeb0Sopenharmony_ci    corresponding KHR-suffixed versions (e.g., replace eglCreateSync
18602f4aeb0Sopenharmony_ci    with eglCreateSyncKHR).
18702f4aeb0Sopenharmony_ci
18802f4aeb0Sopenharmony_ci    Additionally, this extension may be used with the 64-bit types and
18902f4aeb0Sopenharmony_ci    functions added to EGL_KHR_fence_sync introduced by
19002f4aeb0Sopenharmony_ci    EGL_KHR_cl_event2 (EGLAttribKHR and eglCreateSync64KHR). Support
19102f4aeb0Sopenharmony_ci    for OpenCL events is not required.
19202f4aeb0Sopenharmony_ci
19302f4aeb0Sopenharmony_ciIssues
19402f4aeb0Sopenharmony_ci
19502f4aeb0Sopenharmony_ci    None
19602f4aeb0Sopenharmony_ci
19702f4aeb0Sopenharmony_ciRevision History
19802f4aeb0Sopenharmony_ci
19902f4aeb0Sopenharmony_ci    Version 2, 2018/06/28 (Daniel Kartch)
20002f4aeb0Sopenharmony_ci        - Rewritten to clearly define interactions with
20102f4aeb0Sopenharmony_ci          EGL_EXT_sync_reuse, without requiring it
20202f4aeb0Sopenharmony_ci        - Fixed incorrect CUDA function name
20302f4aeb0Sopenharmony_ci        - Fixed table spacing
20402f4aeb0Sopenharmony_ci
20502f4aeb0Sopenharmony_ci    Version 1, 2014/06/20 (Michael Chock)
20602f4aeb0Sopenharmony_ci        - initial version.
207