15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    NV_command_list
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_NV_command_list
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContact
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Pierre Boudier, NVIDIA (pboudier 'at' nvidia.com)
125bd8deadSopenharmony_ci    Christoph Kubisch, NVIDIA (ckubisch 'at' nvidia.com)
135bd8deadSopenharmony_ci    Tristan Lorach, NVIDIA (tlorach 'at' nvidia.com)
145bd8deadSopenharmony_ci
155bd8deadSopenharmony_ciContributors
165bd8deadSopenharmony_ci
175bd8deadSopenharmony_ci    Jeff Bolz, NVIDIA
185bd8deadSopenharmony_ci    Corentin Wallez, NVIDIA
195bd8deadSopenharmony_ci    Markus Tavenrath, NVIDIA
205bd8deadSopenharmony_ci    Mark Kilgard, NVIDIA
215bd8deadSopenharmony_ci    Joseph Emmons, NVIDIA
225bd8deadSopenharmony_ci    Thomas Ludwig, MAXON
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ciStatus
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ci    Shipping with NVIDIA driver release 347.88 (March 2015)
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciVersion
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    Last Modified Date: November 3, 2015
315bd8deadSopenharmony_ci    Revision: 6
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciNumber
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    OpenGL Extension #477
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ciDependencies
385bd8deadSopenharmony_ci
395bd8deadSopenharmony_ci    This extension interacts with NV_vertex_buffer_unified_memory.
405bd8deadSopenharmony_ci    
415bd8deadSopenharmony_ci    This extension interacts with NV_uniform_buffer_unified_memory.
425bd8deadSopenharmony_ci    
435bd8deadSopenharmony_ci    This extension interacts with NV_parameter_buffer_object.
445bd8deadSopenharmony_ci    
455bd8deadSopenharmony_ci    This extension interacts with ARB_robust_buffer_access_behavior
465bd8deadSopenharmony_ci    
475bd8deadSopenharmony_ci    This extension interacts with NV_bindless_texture and ARB_bindless_texture
485bd8deadSopenharmony_ci    
495bd8deadSopenharmony_ci    This extension interacts with NV_shader_buffer_load
505bd8deadSopenharmony_ci    
515bd8deadSopenharmony_ci    This extension interacts with ARB_shader_draw_parameters
525bd8deadSopenharmony_ci    
535bd8deadSopenharmony_ci    The extension is written against the OpenGL 4.4 Specification, 
545bd8deadSopenharmony_ci    Compatibility Profile.
555bd8deadSopenharmony_ci
565bd8deadSopenharmony_ciOverview
575bd8deadSopenharmony_ci
585bd8deadSopenharmony_ci    This extension adds a few new features designed to provide very low 
595bd8deadSopenharmony_ci    overhead batching and replay of rendering commands and state changes:
605bd8deadSopenharmony_ci
615bd8deadSopenharmony_ci    - A state object, which stores a pre-validated representation of the
625bd8deadSopenharmony_ci      the state of (almost) the entire pipeline.
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ci    - A more flexible and extensible MultiDrawIndirect (MDI) type of mechanism, using
655bd8deadSopenharmony_ci      a token-based command stream, allowing to setup binding state and emit draw calls.
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    - A set of functions to execute a list of the token-based command streams with state object
685bd8deadSopenharmony_ci      changes interleaved with the streams.
695bd8deadSopenharmony_ci
705bd8deadSopenharmony_ci    - Command lists enabling compilation and reuse of sequences of command
715bd8deadSopenharmony_ci      streams and state object changes.
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci    Because state objects reflect the state of the entire pipeline, it is 
745bd8deadSopenharmony_ci    expected that they can be pre-validated and executed efficiently. It is 
755bd8deadSopenharmony_ci    also expected that when state objects are combined into a command list,
765bd8deadSopenharmony_ci    the command list can diff consecutive state objects to produce a reduced/
775bd8deadSopenharmony_ci    optimized set of state changes specific to that transition.
785bd8deadSopenharmony_ci
795bd8deadSopenharmony_ci    The token-based command stream can also be stored in regular buffer objects
805bd8deadSopenharmony_ci    and therefore be modified by the server itself. This allows more 
815bd8deadSopenharmony_ci    complex work creation than the original MDI approach, which was limited
825bd8deadSopenharmony_ci    to emitting draw calls only.
835bd8deadSopenharmony_ci
845bd8deadSopenharmony_ciNew Procedures and Functions
855bd8deadSopenharmony_ci
865bd8deadSopenharmony_ci    void CreateStatesNV(sizei n, uint *states);
875bd8deadSopenharmony_ci    void DeleteStatesNV(sizei n, const uint *states);
885bd8deadSopenharmony_ci    boolean IsStateNV(uint state);
895bd8deadSopenharmony_ci
905bd8deadSopenharmony_ci    void StateCaptureNV(uint state, enum mode);
915bd8deadSopenharmony_ci
925bd8deadSopenharmony_ci    uint   GetCommandHeaderNV(enum tokenID, uint size);
935bd8deadSopenharmony_ci    ushort GetStageIndexNV(enum shadertype);
945bd8deadSopenharmony_ci    
955bd8deadSopenharmony_ci    void DrawCommandsNV(enum primitiveMode, uint buffer, const intptr* indirects, const sizei* sizes, 
965bd8deadSopenharmony_ci                        uint count);
975bd8deadSopenharmony_ci    void DrawCommandsAddressNV(enum primitiveMode, const uint64* indirects, const sizei* sizes, 
985bd8deadSopenharmony_ci                               uint count);
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    void DrawCommandsStatesNV(uint buffer, const intptr* indirects, const sizei* sizes, 
1015bd8deadSopenharmony_ci                                   const uint* states, const uint* fbos, uint count);
1025bd8deadSopenharmony_ci    void DrawCommandsStatesAddressNV(const uint64* indirects, const sizei* sizes, 
1035bd8deadSopenharmony_ci                                     const uint* states, const uint* fbos, uint count);
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ci    void CreateCommandListsNV(sizei n, uint *lists);
1065bd8deadSopenharmony_ci    void DeleteCommandListsNV(sizei n, const uint *lists);
1075bd8deadSopenharmony_ci    boolean IsCommandListNV(uint list);
1085bd8deadSopenharmony_ci    
1095bd8deadSopenharmony_ci    void ListDrawCommandsStatesClientNV(uint list, uint segment, const void** indirects, 
1105bd8deadSopenharmony_ci                                        const sizei* sizes, const uint* states, const uint* fbos, uint count);
1115bd8deadSopenharmony_ci    
1125bd8deadSopenharmony_ci    void CommandListSegmentsNV(uint list, uint segments);
1135bd8deadSopenharmony_ci    void CompileCommandListNV(uint list);
1145bd8deadSopenharmony_ci    void CallCommandListNV(uint list);
1155bd8deadSopenharmony_ci  
1165bd8deadSopenharmony_ciNew Tokens
1175bd8deadSopenharmony_ci
1185bd8deadSopenharmony_ci    Used in DrawCommandsStates buffer formats, in
1195bd8deadSopenharmony_ci    GetCommandHeaderNV to return the header:
1205bd8deadSopenharmony_ci
1215bd8deadSopenharmony_ci
1225bd8deadSopenharmony_ci      TERMINATE_SEQUENCE_COMMAND_NV                      0x0000
1235bd8deadSopenharmony_ci      NOP_COMMAND_NV                                     0x0001
1245bd8deadSopenharmony_ci      DRAW_ELEMENTS_COMMAND_NV                           0x0002
1255bd8deadSopenharmony_ci      DRAW_ARRAYS_COMMAND_NV                             0x0003
1265bd8deadSopenharmony_ci      DRAW_ELEMENTS_STRIP_COMMAND_NV                     0x0004
1275bd8deadSopenharmony_ci      DRAW_ARRAYS_STRIP_COMMAND_NV                       0x0005
1285bd8deadSopenharmony_ci      DRAW_ELEMENTS_INSTANCED_COMMAND_NV                 0x0006
1295bd8deadSopenharmony_ci      DRAW_ARRAYS_INSTANCED_COMMAND_NV                   0x0007
1305bd8deadSopenharmony_ci      ELEMENT_ADDRESS_COMMAND_NV                         0x0008
1315bd8deadSopenharmony_ci      ATTRIBUTE_ADDRESS_COMMAND_NV                       0x0009
1325bd8deadSopenharmony_ci      UNIFORM_ADDRESS_COMMAND_NV                         0x000a
1335bd8deadSopenharmony_ci      BLEND_COLOR_COMMAND_NV                             0x000b
1345bd8deadSopenharmony_ci      STENCIL_REF_COMMAND_NV                             0x000c
1355bd8deadSopenharmony_ci      LINE_WIDTH_COMMAND_NV                              0x000d
1365bd8deadSopenharmony_ci      POLYGON_OFFSET_COMMAND_NV                          0x000e
1375bd8deadSopenharmony_ci      ALPHA_REF_COMMAND_NV                               0x000f
1385bd8deadSopenharmony_ci      VIEWPORT_COMMAND_NV                                0x0010
1395bd8deadSopenharmony_ci      SCISSOR_COMMAND_NV                                 0x0011
1405bd8deadSopenharmony_ci      FRONT_FACE_COMMAND_NV                              0x0012
1415bd8deadSopenharmony_ci          
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 4.4 (Compatibility) Specification
1445bd8deadSopenharmony_ci(Shared Objects and Multiple Contexts)
1455bd8deadSopenharmony_ci
1465bd8deadSopenharmony_ci    Add state objects and command lists to the set of objects that can not be 
1475bd8deadSopenharmony_ci    shared between contexts.
1485bd8deadSopenharmony_ci    
1495bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL 4.4 (Compatibility) Specification
1505bd8deadSopenharmony_ci(Shared Objects and Multiple Contexts)
1515bd8deadSopenharmony_ci
1525bd8deadSopenharmony_ci    Modify Section 7.12.2, Shader Memory Access Synchronization
1535bd8deadSopenharmony_ci    
1545bd8deadSopenharmony_ci    (modify list of barrier bits)
1555bd8deadSopenharmony_ci    
1565bd8deadSopenharmony_ci    * COMMAND_BARRIER_BIT: Command data sourced from buffer objects by
1575bd8deadSopenharmony_ci      Draw*Indirect, DispatchComputeIndirect and DrawCommands*NV commands 
1585bd8deadSopenharmony_ci      after the barrier will reflect data written by shaders prior to the 
1595bd8deadSopenharmony_ci      barrier. The buffer objects affected by this bit are derived from the
1605bd8deadSopenharmony_ci      DRAW_INDIRECT_BUFFER and DISPATCH_INDIRECT_BUFFER bindings, or 
1615bd8deadSopenharmony_ci      from the arguments passed to DrawCommands*NV.
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ciAdditions to Chapter 10 of the OpenGL 4.4 (Compatibility) Specification 
1645bd8deadSopenharmony_ci(Drawing Commands)
1655bd8deadSopenharmony_ci
1665bd8deadSopenharmony_ciAdd a new Section 10.X (Indirect Draw Commands With State Changes)
1675bd8deadSopenharmony_ci
1685bd8deadSopenharmony_ciAdd a new subsection 10.X.1 (State Objects)
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ci    The current state of the rendering pipeline can be captured into a state 
1715bd8deadSopenharmony_ci    object for later reuse with a new set of drawing commands. The name space
1725bd8deadSopenharmony_ci    for state objects is the unsigned integers, with zero reserved. The 
1735bd8deadSopenharmony_ci    command:
1745bd8deadSopenharmony_ci
1755bd8deadSopenharmony_ci        void CreateStatesNV(sizei n, uint *states);
1765bd8deadSopenharmony_ci
1775bd8deadSopenharmony_ci    returns <n> previously unused state object names in <states>, and creates
1785bd8deadSopenharmony_ci    a state object in the initial state for each name.
1795bd8deadSopenharmony_ci
1805bd8deadSopenharmony_ci    State objects are deleted by calling
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci        void DeleteStatesNV(sizei n, const uint *states);
1835bd8deadSopenharmony_ci
1845bd8deadSopenharmony_ci    <states> contains <n> names of state objects to be deleted. Once a state
1855bd8deadSopenharmony_ci    object is deleted it has no contents and its name is again unused. Unused 
1865bd8deadSopenharmony_ci    names in <states> are silently ignored, as is the value zero.
1875bd8deadSopenharmony_ci
1885bd8deadSopenharmony_ci    All the states that can be set via DrawCommandsStatesNV (as defined in 
1895bd8deadSopenharmony_ci    Section 10.X.2) are excluded from the captured state and will be inherited 
1905bd8deadSopenharmony_ci    from the most recent commands or GL context state. Binding state is, however,
1915bd8deadSopenharmony_ci    never inherited from GL context, only from commands.
1925bd8deadSopenharmony_ci
1935bd8deadSopenharmony_ci    
1945bd8deadSopenharmony_ci    The command 
1955bd8deadSopenharmony_ci    
1965bd8deadSopenharmony_ci        void StateCaptureNV(uint state, enum basicmode);
1975bd8deadSopenharmony_ci
1985bd8deadSopenharmony_ci    captures the current state of the rendering pipeline into the object 
1995bd8deadSopenharmony_ci    indicated by <state>. <basicmode> indicates the basic Begin mode that this
2005bd8deadSopenharmony_ci    state object must be used with, see Table 10.X.1.2 for compatibility
2015bd8deadSopenharmony_ci    between primitive modes and basic modes.
2025bd8deadSopenharmony_ci  
2035bd8deadSopenharmony_ci        Table 10.X.1.2 (Primitive mode compatibility)
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci        basic primitive mode        | compatible primitive mode
2065bd8deadSopenharmony_ci        ---------------------------------------------------------------------
2075bd8deadSopenharmony_ci        POINTS                      | POINTS
2085bd8deadSopenharmony_ci        LINES                       | LINES
2095bd8deadSopenharmony_ci                                    | LINE_STRIP
2105bd8deadSopenharmony_ci                                    | LINE_LOOP
2115bd8deadSopenharmony_ci        TRIANGLES                   | TRIANGLES
2125bd8deadSopenharmony_ci                                    | TRIANGLE_STRIP
2135bd8deadSopenharmony_ci                                    | TRIANGLE_FAN
2145bd8deadSopenharmony_ci        QUADS                       | QUADS
2155bd8deadSopenharmony_ci                                    | QUAD_STRIP
2165bd8deadSopenharmony_ci        PATCHES                     | PATCHES
2175bd8deadSopenharmony_ci        LINES_ADJACENCY             | LINES_ADJACENCY
2185bd8deadSopenharmony_ci                                    | LINES_STRIP_ADJACENCY
2195bd8deadSopenharmony_ci        TRIANGLES_ADJACENCY         | TRIANGLES_ADJACENCY
2205bd8deadSopenharmony_ci                                    | TRIANGLES_STRIP_ADJACENCY
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci    This rendering state includes:
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci    - Vertex attribute enable state, formats, types, relative offsets and strides.
2255bd8deadSopenharmony_ci      
2265bd8deadSopenharmony_ci    - Primitive state such as primitive restart and patch parameters, provoking vertex.
2275bd8deadSopenharmony_ci      
2285bd8deadSopenharmony_ci    - Immediate vertex attribute values as provided by glVertexAttrib* or
2295bd8deadSopenharmony_ci      glVertexAttribI*
2305bd8deadSopenharmony_ci      
2315bd8deadSopenharmony_ci    - All active program binaries except compute (either from the active 
2325bd8deadSopenharmony_ci      program pipeline or from UseProgram) with their current subroutine 
2335bd8deadSopenharmony_ci      configuration.
2345bd8deadSopenharmony_ci    
2355bd8deadSopenharmony_ci    - Rasterization, multisample fragment operation, depth, stencil, and 
2365bd8deadSopenharmony_ci      blending state.
2375bd8deadSopenharmony_ci      
2385bd8deadSopenharmony_ci    - Rasterization state such as stippling and polygon modes and offsets.
2395bd8deadSopenharmony_ci
2405bd8deadSopenharmony_ci    - Viewport, scissor, and depth range state.
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    - Framebuffer attachment configuration: attachment state including attachment 
2435bd8deadSopenharmony_ci      formats, drawbuffer state, and target/layer information, but not including 
2445bd8deadSopenharmony_ci      actual attachments or sizes of attachments (these are stored separately).
2455bd8deadSopenharmony_ci     
2465bd8deadSopenharmony_ci    - Framebuffer attachment textures (but not their residency state).
2475bd8deadSopenharmony_ci    
2485bd8deadSopenharmony_ci    It does NOT include:
2495bd8deadSopenharmony_ci
2505bd8deadSopenharmony_ci    - Bound vertex buffers or vertex unified addresses, or their offsets,
2515bd8deadSopenharmony_ci      or bound index buffers/addresses.
2525bd8deadSopenharmony_ci
2535bd8deadSopenharmony_ci    - Other program-related bindings, such as shader storage buffers, atomic counter buffers, texture
2545bd8deadSopenharmony_ci      and sampler bindings.
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci    - Default-block uniform values from active programs
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    - Blending constant color, front and back stencil reference values, alpha test threshold.
2595bd8deadSopenharmony_ci
2605bd8deadSopenharmony_ci    - Polygon offset values.
2615bd8deadSopenharmony_ci
2625bd8deadSopenharmony_ci    - Viewport and scissor rectangle for viewport index zero.
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ci    Essentially all state that can be manupulated by the commands listed in 10.X.2 (Drawing with Commands)
2655bd8deadSopenharmony_ci    is excluded from the state capture.
2665bd8deadSopenharmony_ci     
2675bd8deadSopenharmony_ci    INVALID_ENUM is generated if <mode> is not a basic primitive mode, as listed
2685bd8deadSopenharmony_ci    in Table 10.X.1.2.
2695bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the default framebuffer is bound as either draw or read buffer.
2705bd8deadSopenharmony_ci    INVALID_OPERATION is generated if transform feedback is enabled.
2715bd8deadSopenharmony_ci    INVALID_OPERATION is generated if occlusion query is enabled.
2725bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the current active program or program pipeline
2735bd8deadSopenharmony_ci    makes use of SHADER_STORAGE_BUFFER, ATOMIC_COUNTER_BUFFER or has uniforms defined
2745bd8deadSopenharmony_ci    in the default uniform-block, or uniforms inheriting from fixed function state 
2755bd8deadSopenharmony_ci    (gl_ModelView etc.).
2765bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the current active program or program pipeline
2775bd8deadSopenharmony_ci    uses uniform blocks that did not have the "commandBindableNV" flag set (see
2785bd8deadSopenharmony_ci    "Modifications to the OpenGL Shading Language Specification" section).
2795bd8deadSopenharmony_ci    INVALID_OPERATION is generated if neither program, nor program pipeline
2805bd8deadSopenharmony_ci    objects are actively used.
2815bd8deadSopenharmony_ci
2825bd8deadSopenharmony_ciAdd a new subsection 10.X.2 (Drawing with Commands)
2835bd8deadSopenharmony_ci    
2845bd8deadSopenharmony_ci        void DrawCommandsNV(enum mode, uint buffer, const intptr* indirects, const sizei* sizes, 
2855bd8deadSopenharmony_ci                            uint count);
2865bd8deadSopenharmony_ci        void DrawCommandsAddressNV(enum mode, const uint64* indirects, const sizei* sizes, 
2875bd8deadSopenharmony_ci                                   uint count);
2885bd8deadSopenharmony_ci
2895bd8deadSopenharmony_ci    These commands accept arrays of buffer addresses (either an array of 
2905bd8deadSopenharmony_ci    offsets <indirects> into a buffer named by <buffer>, or an array of GPU 
2915bd8deadSopenharmony_ci    addresses <indirects>), and an array of sequence lengths in <sizes>. 
2925bd8deadSopenharmony_ci    All arrays have <count> entries.
2935bd8deadSopenharmony_ci    The current binding state of vertex, element and uniform buffers will not be
2945bd8deadSopenharmony_ci    effective but must be set via commands within the buffer, other state will
2955bd8deadSopenharmony_ci    however be inherited from the current OpenGL context.
2965bd8deadSopenharmony_ci
2975bd8deadSopenharmony_ci    INVALID_ENUM is generated if <mode> is not an accepted value.
2985bd8deadSopenharmony_ci    INVALID_VALUE is generated if <buffer> is not a valid buffer object.
2995bd8deadSopenharmony_ci    INVALID_OPERATION is generated if a geometry shader is active and <mode> is 
3005bd8deadSopenharmony_ci    incompatible with the input primitive type of the geometry shader in the currently
3015bd8deadSopenharmony_ci    installed program object.
3025bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the default (zero) frame buffer object is
3035bd8deadSopenharmony_ci    currently bound as DRAW_FRAMEBUFFER, a non-zero frame buffer object is required.
3045bd8deadSopenharmony_ci    
3055bd8deadSopenharmony_ci    DrawCommandsNV and DrawCommandsAddressNV are equivalent to:
3065bd8deadSopenharmony_ci
3075bd8deadSopenharmony_ci        Save current GL state;
3085bd8deadSopenharmony_ci        enum indexType = UNSIGNED_SHORT;
3095bd8deadSopenharmony_ci        for (uint i = 0; i < count; i++) {
3105bd8deadSopenharmony_ci            uint64 address = address computed from <buffer>+<indirects>[i];
3115bd8deadSopenharmony_ci            
3125bd8deadSopenharmony_ci            indexType = DrawCommandSequenceNV(<mode>, indexType, address, sizes[i]);
3135bd8deadSopenharmony_ci        }
3145bd8deadSopenharmony_ci        Restore current GL state;
3155bd8deadSopenharmony_ci        
3165bd8deadSopenharmony_ci    The command:
3175bd8deadSopenharmony_ci
3185bd8deadSopenharmony_ci        enum DrawCommandSequenceNV(enum mode, enum indexType, void *address, sizei size);
3195bd8deadSopenharmony_ci
3205bd8deadSopenharmony_ci    does not exist in the GL, but is used to describe functionality in the rest
3215bd8deadSopenharmony_ci    of this section. 
3225bd8deadSopenharmony_ci    
3235bd8deadSopenharmony_ci    DrawCommandSequenceNV is a flexible and extensible command that executes
3245bd8deadSopenharmony_ci    simple state changes and draw commands based on a tokenized format. The
3255bd8deadSopenharmony_ci    loop above illustrates that the state changes from one invocation will
3265bd8deadSopenharmony_ci    influence the next. All rendering is peformed as if the client states for
3275bd8deadSopenharmony_ci    VERTEX_ATTRIB_ARRAY_UNIFIED_NV, ELEMENT_ARRAY_UNIFIED_NV and 
3285bd8deadSopenharmony_ci    UNIFORM_BUFFER_UNIFIED_NV are enabled.
3295bd8deadSopenharmony_ci    
3305bd8deadSopenharmony_ci    It is defined by the following pseudo code, tokens, and structures:
3315bd8deadSopenharmony_ci
3325bd8deadSopenharmony_ci
3335bd8deadSopenharmony_ci    Table 10.X.2 (Token values and command structure names)
3345bd8deadSopenharmony_ci
3355bd8deadSopenharmony_ci      tokenID                               | Command
3365bd8deadSopenharmony_ci      ---------------------------------------------------------------------
3375bd8deadSopenharmony_ci        TERMINATE_SEQUENCE_COMMAND_NV       | TerminateSequenceCommandNV
3385bd8deadSopenharmony_ci        NOP_COMMAND_NV                      | NOPCommandNV
3395bd8deadSopenharmony_ci        DRAW_ELEMENTS_COMMAND_NV            | DrawElementsCommandNV
3405bd8deadSopenharmony_ci        DRAW_ARRAYS_COMMAND_NV              | DrawArraysCommandNV
3415bd8deadSopenharmony_ci        DRAW_ELEMENTS_STRIP_COMMAND_NV      | DrawElementsCommandNV
3425bd8deadSopenharmony_ci        DRAW_ARRAYS__STRIP_COMMAND_NV       | DrawArraysCommandNV
3435bd8deadSopenharmony_ci        DRAW_ELEMENTS_INSTANCED_COMMAND_NV  | DrawElementsInstancedCommandNV
3445bd8deadSopenharmony_ci        DRAW_ARRAYS_INSTANCED_COMMAND_NV    | DrawArraysInstancedCommandNV
3455bd8deadSopenharmony_ci        ELEMENT_ADDRESS_COMMAND_NV          | ElementAddressCommandNV
3465bd8deadSopenharmony_ci        ATTRIBUTE_ADDRESS_COMMAND_NV        | AttributeAddressCommandNV
3475bd8deadSopenharmony_ci        UNIFORM_ADDRESS_COMMAND_NV          | UniformAddressCommandNV
3485bd8deadSopenharmony_ci        BLEND_COLOR_COMMAND_NV              | BlendColorCommandNV
3495bd8deadSopenharmony_ci        STENCIL_REF_COMMAND_NV              | StencilRefCommandNV
3505bd8deadSopenharmony_ci        LINE_WIDTH_COMMAND_NV               | LineWidthCommandNV
3515bd8deadSopenharmony_ci        POLYGON_OFFSET_COMMAND_NV           | PolygonOffsetCommandNV
3525bd8deadSopenharmony_ci        ALPHA_REF_COMMAND_NV                | AlphaRefCommandNV
3535bd8deadSopenharmony_ci        VIEWPORT_COMMAND_NV                 | ViewportCommandNV
3545bd8deadSopenharmony_ci        SCISSOR_COMMAND_NV                  | ScissorCommandNV
3555bd8deadSopenharmony_ci        FRONT_FACE_COMMAND_NV               | FrontFaceCommandNV
3565bd8deadSopenharmony_ci
3575bd8deadSopenharmony_ci
3585bd8deadSopenharmony_ci        Tight packing is used for all structures
3595bd8deadSopenharmony_ci        
3605bd8deadSopenharmony_ci        typedef struct {
3615bd8deadSopenharmony_ci          uint  header;
3625bd8deadSopenharmony_ci        } TerminateSequenceCommandNV;
3635bd8deadSopenharmony_ci
3645bd8deadSopenharmony_ci        typedef struct {
3655bd8deadSopenharmony_ci          uint  header;
3665bd8deadSopenharmony_ci        } NOPCommandNV;
3675bd8deadSopenharmony_ci        
3685bd8deadSopenharmony_ci        typedef  struct {
3695bd8deadSopenharmony_ci          uint  header;
3705bd8deadSopenharmony_ci          uint  count;
3715bd8deadSopenharmony_ci          uint  firstIndex;
3725bd8deadSopenharmony_ci          uint  baseVertex;
3735bd8deadSopenharmony_ci        } DrawElementsCommandNV;
3745bd8deadSopenharmony_ci
3755bd8deadSopenharmony_ci        typedef  struct {
3765bd8deadSopenharmony_ci          uint  header;
3775bd8deadSopenharmony_ci          uint  count;
3785bd8deadSopenharmony_ci          uint  first;
3795bd8deadSopenharmony_ci        } DrawArraysCommandNV;
3805bd8deadSopenharmony_ci        
3815bd8deadSopenharmony_ci        typedef  struct {
3825bd8deadSopenharmony_ci          uint  header;
3835bd8deadSopenharmony_ci          uint  mode;
3845bd8deadSopenharmony_ci          uint  count;
3855bd8deadSopenharmony_ci          uint  instanceCount;
3865bd8deadSopenharmony_ci          uint  firstIndex;
3875bd8deadSopenharmony_ci          uint  baseVertex;
3885bd8deadSopenharmony_ci          uint  baseInstance;
3895bd8deadSopenharmony_ci        } DrawElementsInstancedCommandNV;
3905bd8deadSopenharmony_ci
3915bd8deadSopenharmony_ci        typedef  struct {
3925bd8deadSopenharmony_ci          uint  header;
3935bd8deadSopenharmony_ci          uint  mode;
3945bd8deadSopenharmony_ci          uint  count;
3955bd8deadSopenharmony_ci          uint  instanceCount;
3965bd8deadSopenharmony_ci          uint  first;
3975bd8deadSopenharmony_ci          uint  baseInstance;
3985bd8deadSopenharmony_ci        } DrawArraysInstancedCommandNV;
3995bd8deadSopenharmony_ci
4005bd8deadSopenharmony_ci        typedef struct {
4015bd8deadSopenharmony_ci          uint  header;
4025bd8deadSopenharmony_ci          uint  addressLo;
4035bd8deadSopenharmony_ci          uint  addressHi;
4045bd8deadSopenharmony_ci          uint  typeSizeInByte;
4055bd8deadSopenharmony_ci        } ElementAddressCommandNV;
4065bd8deadSopenharmony_ci
4075bd8deadSopenharmony_ci        typedef struct {
4085bd8deadSopenharmony_ci          uint  header;
4095bd8deadSopenharmony_ci          uint  index;
4105bd8deadSopenharmony_ci          uint  addressLo;
4115bd8deadSopenharmony_ci          uint  addressHi;
4125bd8deadSopenharmony_ci        } AttributeAddressCommandNV;
4135bd8deadSopenharmony_ci
4145bd8deadSopenharmony_ci        typedef struct {
4155bd8deadSopenharmony_ci          uint    header;
4165bd8deadSopenharmony_ci          ushort  index;
4175bd8deadSopenharmony_ci          ushort  stage;
4185bd8deadSopenharmony_ci          uint    addressLo;
4195bd8deadSopenharmony_ci          uint    addressHi;
4205bd8deadSopenharmony_ci        } UniformAddressCommandNV;
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ci        typedef struct {
4235bd8deadSopenharmony_ci          uint  header;
4245bd8deadSopenharmony_ci          float red;
4255bd8deadSopenharmony_ci          float green;
4265bd8deadSopenharmony_ci          float blue;
4275bd8deadSopenharmony_ci          float alpha;
4285bd8deadSopenharmony_ci        } BlendColorCommandNV;
4295bd8deadSopenharmony_ci
4305bd8deadSopenharmony_ci        typedef struct {
4315bd8deadSopenharmony_ci          uint  header;
4325bd8deadSopenharmony_ci          uint  frontStencilRef;
4335bd8deadSopenharmony_ci          uint  backStencilRef;
4345bd8deadSopenharmony_ci        } StencilRefCommandNV;
4355bd8deadSopenharmony_ci        
4365bd8deadSopenharmony_ci        typedef struct {
4375bd8deadSopenharmony_ci          uint  header;
4385bd8deadSopenharmony_ci          float lineWidth;
4395bd8deadSopenharmony_ci        } LineWidthCommandNV;
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci        typedef struct {
4425bd8deadSopenharmony_ci          uint  header;
4435bd8deadSopenharmony_ci          float scale;
4445bd8deadSopenharmony_ci          float bias;
4455bd8deadSopenharmony_ci        } PolygonOffsetCommandNV;
4465bd8deadSopenharmony_ci        
4475bd8deadSopenharmony_ci        typedef struct {
4485bd8deadSopenharmony_ci          uint  header;
4495bd8deadSopenharmony_ci          float alphaRef;
4505bd8deadSopenharmony_ci        } AlphaRefCommandNV;
4515bd8deadSopenharmony_ci
4525bd8deadSopenharmony_ci        typedef struct {
4535bd8deadSopenharmony_ci          uint  header;
4545bd8deadSopenharmony_ci          uint  x;
4555bd8deadSopenharmony_ci          uint  y;
4565bd8deadSopenharmony_ci          uint  width;
4575bd8deadSopenharmony_ci          uint  height;
4585bd8deadSopenharmony_ci        } ViewportCommandNV; // only ViewportIndex 0
4595bd8deadSopenharmony_ci
4605bd8deadSopenharmony_ci        typedef struct {
4615bd8deadSopenharmony_ci          uint  header;
4625bd8deadSopenharmony_ci          uint  x;
4635bd8deadSopenharmony_ci          uint  y;
4645bd8deadSopenharmony_ci          uint  width;
4655bd8deadSopenharmony_ci          uint  height;
4665bd8deadSopenharmony_ci        } ScissorCommandNV; // only ViewportIndex 0
4675bd8deadSopenharmony_ci
4685bd8deadSopenharmony_ci        typedef struct {
4695bd8deadSopenharmony_ci          uint  header;
4705bd8deadSopenharmony_ci          uint  frontFace; // 0 for CW, 1 for CCW
4715bd8deadSopenharmony_ci        } FrontFaceCommandNV;
4725bd8deadSopenharmony_ci
4735bd8deadSopenharmony_ci        enum DrawCommandSequenceNV(enum mode, enum indexType, void *address, sizei size)
4745bd8deadSopenharmony_ci        {
4755bd8deadSopenharmony_ci          enum modeStrip;
4765bd8deadSopenharmony_ci          if      (mode == TRIANGLES)            modeStrip = TRIANGLE_STRIP;
4775bd8deadSopenharmony_ci          else if (mode == LINES)                modeStrip = LINE_STRIP;
4785bd8deadSopenharmony_ci          else if (mode == LINES_ADJACENCY)      modeStrip = LINE_STRIP_ADJACENCY;
4795bd8deadSopenharmony_ci          else if (mode == TRIANGLES_ADJACENCY)  modeStrip = TRIANGLE_STRIP_ADJACENCY;
4805bd8deadSopenharmony_ci          else if (mode == QUADS)                modeStrip = QUAD_STRIP;
4815bd8deadSopenharmony_ci          else    modeStrip = mode;
4825bd8deadSopenharmony_ci
4835bd8deadSopenharmony_ci          enum modeSpecial;
4845bd8deadSopenharmony_ci          if      (mode == LINES)      modeSpecial = LINE_LOOP;
4855bd8deadSopenharmony_ci          else if (mode == TRIANGLES)  modeSpecial = TRIANGLE_FAN;
4865bd8deadSopenharmony_ci          else    modeSpecial = mode;
4875bd8deadSopenharmony_ci
4885bd8deadSopenharmony_ci          void *current = address;
4895bd8deadSopenharmony_ci          
4905bd8deadSopenharmony_ci          while (current != (ubyte *)address + size) {
4915bd8deadSopenharmony_ci            uint    header  = *(uint*)current;
4925bd8deadSopenharmony_ci
4935bd8deadSopenharmony_ci            switch( GetTokenType(header)){
4945bd8deadSopenharmony_ci            case TERMINATE_SEQUENCE_NV:
4955bd8deadSopenharmony_ci              {
4965bd8deadSopenharmony_ci                return indexType;
4975bd8deadSopenharmony_ci              }
4985bd8deadSopenharmony_ci              break;
4995bd8deadSopenharmony_ci            case NOP_COMMAND_NV:
5005bd8deadSopenharmony_ci            
5015bd8deadSopenharmony_ci              break;
5025bd8deadSopenharmony_ci            case DRAW_ELEMENTS_COMMAND_NV:
5035bd8deadSopenharmony_ci              {
5045bd8deadSopenharmony_ci                DrawElementsCommandNV* cmd = (DrawElementsCommandNV*)current;
5055bd8deadSopenharmony_ci                DrawElementsBaseVertex(mode, cmd->count, indexType, (void*)(cmd->firstIndex * sizeofindextype), cmd->baseVertex);
5065bd8deadSopenharmony_ci              }
5075bd8deadSopenharmony_ci              break;
5085bd8deadSopenharmony_ci            case DRAW_ARRAYS_COMMAND_NV:
5095bd8deadSopenharmony_ci              {
5105bd8deadSopenharmony_ci                DrawArraysCommandNV* cmd = (DrawArraysCommandNV*)current;
5115bd8deadSopenharmony_ci                DrawArrays(mode, cmd->first, cmd->count);
5125bd8deadSopenharmony_ci              }
5135bd8deadSopenharmony_ci              break;
5145bd8deadSopenharmony_ci            case DRAW_ELEMENTS_STRIP_COMMAND_NV:
5155bd8deadSopenharmony_ci              {
5165bd8deadSopenharmony_ci                DrawElementsCommandNV* cmd = (DrawElementsCommandNV*)current;
5175bd8deadSopenharmony_ci                DrawElementsBaseVertex(modeStrip, cmd->count, indexType, (void*)(cmd->firstIndex * sizeofindextype), cmd->baseVertex);
5185bd8deadSopenharmony_ci              }
5195bd8deadSopenharmony_ci              break;
5205bd8deadSopenharmony_ci            case DRAW_ARRAYS_STRIP_COMMAND_NV:
5215bd8deadSopenharmony_ci              {
5225bd8deadSopenharmony_ci                DrawArraysCommandNV* cmd = (DrawArraysCommandNV*)current;
5235bd8deadSopenharmony_ci                DrawArrays(modeStrip, cmd->first, cmd->count);
5245bd8deadSopenharmony_ci              }
5255bd8deadSopenharmony_ci              break;
5265bd8deadSopenharmony_ci            case DRAW_ELEMENTS_INSTANCED_COMMAND_NV:
5275bd8deadSopenharmony_ci              {
5285bd8deadSopenharmony_ci                // undefined behavior if (cmd->mode != mode && cmd->mode != modeStrip && cmd->mode != modeSpecial)
5295bd8deadSopenharmony_ci                
5305bd8deadSopenharmony_ci                DrawElementsInstancedCommandNV* cmd = (DrawElementsInstancedCommandNV*)current;
5315bd8deadSopenharmony_ci                DrawElementsIndirect(cmd->mode, indexType, &cmd->count);
5325bd8deadSopenharmony_ci              }
5335bd8deadSopenharmony_ci              break;
5345bd8deadSopenharmony_ci            case DRAW_ARRAYS_INSTANCED_COMMAND_NV:
5355bd8deadSopenharmony_ci              {
5365bd8deadSopenharmony_ci                // undefined behavior if (cmd->mode != mode && cmd->mode != modeStrip && cmd->mode != modeSpecial)
5375bd8deadSopenharmony_ci                
5385bd8deadSopenharmony_ci                DrawArraysInstancedCommandNV* cmd = (DrawArraysInstancedCommandNV*)current;
5395bd8deadSopenharmony_ci                DrawArraysIndirect(cmd->mode, &cmd->count);
5405bd8deadSopenharmony_ci              }
5415bd8deadSopenharmony_ci              break;
5425bd8deadSopenharmony_ci            case ELEMENT_ADDRESS_COMMAND_NV:
5435bd8deadSopenharmony_ci              {
5445bd8deadSopenharmony_ci                ElementAddressCommandNV* cmd = (ElementAddressCommandNV*)current;
5455bd8deadSopenharmony_ci                switch(cmd->typeSizeInByte){
5465bd8deadSopenharmony_ci                  case 1: indexType = UNSIGNED_BYTE;  break;
5475bd8deadSopenharmony_ci                  case 2: indexType = UNSIGNED_SHORT; break;
5485bd8deadSopenharmony_ci                  case 4: indexType = UNSIGNED_INT;   break;
5495bd8deadSopenharmony_ci                }
5505bd8deadSopenharmony_ci                BufferAddressRangeNV(ELEMENT_ARRAY_ADDRESS_NV, 0, uint64(cmd->addressLo) | (uint64(cmd->addressHi)<<32), 0x7FFFFFFF);
5515bd8deadSopenharmony_ci              }
5525bd8deadSopenharmony_ci              break;
5535bd8deadSopenharmony_ci            case ATTRIBUTE_ADDRESS_COMMAND_NV:
5545bd8deadSopenharmony_ci              {
5555bd8deadSopenharmony_ci                AttributeAddressCommandNV* cmd = (AttributeAddressCommandNV*)current;
5565bd8deadSopenharmony_ci                BufferAddressRangeNV(VERTEX_ATTRIB_ARRAY_ADDRESS_NV, cmd->index, uint64(cmd->addressLo) | (uint64(cmd->addressHi)<<32), 0x7FFFFFFF);
5575bd8deadSopenharmony_ci              }
5585bd8deadSopenharmony_ci              break;
5595bd8deadSopenharmony_ci            case UNIFORM_ADDRESS_COMMAND_NV:
5605bd8deadSopenharmony_ci              {
5615bd8deadSopenharmony_ci                UniformAddressCommandNV* cmd = (UniformAddressCommandNV*)current;
5625bd8deadSopenharmony_ci                BufferAddressRangeNV(UNIFORM_BUFFER_ADDRESS_NV, cmd->index, uint64(cmd->addressLo) | (uint64(cmd->addressHi)<<32), 0x10000);
5635bd8deadSopenharmony_ci              }
5645bd8deadSopenharmony_ci              break;
5655bd8deadSopenharmony_ci            case BLEND_COLOR_COMMAND_NV:
5665bd8deadSopenharmony_ci              {
5675bd8deadSopenharmony_ci                BlendColorCommandNV* cmd = (BlendColorCommandNV*)current;
5685bd8deadSopenharmony_ci                BlendColor(cmd->red,cmd->green,cmd->blue,cmd->alpha);
5695bd8deadSopenharmony_ci              }
5705bd8deadSopenharmony_ci              break;
5715bd8deadSopenharmony_ci            case STENCIL_REF_COMMAND_NV:
5725bd8deadSopenharmony_ci              {
5735bd8deadSopenharmony_ci                StencilRefCommandNV* cmd = (StencilRefCommandNV*)current;
5745bd8deadSopenharmony_ci                StencilFuncSeparate(FRONT, asIs, cmd->frontStencilRef, asIs);
5755bd8deadSopenharmony_ci                StencilFuncSeparate(BACK,  asIs, cmd->backStencilRef,  asIs);
5765bd8deadSopenharmony_ci              }
5775bd8deadSopenharmony_ci              break;
5785bd8deadSopenharmony_ci            case LINE_WIDTH_COMMAND_NV:
5795bd8deadSopenharmony_ci              {
5805bd8deadSopenharmony_ci                LineWidthCommandNV* cmd = (LineWidthCommandNV*)current;
5815bd8deadSopenharmony_ci                LineWidth(cmd->lineWidth);
5825bd8deadSopenharmony_ci              }
5835bd8deadSopenharmony_ci              break;
5845bd8deadSopenharmony_ci            case POLYGON_OFFSET_COMMAND_NV:
5855bd8deadSopenharmony_ci              {
5865bd8deadSopenharmony_ci                PolygonOffsetCommandNV* cmd = (PolygonOffsetCommandNV*)current;
5875bd8deadSopenharmony_ci                PolygonOffset(cmd->scale,cmd->bias);
5885bd8deadSopenharmony_ci              }
5895bd8deadSopenharmony_ci              break;
5905bd8deadSopenharmony_ci            case ALPHA_REF_COMMAND_NV:
5915bd8deadSopenharmony_ci              {
5925bd8deadSopenharmony_ci                AlphaRefCommandNV* cmd = (AlphaRefCommandNV*)current;
5935bd8deadSopenharmony_ci                AlphaFunc(asIs, cmd->alphaRef);
5945bd8deadSopenharmony_ci              }
5955bd8deadSopenharmony_ci              break
5965bd8deadSopenharmony_ci            case VIEWPORT_COMMAND_NV:
5975bd8deadSopenharmony_ci              {
5985bd8deadSopenharmony_ci                ViewportCommandNV* cmd = (ViewportCommandNV*)current;
5995bd8deadSopenharmony_ci                Viewport  (cmd->x,cmd->y,cmd->width,cmd->height);
6005bd8deadSopenharmony_ci              }
6015bd8deadSopenharmony_ci              break;
6025bd8deadSopenharmony_ci            case SCISSOR_COMMAND_NV:
6035bd8deadSopenharmony_ci              {
6045bd8deadSopenharmony_ci                ScissorCommandNV* cmd = (ScissorCommandNV*)current;
6055bd8deadSopenharmony_ci                Scissor(cmd->x,cmd->y,cmd->width,cmd->height);
6065bd8deadSopenharmony_ci              }
6075bd8deadSopenharmony_ci              break;
6085bd8deadSopenharmony_ci            case FRONT_FACE_COMMAND_NV:
6095bd8deadSopenharmony_ci              {
6105bd8deadSopenharmony_ci                FrontFaceCommandNV* cmd = (FrontFaceCommandNV*)current;
6115bd8deadSopenharmony_ci                FrontFace(cmd->frontFace ? CW : CCW);
6125bd8deadSopenharmony_ci              }
6135bd8deadSopenharmony_ci              break;
6145bd8deadSopenharmony_ci            }
6155bd8deadSopenharmony_ci
6165bd8deadSopenharmony_ci            current = (ubyte *)current + GetTokenSize(header);
6175bd8deadSopenharmony_ci          }
6185bd8deadSopenharmony_ci          
6195bd8deadSopenharmony_ci          return indexType;
6205bd8deadSopenharmony_ci        }
6215bd8deadSopenharmony_ci    
6225bd8deadSopenharmony_ci    None of the commands called by DrawCommandSequenceNV may generate their
6235bd8deadSopenharmony_ci    appropriate errors, providing erroneous data as parameters
6245bd8deadSopenharmony_ci    or generating state that normally would create errors when executed
6255bd8deadSopenharmony_ci    by the server can produce undefined results and may cause program
6265bd8deadSopenharmony_ci    termination.
6275bd8deadSopenharmony_ci    The residency of all resources referenced directly (buffer addresses inside tokens) 
6285bd8deadSopenharmony_ci    or indirectly (texture handles inside uniform buffer objects) must be managed
6295bd8deadSopenharmony_ci    explicitly.
6305bd8deadSopenharmony_ci    
6315bd8deadSopenharmony_ci    
6325bd8deadSopenharmony_ci    (XXX should we add something similar to CheckFramebufferStatus? for
6335bd8deadSopenharmony_ci     debugging, that tests the content in software and throws error + offset into buffer
6345bd8deadSopenharmony_ci     triggering the error)
6355bd8deadSopenharmony_ci    
6365bd8deadSopenharmony_ci    All BufferAddressRangeNV calls issued by DrawCommandSequenceNV are 
6375bd8deadSopenharmony_ci    effective independent of their appropriate client state being enabled or not.
6385bd8deadSopenharmony_ci
6395bd8deadSopenharmony_ci    
6405bd8deadSopenharmony_ci    uint GetCommandHeaderNV(enum tokenID, uint size)
6415bd8deadSopenharmony_ci    
6425bd8deadSopenharmony_ci    Returns the encoded 32bit header value for a given command; the returned
6435bd8deadSopenharmony_ci    value is implementation specific.
6445bd8deadSopenharmony_ci    The <size> is only provided as basic consistency check, since the size of each 
6455bd8deadSopenharmony_ci    structure is fixed and no padding is allowed. The value is the sum of the 
6465bd8deadSopenharmony_ci    header and the command specific structure.
6475bd8deadSopenharmony_ci    INVALID_ENUM is generated if <tokenID> is not one of the values listed under Table 10.X.2.
6485bd8deadSopenharmony_ci    INVALID_VALUE is thrown if the <size> does not match the fixed 
6495bd8deadSopenharmony_ci    size of a command defined by the spec.
6505bd8deadSopenharmony_ci    
6515bd8deadSopenharmony_ci    ushort GetStageIndexNV(enum shadertype)
6525bd8deadSopenharmony_ci    
6535bd8deadSopenharmony_ci    Returns the 16bit value for a specific shader stage; the returned value
6545bd8deadSopenharmony_ci    is implementation specific. The value is to be used with the stage field
6555bd8deadSopenharmony_ci    within UniformAddressCommandNV tokens.
6565bd8deadSopenharmony_ci    
6575bd8deadSopenharmony_ciAdd a new subsection 10.X.3 (Drawing with Commands and State Objects)
6585bd8deadSopenharmony_ci
6595bd8deadSopenharmony_ci    State objects may be used in rendering with the commands:
6605bd8deadSopenharmony_ci
6615bd8deadSopenharmony_ci        void DrawCommandsStatesNV(uint buffer, const intptr* indirects, const sizei* sizes, 
6625bd8deadSopenharmony_ci                                       const uint* states, const uint* fbos, uint count);
6635bd8deadSopenharmony_ci        void DrawCommandsStatesAddressNV(const uint64* indirects, const sizei* sizes, 
6645bd8deadSopenharmony_ci                                              const uint* states, const uint* fbos, uint count);
6655bd8deadSopenharmony_ci
6665bd8deadSopenharmony_ci    These commands accept arrays of buffer addresses (either an array of 
6675bd8deadSopenharmony_ci    offsets <indirects> into a buffer named by <buffer>, or an array of GPU 
6685bd8deadSopenharmony_ci    addresses <indirects>), an array of sequence lengths in <sizes>, and an 
6695bd8deadSopenharmony_ci    array of state object names in <states>, of which all names must be non-zero.
6705bd8deadSopenharmony_ci    Frame buffer object names are stored in <fbos> and can
6715bd8deadSopenharmony_ci    be either zero or non-zero. All arrays have <count> entries.
6725bd8deadSopenharmony_ci    The residency of textures used as attachment inside the state object's 
6735bd8deadSopenharmony_ci    captured fbo or the passed fbo must managed explicitly. 
6745bd8deadSopenharmony_ci    
6755bd8deadSopenharmony_ci    INVALID_VALUE is generated if one entry of <states> is zero.
6765bd8deadSopenharmony_ci    INVALID_OPERATION is generated if the fbo configuration from <fbos>
6775bd8deadSopenharmony_ci    mismatches the configuration inside the corresponding state object
6785bd8deadSopenharmony_ci    from <states>.
6795bd8deadSopenharmony_ci    
6805bd8deadSopenharmony_ci    DrawCommandsStatesNV and DrawCommandsStatesAddressNV are equivalent to:
6815bd8deadSopenharmony_ci
6825bd8deadSopenharmony_ci        Save current GL state;
6835bd8deadSopenharmony_ci        enum indexType = UNSIGNED_SHORT;
6845bd8deadSopenharmony_ci        for (uint i = 0; i < count; i++) {
6855bd8deadSopenharmony_ci            fbo         = LookupFbo(fbos[i]);
6865bd8deadSopenharmony_ci            stateObject = LookupStateObject(states[i]);
6875bd8deadSopenharmony_ci            
6885bd8deadSopenharmony_ci            if ( i == 0){
6895bd8deadSopenharmony_ci              Set full state captured by stateObject;
6905bd8deadSopenharmony_ci            }
6915bd8deadSopenharmony_ci            else {
6925bd8deadSopenharmony_ci              Set difference of state going from <states>[i-1] to current stateObject, 
6935bd8deadSopenharmony_ci            }
6945bd8deadSopenharmony_ci            
6955bd8deadSopenharmony_ci            if ( fbo == 0) {
6965bd8deadSopenharmony_ci              BindFramebuffer(FRAMEBUFFER, stateObject.fbo.name);
6975bd8deadSopenharmony_ci            }
6985bd8deadSopenharmony_ci            else if ( stateObject.fbo.configuration == fbo.configuration ){
6995bd8deadSopenharmony_ci              // The configuration excludes attachment textures and size information, however
7005bd8deadSopenharmony_ci              // includes attached texture formats and other state (see StateCaptureNV).
7015bd8deadSopenharmony_ci              
7025bd8deadSopenharmony_ci              BindFramebuffer(FRAMEBUFFER, fbo.name);
7035bd8deadSopenharmony_ci            }
7045bd8deadSopenharmony_ci            else {
7055bd8deadSopenharmony_ci              // Only compatible fbo states can be used.
7065bd8deadSopenharmony_ci              
7075bd8deadSopenharmony_ci              generate ERROR INVALID_OPERATION;
7085bd8deadSopenharmony_ci              return;
7095bd8deadSopenharmony_ci            }
7105bd8deadSopenharmony_ci            
7115bd8deadSopenharmony_ci            enum mode = primitive mode from stateObject
7125bd8deadSopenharmony_ci        
7135bd8deadSopenharmony_ci            uint64 address = address computed from <buffer>+<indirects>[i];
7145bd8deadSopenharmony_ci            
7155bd8deadSopenharmony_ci            indexType = DrawCommandSequenceNV(mode, indexType, address, sizes[i]);
7165bd8deadSopenharmony_ci        }
7175bd8deadSopenharmony_ci        Restore current GL state;
7185bd8deadSopenharmony_ci    
7195bd8deadSopenharmony_ci    where LookupFbo and LookupStateObject return the driver's internal fbo
7205bd8deadSopenharmony_ci    and stateObject object and stateObject.fbo is the driver's fbo state
7215bd8deadSopenharmony_ci    object and fbo.configuration and fbo.name are the current configuration
7225bd8deadSopenharmony_ci    of a fbo and the fbo's name respectively.
7235bd8deadSopenharmony_ci
7245bd8deadSopenharmony_ciAdd a new section 10.X.4 (Command Lists)
7255bd8deadSopenharmony_ci
7265bd8deadSopenharmony_ci    A list of DrawCommandsStates* commands may be compiled into a command
7275bd8deadSopenharmony_ci    list, for further optimization and efficient reuse. The name space for 
7285bd8deadSopenharmony_ci    command lists is the unsigned integers, with zero reserved. The command:
7295bd8deadSopenharmony_ci
7305bd8deadSopenharmony_ci        void CreateCommandListsNV(sizei n, uint *lists);
7315bd8deadSopenharmony_ci
7325bd8deadSopenharmony_ci    returns <n> previously unused command list names in <lists>, and creates
7335bd8deadSopenharmony_ci    a command list in the initial state for each name.
7345bd8deadSopenharmony_ci
7355bd8deadSopenharmony_ci    Command lists are deleted by calling
7365bd8deadSopenharmony_ci
7375bd8deadSopenharmony_ci        void DeleteCommandListsNV(sizei n, const uint *lists);
7385bd8deadSopenharmony_ci
7395bd8deadSopenharmony_ci    <lists> contains <n> names of command lists to be deleted. Once a command
7405bd8deadSopenharmony_ci    list is deleted it has no contents and its name is again unused. Unused 
7415bd8deadSopenharmony_ci    names in <lists> are silently ignored, as is the value zero.
7425bd8deadSopenharmony_ci
7435bd8deadSopenharmony_ci    The command
7445bd8deadSopenharmony_ci
7455bd8deadSopenharmony_ci        void CommandListSegmentsNV(uint list, uint segments);
7465bd8deadSopenharmony_ci
7475bd8deadSopenharmony_ci    indicates that <list> will have <segments> number of segments, each
7485bd8deadSopenharmony_ci    of which is a list of command sequences that it enqueues. This must be
7495bd8deadSopenharmony_ci    called before any commands are enqueued. In the initial state, a command 
7505bd8deadSopenharmony_ci    list has a single segment.
7515bd8deadSopenharmony_ci
7525bd8deadSopenharmony_ci    A command list's initial state allows it to enqueue commands, but not to 
7535bd8deadSopenharmony_ci    be executed. The following command can be enqueued:
7545bd8deadSopenharmony_ci
7555bd8deadSopenharmony_ci        void ListDrawCommandsStatesClientNV(uint list, uint segment, const void** indirects, 
7565bd8deadSopenharmony_ci                                              const sizei* sizes, const uint* states, const uint* fbos,
7575bd8deadSopenharmony_ci                                              uint count);
7585bd8deadSopenharmony_ci
7595bd8deadSopenharmony_ci    A list has multiple segments and each segment enqueues an ordered list of 
7605bd8deadSopenharmony_ci    command sequences. This command enqueues the equivalent of the DrawCommandsStatesNV 
7615bd8deadSopenharmony_ci    commands into the list indicated by <list> on the segment indicated by <segment> 
7625bd8deadSopenharmony_ci    except that the sequence data is copied from the sequences pointed to by the <indirects> 
7635bd8deadSopenharmony_ci    pointer. The <indirects> pointer should point to a list of size <count> of pointers, 
7645bd8deadSopenharmony_ci    each of which should point to a command sequence. 
7655bd8deadSopenharmony_ci
7665bd8deadSopenharmony_ci    The pre-validated state from <states> is saved into the command list, rather 
7675bd8deadSopenharmony_ci    than a reference to the state object (i.e. the state objects or fbos could be 
7685bd8deadSopenharmony_ci    deleted and the command list would be unaffected). This includes native
7695bd8deadSopenharmony_ci    GPU addresses for all textures indirectly referenced through the fbos
7705bd8deadSopenharmony_ci    passed or state objects' fbos attachments, therefore a recompile of the command list
7715bd8deadSopenharmony_ci    is required if such referenced textures change their allocation (for example
7725bd8deadSopenharmony_ci    due to resizing), as well as explicit management of the residency of
7735bd8deadSopenharmony_ci    the textures prior CallCommandListNV.
7745bd8deadSopenharmony_ci    
7755bd8deadSopenharmony_ci    ListDrawCommandsStatesClientNV performs a by-value copy of the
7765bd8deadSopenharmony_ci    indirect data based on the provided client-side pointers. In this case 
7775bd8deadSopenharmony_ci    the content is fully immutable, while the buffer-based versions can
7785bd8deadSopenharmony_ci    change the content of the buffers at any later time.
7795bd8deadSopenharmony_ci
7805bd8deadSopenharmony_ci    The command
7815bd8deadSopenharmony_ci
7825bd8deadSopenharmony_ci        void CompileCommandListNV(uint list);
7835bd8deadSopenharmony_ci
7845bd8deadSopenharmony_ci    make the list indicated by <list> switch from allowing collection of 
7855bd8deadSopenharmony_ci    commands to allowing its execution. At this time, the implementation may
7865bd8deadSopenharmony_ci    generate optimized commands to transition between states as efficiently
7875bd8deadSopenharmony_ci    as possible. Lists may be executed with the command
7885bd8deadSopenharmony_ci
7895bd8deadSopenharmony_ci        void CallCommandListNV(uint list);
7905bd8deadSopenharmony_ci
7915bd8deadSopenharmony_ci    This executes the command list indicated by <list>, which operates as if
7925bd8deadSopenharmony_ci    the DrawCommandsStates* commands were replayed in the order they were 
7935bd8deadSopenharmony_ci    enqueued on each segment, starting from segment zero and proceeding to the 
7945bd8deadSopenharmony_ci    maximum segment. All buffer or texture resources' residency must be 
7955bd8deadSopenharmony_ci    managed explicitly, including texture attachments of the effective 
7965bd8deadSopenharmony_ci    fbos during list enqueuing.
7975bd8deadSopenharmony_ci
7985bd8deadSopenharmony_ci    
7995bd8deadSopenharmony_ciModifications to the OpenGL Shading Language Specification, Version 4.40
8005bd8deadSopenharmony_ci
8015bd8deadSopenharmony_ci    Including the following line in a shader can be used to control the
8025bd8deadSopenharmony_ci    language features described in this extension:
8035bd8deadSopenharmony_ci
8045bd8deadSopenharmony_ci      #extension GL_NV_command_list : <behavior>
8055bd8deadSopenharmony_ci
8065bd8deadSopenharmony_ci    where <behavior> is as specified in section 3.3.
8075bd8deadSopenharmony_ci
8085bd8deadSopenharmony_ci    New preprocessor #defines are added to the OpenGL Shading Language:
8095bd8deadSopenharmony_ci
8105bd8deadSopenharmony_ci      #define GL_NV_command_list          1
8115bd8deadSopenharmony_ci    
8125bd8deadSopenharmony_ci    
8135bd8deadSopenharmony_ci    Modify Section 4.4.5, "Uniform and Shader Storage Block Layout Qualifiers"
8145bd8deadSopenharmony_ci
8155bd8deadSopenharmony_ci    (modify first paragraph, p.78) Layout qualifiers can be used for uniform
8165bd8deadSopenharmony_ci    and shader storage blocks, but not for non-block uniform declarations.
8175bd8deadSopenharmony_ci    The layout qualifier identifiers (and shared keyword) for uniform and
8185bd8deadSopenharmony_ci    shader storage blocks are
8195bd8deadSopenharmony_ci
8205bd8deadSopenharmony_ci      layout-qualifier-id
8215bd8deadSopenharmony_ci        shared
8225bd8deadSopenharmony_ci        packed
8235bd8deadSopenharmony_ci        std140
8245bd8deadSopenharmony_ci        std430
8255bd8deadSopenharmony_ci        row_major
8265bd8deadSopenharmony_ci        column_major
8275bd8deadSopenharmony_ci        binding = integer-constant-expression
8285bd8deadSopenharmony_ci        offset  = integer-constant-expression
8295bd8deadSopenharmony_ci        align   = integer-constant-expression
8305bd8deadSopenharmony_ci        commandBindableNV
8315bd8deadSopenharmony_ci    
8325bd8deadSopenharmony_ci    (add paragraph prior "When multiple arguments", p. 80) 
8335bd8deadSopenharmony_ci    The commandBindableNV qualifier enables the associated uniform block
8345bd8deadSopenharmony_ci    to be updated via UniformAddressCommandNVs when executing 
8355bd8deadSopenharmony_ci    DrawCommandsStatesNV. When commandBindableNV is enabled the <binding> 
8365bd8deadSopenharmony_ci    identifier must be provided for each block, only its value will 
8375bd8deadSopenharmony_ci    correspond with the index field of a UniformAddressCommandNV.
8385bd8deadSopenharmony_ci    A link time error will be thrown if an index is greater or equal to
8395bd8deadSopenharmony_ci    MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV.
8405bd8deadSopenharmony_ci    Changing the binding point by the OpenGL API may not influence this 
8415bd8deadSopenharmony_ci    associated index value and may cause UniformAddressCommandNVs to have
8425bd8deadSopenharmony_ci    undefined behavior.
8435bd8deadSopenharmony_ci    
8445bd8deadSopenharmony_ciDependencies on OpenGL 4.4 (Core Profile)
8455bd8deadSopenharmony_ci
8465bd8deadSopenharmony_ci    If only the core profile of OpenGL 4.4 is supported, references to
8475bd8deadSopenharmony_ci    functionality deprecated by OpenGL 3.0 (built-in input/output/uniform variables
8485bd8deadSopenharmony_ci    corresponding to fixed-function vertex attributes, fixed-function
8495bd8deadSopenharmony_ci    vertex and fragment processing) should be removed and/or replaced with 
8505bd8deadSopenharmony_ci    functionality supported in the core profile.  In such an environment, the 
8515bd8deadSopenharmony_ci    QUADS primitive type is not supported by the StateCaptureNV function. StateCaptureNV will
8525bd8deadSopenharmony_ci    also ignore all references to deprecated state such as line stippling.
8535bd8deadSopenharmony_ci    The ALPHA_REF_COMMAND_NV is not allowed to be used, therefore GetCommandHeaderNV will
8545bd8deadSopenharmony_ci    return an error if the token enum is passed.
8555bd8deadSopenharmony_ci    
8565bd8deadSopenharmony_ciInteractions with NV_shader_buffer_load
8575bd8deadSopenharmony_ci    
8585bd8deadSopenharmony_ci    The GPU addresses used in ELEMENT_ADDRESS_COMMAND_NV,
8595bd8deadSopenharmony_ci    ATTRIBUTE_ADDRESS_COMMAND_NV and UNIFORM_ADDRESS_COMMAND_NV 
8605bd8deadSopenharmony_ci    can be queried via the API provided in this extension. Furthermore
8615bd8deadSopenharmony_ci    the same API must be used to ensure residency of such buffers
8625bd8deadSopenharmony_ci    when draw commands using such addresses are issued.
8635bd8deadSopenharmony_ci
8645bd8deadSopenharmony_ciInteractions with NV_bindless_texture or ARB_bindless_texture
8655bd8deadSopenharmony_ci    
8665bd8deadSopenharmony_ci    Residency of fbo attachment textures referenced in state objects
8675bd8deadSopenharmony_ci    or command lists must be managed explicitly using the API provided
8685bd8deadSopenharmony_ci    by either of these extensions.
8695bd8deadSopenharmony_ci
8705bd8deadSopenharmony_ciInteractions with NV_parameter_buffer_object
8715bd8deadSopenharmony_ci  
8725bd8deadSopenharmony_ci    The UNIFORM_ADDRESS_COMMAND_NV described in (Drawing with Commands), will affect
8735bd8deadSopenharmony_ci    the PROGRAM_PARAMETER_BUFFER of the target stage defined within the command
8745bd8deadSopenharmony_ci    token.
8755bd8deadSopenharmony_ci 
8765bd8deadSopenharmony_ciInteractions with ARB_robust_buffer_access_behavior
8775bd8deadSopenharmony_ci
8785bd8deadSopenharmony_ci    The buffer setups performed by ELEMENT_ADDRESS_COMMAND_NV,
8795bd8deadSopenharmony_ci    ATTRIBUTE_ADDRESS_COMMAND_NV and UNIFORM_ADDRESS_COMMAND_NV
8805bd8deadSopenharmony_ci    do not provide the required buffer ranges for robust buffer
8815bd8deadSopenharmony_ci    access. Therefore draw calls executed under this type of 
8825bd8deadSopenharmony_ci    buffer setup will not respect the robust buffer access rules.
8835bd8deadSopenharmony_ci    
8845bd8deadSopenharmony_ciInteractions with ARB_shader_draw_parameters
8855bd8deadSopenharmony_ci
8865bd8deadSopenharmony_ci    The drawing operations performed through this extension will not support
8875bd8deadSopenharmony_ci    setting of the built-in GLSL values that were added by 
8885bd8deadSopenharmony_ci    ARB_shader_draw_parameters (gl_BaseInstanceARB, gl_BaseVertexARB, gl_DrawIDARB).
8895bd8deadSopenharmony_ci    Accessing these variables will result in undefined values.
8905bd8deadSopenharmony_ci
8915bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications
8925bd8deadSopenharmony_ci
8935bd8deadSopenharmony_ci    None.
8945bd8deadSopenharmony_ci
8955bd8deadSopenharmony_ciGLX Protocol
8965bd8deadSopenharmony_ci
8975bd8deadSopenharmony_ci    None.
8985bd8deadSopenharmony_ci
8995bd8deadSopenharmony_ciErrors
9005bd8deadSopenharmony_ci
9015bd8deadSopenharmony_ci
9025bd8deadSopenharmony_ciNew State
9035bd8deadSopenharmony_ci
9045bd8deadSopenharmony_ci    None.
9055bd8deadSopenharmony_ci
9065bd8deadSopenharmony_ciIssues
9075bd8deadSopenharmony_ci
9085bd8deadSopenharmony_ci    1) What motivates the design?
9095bd8deadSopenharmony_ci
9105bd8deadSopenharmony_ci    The primary goal is to be able to reuse pre-validated command buffers. Other
9115bd8deadSopenharmony_ci    APIs and proposals have addressed this with various incarnations of command 
9125bd8deadSopenharmony_ci    lists or state objects, but a recurring problem is that interactions between
9135bd8deadSopenharmony_ci    various stages of the pipeline prevent this prevalidation and reuse. These 
9145bd8deadSopenharmony_ci    interactions are often hardware-specific (and differ from vendor to vendor 
9155bd8deadSopenharmony_ci    or even generation to generation) and new interactions are introduced by 
9165bd8deadSopenharmony_ci    new features that were not imagined when the prevalidation scheme was 
9175bd8deadSopenharmony_ci    proposed.
9185bd8deadSopenharmony_ci
9195bd8deadSopenharmony_ci    We attempt to address this by having a monolithic state object that 
9205bd8deadSopenharmony_ci    encompasses (almost) the entire state of the pipeline. This should provide
9215bd8deadSopenharmony_ci    enough information for all implementations to do any needed cross-
9225bd8deadSopenharmony_ci    validation. We try to create these in a way that minimizes the new API 
9235bd8deadSopenharmony_ci    footprint - since we want ALL state (including any added in the future), we
9245bd8deadSopenharmony_ci    just capture it from the current state of the context.
9255bd8deadSopenharmony_ci
9265bd8deadSopenharmony_ci    We expect that a captured state object will be represented as a list of 
9275bd8deadSopenharmony_ci    commands to send to the GPU. While that list of commands may be fairly 
9285bd8deadSopenharmony_ci    large, it is also well-suited to filtering redundant changes when switching
9295bd8deadSopenharmony_ci    from one state object to another (filtering may occur on the GPU, or by 
9305bd8deadSopenharmony_ci    some processing on the CPU). We anticipate that filtering will be applied
9315bd8deadSopenharmony_ci    when compiling a command list, but it is likely that some (perhaps less 
9325bd8deadSopenharmony_ci    aggressive) filtering will also occur in unlisted DrawCommandsStates 
9335bd8deadSopenharmony_ci    commands.
9345bd8deadSopenharmony_ci
9355bd8deadSopenharmony_ci    2) Should binding state be captured?
9365bd8deadSopenharmony_ci
9375bd8deadSopenharmony_ci    Binding state should not be captured, for multiple reasons. 
9385bd8deadSopenharmony_ci    
9395bd8deadSopenharmony_ci    The memory management performed by the driver as part of legacy command 
9405bd8deadSopenharmony_ci    execution is expensive and not well-suited for the prevalidation of
9415bd8deadSopenharmony_ci    commands. This can be replaced by explicit bindless memory management 
9425bd8deadSopenharmony_ci    APIs (e.g. Make*Resident).
9435bd8deadSopenharmony_ci
9445bd8deadSopenharmony_ci    Resource bindings also require behind-the-scenes management of internal
9455bd8deadSopenharmony_ci    GPU structures like texture handles. Again, this can be replaced by the 
9465bd8deadSopenharmony_ci    bindless APIs.
9475bd8deadSopenharmony_ci
9485bd8deadSopenharmony_ci    3) What FBO state should be captured?
9495bd8deadSopenharmony_ci
9505bd8deadSopenharmony_ci    We definitely want to capture enough information to be able to do any
9515bd8deadSopenharmony_ci    state-based recompiles of the fragment shader, which would include 
9525bd8deadSopenharmony_ci    drawbuffer state and format state. However, it is not desirable to have
9535bd8deadSopenharmony_ci    all properties of the FBO be captured, e.g. if attachment width/height
9545bd8deadSopenharmony_ci    were captured then state objects could become invalid if the window shape
9555bd8deadSopenharmony_ci    changed 
9565bd8deadSopenharmony_ci
9575bd8deadSopenharmony_ci    RESOLVED: state objects reference the FBO configuration, but passing 
9585bd8deadSopenharmony_ci    other compatible FBOs during rendering is possible. Furthermore the
9595bd8deadSopenharmony_ci    VIEWPORT_COMMAND_NV allows setting the appropriate viewport state.
9605bd8deadSopenharmony_ci
9615bd8deadSopenharmony_ci    4) Can UBOs be accessed? How?
9625bd8deadSopenharmony_ci
9635bd8deadSopenharmony_ci    RESOLVED: We want to encourage the "first level of the scene graph" information read
9645bd8deadSopenharmony_ci    by shaders to be accessed with fast UBO memory accesses. 
9655bd8deadSopenharmony_ci    UNIFORM_ADDRESS_COMMAND_NV provides this mechanism.
9665bd8deadSopenharmony_ci
9675bd8deadSopenharmony_ci    5) What about Compute?
9685bd8deadSopenharmony_ci
9695bd8deadSopenharmony_ci    Compute does not have the same complex state interactions that the graphics
9705bd8deadSopenharmony_ci    pipeline has, so it is not included in this extension. 
9715bd8deadSopenharmony_ci
9725bd8deadSopenharmony_ci    6) What dynamic state should be allowed?
9735bd8deadSopenharmony_ci
9745bd8deadSopenharmony_ci    There are some state values which are pretty much raw integer/floating 
9755bd8deadSopenharmony_ci    point data, where requiring a unique state object for each value would
9765bd8deadSopenharmony_ci    drastically bloat the number of state objects needed and break batching.
9775bd8deadSopenharmony_ci    We allow for a few such values to be set in the token command buffer 
9785bd8deadSopenharmony_ci    rather than in the state object. The current list is motivated by similar
9795bd8deadSopenharmony_ci    state in other APIs, and may not be complete.
9805bd8deadSopenharmony_ci
9815bd8deadSopenharmony_ci    7) What are the "segments" in command lists?
9825bd8deadSopenharmony_ci
9835bd8deadSopenharmony_ci    These are multiple "starting points" for appending commands to the list,
9845bd8deadSopenharmony_ci    which are ultimately replayed in order by segments. This may be useful to 
9855bd8deadSopenharmony_ci    build a multipass rendering algorithm with only a single traversal of the
9865bd8deadSopenharmony_ci    scene graph.
9875bd8deadSopenharmony_ci
9885bd8deadSopenharmony_ci    8) When are state objects consumed into the list?
9895bd8deadSopenharmony_ci
9905bd8deadSopenharmony_ci    This could either occur as the command is appended to the list, or during
9915bd8deadSopenharmony_ci    CompileCommandListNV.
9925bd8deadSopenharmony_ci    
9935bd8deadSopenharmony_ci    RESOLVED: At ListDrawCommandsStatesClientNV time.
9945bd8deadSopenharmony_ci
9955bd8deadSopenharmony_ci    9) Do we want to have multiple modes in the same dispatch ?
9965bd8deadSopenharmony_ci
9975bd8deadSopenharmony_ci    RESOLVED: yes, state-objects with different modes can be used, allowing
9985bd8deadSopenharmony_ci    fast transitioning between those. Furthermore, it is possible to mix
9995bd8deadSopenharmony_ci    LINES/LINE_STRIP/LINE_LOOP or TRIANGLES/TRIANGLE_STRIP/TRIANGLE_FAN and others
10005bd8deadSopenharmony_ci    using the same state object, as long as their base primitive mode is the same.
10015bd8deadSopenharmony_ci    
10025bd8deadSopenharmony_ci    10) Do we want to allow mixing DrawArrays and DrawElements in the same
10035bd8deadSopenharmony_ci    dispatch ?
10045bd8deadSopenharmony_ci
10055bd8deadSopenharmony_ci    RESOLVED: yes.
10065bd8deadSopenharmony_ci    
10075bd8deadSopenharmony_ci    11) What happens if the token buffer is modified while it is being dispatched ?
10085bd8deadSopenharmony_ci
10095bd8deadSopenharmony_ci    RESOLVED: there is no guarantee of coherency, so undefined behavior.
10105bd8deadSopenharmony_ci    
10115bd8deadSopenharmony_ci    12) I would like to change states in the middle; how do I do this ?
10125bd8deadSopenharmony_ci    
10135bd8deadSopenharmony_ci    RESOLVED: you can select a new state object or state tokens, but you cannot change
10145bd8deadSopenharmony_ci    state in the indirect buffer itself.
10155bd8deadSopenharmony_ci    
10165bd8deadSopenharmony_ci    13) Is the token buffer multithread safe; does it scale ?
10175bd8deadSopenharmony_ci    
10185bd8deadSopenharmony_ci    RESOLVED: yes. it is trivial to allocate a token buffer per thread, and then submit
10195bd8deadSopenharmony_ci    them in the main thread sequentially. since the implementation is not involved
10205bd8deadSopenharmony_ci    when the application writes to them, the only thread safety requirements are in
10215bd8deadSopenharmony_ci    the application itself.
10225bd8deadSopenharmony_ci    Command lists and state objects are, however, currently not context share-able,
10235bd8deadSopenharmony_ci    though as rendering is much more efficient now, the main dispatching thread can
10245bd8deadSopenharmony_ci    spend the time on preparing state objects prior drawing. The cost of glStateCaptureNV
10255bd8deadSopenharmony_ci    is no worse than a classic API draw call, and exploiting temporal coherence not too
10265bd8deadSopenharmony_ci    many states would be "new" frame to frame, but instead cached states can be reused.
10275bd8deadSopenharmony_ci    
10285bd8deadSopenharmony_ci    14) Can I reuse token buffer multiple times ?
10295bd8deadSopenharmony_ci    
10305bd8deadSopenharmony_ci    RESOLVED: yes.
10315bd8deadSopenharmony_ci     
10325bd8deadSopenharmony_ci    15) Should we use a fixed length decoding or at the very least a size in the header ?
10335bd8deadSopenharmony_ci    
10345bd8deadSopenharmony_ci    RESOLVED: fixed length is used. As basic consistency check the size is also passed to header generation.
10355bd8deadSopenharmony_ci    The NOP command can be used to pad structures to custom sizes.
10365bd8deadSopenharmony_ci
10375bd8deadSopenharmony_ci    16) Can I do buffer updates in a single DrawCommands call ?
10385bd8deadSopenharmony_ci    
10395bd8deadSopenharmony_ci    RESOLVED: NO. 
10405bd8deadSopenharmony_ci    Updating memory in general requires synchronization, and having lots of
10415bd8deadSopenharmony_ci    updates inside a single DrawCommands would become a performance bottleneck.
10425bd8deadSopenharmony_ci
10435bd8deadSopenharmony_ci    17) I want to implement some occlusion scheme and skip some of the draws; how do I do this ?
10445bd8deadSopenharmony_ci    
10455bd8deadSopenharmony_ci    RESOLVED: this extension does not offer a conditional render facility, but this can be
10465bd8deadSopenharmony_ci    implemented by using NOP or preferably TERMINATE_SEQUENCE commands in the stream.
10475bd8deadSopenharmony_ci    
10485bd8deadSopenharmony_ci    18) I want to implement some level of detail scheme; is that possible ?
10495bd8deadSopenharmony_ci    
10505bd8deadSopenharmony_ci    RESOLVED: you can use NOP or TERMINATE_SEQUENCE to skip the level of details that you don't want to draw.
10515bd8deadSopenharmony_ci
10525bd8deadSopenharmony_ci    19) Why can't I just get a token to change the state, and avoid specifying lists of
10535bd8deadSopenharmony_ci    state and indirect buffers ?
10545bd8deadSopenharmony_ci    
10555bd8deadSopenharmony_ci    RESOLVED: Getting a token to specify a state switch imply that the application would
10565bd8deadSopenharmony_ci    have access to a virtual address of state changes. This would potentially open security
10575bd8deadSopenharmony_ci    issue, since part of the validation may involve complex sequence of programming.
10585bd8deadSopenharmony_ci
10595bd8deadSopenharmony_ci    20) Instead of void** which means all commands must be stored in one buffer, could GLuint64** be used
10605bd8deadSopenharmony_ci    when EnableClientState(DRAW_INDIRECT_UNIFIED_NV) is set? This would allow managing different command
10615bd8deadSopenharmony_ci    buffers independently.
10625bd8deadSopenharmony_ci
10635bd8deadSopenharmony_ci    RESOLVED: separate Address command added
10645bd8deadSopenharmony_ci
10655bd8deadSopenharmony_ci    21) How big can each indirect command list's buffer size be? 
10665bd8deadSopenharmony_ci
10675bd8deadSopenharmony_ci    RESOLVED: no limit required.
10685bd8deadSopenharmony_ci
10695bd8deadSopenharmony_ci    22) How to retrieve the "index" within UniformAddressCommandNV, or is that the GL binding point?
10705bd8deadSopenharmony_ci   
10715bd8deadSopenharmony_ci    RESOLVED: added commandBindableNV layout qualifier in GLSL for uniform blocks to ensure fixed binding unit.
10725bd8deadSopenharmony_ci    Also added stage value to command.
10735bd8deadSopenharmony_ci
10745bd8deadSopenharmony_ci    23) In what condition is the state left, that is modified by tokens, after the dispatch call?
10755bd8deadSopenharmony_ci
10765bd8deadSopenharmony_ci    RESOLVED: state is reset.
10775bd8deadSopenharmony_ci    
10785bd8deadSopenharmony_ci    24) How does working with this extension look like
10795bd8deadSopenharmony_ci    
10805bd8deadSopenharmony_ci    You will find related samples at https://github.com/nvpro-samples
10815bd8deadSopenharmony_ci    
10825bd8deadSopenharmony_ci    25) How can I use textures, images, shader storage or atomic counter buffers in combination with state objects?
10835bd8deadSopenharmony_ci
10845bd8deadSopenharmony_ci    Textures and images are covered via NV/ARB_bindless_texture, you can store their handles inside uniform buffers.
10855bd8deadSopenharmony_ci    Shader storage and atomic counter buffers are currently not directly exposed, however NV_gpu_shader5 allows
10865bd8deadSopenharmony_ci    storing pointers to such buffers inside uniform buffers as well. Atomic counters can be replaced by regular
10875bd8deadSopenharmony_ci    atomic increments.
10885bd8deadSopenharmony_ci
10895bd8deadSopenharmony_ci    Alternatively use DrawCommandsNV or DrawCommandsAddressNV, which does support any GLSL programs with these
10905bd8deadSopenharmony_ci    resource bindings, as well as default-block uniforms.
10915bd8deadSopenharmony_ci
10925bd8deadSopenharmony_ci
10935bd8deadSopenharmony_ciRevision History
10945bd8deadSopenharmony_ci
10955bd8deadSopenharmony_ci    Rev.    Date      Author    Changes
10965bd8deadSopenharmony_ci    ----  --------    --------  -----------------------------------------
10975bd8deadSopenharmony_ci     6    11/3/2015   ckubisch  Rephrase what stateobjects capture and what not
10985bd8deadSopenharmony_ci     5    8/17/2015   ckubisch  correct errors for DrawCommandsNV and DrawCommandsAddressNV
10995bd8deadSopenharmony_ci                                rendering to default framebuffer is not allowed. Clarify
11005bd8deadSopenharmony_ci                                which state is inherited (updated Issue 25).
11015bd8deadSopenharmony_ci     4    6/18/2015   ckubisch  Add missing interaction with ARB_shader_draw_parameters
11025bd8deadSopenharmony_ci     3    5/27/2015   jemmons   Multiple minor fixes and clarifications
11035bd8deadSopenharmony_ci     2    4/16/2015   pboudier  Fix incorrect type (size_t is now sizei) in ListDrawCommandsStatesClientNV
11045bd8deadSopenharmony_ci     1                pboudier  concept
11055bd8deadSopenharmony_ci                      jbolz     base spec
11065bd8deadSopenharmony_ci                      ckubisch  detailed spec
11075bd8deadSopenharmony_ci                      mjk       Internal revisions
1108