102f4aeb0Sopenharmony_ciName
202f4aeb0Sopenharmony_ci
302f4aeb0Sopenharmony_ci    KHR_fence_sync
402f4aeb0Sopenharmony_ci
502f4aeb0Sopenharmony_ciName Strings
602f4aeb0Sopenharmony_ci
702f4aeb0Sopenharmony_ci    EGL_KHR_fence_sync
802f4aeb0Sopenharmony_ci    GL_OES_EGL_sync
902f4aeb0Sopenharmony_ci    VG_KHR_EGL_sync
1002f4aeb0Sopenharmony_ci
1102f4aeb0Sopenharmony_ciContributors
1202f4aeb0Sopenharmony_ci
1302f4aeb0Sopenharmony_ci    Acorn Pooley
1402f4aeb0Sopenharmony_ci    Gary King
1502f4aeb0Sopenharmony_ci    Gregory Prisament
1602f4aeb0Sopenharmony_ci    Jon Leech
1702f4aeb0Sopenharmony_ci
1802f4aeb0Sopenharmony_ciContacts
1902f4aeb0Sopenharmony_ci
2002f4aeb0Sopenharmony_ci    Acorn Pooley, NVIDIA Corporation (apooley 'at' nvidia.com)
2102f4aeb0Sopenharmony_ci    Gary King, NVIDIA Corporation (gking 'at' nvidia.com)
2202f4aeb0Sopenharmony_ci    Gregory Prisament, NVIDIA Corporation (gprisament 'at' nvidia.com)
2302f4aeb0Sopenharmony_ci    Jon Leech (jon 'at' alumni.caltech.edu)
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. Approved by the EGL Working Group on March 3, 2010.
3302f4aeb0Sopenharmony_ci    Approved by the Khronos Board of Promoters on April 30, 2010.
3402f4aeb0Sopenharmony_ci
3502f4aeb0Sopenharmony_ciVersion
3602f4aeb0Sopenharmony_ci
3702f4aeb0Sopenharmony_ci    Version 24, January 31, 2014
3802f4aeb0Sopenharmony_ci
3902f4aeb0Sopenharmony_ciNumber
4002f4aeb0Sopenharmony_ci
4102f4aeb0Sopenharmony_ci    EGL Extension #20
4202f4aeb0Sopenharmony_ci    OpenGL ES Extension #75
4302f4aeb0Sopenharmony_ci    OpenVG Extension #7
4402f4aeb0Sopenharmony_ci
4502f4aeb0Sopenharmony_ciDependencies
4602f4aeb0Sopenharmony_ci
4702f4aeb0Sopenharmony_ci    Requires EGL 1.1
4802f4aeb0Sopenharmony_ci
4902f4aeb0Sopenharmony_ci    This extension is written against the wording of the EGL 1.2
5002f4aeb0Sopenharmony_ci    Specification.
5102f4aeb0Sopenharmony_ci
5202f4aeb0Sopenharmony_ciOverview
5302f4aeb0Sopenharmony_ci
5402f4aeb0Sopenharmony_ci    This extension introduces the concept of "sync objects" into EGL.
5502f4aeb0Sopenharmony_ci    Sync objects are a synchronization primitive, representing events
5602f4aeb0Sopenharmony_ci    whose completion can be tested or waited upon.  This extension
5702f4aeb0Sopenharmony_ci    borrows heavily from the GL_ARB_sync extension and introduces a type
5802f4aeb0Sopenharmony_ci    of sync object known as a "fence sync object" comparable to the
5902f4aeb0Sopenharmony_ci    OpenGL fence sync object. The specification is designed to allow
6002f4aeb0Sopenharmony_ci    additional types of sync objects to be easily introduced in later
6102f4aeb0Sopenharmony_ci    extensions.
6202f4aeb0Sopenharmony_ci
6302f4aeb0Sopenharmony_ci    Fence sync objects have corresponding fence commands, which are
6402f4aeb0Sopenharmony_ci    inserted into a client API command stream at the time the fence sync
6502f4aeb0Sopenharmony_ci    is created. A fence sync object is used to wait for completion of
6602f4aeb0Sopenharmony_ci    the corresponding fence command. This allows applications to request
6702f4aeb0Sopenharmony_ci    a partial Finish of an API command stream, wherein all commands
6802f4aeb0Sopenharmony_ci    issued in a particular client API context will be forced to complete
6902f4aeb0Sopenharmony_ci    before control is returned to the calling thread.
7002f4aeb0Sopenharmony_ci
7102f4aeb0Sopenharmony_ci    This document describes three different extension strings
7202f4aeb0Sopenharmony_ci    collectively. The "EGL_KHR_fence_sync" string indicates that fence
7302f4aeb0Sopenharmony_ci    syncs and the corresponding interfaces (to create and place a fence,
7402f4aeb0Sopenharmony_ci    destroy, query, and wait on) are supported.
7502f4aeb0Sopenharmony_ci
7602f4aeb0Sopenharmony_ci    The remaining extensions list valid client APIs for fence syncs. The
7702f4aeb0Sopenharmony_ci    "GL_OES_EGL_sync" string indicates that a fence sync object can be
7802f4aeb0Sopenharmony_ci    created in association with a fence command placed in the command
7902f4aeb0Sopenharmony_ci    stream of a bound OpenGL ES context. The "VG_KHR_EGL_sync" string
8002f4aeb0Sopenharmony_ci    indicates the same thing for a bound OpenVG context.
8102f4aeb0Sopenharmony_ci
8202f4aeb0Sopenharmony_ciNew Types
8302f4aeb0Sopenharmony_ci
8402f4aeb0Sopenharmony_ci    /*
8502f4aeb0Sopenharmony_ci     * EGLSyncKHR is an opaque handle to an EGL sync object
8602f4aeb0Sopenharmony_ci     */
8702f4aeb0Sopenharmony_ci    typedef void* EGLSyncKHR;
8802f4aeb0Sopenharmony_ci
8902f4aeb0Sopenharmony_ci    /*
9002f4aeb0Sopenharmony_ci     * EGLTimeKHR is a 64-bit unsigned integer representing intervals
9102f4aeb0Sopenharmony_ci     * in nanoseconds.
9202f4aeb0Sopenharmony_ci     */
9302f4aeb0Sopenharmony_ci    #include <khrplatform.h>
9402f4aeb0Sopenharmony_ci    typedef khronos_utime_nanoseconds_t EGLTimeKHR;
9502f4aeb0Sopenharmony_ci
9602f4aeb0Sopenharmony_ci
9702f4aeb0Sopenharmony_ciNew Procedures and Functions
9802f4aeb0Sopenharmony_ci
9902f4aeb0Sopenharmony_ci    EGLSyncKHR eglCreateSyncKHR(
10002f4aeb0Sopenharmony_ci                        EGLDisplay dpy,
10102f4aeb0Sopenharmony_ci                        EGLenum type,
10202f4aeb0Sopenharmony_ci                        const EGLint *attrib_list);
10302f4aeb0Sopenharmony_ci
10402f4aeb0Sopenharmony_ci    EGLBoolean eglDestroySyncKHR(
10502f4aeb0Sopenharmony_ci                        EGLDisplay dpy,
10602f4aeb0Sopenharmony_ci                        EGLSyncKHR sync);
10702f4aeb0Sopenharmony_ci
10802f4aeb0Sopenharmony_ci    EGLint eglClientWaitSyncKHR(
10902f4aeb0Sopenharmony_ci                        EGLDisplay dpy,
11002f4aeb0Sopenharmony_ci                        EGLSyncKHR sync,
11102f4aeb0Sopenharmony_ci                        EGLint flags,
11202f4aeb0Sopenharmony_ci                        EGLTimeKHR timeout);
11302f4aeb0Sopenharmony_ci
11402f4aeb0Sopenharmony_ci    EGLBoolean eglGetSyncAttribKHR(
11502f4aeb0Sopenharmony_ci                        EGLDisplay dpy,
11602f4aeb0Sopenharmony_ci                        EGLSyncKHR sync,
11702f4aeb0Sopenharmony_ci                        EGLint attribute,
11802f4aeb0Sopenharmony_ci                        EGLint *value);
11902f4aeb0Sopenharmony_ci
12002f4aeb0Sopenharmony_ci
12102f4aeb0Sopenharmony_ciNew Tokens
12202f4aeb0Sopenharmony_ci
12302f4aeb0Sopenharmony_ci    Accepted by the <type> parameter of eglCreateSyncKHR, and returned
12402f4aeb0Sopenharmony_ci    in <value> when eglGetSyncAttribKHR is called with <attribute>
12502f4aeb0Sopenharmony_ci    EGL_SYNC_TYPE_KHR:
12602f4aeb0Sopenharmony_ci
12702f4aeb0Sopenharmony_ci    EGL_SYNC_FENCE_KHR                      0x30F9
12802f4aeb0Sopenharmony_ci
12902f4aeb0Sopenharmony_ci    Accepted by the <attribute> parameter of eglGetSyncAttribKHR:
13002f4aeb0Sopenharmony_ci
13102f4aeb0Sopenharmony_ci    EGL_SYNC_TYPE_KHR                       0x30F7
13202f4aeb0Sopenharmony_ci    EGL_SYNC_STATUS_KHR                     0x30F1
13302f4aeb0Sopenharmony_ci    EGL_SYNC_CONDITION_KHR                  0x30F8
13402f4aeb0Sopenharmony_ci
13502f4aeb0Sopenharmony_ci    Returned in <value> when eglGetSyncAttribKHR is called with
13602f4aeb0Sopenharmony_ci    <attribute> EGL_SYNC_STATUS_KHR:
13702f4aeb0Sopenharmony_ci
13802f4aeb0Sopenharmony_ci    EGL_SIGNALED_KHR                        0x30F2
13902f4aeb0Sopenharmony_ci    EGL_UNSIGNALED_KHR                      0x30F3
14002f4aeb0Sopenharmony_ci
14102f4aeb0Sopenharmony_ci    Returned in <value> when eglGetSyncAttribKHR is called with
14202f4aeb0Sopenharmony_ci    <attribute> EGL_SYNC_CONDITION_KHR:
14302f4aeb0Sopenharmony_ci
14402f4aeb0Sopenharmony_ci    EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR    0x30F0
14502f4aeb0Sopenharmony_ci
14602f4aeb0Sopenharmony_ci    Accepted in the <flags> parameter of eglClientWaitSyncKHR:
14702f4aeb0Sopenharmony_ci
14802f4aeb0Sopenharmony_ci    EGL_SYNC_FLUSH_COMMANDS_BIT_KHR         0x0001
14902f4aeb0Sopenharmony_ci
15002f4aeb0Sopenharmony_ci    Accepted in the <timeout> parameter of eglClientWaitSyncKHR:
15102f4aeb0Sopenharmony_ci
15202f4aeb0Sopenharmony_ci    EGL_FOREVER_KHR                         0xFFFFFFFFFFFFFFFFull
15302f4aeb0Sopenharmony_ci
15402f4aeb0Sopenharmony_ci    Returned by eglClientWaitSyncKHR:
15502f4aeb0Sopenharmony_ci
15602f4aeb0Sopenharmony_ci    EGL_TIMEOUT_EXPIRED_KHR                 0x30F5
15702f4aeb0Sopenharmony_ci    EGL_CONDITION_SATISFIED_KHR             0x30F6
15802f4aeb0Sopenharmony_ci
15902f4aeb0Sopenharmony_ci    Returned by eglCreateSyncKHR in the event of an error:
16002f4aeb0Sopenharmony_ci
16102f4aeb0Sopenharmony_ci    EGL_NO_SYNC_KHR                         ((EGLSyncKHR)0)
16202f4aeb0Sopenharmony_ci
16302f4aeb0Sopenharmony_ciChanges to Chapter 3 of the EGL 1.2 Specification (EGL Functions and Errors)
16402f4aeb0Sopenharmony_ci
16502f4aeb0Sopenharmony_ci    Add a new subsection at the end of Section 3.8, page 43
16602f4aeb0Sopenharmony_ci    (Synchronization Primitives)
16702f4aeb0Sopenharmony_ci
16802f4aeb0Sopenharmony_ci    "3.8.1  Sync Objects
16902f4aeb0Sopenharmony_ci
17002f4aeb0Sopenharmony_ci    In addition to the aforementioned synchronization functions, which
17102f4aeb0Sopenharmony_ci    provide an efficient means of serializing client and native API
17202f4aeb0Sopenharmony_ci    operations within a thread, <sync objects> are provided to enable
17302f4aeb0Sopenharmony_ci    synchronization of client API operations between threads and/or
17402f4aeb0Sopenharmony_ci    between API contexts. Sync objects may be tested or waited upon by
17502f4aeb0Sopenharmony_ci    application threads.
17602f4aeb0Sopenharmony_ci
17702f4aeb0Sopenharmony_ci    Sync objects have a status with two possible states: <signaled> and
17802f4aeb0Sopenharmony_ci    <unsignaled>. Initially, sync objects are unsignaled. EGL may be
17902f4aeb0Sopenharmony_ci    asked to wait for a sync object to become signaled, or a sync
18002f4aeb0Sopenharmony_ci    object's status may be queried.
18102f4aeb0Sopenharmony_ci
18202f4aeb0Sopenharmony_ci    Depending on the type of a sync object, its status may be changed
18302f4aeb0Sopenharmony_ci    either by an external event, or by explicitly signaling and
18402f4aeb0Sopenharmony_ci    unsignaling the sync.
18502f4aeb0Sopenharmony_ci
18602f4aeb0Sopenharmony_ci    Sync objects are associated with an EGLDisplay when they are
18702f4aeb0Sopenharmony_ci    created, and have <attributes> defining additional aspects of the
18802f4aeb0Sopenharmony_ci    sync object. All sync objects include attributes for their type and
18902f4aeb0Sopenharmony_ci    their status. Additional attributes are discussed below
19002f4aeb0Sopenharmony_ci    for different types of sync objects.
19102f4aeb0Sopenharmony_ci
19202f4aeb0Sopenharmony_ci    <Fence sync objects> are created in association with a <fence
19302f4aeb0Sopenharmony_ci    command> in a client API. When the client API executes the fence
19402f4aeb0Sopenharmony_ci    command, an event is generated which signals the corresponding fence
19502f4aeb0Sopenharmony_ci    sync object. Fence sync objects may not be explicitly signaled, and
19602f4aeb0Sopenharmony_ci    may only change their status once, from the initial unsignaled
19702f4aeb0Sopenharmony_ci    status to signaled. Fence sync objects may be used to wait for
19802f4aeb0Sopenharmony_ci    partial completion of a client API command stream, as a more
19902f4aeb0Sopenharmony_ci    flexible form of glFinish / vgFinish.
20002f4aeb0Sopenharmony_ci
20102f4aeb0Sopenharmony_ci    The command
20202f4aeb0Sopenharmony_ci
20302f4aeb0Sopenharmony_ci        EGLSyncKHR eglCreateSyncKHR(
20402f4aeb0Sopenharmony_ci                            EGLDisplay dpy,
20502f4aeb0Sopenharmony_ci                            EGLenum type,
20602f4aeb0Sopenharmony_ci                            const EGLint *attrib_list);
20702f4aeb0Sopenharmony_ci
20802f4aeb0Sopenharmony_ci    creates a sync object of the specified <type> associated with the
20902f4aeb0Sopenharmony_ci    specified display <dpy>, and returns a handle to the new object.
21002f4aeb0Sopenharmony_ci    <attrib_list> is an attribute-value list specifying other attributes
21102f4aeb0Sopenharmony_ci    of the sync object, terminated by an attribute entry EGL_NONE.
21202f4aeb0Sopenharmony_ci    Attributes not specified in the list will be assigned their default
21302f4aeb0Sopenharmony_ci    values.
21402f4aeb0Sopenharmony_ci
21502f4aeb0Sopenharmony_ci    If <type> is EGL_SYNC_FENCE_KHR, a fence sync object is created. In
21602f4aeb0Sopenharmony_ci    this case <attrib_list> must be NULL or empty (containing only
21702f4aeb0Sopenharmony_ci    EGL_NONE). Attributes of the fence sync object are
21802f4aeb0Sopenharmony_ci    set as follows:
21902f4aeb0Sopenharmony_ci
22002f4aeb0Sopenharmony_ci      Attribute Name         Initial Attribute Value(s)
22102f4aeb0Sopenharmony_ci      ---------------        --------------------------
22202f4aeb0Sopenharmony_ci      EGL_SYNC_TYPE_KHR      EGL_SYNC_FENCE_KHR
22302f4aeb0Sopenharmony_ci      EGL_SYNC_STATUS_KHR    EGL_UNSIGNALED_KHR
22402f4aeb0Sopenharmony_ci      EGL_SYNC_CONDITION_KHR EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR
22502f4aeb0Sopenharmony_ci
22602f4aeb0Sopenharmony_ci    When a fence sync object is created, eglCreateSyncKHR also inserts a
22702f4aeb0Sopenharmony_ci    fence command into the command stream of the bound client API's
22802f4aeb0Sopenharmony_ci    current context (i.e., the context returned by
22902f4aeb0Sopenharmony_ci    eglGetCurrentContext), and associates it with the newly created sync
23002f4aeb0Sopenharmony_ci    object.
23102f4aeb0Sopenharmony_ci
23202f4aeb0Sopenharmony_ci    When the condition of the sync object is satisfied by the fence
23302f4aeb0Sopenharmony_ci    command, the sync is signaled by the associated client API context,
23402f4aeb0Sopenharmony_ci    causing any eglClientWaitSyncKHR commands (see below) blocking on
23502f4aeb0Sopenharmony_ci    <sync> to unblock. The only condition currently supported is
23602f4aeb0Sopenharmony_ci    EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR, which is satisfied by
23702f4aeb0Sopenharmony_ci    completion of the fence command corresponding to the sync object,
23802f4aeb0Sopenharmony_ci    and all preceding commands in the associated client API context's
23902f4aeb0Sopenharmony_ci    command stream. The sync object will not be signaled until all
24002f4aeb0Sopenharmony_ci    effects from these commands on the client API's internal and
24102f4aeb0Sopenharmony_ci    framebuffer state are fully realized. No other state is affected by
24202f4aeb0Sopenharmony_ci    execution of the fence command.
24302f4aeb0Sopenharmony_ci
24402f4aeb0Sopenharmony_ci    Each client API which supports fence commands indicates this support
24502f4aeb0Sopenharmony_ci    in the form of a client API extension. If the GL_OES_EGL_sync
24602f4aeb0Sopenharmony_ci    extension is supported by OpenGL ES (either version 1.x or 2.0), a
24702f4aeb0Sopenharmony_ci    fence sync object may be created when the currently bound API is
24802f4aeb0Sopenharmony_ci    OpenGL ES. If the VG_KHR_EGL_sync extension is supported by OpenVG,
24902f4aeb0Sopenharmony_ci    a fence sync object may be created when the currently bound API is
25002f4aeb0Sopenharmony_ci    OpenVG.
25102f4aeb0Sopenharmony_ci
25202f4aeb0Sopenharmony_ci    Errors
25302f4aeb0Sopenharmony_ci    ------
25402f4aeb0Sopenharmony_ci
25502f4aeb0Sopenharmony_ci      * If <dpy> is not the name of a valid, initialized EGLDisplay,
25602f4aeb0Sopenharmony_ci        EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
25702f4aeb0Sopenharmony_ci        generated.
25802f4aeb0Sopenharmony_ci      * If <attrib_list> is neither NULL nor empty (containing only
25902f4aeb0Sopenharmony_ci        EGL_NONE), EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE
26002f4aeb0Sopenharmony_ci        error is generated.
26102f4aeb0Sopenharmony_ci      * If <type> is not a supported type of sync object,
26202f4aeb0Sopenharmony_ci        EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
26302f4aeb0Sopenharmony_ci        generated.
26402f4aeb0Sopenharmony_ci      * If <type> is EGL_SYNC_FENCE_KHR and no context is current for
26502f4aeb0Sopenharmony_ci        the bound API (i.e., eglGetCurrentContext returns
26602f4aeb0Sopenharmony_ci        EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
26702f4aeb0Sopenharmony_ci        EGL_BAD_MATCH error is generated.
26802f4aeb0Sopenharmony_ci      * If <type> is EGL_SYNC_FENCE_KHR and <dpy> does not match the
26902f4aeb0Sopenharmony_ci        EGLDisplay of the currently bound context for the currently
27002f4aeb0Sopenharmony_ci        bound client API (the EGLDisplay returned by
27102f4aeb0Sopenharmony_ci        eglGetCurrentDisplay()) then EGL_NO_SYNC_KHR is returned and an
27202f4aeb0Sopenharmony_ci        EGL_BAD_MATCH error is generated.
27302f4aeb0Sopenharmony_ci      * If <type> is EGL_SYNC_FENCE_KHR and the currently bound client
27402f4aeb0Sopenharmony_ci        API does not support the client API extension indicating it can
27502f4aeb0Sopenharmony_ci        place fence commands, then EGL_NO_SYNC_KHR is returned and an
27602f4aeb0Sopenharmony_ci        EGL_BAD_MATCH error is generated.
27702f4aeb0Sopenharmony_ci
27802f4aeb0Sopenharmony_ci    The command
27902f4aeb0Sopenharmony_ci
28002f4aeb0Sopenharmony_ci        EGLint eglClientWaitSyncKHR(
28102f4aeb0Sopenharmony_ci                            EGLDisplay dpy,
28202f4aeb0Sopenharmony_ci                            EGLSyncKHR sync,
28302f4aeb0Sopenharmony_ci                            EGLint flags,
28402f4aeb0Sopenharmony_ci                            EGLTimeKHR timeout);
28502f4aeb0Sopenharmony_ci
28602f4aeb0Sopenharmony_ci    blocks the calling thread until the specified sync object <sync> is
28702f4aeb0Sopenharmony_ci    signaled, or until <timeout> nanoseconds have passed.
28802f4aeb0Sopenharmony_ci
28902f4aeb0Sopenharmony_ci    More than one eglClientWaitSyncKHR may be outstanding on the same
29002f4aeb0Sopenharmony_ci    <sync> at any given time. When there are multiple threads blocked on
29102f4aeb0Sopenharmony_ci    the same <sync> and the sync object is signaled, all such threads
29202f4aeb0Sopenharmony_ci    are released, but the order in which they are released is not
29302f4aeb0Sopenharmony_ci    defined.
29402f4aeb0Sopenharmony_ci
29502f4aeb0Sopenharmony_ci    If the value of <timeout> is zero, then eglClientWaitSyncKHR simply
29602f4aeb0Sopenharmony_ci    tests the current status of <sync>. If the value of <timeout> is the
29702f4aeb0Sopenharmony_ci    special value EGL_FOREVER_KHR, then eglClientWaitSyncKHR does not
29802f4aeb0Sopenharmony_ci    time out. For all other values, <timeout> is adjusted to the closest
29902f4aeb0Sopenharmony_ci    value allowed by the implementation-dependent timeout accuracy,
30002f4aeb0Sopenharmony_ci    which may be substantially longer than one nanosecond.
30102f4aeb0Sopenharmony_ci
30202f4aeb0Sopenharmony_ci    eglClientWaitSyncKHR returns one of three status values describing
30302f4aeb0Sopenharmony_ci    the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR
30402f4aeb0Sopenharmony_ci    indicates that the specified timeout period expired before <sync>
30502f4aeb0Sopenharmony_ci    was signaled, or if <timeout> is zero, indicates that <sync> is
30602f4aeb0Sopenharmony_ci    not signaled. A return value of EGL_CONDITION_SATISFIED_KHR
30702f4aeb0Sopenharmony_ci    indicates that <sync> was signaled before the timeout expired, which
30802f4aeb0Sopenharmony_ci    includes the case when <sync> was already signaled when
30902f4aeb0Sopenharmony_ci    eglClientWaitSyncKHR was called. If an error occurs then an error is
31002f4aeb0Sopenharmony_ci    generated and EGL_FALSE is returned.
31102f4aeb0Sopenharmony_ci
31202f4aeb0Sopenharmony_ci    If the sync object being blocked upon will not be signaled in finite
31302f4aeb0Sopenharmony_ci    time (for example, by an associated fence command issued previously,
31402f4aeb0Sopenharmony_ci    but not yet flushed to the graphics pipeline), then
31502f4aeb0Sopenharmony_ci    eglClientWaitSyncKHR may wait forever. To help prevent this behavior
31602f4aeb0Sopenharmony_ci    (footnote1), if the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR bit is set in
31702f4aeb0Sopenharmony_ci    <flags>, and <sync> is unsignaled when eglClientWaitSyncKHR is
31802f4aeb0Sopenharmony_ci    called, then the equivalent of Flush() will be performed for the
31902f4aeb0Sopenharmony_ci    current API context (i.e., the context returned by
32002f4aeb0Sopenharmony_ci    eglGetCurrentContext()) before blocking on <sync>. If no context is
32102f4aeb0Sopenharmony_ci    current for the bound API, the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR bit
32202f4aeb0Sopenharmony_ci    is ignored.
32302f4aeb0Sopenharmony_ci
32402f4aeb0Sopenharmony_ci       [footnote 1: The simple Flush behavior defined by
32502f4aeb0Sopenharmony_ci        EGL_SYNC_FLUSH_COMMANDS_BIT_KHR will not help when waiting for a
32602f4aeb0Sopenharmony_ci        fence command issued in a different context's command stream.
32702f4aeb0Sopenharmony_ci        Applications which block on a fence sync object must take
32802f4aeb0Sopenharmony_ci        additional steps to ensure that the context from which the
32902f4aeb0Sopenharmony_ci        associated fence command was issued has flushed that command to
33002f4aeb0Sopenharmony_ci        the graphics pipeline.]
33102f4aeb0Sopenharmony_ci
33202f4aeb0Sopenharmony_ci    Errors
33302f4aeb0Sopenharmony_ci    ------
33402f4aeb0Sopenharmony_ci
33502f4aeb0Sopenharmony_ci      * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is
33602f4aeb0Sopenharmony_ci        returned and an EGL_BAD_PARAMETER error is generated.
33702f4aeb0Sopenharmony_ci      * If <dpy> does not match the EGLDisplay passed to
33802f4aeb0Sopenharmony_ci        eglCreateSyncKHR when <sync> was created, the behaviour is
33902f4aeb0Sopenharmony_ci        undefined.
34002f4aeb0Sopenharmony_ci
34102f4aeb0Sopenharmony_ci
34202f4aeb0Sopenharmony_ci    The command
34302f4aeb0Sopenharmony_ci
34402f4aeb0Sopenharmony_ci        EGLBoolean eglGetSyncAttribKHR(
34502f4aeb0Sopenharmony_ci                            EGLDisplay dpy,
34602f4aeb0Sopenharmony_ci                            EGLSyncKHR sync,
34702f4aeb0Sopenharmony_ci                            EGLint attribute,
34802f4aeb0Sopenharmony_ci                            EGLint *value);
34902f4aeb0Sopenharmony_ci
35002f4aeb0Sopenharmony_ci    is used to query attributes of the sync object <sync>. Legal values
35102f4aeb0Sopenharmony_ci    for <attribute> depend on the type of sync object, as shown in table
35202f4aeb0Sopenharmony_ci    3.cc. Assuming no errors are generated, EGL_TRUE is returned and the
35302f4aeb0Sopenharmony_ci    value of the queried attribute is returned in <value>.
35402f4aeb0Sopenharmony_ci
35502f4aeb0Sopenharmony_ci    Attribute              Description                Supported Sync Objects
35602f4aeb0Sopenharmony_ci    -----------------      -----------------------    ----------------------
35702f4aeb0Sopenharmony_ci    EGL_SYNC_TYPE_KHR      Type of the sync object    All
35802f4aeb0Sopenharmony_ci    EGL_SYNC_STATUS_KHR    Status of the sync object  All
35902f4aeb0Sopenharmony_ci    EGL_SYNC_CONDITION_KHR Signaling condition        EGL_SYNC_FENCE_KHR only
36002f4aeb0Sopenharmony_ci
36102f4aeb0Sopenharmony_ci    Table 3.cc  Attributes Accepted by eglGetSyncAttribKHR Command
36202f4aeb0Sopenharmony_ci
36302f4aeb0Sopenharmony_ci    Errors
36402f4aeb0Sopenharmony_ci    ------
36502f4aeb0Sopenharmony_ci
36602f4aeb0Sopenharmony_ci      * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is
36702f4aeb0Sopenharmony_ci        returned and an EGL_BAD_PARAMETER error is generated.
36802f4aeb0Sopenharmony_ci      * If <dpy> does not match the display passed to eglCreateSyncKHR
36902f4aeb0Sopenharmony_ci        when <sync> was created, the behaviour is undefined.
37002f4aeb0Sopenharmony_ci      * If <attribute> is not one of the attributes in table 3.cc,
37102f4aeb0Sopenharmony_ci        EGL_FALSE is returned and an EGL_BAD_ATTRIBUTE error is
37202f4aeb0Sopenharmony_ci        generated.
37302f4aeb0Sopenharmony_ci      * If <attribute> is not supported for the type of sync object
37402f4aeb0Sopenharmony_ci        passed in <sync>, EGL_FALSE is returned and an EGL_BAD_MATCH
37502f4aeb0Sopenharmony_ci        error is generated.
37602f4aeb0Sopenharmony_ci
37702f4aeb0Sopenharmony_ci    If any error occurs, <*value> is not modified.
37802f4aeb0Sopenharmony_ci
37902f4aeb0Sopenharmony_ci    The command
38002f4aeb0Sopenharmony_ci
38102f4aeb0Sopenharmony_ci        EGLBoolean eglDestroySyncKHR(
38202f4aeb0Sopenharmony_ci                            EGLDisplay dpy,
38302f4aeb0Sopenharmony_ci                            EGLSyncKHR sync);
38402f4aeb0Sopenharmony_ci
38502f4aeb0Sopenharmony_ci    is used to destroy an existing sync object.
38602f4aeb0Sopenharmony_ci
38702f4aeb0Sopenharmony_ci    If any eglClientWaitSyncKHR commands are blocking on <sync> when
38802f4aeb0Sopenharmony_ci    eglDestroySyncKHR is called, <sync> is flagged for deletion and will
38902f4aeb0Sopenharmony_ci    be deleted when it is no longer associated with any fence command
39002f4aeb0Sopenharmony_ci    and is no longer blocking any eglClientWaitSyncKHR command.
39102f4aeb0Sopenharmony_ci
39202f4aeb0Sopenharmony_ci    If no errors are generated, EGL_TRUE is returned, and <sync> will no
39302f4aeb0Sopenharmony_ci    longer be the handle of a valid sync object.
39402f4aeb0Sopenharmony_ci
39502f4aeb0Sopenharmony_ci    Errors
39602f4aeb0Sopenharmony_ci    ------
39702f4aeb0Sopenharmony_ci
39802f4aeb0Sopenharmony_ci      * If <sync> is not a valid sync object for <dpy>, EGL_FALSE is
39902f4aeb0Sopenharmony_ci        returned and an EGL_BAD_PARAMETER error is generated.
40002f4aeb0Sopenharmony_ci      * If <dpy> does not match the display passed to eglCreateSyncKHR
40102f4aeb0Sopenharmony_ci        when <sync> was created, the behaviour is undefined.
40202f4aeb0Sopenharmony_ci
40302f4aeb0Sopenharmony_ciIssues
40402f4aeb0Sopenharmony_ci
40502f4aeb0Sopenharmony_ci    Note about the Issues
40602f4aeb0Sopenharmony_ci    ---------------------
40702f4aeb0Sopenharmony_ci    The wording for this extension was originally written as a single
40802f4aeb0Sopenharmony_ci    extension defining two types of sync object; a "reusable sync
40902f4aeb0Sopenharmony_ci    object" and a "fence sync object". That extension was split to
41002f4aeb0Sopenharmony_ci    produce standalone extensions for each type of sync object, and
41102f4aeb0Sopenharmony_ci    references to the other type removed from the specification
41202f4aeb0Sopenharmony_ci    language. This issues list has been simplied to remove references to
41302f4aeb0Sopenharmony_ci    reusable sync objects but is otherwise very similar to the
41402f4aeb0Sopenharmony_ci    EGL_KHR_reusable_sync extension issues list.
41502f4aeb0Sopenharmony_ci
41602f4aeb0Sopenharmony_ci    1. [REMOVED - found in the reusable_sync extension.]
41702f4aeb0Sopenharmony_ci
41802f4aeb0Sopenharmony_ci    2. [REMOVED - found in the reusable_sync extension.]
41902f4aeb0Sopenharmony_ci
42002f4aeb0Sopenharmony_ci    3. What does this extension provide that can not be accomplished
42102f4aeb0Sopenharmony_ci    with the existing, more efficient eglWaitClient and eglWaitNative
42202f4aeb0Sopenharmony_ci    API functions?
42302f4aeb0Sopenharmony_ci
42402f4aeb0Sopenharmony_ci    RESPONSE: eglWaitClient and eglWaitNative may be implemented in
42502f4aeb0Sopenharmony_ci    extremely lightweight manners, in some cases not blocking the
42602f4aeb0Sopenharmony_ci    calling thread at all; however, they can not be used to synchronize
42702f4aeb0Sopenharmony_ci    between client API contexts and native APIs executing in separate
42802f4aeb0Sopenharmony_ci    threads (or simply between client API contexts executing in separate
42902f4aeb0Sopenharmony_ci    threads), such as between a thread with an active OpenGL context and
43002f4aeb0Sopenharmony_ci    a second thread performing video decode.
43102f4aeb0Sopenharmony_ci
43202f4aeb0Sopenharmony_ci    4. What does this extension provide that could not be accomplished
43302f4aeb0Sopenharmony_ci    with native platform synchronization primitives and the existing
43402f4aeb0Sopenharmony_ci    client API Finish commands?
43502f4aeb0Sopenharmony_ci
43602f4aeb0Sopenharmony_ci    RESPONSE: This extension provides a lighter-weight mechanism for
43702f4aeb0Sopenharmony_ci    synchronizing an application with client API command streams than
43802f4aeb0Sopenharmony_ci    the all-or-nothing Finish commands, enabling applications to block
43902f4aeb0Sopenharmony_ci    until a subset of issued client API commands have completed.
44002f4aeb0Sopenharmony_ci
44102f4aeb0Sopenharmony_ci    5. [REMOVED - found in the reusable_sync extension.]
44202f4aeb0Sopenharmony_ci
44302f4aeb0Sopenharmony_ci    6. Please provide a more detailed description of how
44402f4aeb0Sopenharmony_ci    eglClientWaitSyncKHR behaves.
44502f4aeb0Sopenharmony_ci
44602f4aeb0Sopenharmony_ci    RESOLVED: eglClientWaitSyncKHR blocks until the status of the sync
44702f4aeb0Sopenharmony_ci    object transitions to the signaled state. Sync object status is
44802f4aeb0Sopenharmony_ci    either signaled or unsignaled. More detailed rules describing
44902f4aeb0Sopenharmony_ci    signalling follow (these may need to be imbedded into the actual
45002f4aeb0Sopenharmony_ci    spec language):
45102f4aeb0Sopenharmony_ci
45202f4aeb0Sopenharmony_ci      * A fence sync object has two possible status values: signaled or
45302f4aeb0Sopenharmony_ci        unsignaled.
45402f4aeb0Sopenharmony_ci      * When created, the status of the sync object is unsignaled.
45502f4aeb0Sopenharmony_ci      * A fence command is inserted into a command stream. A fence sync
45602f4aeb0Sopenharmony_ci        object is not.
45702f4aeb0Sopenharmony_ci      * A fence command, once its condition has been met, will set its
45802f4aeb0Sopenharmony_ci        associated sync object to the signaled state. The only condition
45902f4aeb0Sopenharmony_ci        currently supported is EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR.
46002f4aeb0Sopenharmony_ci      * A wait function, such as ClientWaitSyncKHR, waits on a fence
46102f4aeb0Sopenharmony_ci        sync object, not on a fence command.
46202f4aeb0Sopenharmony_ci      * A wait function called on a sync object in the unsignaled state
46302f4aeb0Sopenharmony_ci        will block. It unblocks (note, not "returns to the application")
46402f4aeb0Sopenharmony_ci        when the sync object transitions to the signaled state.
46502f4aeb0Sopenharmony_ci      * A wait function called on a sync object in the signaled state
46602f4aeb0Sopenharmony_ci        will return immediately.
46702f4aeb0Sopenharmony_ci
46802f4aeb0Sopenharmony_ci    7. [REMOVED - found in the reusable_sync extension.]
46902f4aeb0Sopenharmony_ci
47002f4aeb0Sopenharmony_ci    8. [REMOVED - found in the reusable_sync extension.]
47102f4aeb0Sopenharmony_ci
47202f4aeb0Sopenharmony_ci    9. Should eglDestroySyncKHR release all WaitSyncs placed on a fence
47302f4aeb0Sopenharmony_ci    sync object?
47402f4aeb0Sopenharmony_ci
47502f4aeb0Sopenharmony_ci    RESOLVED: No. (note that this behavior differs from reusable syncs.)
47602f4aeb0Sopenharmony_ci
47702f4aeb0Sopenharmony_ci    Fence sync objects are intended to be signalled by the graphics
47802f4aeb0Sopenharmony_ci    driver within a short period of time (typically less than 1 second
47902f4aeb0Sopenharmony_ci    after creation) and so should not cause waiting threads to hang
48002f4aeb0Sopenharmony_ci    forever. To reduce implementation complexity, fence sync objects are
48102f4aeb0Sopenharmony_ci    defined to not release waiting threads; waiting threads are released
48202f4aeb0Sopenharmony_ci    normally when their condition is satisfied or their timeout expires.
48302f4aeb0Sopenharmony_ci    The handle to a fence sync object immediately becomes invalid
48402f4aeb0Sopenharmony_ci    following a call to eglDestroySyncKHR.
48502f4aeb0Sopenharmony_ci
48602f4aeb0Sopenharmony_ciRevision History
48702f4aeb0Sopenharmony_ci
48802f4aeb0Sopenharmony_ci#24 (Jon Leech, January 31, 2014)
48902f4aeb0Sopenharmony_ci    - Clarify return value of ClientWaitSyncKHR when called with <timeout>
49002f4aeb0Sopenharmony_ci      of zero for an unsignaled <sync> (Bug 11576).
49102f4aeb0Sopenharmony_ci#23 (Jon Leech, April 23, 2013)
49202f4aeb0Sopenharmony_ci    - Simplify issues list to remove issues specific to reusable sync
49302f4aeb0Sopenharmony_ci      objects and general sync object design issues.
49402f4aeb0Sopenharmony_ci#22 (Jon Leech, June 15, 2010)
49502f4aeb0Sopenharmony_ci    - Correct minor typos in GL/VG extension names.
49602f4aeb0Sopenharmony_ci#21 (Jon Leech, May 5, 2010)
49702f4aeb0Sopenharmony_ci    - Correct minor typos, assign extension numbers for EGL, OpenGL ES,
49802f4aeb0Sopenharmony_ci      and OpenVG, and publish in the registry,
49902f4aeb0Sopenharmony_ci#20 (Robert Palmer, July 14, 2009)
50002f4aeb0Sopenharmony_ci    - Branch wording from draft KHR_sync specification. Remove ability
50102f4aeb0Sopenharmony_ci      to create "reusable sync objects and all tokens/wording specific
50202f4aeb0Sopenharmony_ci      to them.
50302f4aeb0Sopenharmony_ci#19 (Robert Palmer, July 22, 2009)
50402f4aeb0Sopenharmony_ci    - Replace specific eglCreateSyncKHR error cases for bad <type>
50502f4aeb0Sopenharmony_ci    argument with extensible catch-all case.
50602f4aeb0Sopenharmony_ci#18 (Robert Palmer, July 8, 2009)
50702f4aeb0Sopenharmony_ci    - Issues 8 and 9 declared resolved in EGL meeting 2009-07-08
50802f4aeb0Sopenharmony_ci#17 (Robert Palmer, July 8, 2009)
50902f4aeb0Sopenharmony_ci    - Update eglDestroySyncKHR to special-case deletion of fence sync
51002f4aeb0Sopenharmony_ci      objects.  This is explained in issue 9.
51102f4aeb0Sopenharmony_ci    - Corrected EGL_REUSABLE_SYNC_KHR -> EGL_SYNC_REUSABLE_KHR
51202f4aeb0Sopenharmony_ci    - Define value for EGL_SYNC_REUSABLE_KHR
51302f4aeb0Sopenharmony_ci    - Fix typo and whitespace
51402f4aeb0Sopenharmony_ci#16 (Jon Leech, July 7, 2009)
51502f4aeb0Sopenharmony_ci    - Update description of new tokens to match changes to the
51602f4aeb0Sopenharmony_ci      eglCreateSyncKHR entry point in revision 15.
51702f4aeb0Sopenharmony_ci#15 (Jon Leech, June 16, 2009)
51802f4aeb0Sopenharmony_ci    - Define separate one-time fence sync and reusable sync extensions
51902f4aeb0Sopenharmony_ci      and corresponding extension strings. Remove AUTO_RESET and
52002f4aeb0Sopenharmony_ci      eglFenceKHR. Rename eglCreateFenceSyncKHR to eglCreateSyncKHR and
52102f4aeb0Sopenharmony_ci      change initial status of reusable syncs to unsignaled. Clarify
52202f4aeb0Sopenharmony_ci      which functions apply to which types of sync objects. Update
52302f4aeb0Sopenharmony_ci      issues list.
52402f4aeb0Sopenharmony_ci#14 (Jon Leech, April 29, 2009)
52502f4aeb0Sopenharmony_ci    - Clarify that all waiters are woken up on signalling a sync.
52602f4aeb0Sopenharmony_ci      Remove tabs to cleanup some formatting issues.
52702f4aeb0Sopenharmony_ci#13 (Acorn Pooley, April 2, 2009)
52802f4aeb0Sopenharmony_ci    - Renamed
52902f4aeb0Sopenharmony_ci        GL_OES_egl_sync -> GL_OES_EGL_sync
53002f4aeb0Sopenharmony_ci        VG_KHR_egl_sync -> VG_KHR_EGL_sync
53102f4aeb0Sopenharmony_ci#12 (Jon Leech, April 1, 2009)
53202f4aeb0Sopenharmony_ci    - Changed sync flags type from EGLuint to EGLint and add issue 7.
53302f4aeb0Sopenharmony_ci#11 (Acorn Pooley, February 4, 2009)
53402f4aeb0Sopenharmony_ci    - add error case to eglGetSyncAttribKHR.
53502f4aeb0Sopenharmony_ci    - fix year on rev 8-10 (2008->2009)
53602f4aeb0Sopenharmony_ci#10 (Acorn Pooley, February 4, 2009)
53702f4aeb0Sopenharmony_ci    - clarify some error message descriptions
53802f4aeb0Sopenharmony_ci#9  (Greg Prisament, January 15, 2009)
53902f4aeb0Sopenharmony_ci    - Destroy now wakes up all waits (eglClientWaitSyncKHR)
54002f4aeb0Sopenharmony_ci    - Add EGLDisplay <dpy> as first parameter to all commands
54102f4aeb0Sopenharmony_ci    - Split into 3 extension strings, EGL_KHR_sync, GL_OES_egl_sync,
54202f4aeb0Sopenharmony_ci      VG_KHR_egl_sync, all described in this document.
54302f4aeb0Sopenharmony_ci    - Add attribute AUTO_RESET_KHR
54402f4aeb0Sopenharmony_ci    - Time type uses the type from khrplatform.h
54502f4aeb0Sopenharmony_ci    - Remove EGL_ALREADY_SIGNALLED
54602f4aeb0Sopenharmony_ci#8  (Jon Leech, November 11, 2009)
54702f4aeb0Sopenharmony_ci   - Assign enum values
54802f4aeb0Sopenharmony_ci#7   (Acorn Pooley, October 30, 2008)
54902f4aeb0Sopenharmony_ci   - Fix typos
55002f4aeb0Sopenharmony_ci   - remove obsolete wording about Native sync objects (see issue 5)
55102f4aeb0Sopenharmony_ci   - formatting: remove tabs, 80 columns
55202f4aeb0Sopenharmony_ci#6   (Acorn Pooley, October 27, 2008)
55302f4aeb0Sopenharmony_ci   - Corrected 'enum' to 'EGLenum' in prototypes.
55402f4aeb0Sopenharmony_ci#5   (Jon Leech, September 9, 2008)
55502f4aeb0Sopenharmony_ci   - Removed native sync support (eglCreateNativeSyncKHR and
55602f4aeb0Sopenharmony_ci     EGL_SYNC_NATIVE_SYNC_KHR), and re-flowed spec to fit in 80 columns.
55702f4aeb0Sopenharmony_ci#4   (Jon Leech, November 20, 2007)
55802f4aeb0Sopenharmony_ci   - Corrected 'enum' to 'EGLenum' in prototypes.
55902f4aeb0Sopenharmony_ci#3   (Jon Leech, April 5, 2007)
56002f4aeb0Sopenharmony_ci   - Added draft Status and TBD Number
56102f4aeb0Sopenharmony_ci#2   (November 27, 2006)
56202f4aeb0Sopenharmony_ci   - Changed OES token to KHR
563