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"
36 #include "glformats.h"
43 #include "main/dispatch.h"
46 /** Used to do error checking for GL_EXT_vertex_array_bgra */
50 /** Used to indicate which GL datatypes are accepted by each of the
51 * glVertex/Color/Attrib/EtcPointer() functions.
53 #define BOOL_BIT (1 << 0)
54 #define BYTE_BIT (1 << 1)
55 #define UNSIGNED_BYTE_BIT (1 << 2)
56 #define SHORT_BIT (1 << 3)
57 #define UNSIGNED_SHORT_BIT (1 << 4)
58 #define INT_BIT (1 << 5)
59 #define UNSIGNED_INT_BIT (1 << 6)
60 #define HALF_BIT (1 << 7)
61 #define FLOAT_BIT (1 << 8)
62 #define DOUBLE_BIT (1 << 9)
63 #define FIXED_ES_BIT (1 << 10)
64 #define FIXED_GL_BIT (1 << 11)
65 #define UNSIGNED_INT_2_10_10_10_REV_BIT (1 << 12)
66 #define INT_2_10_10_10_REV_BIT (1 << 13)
67 #define UNSIGNED_INT_10F_11F_11F_REV_BIT (1 << 14)
68 #define ALL_TYPE_BITS ((1 << 15) - 1)
70 #define ATTRIB_FORMAT_TYPES_MASK (BYTE_BIT | UNSIGNED_BYTE_BIT | \
71 SHORT_BIT | UNSIGNED_SHORT_BIT | \
72 INT_BIT | UNSIGNED_INT_BIT | \
73 HALF_BIT | FLOAT_BIT | DOUBLE_BIT | \
75 UNSIGNED_INT_2_10_10_10_REV_BIT | \
76 INT_2_10_10_10_REV_BIT | \
77 UNSIGNED_INT_10F_11F_11F_REV_BIT)
79 #define ATTRIB_IFORMAT_TYPES_MASK (BYTE_BIT | UNSIGNED_BYTE_BIT | \
80 SHORT_BIT | UNSIGNED_SHORT_BIT | \
81 INT_BIT | UNSIGNED_INT_BIT)
83 #define ATTRIB_LFORMAT_TYPES_MASK DOUBLE_BIT
86 /** Convert GL datatype enum into a <type>_BIT value seen above */
88 type_to_bit(const struct gl_context
*ctx
, GLenum type
)
95 case GL_UNSIGNED_BYTE
:
96 return UNSIGNED_BYTE_BIT
;
99 case GL_UNSIGNED_SHORT
:
100 return UNSIGNED_SHORT_BIT
;
103 case GL_UNSIGNED_INT
:
104 return UNSIGNED_INT_BIT
;
106 case GL_HALF_FLOAT_OES
:
107 if (ctx
->Extensions
.ARB_half_float_vertex
)
116 return _mesa_is_desktop_gl(ctx
) ? FIXED_GL_BIT
: FIXED_ES_BIT
;
117 case GL_UNSIGNED_INT_2_10_10_10_REV
:
118 return UNSIGNED_INT_2_10_10_10_REV_BIT
;
119 case GL_INT_2_10_10_10_REV
:
120 return INT_2_10_10_10_REV_BIT
;
121 case GL_UNSIGNED_INT_10F_11F_11F_REV
:
122 return UNSIGNED_INT_10F_11F_11F_REV_BIT
;
130 * Depending on the position and generic0 attributes enable flags select
131 * the one that is used for both attributes.
132 * The generic0 attribute takes precedence.
135 update_attribute_map_mode(const struct gl_context
*ctx
,
136 struct gl_vertex_array_object
*vao
)
139 * There is no need to change the mapping away from the
140 * identity mapping if we are not in compat mode.
142 if (ctx
->API
!= API_OPENGL_COMPAT
)
144 /* The generic0 attribute superseeds the position attribute */
145 const GLbitfield enabled
= vao
->Enabled
;
146 if (enabled
& VERT_BIT_GENERIC0
)
147 vao
->_AttributeMapMode
= ATTRIBUTE_MAP_MODE_GENERIC0
;
148 else if (enabled
& VERT_BIT_POS
)
149 vao
->_AttributeMapMode
= ATTRIBUTE_MAP_MODE_POSITION
;
151 vao
->_AttributeMapMode
= ATTRIBUTE_MAP_MODE_IDENTITY
;
156 * Sets the BufferBindingIndex field for the vertex attribute given by
160 _mesa_vertex_attrib_binding(struct gl_context
*ctx
,
161 struct gl_vertex_array_object
*vao
,
162 gl_vert_attrib attribIndex
,
165 struct gl_array_attributes
*array
= &vao
->VertexAttrib
[attribIndex
];
166 assert(!vao
->SharedAndImmutable
);
168 if (array
->BufferBindingIndex
!= bindingIndex
) {
169 const GLbitfield array_bit
= VERT_BIT(attribIndex
);
171 if (_mesa_is_bufferobj(vao
->BufferBinding
[bindingIndex
].BufferObj
))
172 vao
->VertexAttribBufferMask
|= array_bit
;
174 vao
->VertexAttribBufferMask
&= ~array_bit
;
176 vao
->BufferBinding
[array
->BufferBindingIndex
]._BoundArrays
&= ~array_bit
;
177 vao
->BufferBinding
[bindingIndex
]._BoundArrays
|= array_bit
;
179 array
->BufferBindingIndex
= bindingIndex
;
181 vao
->NewArrays
|= vao
->Enabled
& array_bit
;
187 * Binds a buffer object to the vertex buffer binding point given by index,
188 * and sets the Offset and Stride fields.
191 _mesa_bind_vertex_buffer(struct gl_context
*ctx
,
192 struct gl_vertex_array_object
*vao
,
194 struct gl_buffer_object
*vbo
,
195 GLintptr offset
, GLsizei stride
)
197 assert(index
< ARRAY_SIZE(vao
->BufferBinding
));
198 assert(!vao
->SharedAndImmutable
);
199 struct gl_vertex_buffer_binding
*binding
= &vao
->BufferBinding
[index
];
201 if (binding
->BufferObj
!= vbo
||
202 binding
->Offset
!= offset
||
203 binding
->Stride
!= stride
) {
205 _mesa_reference_buffer_object(ctx
, &binding
->BufferObj
, vbo
);
207 binding
->Offset
= offset
;
208 binding
->Stride
= stride
;
210 if (!_mesa_is_bufferobj(vbo
)) {
211 vao
->VertexAttribBufferMask
&= ~binding
->_BoundArrays
;
213 vao
->VertexAttribBufferMask
|= binding
->_BoundArrays
;
214 vbo
->UsageHistory
|= USAGE_ARRAY_BUFFER
;
217 vao
->NewArrays
|= vao
->Enabled
& binding
->_BoundArrays
;
223 * Sets the InstanceDivisor field in the vertex buffer binding point
224 * given by bindingIndex.
227 vertex_binding_divisor(struct gl_context
*ctx
,
228 struct gl_vertex_array_object
*vao
,
232 struct gl_vertex_buffer_binding
*binding
=
233 &vao
->BufferBinding
[bindingIndex
];
234 assert(!vao
->SharedAndImmutable
);
236 if (binding
->InstanceDivisor
!= divisor
) {
237 binding
->InstanceDivisor
= divisor
;
238 vao
->NewArrays
|= vao
->Enabled
& binding
->_BoundArrays
;
244 _mesa_set_vertex_format(struct gl_vertex_format
*vertex_format
,
245 GLubyte size
, GLenum16 type
, GLenum16 format
,
246 GLboolean normalized
, GLboolean integer
,
250 vertex_format
->Type
= type
;
251 vertex_format
->Format
= format
;
252 vertex_format
->Size
= size
;
253 vertex_format
->Normalized
= normalized
;
254 vertex_format
->Integer
= integer
;
255 vertex_format
->Doubles
= doubles
;
256 vertex_format
->_ElementSize
= _mesa_bytes_per_vertex_attrib(size
, type
);
257 assert(vertex_format
->_ElementSize
<= 4*sizeof(double));
262 * Examine the API profile and extensions to determine which types are legal
263 * for vertex arrays. This is called once from update_array_format().
266 get_legal_types_mask(const struct gl_context
*ctx
)
268 GLbitfield legalTypesMask
= ALL_TYPE_BITS
;
270 if (_mesa_is_gles(ctx
)) {
271 legalTypesMask
&= ~(FIXED_GL_BIT
|
273 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
275 /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until
276 * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or
277 * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed
278 * until 3.0 or with the GL_OES_vertex_half float extension, which isn't
279 * quite as trivial as we'd like because it uses a different enum value
280 * for GL_HALF_FLOAT_OES.
282 if (ctx
->Version
< 30) {
283 legalTypesMask
&= ~(UNSIGNED_INT_BIT
|
285 UNSIGNED_INT_2_10_10_10_REV_BIT
|
286 INT_2_10_10_10_REV_BIT
);
288 if (!_mesa_has_OES_vertex_half_float(ctx
))
289 legalTypesMask
&= ~HALF_BIT
;
293 legalTypesMask
&= ~FIXED_ES_BIT
;
295 if (!ctx
->Extensions
.ARB_ES2_compatibility
)
296 legalTypesMask
&= ~FIXED_GL_BIT
;
298 if (!ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
)
299 legalTypesMask
&= ~(UNSIGNED_INT_2_10_10_10_REV_BIT
|
300 INT_2_10_10_10_REV_BIT
);
302 if (!ctx
->Extensions
.ARB_vertex_type_10f_11f_11f_rev
)
303 legalTypesMask
&= ~UNSIGNED_INT_10F_11F_11F_REV_BIT
;
306 return legalTypesMask
;
310 get_array_format(const struct gl_context
*ctx
, GLint sizeMax
, GLint
*size
)
312 GLenum format
= GL_RGBA
;
314 /* Do size parameter checking.
315 * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and
316 * must be handled specially.
318 if (ctx
->Extensions
.EXT_vertex_array_bgra
&& sizeMax
== BGRA_OR_4
&&
329 * \param attrib The index of the attribute array
330 * \param size Components per element (1, 2, 3 or 4)
331 * \param type Datatype of each component (GL_FLOAT, GL_INT, etc)
332 * \param format Either GL_RGBA or GL_BGRA.
333 * \param normalized Whether integer types are converted to floats in [-1, 1]
334 * \param integer Integer-valued values (will not be normalized to [-1, 1])
335 * \param doubles Double values not reduced to floats
336 * \param relativeOffset Offset of the first element relative to the binding
340 _mesa_update_array_format(struct gl_context
*ctx
,
341 struct gl_vertex_array_object
*vao
,
342 gl_vert_attrib attrib
, GLint size
, GLenum type
,
343 GLenum format
, GLboolean normalized
,
344 GLboolean integer
, GLboolean doubles
,
345 GLuint relativeOffset
)
347 struct gl_array_attributes
*const array
= &vao
->VertexAttrib
[attrib
];
349 assert(!vao
->SharedAndImmutable
);
352 array
->RelativeOffset
= relativeOffset
;
353 _mesa_set_vertex_format(&array
->Format
, size
, type
, format
,
354 normalized
, integer
, doubles
);
356 vao
->NewArrays
|= vao
->Enabled
& VERT_BIT(attrib
);
360 * Does error checking of the format in an attrib array.
362 * Called by *Pointer() and VertexAttrib*Format().
364 * \param func Name of calling function used for error reporting
365 * \param attrib The index of the attribute array
366 * \param legalTypes Bitmask of *_BIT above indicating legal datatypes
367 * \param sizeMin Min allowable size value
368 * \param sizeMax Max allowable size value (may also be BGRA_OR_4)
369 * \param size Components per element (1, 2, 3 or 4)
370 * \param type Datatype of each component (GL_FLOAT, GL_INT, etc)
371 * \param normalized Whether integer types are converted to floats in [-1, 1]
372 * \param integer Integer-valued values (will not be normalized to [-1, 1])
373 * \param doubles Double values not reduced to floats
374 * \param relativeOffset Offset of the first element relative to the binding offset.
375 * \return bool True if validation is successful, False otherwise.
378 validate_array_format(struct gl_context
*ctx
, const char *func
,
379 struct gl_vertex_array_object
*vao
,
380 GLuint attrib
, GLbitfield legalTypesMask
,
381 GLint sizeMin
, GLint sizeMax
,
382 GLint size
, GLenum type
, GLboolean normalized
,
383 GLboolean integer
, GLboolean doubles
,
384 GLuint relativeOffset
, GLenum format
)
388 /* at most, one of these bools can be true */
389 assert((int) normalized
+ (int) integer
+ (int) doubles
<= 1);
391 if (ctx
->Array
.LegalTypesMask
== 0 || ctx
->Array
.LegalTypesMaskAPI
!= ctx
->API
) {
392 /* Compute the LegalTypesMask only once, unless the context API has
393 * changed, in which case we want to compute it again. We can't do this
394 * in _mesa_init_varrays() below because extensions are not yet enabled
397 ctx
->Array
.LegalTypesMask
= get_legal_types_mask(ctx
);
398 ctx
->Array
.LegalTypesMaskAPI
= ctx
->API
;
401 legalTypesMask
&= ctx
->Array
.LegalTypesMask
;
403 if (_mesa_is_gles(ctx
) && sizeMax
== BGRA_OR_4
) {
404 /* BGRA ordering is not supported in ES contexts.
409 typeBit
= type_to_bit(ctx
, type
);
410 if (typeBit
== 0x0 || (typeBit
& legalTypesMask
) == 0x0) {
411 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)",
412 func
, _mesa_enum_to_string(type
));
416 if (format
== GL_BGRA
) {
417 /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
419 * "An INVALID_OPERATION error is generated under any of the following
422 * • size is BGRA and type is not UNSIGNED_BYTE, INT_2_10_10_10_REV
423 * or UNSIGNED_INT_2_10_10_10_REV;
425 * • size is BGRA and normalized is FALSE;"
427 bool bgra_error
= false;
429 if (ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
) {
430 if (type
!= GL_UNSIGNED_INT_2_10_10_10_REV
&&
431 type
!= GL_INT_2_10_10_10_REV
&&
432 type
!= GL_UNSIGNED_BYTE
)
434 } else if (type
!= GL_UNSIGNED_BYTE
)
438 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=GL_BGRA and type=%s)",
439 func
, _mesa_enum_to_string(type
));
444 _mesa_error(ctx
, GL_INVALID_OPERATION
,
445 "%s(size=GL_BGRA and normalized=GL_FALSE)", func
);
449 else if (size
< sizeMin
|| size
> sizeMax
|| size
> 4) {
450 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(size=%d)", func
, size
);
454 if (ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
&&
455 (type
== GL_UNSIGNED_INT_2_10_10_10_REV
||
456 type
== GL_INT_2_10_10_10_REV
) && size
!= 4) {
457 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=%d)", func
, size
);
461 /* The ARB_vertex_attrib_binding_spec says:
463 * An INVALID_VALUE error is generated if <relativeoffset> is larger than
464 * the value of MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.
466 if (relativeOffset
> ctx
->Const
.MaxVertexAttribRelativeOffset
) {
467 _mesa_error(ctx
, GL_INVALID_VALUE
,
468 "%s(relativeOffset=%d > "
469 "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)",
470 func
, relativeOffset
);
474 if (ctx
->Extensions
.ARB_vertex_type_10f_11f_11f_rev
&&
475 type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&& size
!= 3) {
476 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=%d)", func
, size
);
484 * Do error checking for glVertex/Color/TexCoord/...Pointer functions.
486 * \param func name of calling function used for error reporting
487 * \param vao the vao to update
488 * \param obj the bound buffer object
489 * \param attrib the attribute array index to update
490 * \param legalTypes bitmask of *_BIT above indicating legal datatypes
491 * \param sizeMin min allowable size value
492 * \param sizeMax max allowable size value (may also be BGRA_OR_4)
493 * \param size components per element (1, 2, 3 or 4)
494 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
495 * \param stride stride between elements, in elements
496 * \param normalized are integer types converted to floats in [-1, 1]?
497 * \param integer integer-valued values (will not be normalized to [-1,1])
498 * \param doubles Double values not reduced to floats
499 * \param ptr the address (or offset inside VBO) of the array data
502 validate_array(struct gl_context
*ctx
, const char *func
,
503 struct gl_vertex_array_object
*vao
,
504 struct gl_buffer_object
*obj
,
505 GLuint attrib
, GLbitfield legalTypesMask
,
506 GLint sizeMin
, GLint sizeMax
,
507 GLint size
, GLenum type
, GLsizei stride
,
508 GLboolean normalized
, GLboolean integer
, GLboolean doubles
,
511 /* Page 407 (page 423 of the PDF) of the OpenGL 3.0 spec says:
513 * "Client vertex arrays - all vertex array attribute pointers must
514 * refer to buffer objects (section 2.9.2). The default vertex array
515 * object (the name zero) is also deprecated. Calling
516 * VertexAttribPointer when no buffer object or no vertex array object
517 * is bound will generate an INVALID_OPERATION error..."
519 * The check for VBOs is handled below.
521 if (ctx
->API
== API_OPENGL_CORE
&& (vao
== ctx
->Array
.DefaultVAO
)) {
522 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no array object bound)",
528 _mesa_error( ctx
, GL_INVALID_VALUE
, "%s(stride=%d)", func
, stride
);
532 if (_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 44 &&
533 stride
> ctx
->Const
.MaxVertexAttribStride
) {
534 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride=%d > "
535 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, stride
);
539 /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says:
541 * "An INVALID_OPERATION error is generated under any of the following
546 * * any of the *Pointer commands specifying the location and
547 * organization of vertex array data are called while zero is bound
548 * to the ARRAY_BUFFER buffer object binding point (see section
549 * 2.9.6), and the pointer argument is not NULL."
551 if (ptr
!= NULL
&& vao
!= ctx
->Array
.DefaultVAO
&&
552 !_mesa_is_bufferobj(obj
)) {
553 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(non-VBO array)", func
);
560 validate_array_and_format(struct gl_context
*ctx
, const char *func
,
561 struct gl_vertex_array_object
*vao
,
562 struct gl_buffer_object
*obj
,
563 GLuint attrib
, GLbitfield legalTypes
,
564 GLint sizeMin
, GLint sizeMax
,
565 GLint size
, GLenum type
, GLsizei stride
,
566 GLboolean normalized
, GLboolean integer
,
567 GLboolean doubles
, GLenum format
, const GLvoid
*ptr
)
569 validate_array(ctx
, func
, vao
, obj
, attrib
, legalTypes
, sizeMin
, sizeMax
,
570 size
, type
, stride
, normalized
, integer
, doubles
, ptr
);
572 return validate_array_format(ctx
, func
, vao
, attrib
, legalTypes
, sizeMin
,
573 sizeMax
, size
, type
, normalized
, integer
,
579 * Update state for glVertex/Color/TexCoord/...Pointer functions.
581 * \param vao the vao to update
582 * \param obj the bound buffer object
583 * \param attrib the attribute array index to update
584 * \param format Either GL_RGBA or GL_BGRA.
585 * \param sizeMax max allowable size value (may also be BGRA_OR_4)
586 * \param size components per element (1, 2, 3 or 4)
587 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
588 * \param stride stride between elements, in elements
589 * \param normalized are integer types converted to floats in [-1, 1]?
590 * \param integer integer-valued values (will not be normalized to [-1,1])
591 * \param doubles Double values not reduced to floats
592 * \param ptr the address (or offset inside VBO) of the array data
595 update_array(struct gl_context
*ctx
,
596 struct gl_vertex_array_object
*vao
,
597 struct gl_buffer_object
*obj
,
598 GLuint attrib
, GLenum format
,
600 GLint size
, GLenum type
, GLsizei stride
,
601 GLboolean normalized
, GLboolean integer
, GLboolean doubles
,
604 _mesa_update_array_format(ctx
, vao
, attrib
, size
, type
, format
,
605 normalized
, integer
, doubles
, 0);
607 /* Reset the vertex attrib binding */
608 _mesa_vertex_attrib_binding(ctx
, vao
, attrib
, attrib
);
610 /* The Stride and Ptr fields are not set by update_array_format() */
611 struct gl_array_attributes
*array
= &vao
->VertexAttrib
[attrib
];
612 array
->Stride
= stride
;
613 /* For updating the pointer we would need to add the vao->NewArrays flag
614 * to the VAO. But but that is done already unconditionally in
615 * _mesa_update_array_format called above.
617 assert((vao
->NewArrays
| ~vao
->Enabled
) & VERT_BIT(attrib
));
620 /* Update the vertex buffer binding */
621 GLsizei effectiveStride
= stride
!= 0 ?
622 stride
: array
->Format
._ElementSize
;
623 _mesa_bind_vertex_buffer(ctx
, vao
, attrib
,
629 /* Helper function for all EXT_direct_state_access glVertexArray* functions */
631 _lookup_vao_and_vbo_dsa(struct gl_context
*ctx
,
632 GLuint vaobj
, GLuint buffer
,
634 struct gl_vertex_array_object
** vao
,
635 struct gl_buffer_object
** vbo
,
638 *vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true, caller
);
643 *vbo
= _mesa_lookup_bufferobj(ctx
, buffer
);
644 if (!_mesa_handle_bind_buffer_gen(ctx
, buffer
, vbo
, caller
))
648 _mesa_error(ctx
, GL_INVALID_VALUE
,
649 "%s(negative offset with non-0 buffer)", caller
);
653 *vbo
= ctx
->Shared
->NullBufferObj
;
661 _mesa_VertexPointer_no_error(GLint size
, GLenum type
, GLsizei stride
,
664 GET_CURRENT_CONTEXT(ctx
);
666 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
667 VERT_ATTRIB_POS
, GL_RGBA
, 4, size
, type
, stride
,
668 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
673 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
675 GET_CURRENT_CONTEXT(ctx
);
677 GLenum format
= GL_RGBA
;
678 GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
679 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
680 : (SHORT_BIT
| INT_BIT
| FLOAT_BIT
|
681 DOUBLE_BIT
| HALF_BIT
|
682 UNSIGNED_INT_2_10_10_10_REV_BIT
|
683 INT_2_10_10_10_REV_BIT
);
685 if (!validate_array_and_format(ctx
, "glVertexPointer",
686 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
687 VERT_ATTRIB_POS
, legalTypes
, 2, 4, size
,
688 type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
,
692 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
693 VERT_ATTRIB_POS
, format
, 4, size
, type
, stride
,
694 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
699 _mesa_VertexArrayVertexOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
700 GLenum type
, GLsizei stride
, GLintptr offset
)
702 GET_CURRENT_CONTEXT(ctx
);
704 GLenum format
= GL_RGBA
;
705 GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
706 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
707 : (SHORT_BIT
| INT_BIT
| FLOAT_BIT
|
708 DOUBLE_BIT
| HALF_BIT
|
709 UNSIGNED_INT_2_10_10_10_REV_BIT
|
710 INT_2_10_10_10_REV_BIT
);
712 struct gl_vertex_array_object
* vao
;
713 struct gl_buffer_object
* vbo
;
715 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
717 "glVertexArrayVertexOffsetEXT"))
720 if (!validate_array_and_format(ctx
, "glVertexArrayVertexOffsetEXT",
722 VERT_ATTRIB_POS
, legalTypes
, 2, 4, size
,
723 type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
,
724 format
, (void*) offset
))
727 update_array(ctx
, vao
, vbo
,
728 VERT_ATTRIB_POS
, format
, 4, size
, type
, stride
,
729 GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
734 _mesa_NormalPointer_no_error(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
736 GET_CURRENT_CONTEXT(ctx
);
738 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
739 VERT_ATTRIB_NORMAL
, GL_RGBA
, 3, 3, type
, stride
, GL_TRUE
,
740 GL_FALSE
, GL_FALSE
, ptr
);
745 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
747 GET_CURRENT_CONTEXT(ctx
);
749 GLenum format
= GL_RGBA
;
750 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
751 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
752 : (BYTE_BIT
| SHORT_BIT
| INT_BIT
|
753 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
754 UNSIGNED_INT_2_10_10_10_REV_BIT
|
755 INT_2_10_10_10_REV_BIT
);
757 if (!validate_array_and_format(ctx
, "glNormalPointer",
758 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
759 VERT_ATTRIB_NORMAL
, legalTypes
, 3, 3, 3,
760 type
, stride
, GL_TRUE
, GL_FALSE
,
761 GL_FALSE
, format
, ptr
))
764 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
765 VERT_ATTRIB_NORMAL
, format
, 3, 3, type
, stride
, GL_TRUE
,
766 GL_FALSE
, GL_FALSE
, ptr
);
771 _mesa_VertexArrayNormalOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum type
,
772 GLsizei stride
, GLintptr offset
)
774 GET_CURRENT_CONTEXT(ctx
);
776 GLenum format
= GL_RGBA
;
777 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
778 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
779 : (BYTE_BIT
| SHORT_BIT
| INT_BIT
|
780 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
781 UNSIGNED_INT_2_10_10_10_REV_BIT
|
782 INT_2_10_10_10_REV_BIT
);
784 struct gl_vertex_array_object
* vao
;
785 struct gl_buffer_object
* vbo
;
787 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
792 if (!validate_array_and_format(ctx
, "glNormalPointer",
794 VERT_ATTRIB_NORMAL
, legalTypes
, 3, 3, 3,
795 type
, stride
, GL_TRUE
, GL_FALSE
,
796 GL_FALSE
, format
, (void*) offset
))
799 update_array(ctx
, vao
, vbo
,
800 VERT_ATTRIB_NORMAL
, format
, 3, 3, type
, stride
, GL_TRUE
,
801 GL_FALSE
, GL_FALSE
, (void*) offset
);
806 _mesa_ColorPointer_no_error(GLint size
, GLenum type
, GLsizei stride
,
809 GET_CURRENT_CONTEXT(ctx
);
811 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
812 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
813 VERT_ATTRIB_COLOR0
, format
, BGRA_OR_4
, size
,
814 type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
819 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
821 GET_CURRENT_CONTEXT(ctx
);
822 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 4 : 3;
824 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
825 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
826 ? (UNSIGNED_BYTE_BIT
| HALF_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
827 : (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
828 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
829 INT_BIT
| UNSIGNED_INT_BIT
|
830 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
831 UNSIGNED_INT_2_10_10_10_REV_BIT
|
832 INT_2_10_10_10_REV_BIT
);
834 if (!validate_array_and_format(ctx
, "glColorPointer",
835 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
836 VERT_ATTRIB_COLOR0
, legalTypes
, sizeMin
,
837 BGRA_OR_4
, size
, type
, stride
, GL_TRUE
,
838 GL_FALSE
, GL_FALSE
, format
, ptr
))
841 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
842 VERT_ATTRIB_COLOR0
, format
, BGRA_OR_4
, size
,
843 type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
848 _mesa_VertexArrayColorOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
849 GLenum type
, GLsizei stride
, GLintptr offset
)
851 GET_CURRENT_CONTEXT(ctx
);
852 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 4 : 3;
854 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
855 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
856 ? (UNSIGNED_BYTE_BIT
| HALF_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
857 : (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
858 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
859 INT_BIT
| UNSIGNED_INT_BIT
|
860 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
861 UNSIGNED_INT_2_10_10_10_REV_BIT
|
862 INT_2_10_10_10_REV_BIT
);
864 struct gl_vertex_array_object
* vao
;
865 struct gl_buffer_object
* vbo
;
867 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
869 "glVertexArrayColorOffsetEXT"))
872 if (!validate_array_and_format(ctx
, "glVertexArrayColorOffsetEXT",
874 VERT_ATTRIB_COLOR0
, legalTypes
, sizeMin
,
875 BGRA_OR_4
, size
, type
, stride
, GL_TRUE
,
876 GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
879 update_array(ctx
, vao
, vbo
,
880 VERT_ATTRIB_COLOR0
, format
, BGRA_OR_4
, size
,
881 type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
886 _mesa_FogCoordPointer_no_error(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
888 GET_CURRENT_CONTEXT(ctx
);
890 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
891 VERT_ATTRIB_FOG
, GL_RGBA
, 1, 1, type
, stride
, GL_FALSE
,
892 GL_FALSE
, GL_FALSE
, ptr
);
897 _mesa_FogCoordPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
899 GET_CURRENT_CONTEXT(ctx
);
901 GLenum format
= GL_RGBA
;
902 const GLbitfield legalTypes
= (HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
);
904 if (!validate_array_and_format(ctx
, "glFogCoordPointer",
905 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
906 VERT_ATTRIB_FOG
, legalTypes
, 1, 1, 1,
907 type
, stride
, GL_FALSE
, GL_FALSE
,
908 GL_FALSE
, format
, ptr
))
911 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
912 VERT_ATTRIB_FOG
, format
, 1, 1, type
, stride
, GL_FALSE
,
913 GL_FALSE
, GL_FALSE
, ptr
);
918 _mesa_VertexArrayFogCoordOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum type
,
919 GLsizei stride
, GLintptr offset
)
921 GET_CURRENT_CONTEXT(ctx
);
923 GLenum format
= GL_RGBA
;
924 const GLbitfield legalTypes
= (HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
);
926 struct gl_vertex_array_object
* vao
;
927 struct gl_buffer_object
* vbo
;
929 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
931 "glVertexArrayFogCoordOffsetEXT"))
934 if (!validate_array_and_format(ctx
, "glVertexArrayFogCoordOffsetEXT",
936 VERT_ATTRIB_FOG
, legalTypes
, 1, 1, 1,
937 type
, stride
, GL_FALSE
, GL_FALSE
,
938 GL_FALSE
, format
, (void*) offset
))
941 update_array(ctx
, vao
, vbo
,
942 VERT_ATTRIB_FOG
, format
, 1, 1, type
, stride
, GL_FALSE
,
943 GL_FALSE
, GL_FALSE
, (void*) offset
);
948 _mesa_IndexPointer_no_error(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
950 GET_CURRENT_CONTEXT(ctx
);
952 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
953 VERT_ATTRIB_COLOR_INDEX
, GL_RGBA
, 1, 1, type
, stride
,
954 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
959 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
961 GET_CURRENT_CONTEXT(ctx
);
963 GLenum format
= GL_RGBA
;
964 const GLbitfield legalTypes
= (UNSIGNED_BYTE_BIT
| SHORT_BIT
| INT_BIT
|
965 FLOAT_BIT
| DOUBLE_BIT
);
967 if (!validate_array_and_format(ctx
, "glIndexPointer",
968 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
969 VERT_ATTRIB_COLOR_INDEX
,
970 legalTypes
, 1, 1, 1, type
, stride
,
971 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
974 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
975 VERT_ATTRIB_COLOR_INDEX
, format
, 1, 1, type
, stride
,
976 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
981 _mesa_VertexArrayIndexOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum type
,
982 GLsizei stride
, GLintptr offset
)
984 GET_CURRENT_CONTEXT(ctx
);
986 GLenum format
= GL_RGBA
;
987 const GLbitfield legalTypes
= (UNSIGNED_BYTE_BIT
| SHORT_BIT
| INT_BIT
|
988 FLOAT_BIT
| DOUBLE_BIT
);
990 struct gl_vertex_array_object
* vao
;
991 struct gl_buffer_object
* vbo
;
993 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
995 "glVertexArrayIndexOffsetEXT"))
998 if (!validate_array_and_format(ctx
, "glVertexArrayIndexOffsetEXT",
1000 VERT_ATTRIB_COLOR_INDEX
,
1001 legalTypes
, 1, 1, 1, type
, stride
,
1002 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1005 update_array(ctx
, vao
, vbo
,
1006 VERT_ATTRIB_COLOR_INDEX
, format
, 1, 1, type
, stride
,
1007 GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1012 _mesa_SecondaryColorPointer_no_error(GLint size
, GLenum type
,
1013 GLsizei stride
, const GLvoid
*ptr
)
1015 GET_CURRENT_CONTEXT(ctx
);
1017 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1018 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1019 VERT_ATTRIB_COLOR1
, format
, BGRA_OR_4
, size
, type
,
1020 stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
1025 _mesa_SecondaryColorPointer(GLint size
, GLenum type
,
1026 GLsizei stride
, const GLvoid
*ptr
)
1028 GET_CURRENT_CONTEXT(ctx
);
1030 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1031 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1032 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1033 INT_BIT
| UNSIGNED_INT_BIT
|
1034 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1035 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1036 INT_2_10_10_10_REV_BIT
);
1038 if (!validate_array_and_format(ctx
, "glSecondaryColorPointer",
1039 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1040 VERT_ATTRIB_COLOR1
, legalTypes
, 3,
1041 BGRA_OR_4
, size
, type
, stride
,
1042 GL_TRUE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1045 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1046 VERT_ATTRIB_COLOR1
, format
, BGRA_OR_4
, size
, type
,
1047 stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
1052 _mesa_VertexArraySecondaryColorOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
1053 GLenum type
, GLsizei stride
, GLintptr offset
)
1055 GET_CURRENT_CONTEXT(ctx
);
1057 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1058 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1059 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1060 INT_BIT
| UNSIGNED_INT_BIT
|
1061 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1062 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1063 INT_2_10_10_10_REV_BIT
);
1065 struct gl_vertex_array_object
* vao
;
1066 struct gl_buffer_object
* vbo
;
1068 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1070 "glVertexArraySecondaryColorOffsetEXT"))
1073 if (!validate_array_and_format(ctx
, "glVertexArraySecondaryColorOffsetEXT",
1075 VERT_ATTRIB_COLOR1
, legalTypes
, 3,
1076 BGRA_OR_4
, size
, type
, stride
,
1077 GL_TRUE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1080 update_array(ctx
, vao
, vbo
,
1081 VERT_ATTRIB_COLOR1
, format
, BGRA_OR_4
, size
, type
,
1082 stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1087 _mesa_TexCoordPointer_no_error(GLint size
, GLenum type
, GLsizei stride
,
1090 GET_CURRENT_CONTEXT(ctx
);
1091 const GLuint unit
= ctx
->Array
.ActiveTexture
;
1093 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1094 VERT_ATTRIB_TEX(unit
), GL_RGBA
, 4, size
, type
,
1095 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1100 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
1103 GET_CURRENT_CONTEXT(ctx
);
1104 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
1105 const GLuint unit
= ctx
->Array
.ActiveTexture
;
1107 GLenum format
= GL_RGBA
;
1108 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1109 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1110 : (SHORT_BIT
| INT_BIT
|
1111 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1112 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1113 INT_2_10_10_10_REV_BIT
);
1115 if (!validate_array_and_format(ctx
, "glTexCoordPointer",
1116 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1117 VERT_ATTRIB_TEX(unit
), legalTypes
,
1118 sizeMin
, 4, size
, type
, stride
,
1119 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1122 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1123 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
1124 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1129 _mesa_VertexArrayTexCoordOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
1130 GLenum type
, GLsizei stride
, GLintptr offset
)
1132 GET_CURRENT_CONTEXT(ctx
);
1133 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
1134 const GLuint unit
= ctx
->Array
.ActiveTexture
;
1136 GLenum format
= GL_RGBA
;
1137 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1138 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1139 : (SHORT_BIT
| INT_BIT
|
1140 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1141 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1142 INT_2_10_10_10_REV_BIT
);
1144 struct gl_vertex_array_object
* vao
;
1145 struct gl_buffer_object
* vbo
;
1147 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1149 "glVertexArrayTexCoordOffsetEXT"))
1152 if (!validate_array_and_format(ctx
, "glVertexArrayTexCoordOffsetEXT",
1154 VERT_ATTRIB_TEX(unit
), legalTypes
,
1155 sizeMin
, 4, size
, type
, stride
,
1156 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1159 update_array(ctx
, vao
, vbo
,
1160 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
1161 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1166 _mesa_VertexArrayMultiTexCoordOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum texunit
,
1167 GLint size
, GLenum type
, GLsizei stride
,
1170 GET_CURRENT_CONTEXT(ctx
);
1171 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
1172 const GLuint unit
= texunit
- GL_TEXTURE0
;
1174 GLenum format
= GL_RGBA
;
1175 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1176 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1177 : (SHORT_BIT
| INT_BIT
|
1178 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1179 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1180 INT_2_10_10_10_REV_BIT
);
1182 struct gl_vertex_array_object
* vao
;
1183 struct gl_buffer_object
* vbo
;
1185 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1187 "glVertexArrayMultiTexCoordOffsetEXT"))
1190 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
1191 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexArrayMultiTexCoordOffsetEXT(texunit=%d)",
1196 if (!validate_array_and_format(ctx
, "glVertexArrayMultiTexCoordOffsetEXT",
1198 VERT_ATTRIB_TEX(unit
), legalTypes
,
1199 sizeMin
, 4, size
, type
, stride
,
1200 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1203 update_array(ctx
, vao
, vbo
,
1204 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
1205 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1210 _mesa_EdgeFlagPointer_no_error(GLsizei stride
, const GLvoid
*ptr
)
1212 /* this is the same type that glEdgeFlag uses */
1213 const GLboolean integer
= GL_FALSE
;
1214 GET_CURRENT_CONTEXT(ctx
);
1216 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1217 VERT_ATTRIB_EDGEFLAG
, GL_RGBA
, 1, 1, GL_UNSIGNED_BYTE
,
1218 stride
, GL_FALSE
, integer
, GL_FALSE
, ptr
);
1223 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
1225 /* this is the same type that glEdgeFlag uses */
1226 const GLboolean integer
= GL_FALSE
;
1227 GET_CURRENT_CONTEXT(ctx
);
1229 GLenum format
= GL_RGBA
;
1230 const GLbitfield legalTypes
= UNSIGNED_BYTE_BIT
;
1232 if (!validate_array_and_format(ctx
, "glEdgeFlagPointer",
1233 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1234 VERT_ATTRIB_EDGEFLAG
, legalTypes
,
1235 1, 1, 1, GL_UNSIGNED_BYTE
, stride
,
1236 GL_FALSE
, integer
, GL_FALSE
, format
, ptr
))
1239 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1240 VERT_ATTRIB_EDGEFLAG
, format
, 1, 1, GL_UNSIGNED_BYTE
,
1241 stride
, GL_FALSE
, integer
, GL_FALSE
, ptr
);
1246 _mesa_VertexArrayEdgeFlagOffsetEXT(GLuint vaobj
, GLuint buffer
, GLsizei stride
,
1249 /* this is the same type that glEdgeFlag uses */
1250 const GLboolean integer
= GL_FALSE
;
1251 GET_CURRENT_CONTEXT(ctx
);
1253 GLenum format
= GL_RGBA
;
1254 const GLbitfield legalTypes
= UNSIGNED_BYTE_BIT
;
1256 struct gl_vertex_array_object
* vao
;
1257 struct gl_buffer_object
* vbo
;
1259 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1261 "glVertexArrayEdgeFlagOffsetEXT"))
1264 if (!validate_array_and_format(ctx
, "glVertexArrayEdgeFlagOffsetEXT",
1266 VERT_ATTRIB_EDGEFLAG
, legalTypes
,
1267 1, 1, 1, GL_UNSIGNED_BYTE
, stride
,
1268 GL_FALSE
, integer
, GL_FALSE
, format
, (void*) offset
))
1271 update_array(ctx
, vao
, vbo
,
1272 VERT_ATTRIB_EDGEFLAG
, format
, 1, 1, GL_UNSIGNED_BYTE
,
1273 stride
, GL_FALSE
, integer
, GL_FALSE
, (void*) offset
);
1278 _mesa_PointSizePointerOES_no_error(GLenum type
, GLsizei stride
,
1281 GET_CURRENT_CONTEXT(ctx
);
1283 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1284 VERT_ATTRIB_POINT_SIZE
, GL_RGBA
, 1, 1, type
, stride
,
1285 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1290 _mesa_PointSizePointerOES(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1292 GET_CURRENT_CONTEXT(ctx
);
1294 GLenum format
= GL_RGBA
;
1295 if (ctx
->API
!= API_OPENGLES
) {
1296 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1297 "glPointSizePointer(ES 1.x only)");
1301 const GLbitfield legalTypes
= (FLOAT_BIT
| FIXED_ES_BIT
);
1303 if (!validate_array_and_format(ctx
, "glPointSizePointer",
1304 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1305 VERT_ATTRIB_POINT_SIZE
, legalTypes
,
1306 1, 1, 1, type
, stride
, GL_FALSE
, GL_FALSE
,
1307 GL_FALSE
, format
, ptr
))
1310 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1311 VERT_ATTRIB_POINT_SIZE
, format
, 1, 1, type
, stride
,
1312 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1317 _mesa_VertexAttribPointer_no_error(GLuint index
, GLint size
, GLenum type
,
1318 GLboolean normalized
,
1319 GLsizei stride
, const GLvoid
*ptr
)
1321 GET_CURRENT_CONTEXT(ctx
);
1323 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1324 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1325 VERT_ATTRIB_GENERIC(index
), format
, BGRA_OR_4
,
1326 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, ptr
);
1331 * Set a generic vertex attribute array.
1332 * Note that these arrays DO NOT alias the conventional GL vertex arrays
1333 * (position, normal, color, fog, texcoord, etc).
1336 _mesa_VertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
1337 GLboolean normalized
,
1338 GLsizei stride
, const GLvoid
*ptr
)
1340 GET_CURRENT_CONTEXT(ctx
);
1342 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1343 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1344 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(idx)");
1348 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1349 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1350 INT_BIT
| UNSIGNED_INT_BIT
|
1351 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1352 FIXED_ES_BIT
| FIXED_GL_BIT
|
1353 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1354 INT_2_10_10_10_REV_BIT
|
1355 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
1357 if (!validate_array_and_format(ctx
, "glVertexAttribPointer",
1358 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1359 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1360 1, BGRA_OR_4
, size
, type
, stride
,
1361 normalized
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1364 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1365 VERT_ATTRIB_GENERIC(index
), format
, BGRA_OR_4
,
1366 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, ptr
);
1371 _mesa_VertexArrayVertexAttribOffsetEXT(GLuint vaobj
, GLuint buffer
, GLuint index
, GLint size
,
1372 GLenum type
, GLboolean normalized
,
1373 GLsizei stride
, GLintptr offset
)
1375 GET_CURRENT_CONTEXT(ctx
);
1376 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1377 struct gl_vertex_array_object
* vao
;
1378 struct gl_buffer_object
* vbo
;
1380 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1382 "glVertexArrayVertexAttribOffsetEXT"))
1385 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1386 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexArrayVertexAttribOffsetEXT(idx)");
1390 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1391 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1392 INT_BIT
| UNSIGNED_INT_BIT
|
1393 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1394 FIXED_ES_BIT
| FIXED_GL_BIT
|
1395 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1396 INT_2_10_10_10_REV_BIT
|
1397 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
1399 if (!validate_array_and_format(ctx
, "glVertexArrayVertexAttribOffsetEXT",
1401 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1402 1, BGRA_OR_4
, size
, type
, stride
,
1403 normalized
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1406 update_array(ctx
, vao
, vbo
,
1407 VERT_ATTRIB_GENERIC(index
), format
, BGRA_OR_4
,
1408 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1413 _mesa_VertexAttribIPointer_no_error(GLuint index
, GLint size
, GLenum type
,
1414 GLsizei stride
, const GLvoid
*ptr
)
1416 const GLboolean normalized
= GL_FALSE
;
1417 const GLboolean integer
= GL_TRUE
;
1418 GET_CURRENT_CONTEXT(ctx
);
1420 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1421 VERT_ATTRIB_GENERIC(index
), GL_RGBA
, 4, size
, type
,
1422 stride
, normalized
, integer
, GL_FALSE
, ptr
);
1427 * GL_EXT_gpu_shader4 / GL 3.0.
1428 * Set an integer-valued vertex attribute array.
1429 * Note that these arrays DO NOT alias the conventional GL vertex arrays
1430 * (position, normal, color, fog, texcoord, etc).
1433 _mesa_VertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
1434 GLsizei stride
, const GLvoid
*ptr
)
1436 const GLboolean normalized
= GL_FALSE
;
1437 const GLboolean integer
= GL_TRUE
;
1438 GET_CURRENT_CONTEXT(ctx
);
1440 GLenum format
= GL_RGBA
;
1441 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1442 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribIPointer(index)");
1446 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1447 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1448 INT_BIT
| UNSIGNED_INT_BIT
);
1450 if (!validate_array_and_format(ctx
, "glVertexAttribIPointer",
1451 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1452 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1453 1, 4, size
, type
, stride
,
1454 normalized
, integer
, GL_FALSE
, format
, ptr
))
1457 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1458 VERT_ATTRIB_GENERIC(index
), format
, 4, size
, type
,
1459 stride
, normalized
, integer
, GL_FALSE
, ptr
);
1464 _mesa_VertexAttribLPointer_no_error(GLuint index
, GLint size
, GLenum type
,
1465 GLsizei stride
, const GLvoid
*ptr
)
1467 GET_CURRENT_CONTEXT(ctx
);
1469 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1470 VERT_ATTRIB_GENERIC(index
), GL_RGBA
, 4, size
, type
,
1471 stride
, GL_FALSE
, GL_FALSE
, GL_TRUE
, ptr
);
1476 _mesa_VertexArrayVertexAttribIOffsetEXT(GLuint vaobj
, GLuint buffer
, GLuint index
, GLint size
,
1477 GLenum type
, GLsizei stride
, GLintptr offset
)
1479 const GLboolean normalized
= GL_FALSE
;
1480 const GLboolean integer
= GL_TRUE
;
1481 GET_CURRENT_CONTEXT(ctx
);
1482 GLenum format
= GL_RGBA
;
1484 struct gl_vertex_array_object
* vao
;
1485 struct gl_buffer_object
* vbo
;
1487 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1489 "glVertexArrayVertexAttribIOffsetEXT"))
1492 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1493 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexArrayVertexAttribIOffsetEXT(index)");
1497 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1498 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1499 INT_BIT
| UNSIGNED_INT_BIT
);
1501 if (!validate_array_and_format(ctx
, "glVertexArrayVertexAttribIOffsetEXT",
1503 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1504 1, 4, size
, type
, stride
,
1505 normalized
, integer
, GL_FALSE
, format
, (void*) offset
))
1508 update_array(ctx
, vao
, vbo
,
1509 VERT_ATTRIB_GENERIC(index
), format
, 4, size
, type
,
1510 stride
, normalized
, integer
, GL_FALSE
, (void*) offset
);
1515 _mesa_VertexAttribLPointer(GLuint index
, GLint size
, GLenum type
,
1516 GLsizei stride
, const GLvoid
*ptr
)
1518 GET_CURRENT_CONTEXT(ctx
);
1520 GLenum format
= GL_RGBA
;
1521 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1522 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribLPointer(index)");
1526 const GLbitfield legalTypes
= DOUBLE_BIT
;
1528 if (!validate_array_and_format(ctx
, "glVertexAttribLPointer",
1529 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1530 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1531 1, 4, size
, type
, stride
,
1532 GL_FALSE
, GL_FALSE
, GL_TRUE
, format
, ptr
))
1535 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1536 VERT_ATTRIB_GENERIC(index
), format
, 4, size
, type
,
1537 stride
, GL_FALSE
, GL_FALSE
, GL_TRUE
, ptr
);
1542 _mesa_enable_vertex_array_attribs(struct gl_context
*ctx
,
1543 struct gl_vertex_array_object
*vao
,
1544 GLbitfield attrib_bits
)
1546 assert((attrib_bits
& ~VERT_BIT_ALL
) == 0);
1547 assert(!vao
->SharedAndImmutable
);
1549 /* Only work on bits that are disabled */
1550 attrib_bits
&= ~vao
->Enabled
;
1552 /* was disabled, now being enabled */
1553 vao
->Enabled
|= attrib_bits
;
1554 vao
->NewArrays
|= attrib_bits
;
1556 /* Update the map mode if needed */
1557 if (attrib_bits
& (VERT_BIT_POS
|VERT_BIT_GENERIC0
))
1558 update_attribute_map_mode(ctx
, vao
);
1563 enable_vertex_array_attrib(struct gl_context
*ctx
,
1564 struct gl_vertex_array_object
*vao
,
1568 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1569 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index)", func
);
1573 _mesa_enable_vertex_array_attrib(ctx
, vao
, VERT_ATTRIB_GENERIC(index
));
1578 _mesa_EnableVertexAttribArray(GLuint index
)
1580 GET_CURRENT_CONTEXT(ctx
);
1581 enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, index
,
1582 "glEnableVertexAttribArray");
1587 _mesa_EnableVertexAttribArray_no_error(GLuint index
)
1589 GET_CURRENT_CONTEXT(ctx
);
1590 _mesa_enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1591 VERT_ATTRIB_GENERIC(index
));
1596 _mesa_EnableVertexArrayAttrib(GLuint vaobj
, GLuint index
)
1598 GET_CURRENT_CONTEXT(ctx
);
1599 struct gl_vertex_array_object
*vao
;
1601 /* The ARB_direct_state_access specification says:
1603 * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
1604 * and DisableVertexArrayAttrib if <vaobj> is not
1605 * [compatibility profile: zero or] the name of an existing vertex
1608 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glEnableVertexArrayAttrib");
1612 enable_vertex_array_attrib(ctx
, vao
, index
, "glEnableVertexArrayAttrib");
1617 _mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj
, GLuint index
)
1619 GET_CURRENT_CONTEXT(ctx
);
1620 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
1621 _mesa_enable_vertex_array_attrib(ctx
, vao
, VERT_ATTRIB_GENERIC(index
));
1626 _mesa_disable_vertex_array_attribs(struct gl_context
*ctx
,
1627 struct gl_vertex_array_object
*vao
,
1628 GLbitfield attrib_bits
)
1630 assert((attrib_bits
& ~VERT_BIT_ALL
) == 0);
1631 assert(!vao
->SharedAndImmutable
);
1633 /* Only work on bits that are enabled */
1634 attrib_bits
&= vao
->Enabled
;
1636 /* was enabled, now being disabled */
1637 vao
->Enabled
&= ~attrib_bits
;
1638 vao
->NewArrays
|= attrib_bits
;
1640 /* Update the map mode if needed */
1641 if (attrib_bits
& (VERT_BIT_POS
|VERT_BIT_GENERIC0
))
1642 update_attribute_map_mode(ctx
, vao
);
1648 _mesa_DisableVertexAttribArray(GLuint index
)
1650 GET_CURRENT_CONTEXT(ctx
);
1652 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1653 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDisableVertexAttribArray(index)");
1657 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
1658 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attrib
);
1663 _mesa_DisableVertexAttribArray_no_error(GLuint index
)
1665 GET_CURRENT_CONTEXT(ctx
);
1666 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
1667 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attrib
);
1672 _mesa_DisableVertexArrayAttrib(GLuint vaobj
, GLuint index
)
1674 GET_CURRENT_CONTEXT(ctx
);
1675 struct gl_vertex_array_object
*vao
;
1677 /* The ARB_direct_state_access specification says:
1679 * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
1680 * and DisableVertexArrayAttrib if <vaobj> is not
1681 * [compatibility profile: zero or] the name of an existing vertex
1684 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glDisableVertexArrayAttrib");
1688 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1689 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDisableVertexArrayAttrib(index)");
1693 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
1694 _mesa_disable_vertex_array_attrib(ctx
, vao
, attrib
);
1699 _mesa_DisableVertexArrayAttrib_no_error(GLuint vaobj
, GLuint index
)
1701 GET_CURRENT_CONTEXT(ctx
);
1702 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
1703 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
1704 _mesa_disable_vertex_array_attrib(ctx
, vao
, attrib
);
1709 * Return info for a vertex attribute array (no alias with legacy
1710 * vertex attributes (pos, normal, color, etc)). This function does
1711 * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
1714 get_vertex_array_attrib(struct gl_context
*ctx
,
1715 const struct gl_vertex_array_object
*vao
,
1716 GLuint index
, GLenum pname
,
1719 const struct gl_array_attributes
*array
;
1721 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1722 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)", caller
, index
);
1726 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
1728 array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)];
1731 case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB
:
1732 return !!(vao
->Enabled
& VERT_BIT_GENERIC(index
));
1733 case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB
:
1734 return (array
->Format
.Format
== GL_BGRA
) ? GL_BGRA
: array
->Format
.Size
;
1735 case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB
:
1736 return array
->Stride
;
1737 case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB
:
1738 return array
->Format
.Type
;
1739 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB
:
1740 return array
->Format
.Normalized
;
1741 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
1742 return vao
->BufferBinding
[array
->BufferBindingIndex
].BufferObj
->Name
;
1743 case GL_VERTEX_ATTRIB_ARRAY_INTEGER
:
1744 if ((_mesa_is_desktop_gl(ctx
)
1745 && (ctx
->Version
>= 30 || ctx
->Extensions
.EXT_gpu_shader4
))
1746 || _mesa_is_gles3(ctx
)) {
1747 return array
->Format
.Integer
;
1750 case GL_VERTEX_ATTRIB_ARRAY_LONG
:
1751 if (_mesa_is_desktop_gl(ctx
)) {
1752 return array
->Format
.Doubles
;
1755 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB
:
1756 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_instanced_arrays
)
1757 || _mesa_is_gles3(ctx
)) {
1758 return vao
->BufferBinding
[array
->BufferBindingIndex
].InstanceDivisor
;
1761 case GL_VERTEX_ATTRIB_BINDING
:
1762 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles31(ctx
)) {
1763 return array
->BufferBindingIndex
- VERT_ATTRIB_GENERIC0
;
1766 case GL_VERTEX_ATTRIB_RELATIVE_OFFSET
:
1767 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles31(ctx
)) {
1768 return array
->RelativeOffset
;
1772 ; /* fall-through */
1776 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", caller
, pname
);
1781 static const GLfloat
*
1782 get_current_attrib(struct gl_context
*ctx
, GLuint index
, const char *function
)
1785 if (_mesa_attr_zero_aliases_vertex(ctx
)) {
1786 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(index==0)", function
);
1790 else if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1791 _mesa_error(ctx
, GL_INVALID_VALUE
,
1792 "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function
);
1796 assert(VERT_ATTRIB_GENERIC(index
) <
1797 ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1799 FLUSH_CURRENT(ctx
, 0);
1800 return ctx
->Current
.Attrib
[VERT_ATTRIB_GENERIC(index
)];
1804 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
)
1806 GET_CURRENT_CONTEXT(ctx
);
1808 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1809 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribfv");
1815 params
[0] = (GLfloat
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1817 "glGetVertexAttribfv");
1823 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
)
1825 GET_CURRENT_CONTEXT(ctx
);
1827 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1828 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribdv");
1830 params
[0] = (GLdouble
) v
[0];
1831 params
[1] = (GLdouble
) v
[1];
1832 params
[2] = (GLdouble
) v
[2];
1833 params
[3] = (GLdouble
) v
[3];
1837 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1839 "glGetVertexAttribdv");
1844 _mesa_GetVertexAttribLdv(GLuint index
, GLenum pname
, GLdouble
*params
)
1846 GET_CURRENT_CONTEXT(ctx
);
1848 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1850 (const GLdouble
*)get_current_attrib(ctx
, index
,
1851 "glGetVertexAttribLdv");
1860 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1862 "glGetVertexAttribLdv");
1867 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
)
1869 GET_CURRENT_CONTEXT(ctx
);
1871 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1872 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribiv");
1874 /* XXX should floats in[0,1] be scaled to full int range? */
1875 params
[0] = (GLint
) v
[0];
1876 params
[1] = (GLint
) v
[1];
1877 params
[2] = (GLint
) v
[2];
1878 params
[3] = (GLint
) v
[3];
1882 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1884 "glGetVertexAttribiv");
1889 _mesa_GetVertexAttribLui64vARB(GLuint index
, GLenum pname
, GLuint64EXT
*params
)
1891 GET_CURRENT_CONTEXT(ctx
);
1893 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1895 (const GLuint64
*)get_current_attrib(ctx
, index
,
1896 "glGetVertexAttribLui64vARB");
1905 params
[0] = (GLuint64
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1907 "glGetVertexAttribLui64vARB");
1914 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
)
1916 GET_CURRENT_CONTEXT(ctx
);
1918 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1919 const GLint
*v
= (const GLint
*)
1920 get_current_attrib(ctx
, index
, "glGetVertexAttribIiv");
1926 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1928 "glGetVertexAttribIiv");
1935 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
)
1937 GET_CURRENT_CONTEXT(ctx
);
1939 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
1940 const GLuint
*v
= (const GLuint
*)
1941 get_current_attrib(ctx
, index
, "glGetVertexAttribIuiv");
1947 params
[0] = get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1949 "glGetVertexAttribIuiv");
1955 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
)
1957 GET_CURRENT_CONTEXT(ctx
);
1959 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1960 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerARB(index)");
1964 if (pname
!= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
) {
1965 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerARB(pname)");
1969 assert(VERT_ATTRIB_GENERIC(index
) <
1970 ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
1972 *pointer
= (GLvoid
*)
1973 ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Ptr
;
1977 /** ARB_direct_state_access */
1979 _mesa_GetVertexArrayIndexediv(GLuint vaobj
, GLuint index
,
1980 GLenum pname
, GLint
*params
)
1982 GET_CURRENT_CONTEXT(ctx
);
1983 struct gl_vertex_array_object
*vao
;
1985 /* The ARB_direct_state_access specification says:
1987 * "An INVALID_OPERATION error is generated if <vaobj> is not
1988 * [compatibility profile: zero or] the name of an existing
1989 * vertex array object."
1991 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glGetVertexArrayIndexediv");
1995 /* The ARB_direct_state_access specification says:
1997 * "For GetVertexArrayIndexediv, <pname> must be one of
1998 * VERTEX_ATTRIB_ARRAY_ENABLED, VERTEX_ATTRIB_ARRAY_SIZE,
1999 * VERTEX_ATTRIB_ARRAY_STRIDE, VERTEX_ATTRIB_ARRAY_TYPE,
2000 * VERTEX_ATTRIB_ARRAY_NORMALIZED, VERTEX_ATTRIB_ARRAY_INTEGER,
2001 * VERTEX_ATTRIB_ARRAY_LONG, VERTEX_ATTRIB_ARRAY_DIVISOR, or
2002 * VERTEX_ATTRIB_RELATIVE_OFFSET."
2006 * "Add GetVertexArrayIndexediv in 'Get Command' for
2007 * VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
2008 * VERTEX_ATTRIB_BINDING,
2009 * VERTEX_ATTRIB_RELATIVE_OFFSET,
2010 * VERTEX_BINDING_OFFSET, and
2011 * VERTEX_BINDING_STRIDE states"
2013 * The only parameter name common to both lists is
2014 * VERTEX_ATTRIB_RELATIVE_OFFSET. Also note that VERTEX_BINDING_BUFFER
2015 * and VERTEX_BINDING_DIVISOR are missing from both lists. It seems
2016 * pretty clear however that the intent is that it should be possible
2017 * to query all vertex attrib and binding states that can be set with
2021 case GL_VERTEX_BINDING_OFFSET
:
2022 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2024 case GL_VERTEX_BINDING_STRIDE
:
2025 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2027 case GL_VERTEX_BINDING_DIVISOR
:
2028 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2030 case GL_VERTEX_BINDING_BUFFER
:
2031 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2034 params
[0] = get_vertex_array_attrib(ctx
, vao
, index
, pname
,
2035 "glGetVertexArrayIndexediv");
2042 _mesa_GetVertexArrayIndexed64iv(GLuint vaobj
, GLuint index
,
2043 GLenum pname
, GLint64
*params
)
2045 GET_CURRENT_CONTEXT(ctx
);
2046 struct gl_vertex_array_object
*vao
;
2048 /* The ARB_direct_state_access specification says:
2050 * "An INVALID_OPERATION error is generated if <vaobj> is not
2051 * [compatibility profile: zero or] the name of an existing
2052 * vertex array object."
2054 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glGetVertexArrayIndexed64iv");
2058 /* The ARB_direct_state_access specification says:
2060 * "For GetVertexArrayIndexed64iv, <pname> must be
2061 * VERTEX_BINDING_OFFSET."
2065 * "An INVALID_ENUM error is generated if <pname> is not one of
2066 * the valid values listed above for the corresponding command."
2068 if (pname
!= GL_VERTEX_BINDING_OFFSET
) {
2069 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexArrayIndexed64iv("
2070 "pname != GL_VERTEX_BINDING_OFFSET)");
2074 /* The ARB_direct_state_access specification says:
2076 * "An INVALID_VALUE error is generated if <index> is greater than
2077 * or equal to the value of MAX_VERTEX_ATTRIBS."
2079 * Since the index refers to a buffer binding in this case, the intended
2080 * limit must be MAX_VERTEX_ATTRIB_BINDINGS. Both limits are currently
2081 * required to be the same, so in practice this doesn't matter.
2083 if (index
>= ctx
->Const
.MaxVertexAttribBindings
) {
2084 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexArrayIndexed64iv(index"
2085 "%d >= the value of GL_MAX_VERTEX_ATTRIB_BINDINGS (%d))",
2086 index
, ctx
->Const
.MaxVertexAttribBindings
);
2090 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2095 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
2096 GLsizei count
, const GLvoid
*ptr
)
2099 _mesa_VertexPointer(size
, type
, stride
, ptr
);
2104 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
2108 _mesa_NormalPointer(type
, stride
, ptr
);
2113 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
2117 _mesa_ColorPointer(size
, type
, stride
, ptr
);
2122 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
2126 _mesa_IndexPointer(type
, stride
, ptr
);
2131 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
2132 GLsizei count
, const GLvoid
*ptr
)
2135 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
2140 _mesa_MultiTexCoordPointerEXT(GLenum texunit
, GLint size
, GLenum type
,
2141 GLsizei stride
, const GLvoid
*ptr
)
2143 GET_CURRENT_CONTEXT(ctx
);
2144 const GLint sizeMin
= 1;
2145 const GLuint unit
= texunit
- GL_TEXTURE0
;
2147 GLenum format
= GL_RGBA
;
2148 const GLbitfield legalTypes
= (SHORT_BIT
| INT_BIT
|
2149 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
2150 UNSIGNED_INT_2_10_10_10_REV_BIT
|
2151 INT_2_10_10_10_REV_BIT
);
2153 if (!validate_array_and_format(ctx
, "glMultiTexCoordPointerEXT",
2154 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
2155 VERT_ATTRIB_TEX(unit
), legalTypes
,
2156 sizeMin
, 4, size
, type
, stride
,
2157 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
2160 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
2161 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
2162 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
2167 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
2170 _mesa_EdgeFlagPointer(stride
, ptr
);
2175 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
2177 GET_CURRENT_CONTEXT(ctx
);
2178 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
2179 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
2180 GLenum ctype
= 0; /* color type */
2181 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
2182 const GLint toffset
= 0; /* always zero */
2183 GLint defstride
; /* default stride */
2186 f
= sizeof(GLfloat
);
2187 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
2190 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
2196 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2197 tcomps
= 0; ccomps
= 0; vcomps
= 2;
2202 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2203 tcomps
= 0; ccomps
= 0; vcomps
= 3;
2208 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2209 tcomps
= 0; ccomps
= 4; vcomps
= 2;
2210 ctype
= GL_UNSIGNED_BYTE
;
2213 defstride
= c
+ 2*f
;
2216 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2217 tcomps
= 0; ccomps
= 4; vcomps
= 3;
2218 ctype
= GL_UNSIGNED_BYTE
;
2221 defstride
= c
+ 3*f
;
2224 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2225 tcomps
= 0; ccomps
= 3; vcomps
= 3;
2232 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
2233 tcomps
= 0; ccomps
= 0; vcomps
= 3;
2238 case GL_C4F_N3F_V3F
:
2239 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
2240 tcomps
= 0; ccomps
= 4; vcomps
= 3;
2248 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2249 tcomps
= 2; ccomps
= 0; vcomps
= 3;
2254 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2255 tcomps
= 4; ccomps
= 0; vcomps
= 4;
2259 case GL_T2F_C4UB_V3F
:
2260 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2261 tcomps
= 2; ccomps
= 4; vcomps
= 3;
2262 ctype
= GL_UNSIGNED_BYTE
;
2267 case GL_T2F_C3F_V3F
:
2268 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2269 tcomps
= 2; ccomps
= 3; vcomps
= 3;
2275 case GL_T2F_N3F_V3F
:
2276 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
2277 tcomps
= 2; ccomps
= 0; vcomps
= 3;
2282 case GL_T2F_C4F_N3F_V3F
:
2283 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
2284 tcomps
= 2; ccomps
= 4; vcomps
= 3;
2291 case GL_T4F_C4F_N3F_V4F
:
2292 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
2293 tcomps
= 4; ccomps
= 4; vcomps
= 4;
2301 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
2309 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
2310 _mesa_DisableClientState( GL_INDEX_ARRAY
);
2311 /* XXX also disable secondary color and generic arrays? */
2315 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
2316 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
2317 (GLubyte
*) pointer
+ toffset
);
2320 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
2325 _mesa_EnableClientState( GL_COLOR_ARRAY
);
2326 _mesa_ColorPointer( ccomps
, ctype
, stride
,
2327 (GLubyte
*) pointer
+ coffset
);
2330 _mesa_DisableClientState( GL_COLOR_ARRAY
);
2336 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
2337 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
2340 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
2344 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
2345 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
2346 (GLubyte
*) pointer
+ voffset
);
2351 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
2353 GET_CURRENT_CONTEXT(ctx
);
2355 if (MESA_VERBOSE
& VERBOSE_API
)
2356 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
2359 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
2363 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
2366 if (ctx
->Array
.LockCount
!= 0) {
2367 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
2371 ctx
->Array
.LockFirst
= first
;
2372 ctx
->Array
.LockCount
= count
;
2377 _mesa_UnlockArraysEXT( void )
2379 GET_CURRENT_CONTEXT(ctx
);
2381 if (MESA_VERBOSE
& VERBOSE_API
)
2382 _mesa_debug(ctx
, "glUnlockArrays\n");
2384 if (ctx
->Array
.LockCount
== 0) {
2385 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
2389 ctx
->Array
.LockFirst
= 0;
2390 ctx
->Array
.LockCount
= 0;
2395 primitive_restart_index(struct gl_context
*ctx
, GLuint index
)
2397 ctx
->Array
.RestartIndex
= index
;
2402 * GL_NV_primitive_restart and GL 3.1
2405 _mesa_PrimitiveRestartIndex_no_error(GLuint index
)
2407 GET_CURRENT_CONTEXT(ctx
);
2408 primitive_restart_index(ctx
, index
);
2413 _mesa_PrimitiveRestartIndex(GLuint index
)
2415 GET_CURRENT_CONTEXT(ctx
);
2417 if (!ctx
->Extensions
.NV_primitive_restart
&& ctx
->Version
< 31) {
2418 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glPrimitiveRestartIndexNV()");
2422 primitive_restart_index(ctx
, index
);
2427 _mesa_VertexAttribDivisor_no_error(GLuint index
, GLuint divisor
)
2429 GET_CURRENT_CONTEXT(ctx
);
2431 const gl_vert_attrib genericIndex
= VERT_ATTRIB_GENERIC(index
);
2432 struct gl_vertex_array_object
* const vao
= ctx
->Array
.VAO
;
2434 assert(genericIndex
< ARRAY_SIZE(vao
->VertexAttrib
));
2436 /* The ARB_vertex_attrib_binding spec says:
2440 * void VertexAttribDivisor(uint index, uint divisor);
2442 * is equivalent to (assuming no errors are generated):
2444 * VertexAttribBinding(index, index);
2445 * VertexBindingDivisor(index, divisor);"
2447 _mesa_vertex_attrib_binding(ctx
, vao
, genericIndex
, genericIndex
);
2448 vertex_binding_divisor(ctx
, vao
, genericIndex
, divisor
);
2453 * See GL_ARB_instanced_arrays.
2454 * Note that the instance divisor only applies to generic arrays, not
2455 * the legacy vertex arrays.
2458 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
)
2460 GET_CURRENT_CONTEXT(ctx
);
2462 const gl_vert_attrib genericIndex
= VERT_ATTRIB_GENERIC(index
);
2463 struct gl_vertex_array_object
* const vao
= ctx
->Array
.VAO
;
2465 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
2466 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexAttribDivisor()");
2470 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2471 _mesa_error(ctx
, GL_INVALID_VALUE
,
2472 "glVertexAttribDivisor(index = %u)", index
);
2476 assert(genericIndex
< ARRAY_SIZE(vao
->VertexAttrib
));
2478 /* The ARB_vertex_attrib_binding spec says:
2482 * void VertexAttribDivisor(uint index, uint divisor);
2484 * is equivalent to (assuming no errors are generated):
2486 * VertexAttribBinding(index, index);
2487 * VertexBindingDivisor(index, divisor);"
2489 _mesa_vertex_attrib_binding(ctx
, vao
, genericIndex
, genericIndex
);
2490 vertex_binding_divisor(ctx
, vao
, genericIndex
, divisor
);
2494 static ALWAYS_INLINE
void
2495 vertex_array_vertex_buffer(struct gl_context
*ctx
,
2496 struct gl_vertex_array_object
*vao
,
2497 GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
2498 GLsizei stride
, bool no_error
, const char *func
)
2500 struct gl_buffer_object
*vbo
;
2502 vao
->BufferBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
->Name
) {
2503 vbo
= vao
->BufferBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
;
2504 } else if (buffer
!= 0) {
2505 vbo
= _mesa_lookup_bufferobj(ctx
, buffer
);
2507 if (!no_error
&& !vbo
&& _mesa_is_gles31(ctx
)) {
2508 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(non-gen name)", func
);
2511 /* From the GL_ARB_vertex_attrib_array spec:
2513 * "[Core profile only:]
2514 * An INVALID_OPERATION error is generated if buffer is not zero or a
2515 * name returned from a previous call to GenBuffers, or if such a name
2516 * has since been deleted with DeleteBuffers.
2518 * Otherwise, we fall back to the same compat profile behavior as other
2519 * object references (automatically gen it).
2521 if (!_mesa_handle_bind_buffer_gen(ctx
, buffer
, &vbo
, func
))
2524 /* The ARB_vertex_attrib_binding spec says:
2526 * "If <buffer> is zero, any buffer object attached to this
2527 * bindpoint is detached."
2529 vbo
= ctx
->Shared
->NullBufferObj
;
2532 _mesa_bind_vertex_buffer(ctx
, vao
, VERT_ATTRIB_GENERIC(bindingIndex
),
2533 vbo
, offset
, stride
);
2538 * GL_ARB_vertex_attrib_binding
2541 vertex_array_vertex_buffer_err(struct gl_context
*ctx
,
2542 struct gl_vertex_array_object
*vao
,
2543 GLuint bindingIndex
, GLuint buffer
,
2544 GLintptr offset
, GLsizei stride
,
2547 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2549 /* The ARB_vertex_attrib_binding spec says:
2551 * "An INVALID_VALUE error is generated if <bindingindex> is greater than
2552 * the value of MAX_VERTEX_ATTRIB_BINDINGS."
2554 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
2555 _mesa_error(ctx
, GL_INVALID_VALUE
,
2556 "%s(bindingindex=%u > "
2557 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
2558 func
, bindingIndex
);
2562 /* The ARB_vertex_attrib_binding spec says:
2564 * "The error INVALID_VALUE is generated if <stride> or <offset>
2568 _mesa_error(ctx
, GL_INVALID_VALUE
,
2569 "%s(offset=%" PRId64
" < 0)",
2570 func
, (int64_t) offset
);
2575 _mesa_error(ctx
, GL_INVALID_VALUE
,
2576 "%s(stride=%d < 0)", func
, stride
);
2580 if (((_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 44) || _mesa_is_gles31(ctx
)) &&
2581 stride
> ctx
->Const
.MaxVertexAttribStride
) {
2582 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride=%d > "
2583 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, stride
);
2587 vertex_array_vertex_buffer(ctx
, vao
, bindingIndex
, buffer
, offset
,
2588 stride
, false, func
);
2593 _mesa_BindVertexBuffer_no_error(GLuint bindingIndex
, GLuint buffer
,
2594 GLintptr offset
, GLsizei stride
)
2596 GET_CURRENT_CONTEXT(ctx
);
2597 vertex_array_vertex_buffer(ctx
, ctx
->Array
.VAO
, bindingIndex
,
2598 buffer
, offset
, stride
, true,
2599 "glBindVertexBuffer");
2604 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
2607 GET_CURRENT_CONTEXT(ctx
);
2609 /* The ARB_vertex_attrib_binding spec says:
2611 * "An INVALID_OPERATION error is generated if no vertex array object
2614 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
2615 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
2616 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2617 "glBindVertexBuffer(No array object bound)");
2621 vertex_array_vertex_buffer_err(ctx
, ctx
->Array
.VAO
, bindingIndex
,
2622 buffer
, offset
, stride
,
2623 "glBindVertexBuffer");
2628 _mesa_VertexArrayVertexBuffer_no_error(GLuint vaobj
, GLuint bindingIndex
,
2629 GLuint buffer
, GLintptr offset
,
2632 GET_CURRENT_CONTEXT(ctx
);
2634 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
2635 vertex_array_vertex_buffer(ctx
, vao
, bindingIndex
, buffer
, offset
,
2636 stride
, true, "glVertexArrayVertexBuffer");
2641 _mesa_VertexArrayVertexBuffer(GLuint vaobj
, GLuint bindingIndex
, GLuint buffer
,
2642 GLintptr offset
, GLsizei stride
)
2644 GET_CURRENT_CONTEXT(ctx
);
2645 struct gl_vertex_array_object
*vao
;
2647 /* The ARB_direct_state_access specification says:
2649 * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
2650 * if <vaobj> is not [compatibility profile: zero or] the name of an
2651 * existing vertex array object."
2653 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayVertexBuffer");
2657 vertex_array_vertex_buffer_err(ctx
, vao
, bindingIndex
, buffer
, offset
,
2658 stride
, "glVertexArrayVertexBuffer");
2662 static ALWAYS_INLINE
void
2663 vertex_array_vertex_buffers(struct gl_context
*ctx
,
2664 struct gl_vertex_array_object
*vao
,
2665 GLuint first
, GLsizei count
, const GLuint
*buffers
,
2666 const GLintptr
*offsets
, const GLsizei
*strides
,
2667 bool no_error
, const char *func
)
2673 * The ARB_multi_bind spec says:
2675 * "If <buffers> is NULL, each affected vertex buffer binding point
2676 * from <first> through <first>+<count>-1 will be reset to have no
2677 * bound buffer object. In this case, the offsets and strides
2678 * associated with the binding points are set to default values,
2679 * ignoring <offsets> and <strides>."
2681 struct gl_buffer_object
*vbo
= ctx
->Shared
->NullBufferObj
;
2683 for (i
= 0; i
< count
; i
++)
2684 _mesa_bind_vertex_buffer(ctx
, vao
, VERT_ATTRIB_GENERIC(first
+ i
),
2690 /* Note that the error semantics for multi-bind commands differ from
2691 * those of other GL commands.
2693 * The Issues section in the ARB_multi_bind spec says:
2695 * "(11) Typically, OpenGL specifies that if an error is generated by
2696 * a command, that command has no effect. This is somewhat
2697 * unfortunate for multi-bind commands, because it would require
2698 * a first pass to scan the entire list of bound objects for
2699 * errors and then a second pass to actually perform the
2700 * bindings. Should we have different error semantics?
2702 * RESOLVED: Yes. In this specification, when the parameters for
2703 * one of the <count> binding points are invalid, that binding
2704 * point is not updated and an error will be generated. However,
2705 * other binding points in the same command will be updated if
2706 * their parameters are valid and no other error occurs."
2709 _mesa_HashLockMutex(ctx
->Shared
->BufferObjects
);
2711 for (i
= 0; i
< count
; i
++) {
2712 struct gl_buffer_object
*vbo
;
2715 /* The ARB_multi_bind spec says:
2717 * "An INVALID_VALUE error is generated if any value in
2718 * <offsets> or <strides> is negative (per binding)."
2720 if (offsets
[i
] < 0) {
2721 _mesa_error(ctx
, GL_INVALID_VALUE
,
2722 "%s(offsets[%u]=%" PRId64
" < 0)",
2723 func
, i
, (int64_t) offsets
[i
]);
2727 if (strides
[i
] < 0) {
2728 _mesa_error(ctx
, GL_INVALID_VALUE
,
2729 "%s(strides[%u]=%d < 0)",
2730 func
, i
, strides
[i
]);
2734 if (_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 44 &&
2735 strides
[i
] > ctx
->Const
.MaxVertexAttribStride
) {
2736 _mesa_error(ctx
, GL_INVALID_VALUE
,
2737 "%s(strides[%u]=%d > "
2738 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, i
, strides
[i
]);
2744 struct gl_vertex_buffer_binding
*binding
=
2745 &vao
->BufferBinding
[VERT_ATTRIB_GENERIC(first
+ i
)];
2747 if (buffers
[i
] == binding
->BufferObj
->Name
)
2748 vbo
= binding
->BufferObj
;
2750 vbo
= _mesa_multi_bind_lookup_bufferobj(ctx
, buffers
, i
, func
);
2755 vbo
= ctx
->Shared
->NullBufferObj
;
2758 _mesa_bind_vertex_buffer(ctx
, vao
, VERT_ATTRIB_GENERIC(first
+ i
),
2759 vbo
, offsets
[i
], strides
[i
]);
2762 _mesa_HashUnlockMutex(ctx
->Shared
->BufferObjects
);
2767 vertex_array_vertex_buffers_err(struct gl_context
*ctx
,
2768 struct gl_vertex_array_object
*vao
,
2769 GLuint first
, GLsizei count
,
2770 const GLuint
*buffers
, const GLintptr
*offsets
,
2771 const GLsizei
*strides
, const char *func
)
2773 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2775 /* The ARB_multi_bind spec says:
2777 * "An INVALID_OPERATION error is generated if <first> + <count>
2778 * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS."
2780 if (first
+ count
> ctx
->Const
.MaxVertexAttribBindings
) {
2781 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2782 "%s(first=%u + count=%d > the value of "
2783 "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
2784 func
, first
, count
, ctx
->Const
.MaxVertexAttribBindings
);
2788 vertex_array_vertex_buffers(ctx
, vao
, first
, count
, buffers
, offsets
,
2789 strides
, false, func
);
2794 _mesa_BindVertexBuffers_no_error(GLuint first
, GLsizei count
,
2795 const GLuint
*buffers
, const GLintptr
*offsets
,
2796 const GLsizei
*strides
)
2798 GET_CURRENT_CONTEXT(ctx
);
2800 vertex_array_vertex_buffers(ctx
, ctx
->Array
.VAO
, first
, count
,
2801 buffers
, offsets
, strides
, true,
2802 "glBindVertexBuffers");
2807 _mesa_BindVertexBuffers(GLuint first
, GLsizei count
, const GLuint
*buffers
,
2808 const GLintptr
*offsets
, const GLsizei
*strides
)
2810 GET_CURRENT_CONTEXT(ctx
);
2812 /* The ARB_vertex_attrib_binding spec says:
2814 * "An INVALID_OPERATION error is generated if no
2815 * vertex array object is bound."
2817 if (ctx
->API
== API_OPENGL_CORE
&&
2818 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
2819 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2820 "glBindVertexBuffers(No array object bound)");
2824 vertex_array_vertex_buffers_err(ctx
, ctx
->Array
.VAO
, first
, count
,
2825 buffers
, offsets
, strides
,
2826 "glBindVertexBuffers");
2831 _mesa_VertexArrayVertexBuffers_no_error(GLuint vaobj
, GLuint first
,
2832 GLsizei count
, const GLuint
*buffers
,
2833 const GLintptr
*offsets
,
2834 const GLsizei
*strides
)
2836 GET_CURRENT_CONTEXT(ctx
);
2838 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
2839 vertex_array_vertex_buffers(ctx
, vao
, first
, count
,
2840 buffers
, offsets
, strides
, true,
2841 "glVertexArrayVertexBuffers");
2846 _mesa_VertexArrayVertexBuffers(GLuint vaobj
, GLuint first
, GLsizei count
,
2847 const GLuint
*buffers
,
2848 const GLintptr
*offsets
, const GLsizei
*strides
)
2850 GET_CURRENT_CONTEXT(ctx
);
2851 struct gl_vertex_array_object
*vao
;
2853 /* The ARB_direct_state_access specification says:
2855 * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
2856 * if <vaobj> is not [compatibility profile: zero or] the name of an
2857 * existing vertex array object."
2859 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayVertexBuffers");
2863 vertex_array_vertex_buffers_err(ctx
, vao
, first
, count
,
2864 buffers
, offsets
, strides
,
2865 "glVertexArrayVertexBuffers");
2870 vertex_attrib_format(GLuint attribIndex
, GLint size
, GLenum type
,
2871 GLboolean normalized
, GLboolean integer
,
2872 GLboolean doubles
, GLbitfield legalTypes
,
2873 GLsizei sizeMax
, GLuint relativeOffset
,
2876 GET_CURRENT_CONTEXT(ctx
);
2877 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2879 GLenum format
= get_array_format(ctx
, sizeMax
, &size
);
2881 if (!_mesa_is_no_error_enabled(ctx
)) {
2882 /* The ARB_vertex_attrib_binding spec says:
2884 * "An INVALID_OPERATION error is generated under any of the
2885 * following conditions:
2886 * - if no vertex array object is currently bound (see section
2890 * This error condition only applies to VertexAttribFormat and
2891 * VertexAttribIFormat in the extension spec, but we assume that this
2892 * is an oversight. In the OpenGL 4.3 (Core Profile) spec, it applies
2893 * to all three functions.
2895 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
2896 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
2897 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2898 "%s(No array object bound)", func
);
2902 /* The ARB_vertex_attrib_binding spec says:
2904 * "The error INVALID_VALUE is generated if index is greater than or
2905 * equal to the value of MAX_VERTEX_ATTRIBS."
2907 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2908 _mesa_error(ctx
, GL_INVALID_VALUE
,
2909 "%s(attribindex=%u > "
2910 "GL_MAX_VERTEX_ATTRIBS)",
2915 if (!validate_array_format(ctx
, func
, ctx
->Array
.VAO
,
2916 VERT_ATTRIB_GENERIC(attribIndex
),
2917 legalTypes
, 1, sizeMax
, size
, type
,
2918 normalized
, integer
, doubles
, relativeOffset
,
2924 _mesa_update_array_format(ctx
, ctx
->Array
.VAO
,
2925 VERT_ATTRIB_GENERIC(attribIndex
), size
, type
,
2926 format
, normalized
, integer
, doubles
,
2932 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
2933 GLboolean normalized
, GLuint relativeOffset
)
2935 vertex_attrib_format(attribIndex
, size
, type
, normalized
,
2936 GL_FALSE
, GL_FALSE
, ATTRIB_FORMAT_TYPES_MASK
,
2937 BGRA_OR_4
, relativeOffset
,
2938 "glVertexAttribFormat");
2943 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
2944 GLuint relativeOffset
)
2946 vertex_attrib_format(attribIndex
, size
, type
, GL_FALSE
,
2947 GL_TRUE
, GL_FALSE
, ATTRIB_IFORMAT_TYPES_MASK
, 4,
2948 relativeOffset
, "glVertexAttribIFormat");
2953 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
2954 GLuint relativeOffset
)
2956 vertex_attrib_format(attribIndex
, size
, type
, GL_FALSE
, GL_FALSE
,
2957 GL_TRUE
, ATTRIB_LFORMAT_TYPES_MASK
, 4,
2958 relativeOffset
, "glVertexAttribLFormat");
2963 vertex_array_attrib_format(GLuint vaobj
, GLuint attribIndex
, GLint size
,
2964 GLenum type
, GLboolean normalized
,
2965 GLboolean integer
, GLboolean doubles
,
2966 GLbitfield legalTypes
, GLsizei sizeMax
,
2967 GLuint relativeOffset
, const char *func
)
2969 GET_CURRENT_CONTEXT(ctx
);
2970 struct gl_vertex_array_object
*vao
;
2972 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2974 GLenum format
= get_array_format(ctx
, sizeMax
, &size
);
2976 if (_mesa_is_no_error_enabled(ctx
)) {
2977 vao
= _mesa_lookup_vao(ctx
, vaobj
);
2981 /* The ARB_direct_state_access spec says:
2983 * "An INVALID_OPERATION error is generated by
2984 * VertexArrayAttrib*Format if <vaobj> is not [compatibility profile:
2985 * zero or] the name of an existing vertex array object."
2987 vao
= _mesa_lookup_vao_err(ctx
, false, vaobj
, func
);
2991 /* The ARB_vertex_attrib_binding spec says:
2993 * "The error INVALID_VALUE is generated if index is greater than or
2994 * equal to the value of MAX_VERTEX_ATTRIBS."
2996 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2997 _mesa_error(ctx
, GL_INVALID_VALUE
,
2998 "%s(attribindex=%u > GL_MAX_VERTEX_ATTRIBS)",
3003 if (!validate_array_format(ctx
, func
, vao
,
3004 VERT_ATTRIB_GENERIC(attribIndex
),
3005 legalTypes
, 1, sizeMax
, size
, type
,
3006 normalized
, integer
, doubles
, relativeOffset
,
3012 _mesa_update_array_format(ctx
, vao
, VERT_ATTRIB_GENERIC(attribIndex
), size
,
3013 type
, format
, normalized
, integer
, doubles
,
3019 _mesa_VertexArrayAttribFormat(GLuint vaobj
, GLuint attribIndex
, GLint size
,
3020 GLenum type
, GLboolean normalized
,
3021 GLuint relativeOffset
)
3023 vertex_array_attrib_format(vaobj
, attribIndex
, size
, type
, normalized
,
3024 GL_FALSE
, GL_FALSE
, ATTRIB_FORMAT_TYPES_MASK
,
3025 BGRA_OR_4
, relativeOffset
,
3026 "glVertexArrayAttribFormat");
3031 _mesa_VertexArrayAttribIFormat(GLuint vaobj
, GLuint attribIndex
,
3032 GLint size
, GLenum type
,
3033 GLuint relativeOffset
)
3035 vertex_array_attrib_format(vaobj
, attribIndex
, size
, type
, GL_FALSE
,
3036 GL_TRUE
, GL_FALSE
, ATTRIB_IFORMAT_TYPES_MASK
,
3038 "glVertexArrayAttribIFormat");
3043 _mesa_VertexArrayAttribLFormat(GLuint vaobj
, GLuint attribIndex
,
3044 GLint size
, GLenum type
,
3045 GLuint relativeOffset
)
3047 vertex_array_attrib_format(vaobj
, attribIndex
, size
, type
, GL_FALSE
,
3048 GL_FALSE
, GL_TRUE
, ATTRIB_LFORMAT_TYPES_MASK
,
3050 "glVertexArrayAttribLFormat");
3055 vertex_array_attrib_binding(struct gl_context
*ctx
,
3056 struct gl_vertex_array_object
*vao
,
3057 GLuint attribIndex
, GLuint bindingIndex
,
3060 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3062 /* The ARB_vertex_attrib_binding spec says:
3064 * "<attribindex> must be less than the value of MAX_VERTEX_ATTRIBS and
3065 * <bindingindex> must be less than the value of
3066 * MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
3069 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
3070 _mesa_error(ctx
, GL_INVALID_VALUE
,
3071 "%s(attribindex=%u >= "
3072 "GL_MAX_VERTEX_ATTRIBS)",
3077 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
3078 _mesa_error(ctx
, GL_INVALID_VALUE
,
3079 "%s(bindingindex=%u >= "
3080 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
3081 func
, bindingIndex
);
3085 assert(VERT_ATTRIB_GENERIC(attribIndex
) < ARRAY_SIZE(vao
->VertexAttrib
));
3087 _mesa_vertex_attrib_binding(ctx
, vao
,
3088 VERT_ATTRIB_GENERIC(attribIndex
),
3089 VERT_ATTRIB_GENERIC(bindingIndex
));
3094 _mesa_VertexAttribBinding_no_error(GLuint attribIndex
, GLuint bindingIndex
)
3096 GET_CURRENT_CONTEXT(ctx
);
3097 _mesa_vertex_attrib_binding(ctx
, ctx
->Array
.VAO
,
3098 VERT_ATTRIB_GENERIC(attribIndex
),
3099 VERT_ATTRIB_GENERIC(bindingIndex
));
3104 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
)
3106 GET_CURRENT_CONTEXT(ctx
);
3108 /* The ARB_vertex_attrib_binding spec says:
3110 * "An INVALID_OPERATION error is generated if no vertex array object
3113 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
3114 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3115 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3116 "glVertexAttribBinding(No array object bound)");
3120 vertex_array_attrib_binding(ctx
, ctx
->Array
.VAO
,
3121 attribIndex
, bindingIndex
,
3122 "glVertexAttribBinding");
3127 _mesa_VertexArrayAttribBinding_no_error(GLuint vaobj
, GLuint attribIndex
,
3128 GLuint bindingIndex
)
3130 GET_CURRENT_CONTEXT(ctx
);
3132 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
3133 _mesa_vertex_attrib_binding(ctx
, vao
,
3134 VERT_ATTRIB_GENERIC(attribIndex
),
3135 VERT_ATTRIB_GENERIC(bindingIndex
));
3140 _mesa_VertexArrayAttribBinding(GLuint vaobj
, GLuint attribIndex
, GLuint bindingIndex
)
3142 GET_CURRENT_CONTEXT(ctx
);
3143 struct gl_vertex_array_object
*vao
;
3145 /* The ARB_direct_state_access specification says:
3147 * "An INVALID_OPERATION error is generated by VertexArrayAttribBinding
3148 * if <vaobj> is not [compatibility profile: zero or] the name of an
3149 * existing vertex array object."
3151 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayAttribBinding");
3155 vertex_array_attrib_binding(ctx
, vao
, attribIndex
, bindingIndex
,
3156 "glVertexArrayAttribBinding");
3161 vertex_array_binding_divisor(struct gl_context
*ctx
,
3162 struct gl_vertex_array_object
*vao
,
3163 GLuint bindingIndex
, GLuint divisor
,
3166 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3168 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
3169 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s()", func
);
3173 /* The ARB_vertex_attrib_binding spec says:
3175 * "An INVALID_VALUE error is generated if <bindingindex> is greater
3176 * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS."
3178 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
3179 _mesa_error(ctx
, GL_INVALID_VALUE
,
3180 "%s(bindingindex=%u > "
3181 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
3182 func
, bindingIndex
);
3186 vertex_binding_divisor(ctx
, vao
, VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
3191 _mesa_VertexBindingDivisor_no_error(GLuint bindingIndex
, GLuint divisor
)
3193 GET_CURRENT_CONTEXT(ctx
);
3194 vertex_binding_divisor(ctx
, ctx
->Array
.VAO
,
3195 VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
3200 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
)
3202 GET_CURRENT_CONTEXT(ctx
);
3204 /* The ARB_vertex_attrib_binding spec says:
3206 * "An INVALID_OPERATION error is generated if no vertex array object
3209 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
3210 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3211 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3212 "glVertexBindingDivisor(No array object bound)");
3216 vertex_array_binding_divisor(ctx
, ctx
->Array
.VAO
,
3217 bindingIndex
, divisor
,
3218 "glVertexBindingDivisor");
3223 _mesa_VertexArrayBindingDivisor_no_error(GLuint vaobj
, GLuint bindingIndex
,
3226 GET_CURRENT_CONTEXT(ctx
);
3228 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
3229 vertex_binding_divisor(ctx
, vao
, VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
3234 _mesa_VertexArrayBindingDivisor(GLuint vaobj
, GLuint bindingIndex
,
3237 struct gl_vertex_array_object
*vao
;
3238 GET_CURRENT_CONTEXT(ctx
);
3240 /* The ARB_direct_state_access specification says:
3242 * "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
3243 * if <vaobj> is not [compatibility profile: zero or] the name of an
3244 * existing vertex array object."
3246 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayBindingDivisor");
3250 vertex_array_binding_divisor(ctx
, vao
, bindingIndex
, divisor
,
3251 "glVertexArrayBindingDivisor");
3256 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
3257 struct gl_array_attributes
*dst
,
3258 const struct gl_array_attributes
*src
)
3260 dst
->Ptr
= src
->Ptr
;
3261 dst
->RelativeOffset
= src
->RelativeOffset
;
3262 dst
->Format
= src
->Format
;
3263 dst
->Stride
= src
->Stride
;
3264 dst
->BufferBindingIndex
= src
->BufferBindingIndex
;
3265 dst
->_EffBufferBindingIndex
= src
->_EffBufferBindingIndex
;
3266 dst
->_EffRelativeOffset
= src
->_EffRelativeOffset
;
3270 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
3271 struct gl_vertex_buffer_binding
*dst
,
3272 const struct gl_vertex_buffer_binding
*src
)
3274 dst
->Offset
= src
->Offset
;
3275 dst
->Stride
= src
->Stride
;
3276 dst
->InstanceDivisor
= src
->InstanceDivisor
;
3277 dst
->_BoundArrays
= src
->_BoundArrays
;
3278 dst
->_EffBoundArrays
= src
->_EffBoundArrays
;
3279 dst
->_EffOffset
= src
->_EffOffset
;
3281 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, src
->BufferObj
);
3285 * Print current vertex object/array info. For debug.
3288 _mesa_print_arrays(struct gl_context
*ctx
)
3290 const struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
3292 fprintf(stderr
, "Array Object %u\n", vao
->Name
);
3294 GLbitfield mask
= vao
->Enabled
;
3296 const gl_vert_attrib i
= u_bit_scan(&mask
);
3297 const struct gl_array_attributes
*array
= &vao
->VertexAttrib
[i
];
3299 const struct gl_vertex_buffer_binding
*binding
=
3300 &vao
->BufferBinding
[array
->BufferBindingIndex
];
3301 const struct gl_buffer_object
*bo
= binding
->BufferObj
;
3303 fprintf(stderr
, " %s: Ptr=%p, Type=%s, Size=%d, ElemSize=%u, "
3304 "Stride=%d, Buffer=%u(Size %lu)\n",
3305 gl_vert_attrib_name((gl_vert_attrib
)i
),
3306 array
->Ptr
, _mesa_enum_to_string(array
->Format
.Type
),
3308 array
->Format
._ElementSize
, binding
->Stride
, bo
->Name
,
3309 (unsigned long) bo
->Size
);
3315 * Initialize vertex array state for given context.
3318 _mesa_init_varray(struct gl_context
*ctx
)
3320 ctx
->Array
.DefaultVAO
= _mesa_new_vao(ctx
, 0);
3321 _mesa_reference_vao(ctx
, &ctx
->Array
.VAO
, ctx
->Array
.DefaultVAO
);
3322 ctx
->Array
._EmptyVAO
= _mesa_new_vao(ctx
, ~0u);
3323 _mesa_reference_vao(ctx
, &ctx
->Array
._DrawVAO
, ctx
->Array
._EmptyVAO
);
3324 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */
3326 ctx
->Array
.Objects
= _mesa_NewHashTable();
3331 * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
3334 delete_arrayobj_cb(GLuint id
, void *data
, void *userData
)
3336 struct gl_vertex_array_object
*vao
= (struct gl_vertex_array_object
*) data
;
3337 struct gl_context
*ctx
= (struct gl_context
*) userData
;
3338 _mesa_delete_vao(ctx
, vao
);
3343 * Free vertex array state for given context.
3346 _mesa_free_varray_data(struct gl_context
*ctx
)
3348 _mesa_HashDeleteAll(ctx
->Array
.Objects
, delete_arrayobj_cb
, ctx
);
3349 _mesa_DeleteHashTable(ctx
->Array
.Objects
);