xref: /aosp_15_r20/external/angle/extensions/ANGLE_instanced_arrays.txt (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard WorkerName
2*8975f5c5SAndroid Build Coastguard Worker
3*8975f5c5SAndroid Build Coastguard Worker    ANGLE_instanced_arrays
4*8975f5c5SAndroid Build Coastguard Worker
5*8975f5c5SAndroid Build Coastguard WorkerName Strings
6*8975f5c5SAndroid Build Coastguard Worker
7*8975f5c5SAndroid Build Coastguard Worker    GL_ANGLE_instanced_arrays
8*8975f5c5SAndroid Build Coastguard Worker
9*8975f5c5SAndroid Build Coastguard WorkerContributors
10*8975f5c5SAndroid Build Coastguard Worker
11*8975f5c5SAndroid Build Coastguard Worker    Contributors to ARB_instanced_arrays
12*8975f5c5SAndroid Build Coastguard Worker    Nicolas Capens, TransGaming Inc.
13*8975f5c5SAndroid Build Coastguard Worker    James Helferty, TransGaming Inc.
14*8975f5c5SAndroid Build Coastguard Worker    Kenneth Russell, Google Inc.
15*8975f5c5SAndroid Build Coastguard Worker    Vangelis Kokkevis, Google Inc.
16*8975f5c5SAndroid Build Coastguard Worker
17*8975f5c5SAndroid Build Coastguard WorkerContact
18*8975f5c5SAndroid Build Coastguard Worker
19*8975f5c5SAndroid Build Coastguard Worker    Daniel Koch, TransGaming Inc. (daniel 'at' transgaming.com)
20*8975f5c5SAndroid Build Coastguard Worker
21*8975f5c5SAndroid Build Coastguard WorkerStatus
22*8975f5c5SAndroid Build Coastguard Worker
23*8975f5c5SAndroid Build Coastguard Worker    Implemented in ANGLE r976.
24*8975f5c5SAndroid Build Coastguard Worker
25*8975f5c5SAndroid Build Coastguard WorkerVersion
26*8975f5c5SAndroid Build Coastguard Worker
27*8975f5c5SAndroid Build Coastguard Worker    Last Modified Date: February 8, 2012
28*8975f5c5SAndroid Build Coastguard Worker    Author Revision: 3
29*8975f5c5SAndroid Build Coastguard Worker
30*8975f5c5SAndroid Build Coastguard WorkerNumber
31*8975f5c5SAndroid Build Coastguard Worker
32*8975f5c5SAndroid Build Coastguard Worker    OpenGL ES Extension #109
33*8975f5c5SAndroid Build Coastguard Worker
34*8975f5c5SAndroid Build Coastguard WorkerDependencies
35*8975f5c5SAndroid Build Coastguard Worker
36*8975f5c5SAndroid Build Coastguard Worker    OpenGL ES 2.0 is required.
37*8975f5c5SAndroid Build Coastguard Worker
38*8975f5c5SAndroid Build Coastguard Worker    This extension is written against the OpenGL ES 2.0 Specification.
39*8975f5c5SAndroid Build Coastguard Worker
40*8975f5c5SAndroid Build Coastguard WorkerOverview
41*8975f5c5SAndroid Build Coastguard Worker
42*8975f5c5SAndroid Build Coastguard Worker    A common use case in GL for some applications is to be able to
43*8975f5c5SAndroid Build Coastguard Worker    draw the same object, or groups of similar objects that share
44*8975f5c5SAndroid Build Coastguard Worker    vertex data, primitive count and type, multiple times.  This
45*8975f5c5SAndroid Build Coastguard Worker    extension provides a means of accelerating such use cases while
46*8975f5c5SAndroid Build Coastguard Worker    restricting the number of API calls, and keeping the amount of
47*8975f5c5SAndroid Build Coastguard Worker    duplicate data to a minimum.
48*8975f5c5SAndroid Build Coastguard Worker
49*8975f5c5SAndroid Build Coastguard Worker    This extension introduces an array "divisor" for generic
50*8975f5c5SAndroid Build Coastguard Worker    vertex array attributes, which when non-zero specifies that the
51*8975f5c5SAndroid Build Coastguard Worker    attribute is "instanced."  An instanced attribute does not
52*8975f5c5SAndroid Build Coastguard Worker    advance per-vertex as usual, but rather after every <divisor>
53*8975f5c5SAndroid Build Coastguard Worker    conceptual draw calls.
54*8975f5c5SAndroid Build Coastguard Worker
55*8975f5c5SAndroid Build Coastguard Worker    (Attributes which aren't instanced are repeated in their entirety
56*8975f5c5SAndroid Build Coastguard Worker    for every conceptual draw call.)
57*8975f5c5SAndroid Build Coastguard Worker
58*8975f5c5SAndroid Build Coastguard Worker    By specifying transform data in an instanced attribute or series
59*8975f5c5SAndroid Build Coastguard Worker    of instanced attributes, vertex shaders can, in concert with the
60*8975f5c5SAndroid Build Coastguard Worker    instancing draw calls, draw multiple instances of an object with
61*8975f5c5SAndroid Build Coastguard Worker    one draw call.
62*8975f5c5SAndroid Build Coastguard Worker
63*8975f5c5SAndroid Build Coastguard WorkerIP Status
64*8975f5c5SAndroid Build Coastguard Worker
65*8975f5c5SAndroid Build Coastguard Worker    No known IP claims.
66*8975f5c5SAndroid Build Coastguard Worker
67*8975f5c5SAndroid Build Coastguard WorkerNew Tokens
68*8975f5c5SAndroid Build Coastguard Worker
69*8975f5c5SAndroid Build Coastguard Worker    Accepted by the <pname> parameters of GetVertexAttribfv and
70*8975f5c5SAndroid Build Coastguard Worker    GetVertexAttribiv:
71*8975f5c5SAndroid Build Coastguard Worker
72*8975f5c5SAndroid Build Coastguard Worker        VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE               0x88FE
73*8975f5c5SAndroid Build Coastguard Worker
74*8975f5c5SAndroid Build Coastguard WorkerNew Procedures and Functions
75*8975f5c5SAndroid Build Coastguard Worker
76*8975f5c5SAndroid Build Coastguard Worker    void DrawArraysInstancedANGLE(enum mode, int first, sizei count,
77*8975f5c5SAndroid Build Coastguard Worker            sizei primcount);
78*8975f5c5SAndroid Build Coastguard Worker
79*8975f5c5SAndroid Build Coastguard Worker    void DrawElementsInstancedANGLE(enum mode, sizei count, enum type,
80*8975f5c5SAndroid Build Coastguard Worker            const void *indices, sizei primcount);
81*8975f5c5SAndroid Build Coastguard Worker
82*8975f5c5SAndroid Build Coastguard Worker    void VertexAttribDivisorANGLE(uint index, uint divisor);
83*8975f5c5SAndroid Build Coastguard Worker
84*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 2 of the OpenGL ES 2.0 Specification
85*8975f5c5SAndroid Build Coastguard Worker(OpenGL ES Operation)
86*8975f5c5SAndroid Build Coastguard Worker
87*8975f5c5SAndroid Build Coastguard Worker    Modify section 2.8 (Vertex Arrays), p. 21
88*8975f5c5SAndroid Build Coastguard Worker
89*8975f5c5SAndroid Build Coastguard Worker    After description of EnableVertexAttribArray / DisableVertexAttribArray
90*8975f5c5SAndroid Build Coastguard Worker    add the following:
91*8975f5c5SAndroid Build Coastguard Worker
92*8975f5c5SAndroid Build Coastguard Worker    "The command
93*8975f5c5SAndroid Build Coastguard Worker
94*8975f5c5SAndroid Build Coastguard Worker        void VertexAttribDivisorANGLE(uint index, uint divisor);
95*8975f5c5SAndroid Build Coastguard Worker
96*8975f5c5SAndroid Build Coastguard Worker    modifies the rate at which generic vertex attributes advance when
97*8975f5c5SAndroid Build Coastguard Worker    rendering multiple instances of primitives in a single draw call
98*8975f5c5SAndroid Build Coastguard Worker    (see DrawArraysInstancedANGLE and DrawElementsInstancedANGLE below).
99*8975f5c5SAndroid Build Coastguard Worker    If <divisor> is zero, the attribute at slot <index> advances once
100*8975f5c5SAndroid Build Coastguard Worker    per vertex.  If <divisor> is non-zero, the attribute advances once
101*8975f5c5SAndroid Build Coastguard Worker    per <divisor> instances of the primitives being rendered.
102*8975f5c5SAndroid Build Coastguard Worker    An attribute is referred to as "instanced" if its <divisor> value is
103*8975f5c5SAndroid Build Coastguard Worker    non-zero."
104*8975f5c5SAndroid Build Coastguard Worker
105*8975f5c5SAndroid Build Coastguard Worker    Replace the text describing DrawArrays and DrawElements in the
106*8975f5c5SAndroid Build Coastguard Worker    "Transferring Array Elements" subsection of 2.8, from the second paragraph
107*8975f5c5SAndroid Build Coastguard Worker    through the end of the section with the following:
108*8975f5c5SAndroid Build Coastguard Worker
109*8975f5c5SAndroid Build Coastguard Worker    "The command
110*8975f5c5SAndroid Build Coastguard Worker
111*8975f5c5SAndroid Build Coastguard Worker        void DrawArraysOneInstance( enum mode, int first, sizei count, int instance );
112*8975f5c5SAndroid Build Coastguard Worker
113*8975f5c5SAndroid Build Coastguard Worker    does not exist in the GL, but is used to describe functionality in
114*8975f5c5SAndroid Build Coastguard Worker    the rest of this section.  This function constructs a sequence of
115*8975f5c5SAndroid Build Coastguard Worker    geometric primitives by transferring elements <first> through <first> +
116*8975f5c5SAndroid Build Coastguard Worker    <count> - 1 of each enabled non-instanced array to the GL. <mode>
117*8975f5c5SAndroid Build Coastguard Worker    specifies what kind of primitives are constructed, as defined in section
118*8975f5c5SAndroid Build Coastguard Worker    2.6.1.
119*8975f5c5SAndroid Build Coastguard Worker
120*8975f5c5SAndroid Build Coastguard Worker    If an enabled vertex attribute array is instanced (it has a non-zero
121*8975f5c5SAndroid Build Coastguard Worker    attribute <divisor> as specified by VertexAttribDivisorANGLE), the element
122*8975f5c5SAndroid Build Coastguard Worker    that is transferred to the GL is given by:
123*8975f5c5SAndroid Build Coastguard Worker
124*8975f5c5SAndroid Build Coastguard Worker        floor( <instance> / <divisor> ).
125*8975f5c5SAndroid Build Coastguard Worker
126*8975f5c5SAndroid Build Coastguard Worker    If an array corresponding to a generic attribute required by a vertex shader
127*8975f5c5SAndroid Build Coastguard Worker    is not enabled, then the corresponding element is taken from the current
128*8975f5c5SAndroid Build Coastguard Worker    generic attribute state (see section 2.7).
129*8975f5c5SAndroid Build Coastguard Worker
130*8975f5c5SAndroid Build Coastguard Worker    If an array corresponding to a generic attribute required by a vertex shader
131*8975f5c5SAndroid Build Coastguard Worker    is enabled, the corresponding current generic attribute value is unaffected
132*8975f5c5SAndroid Build Coastguard Worker    by the execution of DrawArraysOneInstance.
133*8975f5c5SAndroid Build Coastguard Worker
134*8975f5c5SAndroid Build Coastguard Worker    Specifying <first> < 0 results in undefined behavior. Generating the error
135*8975f5c5SAndroid Build Coastguard Worker    INVALID_VALUE is recommended in this case.
136*8975f5c5SAndroid Build Coastguard Worker
137*8975f5c5SAndroid Build Coastguard Worker    The command
138*8975f5c5SAndroid Build Coastguard Worker
139*8975f5c5SAndroid Build Coastguard Worker        void DrawArrays( enum mode, int first, sizei count );
140*8975f5c5SAndroid Build Coastguard Worker
141*8975f5c5SAndroid Build Coastguard Worker    is equivalent to the command sequence
142*8975f5c5SAndroid Build Coastguard Worker
143*8975f5c5SAndroid Build Coastguard Worker        DrawArraysOneInstance(mode, first, count, 0);
144*8975f5c5SAndroid Build Coastguard Worker
145*8975f5c5SAndroid Build Coastguard Worker    The command
146*8975f5c5SAndroid Build Coastguard Worker
147*8975f5c5SAndroid Build Coastguard Worker        void DrawArraysInstancedANGLE(enum mode, int first, sizei count,
148*8975f5c5SAndroid Build Coastguard Worker                sizei primcount);
149*8975f5c5SAndroid Build Coastguard Worker
150*8975f5c5SAndroid Build Coastguard Worker    behaves identically to DrawArrays except that <primcount>
151*8975f5c5SAndroid Build Coastguard Worker    instances of the range of elements are executed, and the
152*8975f5c5SAndroid Build Coastguard Worker    <instance> advances for each iteration. Instanced attributes that
153*8975f5c5SAndroid Build Coastguard Worker    have <divisor> N, (where N > 0, as specified by
154*8975f5c5SAndroid Build Coastguard Worker    VertexAttribDivisorANGLE) advance once every N instances.
155*8975f5c5SAndroid Build Coastguard Worker
156*8975f5c5SAndroid Build Coastguard Worker    It has the same effect as:
157*8975f5c5SAndroid Build Coastguard Worker
158*8975f5c5SAndroid Build Coastguard Worker        if (mode, count, or primcount is invalid)
159*8975f5c5SAndroid Build Coastguard Worker            generate appropriate error
160*8975f5c5SAndroid Build Coastguard Worker        else {
161*8975f5c5SAndroid Build Coastguard Worker            for (i = 0; i < primcount; i++) {
162*8975f5c5SAndroid Build Coastguard Worker                DrawArraysOneInstance(mode, first, count, i);
163*8975f5c5SAndroid Build Coastguard Worker            }
164*8975f5c5SAndroid Build Coastguard Worker        }
165*8975f5c5SAndroid Build Coastguard Worker
166*8975f5c5SAndroid Build Coastguard Worker    The command
167*8975f5c5SAndroid Build Coastguard Worker
168*8975f5c5SAndroid Build Coastguard Worker       void DrawElementsOneInstance( enum mode, sizei count, enum type,
169*8975f5c5SAndroid Build Coastguard Worker            void *indices, int instance );
170*8975f5c5SAndroid Build Coastguard Worker
171*8975f5c5SAndroid Build Coastguard Worker    does not exist in the GL, but is used to describe functionality in
172*8975f5c5SAndroid Build Coastguard Worker    the rest of this section.  This command constructs a sequence of
173*8975f5c5SAndroid Build Coastguard Worker    geometric primitives by successively transferring the <count> elements
174*8975f5c5SAndroid Build Coastguard Worker    whose indices are stored in the currently bound element array buffer
175*8975f5c5SAndroid Build Coastguard Worker    (see section 2.9.2) at the offset defined by <indices> to the GL.
176*8975f5c5SAndroid Build Coastguard Worker    The <i>-th element transferred by DrawElementsOneInstance will be taken
177*8975f5c5SAndroid Build Coastguard Worker    from element <indices>[i] of each enabled non-instanced array.
178*8975f5c5SAndroid Build Coastguard Worker    <type> must be one of UNSIGNED_BYTE, UNSIGNED_SHORT, or UNSIGNED_INT,
179*8975f5c5SAndroid Build Coastguard Worker    indicating that the index values are of GL type ubyte, ushort, or uint
180*8975f5c5SAndroid Build Coastguard Worker    respectively. <mode> specifies what kind of primitives are constructed,
181*8975f5c5SAndroid Build Coastguard Worker    as defined in section 2.6.1.
182*8975f5c5SAndroid Build Coastguard Worker
183*8975f5c5SAndroid Build Coastguard Worker    If an enabled vertex attribute array is instanced (it has a non-zero
184*8975f5c5SAndroid Build Coastguard Worker    attribute <divisor> as specified by VertexAttribDivisorANGLE), the element
185*8975f5c5SAndroid Build Coastguard Worker    that is transferred to the GL is given by:
186*8975f5c5SAndroid Build Coastguard Worker
187*8975f5c5SAndroid Build Coastguard Worker        floor( <instance> / <divisor> );
188*8975f5c5SAndroid Build Coastguard Worker
189*8975f5c5SAndroid Build Coastguard Worker    If an array corresponding to a generic attribute required by a vertex
190*8975f5c5SAndroid Build Coastguard Worker    shader is not enabled, then the corresponding element is taken from the
191*8975f5c5SAndroid Build Coastguard Worker    current generic attribute state (see section 2.7). Otherwise, if an array
192*8975f5c5SAndroid Build Coastguard Worker    is enabled, the corresponding current generic attribute value is
193*8975f5c5SAndroid Build Coastguard Worker    unaffected by the execution of DrawElementsOneInstance.
194*8975f5c5SAndroid Build Coastguard Worker
195*8975f5c5SAndroid Build Coastguard Worker    The command
196*8975f5c5SAndroid Build Coastguard Worker
197*8975f5c5SAndroid Build Coastguard Worker        void DrawElements( enum mode, sizei count, enum type,
198*8975f5c5SAndroid Build Coastguard Worker             const void *indices);
199*8975f5c5SAndroid Build Coastguard Worker
200*8975f5c5SAndroid Build Coastguard Worker    behaves identically to DrawElementsOneInstance with the <instance>
201*8975f5c5SAndroid Build Coastguard Worker    parameter set to zero; the effect of calling
202*8975f5c5SAndroid Build Coastguard Worker
203*8975f5c5SAndroid Build Coastguard Worker        DrawElements(mode, count, type, indices);
204*8975f5c5SAndroid Build Coastguard Worker
205*8975f5c5SAndroid Build Coastguard Worker    is equivalent to the command sequence:
206*8975f5c5SAndroid Build Coastguard Worker
207*8975f5c5SAndroid Build Coastguard Worker       if (mode, count or type is invalid )
208*8975f5c5SAndroid Build Coastguard Worker            generate appropriate error
209*8975f5c5SAndroid Build Coastguard Worker        else
210*8975f5c5SAndroid Build Coastguard Worker            DrawElementsOneInstance(mode, count, type, indices, 0);
211*8975f5c5SAndroid Build Coastguard Worker
212*8975f5c5SAndroid Build Coastguard Worker    The command
213*8975f5c5SAndroid Build Coastguard Worker
214*8975f5c5SAndroid Build Coastguard Worker        void DrawElementsInstancedANGLE(enum mode, sizei count, enum type,
215*8975f5c5SAndroid Build Coastguard Worker                const void *indices, sizei primcount);
216*8975f5c5SAndroid Build Coastguard Worker
217*8975f5c5SAndroid Build Coastguard Worker    behaves identically to DrawElements except that <primcount>
218*8975f5c5SAndroid Build Coastguard Worker    instances of the set of elements are executed and the instance
219*8975f5c5SAndroid Build Coastguard Worker    advances between each set. Instanced attributes are advanced as they do
220*8975f5c5SAndroid Build Coastguard Worker    during the execution of DrawArraysInstancedANGLE. It has the same effect as:
221*8975f5c5SAndroid Build Coastguard Worker
222*8975f5c5SAndroid Build Coastguard Worker        if (mode, count, primcount, or type is invalid )
223*8975f5c5SAndroid Build Coastguard Worker            generate appropriate error
224*8975f5c5SAndroid Build Coastguard Worker        else {
225*8975f5c5SAndroid Build Coastguard Worker            for (int i = 0; i < primcount; i++) {
226*8975f5c5SAndroid Build Coastguard Worker                DrawElementsOneInstance(mode, count, type, indices, i);
227*8975f5c5SAndroid Build Coastguard Worker            }
228*8975f5c5SAndroid Build Coastguard Worker        }
229*8975f5c5SAndroid Build Coastguard Worker
230*8975f5c5SAndroid Build Coastguard Worker    If the number of supported generic vertex attributes (the value of
231*8975f5c5SAndroid Build Coastguard Worker    MAX_VERTEX_ATTRIBS) is <n>, then the client state required to implement
232*8975f5c5SAndroid Build Coastguard Worker    vertex arrays consists of <n> boolean values, <n> memory pointers, <n>
233*8975f5c5SAndroid Build Coastguard Worker    integer stride values, <n> symbolic constants representing array types,
234*8975f5c5SAndroid Build Coastguard Worker    <n> integers representing values per element, <n> boolean values
235*8975f5c5SAndroid Build Coastguard Worker    indicating normalization, and <n> integers representing vertex attribute
236*8975f5c5SAndroid Build Coastguard Worker    divisors.
237*8975f5c5SAndroid Build Coastguard Worker
238*8975f5c5SAndroid Build Coastguard Worker    In the initial state, the boolean values are each false, the memory
239*8975f5c5SAndroid Build Coastguard Worker    pointers are each NULL, the strides are each zero, the array types are
240*8975f5c5SAndroid Build Coastguard Worker    each FLOAT, the integers representing values per element are each four,
241*8975f5c5SAndroid Build Coastguard Worker    and the divisors are each zero."
242*8975f5c5SAndroid Build Coastguard Worker
243*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization)
244*8975f5c5SAndroid Build Coastguard Worker
245*8975f5c5SAndroid Build Coastguard Worker    None
246*8975f5c5SAndroid Build Coastguard Worker
247*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment
248*8975f5c5SAndroid Build Coastguard WorkerOperations and the Framebuffer)
249*8975f5c5SAndroid Build Coastguard Worker
250*8975f5c5SAndroid Build Coastguard Worker    None
251*8975f5c5SAndroid Build Coastguard Worker
252*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 5 of the OpenGL ES 2.0 Specification (Special Functions)
253*8975f5c5SAndroid Build Coastguard Worker
254*8975f5c5SAndroid Build Coastguard Worker    None
255*8975f5c5SAndroid Build Coastguard Worker
256*8975f5c5SAndroid Build Coastguard WorkerAdditions to Chapter 6 of the OpenGL ES 2.0 Specification (State and State
257*8975f5c5SAndroid Build Coastguard WorkerRequests)
258*8975f5c5SAndroid Build Coastguard Worker
259*8975f5c5SAndroid Build Coastguard Worker    In section 6.1.8, add VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE to the list of
260*8975f5c5SAndroid Build Coastguard Worker    pnames accepted by GetVertexAttribfv and GetVertexAttribiv.
261*8975f5c5SAndroid Build Coastguard Worker
262*8975f5c5SAndroid Build Coastguard WorkerAdditions to the AGL/EGL/GLX/WGL Specifications
263*8975f5c5SAndroid Build Coastguard Worker
264*8975f5c5SAndroid Build Coastguard Worker    None
265*8975f5c5SAndroid Build Coastguard Worker
266*8975f5c5SAndroid Build Coastguard WorkerDependencies on OES_element_index_uint
267*8975f5c5SAndroid Build Coastguard Worker
268*8975f5c5SAndroid Build Coastguard Worker    If OES_element_index_uint is not supported, removed all references
269*8975f5c5SAndroid Build Coastguard Worker    to UNSIGNED_INT indices and the associated GL data type uint in
270*8975f5c5SAndroid Build Coastguard Worker    the description of DrawElementsOneInstance.
271*8975f5c5SAndroid Build Coastguard Worker
272*8975f5c5SAndroid Build Coastguard WorkerErrors
273*8975f5c5SAndroid Build Coastguard Worker
274*8975f5c5SAndroid Build Coastguard Worker    INVALID_VALUE is generated by VertexAttribDivisorANGLE if <index>
275*8975f5c5SAndroid Build Coastguard Worker    is greater than or equal to MAX_VERTEX_ATTRIBS.
276*8975f5c5SAndroid Build Coastguard Worker
277*8975f5c5SAndroid Build Coastguard Worker    INVALID_ENUM is generated by DrawElementsInstancedANGLE if <type> is
278*8975f5c5SAndroid Build Coastguard Worker    not one of UNSIGNED_BYTE, UNSIGNED_SHORT or UNSIGNED_INT.
279*8975f5c5SAndroid Build Coastguard Worker
280*8975f5c5SAndroid Build Coastguard Worker    INVALID_VALUE is generated by DrawArraysInstancedANGLE if <first>,
281*8975f5c5SAndroid Build Coastguard Worker    <count>, or <primcount> is less than zero.
282*8975f5c5SAndroid Build Coastguard Worker
283*8975f5c5SAndroid Build Coastguard Worker    INVALID_ENUM is generated by DrawArraysInstancedANGLE or
284*8975f5c5SAndroid Build Coastguard Worker    DrawElementsInstancedANGLE if <mode> is not one of the modes described in
285*8975f5c5SAndroid Build Coastguard Worker    section 2.6.1.
286*8975f5c5SAndroid Build Coastguard Worker
287*8975f5c5SAndroid Build Coastguard Worker    INVALID_VALUE is generated by DrawElementsInstancedANGLE if <count> or
288*8975f5c5SAndroid Build Coastguard Worker    <primcount> is less than zero.
289*8975f5c5SAndroid Build Coastguard Worker
290*8975f5c5SAndroid Build Coastguard Worker    INVALID_OPERATION is generated by DrawArraysInstancedANGLE or
291*8975f5c5SAndroid Build Coastguard Worker    DrawElementsInstancedANGLE if there is not at least one enabled
292*8975f5c5SAndroid Build Coastguard Worker    vertex attribute array that has a <divisor> of zero and is bound to an
293*8975f5c5SAndroid Build Coastguard Worker    active generic attribute value in the program used for the draw command.
294*8975f5c5SAndroid Build Coastguard Worker
295*8975f5c5SAndroid Build Coastguard WorkerNew State
296*8975f5c5SAndroid Build Coastguard Worker
297*8975f5c5SAndroid Build Coastguard Worker    Changes to table 6.7, p. 268 (Vertex Array Data)
298*8975f5c5SAndroid Build Coastguard Worker
299*8975f5c5SAndroid Build Coastguard Worker                                                               Initial
300*8975f5c5SAndroid Build Coastguard Worker    Get Value                          Type   Get Command      Value    Description       Sec.
301*8975f5c5SAndroid Build Coastguard Worker    ---------                          -----  -----------      -------  -----------       ----
302*8975f5c5SAndroid Build Coastguard Worker    VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE  8*xZ+  GetVertexAttrib  0        Instance Divisor  2.8
303*8975f5c5SAndroid Build Coastguard Worker
304*8975f5c5SAndroid Build Coastguard WorkerIssues
305*8975f5c5SAndroid Build Coastguard Worker
306*8975f5c5SAndroid Build Coastguard Worker    1) Should vertex attribute zero be instance-able?
307*8975f5c5SAndroid Build Coastguard Worker
308*8975f5c5SAndroid Build Coastguard Worker       Resolved: Yes.
309*8975f5c5SAndroid Build Coastguard Worker       Discussion: In Direct3D 9 stream 0 must be specified as indexed data
310*8975f5c5SAndroid Build Coastguard Worker       and it cannot be instanced. In ANGLE we can work around this by
311*8975f5c5SAndroid Build Coastguard Worker       remapping any other stream that does have indexed data (ie a zero
312*8975f5c5SAndroid Build Coastguard Worker       attribute divisor) to stream 0 in D3D9. This works because the HLSL
313*8975f5c5SAndroid Build Coastguard Worker       vertex shader matches attributes against the stream by using the
314*8975f5c5SAndroid Build Coastguard Worker       shader semantic index.
315*8975f5c5SAndroid Build Coastguard Worker
316*8975f5c5SAndroid Build Coastguard Worker    2) Can all vertex attributes be instanced simultaneously?
317*8975f5c5SAndroid Build Coastguard Worker
318*8975f5c5SAndroid Build Coastguard Worker       Resolved: No
319*8975f5c5SAndroid Build Coastguard Worker       Discussion: In rare cases it is possible for no attribute to have a
320*8975f5c5SAndroid Build Coastguard Worker       divisor of 0, meaning that all attributes are instanced and none of
321*8975f5c5SAndroid Build Coastguard Worker       them are regularly indexed. This in turn means each instance can only
322*8975f5c5SAndroid Build Coastguard Worker       have a single position element, and so it only actually renders
323*8975f5c5SAndroid Build Coastguard Worker       something when rendering point primitives. This is not a very
324*8975f5c5SAndroid Build Coastguard Worker       meaningful way of using instancing (which is likely why D3D restricts
325*8975f5c5SAndroid Build Coastguard Worker       stream 0 to be indexed regularly for position data in the first place).
326*8975f5c5SAndroid Build Coastguard Worker       We could implement it by drawing these points one at a time (essentially
327*8975f5c5SAndroid Build Coastguard Worker       emulating instancing), but it would not be very efficient and there
328*8975f5c5SAndroid Build Coastguard Worker       seems to be little-to-no value in doing so.
329*8975f5c5SAndroid Build Coastguard Worker
330*8975f5c5SAndroid Build Coastguard Worker       If all of the enabled vertex attribute arrays that are bound to active
331*8975f5c5SAndroid Build Coastguard Worker       generic attributes in the program have a non-zero divisor, the draw
332*8975f5c5SAndroid Build Coastguard Worker       call should return INVALID_OPERATION.
333*8975f5c5SAndroid Build Coastguard Worker
334*8975f5c5SAndroid Build Coastguard Worker    3) Direct3D 9 only supports instancing for DrawIndexedPrimitive which
335*8975f5c5SAndroid Build Coastguard Worker       corresponds to DrawElementsInstanced.  Should we support
336*8975f5c5SAndroid Build Coastguard Worker       DrawArraysInstanced?
337*8975f5c5SAndroid Build Coastguard Worker
338*8975f5c5SAndroid Build Coastguard Worker       Resolved: Yes
339*8975f5c5SAndroid Build Coastguard Worker       Discussion: This can be supported easily enough by simply manufacturing
340*8975f5c5SAndroid Build Coastguard Worker       a linear index buffer of sufficient size and using that to do indexed
341*8975f5c5SAndroid Build Coastguard Worker       D3D9 drawing.
342*8975f5c5SAndroid Build Coastguard Worker
343*8975f5c5SAndroid Build Coastguard Worker    4) How much data is needed in a buffer for an instanced attribute?
344*8975f5c5SAndroid Build Coastguard Worker
345*8975f5c5SAndroid Build Coastguard Worker       Resolved: Where stride is the value passed to VertexAttribPointer:
346*8975f5c5SAndroid Build Coastguard Worker
347*8975f5c5SAndroid Build Coastguard Worker       if stride > 0
348*8975f5c5SAndroid Build Coastguard Worker         size = stride * ceil(primcount / divisor);
349*8975f5c5SAndroid Build Coastguard Worker       else
350*8975f5c5SAndroid Build Coastguard Worker         size = elementsize * ceil(primcount / divisor);
351*8975f5c5SAndroid Build Coastguard Worker
352*8975f5c5SAndroid Build Coastguard WorkerRevision History
353*8975f5c5SAndroid Build Coastguard Worker
354*8975f5c5SAndroid Build Coastguard Worker    #3 February 8, 2012 dgkoch
355*8975f5c5SAndroid Build Coastguard Worker       - clarify Issue 3 and the error condition for no indexed attributes
356*8975f5c5SAndroid Build Coastguard Worker    #2 January 24, 2012 dgkoch
357*8975f5c5SAndroid Build Coastguard Worker       - fix typos, add clarifications, and more errors
358*8975f5c5SAndroid Build Coastguard Worker    #1 January 17, 2012 dgkoch
359*8975f5c5SAndroid Build Coastguard Worker       - initial GLES2 version from ARB_instanced_arrays
360