15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_instanced_arrays
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_instanced_arrays
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Contributors to ARB_instanced_arrays desktop OpenGL extension 
125bd8deadSopenharmony_ci        from which this extension borrows heavily
135bd8deadSopenharmony_ci    Abhijit Bhelande, Apple
145bd8deadSopenharmony_ci    Benj Lipchak, Apple
155bd8deadSopenharmony_ci
165bd8deadSopenharmony_ciContact
175bd8deadSopenharmony_ci
185bd8deadSopenharmony_ci    Benj Lipchak, Apple (lipchak 'at' apple.com)
195bd8deadSopenharmony_ci
205bd8deadSopenharmony_ciStatus
215bd8deadSopenharmony_ci
225bd8deadSopenharmony_ci    Complete
235bd8deadSopenharmony_ci
245bd8deadSopenharmony_ciVersion
255bd8deadSopenharmony_ci
265bd8deadSopenharmony_ci    Last Modified Date:     June 26, 2013
275bd8deadSopenharmony_ci    Revision:               2
285bd8deadSopenharmony_ci
295bd8deadSopenharmony_ciNumber
305bd8deadSopenharmony_ci
315bd8deadSopenharmony_ci    OpenGL ES Extension #156
325bd8deadSopenharmony_ci
335bd8deadSopenharmony_ciDependencies
345bd8deadSopenharmony_ci
355bd8deadSopenharmony_ci    OpenGL ES 2.0 is required.
365bd8deadSopenharmony_ci
375bd8deadSopenharmony_ci    This extension is written against the OpenGL ES 2.0 Specification.
385bd8deadSopenharmony_ci    
395bd8deadSopenharmony_ci    OES_element_index_uint affects the definition of this extension.
405bd8deadSopenharmony_ci
415bd8deadSopenharmony_ciOverview
425bd8deadSopenharmony_ci
435bd8deadSopenharmony_ci    A common use case in GL for some applications is to be able to
445bd8deadSopenharmony_ci    draw the same object, or groups of similar objects that share
455bd8deadSopenharmony_ci    vertex data, primitive count and type, multiple times.  This 
465bd8deadSopenharmony_ci    extension provides a means of accelerating such use cases while 
475bd8deadSopenharmony_ci    reducing the number of API calls, and keeping the amount of 
485bd8deadSopenharmony_ci    duplicate data to a minimum.
495bd8deadSopenharmony_ci    
505bd8deadSopenharmony_ci    This extension introduces an array "divisor" for generic
515bd8deadSopenharmony_ci    vertex array attributes, which when non-zero specifies that the
525bd8deadSopenharmony_ci    attribute is "instanced."  An instanced attribute does not
535bd8deadSopenharmony_ci    advance per-vertex as usual, but rather after every <divisor>
545bd8deadSopenharmony_ci    conceptual draw calls.
555bd8deadSopenharmony_ci    
565bd8deadSopenharmony_ci    (Attributes which aren't instanced are repeated in their entirety
575bd8deadSopenharmony_ci    for every conceptual draw call.)
585bd8deadSopenharmony_ci    
595bd8deadSopenharmony_ci    By specifying transform data in an instanced attribute or series
605bd8deadSopenharmony_ci    of instanced attributes, vertex shaders can, in concert with the 
615bd8deadSopenharmony_ci    instancing draw calls, draw multiple instances of an object with 
625bd8deadSopenharmony_ci    one draw call.
635bd8deadSopenharmony_ci
645bd8deadSopenharmony_ciIP Status
655bd8deadSopenharmony_ci
665bd8deadSopenharmony_ci    No known IP claims.
675bd8deadSopenharmony_ci
685bd8deadSopenharmony_ciNew Tokens
695bd8deadSopenharmony_ci
705bd8deadSopenharmony_ci    Accepted by the <pname> parameters of GetVertexAttribfv and 
715bd8deadSopenharmony_ci    GetVertexAttribiv:
725bd8deadSopenharmony_ci
735bd8deadSopenharmony_ci        VERTEX_ATTRIB_ARRAY_DIVISOR_EXT                 0x88FE
745bd8deadSopenharmony_ci
755bd8deadSopenharmony_ciNew Procedures and Functions
765bd8deadSopenharmony_ci
775bd8deadSopenharmony_ci    void VertexAttribDivisorEXT(uint index, uint divisor);
785bd8deadSopenharmony_ci    void DrawArraysInstancedEXT(enum mode, int first, sizei count,
795bd8deadSopenharmony_ci            sizei instanceCount);
805bd8deadSopenharmony_ci    void DrawElementsInstancedEXT(enum mode, sizei count, enum type,
815bd8deadSopenharmony_ci            const void *indices, sizei instanceCount);
825bd8deadSopenharmony_ci
835bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 2.0 Specification
845bd8deadSopenharmony_ci
855bd8deadSopenharmony_ci    Modify section 2.8 (Vertex Arrays), p. 21
865bd8deadSopenharmony_ci
875bd8deadSopenharmony_ci    (insert before section Transferring Array Elements, p. 21)
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ci    "The command
905bd8deadSopenharmony_ci        
915bd8deadSopenharmony_ci        void VertexAttribDivisorEXT(uint index, uint divisor);
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci    modifies the rate at which generic vertex attributes advance, which is 
945bd8deadSopenharmony_ci    useful when rendering multiple instances of primitives in a single draw call
955bd8deadSopenharmony_ci    (see DrawArraysInstancedEXT and DrawElementsInstancedEXT below). If 
965bd8deadSopenharmony_ci    <divisor> is zero, the attribute at slot <index> advances once per vertex. 
975bd8deadSopenharmony_ci    If <divisor> is non-zero, the attribute advances once per <divisor> 
985bd8deadSopenharmony_ci    instances of the primitives being rendered. An attribute is referred to as 
995bd8deadSopenharmony_ci    instanced if its <divisor> value is non-zero.
1005bd8deadSopenharmony_ci    
1015bd8deadSopenharmony_ci    An INVALID_VALUE error is generated if <index> is greater than or equal to 
1025bd8deadSopenharmony_ci    the value of MAX_VERTEX_ATTRIBS."
1035bd8deadSopenharmony_ci
1045bd8deadSopenharmony_ci    (replace all occurrences of "DrawArrays or DrawElements" with "DrawArrays, 
1055bd8deadSopenharmony_ci    DrawElements, or the other Draw* commands", for example the first sentence 
1065bd8deadSopenharmony_ci    of Transferring Array Elements, p. 21)
1075bd8deadSopenharmony_ci    
1085bd8deadSopenharmony_ci    "When an array element i is transferred to the GL by DrawArrays, 
1095bd8deadSopenharmony_ci    DrawElements, or the other Draw* commands described below, each generic 
1105bd8deadSopenharmony_ci    attribute is expanded to four components."
1115bd8deadSopenharmony_ci    
1125bd8deadSopenharmony_ci    (replace second through fourth paragraphs of Transferring Array Elements)
1135bd8deadSopenharmony_ci    
1145bd8deadSopenharmony_ci    "The command
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci        void DrawArraysOneInstance(enum mode, int first, sizei count, 
1175bd8deadSopenharmony_ci                int instance);
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci    does not exist in the GL, but is used to describe functionality in the rest 
1205bd8deadSopenharmony_ci    of this section. This command constructs a sequence of geometric primitives
1215bd8deadSopenharmony_ci    by successively transferring elements for <count> vertices. Elements <first> 
1225bd8deadSopenharmony_ci    through <first> + <count> − 1 of each enabled non-instanced array are 
1235bd8deadSopenharmony_ci    transferred to the GL. <mode> specifies what kind of primitives are 
1245bd8deadSopenharmony_ci    constructed, as defined in section 2.6.1.
1255bd8deadSopenharmony_ci    
1265bd8deadSopenharmony_ci    If an enabled vertex attribute array is instanced (it has a non-zero 
1275bd8deadSopenharmony_ci    <divisor> as specified by VertexAttribDivisorEXT), the element that is 
1285bd8deadSopenharmony_ci    transferred to the GL, for all vertices, is given by:
1295bd8deadSopenharmony_ci    
1305bd8deadSopenharmony_ci         floor(instance / divisor)
1315bd8deadSopenharmony_ci
1325bd8deadSopenharmony_ci    If an array corresponding to a generic attribute is not enabled, then the 
1335bd8deadSopenharmony_ci    corresponding element is taken from the current generic attribute state (see
1345bd8deadSopenharmony_ci    section 2.7). Otherwise, if an array is enabled, the corresponding current 
1355bd8deadSopenharmony_ci    generic attribute value is unaffected by the execution of 
1365bd8deadSopenharmony_ci    DrawArraysOneInstance.
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    Specifying <first> < 0 results in undefined behavior. Generating the error 
1395bd8deadSopenharmony_ci    INVALID_VALUE is recommended in this case.
1405bd8deadSopenharmony_ci    
1415bd8deadSopenharmony_ci    The command
1425bd8deadSopenharmony_ci
1435bd8deadSopenharmony_ci        void DrawArrays(enum mode, int first, sizei count);
1445bd8deadSopenharmony_ci
1455bd8deadSopenharmony_ci    is equivalent to the command sequence
1465bd8deadSopenharmony_ci
1475bd8deadSopenharmony_ci        DrawArraysOneInstance(mode, first, count, 0); 
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    The command
1505bd8deadSopenharmony_ci        
1515bd8deadSopenharmony_ci        void DrawArraysInstancedEXT(enum mode, int first, sizei count, 
1525bd8deadSopenharmony_ci                sizei instanceCount);
1535bd8deadSopenharmony_ci
1545bd8deadSopenharmony_ci    behaves identically to DrawArrays except that <instanceCount> instances of 
1555bd8deadSopenharmony_ci    the range of elements are executed and the value of <instance> advances 
1565bd8deadSopenharmony_ci    for each iteration. Those attributes that have non-zero values for 
1575bd8deadSopenharmony_ci    <divisor>, as specified by VertexAttribDivisorEXT, advance once every 
1585bd8deadSopenharmony_ci    <divisor> instances. It has the same effect as:
1595bd8deadSopenharmony_ci    
1605bd8deadSopenharmony_ci        if (mode, count, or instanceCount is invalid) 
1615bd8deadSopenharmony_ci            generate appropriate error
1625bd8deadSopenharmony_ci        else {
1635bd8deadSopenharmony_ci            for (i = 0; i < instanceCount; i++) {
1645bd8deadSopenharmony_ci                DrawArraysOneInstance(mode, first, count, i); 
1655bd8deadSopenharmony_ci            }
1665bd8deadSopenharmony_ci        }
1675bd8deadSopenharmony_ci            
1685bd8deadSopenharmony_ci    The command
1695bd8deadSopenharmony_ci        
1705bd8deadSopenharmony_ci        void DrawElementsOneInstance(enum mode, sizei count, enum type, 
1715bd8deadSopenharmony_ci                const void *indices, int instance);
1725bd8deadSopenharmony_ci            
1735bd8deadSopenharmony_ci    does not exist in the GL, but is used to describe functionality in the rest 
1745bd8deadSopenharmony_ci    of this section. This command constructs a sequence of geometric primitives 
1755bd8deadSopenharmony_ci    by successively transferring elements for <count> vertices. The ith element 
1765bd8deadSopenharmony_ci    transferred by DrawElementsOneInstance will be taken from element 
1775bd8deadSopenharmony_ci    <indices>[i] of each enabled non-instanced array, where <indices> specifies 
1785bd8deadSopenharmony_ci    the location in memory of the first index of the element array being 
1795bd8deadSopenharmony_ci    specified. <type> must be one of UNSIGNED_BYTE, UNSIGNED_SHORT, or 
1805bd8deadSopenharmony_ci    UNSIGNED_INT indicating that the index values are of GL type ubyte, ushort,
1815bd8deadSopenharmony_ci    or uint respectively. <mode> specifies what kind of primitives are 
1825bd8deadSopenharmony_ci    constructed, as defined in section 2.6.1.
1835bd8deadSopenharmony_ci    
1845bd8deadSopenharmony_ci    If an enabled vertex attribute array is instanced (it has a non-zero 
1855bd8deadSopenharmony_ci    <divisor> as specified by VertexAttribDivisorEXT), the element that is 
1865bd8deadSopenharmony_ci    transferred to the GL, for all vertices, is given by:
1875bd8deadSopenharmony_ci    
1885bd8deadSopenharmony_ci    floor(instance / divisor)
1895bd8deadSopenharmony_ci
1905bd8deadSopenharmony_ci    If an array corresponding to a generic attribute is not enabled, then the 
1915bd8deadSopenharmony_ci    corresponding element is taken from the current generic attribute state (see
1925bd8deadSopenharmony_ci    section 2.7). Otherwise, if an array is enabled, the corresponding current 
1935bd8deadSopenharmony_ci    generic attribute value is unaffected by the execution of 
1945bd8deadSopenharmony_ci    DrawElementsOneInstance.
1955bd8deadSopenharmony_ci
1965bd8deadSopenharmony_ci    The command
1975bd8deadSopenharmony_ci    
1985bd8deadSopenharmony_ci        void DrawElements(enum mode, sizei count, enum type, 
1995bd8deadSopenharmony_ci                const void *indices);
2005bd8deadSopenharmony_ci    
2015bd8deadSopenharmony_ci    behaves identically to DrawElementsOneInstance with the <instance> 
2025bd8deadSopenharmony_ci    parameter set to zero; the effect of calling
2035bd8deadSopenharmony_ci    
2045bd8deadSopenharmony_ci        DrawElements(mode, count, type, indices); 
2055bd8deadSopenharmony_ci    
2065bd8deadSopenharmony_ci    is equivalent to the command sequence:
2075bd8deadSopenharmony_ci        
2085bd8deadSopenharmony_ci        if (mode, count or type is invalid) 
2095bd8deadSopenharmony_ci            generate appropriate error
2105bd8deadSopenharmony_ci        else
2115bd8deadSopenharmony_ci            DrawElementsOneInstance(mode, count, type, indices, 0);
2125bd8deadSopenharmony_ci            
2135bd8deadSopenharmony_ci    The command
2145bd8deadSopenharmony_ci            
2155bd8deadSopenharmony_ci        void DrawElementsInstancedEXT(enum mode, sizei count, enum type, 
2165bd8deadSopenharmony_ci                const void *indices, sizei instanceCount);
2175bd8deadSopenharmony_ci            
2185bd8deadSopenharmony_ci    behaves identically to DrawElements except that <instanceCount> instances of
2195bd8deadSopenharmony_ci    the set of elements are executed and the value of <instance> advances 
2205bd8deadSopenharmony_ci    between each set. Instanced attributes are advanced as they do during 
2215bd8deadSopenharmony_ci    execution of DrawArraysInstancedEXT. It has the same effect as:
2225bd8deadSopenharmony_ci            
2235bd8deadSopenharmony_ci        if (mode, count, instanceCount, or type is invalid) 
2245bd8deadSopenharmony_ci            generate appropriate error
2255bd8deadSopenharmony_ci        else {
2265bd8deadSopenharmony_ci            for (int i = 0; i < instanceCount; i++) {
2275bd8deadSopenharmony_ci                DrawElementsOneInstance(mode, count, type, indices, i); 
2285bd8deadSopenharmony_ci            }
2295bd8deadSopenharmony_ci        }
2305bd8deadSopenharmony_ci        
2315bd8deadSopenharmony_ci    (append to first sentence of last paragraph of Transferring Array Elements)
2325bd8deadSopenharmony_ci    
2335bd8deadSopenharmony_ci    "..., and n integers representing vertex attribute divisors."
2345bd8deadSopenharmony_ci
2355bd8deadSopenharmony_ci    (append to last sentence of last paragraph of Transferring Array Elements)
2365bd8deadSopenharmony_ci    
2375bd8deadSopenharmony_ci    "..., the divisors are each zero."
2385bd8deadSopenharmony_ci
2395bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State
2405bd8deadSopenharmony_ciRequests)
2415bd8deadSopenharmony_ci
2425bd8deadSopenharmony_ci    In section 6.1.8, add to the list of pnames accepted by GetVertexAttrib*v: 
2435bd8deadSopenharmony_ci    VERTEX_ATTRIB_ARRAY_DIVISOR_EXT
2445bd8deadSopenharmony_ci
2455bd8deadSopenharmony_ciDependencies on OES_element_index_uint
2465bd8deadSopenharmony_ci    
2475bd8deadSopenharmony_ci    If OES_element_index_uint is not supported, remove references to
2485bd8deadSopenharmony_ci    UNSIGNED_INT as a valid <type> for DrawElements*.
2495bd8deadSopenharmony_ci    
2505bd8deadSopenharmony_ciErrors
2515bd8deadSopenharmony_ci
2525bd8deadSopenharmony_ci    INVALID_VALUE is generated by VertexAttribDivisorEXT if <index>
2535bd8deadSopenharmony_ci    is greater than or equal to MAX_VERTEX_ATTRIBS.
2545bd8deadSopenharmony_ci
2555bd8deadSopenharmony_ci    INVALID_ENUM is generated by DrawElementsInstancedEXT if <type> is
2565bd8deadSopenharmony_ci    not one of UNSIGNED_BYTE, UNSIGNED_SHORT or UNSIGNED_INT.
2575bd8deadSopenharmony_ci
2585bd8deadSopenharmony_ci    INVALID_VALUE is generated by DrawArraysInstancedEXT if <first>,
2595bd8deadSopenharmony_ci    <count>, or <instanceCount> is less than zero.
2605bd8deadSopenharmony_ci
2615bd8deadSopenharmony_ci    INVALID_VALUE is generated by DrawElementsInstancedEXT if <count> or
2625bd8deadSopenharmony_ci    <instanceCount> is less than zero.
2635bd8deadSopenharmony_ci
2645bd8deadSopenharmony_ci    INVALID_ENUM is generated by DrawArraysInstancedEXT or
2655bd8deadSopenharmony_ci    DrawElementsInstancedEXT if <mode> is not one of the kinds of primitives
2665bd8deadSopenharmony_ci    accepted by DrawArrays and DrawElements.
2675bd8deadSopenharmony_ci
2685bd8deadSopenharmony_ci
2695bd8deadSopenharmony_ciNew State
2705bd8deadSopenharmony_ci
2715bd8deadSopenharmony_ci    Changes to table 6.2, p. 136 (Vertex Array Data)
2725bd8deadSopenharmony_ci                                                                    Initial
2735bd8deadSopenharmony_ci    Get Value                          Type      Get Command        Value    Description          Sec.
2745bd8deadSopenharmony_ci    ---------                          ----      -----------        -------  -----------          ----
2755bd8deadSopenharmony_ci    VERTEX_ATTRIB_ARRAY_DIVISOR_EXT    16* x Z+  GetVertexAttribiv  0        Vertex attrib array  2.8
2765bd8deadSopenharmony_ci                                                                             instance divisor
2775bd8deadSopenharmony_ciIssues
2785bd8deadSopenharmony_ci
2795bd8deadSopenharmony_ci    None
2805bd8deadSopenharmony_ci    
2815bd8deadSopenharmony_ciRevision History
2825bd8deadSopenharmony_ci
2835bd8deadSopenharmony_ci    #1 November 11 2012, Abhijit Bhelande and Benj Lipchak
2845bd8deadSopenharmony_ci        - initial conversion from ARB to APPLE for ES2
2855bd8deadSopenharmony_ci    #2 June 26 2013, Benj Lipchak
2865bd8deadSopenharmony_ci        - promotion from APPLE to EXT
287