15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    ARB_instanced_arrays
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_ARB_instanced_arrays
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Michael Gold, NVIDIA
125bd8deadSopenharmony_ci    James Helferty, TransGaming Inc.
135bd8deadSopenharmony_ci    Daniel Koch, TransGaming Inc.
145bd8deadSopenharmony_ci    John Rosasco, Apple
155bd8deadSopenharmony_ci    Mark Kilgard, NVIDIA
165bd8deadSopenharmony_ci    Piers Daniell, NVIDIA
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ciContact
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ci    James Helferty, TransGaming Inc. (james 'at' transgaming.com)
215bd8deadSopenharmony_ci    Daniel Koch, TransGaming Inc. (daniel 'at' transgaming.com)
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ciNotice
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ci    Copyright (c) 2008-2013 The Khronos Group Inc. Copyright terms at
265bd8deadSopenharmony_ci        http://www.khronos.org/registry/speccopyright.html
275bd8deadSopenharmony_ci
285bd8deadSopenharmony_ciSpecification Update Policy
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ci    Khronos-approved extension specifications are updated in response to
315bd8deadSopenharmony_ci    issues and bugs prioritized by the Khronos OpenGL Working Group. For
325bd8deadSopenharmony_ci    extensions which have been promoted to a core Specification, fixes will
335bd8deadSopenharmony_ci    first appear in the latest version of that core Specification, and will
345bd8deadSopenharmony_ci    eventually be backported to the extension document. This policy is
355bd8deadSopenharmony_ci    described in more detail at
365bd8deadSopenharmony_ci        https://www.khronos.org/registry/OpenGL/docs/update_policy.php
375bd8deadSopenharmony_ci
385bd8deadSopenharmony_ciStatus
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    Approved by the ARB on July 11, 2008.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ciVersion
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    Last Modified Date:  August 8, 2013
455bd8deadSopenharmony_ci    Author Revision: 7
465bd8deadSopenharmony_ci
475bd8deadSopenharmony_ci    EXT_direct_state_access interacton added with revision 7.
485bd8deadSopenharmony_ci
495bd8deadSopenharmony_ciNumber
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    ARB Extension #49
525bd8deadSopenharmony_ci
535bd8deadSopenharmony_ciDependencies
545bd8deadSopenharmony_ci
555bd8deadSopenharmony_ci    OpenGL 1.1 is required.
565bd8deadSopenharmony_ci
575bd8deadSopenharmony_ci    This extension is written against the OpenGL 2.1 Specification.
585bd8deadSopenharmony_ci
595bd8deadSopenharmony_ci    ARB_draw_instanced affects the definition of this extension.
605bd8deadSopenharmony_ci    
615bd8deadSopenharmony_ci    EXT_draw_instanced affects the definition of this extension.
625bd8deadSopenharmony_ci    
635bd8deadSopenharmony_ci    EXT_gpu_shader4 affects the definition of this extension.
645bd8deadSopenharmony_ci
655bd8deadSopenharmony_ciOverview
665bd8deadSopenharmony_ci
675bd8deadSopenharmony_ci    A common use case in GL for some applications is to be able to
685bd8deadSopenharmony_ci    draw the same object, or groups of similar objects that share
695bd8deadSopenharmony_ci    vertex data, primitive count and type, multiple times.  This 
705bd8deadSopenharmony_ci    extension provides a means of accelerating such use cases while 
715bd8deadSopenharmony_ci    restricting the number of API calls, and keeping the amount of 
725bd8deadSopenharmony_ci    duplicate data to a minimum.
735bd8deadSopenharmony_ci    
745bd8deadSopenharmony_ci    In particular, this extension specifies an alternative to the 
755bd8deadSopenharmony_ci    read-only shader variable introduced by ARB_draw_instanced.  It
765bd8deadSopenharmony_ci    uses the same draw calls introduced by that extension, but 
775bd8deadSopenharmony_ci    redefines them so that a vertex shader can instead use vertex 
785bd8deadSopenharmony_ci    array attributes as a source of instance data.
795bd8deadSopenharmony_ci    
805bd8deadSopenharmony_ci    This extension introduces an array "divisor" for generic
815bd8deadSopenharmony_ci    vertex array attributes, which when non-zero specifies that the
825bd8deadSopenharmony_ci    attribute is "instanced."  An instanced attribute does not
835bd8deadSopenharmony_ci    advance per-vertex as usual, but rather after every <divisor>
845bd8deadSopenharmony_ci    conceptual draw calls.
855bd8deadSopenharmony_ci    
865bd8deadSopenharmony_ci    (Attributes which aren't instanced are repeated in their entirety
875bd8deadSopenharmony_ci    for every conceptual draw call.)
885bd8deadSopenharmony_ci    
895bd8deadSopenharmony_ci    By specifying transform data in an instanced attribute or series
905bd8deadSopenharmony_ci    of instanced attributes, vertex shaders can, in concert with the 
915bd8deadSopenharmony_ci    instancing draw calls, draw multiple instances of an object with 
925bd8deadSopenharmony_ci    one draw call.
935bd8deadSopenharmony_ci
945bd8deadSopenharmony_ciIP Status
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci    No known IP claims.
975bd8deadSopenharmony_ci
985bd8deadSopenharmony_ciNew Tokens
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci    Accepted by the <pname> parameters of GetVertexAttribdv,
1015bd8deadSopenharmony_ci    GetVertexAttribfv, and GetVertexAttribiv:
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci        VERTEX_ATTRIB_ARRAY_DIVISOR_ARB                 0x88FE
1045bd8deadSopenharmony_ci
1055bd8deadSopenharmony_ciNew Procedures and Functions
1065bd8deadSopenharmony_ci
1075bd8deadSopenharmony_ci    void VertexAttribDivisorARB(uint index, uint divisor);
1085bd8deadSopenharmony_ci
1095bd8deadSopenharmony_ci    When EXT_direct_state_access is present:
1105bd8deadSopenharmony_ci
1115bd8deadSopenharmony_ci        void VertexArrayVertexAttribDivisorEXT(uint vaobj, uint index, uint divisor);
1125bd8deadSopenharmony_ci
1135bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.1 Specification
1145bd8deadSopenharmony_ci(OpenGL Operation)
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci    Modify section 2.8 (Vertex Arrays), p. 23
1175bd8deadSopenharmony_ci    
1185bd8deadSopenharmony_ci    (remove modifications to section 2.8 made by ARB_draw_instanced
1195bd8deadSopenharmony_ci    and EXT_draw_instanced, and replace everything from the second 
1205bd8deadSopenharmony_ci    paragraph, p. 27 through the second paragraph, p. 30)
1215bd8deadSopenharmony_ci    The internal counter <instanceID> is a 32-bit integer value which
1225bd8deadSopenharmony_ci    may be read by a vertex program as <vertex.instance>, as described
1235bd8deadSopenharmony_ci    in section 2.X.3.2, or vertex shader as <gl_InstanceIDARB>, as
1245bd8deadSopenharmony_ci    described in section 2.15.4.2.  The value of this counter is
1255bd8deadSopenharmony_ci    always zero, except as noted.
1265bd8deadSopenharmony_ci
1275bd8deadSopenharmony_ci    The command
1285bd8deadSopenharmony_ci
1295bd8deadSopenharmony_ci        void VertexAttribDivisorARB(uint index, uint divisor);
1305bd8deadSopenharmony_ci
1315bd8deadSopenharmony_ci    modifies the rate at which generic vertex attributes advance when
1325bd8deadSopenharmony_ci    rendering multiple instances of primitives in a single draw call.
1335bd8deadSopenharmony_ci    If <divisor> is zero, the attribute at slot <index> advances once
1345bd8deadSopenharmony_ci    per vertex.  If <divisor> is non-zero, the attribute advances once
1355bd8deadSopenharmony_ci    per <divisor> instances of the set(s) of vertices being rendered.
1365bd8deadSopenharmony_ci    An attribute is referred to as <instanced> if its <divisor> value
1375bd8deadSopenharmony_ci    is non-zero.
1385bd8deadSopenharmony_ci
1395bd8deadSopenharmony_ci    The function
1405bd8deadSopenharmony_ci
1415bd8deadSopenharmony_ci        void ArrayElementInstanced( int i, int instance );
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci    does not exist in the GL, but is used to describe functionality in
1445bd8deadSopenharmony_ci    the rest of this section.  This function transfers the <i>th
1455bd8deadSopenharmony_ci    element of every enabled, non-instanced array and the 
1465bd8deadSopenharmony_ci    floor(<instance>/<divisor>)'th element of every enabled instanced 
1475bd8deadSopenharmony_ci    array to the GL. The effect of ArrayElementInstanced(i) is the 
1485bd8deadSopenharmony_ci    same as the effect of the command sequence
1495bd8deadSopenharmony_ci
1505bd8deadSopenharmony_ci        if (normal array enabled)
1515bd8deadSopenharmony_ci            Normal3[type]v(normal array element i);
1525bd8deadSopenharmony_ci        if (color array enabled)
1535bd8deadSopenharmony_ci            Color[size][type]v(color array element i);
1545bd8deadSopenharmony_ci        if (secondary color array enabled)
1555bd8deadSopenharmony_ci            SecondaryColor3[type]v(secondary color array element i);
1565bd8deadSopenharmony_ci        if (fog coordinate array enabled)
1575bd8deadSopenharmony_ci            FogCoord[type]v(fog coordinate array element i);
1585bd8deadSopenharmony_ci        for (j = 0; j < textureUnits; j++) {
1595bd8deadSopenharmony_ci            if (texture coordinate set j array enabled)
1605bd8deadSopenharmony_ci                MultiTexCoord[size][type]v(TEXTURE0 + j, texture coordinate set j array element i);
1615bd8deadSopenharmony_ci        }
1625bd8deadSopenharmony_ci        if (color index array enabled)
1635bd8deadSopenharmony_ci            Index[type]v(color index array element i);
1645bd8deadSopenharmony_ci        if (edge flag array enabled)
1655bd8deadSopenharmony_ci            EdgeFlagv(edge flag array element i);
1665bd8deadSopenharmony_ci        for (j = 1; j < genericAttributes; j++) {
1675bd8deadSopenharmony_ci            if (generic vertex attribute j array enabled) {
1685bd8deadSopenharmony_ci                if (VERTEX_ATTRIB_ARRAY_DIVISOR_ARB[j] > 0)
1695bd8deadSopenharmony_ci                    k = floor(instance / VERTEX_ATTRIB_ARRAY_DIVISOR_ARB[j]);
1705bd8deadSopenharmony_ci                else
1715bd8deadSopenharmony_ci                    k = i;
1725bd8deadSopenharmony_ci                if (generic vertex attribute j array normalization flag is set, and
1735bd8deadSopenharmony_ci                    type is not FLOAT or DOUBLE)
1745bd8deadSopenharmony_ci                    VertexAttrib[size]N[type]v(j, generic vertex attribute j array element k);
1755bd8deadSopenharmony_ci                else
1765bd8deadSopenharmony_ci                    VertexAttrib[size][type]v(j, generic vertex attribute j array element k);
1775bd8deadSopenharmony_ci            }
1785bd8deadSopenharmony_ci        }
1795bd8deadSopenharmony_ci        if (generic attribute array 0 enabled) {
1805bd8deadSopenharmony_ci            if (VERTEX_ATTRIB_ARRAY_DIVISOR_ARB[0] > 0)
1815bd8deadSopenharmony_ci                k = floor(instance / VERTEX_ATTRIB_ARRAY_DIVISOR_ARB[0]);
1825bd8deadSopenharmony_ci            else
1835bd8deadSopenharmony_ci                k = i;
1845bd8deadSopenharmony_ci            if (generic vertex attribute 0 array normalization flag is set, and
1855bd8deadSopenharmony_ci                type is not FLOAT or DOUBLE)
1865bd8deadSopenharmony_ci                VertexAttrib[size]N[type]v(0, generic vertex attribute 0 array element k);
1875bd8deadSopenharmony_ci            else
1885bd8deadSopenharmony_ci                VertexAttrib[size][type]v(0, generic vertex attribute 0 array element k);
1895bd8deadSopenharmony_ci        } else if (vertex array enabled) {
1905bd8deadSopenharmony_ci            Vertex[size][type]v(vertex array element i);
1915bd8deadSopenharmony_ci        }
1925bd8deadSopenharmony_ci    
1935bd8deadSopenharmony_ci    where <textureUnits> and <genericAttributes> give the number of
1945bd8deadSopenharmony_ci    texture coordinate sets and generic vertex attributes supported by
1955bd8deadSopenharmony_ci    the implementation, respectively.  "[size]" and "[type]"
1965bd8deadSopenharmony_ci    correspond to the size and type of the corresponding array.  For
1975bd8deadSopenharmony_ci    generic vertex attributes, it is assumed that a complete set of
1985bd8deadSopenharmony_ci    vertex attribute commands exists, even though not all such
1995bd8deadSopenharmony_ci    functions are provided by the GL.
2005bd8deadSopenharmony_ci
2015bd8deadSopenharmony_ci    The command
2025bd8deadSopenharmony_ci
2035bd8deadSopenharmony_ci        void ArrayElement( int i );
2045bd8deadSopenharmony_ci
2055bd8deadSopenharmony_ci    behaves identically to ArrayElementInstanced with the instance
2065bd8deadSopenharmony_ci    set to zero; it is equivalent to calling
2075bd8deadSopenharmony_ci
2085bd8deadSopenharmony_ci        ArrayElementInstanced(i, 0);
2095bd8deadSopenharmony_ci
2105bd8deadSopenharmony_ci    Changes made to array data between the execution of Begin and the
2115bd8deadSopenharmony_ci    corresponding execution of End may affect calls to ArrayElement
2125bd8deadSopenharmony_ci    that are made within the same Begin/End period in non-sequential
2135bd8deadSopenharmony_ci    ways. That is, a call to ArrayElement that precedes a change to
2145bd8deadSopenharmony_ci    array data may access the changed data, and a call that follows a
2155bd8deadSopenharmony_ci    change to array data may access original data.
2165bd8deadSopenharmony_ci
2175bd8deadSopenharmony_ci    Specifying i < 0 results in undefined behavior. Generating the
2185bd8deadSopenharmony_ci    error INVALID VALUE is recommended in this case.
2195bd8deadSopenharmony_ci
2205bd8deadSopenharmony_ci    The function
2215bd8deadSopenharmony_ci
2225bd8deadSopenharmony_ci        void DrawArraysOneInstance( enum mode, int first, sizei count, int instance );
2235bd8deadSopenharmony_ci
2245bd8deadSopenharmony_ci    does not exist in the GL, but is used to describe functionality in
2255bd8deadSopenharmony_ci    the rest of this section.  This function constructs a sequence of
2265bd8deadSopenharmony_ci    geometric primitives using elements <first> through <first> +
2275bd8deadSopenharmony_ci    <count> - 1 of each enabled, non-instanced array and the
2285bd8deadSopenharmony_ci    <instance>th element of each enabled, instanced array.  <mode>
2295bd8deadSopenharmony_ci    specifies what kind of primitives are constructed; it accepts the
2305bd8deadSopenharmony_ci    same token values as the mode parameter of the Begin command. The
2315bd8deadSopenharmony_ci    effect of
2325bd8deadSopenharmony_ci
2335bd8deadSopenharmony_ci        DrawArraysOneInstance (mode, first, count, int instance);
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ci    is the same as the effect of the command sequence
2365bd8deadSopenharmony_ci
2375bd8deadSopenharmony_ci        Begin(mode);
2385bd8deadSopenharmony_ci        for (int i = 0; i < count ; i++)
2395bd8deadSopenharmony_ci            ArrayElementInstanced(first+ i, instance);
2405bd8deadSopenharmony_ci        End();
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    with one exception: the current normal coordinates, color,
2435bd8deadSopenharmony_ci    secondary color, color index, edge flag, fog coordinate, texture
2445bd8deadSopenharmony_ci    coordinates, and generic attributes are each indeterminate after
2455bd8deadSopenharmony_ci    execution of DrawArraysOneInstance, if the corresponding array is
2465bd8deadSopenharmony_ci    enabled. Current values corresponding to disabled arrays are not
2475bd8deadSopenharmony_ci    modified by the execution of DrawArraysOneInstance.
2485bd8deadSopenharmony_ci
2495bd8deadSopenharmony_ci    Specifying first < 0 results in undefined behavior.  Generating
2505bd8deadSopenharmony_ci    the error INVALID_VALUE is recommended in this case.
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci    The command
2535bd8deadSopenharmony_ci
2545bd8deadSopenharmony_ci        void DrawArrays( enum mode, int first, sizei count );
2555bd8deadSopenharmony_ci
2565bd8deadSopenharmony_ci    behaves identically to DrawArraysOneInstance with the instance
2575bd8deadSopenharmony_ci    set to zero; the effect of calling
2585bd8deadSopenharmony_ci
2595bd8deadSopenharmony_ci        DrawArrays(mode, first, count);
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci    is equivalent to the command sequence:
2625bd8deadSopenharmony_ci
2635bd8deadSopenharmony_ci        if (mode or count is invalid )
2645bd8deadSopenharmony_ci            generate appropriate error
2655bd8deadSopenharmony_ci        else
2665bd8deadSopenharmony_ci            DrawArraysOneInstance(mode, first, count, 0);
2675bd8deadSopenharmony_ci
2685bd8deadSopenharmony_ci    The command
2695bd8deadSopenharmony_ci
2705bd8deadSopenharmony_ci        void DrawArraysInstancedARB(enum mode, int first, sizei count,
2715bd8deadSopenharmony_ci                sizei primcount);
2725bd8deadSopenharmony_ci
2735bd8deadSopenharmony_ci    behaves identically to DrawArrays except that <primcount>
2745bd8deadSopenharmony_ci    instances of the range of elements are executed, the value of
2755bd8deadSopenharmony_ci    <instanceID> advances for each iteration, and the instanced
2765bd8deadSopenharmony_ci    elements advance per instance depending on the value of the divisor
2775bd8deadSopenharmony_ci    for that vertex attribute set with VertexAttribDivisorARB.  It has the 
2785bd8deadSopenharmony_ci    same effect as:
2795bd8deadSopenharmony_ci
2805bd8deadSopenharmony_ci        if (mode or count is invalid)
2815bd8deadSopenharmony_ci            generate appropriate error
2825bd8deadSopenharmony_ci        else {
2835bd8deadSopenharmony_ci            for (i = 0; i < primcount; i++) {
2845bd8deadSopenharmony_ci                instanceID = i;
2855bd8deadSopenharmony_ci                DrawArraysOneInstance(mode, first, count, i);
2865bd8deadSopenharmony_ci            }
2875bd8deadSopenharmony_ci            instanceID = 0;
2885bd8deadSopenharmony_ci        }
2895bd8deadSopenharmony_ci
2905bd8deadSopenharmony_ci    The command
2915bd8deadSopenharmony_ci
2925bd8deadSopenharmony_ci        void MultiDrawArrays( enum mode, int *first,
2935bd8deadSopenharmony_ci            sizei *count, sizei primcount );
2945bd8deadSopenharmony_ci
2955bd8deadSopenharmony_ci    behaves identically to DrawArraysInstancedARB except that
2965bd8deadSopenharmony_ci    <primcount> separate ranges of elements are specified instead,
2975bd8deadSopenharmony_ci    all elements are treated as though they are not instanced,
2985bd8deadSopenharmony_ci    and the value of <instanceID> stays at 0.  It has the same
2995bd8deadSopenharmony_ci    effect as:
3005bd8deadSopenharmony_ci
3015bd8deadSopenharmony_ci        if (mode is invalid)
3025bd8deadSopenharmony_ci            generate appropriate error
3035bd8deadSopenharmony_ci        else {
3045bd8deadSopenharmony_ci            for (i = 0; i < primcount; i++) {
3055bd8deadSopenharmony_ci                if (count[i] > 0)
3065bd8deadSopenharmony_ci                    DrawArraysOneInstance(mode, first[i], count[i], 0);
3075bd8deadSopenharmony_ci            }
3085bd8deadSopenharmony_ci        }
3095bd8deadSopenharmony_ci
3105bd8deadSopenharmony_ci    The function
3115bd8deadSopenharmony_ci
3125bd8deadSopenharmony_ci        void DrawElementsOneInstance( enum mode, sizei count, enum type,
3135bd8deadSopenharmony_ci            void *indices );
3145bd8deadSopenharmony_ci
3155bd8deadSopenharmony_ci    does not exist in the GL, but is used to describe functionality in
3165bd8deadSopenharmony_ci    the rest of this section.  This function constructs a sequence of
3175bd8deadSopenharmony_ci    geometric primitives using the <count> elements whose indices are
3185bd8deadSopenharmony_ci    stored in indices. <type> must be one of UNSIGNED_BYTE,
3195bd8deadSopenharmony_ci    UNSIGNED_SHORT, or UNSIGNED_INT, indicating that the values in
3205bd8deadSopenharmony_ci    <indices> are indices of GL type ubyte, ushort, or uint
3215bd8deadSopenharmony_ci    respectively. <mode> specifies what kind of primitives are
3225bd8deadSopenharmony_ci    constructed; it accepts the same token values as the mode
3235bd8deadSopenharmony_ci    parameter of the Begin command. The effect of
3245bd8deadSopenharmony_ci
3255bd8deadSopenharmony_ci        DrawElementsOneInstance (mode, count, type, indices);
3265bd8deadSopenharmony_ci
3275bd8deadSopenharmony_ci    is the same as the effect of the command sequence
3285bd8deadSopenharmony_ci
3295bd8deadSopenharmony_ci        Begin(mode);
3305bd8deadSopenharmony_ci        for (int i = 0; i < count ; i++)
3315bd8deadSopenharmony_ci            ArrayElementInstanced(indices[i], instance);
3325bd8deadSopenharmony_ci        End();
3335bd8deadSopenharmony_ci
3345bd8deadSopenharmony_ci    with one exception: the current normal coordinates, color,
3355bd8deadSopenharmony_ci    secondary color, color index, edge flag, fog coordinate, texture
3365bd8deadSopenharmony_ci    coordinates, and generic attributes are each indeterminate after
3375bd8deadSopenharmony_ci    execution of DrawElementsOneInstance, if the corresponding array is
3385bd8deadSopenharmony_ci    enabled. Current values corresponding to disabled arrays are not
3395bd8deadSopenharmony_ci    modified by the execution of DrawElementsOneInstance.
3405bd8deadSopenharmony_ci
3415bd8deadSopenharmony_ci    The command
3425bd8deadSopenharmony_ci
3435bd8deadSopenharmony_ci        void DrawElements( enum mode, sizei count, enum type,
3445bd8deadSopenharmony_ci            void *indices );
3455bd8deadSopenharmony_ci
3465bd8deadSopenharmony_ci    behaves identically to DrawElementsOneInstance with the instance
3475bd8deadSopenharmony_ci    paremeter set to zero; the effect of calling
3485bd8deadSopenharmony_ci
3495bd8deadSopenharmony_ci        DrawElements(mode, count, type, indices);
3505bd8deadSopenharmony_ci
3515bd8deadSopenharmony_ci    is equivalent to the command sequence:
3525bd8deadSopenharmony_ci
3535bd8deadSopenharmony_ci        if (mode, count or type is invalid )
3545bd8deadSopenharmony_ci            generate appropriate error
3555bd8deadSopenharmony_ci        else
3565bd8deadSopenharmony_ci            DrawElementsOneInstance(mode, count, type, indices, 0);
3575bd8deadSopenharmony_ci
3585bd8deadSopenharmony_ci    The command
3595bd8deadSopenharmony_ci
3605bd8deadSopenharmony_ci        void DrawElementsInstancedARB(enum mode, sizei count, enum type,
3615bd8deadSopenharmony_ci                const void *indices, sizei primcount);
3625bd8deadSopenharmony_ci
3635bd8deadSopenharmony_ci    behaves identically to DrawElements except that <primcount>
3645bd8deadSopenharmony_ci    instances of the set of elements are executed, the value of
3655bd8deadSopenharmony_ci    <instanceID> advances between each set, and the instance
3665bd8deadSopenharmony_ci    advances between each set.  It has the same effect as:
3675bd8deadSopenharmony_ci
3685bd8deadSopenharmony_ci        if (mode, count, or type is invalid )
3695bd8deadSopenharmony_ci            generate appropriate error
3705bd8deadSopenharmony_ci        else {
3715bd8deadSopenharmony_ci            for (int i = 0; i < primcount; i++) {
3725bd8deadSopenharmony_ci                instanceID = i;
3735bd8deadSopenharmony_ci                DrawElementsOneInstance(mode, count, type, indices, i);
3745bd8deadSopenharmony_ci            }
3755bd8deadSopenharmony_ci            instanceID = 0;
3765bd8deadSopenharmony_ci        }
3775bd8deadSopenharmony_ci
3785bd8deadSopenharmony_ci    The command
3795bd8deadSopenharmony_ci
3805bd8deadSopenharmony_ci        void MultiDrawElements( enum mode, sizei *count,
3815bd8deadSopenharmony_ci            enum type, void **indices, sizei primcount );
3825bd8deadSopenharmony_ci
3835bd8deadSopenharmony_ci    behaves identically to DrawElementsInstancedARB except that
3845bd8deadSopenharmony_ci    <primcount> separate sets of elements are specified instead, all
3855bd8deadSopenharmony_ci    elements are treated as though they are not instanced, and the
3865bd8deadSopenharmony_ci    value of <instanceID> stays at 0.  It has the same effect as:
3875bd8deadSopenharmony_ci
3885bd8deadSopenharmony_ci        if (mode, count, or type is invalid )
3895bd8deadSopenharmony_ci            generate appropriate error
3905bd8deadSopenharmony_ci        else {
3915bd8deadSopenharmony_ci            for (int i = 0; i < primcount; i++)
3925bd8deadSopenharmony_ci                DrawElementsOneInstance(mode, count[i], type, indices[i], 0);
3935bd8deadSopenharmony_ci        }
3945bd8deadSopenharmony_ci
3955bd8deadSopenharmony_ci    The command
3965bd8deadSopenharmony_ci
3975bd8deadSopenharmony_ci        void DrawRangeElements( enum mode, uint start,
3985bd8deadSopenharmony_ci            uint end, sizei count, enum type, void *indices );
3995bd8deadSopenharmony_ci
4005bd8deadSopenharmony_ci    is a restricted form of DrawElements. ...
4015bd8deadSopenharmony_ci
4025bd8deadSopenharmony_ci    Modify section 2.8 (Vertex Arrays), p. 23
4035bd8deadSopenharmony_ci    
4045bd8deadSopenharmony_ci    (remove section before final paragraph, p. 30, that was added by
4055bd8deadSopenharmony_ci    ARB_draw_instanced and EXT_draw_instanced)
4065bd8deadSopenharmony_ci
4075bd8deadSopenharmony_ci    Modify section 2.8 (Vertex Arrays), p. 33
4085bd8deadSopenharmony_ci  
4095bd8deadSopenharmony_ci    (in the list of client state required to implement vertex arrays add)
4105bd8deadSopenharmony_ci    ... <n> integers representing vertex attribute divisors, ...
4115bd8deadSopenharmony_ci
4125bd8deadSopenharmony_ci    (in the list of initial state add)
4135bd8deadSopenharmony_ci    ... the divisors are each zero, ...
4145bd8deadSopenharmony_ci
4155bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.1 Specification
4165bd8deadSopenharmony_ci(Special Functions)
4175bd8deadSopenharmony_ci
4185bd8deadSopenharmony_ci    The error INVALID_OPERATION is generated if DrawArraysInstancedARB
4195bd8deadSopenharmony_ci    or DrawElementsInstancedARB is called during display list
4205bd8deadSopenharmony_ci    compilation.
4215bd8deadSopenharmony_ci
4225bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.1 Specification (State and State
4235bd8deadSopenharmony_ciRequests)
4245bd8deadSopenharmony_ci
4255bd8deadSopenharmony_ci    In section 6.1.14, add to the list of pnames accepted by
4265bd8deadSopenharmony_ci    GetVertexAttrib*v: VERTEX_ATTRIB_ARRAY_DIVISOR_ARB
4275bd8deadSopenharmony_ci
4285bd8deadSopenharmony_ci************************************************************************
4295bd8deadSopenharmony_ci
4305bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications
4315bd8deadSopenharmony_ci
4325bd8deadSopenharmony_ci    None
4335bd8deadSopenharmony_ci
4345bd8deadSopenharmony_ciDependencies on OpenGL 1.4
4355bd8deadSopenharmony_ci
4365bd8deadSopenharmony_ci    If OpenGL 1.4 is not supported, all discussion of MultiDrawArrays
4375bd8deadSopenharmony_ci    and MultiDrawElements should be removed from section 2.8.
4385bd8deadSopenharmony_ci
4395bd8deadSopenharmony_ciDependencies on ARB_draw_instanced
4405bd8deadSopenharmony_ci
4415bd8deadSopenharmony_ci    If neither ARB_draw_instanced nor EXT_draw_instanced is supported,
4425bd8deadSopenharmony_ci    all references to instanceID should be removed from section 2.8.
4435bd8deadSopenharmony_ci    
4445bd8deadSopenharmony_ci    If ARB_draw_instanced is not supported, all references to gl_InstanceIDARB
4455bd8deadSopenharmony_ci    should be removed from section 2.8.  This extension will introduce
4465bd8deadSopenharmony_ci    the following additional New Procedures and Functions:
4475bd8deadSopenharmony_ci
4485bd8deadSopenharmony_ci        void DrawArraysInstancedARB(enum mode, int first, sizei count,
4495bd8deadSopenharmony_ci                sizei primcount);
4505bd8deadSopenharmony_ci        void DrawElementsInstancedARB(enum mode, sizei count, enum type,
4515bd8deadSopenharmony_ci                const void *indices, sizei primcount);
4525bd8deadSopenharmony_ci
4535bd8deadSopenharmony_ciDependencies on EXT_draw_instanced
4545bd8deadSopenharmony_ci    
4555bd8deadSopenharmony_ci    If EXT_draw_instanced is supported, then DrawArraysInstancedEXT
4565bd8deadSopenharmony_ci    is aliased to DrawArraysInstancedARB, and DrawElementsInstancedEXT
4575bd8deadSopenharmony_ci    is aliased to DrawElementsInstancedARB.
4585bd8deadSopenharmony_ci    
4595bd8deadSopenharmony_ci    If neither ARB_draw_instanced nor EXT_draw_instanced is supported,
4605bd8deadSopenharmony_ci    all references to instanceID should be removed from section 2.8.
4615bd8deadSopenharmony_ci
4625bd8deadSopenharmony_ciDependencies on EXT_gpu_shader4
4635bd8deadSopenharmony_ci
4645bd8deadSopenharmony_ci    If EXT_gpu_shader4 is not supported, all references to gl_InstanceID 
4655bd8deadSopenharmony_ci    should be removed from section 2.8.
4665bd8deadSopenharmony_ci
4675bd8deadSopenharmony_ciDependencies on EXT_direct_state_access
4685bd8deadSopenharmony_ci
4695bd8deadSopenharmony_ci    When EXT_direct_state_access is present, add a new entry point that takes a
4705bd8deadSopenharmony_ci    vertex array object handle:
4715bd8deadSopenharmony_ci
4725bd8deadSopenharmony_ci        void VertexArrayVertexAttribDivisorEXT(uint vaobj, uint index, uint divisor);
4735bd8deadSopenharmony_ci
4745bd8deadSopenharmony_ci    This command behaves identically to glVertexAttribDivisorEXT
4755bd8deadSopenharmony_ci    except it modifies the state of the vertex array object named
4765bd8deadSopenharmony_ci    by its initial vaobj parameter (rather than the currently bound
4775bd8deadSopenharmony_ci    vertex array object).  The vertex array object named by vaobj must
4785bd8deadSopenharmony_ci    be generated by GenVertexArrays (and not since deleted); otherwise
4795bd8deadSopenharmony_ci    an INVALID_OPERATION error is generated.
4805bd8deadSopenharmony_ci
4815bd8deadSopenharmony_ci    GetVertexArrayIntegeri_vEXT must accept VERTEX_ATTRIB_ARRAY_DIVISOR_ARB to return
4825bd8deadSopenharmony_ci    the vertex array object's vertex attrib array divisor state.
4835bd8deadSopenharmony_ci
4845bd8deadSopenharmony_ciErrors
4855bd8deadSopenharmony_ci
4865bd8deadSopenharmony_ci    INVALID_VALUE is generated by VertexAttribDivisorARB if <index>
4875bd8deadSopenharmony_ci    is greater than or equal to MAX_VERTEX_ATTRIBS.
4885bd8deadSopenharmony_ci
4895bd8deadSopenharmony_ci    INVALID_ENUM is generated by DrawElementsInstancedARB if <type> is
4905bd8deadSopenharmony_ci    not one of UNSIGNED_BYTE, UNSIGNED_SHORT or UNSIGNED_INT.
4915bd8deadSopenharmony_ci
4925bd8deadSopenharmony_ci    INVALID_VALUE is generated by DrawArraysInstancedARB if <first> is
4935bd8deadSopenharmony_ci    less than zero.
4945bd8deadSopenharmony_ci
4955bd8deadSopenharmony_ciNew State
4965bd8deadSopenharmony_ci
4975bd8deadSopenharmony_ci    Changes to table 6.7, p. 268 (Vertex Array Data)
4985bd8deadSopenharmony_ci
4995bd8deadSopenharmony_ci                                                         Initial
5005bd8deadSopenharmony_ci    Get Value                        Type     Get Command      Value    Description       Sec.  Attribute
5015bd8deadSopenharmony_ci    ---------                        ----     -----------      -------  -----------       ----  ---------
5025bd8deadSopenharmony_ci    VERTEX_ATTRIB_ARRAY_DIVISOR_ARB  16+ xZ+  GetVertexAttrib  0        Instance Divisor  2.8   vertex-array
5035bd8deadSopenharmony_ci
5045bd8deadSopenharmony_ciIssues
5055bd8deadSopenharmony_ci
5065bd8deadSopenharmony_ci    1) Should legacy arrays be supported, or only generic vertex
5075bd8deadSopenharmony_ci       attribs?
5085bd8deadSopenharmony_ci
5095bd8deadSopenharmony_ci        Resolved: It is possible to render instanced objects which use
5105bd8deadSopenharmony_ci        legacy array types but only the generic arrays may have a
5115bd8deadSopenharmony_ci        divisor.
5125bd8deadSopenharmony_ci
5135bd8deadSopenharmony_ci    2) Should generic attrib zero be instance-able?
5145bd8deadSopenharmony_ci
5155bd8deadSopenharmony_ci        Resolved: Yes. This was added in revision 5 of the spec.
5165bd8deadSopenharmony_ci
5175bd8deadSopenharmony_ci        Prior to revision 5 of this spec, attempting to call 
5185bd8deadSopenharmony_ci        VertexAttribDivisorARB with attrib=0 generated INVALID_VALUE. 
5195bd8deadSopenharmony_ci        It was originally thought that this implied issuing a vertex at 
5205bd8deadSopenharmony_ci        lower frequency than the associated attribs (due to the special 
5215bd8deadSopenharmony_ci        properties of vertex attribute zero in GL 2.x and the compatibility
5225bd8deadSopenharmony_ci        profiles).  That would be true if the immediate-mode model of 
5235bd8deadSopenharmony_ci        instancing was to make an attribute call only once every <N> vertices
5245bd8deadSopenharmony_ci        for instanced attributes -- you wouldn't want to specify a new vertex
5255bd8deadSopenharmony_ci        once every <N> vertices! But that's not the model -- the frequency 
5265bd8deadSopenharmony_ci        <N> is only used to translate an incoming array element <i> into an 
5275bd8deadSopenharmony_ci        attribute index <k>.  Immediate mode calls are still specified as 
5285bd8deadSopenharmony_ci        happening for every vertex. Given this definition, it is not 
5295bd8deadSopenharmony_ci        necessary to do anything differently for attribute zero.
5305bd8deadSopenharmony_ci
5315bd8deadSopenharmony_ci    3) How is ArrayElement affected by this extension?
5325bd8deadSopenharmony_ci
5335bd8deadSopenharmony_ci        Resolved: Arrays with a non-zero divisor return the first
5345bd8deadSopenharmony_ci        element of the array, as if instanceID is fixed at zero.  This
5355bd8deadSopenharmony_ci        allows legacy varray draw calls to give instancing behavior
5365bd8deadSopenharmony_ci        but are still defined in terms of ArrayElement.
5375bd8deadSopenharmony_ci
5385bd8deadSopenharmony_ci    4) Should DrawArraysInstanced and DrawElementsInstanced be compiled
5395bd8deadSopenharmony_ci       into display lists?
5405bd8deadSopenharmony_ci
5415bd8deadSopenharmony_ci        Resolved: No, calling these during display list compilation
5425bd8deadSopenharmony_ci        generate INVALID_OPERATION.  This matches EXT_draw_instanced
5435bd8deadSopenharmony_ci        and ARB_draw_instanced.
5445bd8deadSopenharmony_ci
5455bd8deadSopenharmony_ci    5) Is it useful to have instancing for the MultiDraw* functions?
5465bd8deadSopenharmony_ci
5475bd8deadSopenharmony_ci        Resolved: We will follow the lead of EXT_draw_instanced and 
5485bd8deadSopenharmony_ci        ARB_draw_instanced in not extending these functions.
5495bd8deadSopenharmony_ci
5505bd8deadSopenharmony_ci    6) This extension must elaborate on the definition of functions 
5515bd8deadSopenharmony_ci       added by ARB_draw_instanced.  How do we do this in a manner such
5525bd8deadSopenharmony_ci       that both extensions may coexist?
5535bd8deadSopenharmony_ci       
5545bd8deadSopenharmony_ci        Resolved: This extension is specified so that it applies on
5555bd8deadSopenharmony_ci        top of ARB_draw_instanced and EXT_draw_instanced.  As a 
5565bd8deadSopenharmony_ci        result, some portions modified by those extensions are 
5575bd8deadSopenharmony_ci        replaced in this extension.  In the event that those
5585bd8deadSopenharmony_ci        extensions are not supported, this extension reintroduces
5595bd8deadSopenharmony_ci        the draw calls from ARB_draw_instanced.
5605bd8deadSopenharmony_ci
5615bd8deadSopenharmony_ci    7) How should EXT_direct_state_access interact with this extension?
5625bd8deadSopenharmony_ci
5635bd8deadSopenharmony_ci        Resolved:  Add glVertexArrayVertexAttribDivisorEXT selector-free
5645bd8deadSopenharmony_ci        vertex array object command and glGetVertexArrayIntegeri_vEXT
5655bd8deadSopenharmony_ci        query must accept VERTEX_ATTRIB_ARRAY_DIVISOR_ARB to return the
5665bd8deadSopenharmony_ci        vertex array object's vertex attrib array divisor state.
5675bd8deadSopenharmony_ci
5685bd8deadSopenharmony_ci        The DSA interaction was added July 2013.  If implementations
5695bd8deadSopenharmony_ci        respond to a wglGetProcAddress, etc. query for
5705bd8deadSopenharmony_ci        "glVertexArrayVertexAttribDivisorEXT" with a NULL pointer,
5715bd8deadSopenharmony_ci        the DSA functionality is not available.
5725bd8deadSopenharmony_ci
5735bd8deadSopenharmony_ciRevision History
5745bd8deadSopenharmony_ci
5755bd8deadSopenharmony_ci    #7 August 6, 2013 mjk
5765bd8deadSopenharmony_ci       - Add EXT_direct_state_access interaction
5775bd8deadSopenharmony_ci    #6 February 11, 2010 dgkoch
5785bd8deadSopenharmony_ci       - sync language with GL3.3, add required and initial state for divisors
5795bd8deadSopenharmony_ci    #5 January 13, 2010 dgkoch
5805bd8deadSopenharmony_ci       - update spec so that specifying a divisor on vertex attrib 0 is legal (5796)
5815bd8deadSopenharmony_ci       - update resolution of Issue 2 appropriately.
5825bd8deadSopenharmony_ci    #4 January 1, 2010, Jon Leech
5835bd8deadSopenharmony_ci       - Correct Errors section to match spec body
5845bd8deadSopenharmony_ci    #3 July 8, 2008, jhelferty
5855bd8deadSopenharmony_ci       - expanded Overview
5865bd8deadSopenharmony_ci       - changed name of GLSL instance ID variable to follow naming conventions,
5875bd8deadSopenharmony_ci         and match ARB_draw_instanced.
5885bd8deadSopenharmony_ci       - made dependencies and interactions more explicit
5895bd8deadSopenharmony_ci    #2 May 14 2008, jhelferty
5905bd8deadSopenharmony_ci       - changed pname to VERTEX_ATTRIB_ARRAY_DIVISOR_ARB
5915bd8deadSopenharmony_ci       - added dependencies on ARB_draw_instanced
5925bd8deadSopenharmony_ci       - update to GL 2.1 language
5935bd8deadSopenharmony_ci    #1 May 12 2008, dgkoch
5945bd8deadSopenharmony_ci       - copied from NVX_instanced_arrays and renamed. removed original revision history
595