15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    APPLE_sync
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_APPLE_sync
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Contributors to ARB_sync desktop OpenGL extension from which this 
125bd8deadSopenharmony_ci    extension borrows heavily
135bd8deadSopenharmony_ci    
145bd8deadSopenharmony_ciContact
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ci    Benj Lipchak (lipchak 'at' apple 'dot' com)
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciStatus
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    Complete
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ciVersion
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ci    Last Modified Date: July 10, 2012
255bd8deadSopenharmony_ci    Author Revision: 3
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ciNumber
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ci    OpenGL ES Extension #124
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ciDependencies
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ci    OpenGL ES 1.1 or OpenGL ES 2.0 is required.
345bd8deadSopenharmony_ci    
355bd8deadSopenharmony_ci    This specification is written against the OpenGL ES 2.0.25 specification.
365bd8deadSopenharmony_ci    
375bd8deadSopenharmony_ci    EXT_debug_label affects the definition of this extension.
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ciOverview
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ci    This extension introduces the concept of "sync objects". Sync
425bd8deadSopenharmony_ci    objects are a synchronization primitive - a representation of events
435bd8deadSopenharmony_ci    whose completion status can be tested or waited upon. One specific
445bd8deadSopenharmony_ci    type of sync object, the "fence sync object", is supported in this
455bd8deadSopenharmony_ci    extension, and additional types can easily be added in the future.
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    Fence sync objects have corresponding fences, which are inserted
485bd8deadSopenharmony_ci    into the OpenGL command stream at the time the sync object is
495bd8deadSopenharmony_ci    created. A sync object can be queried for a given condition. The
505bd8deadSopenharmony_ci    only condition supported for fence sync objects is completion of the
515bd8deadSopenharmony_ci    corresponding fence command. Fence completion allows applications to
525bd8deadSopenharmony_ci    request a partial Finish, wherein all commands prior to the fence
535bd8deadSopenharmony_ci    will be forced to complete before control is returned to the calling
545bd8deadSopenharmony_ci    process.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    These new mechanisms allow for synchronization between the host CPU
575bd8deadSopenharmony_ci    and the GPU, which may be accessing the same resources (typically
585bd8deadSopenharmony_ci    memory), as well as between multiple GL contexts bound to multiple
595bd8deadSopenharmony_ci    threads in the host CPU.
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ciNew Types
625bd8deadSopenharmony_ci
635bd8deadSopenharmony_ci    (Implementer's Note: GLint64 and GLuint64 are defined as appropriate
645bd8deadSopenharmony_ci    for an ISO C 99 compiler. Other language bindings, or non-ISO
655bd8deadSopenharmony_ci    compilers, may need to use a different approach).
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    #include <inttypes.h>
685bd8deadSopenharmony_ci    typedef int64_t GLint64;
695bd8deadSopenharmony_ci    typedef uint64_t GLuint64;
705bd8deadSopenharmony_ci    typedef struct __GLsync *GLsync;
715bd8deadSopenharmony_ci
725bd8deadSopenharmony_ciNew Procedures and Functions
735bd8deadSopenharmony_ci
745bd8deadSopenharmony_ci    sync FenceSyncAPPLE(enum condition, bitfield flags);
755bd8deadSopenharmony_ci    boolean IsSyncAPPLE(sync sync);
765bd8deadSopenharmony_ci    void DeleteSyncAPPLE(sync sync);
775bd8deadSopenharmony_ci
785bd8deadSopenharmony_ci    enum ClientWaitSyncAPPLE(sync sync, bitfield flags, uint64 timeout);
795bd8deadSopenharmony_ci    void WaitSyncAPPLE(sync sync, bitfield flags, uint64 timeout);
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci    void GetInteger64vAPPLE(enum pname, int64 *params);
825bd8deadSopenharmony_ci    void GetSyncivAPPLE(sync sync, enum pname, sizei bufSize, sizei *length,
835bd8deadSopenharmony_ci        int *values);
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ciNew Tokens
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci    Accepted as the <pname> parameter of GetInteger64vAPPLE:
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ci        MAX_SERVER_WAIT_TIMEOUT_APPLE        0x9111
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    Accepted as the <pname> parameter of GetSyncivAPPLE:
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci        OBJECT_TYPE_APPLE                    0x9112
945bd8deadSopenharmony_ci        SYNC_CONDITION_APPLE                 0x9113
955bd8deadSopenharmony_ci        SYNC_STATUS_APPLE                    0x9114
965bd8deadSopenharmony_ci        SYNC_FLAGS_APPLE                     0x9115
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ci    Returned in <values> for GetSynciv <pname> OBJECT_TYPE_APPLE:
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci        SYNC_FENCE_APPLE                     0x9116
1015bd8deadSopenharmony_ci
1025bd8deadSopenharmony_ci    Returned in <values> for GetSyncivAPPLE <pname> SYNC_CONDITION_APPLE:
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci        SYNC_GPU_COMMANDS_COMPLETE_APPLE     0x9117
1055bd8deadSopenharmony_ci
1065bd8deadSopenharmony_ci    Returned in <values> for GetSyncivAPPLE <pname> SYNC_STATUS_APPLE:
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci        UNSIGNALED_APPLE                     0x9118
1095bd8deadSopenharmony_ci        SIGNALED_APPLE                       0x9119
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci    Accepted in the <flags> parameter of ClientWaitSyncAPPLE:
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ci        SYNC_FLUSH_COMMANDS_BIT_APPLE        0x00000001
1145bd8deadSopenharmony_ci
1155bd8deadSopenharmony_ci    Accepted in the <timeout> parameter of WaitSyncAPPLE:
1165bd8deadSopenharmony_ci
1175bd8deadSopenharmony_ci        TIMEOUT_IGNORED_APPLE                0xFFFFFFFFFFFFFFFFull
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    Returned by ClientWaitSyncAPPLE:
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci        ALREADY_SIGNALED_APPLE               0x911A
1225bd8deadSopenharmony_ci        TIMEOUT_EXPIRED_APPLE                0x911B
1235bd8deadSopenharmony_ci        CONDITION_SATISFIED_APPLE            0x911C
1245bd8deadSopenharmony_ci        WAIT_FAILED_APPLE                    0x911D
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci    Accepted by the <type> parameter of LabelObjectEXT and 
1275bd8deadSopenharmony_ci    GetObjectLabelEXT:
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci        SYNC_OBJECT_APPLE                    0x8A53
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL ES Operation)
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci    Add to Table 2.2, GL data types:
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci   "GL Type  Minimum    Description
1375bd8deadSopenharmony_ci             Bit Width
1385bd8deadSopenharmony_ci    -------  ---------  ----------------------------------------------
1395bd8deadSopenharmony_ci    int64    64         Signed 2's complement binary integer
1405bd8deadSopenharmony_ci    uint64   64         Unsigned binary integer
1415bd8deadSopenharmony_ci    sync     <ptrbits>  Sync object handle (see section 5.2)"
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 2.0 Specification (Special Functions)
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci    Insert a new section following "Flush and Finish" (Section 5.1)
1475bd8deadSopenharmony_ci    describing sync objects and fence operation. Renumber existing
1485bd8deadSopenharmony_ci    section 5.2 "Hints" and all following 5.* sections.
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ci   "5.2 Sync Objects and Fences
1515bd8deadSopenharmony_ci    ---------------------------
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci    Sync objects act as a <synchronization primitive> - a representation
1545bd8deadSopenharmony_ci    of events whose completion status can be tested or waited upon. Sync
1555bd8deadSopenharmony_ci    objects may be used for synchronization with operations occuring in
1565bd8deadSopenharmony_ci    the GL state machine or in the graphics pipeline, and for
1575bd8deadSopenharmony_ci    synchronizing between multiple graphics contexts, among other
1585bd8deadSopenharmony_ci    purposes.
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci    Sync objects have a status value with two possible states:
1615bd8deadSopenharmony_ci    <signaled> and <unsignaled>. Events are associated with a sync
1625bd8deadSopenharmony_ci    object. When a sync object is created, its status is set to
1635bd8deadSopenharmony_ci    unsignaled. When the associated event occurs, the sync object is
1645bd8deadSopenharmony_ci    signaled (its status is set to signaled). The GL may be asked to 
1655bd8deadSopenharmony_ci    wait for a sync object to become signaled.
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    Initially, only one specific type of sync object is defined: the
1685bd8deadSopenharmony_ci    fence sync object, whose associated event is triggered by a fence
1695bd8deadSopenharmony_ci    command placed in the GL command stream. Fence sync objects are used
1705bd8deadSopenharmony_ci    to wait for partial completion of the GL command stream, as a more
1715bd8deadSopenharmony_ci    flexible form of Finish.
1725bd8deadSopenharmony_ci
1735bd8deadSopenharmony_ci    The command
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci    sync FenceSyncAPPLE(enum condition, bitfield flags);
1765bd8deadSopenharmony_ci
1775bd8deadSopenharmony_ci    creates a new fence sync object, inserts a fence command in the GL
1785bd8deadSopenharmony_ci    command stream and associates it with that sync object, and returns
1795bd8deadSopenharmony_ci    a non-zero name corresponding to the sync object.
1805bd8deadSopenharmony_ci
1815bd8deadSopenharmony_ci    When the specified <condition> of the sync object is satisfied by
1825bd8deadSopenharmony_ci    the fence command, the sync object is signaled by the GL, causing
1835bd8deadSopenharmony_ci    any ClientWaitSyncAPPLE or WaitSyncAPPLE commands (see below) blocking 
1845bd8deadSopenharmony_ci    on <sync> to <unblock>. No other state is affected by FenceSyncAPPLE 
1855bd8deadSopenharmony_ci    or by execution of the associated fence command.
1865bd8deadSopenharmony_ci
1875bd8deadSopenharmony_ci    <condition> must be SYNC_GPU_COMMANDS_COMPLETE_APPLE. This condition 
1885bd8deadSopenharmony_ci    is satisfied by completion of the fence command corresponding to the
1895bd8deadSopenharmony_ci    sync object and all preceding commands in the same command stream.
1905bd8deadSopenharmony_ci    The sync object will not be signaled until all effects from these
1915bd8deadSopenharmony_ci    commands on GL client and server state and the framebuffer are fully
1925bd8deadSopenharmony_ci    realized. Note that completion of the fence command occurs once the
1935bd8deadSopenharmony_ci    state of the corresponding sync object has been changed, but
1945bd8deadSopenharmony_ci    commands waiting on that sync object may not be unblocked until
1955bd8deadSopenharmony_ci    some time after the fence command completes.
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ci    <flags> must be 0[fn1].
1985bd8deadSopenharmony_ci       [fn1: <flags> is a placeholder for anticipated future extensions
1995bd8deadSopenharmony_ci    of fence sync object capabilities.]
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    Each sync object contains a number of <properties> which determine
2025bd8deadSopenharmony_ci    the state of the object and the behavior of any commands associated
2035bd8deadSopenharmony_ci    with it. Each property has a <property name> and <property value>.
2045bd8deadSopenharmony_ci    The initial property values for a sync object created by FenceSyncAPPLE
2055bd8deadSopenharmony_ci    are shown in table 5.props:
2065bd8deadSopenharmony_ci
2075bd8deadSopenharmony_ci    Property Name         Property Value
2085bd8deadSopenharmony_ci    --------------------  ----------------
2095bd8deadSopenharmony_ci    OBJECT_TYPE_APPLE     SYNC_FENCE_APPLE
2105bd8deadSopenharmony_ci    SYNC_CONDITION_APPLE  <condition>
2115bd8deadSopenharmony_ci    SYNC_STATUS_APPLE     UNSIGNALED_APPLE
2125bd8deadSopenharmony_ci    SYNC_FLAGS_APPLE      <flags>
2135bd8deadSopenharmony_ci    --------------------------------------
2145bd8deadSopenharmony_ci    Table 5.props: Initial properties of a
2155bd8deadSopenharmony_ci    sync object created with FenceSyncAPPLE.
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci    Properties of a sync object may be queried with GetSyncivAPPLE (see
2185bd8deadSopenharmony_ci    section 6.1.6). The SYNC_STATUS_APPLE property will be changed to
2195bd8deadSopenharmony_ci    SIGNALED_APPLE when <condition> is satisfied.
2205bd8deadSopenharmony_ci
2215bd8deadSopenharmony_ci    If FenceSyncAPPLE fails to create a sync object, zero will be returned
2225bd8deadSopenharmony_ci    and a GL error will be generated as described. An INVALID_ENUM error
2235bd8deadSopenharmony_ci    is generated if <condition> is not SYNC_GPU_COMMANDS_COMPLETE_APPLE. If
2245bd8deadSopenharmony_ci    <flags> is not zero, an INVALID_VALUE error is generated.
2255bd8deadSopenharmony_ci
2265bd8deadSopenharmony_ci    A sync object can be deleted by passing its name to the command
2275bd8deadSopenharmony_ci
2285bd8deadSopenharmony_ci    void DeleteSyncAPPLE(sync sync);
2295bd8deadSopenharmony_ci
2305bd8deadSopenharmony_ci    If the fence command corresponding to the specified sync object has
2315bd8deadSopenharmony_ci    completed, or if no ClientWaitSyncAPPLE or WaitSyncAPPLE commands are 
2325bd8deadSopenharmony_ci    blocking on <sync>, the object is deleted immediately. Otherwise, <sync> 
2335bd8deadSopenharmony_ci    is flagged for deletion and will be deleted when it is no longer
2345bd8deadSopenharmony_ci    associated with any fence command and is no longer blocking any
2355bd8deadSopenharmony_ci    ClientWaitSyncAPPLE or WaitSyncAPPLE command. In either case, after 
2365bd8deadSopenharmony_ci    returning from DeleteSyncAPPLE the <sync> name is invalid and can no 
2375bd8deadSopenharmony_ci    longer be used to refer to the sync object.
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ci    DeleteSyncAPPLE will silently ignore a <sync> value of zero. An
2405bd8deadSopenharmony_ci    INVALID_VALUE error is generated if <sync> is neither zero nor the
2415bd8deadSopenharmony_ci    name of a sync object.
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci
2445bd8deadSopenharmony_ci    5.2.1 Waiting for Sync Objects
2455bd8deadSopenharmony_ci    ------------------------------
2465bd8deadSopenharmony_ci
2475bd8deadSopenharmony_ci    The command
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci    enum ClientWaitSyncAPPLE(sync sync, bitfield flags, uint64 timeout);
2505bd8deadSopenharmony_ci
2515bd8deadSopenharmony_ci    causes the GL to block, and will not return until the sync object
2525bd8deadSopenharmony_ci    <sync> is signaled, or until the specified <timeout> period expires.
2535bd8deadSopenharmony_ci    <timeout> is in units of nanoseconds. <timeout> is adjusted to the
2545bd8deadSopenharmony_ci    closest value allowed by the implementation-dependent timeout
2555bd8deadSopenharmony_ci    accuracy, which may be substantially longer than one nanosecond, and
2565bd8deadSopenharmony_ci    may be longer than the requested period.
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    If <sync> is signaled at the time ClientWaitSyncAPPLE is called
2595bd8deadSopenharmony_ci    then ClientWaitSyncAPPLE returns immediately. If <sync> is unsignaled 
2605bd8deadSopenharmony_ci    at the time ClientWaitSyncAPPLE is called then ClientWaitSyncAPPLE will 
2615bd8deadSopenharmony_ci    block and will wait up to <timeout> nanoseconds for <sync> to become 
2625bd8deadSopenharmony_ci    signaled. <flags> controls command flushing behavior, and may be
2635bd8deadSopenharmony_ci    SYNC_FLUSH_COMMANDS_BIT_APPLE, as discussed in section 5.2.2.
2645bd8deadSopenharmony_ci
2655bd8deadSopenharmony_ci    ClientWaitSyncAPPLE returns one of four status values. A return value of
2665bd8deadSopenharmony_ci    ALREADY_SIGNALED_APPLE indicates that <sync> was signaled at the time
2675bd8deadSopenharmony_ci    ClientWaitSyncAPPLE was called. ALREADY_SIGNALED_APPLE will always be 
2685bd8deadSopenharmony_ci    returned if <sync> was signaled, even if the value of <timeout> is zero. 
2695bd8deadSopenharmony_ci    A return value of TIMEOUT_EXPIRED_APPLE indicates that the specified 
2705bd8deadSopenharmony_ci    timeout period expired before <sync> was signaled. A return value of
2715bd8deadSopenharmony_ci    CONDITION_SATISFIED_APPLE indicates that <sync> was signaled before the
2725bd8deadSopenharmony_ci    timeout expired. Finally, if an error occurs, in addition to
2735bd8deadSopenharmony_ci    generating a GL error as specified below, ClientWaitSyncAPPLE immediately
2745bd8deadSopenharmony_ci    returns WAIT_FAILED_APPLE without blocking.
2755bd8deadSopenharmony_ci
2765bd8deadSopenharmony_ci    If the value of <timeout> is zero, then ClientWaitSyncAPPLE does not
2775bd8deadSopenharmony_ci    block, but simply tests the current state of <sync>. 
2785bd8deadSopenharmony_ci    TIMEOUT_EXPIRED_APPLE will be returned in this case if <sync> is not 
2795bd8deadSopenharmony_ci    signaled, even though no actual wait was performed.
2805bd8deadSopenharmony_ci
2815bd8deadSopenharmony_ci    If <sync> is not the name of a sync object, an INVALID_VALUE error
2825bd8deadSopenharmony_ci    is generated. If <flags> contains any bits other than
2835bd8deadSopenharmony_ci    SYNC_FLUSH_COMMANDS_BIT_APPLE, an INVALID_VALUE error is generated.
2845bd8deadSopenharmony_ci
2855bd8deadSopenharmony_ci    The command
2865bd8deadSopenharmony_ci
2875bd8deadSopenharmony_ci    void WaitSyncAPPLE(sync sync, bitfield flags, uint64 timeout);
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci    is similar to ClientWaitSyncAPPLE, but instead of blocking and not
2905bd8deadSopenharmony_ci    returning to the application until <sync> is signaled, WaitSyncAPPLE
2915bd8deadSopenharmony_ci    returns immediately, instead causing the GL server [fn2] to block
2925bd8deadSopenharmony_ci    until <sync> is signaled [fn3].
2935bd8deadSopenharmony_ci       [fn2 - the GL server may choose to wait either in the CPU
2945bd8deadSopenharmony_ci    executing server-side code, or in the GPU hardware if it
2955bd8deadSopenharmony_ci    supports this operation.]
2965bd8deadSopenharmony_ci       [fn3 - WaitSyncAPPLE allows applications to continue to queue commands
2975bd8deadSopenharmony_ci    from the client in anticipation of the sync being signalled,
2985bd8deadSopenharmony_ci    increasing client-server parallelism.]
2995bd8deadSopenharmony_ci
3005bd8deadSopenharmony_ci    <sync> has the same meaning as for ClientWaitSyncAPPLE.
3015bd8deadSopenharmony_ci
3025bd8deadSopenharmony_ci    <timeout> must currently be the special value TIMEOUT_IGNORED_APPLE, and
3035bd8deadSopenharmony_ci    is not used. Instead, WaitSyncAPPLE will always wait no longer than an
3045bd8deadSopenharmony_ci    implementation-dependent timeout. The duration of this timeout in
3055bd8deadSopenharmony_ci    nanoseconds may be queried by calling GetInteger64vAPPLE with <value>
3065bd8deadSopenharmony_ci    MAX_SERVER_WAIT_TIMEOUT_APPLE. There is currently no way to determine
3075bd8deadSopenharmony_ci    whether WaitSyncAPPLE unblocked because the timeout expired or because
3085bd8deadSopenharmony_ci    the sync object being waited on was signaled.
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci    <flags> must be 0.
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci    If an error occurs, WaitSyncAPPLE generates a GL error as specified
3135bd8deadSopenharmony_ci    below, and does not cause the GL server to block.
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci    If <sync> is not the name of a sync object, an INVALID_VALUE error
3165bd8deadSopenharmony_ci    is generated. If <timeout> is not TIMEOUT_IGNORED_APPLE, or <flags> 
3175bd8deadSopenharmony_ci    is not zero, an INVALID_VALUE error is generated [fn4].
3185bd8deadSopenharmony_ci       [fn4 - <flags> and <timeout> are placeholders for anticipated future 
3195bd8deadSopenharmony_ci    extensions of sync object capabilities. They must have these reserved 
3205bd8deadSopenharmony_ci    values in order that existing code calling WaitSyncAPPLE operate properly 
3215bd8deadSopenharmony_ci    in the presence of such extensions.]
3225bd8deadSopenharmony_ci
3235bd8deadSopenharmony_ci    Multiple Waiters
3245bd8deadSopenharmony_ci    ----------------
3255bd8deadSopenharmony_ci
3265bd8deadSopenharmony_ci    It is possible for both the GL client to be blocked on a sync object
3275bd8deadSopenharmony_ci    in a ClientWaitSyncAPPLE command, the GL server to be blocked as the
3285bd8deadSopenharmony_ci    result of a previous WaitSyncAPPLE command, and for additional 
3295bd8deadSopenharmony_ci    WaitSyncAPPLE commands to be queued in the GL server, all for a single 
3305bd8deadSopenharmony_ci    sync object. When such a sync object is signaled in this situation, the
3315bd8deadSopenharmony_ci    client will be unblocked, the server will be unblocked, and all such
3325bd8deadSopenharmony_ci    queued WaitSyncAPPLE commands will continue immediately when they are
3335bd8deadSopenharmony_ci    reached.
3345bd8deadSopenharmony_ci
3355bd8deadSopenharmony_ci    See appendix C.2 for more information about blocking on a sync
3365bd8deadSopenharmony_ci    object in multiple GL contexts.
3375bd8deadSopenharmony_ci
3385bd8deadSopenharmony_ci    5.2.2 Signalling
3395bd8deadSopenharmony_ci    ----------------
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    A fence sync object can be in the signaled state only once the
3425bd8deadSopenharmony_ci    corresponding fence command has completed and signaled the sync
3435bd8deadSopenharmony_ci    object.
3445bd8deadSopenharmony_ci
3455bd8deadSopenharmony_ci    If the sync object being blocked upon will not be signaled in finite
3465bd8deadSopenharmony_ci    time (for example, by an associated fence command issued previously,
3475bd8deadSopenharmony_ci    but not yet flushed to the graphics pipeline), then ClientWaitSyncAPPLE
3485bd8deadSopenharmony_ci    may hang forever. To help prevent this behavior [fn5], if the
3495bd8deadSopenharmony_ci    SYNC_FLUSH_COMMANDS_BIT_APPLE bit is set in <flags>, and <sync> is
3505bd8deadSopenharmony_ci    unsignaled when ClientWaitSyncAPPLE is called, then the equivalent of
3515bd8deadSopenharmony_ci    Flush will be performed before blocking on <sync>.
3525bd8deadSopenharmony_ci       [fn5 - The simple flushing behavior defined by
3535bd8deadSopenharmony_ci    SYNC_FLUSH_COMMANDS_BIT_APPLE will not help when waiting for a fence
3545bd8deadSopenharmony_ci    command issued in another context's command stream to complete.
3555bd8deadSopenharmony_ci    Applications which block on a fence sync object must take
3565bd8deadSopenharmony_ci    additional steps to assure that the context from which the
3575bd8deadSopenharmony_ci    corresponding fence command was issued has flushed that command
3585bd8deadSopenharmony_ci    to the graphics pipeline.]
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci    If a sync object is marked for deletion while a client is blocking
3615bd8deadSopenharmony_ci    on that object in a ClientWaitSyncAPPLE command, or a GL server is
3625bd8deadSopenharmony_ci    blocking on that object as a result of a prior WaitSyncAPPLE command,
3635bd8deadSopenharmony_ci    deletion is deferred until the sync object is signaled and all
3645bd8deadSopenharmony_ci    blocked GL clients and servers are unblocked.
3655bd8deadSopenharmony_ci
3665bd8deadSopenharmony_ci    Additional constraints on the use of sync objects are discussed in
3675bd8deadSopenharmony_ci    appendix C.
3685bd8deadSopenharmony_ci
3695bd8deadSopenharmony_ci    State must be maintained to indicate which sync object names are
3705bd8deadSopenharmony_ci    currently in use. The state require for each sync object in use is
3715bd8deadSopenharmony_ci    an integer for the specific type, an integer for the condition, an
3725bd8deadSopenharmony_ci    integer for the flags, and a bit indicating whether the object is
3735bd8deadSopenharmony_ci    signaled or unsignaled. The initial values of sync object state are
3745bd8deadSopenharmony_ci    defined as specified by FenceSyncAPPLE."
3755bd8deadSopenharmony_ci
3765bd8deadSopenharmony_ci    Update the Debug Labels section's last sentence to include 
3775bd8deadSopenharmony_ci    SYNC_OBJECT_APPLE as a value supported for the <type> passed to
3785bd8deadSopenharmony_ci    LabelObjectEXT.
3795bd8deadSopenharmony_ci
3805bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State 
3815bd8deadSopenharmony_ciRequests)
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci    Add GetInteger64vAPPLE to the first list of commands in section 6.1.1
3845bd8deadSopenharmony_ci    "Simple Queries", and change the next sentence to mention the query:
3855bd8deadSopenharmony_ci
3865bd8deadSopenharmony_ci   "There are four commands for obtaining simple state variables:
3875bd8deadSopenharmony_ci
3885bd8deadSopenharmony_ci       ...
3895bd8deadSopenharmony_ci       void GetInteger64vAPPLE(enum value, int64 *data);
3905bd8deadSopenharmony_ci       ...
3915bd8deadSopenharmony_ci
3925bd8deadSopenharmony_ci    The commands obtain boolean, integer, 64-bit integer, or
3935bd8deadSopenharmony_ci    floating-point..."
3945bd8deadSopenharmony_ci
3955bd8deadSopenharmony_ci    Modify the third sentence of section 6.1.2 "Data Conversions":
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ci   "If any of the other simple queries are called, a boolean value of
3985bd8deadSopenharmony_ci    TRUE or FALSE is interpreted as 1 or 0, respectively. If GetIntegerv
3995bd8deadSopenharmony_ci    or GetInteger64vAPPLE are called, a floating-point value is rounded to
4005bd8deadSopenharmony_ci    the nearest integer, unless the value is an RGBA color component..."
4015bd8deadSopenharmony_ci
4025bd8deadSopenharmony_ci    Insert a new subsection following "String Queries" (subsection
4035bd8deadSopenharmony_ci    6.1.5) describing sync object queries. Renumber existing subsection
4045bd8deadSopenharmony_ci    6.1.6 "Buffer Object Queries" and all following 6.1.* subsections.
4055bd8deadSopenharmony_ci
4065bd8deadSopenharmony_ci   "6.1.6 Sync Object Queries
4075bd8deadSopenharmony_ci
4085bd8deadSopenharmony_ci    Properties of sync objects may be queried using the command
4095bd8deadSopenharmony_ci
4105bd8deadSopenharmony_ci    void GetSyncivAPPLE(sync sync, enum pname, sizei bufSize, 
4115bd8deadSopenharmony_ci        sizei *length, int *values);
4125bd8deadSopenharmony_ci
4135bd8deadSopenharmony_ci    The value or values being queried are returned in the parameters
4145bd8deadSopenharmony_ci    <length> and <values>.
4155bd8deadSopenharmony_ci
4165bd8deadSopenharmony_ci    On success, GetSyncivAPPLE replaces up to <bufSize> integers in <values>
4175bd8deadSopenharmony_ci    with the corresponding property values of the object being queried.
4185bd8deadSopenharmony_ci    The actual number of integers replaced is returned in *<length>. If
4195bd8deadSopenharmony_ci    <length> is NULL, no length is returned.
4205bd8deadSopenharmony_ci
4215bd8deadSopenharmony_ci    If <pname> is OBJECT_TYPE_APPLE, a single value representing the specific
4225bd8deadSopenharmony_ci    type of the sync object is placed in <values>. The only type
4235bd8deadSopenharmony_ci    supported is SYNC_FENCE_APPLE.
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci    If <pname> is SYNC_STATUS_APPLE, a single value representing the status of
4265bd8deadSopenharmony_ci    the sync object (SIGNALED_APPLE or UNSIGNALED_APPLE) is placed in <values>.
4275bd8deadSopenharmony_ci
4285bd8deadSopenharmony_ci    If <pname> is SYNC_CONDITION_APPLE, a single value representing the
4295bd8deadSopenharmony_ci    condition of the sync object is placed in <values>. The only
4305bd8deadSopenharmony_ci    condition supported is SYNC_GPU_COMMANDS_COMPLETE_APPLE.
4315bd8deadSopenharmony_ci
4325bd8deadSopenharmony_ci    If <pname> is SYNC_FLAGS_APPLE, a single value representing the flags with
4335bd8deadSopenharmony_ci    which the sync object was created is placed in <values>. No flags
4345bd8deadSopenharmony_ci    are currently supported.
4355bd8deadSopenharmony_ci
4365bd8deadSopenharmony_ci    If <sync> is not the name of a sync object, an INVALID_VALUE error
4375bd8deadSopenharmony_ci    is generated. If <pname> is not one of the values described above,
4385bd8deadSopenharmony_ci    an INVALID_ENUM error is generated. If an error occurs,
4395bd8deadSopenharmony_ci    nothing will be written to <values> or <length>.
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci    The command
4425bd8deadSopenharmony_ci
4435bd8deadSopenharmony_ci    boolean IsSyncAPPLE(sync sync);
4445bd8deadSopenharmony_ci
4455bd8deadSopenharmony_ci    returns TRUE if <sync> is the name of a sync object. If <sync> is
4465bd8deadSopenharmony_ci    not the name of a sync object, or if an error condition occurs,
4475bd8deadSopenharmony_ci    IsSyncAPPLE returns FALSE (note that zero is not the name of a sync
4485bd8deadSopenharmony_ci    object).
4495bd8deadSopenharmony_ci
4505bd8deadSopenharmony_ci    Sync object names immediately become invalid after calling
4515bd8deadSopenharmony_ci    DeleteSyncAPPLE, as discussed in sections 5.2 and D.2, but the underlying
4525bd8deadSopenharmony_ci    sync object will not be deleted until it is no longer associated
4535bd8deadSopenharmony_ci    with any fence command and no longer blocking any *WaitSyncAPPLE command."
4545bd8deadSopenharmony_ci
4555bd8deadSopenharmony_ci    Update the Debug Labels section's last sentence to include 
4565bd8deadSopenharmony_ci    SYNC_OBJECT_APPLE as a value supported for the <type> passed to
4575bd8deadSopenharmony_ci    GetObjectLabelEXT.
4585bd8deadSopenharmony_ci
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ciAdditions to Appendix C (Shared Objects and Multiple Contexts)
4615bd8deadSopenharmony_ci
4625bd8deadSopenharmony_ci    In the third paragraph of the appendix, add "sync objects" to the
4635bd8deadSopenharmony_ci    list of shared state.
4645bd8deadSopenharmony_ci
4655bd8deadSopenharmony_ci    Add "sync objects" to the list of objects in the first sentence of
4665bd8deadSopenharmony_ci    C.1.3.  Append the following to the first paragraph of C.1.3:
4675bd8deadSopenharmony_ci    
4685bd8deadSopenharmony_ci   "A sync object is in use while there is a corresponding fence command 
4695bd8deadSopenharmony_ci    which has not yet completed and signaled the sync object, or while 
4705bd8deadSopenharmony_ci    there are any GL clients and/or servers blocked on the sync object as 
4715bd8deadSopenharmony_ci    a result of ClientWaitSyncAPPLE or WaitSyncAPPLE commands."
4725bd8deadSopenharmony_ci    
4735bd8deadSopenharmony_ci   "C.1.3 Deleted Object and Object Name Lifetimes
4745bd8deadSopenharmony_ci
4755bd8deadSopenharmony_ci    Insert a new section following "Object Deletion Behavior" (section
4765bd8deadSopenharmony_ci    C.1) describing sync object multicontext behavior. Renumber existing
4775bd8deadSopenharmony_ci    section C.2 "Propagating State Changes..." and all following C.*
4785bd8deadSopenharmony_ci    sections.
4795bd8deadSopenharmony_ci
4805bd8deadSopenharmony_ci   "C.2 Sync Objects and Multiple Contexts
4815bd8deadSopenharmony_ci    --------------------------------------
4825bd8deadSopenharmony_ci    
4835bd8deadSopenharmony_ci    When multiple GL clients and/or servers are blocked on a single sync 
4845bd8deadSopenharmony_ci    object and that sync object is signalled, all such blocks are released. 
4855bd8deadSopenharmony_ci    The order in which blocks are released is implementation-dependent."
4865bd8deadSopenharmony_ci
4875bd8deadSopenharmony_ci    Edit the former C.2.1 to read as follows:
4885bd8deadSopenharmony_ci
4895bd8deadSopenharmony_ci   "C.3.1 Determining Completion of Changes to an object
4905bd8deadSopenharmony_ci    ----------------------------------------------------
4915bd8deadSopenharmony_ci
4925bd8deadSopenharmony_ci    The contents of an object T are considered to have been changed once 
4935bd8deadSopenharmony_ci    a command such as described in section C.2 has completed. Completion 
4945bd8deadSopenharmony_ci    of a command [fn6] may be determined either by calling Finish, or by 
4955bd8deadSopenharmony_ci    calling FenceSyncAPPLE and executing a WaitSyncAPPLE command on the 
4965bd8deadSopenharmony_ci    associated sync object. The second method does not require a round trip 
4975bd8deadSopenharmony_ci    to the GL server and may be more efficient, particularly when changes to 
4985bd8deadSopenharmony_ci    T in one context must be known to have completed before executing 
4995bd8deadSopenharmony_ci    commands dependent on those changes in another context.
5005bd8deadSopenharmony_ci        [fn6: The GL already specifies that a single context processes
5015bd8deadSopenharmony_ci    commands in the order they are received. This means that a change to 
5025bd8deadSopenharmony_ci    an object in a context at time <t> must be completed by the time a 
5035bd8deadSopenharmony_ci    command issued in the same context at time <t+1> uses the result of that 
5045bd8deadSopenharmony_ci    change.]"
5055bd8deadSopenharmony_ci
5065bd8deadSopenharmony_ciDependencies on EXT_debug_label
5075bd8deadSopenharmony_ci
5085bd8deadSopenharmony_ci    If EXT_debug_label is not available, omit the updates to Debug label
5095bd8deadSopenharmony_ci    sections of chapters 5 and 6, and omit SYNC_OBJECT_APPLE from Table 6.X.
5105bd8deadSopenharmony_ci
5115bd8deadSopenharmony_ciErrors
5125bd8deadSopenharmony_ci
5135bd8deadSopenharmony_ci    INVALID_VALUE is generated if the <sync> parameter of
5145bd8deadSopenharmony_ci    ClientWaitSyncAPPLE, WaitSyncAPPLE, or GetSyncivAPPLE is not the name
5155bd8deadSopenharmony_ci    of a sync object.
5165bd8deadSopenharmony_ci
5175bd8deadSopenharmony_ci    INVALID_VALUE is generated if the <sync> parameter of DeleteSyncAPPLE
5185bd8deadSopenharmony_ci    is neither zero nor the name of a sync object.
5195bd8deadSopenharmony_ci
5205bd8deadSopenharmony_ci    INVALID_ENUM is generated if the <condition> parameter of FenceSyncAPPLE
5215bd8deadSopenharmony_ci    is not SYNC_GPU_COMMANDS_COMPLETE_APPLE.
5225bd8deadSopenharmony_ci
5235bd8deadSopenharmony_ci    INVALID_VALUE is generated if the <flags> parameter of
5245bd8deadSopenharmony_ci    ClientWaitSyncAPPLE contains bits other than SYNC_FLUSH_COMMANDS_BIT_APPLE, 
5255bd8deadSopenharmony_ci    or if the <flags> parameter of WaitSyncAPPLE is nonzero.
5265bd8deadSopenharmony_ci
5275bd8deadSopenharmony_ci    INVALID_ENUM is generated if the <pname> parameter of GetSyncivAPPLE is
5285bd8deadSopenharmony_ci    neither OBJECT_TYPE_APPLE, SYNC_CONDITION_APPLE, SYNC_FLAGS_APPLE, nor 
5295bd8deadSopenharmony_ci    SYNC_STATUS_APPLE.
5305bd8deadSopenharmony_ci
5315bd8deadSopenharmony_ciNew State
5325bd8deadSopenharmony_ci
5335bd8deadSopenharmony_ciTable 6.X.  Sync Objects.
5345bd8deadSopenharmony_ci
5355bd8deadSopenharmony_ciGet value             Type  Get command        Initial value                     Description            Section
5365bd8deadSopenharmony_ci--------------------  ----  -----------------  --------------------------------  ---------------------  -------
5375bd8deadSopenharmony_ciOBJECT_TYPE_APPLE     Z_1   GetSyncivAPPLE     SYNC_FENCE_APPLE                  Type of sync object    5.2
5385bd8deadSopenharmony_ciSYNC_STATUS_APPLE     Z_2   GetSyncivAPPLE     UNSIGNALED_APPLE                  Sync object status     5.2
5395bd8deadSopenharmony_ciSYNC_CONDITION_APPLE  Z_1   GetSyncivAPPLE     SYNC_GPU_COMMANDS_COMPLETE_APPLE  Sync object condition  5.2
5405bd8deadSopenharmony_ciSYNC_FLAGS_APPLE      Z     GetSyncivAPPLE     SYNC_FLAGS_APPLE                  Sync object flags      5.2
5415bd8deadSopenharmony_ciSYNC_OBJECT_APPLE     0*xc  GetObjectLabelEXT  empty                             Debug label            5.X
5425bd8deadSopenharmony_ci
5435bd8deadSopenharmony_ciNew Implementation Dependent State
5445bd8deadSopenharmony_ci
5455bd8deadSopenharmony_ciTable 40. Implementation Dependent Values (cont.)
5465bd8deadSopenharmony_ci
5475bd8deadSopenharmony_ciGet value           Type  Get command    Min. value  Description       Section
5485bd8deadSopenharmony_ci------------------  ----  -------------  ----------  ----------------  -------
5495bd8deadSopenharmony_ciMAX_SERVER_WAIT_    Z^+   GetInteger64v  0           Maximum WaitSync  5.2
5505bd8deadSopenharmony_ciTIMEOUT_APPLE                                         timeout interval
5515bd8deadSopenharmony_ci
5525bd8deadSopenharmony_ciSample Code
5535bd8deadSopenharmony_ci
5545bd8deadSopenharmony_ci    ... kick off a lengthy GL operation
5555bd8deadSopenharmony_ci    /* Place a fence and associate a fence sync object */
5565bd8deadSopenharmony_ci    GLsyncAPPLE sync = glFenceSyncAPPLE(GLSYNC_GPU_COMMANDS_COMPLETE_APPLE, 0);
5575bd8deadSopenharmony_ci
5585bd8deadSopenharmony_ci    /* Elsewhere, wait for the sync to be signaled */
5595bd8deadSopenharmony_ci
5605bd8deadSopenharmony_ci    /* To wait a specified amount of time (possibly clamped), do
5615bd8deadSopenharmony_ci     * this to convert a time in seconds into nanoseconds:
5625bd8deadSopenharmony_ci     */
5635bd8deadSopenharmony_ci    GLuint64APPLE timeout = num_seconds * ((GLuint64)1000 * 1000 * 1000);
5645bd8deadSopenharmony_ci    glWaitSyncAPPLE(sync, 0, timeout);
5655bd8deadSopenharmony_ci
5665bd8deadSopenharmony_ci    /* Or to determine the maximum possible wait interval and wait
5675bd8deadSopenharmony_ci     * that long, do this instead:
5685bd8deadSopenharmony_ci     */
5695bd8deadSopenharmony_ci    GLuint64APPLE max_timeout;
5705bd8deadSopenharmony_ci    glGetInteger64vAPPLE(GL_MAX_SERVER_WAIT_TIMEOUT_APPLE, &max_timeout);
5715bd8deadSopenharmony_ci    glWaitSyncAPPLE(sync, 0, max_timeout);
5725bd8deadSopenharmony_ci
5735bd8deadSopenharmony_ciIssues
5745bd8deadSopenharmony_ci
5755bd8deadSopenharmony_ci    See ARB_sync issues list: http://www.opengl.org/registry/specs/ARB/sync.txt
5765bd8deadSopenharmony_ci
5775bd8deadSopenharmony_ciRevision History
5785bd8deadSopenharmony_ci
5795bd8deadSopenharmony_ci    Version 3, 2012/07/10 - Add support for debug label extension.
5805bd8deadSopenharmony_ci    Version 2, 2012/06/18 - Correct spec to indicate ES 1.1 may also be okay.
5815bd8deadSopenharmony_ci    Version 1, 2012/06/01 - Conversion from ARB_sync to APPLE_sync for ES.
582