2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
28 #include <inttypes.h> /* for PRId64 macro */
32 #include "bufferobj.h"
42 #include "main/dispatch.h"
45 /** Used to do error checking for GL_EXT_vertex_array_bgra */
49 /** Used to indicate which GL datatypes are accepted by each of the
50 * glVertex/Color/Attrib/EtcPointer() functions.
52 #define BOOL_BIT (1 << 0)
53 #define BYTE_BIT (1 << 1)
54 #define UNSIGNED_BYTE_BIT (1 << 2)
55 #define SHORT_BIT (1 << 3)
56 #define UNSIGNED_SHORT_BIT (1 << 4)
57 #define INT_BIT (1 << 5)
58 #define UNSIGNED_INT_BIT (1 << 6)
59 #define HALF_BIT (1 << 7)
60 #define FLOAT_BIT (1 << 8)
61 #define DOUBLE_BIT (1 << 9)
62 #define FIXED_ES_BIT (1 << 10)
63 #define FIXED_GL_BIT (1 << 11)
64 #define UNSIGNED_INT_2_10_10_10_REV_BIT (1 << 12)
65 #define INT_2_10_10_10_REV_BIT (1 << 13)
66 #define UNSIGNED_INT_10F_11F_11F_REV_BIT (1 << 14)
67 #define ALL_TYPE_BITS ((1 << 15) - 1)
70 /** Convert GL datatype enum into a <type>_BIT value seen above */
72 type_to_bit(const struct gl_context
*ctx
, GLenum type
)
79 case GL_UNSIGNED_BYTE
:
80 return UNSIGNED_BYTE_BIT
;
83 case GL_UNSIGNED_SHORT
:
84 return UNSIGNED_SHORT_BIT
;
88 return UNSIGNED_INT_BIT
;
90 if (ctx
->Extensions
.ARB_half_float_vertex
)
99 return _mesa_is_desktop_gl(ctx
) ? FIXED_GL_BIT
: FIXED_ES_BIT
;
100 case GL_UNSIGNED_INT_2_10_10_10_REV
:
101 return UNSIGNED_INT_2_10_10_10_REV_BIT
;
102 case GL_INT_2_10_10_10_REV
:
103 return INT_2_10_10_10_REV_BIT
;
104 case GL_UNSIGNED_INT_10F_11F_11F_REV
:
105 return UNSIGNED_INT_10F_11F_11F_REV_BIT
;
113 * Sets the VertexBinding field in the vertex attribute given by attribIndex.
116 vertex_attrib_binding(struct gl_context
*ctx
, GLuint attribIndex
,
119 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
120 struct gl_vertex_attrib_array
*array
= &vao
->VertexAttrib
[attribIndex
];
122 if (array
->VertexBinding
!= bindingIndex
) {
123 const GLbitfield64 array_bit
= VERT_BIT(attribIndex
);
125 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
127 vao
->VertexBinding
[array
->VertexBinding
]._BoundArrays
&= ~array_bit
;
128 vao
->VertexBinding
[bindingIndex
]._BoundArrays
|= array_bit
;
130 array
->VertexBinding
= bindingIndex
;
132 vao
->NewArrays
|= array_bit
;
138 * Binds a buffer object to the vertex buffer binding point given by index,
139 * and sets the Offset and Stride fields.
142 bind_vertex_buffer(struct gl_context
*ctx
, GLuint index
,
143 struct gl_buffer_object
*vbo
,
144 GLintptr offset
, GLsizei stride
)
146 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
147 struct gl_vertex_buffer_binding
*binding
= &vao
->VertexBinding
[index
];
149 if (binding
->BufferObj
!= vbo
||
150 binding
->Offset
!= offset
||
151 binding
->Stride
!= stride
) {
153 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
155 _mesa_reference_buffer_object(ctx
, &binding
->BufferObj
, vbo
);
157 binding
->Offset
= offset
;
158 binding
->Stride
= stride
;
160 vao
->NewArrays
|= binding
->_BoundArrays
;
166 * Sets the InstanceDivisor field in the vertex buffer binding point
167 * given by bindingIndex.
170 vertex_binding_divisor(struct gl_context
*ctx
, GLuint bindingIndex
,
173 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
174 struct gl_vertex_buffer_binding
*binding
=
175 &vao
->VertexBinding
[bindingIndex
];
177 if (binding
->InstanceDivisor
!= divisor
) {
178 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
179 binding
->InstanceDivisor
= divisor
;
180 vao
->NewArrays
|= binding
->_BoundArrays
;
186 * Examine the API profile and extensions to determine which types are legal
187 * for vertex arrays. This is called once from update_array_format().
190 get_legal_types_mask(const struct gl_context
*ctx
)
192 GLbitfield legalTypesMask
= ALL_TYPE_BITS
;
194 if (_mesa_is_gles(ctx
)) {
195 legalTypesMask
&= ~(FIXED_GL_BIT
|
197 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
199 /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until
200 * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or
201 * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed
202 * until 3.0 or with the GL_OES_vertex_half float extension, which isn't
203 * quite as trivial as we'd like because it uses a different enum value
204 * for GL_HALF_FLOAT_OES.
206 if (ctx
->Version
< 30) {
207 legalTypesMask
&= ~(UNSIGNED_INT_BIT
|
209 UNSIGNED_INT_2_10_10_10_REV_BIT
|
210 INT_2_10_10_10_REV_BIT
|
215 legalTypesMask
&= ~FIXED_ES_BIT
;
217 if (!ctx
->Extensions
.ARB_ES2_compatibility
)
218 legalTypesMask
&= ~FIXED_GL_BIT
;
220 if (!ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
)
221 legalTypesMask
&= ~(UNSIGNED_INT_2_10_10_10_REV_BIT
|
222 INT_2_10_10_10_REV_BIT
);
224 if (!ctx
->Extensions
.ARB_vertex_type_10f_11f_11f_rev
)
225 legalTypesMask
&= ~UNSIGNED_INT_10F_11F_11F_REV_BIT
;
228 return legalTypesMask
;
233 * Does error checking and updates the format in an attrib array.
235 * Called by update_array() and VertexAttrib*Format().
237 * \param func Name of calling function used for error reporting
238 * \param attrib The index of the attribute array
239 * \param legalTypes Bitmask of *_BIT above indicating legal datatypes
240 * \param sizeMin Min allowable size value
241 * \param sizeMax Max allowable size value (may also be BGRA_OR_4)
242 * \param size Components per element (1, 2, 3 or 4)
243 * \param type Datatype of each component (GL_FLOAT, GL_INT, etc)
244 * \param normalized Whether integer types are converted to floats in [-1, 1]
245 * \param integer Integer-valued values (will not be normalized to [-1, 1])
246 * \param doubles Double values not reduced to floats
247 * \param relativeOffset Offset of the first element relative to the binding offset.
250 update_array_format(struct gl_context
*ctx
,
252 GLuint attrib
, GLbitfield legalTypesMask
,
253 GLint sizeMin
, GLint sizeMax
,
254 GLint size
, GLenum type
,
255 GLboolean normalized
, GLboolean integer
, GLboolean doubles
,
256 GLuint relativeOffset
)
258 struct gl_vertex_attrib_array
*array
;
261 GLenum format
= GL_RGBA
;
263 if (ctx
->Array
.LegalTypesMask
== 0 || ctx
->Array
.LegalTypesMaskAPI
!= ctx
->API
) {
264 /* Compute the LegalTypesMask only once, unless the context API has
265 * changed, in which case we want to compute it again. We can't do this
266 * in _mesa_init_varrays() below because extensions are not yet enabled
269 ctx
->Array
.LegalTypesMask
= get_legal_types_mask(ctx
);
270 ctx
->Array
.LegalTypesMaskAPI
= ctx
->API
;
273 legalTypesMask
&= ctx
->Array
.LegalTypesMask
;
275 if (_mesa_is_gles(ctx
) && sizeMax
== BGRA_OR_4
) {
276 /* BGRA ordering is not supported in ES contexts.
281 typeBit
= type_to_bit(ctx
, type
);
282 if (typeBit
== 0x0 || (typeBit
& legalTypesMask
) == 0x0) {
283 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)",
284 func
, _mesa_lookup_enum_by_nr(type
));
288 /* Do size parameter checking.
289 * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and
290 * must be handled specially.
292 if (ctx
->Extensions
.EXT_vertex_array_bgra
&&
293 sizeMax
== BGRA_OR_4
&&
295 /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
297 * "An INVALID_OPERATION error is generated under any of the following
300 * • size is BGRA and type is not UNSIGNED_BYTE, INT_2_10_10_10_REV
301 * or UNSIGNED_INT_2_10_10_10_REV;
303 * • size is BGRA and normalized is FALSE;"
305 bool bgra_error
= false;
307 if (ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
) {
308 if (type
!= GL_UNSIGNED_INT_2_10_10_10_REV
&&
309 type
!= GL_INT_2_10_10_10_REV
&&
310 type
!= GL_UNSIGNED_BYTE
)
312 } else if (type
!= GL_UNSIGNED_BYTE
)
316 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=GL_BGRA and type=%s)",
317 func
, _mesa_lookup_enum_by_nr(type
));
322 _mesa_error(ctx
, GL_INVALID_OPERATION
,
323 "%s(size=GL_BGRA and normalized=GL_FALSE)", func
);
330 else if (size
< sizeMin
|| size
> sizeMax
|| size
> 4) {
331 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(size=%d)", func
, size
);
335 if (ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
&&
336 (type
== GL_UNSIGNED_INT_2_10_10_10_REV
||
337 type
== GL_INT_2_10_10_10_REV
) && size
!= 4) {
338 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=%d)", func
, size
);
342 /* The ARB_vertex_attrib_binding_spec says:
344 * An INVALID_VALUE error is generated if <relativeoffset> is larger than
345 * the value of MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.
347 if (relativeOffset
> ctx
->Const
.MaxVertexAttribRelativeOffset
) {
348 _mesa_error(ctx
, GL_INVALID_VALUE
,
349 "%s(relativeOffset=%d > "
350 "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)",
351 func
, relativeOffset
);
355 if (ctx
->Extensions
.ARB_vertex_type_10f_11f_11f_rev
&&
356 type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&& size
!= 3) {
357 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=%d)", func
, size
);
363 elementSize
= _mesa_bytes_per_vertex_attrib(size
, type
);
364 assert(elementSize
!= -1);
366 array
= &ctx
->Array
.VAO
->VertexAttrib
[attrib
];
369 array
->Format
= format
;
370 array
->Normalized
= normalized
;
371 array
->Integer
= integer
;
372 array
->Doubles
= doubles
;
373 array
->RelativeOffset
= relativeOffset
;
374 array
->_ElementSize
= elementSize
;
376 ctx
->Array
.VAO
->NewArrays
|= VERT_BIT(attrib
);
377 ctx
->NewState
|= _NEW_ARRAY
;
384 * Do error checking and update state for glVertex/Color/TexCoord/...Pointer
387 * \param func name of calling function used for error reporting
388 * \param attrib the attribute array index to update
389 * \param legalTypes bitmask of *_BIT above indicating legal datatypes
390 * \param sizeMin min allowable size value
391 * \param sizeMax max allowable size value (may also be BGRA_OR_4)
392 * \param size components per element (1, 2, 3 or 4)
393 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
394 * \param stride stride between elements, in elements
395 * \param normalized are integer types converted to floats in [-1, 1]?
396 * \param integer integer-valued values (will not be normalized to [-1,1])
397 * \param doubles Double values not reduced to floats
398 * \param ptr the address (or offset inside VBO) of the array data
401 update_array(struct gl_context
*ctx
,
403 GLuint attrib
, GLbitfield legalTypesMask
,
404 GLint sizeMin
, GLint sizeMax
,
405 GLint size
, GLenum type
, GLsizei stride
,
406 GLboolean normalized
, GLboolean integer
, GLboolean doubles
,
409 struct gl_vertex_attrib_array
*array
;
410 GLsizei effectiveStride
;
412 /* Page 407 (page 423 of the PDF) of the OpenGL 3.0 spec says:
414 * "Client vertex arrays - all vertex array attribute pointers must
415 * refer to buffer objects (section 2.9.2). The default vertex array
416 * object (the name zero) is also deprecated. Calling
417 * VertexAttribPointer when no buffer object or no vertex array object
418 * is bound will generate an INVALID_OPERATION error..."
420 * The check for VBOs is handled below.
422 if (ctx
->API
== API_OPENGL_CORE
423 && (ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
)) {
424 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no array object bound)",
430 _mesa_error( ctx
, GL_INVALID_VALUE
, "%s(stride=%d)", func
, stride
);
434 if (ctx
->API
== API_OPENGL_CORE
&& ctx
->Version
>= 44 &&
435 stride
> ctx
->Const
.MaxVertexAttribStride
) {
436 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride=%d > "
437 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, stride
);
441 /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says:
443 * "An INVALID_OPERATION error is generated under any of the following
448 * * any of the *Pointer commands specifying the location and
449 * organization of vertex array data are called while zero is bound
450 * to the ARRAY_BUFFER buffer object binding point (see section
451 * 2.9.6), and the pointer argument is not NULL."
453 if (ptr
!= NULL
&& ctx
->Array
.VAO
->ARBsemantics
&&
454 !_mesa_is_bufferobj(ctx
->Array
.ArrayBufferObj
)) {
455 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(non-VBO array)", func
);
459 if (!update_array_format(ctx
, func
, attrib
, legalTypesMask
, sizeMin
,
460 sizeMax
, size
, type
, normalized
, integer
, doubles
, 0)) {
464 /* Reset the vertex attrib binding */
465 vertex_attrib_binding(ctx
, attrib
, attrib
);
467 /* The Stride and Ptr fields are not set by update_array_format() */
468 array
= &ctx
->Array
.VAO
->VertexAttrib
[attrib
];
469 array
->Stride
= stride
;
470 array
->Ptr
= (const GLvoid
*) ptr
;
472 /* Update the vertex buffer binding */
473 effectiveStride
= stride
!= 0 ? stride
: array
->_ElementSize
;
474 bind_vertex_buffer(ctx
, attrib
, ctx
->Array
.ArrayBufferObj
,
475 (GLintptr
) ptr
, effectiveStride
);
480 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
482 GET_CURRENT_CONTEXT(ctx
);
483 GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
484 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
485 : (SHORT_BIT
| INT_BIT
| FLOAT_BIT
|
486 DOUBLE_BIT
| HALF_BIT
|
487 UNSIGNED_INT_2_10_10_10_REV_BIT
|
488 INT_2_10_10_10_REV_BIT
);
490 FLUSH_VERTICES(ctx
, 0);
492 update_array(ctx
, "glVertexPointer", VERT_ATTRIB_POS
,
494 size
, type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
499 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
501 GET_CURRENT_CONTEXT(ctx
);
502 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
503 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
504 : (BYTE_BIT
| SHORT_BIT
| INT_BIT
|
505 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
506 UNSIGNED_INT_2_10_10_10_REV_BIT
|
507 INT_2_10_10_10_REV_BIT
);
509 FLUSH_VERTICES(ctx
, 0);
511 update_array(ctx
, "glNormalPointer", VERT_ATTRIB_NORMAL
,
513 3, type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
518 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
520 GET_CURRENT_CONTEXT(ctx
);
521 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
522 ? (UNSIGNED_BYTE_BIT
| HALF_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
523 : (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
524 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
525 INT_BIT
| UNSIGNED_INT_BIT
|
526 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
527 UNSIGNED_INT_2_10_10_10_REV_BIT
|
528 INT_2_10_10_10_REV_BIT
);
529 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 4 : 3;
531 FLUSH_VERTICES(ctx
, 0);
533 update_array(ctx
, "glColorPointer", VERT_ATTRIB_COLOR0
,
534 legalTypes
, sizeMin
, BGRA_OR_4
,
535 size
, type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
540 _mesa_FogCoordPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
542 const GLbitfield legalTypes
= (HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
);
543 GET_CURRENT_CONTEXT(ctx
);
545 FLUSH_VERTICES(ctx
, 0);
547 update_array(ctx
, "glFogCoordPointer", VERT_ATTRIB_FOG
,
549 1, type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
554 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
556 const GLbitfield legalTypes
= (UNSIGNED_BYTE_BIT
| SHORT_BIT
| INT_BIT
|
557 FLOAT_BIT
| DOUBLE_BIT
);
558 GET_CURRENT_CONTEXT(ctx
);
560 FLUSH_VERTICES(ctx
, 0);
562 update_array(ctx
, "glIndexPointer", VERT_ATTRIB_COLOR_INDEX
,
564 1, type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
569 _mesa_SecondaryColorPointer(GLint size
, GLenum type
,
570 GLsizei stride
, const GLvoid
*ptr
)
572 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
573 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
574 INT_BIT
| UNSIGNED_INT_BIT
|
575 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
576 UNSIGNED_INT_2_10_10_10_REV_BIT
|
577 INT_2_10_10_10_REV_BIT
);
578 GET_CURRENT_CONTEXT(ctx
);
580 FLUSH_VERTICES(ctx
, 0);
582 update_array(ctx
, "glSecondaryColorPointer", VERT_ATTRIB_COLOR1
,
583 legalTypes
, 3, BGRA_OR_4
,
584 size
, type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
589 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
592 GET_CURRENT_CONTEXT(ctx
);
593 GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
594 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
595 : (SHORT_BIT
| INT_BIT
|
596 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
597 UNSIGNED_INT_2_10_10_10_REV_BIT
|
598 INT_2_10_10_10_REV_BIT
);
599 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
600 const GLuint unit
= ctx
->Array
.ActiveTexture
;
602 FLUSH_VERTICES(ctx
, 0);
604 update_array(ctx
, "glTexCoordPointer", VERT_ATTRIB_TEX(unit
),
605 legalTypes
, sizeMin
, 4,
606 size
, type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
,
612 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
614 const GLbitfield legalTypes
= UNSIGNED_BYTE_BIT
;
615 /* this is the same type that glEdgeFlag uses */
616 const GLboolean integer
= GL_FALSE
;
617 GET_CURRENT_CONTEXT(ctx
);
619 FLUSH_VERTICES(ctx
, 0);
621 update_array(ctx
, "glEdgeFlagPointer", VERT_ATTRIB_EDGEFLAG
,
623 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, integer
, GL_FALSE
, ptr
);
628 _mesa_PointSizePointerOES(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
630 const GLbitfield legalTypes
= (FLOAT_BIT
| FIXED_ES_BIT
);
631 GET_CURRENT_CONTEXT(ctx
);
633 FLUSH_VERTICES(ctx
, 0);
635 if (ctx
->API
!= API_OPENGLES
) {
636 _mesa_error(ctx
, GL_INVALID_OPERATION
,
637 "glPointSizePointer(ES 1.x only)");
641 update_array(ctx
, "glPointSizePointer", VERT_ATTRIB_POINT_SIZE
,
643 1, type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
648 * Set a generic vertex attribute array.
649 * Note that these arrays DO NOT alias the conventional GL vertex arrays
650 * (position, normal, color, fog, texcoord, etc).
653 _mesa_VertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
654 GLboolean normalized
,
655 GLsizei stride
, const GLvoid
*ptr
)
657 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
658 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
659 INT_BIT
| UNSIGNED_INT_BIT
|
660 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
661 FIXED_ES_BIT
| FIXED_GL_BIT
|
662 UNSIGNED_INT_2_10_10_10_REV_BIT
|
663 INT_2_10_10_10_REV_BIT
|
664 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
665 GET_CURRENT_CONTEXT(ctx
);
667 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
668 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
672 update_array(ctx
, "glVertexAttribPointer", VERT_ATTRIB_GENERIC(index
),
673 legalTypes
, 1, BGRA_OR_4
,
674 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, ptr
);
679 * GL_EXT_gpu_shader4 / GL 3.0.
680 * Set an integer-valued vertex attribute array.
681 * Note that these arrays DO NOT alias the conventional GL vertex arrays
682 * (position, normal, color, fog, texcoord, etc).
685 _mesa_VertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
686 GLsizei stride
, const GLvoid
*ptr
)
688 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
689 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
690 INT_BIT
| UNSIGNED_INT_BIT
);
691 const GLboolean normalized
= GL_FALSE
;
692 const GLboolean integer
= GL_TRUE
;
693 GET_CURRENT_CONTEXT(ctx
);
695 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
696 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribIPointer(index)");
700 update_array(ctx
, "glVertexAttribIPointer", VERT_ATTRIB_GENERIC(index
),
702 size
, type
, stride
, normalized
, integer
, GL_FALSE
, ptr
);
706 _mesa_VertexAttribLPointer(GLuint index
, GLint size
, GLenum type
,
707 GLsizei stride
, const GLvoid
*ptr
)
709 GET_CURRENT_CONTEXT(ctx
);
710 const GLbitfield legalTypes
= (DOUBLE_BIT
);
711 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
712 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribLPointer(index)");
716 update_array(ctx
, "glVertexAttribLPointer", VERT_ATTRIB_GENERIC(index
),
718 size
, type
, stride
, GL_TRUE
, GL_FALSE
, GL_TRUE
, ptr
);
722 _mesa_EnableVertexAttribArray(GLuint index
)
724 struct gl_vertex_array_object
*vao
;
725 GET_CURRENT_CONTEXT(ctx
);
727 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
728 _mesa_error(ctx
, GL_INVALID_VALUE
,
729 "glEnableVertexAttribArrayARB(index)");
733 vao
= ctx
->Array
.VAO
;
735 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
737 if (!vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Enabled
) {
738 /* was disabled, now being enabled */
739 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
740 vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Enabled
= GL_TRUE
;
741 vao
->_Enabled
|= VERT_BIT_GENERIC(index
);
742 vao
->NewArrays
|= VERT_BIT_GENERIC(index
);
748 _mesa_DisableVertexAttribArray(GLuint index
)
750 struct gl_vertex_array_object
*vao
;
751 GET_CURRENT_CONTEXT(ctx
);
753 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
754 _mesa_error(ctx
, GL_INVALID_VALUE
,
755 "glDisableVertexAttribArrayARB(index)");
759 vao
= ctx
->Array
.VAO
;
761 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
763 if (vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Enabled
) {
764 /* was enabled, now being disabled */
765 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
766 vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Enabled
= GL_FALSE
;
767 vao
->_Enabled
&= ~VERT_BIT_GENERIC(index
);
768 vao
->NewArrays
|= VERT_BIT_GENERIC(index
);
774 * Return info for a vertex attribute array (no alias with legacy
775 * vertex attributes (pos, normal, color, etc)). This function does
776 * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
779 get_vertex_array_attrib(struct gl_context
*ctx
, GLuint index
, GLenum pname
,
782 const struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
783 const struct gl_vertex_attrib_array
*array
;
785 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
786 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)", caller
, index
);
790 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
792 array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)];
795 case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB
:
796 return array
->Enabled
;
797 case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB
:
798 return (array
->Format
== GL_BGRA
) ? GL_BGRA
: array
->Size
;
799 case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB
:
800 return array
->Stride
;
801 case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB
:
803 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB
:
804 return array
->Normalized
;
805 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
806 return vao
->VertexBinding
[array
->VertexBinding
].BufferObj
->Name
;
807 case GL_VERTEX_ATTRIB_ARRAY_INTEGER
:
808 if ((_mesa_is_desktop_gl(ctx
)
809 && (ctx
->Version
>= 30 || ctx
->Extensions
.EXT_gpu_shader4
))
810 || _mesa_is_gles3(ctx
)) {
811 return array
->Integer
;
814 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB
:
815 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_instanced_arrays
)
816 || _mesa_is_gles3(ctx
)) {
817 return vao
->VertexBinding
[array
->VertexBinding
].InstanceDivisor
;
820 case GL_VERTEX_ATTRIB_BINDING
:
821 if (_mesa_is_desktop_gl(ctx
)) {
822 return array
->VertexBinding
- VERT_ATTRIB_GENERIC0
;
825 case GL_VERTEX_ATTRIB_RELATIVE_OFFSET
:
826 if (_mesa_is_desktop_gl(ctx
)) {
827 return array
->RelativeOffset
;
835 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", caller
, pname
);
840 static const GLfloat
*
841 get_current_attrib(struct gl_context
*ctx
, GLuint index
, const char *function
)
844 if (_mesa_attr_zero_aliases_vertex(ctx
)) {
845 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(index==0)", function
);
849 else if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
850 _mesa_error(ctx
, GL_INVALID_VALUE
,
851 "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function
);
855 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
857 FLUSH_CURRENT(ctx
, 0);
858 return ctx
->Current
.Attrib
[VERT_ATTRIB_GENERIC(index
)];
862 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
)
864 GET_CURRENT_CONTEXT(ctx
);
866 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
867 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribfv");
873 params
[0] = (GLfloat
) get_vertex_array_attrib(ctx
, index
, pname
,
874 "glGetVertexAttribfv");
880 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
)
882 GET_CURRENT_CONTEXT(ctx
);
884 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
885 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribdv");
887 params
[0] = (GLdouble
) v
[0];
888 params
[1] = (GLdouble
) v
[1];
889 params
[2] = (GLdouble
) v
[2];
890 params
[3] = (GLdouble
) v
[3];
894 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, index
, pname
,
895 "glGetVertexAttribdv");
900 _mesa_GetVertexAttribLdv(GLuint index
, GLenum pname
, GLdouble
*params
)
902 GET_CURRENT_CONTEXT(ctx
);
904 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
905 const GLdouble
*v
= (const GLdouble
*)get_current_attrib(ctx
, index
, "glGetVertexAttribLdv");
914 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, index
, pname
,
915 "glGetVertexAttribLdv");
920 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
)
922 GET_CURRENT_CONTEXT(ctx
);
924 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
925 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribiv");
927 /* XXX should floats in[0,1] be scaled to full int range? */
928 params
[0] = (GLint
) v
[0];
929 params
[1] = (GLint
) v
[1];
930 params
[2] = (GLint
) v
[2];
931 params
[3] = (GLint
) v
[3];
935 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, index
, pname
,
936 "glGetVertexAttribiv");
943 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
)
945 GET_CURRENT_CONTEXT(ctx
);
947 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
948 const GLint
*v
= (const GLint
*)
949 get_current_attrib(ctx
, index
, "glGetVertexAttribIiv");
955 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, index
, pname
,
956 "glGetVertexAttribIiv");
963 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
)
965 GET_CURRENT_CONTEXT(ctx
);
967 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
968 const GLuint
*v
= (const GLuint
*)
969 get_current_attrib(ctx
, index
, "glGetVertexAttribIuiv");
975 params
[0] = get_vertex_array_attrib(ctx
, index
, pname
,
976 "glGetVertexAttribIuiv");
982 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
)
984 GET_CURRENT_CONTEXT(ctx
);
986 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
987 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerARB(index)");
991 if (pname
!= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
) {
992 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerARB(pname)");
996 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
998 *pointer
= (GLvoid
*) ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Ptr
;
1003 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
1004 GLsizei count
, const GLvoid
*ptr
)
1007 _mesa_VertexPointer(size
, type
, stride
, ptr
);
1012 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
1016 _mesa_NormalPointer(type
, stride
, ptr
);
1021 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
1025 _mesa_ColorPointer(size
, type
, stride
, ptr
);
1030 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
1034 _mesa_IndexPointer(type
, stride
, ptr
);
1039 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
1040 GLsizei count
, const GLvoid
*ptr
)
1043 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
1048 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
1051 _mesa_EdgeFlagPointer(stride
, ptr
);
1056 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
1058 GET_CURRENT_CONTEXT(ctx
);
1059 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
1060 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
1061 GLenum ctype
= 0; /* color type */
1062 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
1063 const GLint toffset
= 0; /* always zero */
1064 GLint defstride
; /* default stride */
1067 FLUSH_VERTICES(ctx
, 0);
1069 f
= sizeof(GLfloat
);
1070 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
1073 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
1079 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1080 tcomps
= 0; ccomps
= 0; vcomps
= 2;
1085 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1086 tcomps
= 0; ccomps
= 0; vcomps
= 3;
1091 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1092 tcomps
= 0; ccomps
= 4; vcomps
= 2;
1093 ctype
= GL_UNSIGNED_BYTE
;
1096 defstride
= c
+ 2*f
;
1099 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1100 tcomps
= 0; ccomps
= 4; vcomps
= 3;
1101 ctype
= GL_UNSIGNED_BYTE
;
1104 defstride
= c
+ 3*f
;
1107 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1108 tcomps
= 0; ccomps
= 3; vcomps
= 3;
1115 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
1116 tcomps
= 0; ccomps
= 0; vcomps
= 3;
1121 case GL_C4F_N3F_V3F
:
1122 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
1123 tcomps
= 0; ccomps
= 4; vcomps
= 3;
1131 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1132 tcomps
= 2; ccomps
= 0; vcomps
= 3;
1137 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1138 tcomps
= 4; ccomps
= 0; vcomps
= 4;
1142 case GL_T2F_C4UB_V3F
:
1143 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1144 tcomps
= 2; ccomps
= 4; vcomps
= 3;
1145 ctype
= GL_UNSIGNED_BYTE
;
1150 case GL_T2F_C3F_V3F
:
1151 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1152 tcomps
= 2; ccomps
= 3; vcomps
= 3;
1158 case GL_T2F_N3F_V3F
:
1159 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
1160 tcomps
= 2; ccomps
= 0; vcomps
= 3;
1165 case GL_T2F_C4F_N3F_V3F
:
1166 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
1167 tcomps
= 2; ccomps
= 4; vcomps
= 3;
1174 case GL_T4F_C4F_N3F_V4F
:
1175 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
1176 tcomps
= 4; ccomps
= 4; vcomps
= 4;
1184 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
1192 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
1193 _mesa_DisableClientState( GL_INDEX_ARRAY
);
1194 /* XXX also disable secondary color and generic arrays? */
1198 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
1199 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
1200 (GLubyte
*) pointer
+ toffset
);
1203 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
1208 _mesa_EnableClientState( GL_COLOR_ARRAY
);
1209 _mesa_ColorPointer( ccomps
, ctype
, stride
,
1210 (GLubyte
*) pointer
+ coffset
);
1213 _mesa_DisableClientState( GL_COLOR_ARRAY
);
1219 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
1220 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
1223 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
1227 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
1228 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
1229 (GLubyte
*) pointer
+ voffset
);
1234 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
1236 GET_CURRENT_CONTEXT(ctx
);
1238 FLUSH_VERTICES(ctx
, 0);
1240 if (MESA_VERBOSE
& VERBOSE_API
)
1241 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
1244 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
1248 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
1251 if (ctx
->Array
.LockCount
!= 0) {
1252 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
1256 ctx
->Array
.LockFirst
= first
;
1257 ctx
->Array
.LockCount
= count
;
1259 ctx
->NewState
|= _NEW_ARRAY
;
1264 _mesa_UnlockArraysEXT( void )
1266 GET_CURRENT_CONTEXT(ctx
);
1268 FLUSH_VERTICES(ctx
, 0);
1270 if (MESA_VERBOSE
& VERBOSE_API
)
1271 _mesa_debug(ctx
, "glUnlockArrays\n");
1273 if (ctx
->Array
.LockCount
== 0) {
1274 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
1278 ctx
->Array
.LockFirst
= 0;
1279 ctx
->Array
.LockCount
= 0;
1280 ctx
->NewState
|= _NEW_ARRAY
;
1284 /* GL_EXT_multi_draw_arrays */
1286 _mesa_MultiDrawArrays( GLenum mode
, const GLint
*first
,
1287 const GLsizei
*count
, GLsizei primcount
)
1289 GET_CURRENT_CONTEXT(ctx
);
1292 FLUSH_VERTICES(ctx
, 0);
1294 for (i
= 0; i
< primcount
; i
++) {
1296 CALL_DrawArrays(ctx
->CurrentDispatch
, (mode
, first
[i
], count
[i
]));
1302 /* GL_IBM_multimode_draw_arrays */
1304 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
1305 const GLsizei
* count
,
1306 GLsizei primcount
, GLint modestride
)
1308 GET_CURRENT_CONTEXT(ctx
);
1311 FLUSH_VERTICES(ctx
, 0);
1313 for ( i
= 0 ; i
< primcount
; i
++ ) {
1314 if ( count
[i
] > 0 ) {
1315 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1316 CALL_DrawArrays(ctx
->CurrentDispatch
, ( m
, first
[i
], count
[i
] ));
1322 /* GL_IBM_multimode_draw_arrays */
1324 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
1325 GLenum type
, const GLvoid
* const * indices
,
1326 GLsizei primcount
, GLint modestride
)
1328 GET_CURRENT_CONTEXT(ctx
);
1331 FLUSH_VERTICES(ctx
, 0);
1333 /* XXX not sure about ARB_vertex_buffer_object handling here */
1335 for ( i
= 0 ; i
< primcount
; i
++ ) {
1336 if ( count
[i
] > 0 ) {
1337 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1338 CALL_DrawElements(ctx
->CurrentDispatch
, ( m
, count
[i
], type
,
1346 * GL_NV_primitive_restart and GL 3.1
1349 _mesa_PrimitiveRestartIndex(GLuint index
)
1351 GET_CURRENT_CONTEXT(ctx
);
1353 if (!ctx
->Extensions
.NV_primitive_restart
&& ctx
->Version
< 31) {
1354 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glPrimitiveRestartIndexNV()");
1358 if (ctx
->Array
.RestartIndex
!= index
) {
1359 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
1360 ctx
->Array
.RestartIndex
= index
;
1366 * See GL_ARB_instanced_arrays.
1367 * Note that the instance divisor only applies to generic arrays, not
1368 * the legacy vertex arrays.
1371 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
)
1373 GET_CURRENT_CONTEXT(ctx
);
1375 const GLuint genericIndex
= VERT_ATTRIB_GENERIC(index
);
1377 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
1378 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexAttribDivisor()");
1382 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1383 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribDivisor(index = %u)",
1388 assert(genericIndex
< ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1390 /* The ARB_vertex_attrib_binding spec says:
1394 * void VertexAttribDivisor(uint index, uint divisor);
1396 * is equivalent to (assuming no errors are generated):
1398 * VertexAttribBinding(index, index);
1399 * VertexBindingDivisor(index, divisor);"
1401 vertex_attrib_binding(ctx
, genericIndex
, genericIndex
);
1402 vertex_binding_divisor(ctx
, genericIndex
, divisor
);
1407 _mesa_primitive_restart_index(const struct gl_context
*ctx
, GLenum ib_type
)
1409 /* From the OpenGL 4.3 core specification, page 302:
1410 * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are
1411 * enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX
1414 if (ctx
->Array
.PrimitiveRestartFixedIndex
) {
1416 case GL_UNSIGNED_BYTE
:
1418 case GL_UNSIGNED_SHORT
:
1420 case GL_UNSIGNED_INT
:
1423 assert(!"_mesa_primitive_restart_index: Invalid index buffer type.");
1427 return ctx
->Array
.RestartIndex
;
1432 * GL_ARB_vertex_attrib_binding
1435 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
1438 GET_CURRENT_CONTEXT(ctx
);
1439 const struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1440 struct gl_buffer_object
*vbo
;
1442 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1444 /* The ARB_vertex_attrib_binding spec says:
1446 * "An INVALID_OPERATION error is generated if no vertex array object
1449 if (ctx
->API
== API_OPENGL_CORE
&&
1450 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1451 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1452 "glBindVertexBuffer(No array object bound)");
1456 /* The ARB_vertex_attrib_binding spec says:
1458 * "An INVALID_VALUE error is generated if <bindingindex> is greater than
1459 * the value of MAX_VERTEX_ATTRIB_BINDINGS."
1461 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
1462 _mesa_error(ctx
, GL_INVALID_VALUE
,
1463 "glBindVertexBuffer(bindingindex=%u > "
1464 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
1469 /* The ARB_vertex_attrib_binding spec says:
1471 * "The error INVALID_VALUE is generated if <stride> or <offset>
1475 _mesa_error(ctx
, GL_INVALID_VALUE
,
1476 "glBindVertexBuffer(offset=%" PRId64
" < 0)",
1482 _mesa_error(ctx
, GL_INVALID_VALUE
,
1483 "glBindVertexBuffer(stride=%d < 0)", stride
);
1487 if (ctx
->API
== API_OPENGL_CORE
&& ctx
->Version
>= 44 &&
1488 stride
> ctx
->Const
.MaxVertexAttribStride
) {
1489 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindVertexBuffer(stride=%d > "
1490 "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride
);
1494 if (buffer
== vao
->VertexBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
->Name
) {
1495 vbo
= vao
->VertexBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
;
1496 } else if (buffer
!= 0) {
1497 vbo
= _mesa_lookup_bufferobj(ctx
, buffer
);
1499 /* From the GL_ARB_vertex_attrib_array spec:
1501 * "[Core profile only:]
1502 * An INVALID_OPERATION error is generated if buffer is not zero or a
1503 * name returned from a previous call to GenBuffers, or if such a name
1504 * has since been deleted with DeleteBuffers.
1506 * Otherwise, we fall back to the same compat profile behavior as other
1507 * object references (automatically gen it).
1509 if (!_mesa_handle_bind_buffer_gen(ctx
, GL_ARRAY_BUFFER
, buffer
,
1510 &vbo
, "glBindVertexBuffer"))
1513 /* The ARB_vertex_attrib_binding spec says:
1515 * "If <buffer> is zero, any buffer object attached to this
1516 * bindpoint is detached."
1518 vbo
= ctx
->Shared
->NullBufferObj
;
1521 bind_vertex_buffer(ctx
, VERT_ATTRIB_GENERIC(bindingIndex
),
1522 vbo
, offset
, stride
);
1527 _mesa_BindVertexBuffers(GLuint first
, GLsizei count
, const GLuint
*buffers
,
1528 const GLintptr
*offsets
, const GLsizei
*strides
)
1530 GET_CURRENT_CONTEXT(ctx
);
1531 struct gl_vertex_array_object
* const vao
= ctx
->Array
.VAO
;
1534 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1536 /* The ARB_vertex_attrib_binding spec says:
1538 * "An INVALID_OPERATION error is generated if no
1539 * vertex array object is bound."
1541 if (ctx
->API
== API_OPENGL_CORE
&&
1542 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1543 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1544 "glBindVertexBuffers(No array object bound)");
1548 /* The ARB_multi_bind spec says:
1550 * "An INVALID_OPERATION error is generated if <first> + <count>
1551 * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS."
1553 if (first
+ count
> ctx
->Const
.MaxVertexAttribBindings
) {
1554 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1555 "glBindVertexBuffers(first=%u + count=%d > the value of "
1556 "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
1557 first
, count
, ctx
->Const
.MaxVertexAttribBindings
);
1563 * The ARB_multi_bind spec says:
1565 * "If <buffers> is NULL, each affected vertex buffer binding point
1566 * from <first> through <first>+<count>-1 will be reset to have no
1567 * bound buffer object. In this case, the offsets and strides
1568 * associated with the binding points are set to default values,
1569 * ignoring <offsets> and <strides>."
1571 struct gl_buffer_object
*vbo
= ctx
->Shared
->NullBufferObj
;
1573 for (i
= 0; i
< count
; i
++)
1574 bind_vertex_buffer(ctx
, VERT_ATTRIB_GENERIC(first
+ i
), vbo
, 0, 16);
1579 /* Note that the error semantics for multi-bind commands differ from
1580 * those of other GL commands.
1582 * The Issues section in the ARB_multi_bind spec says:
1584 * "(11) Typically, OpenGL specifies that if an error is generated by
1585 * a command, that command has no effect. This is somewhat
1586 * unfortunate for multi-bind commands, because it would require
1587 * a first pass to scan the entire list of bound objects for
1588 * errors and then a second pass to actually perform the
1589 * bindings. Should we have different error semantics?
1591 * RESOLVED: Yes. In this specification, when the parameters for
1592 * one of the <count> binding points are invalid, that binding
1593 * point is not updated and an error will be generated. However,
1594 * other binding points in the same command will be updated if
1595 * their parameters are valid and no other error occurs."
1598 _mesa_begin_bufferobj_lookups(ctx
);
1600 for (i
= 0; i
< count
; i
++) {
1601 struct gl_buffer_object
*vbo
;
1603 /* The ARB_multi_bind spec says:
1605 * "An INVALID_VALUE error is generated if any value in
1606 * <offsets> or <strides> is negative (per binding)."
1608 if (offsets
[i
] < 0) {
1609 _mesa_error(ctx
, GL_INVALID_VALUE
,
1610 "glBindVertexBuffers(offsets[%u]=%" PRId64
" < 0)",
1611 i
, (int64_t) offsets
[i
]);
1615 if (strides
[i
] < 0) {
1616 _mesa_error(ctx
, GL_INVALID_VALUE
,
1617 "glBindVertexBuffers(strides[%u]=%d < 0)",
1622 if (ctx
->API
== API_OPENGL_CORE
&& ctx
->Version
>= 44 &&
1623 strides
[i
] > ctx
->Const
.MaxVertexAttribStride
) {
1624 _mesa_error(ctx
, GL_INVALID_VALUE
,
1625 "glBindVertexBuffers(strides[%u]=%d > "
1626 "GL_MAX_VERTEX_ATTRIB_STRIDE)", i
, strides
[i
]);
1631 struct gl_vertex_buffer_binding
*binding
=
1632 &vao
->VertexBinding
[VERT_ATTRIB_GENERIC(first
+ i
)];
1634 if (buffers
[i
] == binding
->BufferObj
->Name
)
1635 vbo
= binding
->BufferObj
;
1637 vbo
= _mesa_multi_bind_lookup_bufferobj(ctx
, buffers
, i
,
1638 "glBindVertexBuffers");
1643 vbo
= ctx
->Shared
->NullBufferObj
;
1646 bind_vertex_buffer(ctx
, VERT_ATTRIB_GENERIC(first
+ i
), vbo
,
1647 offsets
[i
], strides
[i
]);
1650 _mesa_end_bufferobj_lookups(ctx
);
1655 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
1656 GLboolean normalized
, GLuint relativeOffset
)
1658 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1659 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1660 INT_BIT
| UNSIGNED_INT_BIT
|
1661 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1663 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1664 INT_2_10_10_10_REV_BIT
|
1665 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
1667 GET_CURRENT_CONTEXT(ctx
);
1668 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1670 /* The ARB_vertex_attrib_binding spec says:
1672 * "An INVALID_OPERATION error is generated under any of the following
1674 * - if no vertex array object is currently bound (see section 2.10);
1677 if (ctx
->API
== API_OPENGL_CORE
&&
1678 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1679 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1680 "glVertexAttribFormat(No array object bound)");
1684 /* The ARB_vertex_attrib_binding spec says:
1686 * "The error INVALID_VALUE is generated if index is greater than or equal
1687 * to the value of MAX_VERTEX_ATTRIBS."
1689 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1690 _mesa_error(ctx
, GL_INVALID_VALUE
,
1691 "glVertexAttribFormat(attribindex=%u > "
1692 "GL_MAX_VERTEX_ATTRIBS)",
1697 FLUSH_VERTICES(ctx
, 0);
1699 update_array_format(ctx
, "glVertexAttribFormat",
1700 VERT_ATTRIB_GENERIC(attribIndex
),
1701 legalTypes
, 1, BGRA_OR_4
, size
, type
, normalized
,
1702 GL_FALSE
, GL_FALSE
, relativeOffset
);
1707 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
1708 GLuint relativeOffset
)
1710 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1711 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1712 INT_BIT
| UNSIGNED_INT_BIT
);
1714 GET_CURRENT_CONTEXT(ctx
);
1715 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1717 /* The ARB_vertex_attrib_binding spec says:
1719 * "An INVALID_OPERATION error is generated under any of the following
1721 * - if no vertex array object is currently bound (see section 2.10);
1724 if (ctx
->API
== API_OPENGL_CORE
&&
1725 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1726 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1727 "glVertexAttribIFormat(No array object bound)");
1731 /* The ARB_vertex_attrib_binding spec says:
1733 * "The error INVALID_VALUE is generated if index is greater than
1734 * or equal to the value of MAX_VERTEX_ATTRIBS."
1736 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1737 _mesa_error(ctx
, GL_INVALID_VALUE
,
1738 "glVertexAttribIFormat(attribindex=%u > "
1739 "GL_MAX_VERTEX_ATTRIBS)",
1744 FLUSH_VERTICES(ctx
, 0);
1746 update_array_format(ctx
, "glVertexAttribIFormat",
1747 VERT_ATTRIB_GENERIC(attribIndex
),
1748 legalTypes
, 1, 4, size
, type
, GL_FALSE
, GL_TRUE
, GL_FALSE
,
1754 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
1755 GLuint relativeOffset
)
1757 const GLbitfield legalTypes
= DOUBLE_BIT
;
1759 GET_CURRENT_CONTEXT(ctx
);
1760 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1762 /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
1764 * "An INVALID_OPERATION error is generated under any of the following
1766 * • if no vertex array object is currently bound (see section 10.4);
1769 * This language is missing from the extension spec, but we assume
1770 * that this is an oversight.
1772 if (ctx
->API
== API_OPENGL_CORE
&&
1773 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1774 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1775 "glVertexAttribLFormat(No array object bound)");
1779 /* The ARB_vertex_attrib_binding spec says:
1781 * "The error INVALID_VALUE is generated if <attribindex> is greater than
1782 * or equal to the value of MAX_VERTEX_ATTRIBS."
1784 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1785 _mesa_error(ctx
, GL_INVALID_VALUE
,
1786 "glVertexAttribLFormat(attribindex=%u > "
1787 "GL_MAX_VERTEX_ATTRIBS)",
1792 FLUSH_VERTICES(ctx
, 0);
1794 update_array_format(ctx
, "glVertexAttribLFormat",
1795 VERT_ATTRIB_GENERIC(attribIndex
),
1796 legalTypes
, 1, 4, size
, type
, GL_FALSE
, GL_FALSE
, GL_TRUE
,
1802 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
)
1804 GET_CURRENT_CONTEXT(ctx
);
1805 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1807 /* The ARB_vertex_attrib_binding spec says:
1809 * "An INVALID_OPERATION error is generated if no vertex array object
1812 if (ctx
->API
== API_OPENGL_CORE
&&
1813 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1814 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1815 "glVertexAttribBinding(No array object bound)");
1819 /* The ARB_vertex_attrib_binding spec says:
1821 * "<attribindex> must be less than the value of MAX_VERTEX_ATTRIBS and
1822 * <bindingindex> must be less than the value of
1823 * MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
1826 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1827 _mesa_error(ctx
, GL_INVALID_VALUE
,
1828 "glVertexAttribBinding(attribindex=%u >= "
1829 "GL_MAX_VERTEX_ATTRIBS)",
1834 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
1835 _mesa_error(ctx
, GL_INVALID_VALUE
,
1836 "glVertexAttribBinding(bindingindex=%u >= "
1837 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
1842 assert(VERT_ATTRIB_GENERIC(attribIndex
) <
1843 ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1845 vertex_attrib_binding(ctx
, VERT_ATTRIB_GENERIC(attribIndex
),
1846 VERT_ATTRIB_GENERIC(bindingIndex
));
1851 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
)
1853 GET_CURRENT_CONTEXT(ctx
);
1854 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1856 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
1857 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexBindingDivisor()");
1861 /* The ARB_vertex_attrib_binding spec says:
1863 * "An INVALID_OPERATION error is generated if no vertex array object
1866 if (ctx
->API
== API_OPENGL_CORE
&&
1867 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1868 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1869 "glVertexBindingDivisor(No array object bound)");
1873 /* The ARB_vertex_attrib_binding spec says:
1875 * "An INVALID_VALUE error is generated if <bindingindex> is greater
1876 * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS."
1878 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
1879 _mesa_error(ctx
, GL_INVALID_VALUE
,
1880 "glVertexBindingDivisor(bindingindex=%u > "
1881 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
1886 vertex_binding_divisor(ctx
, VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
1891 * Copy one client vertex array to another.
1894 _mesa_copy_client_array(struct gl_context
*ctx
,
1895 struct gl_client_array
*dst
,
1896 struct gl_client_array
*src
)
1898 dst
->Size
= src
->Size
;
1899 dst
->Type
= src
->Type
;
1900 dst
->Format
= src
->Format
;
1901 dst
->Stride
= src
->Stride
;
1902 dst
->StrideB
= src
->StrideB
;
1903 dst
->Ptr
= src
->Ptr
;
1904 dst
->Enabled
= src
->Enabled
;
1905 dst
->Normalized
= src
->Normalized
;
1906 dst
->Integer
= src
->Integer
;
1907 dst
->Doubles
= src
->Doubles
;
1908 dst
->InstanceDivisor
= src
->InstanceDivisor
;
1909 dst
->_ElementSize
= src
->_ElementSize
;
1910 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, src
->BufferObj
);
1914 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
1915 struct gl_vertex_attrib_array
*dst
,
1916 const struct gl_vertex_attrib_array
*src
)
1918 dst
->Size
= src
->Size
;
1919 dst
->Type
= src
->Type
;
1920 dst
->Format
= src
->Format
;
1921 dst
->VertexBinding
= src
->VertexBinding
;
1922 dst
->RelativeOffset
= src
->RelativeOffset
;
1923 dst
->Format
= src
->Format
;
1924 dst
->Integer
= src
->Integer
;
1925 dst
->Doubles
= src
->Doubles
;
1926 dst
->Normalized
= src
->Normalized
;
1927 dst
->Ptr
= src
->Ptr
;
1928 dst
->Enabled
= src
->Enabled
;
1929 dst
->_ElementSize
= src
->_ElementSize
;
1933 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
1934 struct gl_vertex_buffer_binding
*dst
,
1935 const struct gl_vertex_buffer_binding
*src
)
1937 dst
->Offset
= src
->Offset
;
1938 dst
->Stride
= src
->Stride
;
1939 dst
->InstanceDivisor
= src
->InstanceDivisor
;
1940 dst
->_BoundArrays
= src
->_BoundArrays
;
1942 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, src
->BufferObj
);
1946 * Print vertex array's fields.
1949 print_array(const char *name
, GLint index
, const struct gl_client_array
*array
)
1952 fprintf(stderr
, " %s[%d]: ", name
, index
);
1954 fprintf(stderr
, " %s: ", name
);
1955 fprintf(stderr
, "Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu)\n",
1956 array
->Ptr
, array
->Type
, array
->Size
,
1957 array
->_ElementSize
, array
->StrideB
,
1958 array
->BufferObj
->Name
, (unsigned long) array
->BufferObj
->Size
);
1963 * Print current vertex object/array info. For debug.
1966 _mesa_print_arrays(struct gl_context
*ctx
)
1968 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1971 printf("Array Object %u\n", vao
->Name
);
1972 if (vao
->_VertexAttrib
[VERT_ATTRIB_POS
].Enabled
)
1973 print_array("Vertex", -1, &vao
->_VertexAttrib
[VERT_ATTRIB_POS
]);
1974 if (vao
->_VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
)
1975 print_array("Normal", -1, &vao
->_VertexAttrib
[VERT_ATTRIB_NORMAL
]);
1976 if (vao
->_VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
)
1977 print_array("Color", -1, &vao
->_VertexAttrib
[VERT_ATTRIB_COLOR0
]);
1978 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++)
1979 if (vao
->_VertexAttrib
[VERT_ATTRIB_TEX(i
)].Enabled
)
1980 print_array("TexCoord", i
, &vao
->_VertexAttrib
[VERT_ATTRIB_TEX(i
)]);
1981 for (i
= 0; i
< VERT_ATTRIB_GENERIC_MAX
; i
++)
1982 if (vao
->_VertexAttrib
[VERT_ATTRIB_GENERIC(i
)].Enabled
)
1983 print_array("Attrib", i
, &vao
->_VertexAttrib
[VERT_ATTRIB_GENERIC(i
)]);
1988 * Initialize vertex array state for given context.
1991 _mesa_init_varray(struct gl_context
*ctx
)
1993 ctx
->Array
.DefaultVAO
= ctx
->Driver
.NewArrayObject(ctx
, 0);
1994 _mesa_reference_vao(ctx
, &ctx
->Array
.VAO
, ctx
->Array
.DefaultVAO
);
1995 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */
1997 ctx
->Array
.Objects
= _mesa_NewHashTable();
2002 * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
2005 delete_arrayobj_cb(GLuint id
, void *data
, void *userData
)
2007 struct gl_vertex_array_object
*vao
= (struct gl_vertex_array_object
*) data
;
2008 struct gl_context
*ctx
= (struct gl_context
*) userData
;
2009 _mesa_delete_vao(ctx
, vao
);
2014 * Free vertex array state for given context.
2017 _mesa_free_varray_data(struct gl_context
*ctx
)
2019 _mesa_HashDeleteAll(ctx
->Array
.Objects
, delete_arrayobj_cb
, ctx
);
2020 _mesa_DeleteHashTable(ctx
->Array
.Objects
);