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 disable_vertex_array_attrib(struct gl_context
*ctx
,
749 struct gl_vertex_array_object
*vao
,
753 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
754 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index)", func
);
758 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
760 if (vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Enabled
) {
761 /* was enabled, now being disabled */
762 FLUSH_VERTICES(ctx
, _NEW_ARRAY
);
763 vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Enabled
= GL_FALSE
;
764 vao
->_Enabled
&= ~VERT_BIT_GENERIC(index
);
765 vao
->NewArrays
|= VERT_BIT_GENERIC(index
);
771 _mesa_DisableVertexAttribArray(GLuint index
)
773 GET_CURRENT_CONTEXT(ctx
);
774 disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, index
,
775 "glDisableVertexAttribArray");
780 _mesa_DisableVertexArrayAttrib(GLuint vaobj
, GLuint index
)
782 GET_CURRENT_CONTEXT(ctx
);
783 struct gl_vertex_array_object
*vao
;
785 /* The ARB_direct_state_access specification says:
787 * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
788 * and DisableVertexArrayAttrib if <vaobj> is not
789 * [compatibility profile: zero or] the name of an existing vertex
792 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, "glDisableVertexArrayAttrib");
796 disable_vertex_array_attrib(ctx
, vao
, index
, "glDisableVertexArrayAttrib");
801 * Return info for a vertex attribute array (no alias with legacy
802 * vertex attributes (pos, normal, color, etc)). This function does
803 * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
806 get_vertex_array_attrib(struct gl_context
*ctx
, GLuint index
, GLenum pname
,
809 const struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
810 const struct gl_vertex_attrib_array
*array
;
812 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
813 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)", caller
, index
);
817 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
819 array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)];
822 case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB
:
823 return array
->Enabled
;
824 case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB
:
825 return (array
->Format
== GL_BGRA
) ? GL_BGRA
: array
->Size
;
826 case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB
:
827 return array
->Stride
;
828 case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB
:
830 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB
:
831 return array
->Normalized
;
832 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
833 return vao
->VertexBinding
[array
->VertexBinding
].BufferObj
->Name
;
834 case GL_VERTEX_ATTRIB_ARRAY_INTEGER
:
835 if ((_mesa_is_desktop_gl(ctx
)
836 && (ctx
->Version
>= 30 || ctx
->Extensions
.EXT_gpu_shader4
))
837 || _mesa_is_gles3(ctx
)) {
838 return array
->Integer
;
841 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB
:
842 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_instanced_arrays
)
843 || _mesa_is_gles3(ctx
)) {
844 return vao
->VertexBinding
[array
->VertexBinding
].InstanceDivisor
;
847 case GL_VERTEX_ATTRIB_BINDING
:
848 if (_mesa_is_desktop_gl(ctx
)) {
849 return array
->VertexBinding
- VERT_ATTRIB_GENERIC0
;
852 case GL_VERTEX_ATTRIB_RELATIVE_OFFSET
:
853 if (_mesa_is_desktop_gl(ctx
)) {
854 return array
->RelativeOffset
;
862 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", caller
, pname
);
867 static const GLfloat
*
868 get_current_attrib(struct gl_context
*ctx
, GLuint index
, const char *function
)
871 if (_mesa_attr_zero_aliases_vertex(ctx
)) {
872 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(index==0)", function
);
876 else if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
877 _mesa_error(ctx
, GL_INVALID_VALUE
,
878 "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function
);
882 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
884 FLUSH_CURRENT(ctx
, 0);
885 return ctx
->Current
.Attrib
[VERT_ATTRIB_GENERIC(index
)];
889 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
)
891 GET_CURRENT_CONTEXT(ctx
);
893 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
894 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribfv");
900 params
[0] = (GLfloat
) get_vertex_array_attrib(ctx
, index
, pname
,
901 "glGetVertexAttribfv");
907 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
)
909 GET_CURRENT_CONTEXT(ctx
);
911 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
912 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribdv");
914 params
[0] = (GLdouble
) v
[0];
915 params
[1] = (GLdouble
) v
[1];
916 params
[2] = (GLdouble
) v
[2];
917 params
[3] = (GLdouble
) v
[3];
921 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, index
, pname
,
922 "glGetVertexAttribdv");
927 _mesa_GetVertexAttribLdv(GLuint index
, GLenum pname
, GLdouble
*params
)
929 GET_CURRENT_CONTEXT(ctx
);
931 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
932 const GLdouble
*v
= (const GLdouble
*)get_current_attrib(ctx
, index
, "glGetVertexAttribLdv");
941 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, index
, pname
,
942 "glGetVertexAttribLdv");
947 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
)
949 GET_CURRENT_CONTEXT(ctx
);
951 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
952 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribiv");
954 /* XXX should floats in[0,1] be scaled to full int range? */
955 params
[0] = (GLint
) v
[0];
956 params
[1] = (GLint
) v
[1];
957 params
[2] = (GLint
) v
[2];
958 params
[3] = (GLint
) v
[3];
962 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, index
, pname
,
963 "glGetVertexAttribiv");
970 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
)
972 GET_CURRENT_CONTEXT(ctx
);
974 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
975 const GLint
*v
= (const GLint
*)
976 get_current_attrib(ctx
, index
, "glGetVertexAttribIiv");
982 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, index
, pname
,
983 "glGetVertexAttribIiv");
990 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
)
992 GET_CURRENT_CONTEXT(ctx
);
994 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
995 const GLuint
*v
= (const GLuint
*)
996 get_current_attrib(ctx
, index
, "glGetVertexAttribIuiv");
1002 params
[0] = get_vertex_array_attrib(ctx
, index
, pname
,
1003 "glGetVertexAttribIuiv");
1009 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
)
1011 GET_CURRENT_CONTEXT(ctx
);
1013 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1014 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerARB(index)");
1018 if (pname
!= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
) {
1019 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerARB(pname)");
1023 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1025 *pointer
= (GLvoid
*) ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Ptr
;
1030 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
1031 GLsizei count
, const GLvoid
*ptr
)
1034 _mesa_VertexPointer(size
, type
, stride
, ptr
);
1039 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
1043 _mesa_NormalPointer(type
, stride
, ptr
);
1048 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
1052 _mesa_ColorPointer(size
, type
, stride
, ptr
);
1057 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
1061 _mesa_IndexPointer(type
, stride
, ptr
);
1066 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
1067 GLsizei count
, const GLvoid
*ptr
)
1070 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
1075 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
1078 _mesa_EdgeFlagPointer(stride
, ptr
);
1083 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
1085 GET_CURRENT_CONTEXT(ctx
);
1086 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
1087 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
1088 GLenum ctype
= 0; /* color type */
1089 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
1090 const GLint toffset
= 0; /* always zero */
1091 GLint defstride
; /* default stride */
1094 FLUSH_VERTICES(ctx
, 0);
1096 f
= sizeof(GLfloat
);
1097 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
1100 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
1106 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1107 tcomps
= 0; ccomps
= 0; vcomps
= 2;
1112 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1113 tcomps
= 0; ccomps
= 0; vcomps
= 3;
1118 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1119 tcomps
= 0; ccomps
= 4; vcomps
= 2;
1120 ctype
= GL_UNSIGNED_BYTE
;
1123 defstride
= c
+ 2*f
;
1126 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1127 tcomps
= 0; ccomps
= 4; vcomps
= 3;
1128 ctype
= GL_UNSIGNED_BYTE
;
1131 defstride
= c
+ 3*f
;
1134 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1135 tcomps
= 0; ccomps
= 3; vcomps
= 3;
1142 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
1143 tcomps
= 0; ccomps
= 0; vcomps
= 3;
1148 case GL_C4F_N3F_V3F
:
1149 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
1150 tcomps
= 0; ccomps
= 4; vcomps
= 3;
1158 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1159 tcomps
= 2; ccomps
= 0; vcomps
= 3;
1164 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
1165 tcomps
= 4; ccomps
= 0; vcomps
= 4;
1169 case GL_T2F_C4UB_V3F
:
1170 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1171 tcomps
= 2; ccomps
= 4; vcomps
= 3;
1172 ctype
= GL_UNSIGNED_BYTE
;
1177 case GL_T2F_C3F_V3F
:
1178 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
1179 tcomps
= 2; ccomps
= 3; vcomps
= 3;
1185 case GL_T2F_N3F_V3F
:
1186 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
1187 tcomps
= 2; ccomps
= 0; vcomps
= 3;
1192 case GL_T2F_C4F_N3F_V3F
:
1193 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
1194 tcomps
= 2; ccomps
= 4; vcomps
= 3;
1201 case GL_T4F_C4F_N3F_V4F
:
1202 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
1203 tcomps
= 4; ccomps
= 4; vcomps
= 4;
1211 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
1219 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
1220 _mesa_DisableClientState( GL_INDEX_ARRAY
);
1221 /* XXX also disable secondary color and generic arrays? */
1225 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
1226 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
1227 (GLubyte
*) pointer
+ toffset
);
1230 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
1235 _mesa_EnableClientState( GL_COLOR_ARRAY
);
1236 _mesa_ColorPointer( ccomps
, ctype
, stride
,
1237 (GLubyte
*) pointer
+ coffset
);
1240 _mesa_DisableClientState( GL_COLOR_ARRAY
);
1246 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
1247 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
1250 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
1254 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
1255 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
1256 (GLubyte
*) pointer
+ voffset
);
1261 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
1263 GET_CURRENT_CONTEXT(ctx
);
1265 FLUSH_VERTICES(ctx
, 0);
1267 if (MESA_VERBOSE
& VERBOSE_API
)
1268 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
1271 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
1275 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
1278 if (ctx
->Array
.LockCount
!= 0) {
1279 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
1283 ctx
->Array
.LockFirst
= first
;
1284 ctx
->Array
.LockCount
= count
;
1286 ctx
->NewState
|= _NEW_ARRAY
;
1291 _mesa_UnlockArraysEXT( void )
1293 GET_CURRENT_CONTEXT(ctx
);
1295 FLUSH_VERTICES(ctx
, 0);
1297 if (MESA_VERBOSE
& VERBOSE_API
)
1298 _mesa_debug(ctx
, "glUnlockArrays\n");
1300 if (ctx
->Array
.LockCount
== 0) {
1301 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
1305 ctx
->Array
.LockFirst
= 0;
1306 ctx
->Array
.LockCount
= 0;
1307 ctx
->NewState
|= _NEW_ARRAY
;
1311 /* GL_EXT_multi_draw_arrays */
1313 _mesa_MultiDrawArrays( GLenum mode
, const GLint
*first
,
1314 const GLsizei
*count
, GLsizei primcount
)
1316 GET_CURRENT_CONTEXT(ctx
);
1319 FLUSH_VERTICES(ctx
, 0);
1321 for (i
= 0; i
< primcount
; i
++) {
1323 CALL_DrawArrays(ctx
->CurrentDispatch
, (mode
, first
[i
], count
[i
]));
1329 /* GL_IBM_multimode_draw_arrays */
1331 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
1332 const GLsizei
* count
,
1333 GLsizei primcount
, GLint modestride
)
1335 GET_CURRENT_CONTEXT(ctx
);
1338 FLUSH_VERTICES(ctx
, 0);
1340 for ( i
= 0 ; i
< primcount
; i
++ ) {
1341 if ( count
[i
] > 0 ) {
1342 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1343 CALL_DrawArrays(ctx
->CurrentDispatch
, ( m
, first
[i
], count
[i
] ));
1349 /* GL_IBM_multimode_draw_arrays */
1351 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
1352 GLenum type
, const GLvoid
* const * indices
,
1353 GLsizei primcount
, GLint modestride
)
1355 GET_CURRENT_CONTEXT(ctx
);
1358 FLUSH_VERTICES(ctx
, 0);
1360 /* XXX not sure about ARB_vertex_buffer_object handling here */
1362 for ( i
= 0 ; i
< primcount
; i
++ ) {
1363 if ( count
[i
] > 0 ) {
1364 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1365 CALL_DrawElements(ctx
->CurrentDispatch
, ( m
, count
[i
], type
,
1373 * GL_NV_primitive_restart and GL 3.1
1376 _mesa_PrimitiveRestartIndex(GLuint index
)
1378 GET_CURRENT_CONTEXT(ctx
);
1380 if (!ctx
->Extensions
.NV_primitive_restart
&& ctx
->Version
< 31) {
1381 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glPrimitiveRestartIndexNV()");
1385 if (ctx
->Array
.RestartIndex
!= index
) {
1386 FLUSH_VERTICES(ctx
, _NEW_TRANSFORM
);
1387 ctx
->Array
.RestartIndex
= index
;
1393 * See GL_ARB_instanced_arrays.
1394 * Note that the instance divisor only applies to generic arrays, not
1395 * the legacy vertex arrays.
1398 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
)
1400 GET_CURRENT_CONTEXT(ctx
);
1402 const GLuint genericIndex
= VERT_ATTRIB_GENERIC(index
);
1404 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
1405 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexAttribDivisor()");
1409 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1410 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribDivisor(index = %u)",
1415 assert(genericIndex
< ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1417 /* The ARB_vertex_attrib_binding spec says:
1421 * void VertexAttribDivisor(uint index, uint divisor);
1423 * is equivalent to (assuming no errors are generated):
1425 * VertexAttribBinding(index, index);
1426 * VertexBindingDivisor(index, divisor);"
1428 vertex_attrib_binding(ctx
, genericIndex
, genericIndex
);
1429 vertex_binding_divisor(ctx
, genericIndex
, divisor
);
1434 _mesa_primitive_restart_index(const struct gl_context
*ctx
, GLenum ib_type
)
1436 /* From the OpenGL 4.3 core specification, page 302:
1437 * "If both PRIMITIVE_RESTART and PRIMITIVE_RESTART_FIXED_INDEX are
1438 * enabled, the index value determined by PRIMITIVE_RESTART_FIXED_INDEX
1441 if (ctx
->Array
.PrimitiveRestartFixedIndex
) {
1443 case GL_UNSIGNED_BYTE
:
1445 case GL_UNSIGNED_SHORT
:
1447 case GL_UNSIGNED_INT
:
1450 assert(!"_mesa_primitive_restart_index: Invalid index buffer type.");
1454 return ctx
->Array
.RestartIndex
;
1459 * GL_ARB_vertex_attrib_binding
1462 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
1465 GET_CURRENT_CONTEXT(ctx
);
1466 const struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1467 struct gl_buffer_object
*vbo
;
1469 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1471 /* The ARB_vertex_attrib_binding spec says:
1473 * "An INVALID_OPERATION error is generated if no vertex array object
1476 if (ctx
->API
== API_OPENGL_CORE
&&
1477 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1478 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1479 "glBindVertexBuffer(No array object bound)");
1483 /* The ARB_vertex_attrib_binding spec says:
1485 * "An INVALID_VALUE error is generated if <bindingindex> is greater than
1486 * the value of MAX_VERTEX_ATTRIB_BINDINGS."
1488 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
1489 _mesa_error(ctx
, GL_INVALID_VALUE
,
1490 "glBindVertexBuffer(bindingindex=%u > "
1491 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
1496 /* The ARB_vertex_attrib_binding spec says:
1498 * "The error INVALID_VALUE is generated if <stride> or <offset>
1502 _mesa_error(ctx
, GL_INVALID_VALUE
,
1503 "glBindVertexBuffer(offset=%" PRId64
" < 0)",
1509 _mesa_error(ctx
, GL_INVALID_VALUE
,
1510 "glBindVertexBuffer(stride=%d < 0)", stride
);
1514 if (ctx
->API
== API_OPENGL_CORE
&& ctx
->Version
>= 44 &&
1515 stride
> ctx
->Const
.MaxVertexAttribStride
) {
1516 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBindVertexBuffer(stride=%d > "
1517 "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride
);
1521 if (buffer
== vao
->VertexBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
->Name
) {
1522 vbo
= vao
->VertexBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
;
1523 } else if (buffer
!= 0) {
1524 vbo
= _mesa_lookup_bufferobj(ctx
, buffer
);
1526 /* From the GL_ARB_vertex_attrib_array spec:
1528 * "[Core profile only:]
1529 * An INVALID_OPERATION error is generated if buffer is not zero or a
1530 * name returned from a previous call to GenBuffers, or if such a name
1531 * has since been deleted with DeleteBuffers.
1533 * Otherwise, we fall back to the same compat profile behavior as other
1534 * object references (automatically gen it).
1536 if (!_mesa_handle_bind_buffer_gen(ctx
, GL_ARRAY_BUFFER
, buffer
,
1537 &vbo
, "glBindVertexBuffer"))
1540 /* The ARB_vertex_attrib_binding spec says:
1542 * "If <buffer> is zero, any buffer object attached to this
1543 * bindpoint is detached."
1545 vbo
= ctx
->Shared
->NullBufferObj
;
1548 bind_vertex_buffer(ctx
, VERT_ATTRIB_GENERIC(bindingIndex
),
1549 vbo
, offset
, stride
);
1554 _mesa_BindVertexBuffers(GLuint first
, GLsizei count
, const GLuint
*buffers
,
1555 const GLintptr
*offsets
, const GLsizei
*strides
)
1557 GET_CURRENT_CONTEXT(ctx
);
1558 struct gl_vertex_array_object
* const vao
= ctx
->Array
.VAO
;
1561 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1563 /* The ARB_vertex_attrib_binding spec says:
1565 * "An INVALID_OPERATION error is generated if no
1566 * vertex array object is bound."
1568 if (ctx
->API
== API_OPENGL_CORE
&&
1569 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1570 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1571 "glBindVertexBuffers(No array object bound)");
1575 /* The ARB_multi_bind spec says:
1577 * "An INVALID_OPERATION error is generated if <first> + <count>
1578 * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS."
1580 if (first
+ count
> ctx
->Const
.MaxVertexAttribBindings
) {
1581 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1582 "glBindVertexBuffers(first=%u + count=%d > the value of "
1583 "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
1584 first
, count
, ctx
->Const
.MaxVertexAttribBindings
);
1590 * The ARB_multi_bind spec says:
1592 * "If <buffers> is NULL, each affected vertex buffer binding point
1593 * from <first> through <first>+<count>-1 will be reset to have no
1594 * bound buffer object. In this case, the offsets and strides
1595 * associated with the binding points are set to default values,
1596 * ignoring <offsets> and <strides>."
1598 struct gl_buffer_object
*vbo
= ctx
->Shared
->NullBufferObj
;
1600 for (i
= 0; i
< count
; i
++)
1601 bind_vertex_buffer(ctx
, VERT_ATTRIB_GENERIC(first
+ i
), vbo
, 0, 16);
1606 /* Note that the error semantics for multi-bind commands differ from
1607 * those of other GL commands.
1609 * The Issues section in the ARB_multi_bind spec says:
1611 * "(11) Typically, OpenGL specifies that if an error is generated by
1612 * a command, that command has no effect. This is somewhat
1613 * unfortunate for multi-bind commands, because it would require
1614 * a first pass to scan the entire list of bound objects for
1615 * errors and then a second pass to actually perform the
1616 * bindings. Should we have different error semantics?
1618 * RESOLVED: Yes. In this specification, when the parameters for
1619 * one of the <count> binding points are invalid, that binding
1620 * point is not updated and an error will be generated. However,
1621 * other binding points in the same command will be updated if
1622 * their parameters are valid and no other error occurs."
1625 _mesa_begin_bufferobj_lookups(ctx
);
1627 for (i
= 0; i
< count
; i
++) {
1628 struct gl_buffer_object
*vbo
;
1630 /* The ARB_multi_bind spec says:
1632 * "An INVALID_VALUE error is generated if any value in
1633 * <offsets> or <strides> is negative (per binding)."
1635 if (offsets
[i
] < 0) {
1636 _mesa_error(ctx
, GL_INVALID_VALUE
,
1637 "glBindVertexBuffers(offsets[%u]=%" PRId64
" < 0)",
1638 i
, (int64_t) offsets
[i
]);
1642 if (strides
[i
] < 0) {
1643 _mesa_error(ctx
, GL_INVALID_VALUE
,
1644 "glBindVertexBuffers(strides[%u]=%d < 0)",
1649 if (ctx
->API
== API_OPENGL_CORE
&& ctx
->Version
>= 44 &&
1650 strides
[i
] > ctx
->Const
.MaxVertexAttribStride
) {
1651 _mesa_error(ctx
, GL_INVALID_VALUE
,
1652 "glBindVertexBuffers(strides[%u]=%d > "
1653 "GL_MAX_VERTEX_ATTRIB_STRIDE)", i
, strides
[i
]);
1658 struct gl_vertex_buffer_binding
*binding
=
1659 &vao
->VertexBinding
[VERT_ATTRIB_GENERIC(first
+ i
)];
1661 if (buffers
[i
] == binding
->BufferObj
->Name
)
1662 vbo
= binding
->BufferObj
;
1664 vbo
= _mesa_multi_bind_lookup_bufferobj(ctx
, buffers
, i
,
1665 "glBindVertexBuffers");
1670 vbo
= ctx
->Shared
->NullBufferObj
;
1673 bind_vertex_buffer(ctx
, VERT_ATTRIB_GENERIC(first
+ i
), vbo
,
1674 offsets
[i
], strides
[i
]);
1677 _mesa_end_bufferobj_lookups(ctx
);
1682 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
1683 GLboolean normalized
, GLuint relativeOffset
)
1685 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1686 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1687 INT_BIT
| UNSIGNED_INT_BIT
|
1688 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1690 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1691 INT_2_10_10_10_REV_BIT
|
1692 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
1694 GET_CURRENT_CONTEXT(ctx
);
1695 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1697 /* The ARB_vertex_attrib_binding spec says:
1699 * "An INVALID_OPERATION error is generated under any of the following
1701 * - if no vertex array object is currently bound (see section 2.10);
1704 if (ctx
->API
== API_OPENGL_CORE
&&
1705 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1706 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1707 "glVertexAttribFormat(No array object bound)");
1711 /* The ARB_vertex_attrib_binding spec says:
1713 * "The error INVALID_VALUE is generated if index is greater than or equal
1714 * to the value of MAX_VERTEX_ATTRIBS."
1716 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1717 _mesa_error(ctx
, GL_INVALID_VALUE
,
1718 "glVertexAttribFormat(attribindex=%u > "
1719 "GL_MAX_VERTEX_ATTRIBS)",
1724 FLUSH_VERTICES(ctx
, 0);
1726 update_array_format(ctx
, "glVertexAttribFormat",
1727 VERT_ATTRIB_GENERIC(attribIndex
),
1728 legalTypes
, 1, BGRA_OR_4
, size
, type
, normalized
,
1729 GL_FALSE
, GL_FALSE
, relativeOffset
);
1734 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
1735 GLuint relativeOffset
)
1737 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1738 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1739 INT_BIT
| UNSIGNED_INT_BIT
);
1741 GET_CURRENT_CONTEXT(ctx
);
1742 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1744 /* The ARB_vertex_attrib_binding spec says:
1746 * "An INVALID_OPERATION error is generated under any of the following
1748 * - if no vertex array object is currently bound (see section 2.10);
1751 if (ctx
->API
== API_OPENGL_CORE
&&
1752 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1753 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1754 "glVertexAttribIFormat(No array object bound)");
1758 /* The ARB_vertex_attrib_binding spec says:
1760 * "The error INVALID_VALUE is generated if index is greater than
1761 * or equal to the value of MAX_VERTEX_ATTRIBS."
1763 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1764 _mesa_error(ctx
, GL_INVALID_VALUE
,
1765 "glVertexAttribIFormat(attribindex=%u > "
1766 "GL_MAX_VERTEX_ATTRIBS)",
1771 FLUSH_VERTICES(ctx
, 0);
1773 update_array_format(ctx
, "glVertexAttribIFormat",
1774 VERT_ATTRIB_GENERIC(attribIndex
),
1775 legalTypes
, 1, 4, size
, type
, GL_FALSE
, GL_TRUE
, GL_FALSE
,
1781 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
1782 GLuint relativeOffset
)
1784 const GLbitfield legalTypes
= DOUBLE_BIT
;
1786 GET_CURRENT_CONTEXT(ctx
);
1787 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1789 /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
1791 * "An INVALID_OPERATION error is generated under any of the following
1793 * • if no vertex array object is currently bound (see section 10.4);
1796 * This language is missing from the extension spec, but we assume
1797 * that this is an oversight.
1799 if (ctx
->API
== API_OPENGL_CORE
&&
1800 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1801 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1802 "glVertexAttribLFormat(No array object bound)");
1806 /* The ARB_vertex_attrib_binding spec says:
1808 * "The error INVALID_VALUE is generated if <attribindex> is greater than
1809 * or equal to the value of MAX_VERTEX_ATTRIBS."
1811 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1812 _mesa_error(ctx
, GL_INVALID_VALUE
,
1813 "glVertexAttribLFormat(attribindex=%u > "
1814 "GL_MAX_VERTEX_ATTRIBS)",
1819 FLUSH_VERTICES(ctx
, 0);
1821 update_array_format(ctx
, "glVertexAttribLFormat",
1822 VERT_ATTRIB_GENERIC(attribIndex
),
1823 legalTypes
, 1, 4, size
, type
, GL_FALSE
, GL_FALSE
, GL_TRUE
,
1829 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
)
1831 GET_CURRENT_CONTEXT(ctx
);
1832 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1834 /* The ARB_vertex_attrib_binding spec says:
1836 * "An INVALID_OPERATION error is generated if no vertex array object
1839 if (ctx
->API
== API_OPENGL_CORE
&&
1840 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1841 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1842 "glVertexAttribBinding(No array object bound)");
1846 /* The ARB_vertex_attrib_binding spec says:
1848 * "<attribindex> must be less than the value of MAX_VERTEX_ATTRIBS and
1849 * <bindingindex> must be less than the value of
1850 * MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
1853 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1854 _mesa_error(ctx
, GL_INVALID_VALUE
,
1855 "glVertexAttribBinding(attribindex=%u >= "
1856 "GL_MAX_VERTEX_ATTRIBS)",
1861 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
1862 _mesa_error(ctx
, GL_INVALID_VALUE
,
1863 "glVertexAttribBinding(bindingindex=%u >= "
1864 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
1869 assert(VERT_ATTRIB_GENERIC(attribIndex
) <
1870 ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1872 vertex_attrib_binding(ctx
, VERT_ATTRIB_GENERIC(attribIndex
),
1873 VERT_ATTRIB_GENERIC(bindingIndex
));
1878 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
)
1880 GET_CURRENT_CONTEXT(ctx
);
1881 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1883 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
1884 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexBindingDivisor()");
1888 /* The ARB_vertex_attrib_binding spec says:
1890 * "An INVALID_OPERATION error is generated if no vertex array object
1893 if (ctx
->API
== API_OPENGL_CORE
&&
1894 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
1895 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1896 "glVertexBindingDivisor(No array object bound)");
1900 /* The ARB_vertex_attrib_binding spec says:
1902 * "An INVALID_VALUE error is generated if <bindingindex> is greater
1903 * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS."
1905 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
1906 _mesa_error(ctx
, GL_INVALID_VALUE
,
1907 "glVertexBindingDivisor(bindingindex=%u > "
1908 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
1913 vertex_binding_divisor(ctx
, VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
1918 * Copy one client vertex array to another.
1921 _mesa_copy_client_array(struct gl_context
*ctx
,
1922 struct gl_client_array
*dst
,
1923 struct gl_client_array
*src
)
1925 dst
->Size
= src
->Size
;
1926 dst
->Type
= src
->Type
;
1927 dst
->Format
= src
->Format
;
1928 dst
->Stride
= src
->Stride
;
1929 dst
->StrideB
= src
->StrideB
;
1930 dst
->Ptr
= src
->Ptr
;
1931 dst
->Enabled
= src
->Enabled
;
1932 dst
->Normalized
= src
->Normalized
;
1933 dst
->Integer
= src
->Integer
;
1934 dst
->Doubles
= src
->Doubles
;
1935 dst
->InstanceDivisor
= src
->InstanceDivisor
;
1936 dst
->_ElementSize
= src
->_ElementSize
;
1937 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, src
->BufferObj
);
1941 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
1942 struct gl_vertex_attrib_array
*dst
,
1943 const struct gl_vertex_attrib_array
*src
)
1945 dst
->Size
= src
->Size
;
1946 dst
->Type
= src
->Type
;
1947 dst
->Format
= src
->Format
;
1948 dst
->VertexBinding
= src
->VertexBinding
;
1949 dst
->RelativeOffset
= src
->RelativeOffset
;
1950 dst
->Format
= src
->Format
;
1951 dst
->Integer
= src
->Integer
;
1952 dst
->Doubles
= src
->Doubles
;
1953 dst
->Normalized
= src
->Normalized
;
1954 dst
->Ptr
= src
->Ptr
;
1955 dst
->Enabled
= src
->Enabled
;
1956 dst
->_ElementSize
= src
->_ElementSize
;
1960 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
1961 struct gl_vertex_buffer_binding
*dst
,
1962 const struct gl_vertex_buffer_binding
*src
)
1964 dst
->Offset
= src
->Offset
;
1965 dst
->Stride
= src
->Stride
;
1966 dst
->InstanceDivisor
= src
->InstanceDivisor
;
1967 dst
->_BoundArrays
= src
->_BoundArrays
;
1969 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, src
->BufferObj
);
1973 * Print vertex array's fields.
1976 print_array(const char *name
, GLint index
, const struct gl_client_array
*array
)
1979 fprintf(stderr
, " %s[%d]: ", name
, index
);
1981 fprintf(stderr
, " %s: ", name
);
1982 fprintf(stderr
, "Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %lu)\n",
1983 array
->Ptr
, array
->Type
, array
->Size
,
1984 array
->_ElementSize
, array
->StrideB
,
1985 array
->BufferObj
->Name
, (unsigned long) array
->BufferObj
->Size
);
1990 * Print current vertex object/array info. For debug.
1993 _mesa_print_arrays(struct gl_context
*ctx
)
1995 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1998 printf("Array Object %u\n", vao
->Name
);
1999 if (vao
->_VertexAttrib
[VERT_ATTRIB_POS
].Enabled
)
2000 print_array("Vertex", -1, &vao
->_VertexAttrib
[VERT_ATTRIB_POS
]);
2001 if (vao
->_VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
)
2002 print_array("Normal", -1, &vao
->_VertexAttrib
[VERT_ATTRIB_NORMAL
]);
2003 if (vao
->_VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
)
2004 print_array("Color", -1, &vao
->_VertexAttrib
[VERT_ATTRIB_COLOR0
]);
2005 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++)
2006 if (vao
->_VertexAttrib
[VERT_ATTRIB_TEX(i
)].Enabled
)
2007 print_array("TexCoord", i
, &vao
->_VertexAttrib
[VERT_ATTRIB_TEX(i
)]);
2008 for (i
= 0; i
< VERT_ATTRIB_GENERIC_MAX
; i
++)
2009 if (vao
->_VertexAttrib
[VERT_ATTRIB_GENERIC(i
)].Enabled
)
2010 print_array("Attrib", i
, &vao
->_VertexAttrib
[VERT_ATTRIB_GENERIC(i
)]);
2015 * Initialize vertex array state for given context.
2018 _mesa_init_varray(struct gl_context
*ctx
)
2020 ctx
->Array
.DefaultVAO
= ctx
->Driver
.NewArrayObject(ctx
, 0);
2021 _mesa_reference_vao(ctx
, &ctx
->Array
.VAO
, ctx
->Array
.DefaultVAO
);
2022 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */
2024 ctx
->Array
.Objects
= _mesa_NewHashTable();
2029 * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
2032 delete_arrayobj_cb(GLuint id
, void *data
, void *userData
)
2034 struct gl_vertex_array_object
*vao
= (struct gl_vertex_array_object
*) data
;
2035 struct gl_context
*ctx
= (struct gl_context
*) userData
;
2036 _mesa_delete_vao(ctx
, vao
);
2041 * Free vertex array state for given context.
2044 _mesa_free_varray_data(struct gl_context
*ctx
)
2046 _mesa_HashDeleteAll(ctx
->Array
.Objects
, delete_arrayobj_cb
, ctx
);
2047 _mesa_DeleteHashTable(ctx
->Array
.Objects
);