15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    APPLE_fence
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_APPLE_fence
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Geoff Stahl, Apple (gstahl 'at' apple.com)
125bd8deadSopenharmony_ci
135bd8deadSopenharmony_ciStatus
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ci    Shipping as of August 24, 2002 (Mac OS X v10.2)
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ciVersion
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    $Date: 2002/08/23 00:31:45 $ $Revision: 1.3 $
205bd8deadSopenharmony_ci	
215bd8deadSopenharmony_ciNumber
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    272
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciDependencies
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    None
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciOverview
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    This extension is provided a finer granularity of synchronizing GL command
325bd8deadSopenharmony_ci    completion than offered by standard OpenGL, which currently offers only two
335bd8deadSopenharmony_ci    mechanisms for synchronization: Flush and Finish. Since Flush merely assures
345bd8deadSopenharmony_ci    the user that the commands complete in a finite (though undetermined) amount
355bd8deadSopenharmony_ci    of time, it is, thus, of only modest utility.  Finish, on the other hand,
365bd8deadSopenharmony_ci    stalls CPU execution until all pending GL commands have completed forcing
375bd8deadSopenharmony_ci    completely synchronous operation, which most often not the desired result.
385bd8deadSopenharmony_ci    This extension offers a middle ground - the ability to "finish" a subset of
395bd8deadSopenharmony_ci    the command stream, and the ability to determine whether a given command has
405bd8deadSopenharmony_ci    completed or not.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ci    This extension introduces the concept of a "fence" to the OpenGL command
435bd8deadSopenharmony_ci    stream with SetFenceAPPLE.  Once the fence is inserted into the command
445bd8deadSopenharmony_ci    stream, it can be tested for its completion with TestFenceAPPLE. Moreover,
455bd8deadSopenharmony_ci    the application may also request a partial Finish up to a particular "fence"
465bd8deadSopenharmony_ci    using the FinishFenceAPPLE command -- that is, all commands prior to the
475bd8deadSopenharmony_ci    fence will be forced to complete until control is returned to the calling
485bd8deadSopenharmony_ci    process.  These new mechanisms allow for synchronization between the host
495bd8deadSopenharmony_ci    CPU and the GPU, which may be accessing the same resources (typically
505bd8deadSopenharmony_ci    memory).
515bd8deadSopenharmony_ci
525bd8deadSopenharmony_ci    Fences are created and deleted, as are other objects in OpenGL, specifically
535bd8deadSopenharmony_ci    with GenFencesAPPLE and DeleteFencesAPPLE.  The former returns a list of
545bd8deadSopenharmony_ci    unused fence names and the later deletes the provided list of fence names.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ci    In addition to being able to test or finish a fence this extension allows
575bd8deadSopenharmony_ci    testing for other types of completion, including texture objects, vertex
585bd8deadSopenharmony_ci    array objects, and draw pixels. This allows the client to use
595bd8deadSopenharmony_ci    TestObjectAPPLE or FinishObjectAPPLE with FENCE_APPLE, TEXTURE,
605bd8deadSopenharmony_ci    VERTEX_ARRAY, or DRAW_PIXELS_APPLE with the same type of results as
615bd8deadSopenharmony_ci    TestFenceAPPLE and FinishFenceAPPLE.  Specifically, using the FENCE_APPLE
625bd8deadSopenharmony_ci    type is equivalent to calling TestFenceAPPLE or FinishFenceAPPLE with the
635bd8deadSopenharmony_ci    particular fence name.  Using TEXTURE as the object type tests or waits for
645bd8deadSopenharmony_ci    completion of a specific texture, meaning when there are no pending
655bd8deadSopenharmony_ci    rendering commands which use that texture object. Using the VERTEX_ARRAY
665bd8deadSopenharmony_ci    type will test or wait for drawing commands using that particular vertex
675bd8deadSopenharmony_ci    array object name.  Finally, DRAW_PIXELS_APPLE will wait or test for
685bd8deadSopenharmony_ci    completion of all pending DrawPixels commands.  These tests and finishes
695bd8deadSopenharmony_ci    operate with the same limitations and results as test and finish fence.
705bd8deadSopenharmony_ci
715bd8deadSopenharmony_ci    One use of this extension is in conjunction with APPLE_vertex_array_range to
725bd8deadSopenharmony_ci    determine when graphics hardware has completed accessing vertex data from a
735bd8deadSopenharmony_ci    vertex array range.  Once a fence has been tested TRUE or finished, all
745bd8deadSopenharmony_ci    vertex indices issued before the fence must have completed being accessed.
755bd8deadSopenharmony_ci    This ensures that the vertex data memory corresponding to the issued vertex
765bd8deadSopenharmony_ci    indices can be safely modified (assuming no other outstanding vertex indices
775bd8deadSopenharmony_ci    are issued subsequent to the fence).
785bd8deadSopenharmony_ci    
795bd8deadSopenharmony_ciIssues
805bd8deadSopenharmony_ci
815bd8deadSopenharmony_ci	How is TestObjectAPPLE or FinishObjectAPPLE used with DRAW_PIXELS_APPLE?
825bd8deadSopenharmony_ci		
835bd8deadSopenharmony_ci		Resolution:  Currently there is no support DrawPixels with storage using
845bd8deadSopenharmony_ci		the APPLE_client_storage extension and thus this option has no utility,
855bd8deadSopenharmony_ci		due to implementation specifics, which always copy the DrawPixels
865bd8deadSopenharmony_ci		buffer, thus allowing the client to immediately modify the data used by
875bd8deadSopenharmony_ci		DrawPixels.  Once the APPLE_client_storage extension is supported,
885bd8deadSopenharmony_ci		DrawPixels modification synchronization will be required after drawing
895bd8deadSopenharmony_ci		with a buffer, which resides in client space.
905bd8deadSopenharmony_ci
915bd8deadSopenharmony_ci    Do we need an IsFenceAPPLE command?
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci        RESOLUTION:  Yes.  IsFenceAPPLE makes APPLE_fence's API orthogonal to
945bd8deadSopenharmony_ci        other OpenGL object interfaces, and can be used as any other Is...
955bd8deadSopenharmony_ci        command would be.
965bd8deadSopenharmony_ci
975bd8deadSopenharmony_ci    Are the fences sharable between multiple contexts?
985bd8deadSopenharmony_ci
995bd8deadSopenharmony_ci        RESOLUTION:  No.
1005bd8deadSopenharmony_ci
1015bd8deadSopenharmony_ci    What is the relative performance of the calls?
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci        Execution of a SetFenceAPPLE is not free.  In the initial
1045bd8deadSopenharmony_ci        implementation, a Flush is generated.  This will likely change for
1055bd8deadSopenharmony_ci        future implementations and should not be depended on.  A Finish will not
1065bd8deadSopenharmony_ci        be generated in any case.
1075bd8deadSopenharmony_ci
1085bd8deadSopenharmony_ci    Is the TestFenceAPPLE call really necessary?  How often would this be used
1095bd8deadSopenharmony_ci    compared to the FinishFenceAPPLE call (which also flushes to ensure this
1105bd8deadSopenharmony_ci    happens in finite time)?
1115bd8deadSopenharmony_ci
1125bd8deadSopenharmony_ci        TestFenceAPPLE allows clients to provide logic to handle
1135bd8deadSopenharmony_ci        synchronization issues rather than forcing completely synchronous
1145bd8deadSopenharmony_ci        operation at the point of testing or finishing.
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci    Should we allow these commands to be compiled within display list?
1175bd8deadSopenharmony_ci    Which ones?  How about within Begin/End pairs?
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci        RESOLUTION:  DeleteFencesAPPLE, GenFencesAPPLE, TestFenceAPPLE,
1205bd8deadSopenharmony_ci        TestObjectAPPLE, and IsFenceAPPLE are executed immediately while
1215bd8deadSopenharmony_ci        FinishFenceAPPLE, FinishObjectAPPLE and SetFenceAPPLE are compiled. 
1225bd8deadSopenharmony_ci        None of these commands are allowed within Begin/End pairs.
1235bd8deadSopenharmony_ci
1245bd8deadSopenharmony_ciNew Procedures and Functions
1255bd8deadSopenharmony_ci
1265bd8deadSopenharmony_ci	void GenFencesAPPLE(sizei n, uint *fences);
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci	void DeleteFencesAPPLE(sizei n, const uint *fences);
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci	void SetFenceAPPLE(uint fence);
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci	boolean IsFenceAPPLE(uint fence);
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci	boolean TestFenceAPPLE(uint fence);
1355bd8deadSopenharmony_ci
1365bd8deadSopenharmony_ci	void FinishFenceAPPLE(uint fence);
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci	boolean TestObjectAPPLE(enum object, uint name);
1395bd8deadSopenharmony_ci
1405bd8deadSopenharmony_ci	void FinishObjectAPPLE(enum object, int name);
1415bd8deadSopenharmony_ci
1425bd8deadSopenharmony_ciNew Tokens
1435bd8deadSopenharmony_ci
1445bd8deadSopenharmony_ci    Accepted by the <object> parameter of TestObjectAPPLE and FinishObjectAPPLE:
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci        DRAW_PIXELS_APPLE                    0x8A0A
1475bd8deadSopenharmony_ci        FENCE_APPLE                          0x8A0B
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
1505bd8deadSopenharmony_ci
1515bd8deadSopenharmony_ci    Add to the end of Section 5.4 "Display Lists"
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ci    "DeleteFencesAPPLE, GenFencesAPPLE, TestFenceAPPLE, IsFenceAPPLE, and
1545bd8deadSopenharmony_ci    TestObjectAPPLE are not complied into display lists but are executed
1555bd8deadSopenharmony_ci    immediately."
1565bd8deadSopenharmony_ci
1575bd8deadSopenharmony_ci    After the discussion of Flush and Finish (Section 5.5) add a
1585bd8deadSopenharmony_ci    description of the fence operations:
1595bd8deadSopenharmony_ci
1605bd8deadSopenharmony_ci    "5.X  Fences
1615bd8deadSopenharmony_ci
1625bd8deadSopenharmony_ci    The command 
1635bd8deadSopenharmony_ci
1645bd8deadSopenharmony_ci       void SetFenceAPPLE(uint fence);
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ci    sets a fence within the GL command stream and assigns the fence a status of
1675bd8deadSopenharmony_ci    FALSE. No other state is affected by execution of the fence command.  A
1685bd8deadSopenharmony_ci    fence's state can be queried by calling the command
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci      boolean TestFenceAPPLE(uint fence);
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci    The command
1735bd8deadSopenharmony_ci
1745bd8deadSopenharmony_ci      void FinishFenceAPPLE(uint fence);
1755bd8deadSopenharmony_ci
1765bd8deadSopenharmony_ci    forces all GL commands prior to the fence to complete. FinishFenceAPPLE does
1775bd8deadSopenharmony_ci    not return until all effects from these commands on GL client and server
1785bd8deadSopenharmony_ci    state and the frame buffer are fully realized.
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci    The fence must first be created before it can be used.  The command
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci      void GenFencesAPPLE(sizei n, uint *fences);
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ci    returns n previously unused fence names in fences.  These names are marked
1855bd8deadSopenharmony_ci    as used for the purposes of GenFencesAPPLE only and acquire boolean state
1865bd8deadSopenharmony_ci    only when they have been set.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    Fences are deleted by calling
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci      void DeleteFencesAPPLE(sizei n, const uint *fences);
1915bd8deadSopenharmony_ci
1925bd8deadSopenharmony_ci    fences contains n names of fences to be deleted.  After a fence is deleted,
1935bd8deadSopenharmony_ci    it has no state, and its name is again unused.  Unused names in fences are
1945bd8deadSopenharmony_ci    silently ignored.
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ci    If the fence passed to TestFenceAPPLE or FinishFenceAPPLE is not the name of
1975bd8deadSopenharmony_ci    a fence, the error INVALID_OPERATION is generated.  In this case,
1985bd8deadSopenharmony_ci    TestFenceAPPLE will return TRUE, for the sake of consistency. Note, fences
1995bd8deadSopenharmony_ci    that have note been set prior to calling TestFenceAPPLE or FinishFenceAPPLE
2005bd8deadSopenharmony_ci    act as if the state is TRUE and the fence command has already been
2015bd8deadSopenharmony_ci    completed.  In other words TestFenceAPPLE returns TRUE and FinishFenceAPPLE
2025bd8deadSopenharmony_ci    will not block on fences that have not been set.
2035bd8deadSopenharmony_ci
2045bd8deadSopenharmony_ci    State must be maintained to indicate which fence integers are currently used
2055bd8deadSopenharmony_ci    or set.  In the initial state, no indices are in use. When a fence integer
2065bd8deadSopenharmony_ci    is set, status of the fence is also maintained.  The status is a boolean.
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci    Once the status of a fence has been finished (via FinishFenceAPPLE) or
2095bd8deadSopenharmony_ci    tested and the returned status is TRUE (via TestFenceAPPLE), the status
2105bd8deadSopenharmony_ci    remains TRUE until the next SetFenceAPPLE of the fence.
2115bd8deadSopenharmony_ci    
2125bd8deadSopenharmony_ci    The command
2135bd8deadSopenharmony_ci    
2145bd8deadSopenharmony_ci      boolean TestObjectAPPLE(enum object, uint name);
2155bd8deadSopenharmony_ci    
2165bd8deadSopenharmony_ci    and the command
2175bd8deadSopenharmony_ci
2185bd8deadSopenharmony_ci      void FinishObjectAPPLE(enum object, int name);
2195bd8deadSopenharmony_ci    
2205bd8deadSopenharmony_ci    work in a similar fashion to TestFenceAPPLE and FinishFenceAPPLE but on
2215bd8deadSopenharmony_ci    other types of "objects".  Both of these commands take an object, which can
2225bd8deadSopenharmony_ci    be FENCE_APPLE, TEXTURE, VERTEX_ARRAY, or DRAW_PIXELS_APPLE and an object
2235bd8deadSopenharmony_ci    name. These commands are useful for synchronizing the update of buffers for
2245bd8deadSopenharmony_ci    textures, draw pixels, or vertex arrays, especially when using extensions
2255bd8deadSopenharmony_ci    such as Apple's vertex array range or client storage.
2265bd8deadSopenharmony_ci
2275bd8deadSopenharmony_ci    If the object parameter for TestObjectAPPLE or FinishObjectAPPLE is
2285bd8deadSopenharmony_ci    FENCE_APPLE then these commands work in exactly the same manner as
2295bd8deadSopenharmony_ci    TestFenceAPPLE and FinishFenceAPPLE, respectively.  If the object parameter
2305bd8deadSopenharmony_ci    is TEXTURE then these routines test or finish the use of a texture object,
2315bd8deadSopenharmony_ci    thus FinishObjectAPPLE will block and TestFenceAPPLE will return FALSE while
2325bd8deadSopenharmony_ci    there are pending rendering commands utilizing the texture object in
2335bd8deadSopenharmony_ci    question. If the object parameter is VERTEX_ARRAY, FinishObjectAPPLE will
2345bd8deadSopenharmony_ci    block and TestFenceAPPLE will return FALSE while there are pending rendering
2355bd8deadSopenharmony_ci    commands utilizing the vertex array object in question.  Note, in both these
2365bd8deadSopenharmony_ci    cases object name 0 will work as expected, thus testing or finishing the
2375bd8deadSopenharmony_ci    default texture or vertex array object. If the object parameter is
2385bd8deadSopenharmony_ci    DRAW_PIXELS_APPLE, FinishObjectAPPLE will block and TestFenceAPPLE will
2395bd8deadSopenharmony_ci    return FALSE while there are pending DrawPixels commands.  For all other
2405bd8deadSopenharmony_ci    cases, assuming a valid object type and name are used, FinishObjectAPPLE
2415bd8deadSopenharmony_ci    will return immediately and TestFenceAPPLE will return TRUE.
2425bd8deadSopenharmony_ci
2435bd8deadSopenharmony_ci    INVALID_OPERATION error is generated if FinishObjectAPPLE or TestFenceAPPLE
2445bd8deadSopenharmony_ci    is called with either an invalid object type enumeration or a name, which is
2455bd8deadSopenharmony_ci    not the name of a valid object of the type specified in the object
2465bd8deadSopenharmony_ci    parameter.
2475bd8deadSopenharmony_ci
2485bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.2.1 Specification (State and State Requests)
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    Insert new section after Section 6.1.10 "Minmax Query"
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci    "6.1.11 Fence Query
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci    The command
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci      boolean IsFenceAPPLE(uint fence);
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    returns TRUE if texture is the name of a fence.  If fence is not the name of
2595bd8deadSopenharmony_ci    a fence, or if an error condition occurs, IsFenceAPPLE returns FALSE.  A
2605bd8deadSopenharmony_ci    name returned by GenFencesAPPLE, but not yet set via SetFenceAPPLE, is not
2615bd8deadSopenharmony_ci    the name of a fence.
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ciAdditions to the GLX Specification
2645bd8deadSopenharmony_ci
2655bd8deadSopenharmony_ci    None
2665bd8deadSopenharmony_ci
2675bd8deadSopenharmony_ciGLX Protocol
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ci    None
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ciErrors
2725bd8deadSopenharmony_ci
2735bd8deadSopenharmony_ci    INVALID_VALUE is generated if GenFencesAPPLE parameter <n> is negative.
2745bd8deadSopenharmony_ci
2755bd8deadSopenharmony_ci    INVALID_VALUE is generated if DeleteFencesAPPLE parameter <n> is negative.
2765bd8deadSopenharmony_ci
2775bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the fence used in TestFenceAPPLE or
2785bd8deadSopenharmony_ci    FinishFenceAPPLE is not the name of a fence. 
2795bd8deadSopenharmony_ci    
2805bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the object name used in TestObjectAPPLE or
2815bd8deadSopenharmony_ci    FinishObjectAPPLE is not the name of an object of the type requested in the
2825bd8deadSopenharmony_ci    object parameter.
2835bd8deadSopenharmony_ci
2845bd8deadSopenharmony_ci    INVALID_OPERATION is generated if any of the commands defined in
2855bd8deadSopenharmony_ci    this extension is executed between the execution of Begin and the
2865bd8deadSopenharmony_ci    corresponding execution of End.
2875bd8deadSopenharmony_ci    
2885bd8deadSopenharmony_ci    INVALID_VALUE is generated if DeleteFencesAPPLE or GenFencesAPPLE are
2895bd8deadSopenharmony_ci    called where n is negative.
2905bd8deadSopenharmony_ci
2915bd8deadSopenharmony_ciNew State
2925bd8deadSopenharmony_ci	
2935bd8deadSopenharmony_ci	None
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ciNew Implementation Dependent State
2965bd8deadSopenharmony_ci
2975bd8deadSopenharmony_ci    None
2985bd8deadSopenharmony_ci
2995bd8deadSopenharmony_ciImplementation Details
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci    This section describes implementation-defined limits:
3025bd8deadSopenharmony_ci
3035bd8deadSopenharmony_ci        SetFenceAPPLE calls are not free.  They should be used prudently, and a
3045bd8deadSopenharmony_ci        "good number" of commands should be sent between calls to SetFenceAPPLE.
3055bd8deadSopenharmony_ci        Testing or finishing a fence may cause a Flush if commands up to the
3065bd8deadSopenharmony_ci        fence being tested have not been submitted to the hardware.
3075bd8deadSopenharmony_ci
3085bd8deadSopenharmony_ciRevision History
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci	None
3115bd8deadSopenharmony_ci
312