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 */
31 #include "util/imports.h"
32 #include "bufferobj.h"
36 #include "glformats.h"
44 #include "main/dispatch.h"
47 /** Used to do error checking for GL_EXT_vertex_array_bgra */
51 /** Used to indicate which GL datatypes are accepted by each of the
52 * glVertex/Color/Attrib/EtcPointer() functions.
54 #define BOOL_BIT (1 << 0)
55 #define BYTE_BIT (1 << 1)
56 #define UNSIGNED_BYTE_BIT (1 << 2)
57 #define SHORT_BIT (1 << 3)
58 #define UNSIGNED_SHORT_BIT (1 << 4)
59 #define INT_BIT (1 << 5)
60 #define UNSIGNED_INT_BIT (1 << 6)
61 #define HALF_BIT (1 << 7)
62 #define FLOAT_BIT (1 << 8)
63 #define DOUBLE_BIT (1 << 9)
64 #define FIXED_ES_BIT (1 << 10)
65 #define FIXED_GL_BIT (1 << 11)
66 #define UNSIGNED_INT_2_10_10_10_REV_BIT (1 << 12)
67 #define INT_2_10_10_10_REV_BIT (1 << 13)
68 #define UNSIGNED_INT_10F_11F_11F_REV_BIT (1 << 14)
69 #define ALL_TYPE_BITS ((1 << 15) - 1)
71 #define ATTRIB_FORMAT_TYPES_MASK (BYTE_BIT | UNSIGNED_BYTE_BIT | \
72 SHORT_BIT | UNSIGNED_SHORT_BIT | \
73 INT_BIT | UNSIGNED_INT_BIT | \
74 HALF_BIT | FLOAT_BIT | DOUBLE_BIT | \
76 UNSIGNED_INT_2_10_10_10_REV_BIT | \
77 INT_2_10_10_10_REV_BIT | \
78 UNSIGNED_INT_10F_11F_11F_REV_BIT)
80 #define ATTRIB_IFORMAT_TYPES_MASK (BYTE_BIT | UNSIGNED_BYTE_BIT | \
81 SHORT_BIT | UNSIGNED_SHORT_BIT | \
82 INT_BIT | UNSIGNED_INT_BIT)
84 #define ATTRIB_LFORMAT_TYPES_MASK DOUBLE_BIT
87 /** Convert GL datatype enum into a <type>_BIT value seen above */
89 type_to_bit(const struct gl_context
*ctx
, GLenum type
)
96 case GL_UNSIGNED_BYTE
:
97 return UNSIGNED_BYTE_BIT
;
100 case GL_UNSIGNED_SHORT
:
101 return UNSIGNED_SHORT_BIT
;
104 case GL_UNSIGNED_INT
:
105 return UNSIGNED_INT_BIT
;
107 case GL_HALF_FLOAT_OES
:
108 if (ctx
->Extensions
.ARB_half_float_vertex
)
117 return _mesa_is_desktop_gl(ctx
) ? FIXED_GL_BIT
: FIXED_ES_BIT
;
118 case GL_UNSIGNED_INT_2_10_10_10_REV
:
119 return UNSIGNED_INT_2_10_10_10_REV_BIT
;
120 case GL_INT_2_10_10_10_REV
:
121 return INT_2_10_10_10_REV_BIT
;
122 case GL_UNSIGNED_INT_10F_11F_11F_REV
:
123 return UNSIGNED_INT_10F_11F_11F_REV_BIT
;
131 * Depending on the position and generic0 attributes enable flags select
132 * the one that is used for both attributes.
133 * The generic0 attribute takes precedence.
136 update_attribute_map_mode(const struct gl_context
*ctx
,
137 struct gl_vertex_array_object
*vao
)
140 * There is no need to change the mapping away from the
141 * identity mapping if we are not in compat mode.
143 if (ctx
->API
!= API_OPENGL_COMPAT
)
145 /* The generic0 attribute superseeds the position attribute */
146 const GLbitfield enabled
= vao
->Enabled
;
147 if (enabled
& VERT_BIT_GENERIC0
)
148 vao
->_AttributeMapMode
= ATTRIBUTE_MAP_MODE_GENERIC0
;
149 else if (enabled
& VERT_BIT_POS
)
150 vao
->_AttributeMapMode
= ATTRIBUTE_MAP_MODE_POSITION
;
152 vao
->_AttributeMapMode
= ATTRIBUTE_MAP_MODE_IDENTITY
;
157 * Sets the BufferBindingIndex field for the vertex attribute given by
161 _mesa_vertex_attrib_binding(struct gl_context
*ctx
,
162 struct gl_vertex_array_object
*vao
,
163 gl_vert_attrib attribIndex
,
166 struct gl_array_attributes
*array
= &vao
->VertexAttrib
[attribIndex
];
167 assert(!vao
->SharedAndImmutable
);
169 if (array
->BufferBindingIndex
!= bindingIndex
) {
170 const GLbitfield array_bit
= VERT_BIT(attribIndex
);
172 if (_mesa_is_bufferobj(vao
->BufferBinding
[bindingIndex
].BufferObj
))
173 vao
->VertexAttribBufferMask
|= array_bit
;
175 vao
->VertexAttribBufferMask
&= ~array_bit
;
177 if (vao
->BufferBinding
[bindingIndex
].InstanceDivisor
)
178 vao
->NonZeroDivisorMask
|= array_bit
;
180 vao
->NonZeroDivisorMask
&= ~array_bit
;
182 vao
->BufferBinding
[array
->BufferBindingIndex
]._BoundArrays
&= ~array_bit
;
183 vao
->BufferBinding
[bindingIndex
]._BoundArrays
|= array_bit
;
185 array
->BufferBindingIndex
= bindingIndex
;
187 vao
->NewArrays
|= vao
->Enabled
& array_bit
;
193 * Binds a buffer object to the vertex buffer binding point given by index,
194 * and sets the Offset and Stride fields.
197 _mesa_bind_vertex_buffer(struct gl_context
*ctx
,
198 struct gl_vertex_array_object
*vao
,
200 struct gl_buffer_object
*vbo
,
201 GLintptr offset
, GLsizei stride
)
203 assert(index
< ARRAY_SIZE(vao
->BufferBinding
));
204 assert(!vao
->SharedAndImmutable
);
205 struct gl_vertex_buffer_binding
*binding
= &vao
->BufferBinding
[index
];
207 if (ctx
->Const
.VertexBufferOffsetIsInt32
&& (int)offset
< 0 &&
208 _mesa_is_bufferobj(vbo
)) {
209 /* The offset will be interpreted as a signed int, so make sure
210 * the user supplied offset is not negative (driver limitation).
212 _mesa_warning(ctx
, "Received negative int32 vertex buffer offset. "
213 "(driver limitation)\n");
215 /* We can't disable this binding, so use a non-negative offset value
221 if (binding
->BufferObj
!= vbo
||
222 binding
->Offset
!= offset
||
223 binding
->Stride
!= stride
) {
225 _mesa_reference_buffer_object(ctx
, &binding
->BufferObj
, vbo
);
227 binding
->Offset
= offset
;
228 binding
->Stride
= stride
;
230 if (!_mesa_is_bufferobj(vbo
)) {
231 vao
->VertexAttribBufferMask
&= ~binding
->_BoundArrays
;
233 vao
->VertexAttribBufferMask
|= binding
->_BoundArrays
;
234 vbo
->UsageHistory
|= USAGE_ARRAY_BUFFER
;
237 vao
->NewArrays
|= vao
->Enabled
& binding
->_BoundArrays
;
243 * Sets the InstanceDivisor field in the vertex buffer binding point
244 * given by bindingIndex.
247 vertex_binding_divisor(struct gl_context
*ctx
,
248 struct gl_vertex_array_object
*vao
,
252 struct gl_vertex_buffer_binding
*binding
=
253 &vao
->BufferBinding
[bindingIndex
];
254 assert(!vao
->SharedAndImmutable
);
256 if (binding
->InstanceDivisor
!= divisor
) {
257 binding
->InstanceDivisor
= divisor
;
260 vao
->NonZeroDivisorMask
|= binding
->_BoundArrays
;
262 vao
->NonZeroDivisorMask
&= ~binding
->_BoundArrays
;
264 vao
->NewArrays
|= vao
->Enabled
& binding
->_BoundArrays
;
268 /* vertex_formats[gltype - GL_BYTE][integer*2 + normalized][size - 1] */
269 static const uint16_t vertex_formats
[][4][4] = {
272 PIPE_FORMAT_R8_SSCALED
,
273 PIPE_FORMAT_R8G8_SSCALED
,
274 PIPE_FORMAT_R8G8B8_SSCALED
,
275 PIPE_FORMAT_R8G8B8A8_SSCALED
278 PIPE_FORMAT_R8_SNORM
,
279 PIPE_FORMAT_R8G8_SNORM
,
280 PIPE_FORMAT_R8G8B8_SNORM
,
281 PIPE_FORMAT_R8G8B8A8_SNORM
285 PIPE_FORMAT_R8G8_SINT
,
286 PIPE_FORMAT_R8G8B8_SINT
,
287 PIPE_FORMAT_R8G8B8A8_SINT
290 { /* GL_UNSIGNED_BYTE */
292 PIPE_FORMAT_R8_USCALED
,
293 PIPE_FORMAT_R8G8_USCALED
,
294 PIPE_FORMAT_R8G8B8_USCALED
,
295 PIPE_FORMAT_R8G8B8A8_USCALED
298 PIPE_FORMAT_R8_UNORM
,
299 PIPE_FORMAT_R8G8_UNORM
,
300 PIPE_FORMAT_R8G8B8_UNORM
,
301 PIPE_FORMAT_R8G8B8A8_UNORM
305 PIPE_FORMAT_R8G8_UINT
,
306 PIPE_FORMAT_R8G8B8_UINT
,
307 PIPE_FORMAT_R8G8B8A8_UINT
312 PIPE_FORMAT_R16_SSCALED
,
313 PIPE_FORMAT_R16G16_SSCALED
,
314 PIPE_FORMAT_R16G16B16_SSCALED
,
315 PIPE_FORMAT_R16G16B16A16_SSCALED
318 PIPE_FORMAT_R16_SNORM
,
319 PIPE_FORMAT_R16G16_SNORM
,
320 PIPE_FORMAT_R16G16B16_SNORM
,
321 PIPE_FORMAT_R16G16B16A16_SNORM
324 PIPE_FORMAT_R16_SINT
,
325 PIPE_FORMAT_R16G16_SINT
,
326 PIPE_FORMAT_R16G16B16_SINT
,
327 PIPE_FORMAT_R16G16B16A16_SINT
330 { /* GL_UNSIGNED_SHORT */
332 PIPE_FORMAT_R16_USCALED
,
333 PIPE_FORMAT_R16G16_USCALED
,
334 PIPE_FORMAT_R16G16B16_USCALED
,
335 PIPE_FORMAT_R16G16B16A16_USCALED
338 PIPE_FORMAT_R16_UNORM
,
339 PIPE_FORMAT_R16G16_UNORM
,
340 PIPE_FORMAT_R16G16B16_UNORM
,
341 PIPE_FORMAT_R16G16B16A16_UNORM
344 PIPE_FORMAT_R16_UINT
,
345 PIPE_FORMAT_R16G16_UINT
,
346 PIPE_FORMAT_R16G16B16_UINT
,
347 PIPE_FORMAT_R16G16B16A16_UINT
352 PIPE_FORMAT_R32_SSCALED
,
353 PIPE_FORMAT_R32G32_SSCALED
,
354 PIPE_FORMAT_R32G32B32_SSCALED
,
355 PIPE_FORMAT_R32G32B32A32_SSCALED
358 PIPE_FORMAT_R32_SNORM
,
359 PIPE_FORMAT_R32G32_SNORM
,
360 PIPE_FORMAT_R32G32B32_SNORM
,
361 PIPE_FORMAT_R32G32B32A32_SNORM
364 PIPE_FORMAT_R32_SINT
,
365 PIPE_FORMAT_R32G32_SINT
,
366 PIPE_FORMAT_R32G32B32_SINT
,
367 PIPE_FORMAT_R32G32B32A32_SINT
370 { /* GL_UNSIGNED_INT */
372 PIPE_FORMAT_R32_USCALED
,
373 PIPE_FORMAT_R32G32_USCALED
,
374 PIPE_FORMAT_R32G32B32_USCALED
,
375 PIPE_FORMAT_R32G32B32A32_USCALED
378 PIPE_FORMAT_R32_UNORM
,
379 PIPE_FORMAT_R32G32_UNORM
,
380 PIPE_FORMAT_R32G32B32_UNORM
,
381 PIPE_FORMAT_R32G32B32A32_UNORM
384 PIPE_FORMAT_R32_UINT
,
385 PIPE_FORMAT_R32G32_UINT
,
386 PIPE_FORMAT_R32G32B32_UINT
,
387 PIPE_FORMAT_R32G32B32A32_UINT
392 PIPE_FORMAT_R32_FLOAT
,
393 PIPE_FORMAT_R32G32_FLOAT
,
394 PIPE_FORMAT_R32G32B32_FLOAT
,
395 PIPE_FORMAT_R32G32B32A32_FLOAT
398 PIPE_FORMAT_R32_FLOAT
,
399 PIPE_FORMAT_R32G32_FLOAT
,
400 PIPE_FORMAT_R32G32B32_FLOAT
,
401 PIPE_FORMAT_R32G32B32A32_FLOAT
404 {{0}}, /* GL_2_BYTES */
405 {{0}}, /* GL_3_BYTES */
406 {{0}}, /* GL_4_BYTES */
409 PIPE_FORMAT_R64_FLOAT
,
410 PIPE_FORMAT_R64G64_FLOAT
,
411 PIPE_FORMAT_R64G64B64_FLOAT
,
412 PIPE_FORMAT_R64G64B64A64_FLOAT
415 PIPE_FORMAT_R64_FLOAT
,
416 PIPE_FORMAT_R64G64_FLOAT
,
417 PIPE_FORMAT_R64G64B64_FLOAT
,
418 PIPE_FORMAT_R64G64B64A64_FLOAT
421 { /* GL_HALF_FLOAT */
423 PIPE_FORMAT_R16_FLOAT
,
424 PIPE_FORMAT_R16G16_FLOAT
,
425 PIPE_FORMAT_R16G16B16_FLOAT
,
426 PIPE_FORMAT_R16G16B16A16_FLOAT
429 PIPE_FORMAT_R16_FLOAT
,
430 PIPE_FORMAT_R16G16_FLOAT
,
431 PIPE_FORMAT_R16G16B16_FLOAT
,
432 PIPE_FORMAT_R16G16B16A16_FLOAT
437 PIPE_FORMAT_R32_FIXED
,
438 PIPE_FORMAT_R32G32_FIXED
,
439 PIPE_FORMAT_R32G32B32_FIXED
,
440 PIPE_FORMAT_R32G32B32A32_FIXED
443 PIPE_FORMAT_R32_FIXED
,
444 PIPE_FORMAT_R32G32_FIXED
,
445 PIPE_FORMAT_R32G32B32_FIXED
,
446 PIPE_FORMAT_R32G32B32A32_FIXED
452 * Return a PIPE_FORMAT_x for the given GL datatype and size.
454 static enum pipe_format
455 vertex_format_to_pipe_format(GLubyte size
, GLenum16 type
, GLenum16 format
,
456 GLboolean normalized
, GLboolean integer
,
459 assert(size
>= 1 && size
<= 4);
460 assert(format
== GL_RGBA
|| format
== GL_BGRA
);
462 /* 64-bit attributes are translated by drivers. */
464 return PIPE_FORMAT_NONE
;
467 case GL_HALF_FLOAT_OES
:
468 type
= GL_HALF_FLOAT
;
471 case GL_INT_2_10_10_10_REV
:
472 assert(size
== 4 && !integer
);
474 if (format
== GL_BGRA
) {
476 return PIPE_FORMAT_B10G10R10A2_SNORM
;
478 return PIPE_FORMAT_B10G10R10A2_SSCALED
;
481 return PIPE_FORMAT_R10G10B10A2_SNORM
;
483 return PIPE_FORMAT_R10G10B10A2_SSCALED
;
487 case GL_UNSIGNED_INT_2_10_10_10_REV
:
488 assert(size
== 4 && !integer
);
490 if (format
== GL_BGRA
) {
492 return PIPE_FORMAT_B10G10R10A2_UNORM
;
494 return PIPE_FORMAT_B10G10R10A2_USCALED
;
497 return PIPE_FORMAT_R10G10B10A2_UNORM
;
499 return PIPE_FORMAT_R10G10B10A2_USCALED
;
503 case GL_UNSIGNED_INT_10F_11F_11F_REV
:
504 assert(size
== 3 && !integer
&& format
== GL_RGBA
);
505 return PIPE_FORMAT_R11G11B10_FLOAT
;
507 case GL_UNSIGNED_BYTE
:
508 if (format
== GL_BGRA
) {
509 /* this is an odd-ball case */
511 return PIPE_FORMAT_B8G8R8A8_UNORM
;
516 unsigned index
= integer
*2 + normalized
;
518 assert(type
>= GL_BYTE
&& type
<= GL_FIXED
);
519 return vertex_formats
[type
- GL_BYTE
][index
][size
-1];
523 _mesa_set_vertex_format(struct gl_vertex_format
*vertex_format
,
524 GLubyte size
, GLenum16 type
, GLenum16 format
,
525 GLboolean normalized
, GLboolean integer
,
529 vertex_format
->Type
= type
;
530 vertex_format
->Format
= format
;
531 vertex_format
->Size
= size
;
532 vertex_format
->Normalized
= normalized
;
533 vertex_format
->Integer
= integer
;
534 vertex_format
->Doubles
= doubles
;
535 vertex_format
->_ElementSize
= _mesa_bytes_per_vertex_attrib(size
, type
);
536 assert(vertex_format
->_ElementSize
<= 4*sizeof(double));
537 vertex_format
->_PipeFormat
=
538 vertex_format_to_pipe_format(size
, type
, format
, normalized
, integer
,
544 * Examine the API profile and extensions to determine which types are legal
545 * for vertex arrays. This is called once from update_array_format().
548 get_legal_types_mask(const struct gl_context
*ctx
)
550 GLbitfield legalTypesMask
= ALL_TYPE_BITS
;
552 if (_mesa_is_gles(ctx
)) {
553 legalTypesMask
&= ~(FIXED_GL_BIT
|
555 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
557 /* GL_INT and GL_UNSIGNED_INT data is not allowed in OpenGL ES until
558 * 3.0. The 2_10_10_10 types are added in OpenGL ES 3.0 or
559 * GL_OES_vertex_type_10_10_10_2. GL_HALF_FLOAT data is not allowed
560 * until 3.0 or with the GL_OES_vertex_half float extension, which isn't
561 * quite as trivial as we'd like because it uses a different enum value
562 * for GL_HALF_FLOAT_OES.
564 if (ctx
->Version
< 30) {
565 legalTypesMask
&= ~(UNSIGNED_INT_BIT
|
567 UNSIGNED_INT_2_10_10_10_REV_BIT
|
568 INT_2_10_10_10_REV_BIT
);
570 if (!_mesa_has_OES_vertex_half_float(ctx
))
571 legalTypesMask
&= ~HALF_BIT
;
575 legalTypesMask
&= ~FIXED_ES_BIT
;
577 if (!ctx
->Extensions
.ARB_ES2_compatibility
)
578 legalTypesMask
&= ~FIXED_GL_BIT
;
580 if (!ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
)
581 legalTypesMask
&= ~(UNSIGNED_INT_2_10_10_10_REV_BIT
|
582 INT_2_10_10_10_REV_BIT
);
584 if (!ctx
->Extensions
.ARB_vertex_type_10f_11f_11f_rev
)
585 legalTypesMask
&= ~UNSIGNED_INT_10F_11F_11F_REV_BIT
;
588 return legalTypesMask
;
592 get_array_format(const struct gl_context
*ctx
, GLint sizeMax
, GLint
*size
)
594 GLenum format
= GL_RGBA
;
596 /* Do size parameter checking.
597 * If sizeMax = BGRA_OR_4 it means that size = GL_BGRA is legal and
598 * must be handled specially.
600 if (ctx
->Extensions
.EXT_vertex_array_bgra
&& sizeMax
== BGRA_OR_4
&&
611 * \param attrib The index of the attribute array
612 * \param size Components per element (1, 2, 3 or 4)
613 * \param type Datatype of each component (GL_FLOAT, GL_INT, etc)
614 * \param format Either GL_RGBA or GL_BGRA.
615 * \param normalized Whether integer types are converted to floats in [-1, 1]
616 * \param integer Integer-valued values (will not be normalized to [-1, 1])
617 * \param doubles Double values not reduced to floats
618 * \param relativeOffset Offset of the first element relative to the binding
622 _mesa_update_array_format(struct gl_context
*ctx
,
623 struct gl_vertex_array_object
*vao
,
624 gl_vert_attrib attrib
, GLint size
, GLenum type
,
625 GLenum format
, GLboolean normalized
,
626 GLboolean integer
, GLboolean doubles
,
627 GLuint relativeOffset
)
629 struct gl_array_attributes
*const array
= &vao
->VertexAttrib
[attrib
];
631 assert(!vao
->SharedAndImmutable
);
634 array
->RelativeOffset
= relativeOffset
;
635 _mesa_set_vertex_format(&array
->Format
, size
, type
, format
,
636 normalized
, integer
, doubles
);
638 vao
->NewArrays
|= vao
->Enabled
& VERT_BIT(attrib
);
642 * Does error checking of the format in an attrib array.
644 * Called by *Pointer() and VertexAttrib*Format().
646 * \param func Name of calling function used for error reporting
647 * \param attrib The index of the attribute array
648 * \param legalTypes Bitmask of *_BIT above indicating legal datatypes
649 * \param sizeMin Min allowable size value
650 * \param sizeMax Max allowable size value (may also be BGRA_OR_4)
651 * \param size Components per element (1, 2, 3 or 4)
652 * \param type Datatype of each component (GL_FLOAT, GL_INT, etc)
653 * \param normalized Whether integer types are converted to floats in [-1, 1]
654 * \param integer Integer-valued values (will not be normalized to [-1, 1])
655 * \param doubles Double values not reduced to floats
656 * \param relativeOffset Offset of the first element relative to the binding offset.
657 * \return bool True if validation is successful, False otherwise.
660 validate_array_format(struct gl_context
*ctx
, const char *func
,
661 struct gl_vertex_array_object
*vao
,
662 GLuint attrib
, GLbitfield legalTypesMask
,
663 GLint sizeMin
, GLint sizeMax
,
664 GLint size
, GLenum type
, GLboolean normalized
,
665 GLboolean integer
, GLboolean doubles
,
666 GLuint relativeOffset
, GLenum format
)
670 /* at most, one of these bools can be true */
671 assert((int) normalized
+ (int) integer
+ (int) doubles
<= 1);
673 if (ctx
->Array
.LegalTypesMask
== 0 || ctx
->Array
.LegalTypesMaskAPI
!= ctx
->API
) {
674 /* Compute the LegalTypesMask only once, unless the context API has
675 * changed, in which case we want to compute it again. We can't do this
676 * in _mesa_init_varrays() below because extensions are not yet enabled
679 ctx
->Array
.LegalTypesMask
= get_legal_types_mask(ctx
);
680 ctx
->Array
.LegalTypesMaskAPI
= ctx
->API
;
683 legalTypesMask
&= ctx
->Array
.LegalTypesMask
;
685 if (_mesa_is_gles(ctx
) && sizeMax
== BGRA_OR_4
) {
686 /* BGRA ordering is not supported in ES contexts.
691 typeBit
= type_to_bit(ctx
, type
);
692 if (typeBit
== 0x0 || (typeBit
& legalTypesMask
) == 0x0) {
693 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(type = %s)",
694 func
, _mesa_enum_to_string(type
));
698 if (format
== GL_BGRA
) {
699 /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
701 * "An INVALID_OPERATION error is generated under any of the following
704 * • size is BGRA and type is not UNSIGNED_BYTE, INT_2_10_10_10_REV
705 * or UNSIGNED_INT_2_10_10_10_REV;
707 * • size is BGRA and normalized is FALSE;"
709 bool bgra_error
= false;
711 if (ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
) {
712 if (type
!= GL_UNSIGNED_INT_2_10_10_10_REV
&&
713 type
!= GL_INT_2_10_10_10_REV
&&
714 type
!= GL_UNSIGNED_BYTE
)
716 } else if (type
!= GL_UNSIGNED_BYTE
)
720 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=GL_BGRA and type=%s)",
721 func
, _mesa_enum_to_string(type
));
726 _mesa_error(ctx
, GL_INVALID_OPERATION
,
727 "%s(size=GL_BGRA and normalized=GL_FALSE)", func
);
731 else if (size
< sizeMin
|| size
> sizeMax
|| size
> 4) {
732 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(size=%d)", func
, size
);
736 if (ctx
->Extensions
.ARB_vertex_type_2_10_10_10_rev
&&
737 (type
== GL_UNSIGNED_INT_2_10_10_10_REV
||
738 type
== GL_INT_2_10_10_10_REV
) && size
!= 4) {
739 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=%d)", func
, size
);
743 /* The ARB_vertex_attrib_binding_spec says:
745 * An INVALID_VALUE error is generated if <relativeoffset> is larger than
746 * the value of MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.
748 if (relativeOffset
> ctx
->Const
.MaxVertexAttribRelativeOffset
) {
749 _mesa_error(ctx
, GL_INVALID_VALUE
,
750 "%s(relativeOffset=%d > "
751 "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET)",
752 func
, relativeOffset
);
756 if (ctx
->Extensions
.ARB_vertex_type_10f_11f_11f_rev
&&
757 type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&& size
!= 3) {
758 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(size=%d)", func
, size
);
766 * Do error checking for glVertex/Color/TexCoord/...Pointer functions.
768 * \param func name of calling function used for error reporting
769 * \param vao the vao to update
770 * \param obj the bound buffer object
771 * \param attrib the attribute array index to update
772 * \param legalTypes bitmask of *_BIT above indicating legal datatypes
773 * \param sizeMin min allowable size value
774 * \param sizeMax max allowable size value (may also be BGRA_OR_4)
775 * \param size components per element (1, 2, 3 or 4)
776 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
777 * \param stride stride between elements, in elements
778 * \param normalized are integer types converted to floats in [-1, 1]?
779 * \param integer integer-valued values (will not be normalized to [-1,1])
780 * \param doubles Double values not reduced to floats
781 * \param ptr the address (or offset inside VBO) of the array data
784 validate_array(struct gl_context
*ctx
, const char *func
,
785 struct gl_vertex_array_object
*vao
,
786 struct gl_buffer_object
*obj
,
787 GLuint attrib
, GLbitfield legalTypesMask
,
788 GLint sizeMin
, GLint sizeMax
,
789 GLint size
, GLenum type
, GLsizei stride
,
790 GLboolean normalized
, GLboolean integer
, GLboolean doubles
,
793 /* Page 407 (page 423 of the PDF) of the OpenGL 3.0 spec says:
795 * "Client vertex arrays - all vertex array attribute pointers must
796 * refer to buffer objects (section 2.9.2). The default vertex array
797 * object (the name zero) is also deprecated. Calling
798 * VertexAttribPointer when no buffer object or no vertex array object
799 * is bound will generate an INVALID_OPERATION error..."
801 * The check for VBOs is handled below.
803 if (ctx
->API
== API_OPENGL_CORE
&& (vao
== ctx
->Array
.DefaultVAO
)) {
804 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(no array object bound)",
810 _mesa_error( ctx
, GL_INVALID_VALUE
, "%s(stride=%d)", func
, stride
);
814 if (_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 44 &&
815 stride
> ctx
->Const
.MaxVertexAttribStride
) {
816 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride=%d > "
817 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, stride
);
821 /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says:
823 * "An INVALID_OPERATION error is generated under any of the following
828 * * any of the *Pointer commands specifying the location and
829 * organization of vertex array data are called while zero is bound
830 * to the ARRAY_BUFFER buffer object binding point (see section
831 * 2.9.6), and the pointer argument is not NULL."
833 if (ptr
!= NULL
&& vao
!= ctx
->Array
.DefaultVAO
&&
834 !_mesa_is_bufferobj(obj
)) {
835 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(non-VBO array)", func
);
842 validate_array_and_format(struct gl_context
*ctx
, const char *func
,
843 struct gl_vertex_array_object
*vao
,
844 struct gl_buffer_object
*obj
,
845 GLuint attrib
, GLbitfield legalTypes
,
846 GLint sizeMin
, GLint sizeMax
,
847 GLint size
, GLenum type
, GLsizei stride
,
848 GLboolean normalized
, GLboolean integer
,
849 GLboolean doubles
, GLenum format
, const GLvoid
*ptr
)
851 validate_array(ctx
, func
, vao
, obj
, attrib
, legalTypes
, sizeMin
, sizeMax
,
852 size
, type
, stride
, normalized
, integer
, doubles
, ptr
);
854 return validate_array_format(ctx
, func
, vao
, attrib
, legalTypes
, sizeMin
,
855 sizeMax
, size
, type
, normalized
, integer
,
861 * Update state for glVertex/Color/TexCoord/...Pointer functions.
863 * \param vao the vao to update
864 * \param obj the bound buffer object
865 * \param attrib the attribute array index to update
866 * \param format Either GL_RGBA or GL_BGRA.
867 * \param sizeMax max allowable size value (may also be BGRA_OR_4)
868 * \param size components per element (1, 2, 3 or 4)
869 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
870 * \param stride stride between elements, in elements
871 * \param normalized are integer types converted to floats in [-1, 1]?
872 * \param integer integer-valued values (will not be normalized to [-1,1])
873 * \param doubles Double values not reduced to floats
874 * \param ptr the address (or offset inside VBO) of the array data
877 update_array(struct gl_context
*ctx
,
878 struct gl_vertex_array_object
*vao
,
879 struct gl_buffer_object
*obj
,
880 GLuint attrib
, GLenum format
,
882 GLint size
, GLenum type
, GLsizei stride
,
883 GLboolean normalized
, GLboolean integer
, GLboolean doubles
,
886 _mesa_update_array_format(ctx
, vao
, attrib
, size
, type
, format
,
887 normalized
, integer
, doubles
, 0);
889 /* Reset the vertex attrib binding */
890 _mesa_vertex_attrib_binding(ctx
, vao
, attrib
, attrib
);
892 /* The Stride and Ptr fields are not set by update_array_format() */
893 struct gl_array_attributes
*array
= &vao
->VertexAttrib
[attrib
];
894 array
->Stride
= stride
;
895 /* For updating the pointer we would need to add the vao->NewArrays flag
896 * to the VAO. But but that is done already unconditionally in
897 * _mesa_update_array_format called above.
899 assert((vao
->NewArrays
| ~vao
->Enabled
) & VERT_BIT(attrib
));
902 /* Update the vertex buffer binding */
903 GLsizei effectiveStride
= stride
!= 0 ?
904 stride
: array
->Format
._ElementSize
;
905 _mesa_bind_vertex_buffer(ctx
, vao
, attrib
,
911 /* Helper function for all EXT_direct_state_access glVertexArray* functions */
913 _lookup_vao_and_vbo_dsa(struct gl_context
*ctx
,
914 GLuint vaobj
, GLuint buffer
,
916 struct gl_vertex_array_object
** vao
,
917 struct gl_buffer_object
** vbo
,
920 *vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true, caller
);
925 *vbo
= _mesa_lookup_bufferobj(ctx
, buffer
);
926 if (!_mesa_handle_bind_buffer_gen(ctx
, buffer
, vbo
, caller
))
930 _mesa_error(ctx
, GL_INVALID_VALUE
,
931 "%s(negative offset with non-0 buffer)", caller
);
935 *vbo
= ctx
->Shared
->NullBufferObj
;
943 _mesa_VertexPointer_no_error(GLint size
, GLenum type
, GLsizei stride
,
946 GET_CURRENT_CONTEXT(ctx
);
948 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
949 VERT_ATTRIB_POS
, GL_RGBA
, 4, size
, type
, stride
,
950 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
955 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
957 GET_CURRENT_CONTEXT(ctx
);
959 GLenum format
= GL_RGBA
;
960 GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
961 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
962 : (SHORT_BIT
| INT_BIT
| FLOAT_BIT
|
963 DOUBLE_BIT
| HALF_BIT
|
964 UNSIGNED_INT_2_10_10_10_REV_BIT
|
965 INT_2_10_10_10_REV_BIT
);
967 if (!validate_array_and_format(ctx
, "glVertexPointer",
968 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
969 VERT_ATTRIB_POS
, legalTypes
, 2, 4, size
,
970 type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
,
974 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
975 VERT_ATTRIB_POS
, format
, 4, size
, type
, stride
,
976 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
981 _mesa_VertexArrayVertexOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
982 GLenum type
, GLsizei stride
, GLintptr offset
)
984 GET_CURRENT_CONTEXT(ctx
);
986 GLenum format
= GL_RGBA
;
987 GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
988 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
989 : (SHORT_BIT
| INT_BIT
| FLOAT_BIT
|
990 DOUBLE_BIT
| HALF_BIT
|
991 UNSIGNED_INT_2_10_10_10_REV_BIT
|
992 INT_2_10_10_10_REV_BIT
);
994 struct gl_vertex_array_object
* vao
;
995 struct gl_buffer_object
* vbo
;
997 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
999 "glVertexArrayVertexOffsetEXT"))
1002 if (!validate_array_and_format(ctx
, "glVertexArrayVertexOffsetEXT",
1004 VERT_ATTRIB_POS
, legalTypes
, 2, 4, size
,
1005 type
, stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
,
1006 format
, (void*) offset
))
1009 update_array(ctx
, vao
, vbo
,
1010 VERT_ATTRIB_POS
, format
, 4, size
, type
, stride
,
1011 GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1016 _mesa_NormalPointer_no_error(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1018 GET_CURRENT_CONTEXT(ctx
);
1020 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1021 VERT_ATTRIB_NORMAL
, GL_RGBA
, 3, 3, type
, stride
, GL_TRUE
,
1022 GL_FALSE
, GL_FALSE
, ptr
);
1027 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1029 GET_CURRENT_CONTEXT(ctx
);
1031 GLenum format
= GL_RGBA
;
1032 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1033 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1034 : (BYTE_BIT
| SHORT_BIT
| INT_BIT
|
1035 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1036 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1037 INT_2_10_10_10_REV_BIT
);
1039 if (!validate_array_and_format(ctx
, "glNormalPointer",
1040 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1041 VERT_ATTRIB_NORMAL
, legalTypes
, 3, 3, 3,
1042 type
, stride
, GL_TRUE
, GL_FALSE
,
1043 GL_FALSE
, format
, ptr
))
1046 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1047 VERT_ATTRIB_NORMAL
, format
, 3, 3, type
, stride
, GL_TRUE
,
1048 GL_FALSE
, GL_FALSE
, ptr
);
1053 _mesa_VertexArrayNormalOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum type
,
1054 GLsizei stride
, GLintptr offset
)
1056 GET_CURRENT_CONTEXT(ctx
);
1058 GLenum format
= GL_RGBA
;
1059 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1060 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1061 : (BYTE_BIT
| SHORT_BIT
| INT_BIT
|
1062 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1063 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1064 INT_2_10_10_10_REV_BIT
);
1066 struct gl_vertex_array_object
* vao
;
1067 struct gl_buffer_object
* vbo
;
1069 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1074 if (!validate_array_and_format(ctx
, "glNormalPointer",
1076 VERT_ATTRIB_NORMAL
, legalTypes
, 3, 3, 3,
1077 type
, stride
, GL_TRUE
, GL_FALSE
,
1078 GL_FALSE
, format
, (void*) offset
))
1081 update_array(ctx
, vao
, vbo
,
1082 VERT_ATTRIB_NORMAL
, format
, 3, 3, type
, stride
, GL_TRUE
,
1083 GL_FALSE
, GL_FALSE
, (void*) offset
);
1088 _mesa_ColorPointer_no_error(GLint size
, GLenum type
, GLsizei stride
,
1091 GET_CURRENT_CONTEXT(ctx
);
1093 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1094 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1095 VERT_ATTRIB_COLOR0
, format
, BGRA_OR_4
, size
,
1096 type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
1101 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1103 GET_CURRENT_CONTEXT(ctx
);
1104 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 4 : 3;
1106 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1107 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1108 ? (UNSIGNED_BYTE_BIT
| HALF_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1109 : (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1110 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1111 INT_BIT
| UNSIGNED_INT_BIT
|
1112 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1113 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1114 INT_2_10_10_10_REV_BIT
);
1116 if (!validate_array_and_format(ctx
, "glColorPointer",
1117 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1118 VERT_ATTRIB_COLOR0
, legalTypes
, sizeMin
,
1119 BGRA_OR_4
, size
, type
, stride
, GL_TRUE
,
1120 GL_FALSE
, GL_FALSE
, format
, ptr
))
1123 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1124 VERT_ATTRIB_COLOR0
, format
, BGRA_OR_4
, size
,
1125 type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
1130 _mesa_VertexArrayColorOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
1131 GLenum type
, GLsizei stride
, GLintptr offset
)
1133 GET_CURRENT_CONTEXT(ctx
);
1134 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 4 : 3;
1136 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1137 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1138 ? (UNSIGNED_BYTE_BIT
| HALF_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1139 : (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1140 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1141 INT_BIT
| UNSIGNED_INT_BIT
|
1142 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1143 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1144 INT_2_10_10_10_REV_BIT
);
1146 struct gl_vertex_array_object
* vao
;
1147 struct gl_buffer_object
* vbo
;
1149 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1151 "glVertexArrayColorOffsetEXT"))
1154 if (!validate_array_and_format(ctx
, "glVertexArrayColorOffsetEXT",
1156 VERT_ATTRIB_COLOR0
, legalTypes
, sizeMin
,
1157 BGRA_OR_4
, size
, type
, stride
, GL_TRUE
,
1158 GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1161 update_array(ctx
, vao
, vbo
,
1162 VERT_ATTRIB_COLOR0
, format
, BGRA_OR_4
, size
,
1163 type
, stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1168 _mesa_FogCoordPointer_no_error(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1170 GET_CURRENT_CONTEXT(ctx
);
1172 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1173 VERT_ATTRIB_FOG
, GL_RGBA
, 1, 1, type
, stride
, GL_FALSE
,
1174 GL_FALSE
, GL_FALSE
, ptr
);
1179 _mesa_FogCoordPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1181 GET_CURRENT_CONTEXT(ctx
);
1183 GLenum format
= GL_RGBA
;
1184 const GLbitfield legalTypes
= (HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
);
1186 if (!validate_array_and_format(ctx
, "glFogCoordPointer",
1187 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1188 VERT_ATTRIB_FOG
, legalTypes
, 1, 1, 1,
1189 type
, stride
, GL_FALSE
, GL_FALSE
,
1190 GL_FALSE
, format
, ptr
))
1193 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1194 VERT_ATTRIB_FOG
, format
, 1, 1, type
, stride
, GL_FALSE
,
1195 GL_FALSE
, GL_FALSE
, ptr
);
1200 _mesa_VertexArrayFogCoordOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum type
,
1201 GLsizei stride
, GLintptr offset
)
1203 GET_CURRENT_CONTEXT(ctx
);
1205 GLenum format
= GL_RGBA
;
1206 const GLbitfield legalTypes
= (HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
);
1208 struct gl_vertex_array_object
* vao
;
1209 struct gl_buffer_object
* vbo
;
1211 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1213 "glVertexArrayFogCoordOffsetEXT"))
1216 if (!validate_array_and_format(ctx
, "glVertexArrayFogCoordOffsetEXT",
1218 VERT_ATTRIB_FOG
, legalTypes
, 1, 1, 1,
1219 type
, stride
, GL_FALSE
, GL_FALSE
,
1220 GL_FALSE
, format
, (void*) offset
))
1223 update_array(ctx
, vao
, vbo
,
1224 VERT_ATTRIB_FOG
, format
, 1, 1, type
, stride
, GL_FALSE
,
1225 GL_FALSE
, GL_FALSE
, (void*) offset
);
1230 _mesa_IndexPointer_no_error(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1232 GET_CURRENT_CONTEXT(ctx
);
1234 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1235 VERT_ATTRIB_COLOR_INDEX
, GL_RGBA
, 1, 1, type
, stride
,
1236 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1241 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1243 GET_CURRENT_CONTEXT(ctx
);
1245 GLenum format
= GL_RGBA
;
1246 const GLbitfield legalTypes
= (UNSIGNED_BYTE_BIT
| SHORT_BIT
| INT_BIT
|
1247 FLOAT_BIT
| DOUBLE_BIT
);
1249 if (!validate_array_and_format(ctx
, "glIndexPointer",
1250 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1251 VERT_ATTRIB_COLOR_INDEX
,
1252 legalTypes
, 1, 1, 1, type
, stride
,
1253 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1256 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1257 VERT_ATTRIB_COLOR_INDEX
, format
, 1, 1, type
, stride
,
1258 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1263 _mesa_VertexArrayIndexOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum type
,
1264 GLsizei stride
, GLintptr offset
)
1266 GET_CURRENT_CONTEXT(ctx
);
1268 GLenum format
= GL_RGBA
;
1269 const GLbitfield legalTypes
= (UNSIGNED_BYTE_BIT
| SHORT_BIT
| INT_BIT
|
1270 FLOAT_BIT
| DOUBLE_BIT
);
1272 struct gl_vertex_array_object
* vao
;
1273 struct gl_buffer_object
* vbo
;
1275 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1277 "glVertexArrayIndexOffsetEXT"))
1280 if (!validate_array_and_format(ctx
, "glVertexArrayIndexOffsetEXT",
1282 VERT_ATTRIB_COLOR_INDEX
,
1283 legalTypes
, 1, 1, 1, type
, stride
,
1284 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1287 update_array(ctx
, vao
, vbo
,
1288 VERT_ATTRIB_COLOR_INDEX
, format
, 1, 1, type
, stride
,
1289 GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1294 _mesa_SecondaryColorPointer_no_error(GLint size
, GLenum type
,
1295 GLsizei stride
, const GLvoid
*ptr
)
1297 GET_CURRENT_CONTEXT(ctx
);
1299 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1300 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1301 VERT_ATTRIB_COLOR1
, format
, BGRA_OR_4
, size
, type
,
1302 stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
1307 _mesa_SecondaryColorPointer(GLint size
, GLenum type
,
1308 GLsizei stride
, const GLvoid
*ptr
)
1310 GET_CURRENT_CONTEXT(ctx
);
1312 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1313 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1314 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1315 INT_BIT
| UNSIGNED_INT_BIT
|
1316 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1317 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1318 INT_2_10_10_10_REV_BIT
);
1320 if (!validate_array_and_format(ctx
, "glSecondaryColorPointer",
1321 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1322 VERT_ATTRIB_COLOR1
, legalTypes
, 3,
1323 BGRA_OR_4
, size
, type
, stride
,
1324 GL_TRUE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1327 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1328 VERT_ATTRIB_COLOR1
, format
, BGRA_OR_4
, size
, type
,
1329 stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, ptr
);
1334 _mesa_VertexArraySecondaryColorOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
1335 GLenum type
, GLsizei stride
, GLintptr offset
)
1337 GET_CURRENT_CONTEXT(ctx
);
1339 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1340 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1341 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1342 INT_BIT
| UNSIGNED_INT_BIT
|
1343 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1344 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1345 INT_2_10_10_10_REV_BIT
);
1347 struct gl_vertex_array_object
* vao
;
1348 struct gl_buffer_object
* vbo
;
1350 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1352 "glVertexArraySecondaryColorOffsetEXT"))
1355 if (!validate_array_and_format(ctx
, "glVertexArraySecondaryColorOffsetEXT",
1357 VERT_ATTRIB_COLOR1
, legalTypes
, 3,
1358 BGRA_OR_4
, size
, type
, stride
,
1359 GL_TRUE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1362 update_array(ctx
, vao
, vbo
,
1363 VERT_ATTRIB_COLOR1
, format
, BGRA_OR_4
, size
, type
,
1364 stride
, GL_TRUE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1369 _mesa_TexCoordPointer_no_error(GLint size
, GLenum type
, GLsizei stride
,
1372 GET_CURRENT_CONTEXT(ctx
);
1373 const GLuint unit
= ctx
->Array
.ActiveTexture
;
1375 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1376 VERT_ATTRIB_TEX(unit
), GL_RGBA
, 4, size
, type
,
1377 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1382 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
1385 GET_CURRENT_CONTEXT(ctx
);
1386 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
1387 const GLuint unit
= ctx
->Array
.ActiveTexture
;
1389 GLenum format
= GL_RGBA
;
1390 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1391 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1392 : (SHORT_BIT
| INT_BIT
|
1393 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1394 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1395 INT_2_10_10_10_REV_BIT
);
1397 if (!validate_array_and_format(ctx
, "glTexCoordPointer",
1398 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1399 VERT_ATTRIB_TEX(unit
), legalTypes
,
1400 sizeMin
, 4, size
, type
, stride
,
1401 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1404 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1405 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
1406 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1411 _mesa_VertexArrayTexCoordOffsetEXT(GLuint vaobj
, GLuint buffer
, GLint size
,
1412 GLenum type
, GLsizei stride
, GLintptr offset
)
1414 GET_CURRENT_CONTEXT(ctx
);
1415 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
1416 const GLuint unit
= ctx
->Array
.ActiveTexture
;
1418 GLenum format
= GL_RGBA
;
1419 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1420 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1421 : (SHORT_BIT
| INT_BIT
|
1422 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1423 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1424 INT_2_10_10_10_REV_BIT
);
1426 struct gl_vertex_array_object
* vao
;
1427 struct gl_buffer_object
* vbo
;
1429 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1431 "glVertexArrayTexCoordOffsetEXT"))
1434 if (!validate_array_and_format(ctx
, "glVertexArrayTexCoordOffsetEXT",
1436 VERT_ATTRIB_TEX(unit
), legalTypes
,
1437 sizeMin
, 4, size
, type
, stride
,
1438 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1441 update_array(ctx
, vao
, vbo
,
1442 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
1443 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1448 _mesa_VertexArrayMultiTexCoordOffsetEXT(GLuint vaobj
, GLuint buffer
, GLenum texunit
,
1449 GLint size
, GLenum type
, GLsizei stride
,
1452 GET_CURRENT_CONTEXT(ctx
);
1453 const GLint sizeMin
= (ctx
->API
== API_OPENGLES
) ? 2 : 1;
1454 const GLuint unit
= texunit
- GL_TEXTURE0
;
1456 GLenum format
= GL_RGBA
;
1457 const GLbitfield legalTypes
= (ctx
->API
== API_OPENGLES
)
1458 ? (BYTE_BIT
| SHORT_BIT
| FLOAT_BIT
| FIXED_ES_BIT
)
1459 : (SHORT_BIT
| INT_BIT
|
1460 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1461 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1462 INT_2_10_10_10_REV_BIT
);
1464 struct gl_vertex_array_object
* vao
;
1465 struct gl_buffer_object
* vbo
;
1467 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1469 "glVertexArrayMultiTexCoordOffsetEXT"))
1472 if (unit
>= ctx
->Const
.MaxCombinedTextureImageUnits
) {
1473 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexArrayMultiTexCoordOffsetEXT(texunit=%d)",
1478 if (!validate_array_and_format(ctx
, "glVertexArrayMultiTexCoordOffsetEXT",
1480 VERT_ATTRIB_TEX(unit
), legalTypes
,
1481 sizeMin
, 4, size
, type
, stride
,
1482 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1485 update_array(ctx
, vao
, vbo
,
1486 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
1487 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1492 _mesa_EdgeFlagPointer_no_error(GLsizei stride
, const GLvoid
*ptr
)
1494 /* this is the same type that glEdgeFlag uses */
1495 const GLboolean integer
= GL_FALSE
;
1496 GET_CURRENT_CONTEXT(ctx
);
1498 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1499 VERT_ATTRIB_EDGEFLAG
, GL_RGBA
, 1, 1, GL_UNSIGNED_BYTE
,
1500 stride
, GL_FALSE
, integer
, GL_FALSE
, ptr
);
1505 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
1507 /* this is the same type that glEdgeFlag uses */
1508 const GLboolean integer
= GL_FALSE
;
1509 GET_CURRENT_CONTEXT(ctx
);
1511 GLenum format
= GL_RGBA
;
1512 const GLbitfield legalTypes
= UNSIGNED_BYTE_BIT
;
1514 if (!validate_array_and_format(ctx
, "glEdgeFlagPointer",
1515 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1516 VERT_ATTRIB_EDGEFLAG
, legalTypes
,
1517 1, 1, 1, GL_UNSIGNED_BYTE
, stride
,
1518 GL_FALSE
, integer
, GL_FALSE
, format
, ptr
))
1521 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1522 VERT_ATTRIB_EDGEFLAG
, format
, 1, 1, GL_UNSIGNED_BYTE
,
1523 stride
, GL_FALSE
, integer
, GL_FALSE
, ptr
);
1528 _mesa_VertexArrayEdgeFlagOffsetEXT(GLuint vaobj
, GLuint buffer
, GLsizei stride
,
1531 /* this is the same type that glEdgeFlag uses */
1532 const GLboolean integer
= GL_FALSE
;
1533 GET_CURRENT_CONTEXT(ctx
);
1535 GLenum format
= GL_RGBA
;
1536 const GLbitfield legalTypes
= UNSIGNED_BYTE_BIT
;
1538 struct gl_vertex_array_object
* vao
;
1539 struct gl_buffer_object
* vbo
;
1541 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1543 "glVertexArrayEdgeFlagOffsetEXT"))
1546 if (!validate_array_and_format(ctx
, "glVertexArrayEdgeFlagOffsetEXT",
1548 VERT_ATTRIB_EDGEFLAG
, legalTypes
,
1549 1, 1, 1, GL_UNSIGNED_BYTE
, stride
,
1550 GL_FALSE
, integer
, GL_FALSE
, format
, (void*) offset
))
1553 update_array(ctx
, vao
, vbo
,
1554 VERT_ATTRIB_EDGEFLAG
, format
, 1, 1, GL_UNSIGNED_BYTE
,
1555 stride
, GL_FALSE
, integer
, GL_FALSE
, (void*) offset
);
1560 _mesa_PointSizePointerOES_no_error(GLenum type
, GLsizei stride
,
1563 GET_CURRENT_CONTEXT(ctx
);
1565 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1566 VERT_ATTRIB_POINT_SIZE
, GL_RGBA
, 1, 1, type
, stride
,
1567 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1572 _mesa_PointSizePointerOES(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
1574 GET_CURRENT_CONTEXT(ctx
);
1576 GLenum format
= GL_RGBA
;
1577 if (ctx
->API
!= API_OPENGLES
) {
1578 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1579 "glPointSizePointer(ES 1.x only)");
1583 const GLbitfield legalTypes
= (FLOAT_BIT
| FIXED_ES_BIT
);
1585 if (!validate_array_and_format(ctx
, "glPointSizePointer",
1586 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1587 VERT_ATTRIB_POINT_SIZE
, legalTypes
,
1588 1, 1, 1, type
, stride
, GL_FALSE
, GL_FALSE
,
1589 GL_FALSE
, format
, ptr
))
1592 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1593 VERT_ATTRIB_POINT_SIZE
, format
, 1, 1, type
, stride
,
1594 GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
1599 _mesa_VertexAttribPointer_no_error(GLuint index
, GLint size
, GLenum type
,
1600 GLboolean normalized
,
1601 GLsizei stride
, const GLvoid
*ptr
)
1603 GET_CURRENT_CONTEXT(ctx
);
1605 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1606 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1607 VERT_ATTRIB_GENERIC(index
), format
, BGRA_OR_4
,
1608 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, ptr
);
1613 * Set a generic vertex attribute array.
1614 * Note that these arrays DO NOT alias the conventional GL vertex arrays
1615 * (position, normal, color, fog, texcoord, etc).
1618 _mesa_VertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
1619 GLboolean normalized
,
1620 GLsizei stride
, const GLvoid
*ptr
)
1622 GET_CURRENT_CONTEXT(ctx
);
1624 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1625 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1626 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(idx)");
1630 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1631 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1632 INT_BIT
| UNSIGNED_INT_BIT
|
1633 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1634 FIXED_ES_BIT
| FIXED_GL_BIT
|
1635 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1636 INT_2_10_10_10_REV_BIT
|
1637 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
1639 if (!validate_array_and_format(ctx
, "glVertexAttribPointer",
1640 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1641 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1642 1, BGRA_OR_4
, size
, type
, stride
,
1643 normalized
, GL_FALSE
, GL_FALSE
, format
, ptr
))
1646 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1647 VERT_ATTRIB_GENERIC(index
), format
, BGRA_OR_4
,
1648 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, ptr
);
1653 _mesa_VertexArrayVertexAttribOffsetEXT(GLuint vaobj
, GLuint buffer
, GLuint index
, GLint size
,
1654 GLenum type
, GLboolean normalized
,
1655 GLsizei stride
, GLintptr offset
)
1657 GET_CURRENT_CONTEXT(ctx
);
1658 GLenum format
= get_array_format(ctx
, BGRA_OR_4
, &size
);
1659 struct gl_vertex_array_object
* vao
;
1660 struct gl_buffer_object
* vbo
;
1662 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1664 "glVertexArrayVertexAttribOffsetEXT"))
1667 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1668 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexArrayVertexAttribOffsetEXT(idx)");
1672 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1673 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1674 INT_BIT
| UNSIGNED_INT_BIT
|
1675 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
1676 FIXED_ES_BIT
| FIXED_GL_BIT
|
1677 UNSIGNED_INT_2_10_10_10_REV_BIT
|
1678 INT_2_10_10_10_REV_BIT
|
1679 UNSIGNED_INT_10F_11F_11F_REV_BIT
);
1681 if (!validate_array_and_format(ctx
, "glVertexArrayVertexAttribOffsetEXT",
1683 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1684 1, BGRA_OR_4
, size
, type
, stride
,
1685 normalized
, GL_FALSE
, GL_FALSE
, format
, (void*) offset
))
1688 update_array(ctx
, vao
, vbo
,
1689 VERT_ATTRIB_GENERIC(index
), format
, BGRA_OR_4
,
1690 size
, type
, stride
, normalized
, GL_FALSE
, GL_FALSE
, (void*) offset
);
1695 _mesa_VertexArrayVertexAttribLOffsetEXT(GLuint vaobj
, GLuint buffer
, GLuint index
, GLint size
,
1696 GLenum type
, GLsizei stride
, GLintptr offset
)
1698 GET_CURRENT_CONTEXT(ctx
);
1699 GLenum format
= GL_RGBA
;
1700 struct gl_vertex_array_object
* vao
;
1701 struct gl_buffer_object
* vbo
;
1703 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1705 "glVertexArrayVertexAttribLOffsetEXT"))
1708 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1709 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexArrayVertexAttribLOffsetEXT(idx)");
1713 const GLbitfield legalTypes
= DOUBLE_BIT
;
1715 if (!validate_array_and_format(ctx
, "glVertexArrayVertexAttribLOffsetEXT",
1717 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1718 1, 4, size
, type
, stride
,
1719 GL_FALSE
, GL_FALSE
, GL_TRUE
, format
, (void*) offset
))
1722 update_array(ctx
, vao
, vbo
,
1723 VERT_ATTRIB_GENERIC(index
), format
, 4,
1724 size
, type
, stride
, GL_FALSE
, GL_FALSE
, GL_TRUE
, (void*) offset
);
1729 _mesa_VertexAttribIPointer_no_error(GLuint index
, GLint size
, GLenum type
,
1730 GLsizei stride
, const GLvoid
*ptr
)
1732 const GLboolean normalized
= GL_FALSE
;
1733 const GLboolean integer
= GL_TRUE
;
1734 GET_CURRENT_CONTEXT(ctx
);
1736 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1737 VERT_ATTRIB_GENERIC(index
), GL_RGBA
, 4, size
, type
,
1738 stride
, normalized
, integer
, GL_FALSE
, ptr
);
1743 * GL_EXT_gpu_shader4 / GL 3.0.
1744 * Set an integer-valued vertex attribute array.
1745 * Note that these arrays DO NOT alias the conventional GL vertex arrays
1746 * (position, normal, color, fog, texcoord, etc).
1749 _mesa_VertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
1750 GLsizei stride
, const GLvoid
*ptr
)
1752 const GLboolean normalized
= GL_FALSE
;
1753 const GLboolean integer
= GL_TRUE
;
1754 GET_CURRENT_CONTEXT(ctx
);
1756 GLenum format
= GL_RGBA
;
1757 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1758 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribIPointer(index)");
1762 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1763 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1764 INT_BIT
| UNSIGNED_INT_BIT
);
1766 if (!validate_array_and_format(ctx
, "glVertexAttribIPointer",
1767 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1768 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1769 1, 4, size
, type
, stride
,
1770 normalized
, integer
, GL_FALSE
, format
, ptr
))
1773 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1774 VERT_ATTRIB_GENERIC(index
), format
, 4, size
, type
,
1775 stride
, normalized
, integer
, GL_FALSE
, ptr
);
1780 _mesa_VertexAttribLPointer_no_error(GLuint index
, GLint size
, GLenum type
,
1781 GLsizei stride
, const GLvoid
*ptr
)
1783 GET_CURRENT_CONTEXT(ctx
);
1785 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1786 VERT_ATTRIB_GENERIC(index
), GL_RGBA
, 4, size
, type
,
1787 stride
, GL_FALSE
, GL_FALSE
, GL_TRUE
, ptr
);
1792 _mesa_VertexArrayVertexAttribIOffsetEXT(GLuint vaobj
, GLuint buffer
, GLuint index
, GLint size
,
1793 GLenum type
, GLsizei stride
, GLintptr offset
)
1795 const GLboolean normalized
= GL_FALSE
;
1796 const GLboolean integer
= GL_TRUE
;
1797 GET_CURRENT_CONTEXT(ctx
);
1798 GLenum format
= GL_RGBA
;
1800 struct gl_vertex_array_object
* vao
;
1801 struct gl_buffer_object
* vbo
;
1803 if (!_lookup_vao_and_vbo_dsa(ctx
, vaobj
, buffer
, offset
,
1805 "glVertexArrayVertexAttribIOffsetEXT"))
1808 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1809 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexArrayVertexAttribIOffsetEXT(index)");
1813 const GLbitfield legalTypes
= (BYTE_BIT
| UNSIGNED_BYTE_BIT
|
1814 SHORT_BIT
| UNSIGNED_SHORT_BIT
|
1815 INT_BIT
| UNSIGNED_INT_BIT
);
1817 if (!validate_array_and_format(ctx
, "glVertexArrayVertexAttribIOffsetEXT",
1819 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1820 1, 4, size
, type
, stride
,
1821 normalized
, integer
, GL_FALSE
, format
, (void*) offset
))
1824 update_array(ctx
, vao
, vbo
,
1825 VERT_ATTRIB_GENERIC(index
), format
, 4, size
, type
,
1826 stride
, normalized
, integer
, GL_FALSE
, (void*) offset
);
1831 _mesa_VertexAttribLPointer(GLuint index
, GLint size
, GLenum type
,
1832 GLsizei stride
, const GLvoid
*ptr
)
1834 GET_CURRENT_CONTEXT(ctx
);
1836 GLenum format
= GL_RGBA
;
1837 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1838 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribLPointer(index)");
1842 const GLbitfield legalTypes
= DOUBLE_BIT
;
1844 if (!validate_array_and_format(ctx
, "glVertexAttribLPointer",
1845 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1846 VERT_ATTRIB_GENERIC(index
), legalTypes
,
1847 1, 4, size
, type
, stride
,
1848 GL_FALSE
, GL_FALSE
, GL_TRUE
, format
, ptr
))
1851 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
1852 VERT_ATTRIB_GENERIC(index
), format
, 4, size
, type
,
1853 stride
, GL_FALSE
, GL_FALSE
, GL_TRUE
, ptr
);
1858 _mesa_enable_vertex_array_attribs(struct gl_context
*ctx
,
1859 struct gl_vertex_array_object
*vao
,
1860 GLbitfield attrib_bits
)
1862 assert((attrib_bits
& ~VERT_BIT_ALL
) == 0);
1863 assert(!vao
->SharedAndImmutable
);
1865 /* Only work on bits that are disabled */
1866 attrib_bits
&= ~vao
->Enabled
;
1868 /* was disabled, now being enabled */
1869 vao
->Enabled
|= attrib_bits
;
1870 vao
->NewArrays
|= attrib_bits
;
1872 /* Update the map mode if needed */
1873 if (attrib_bits
& (VERT_BIT_POS
|VERT_BIT_GENERIC0
))
1874 update_attribute_map_mode(ctx
, vao
);
1879 enable_vertex_array_attrib(struct gl_context
*ctx
,
1880 struct gl_vertex_array_object
*vao
,
1884 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1885 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index)", func
);
1889 _mesa_enable_vertex_array_attrib(ctx
, vao
, VERT_ATTRIB_GENERIC(index
));
1894 _mesa_EnableVertexAttribArray(GLuint index
)
1896 GET_CURRENT_CONTEXT(ctx
);
1897 enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, index
,
1898 "glEnableVertexAttribArray");
1903 _mesa_EnableVertexAttribArray_no_error(GLuint index
)
1905 GET_CURRENT_CONTEXT(ctx
);
1906 _mesa_enable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
1907 VERT_ATTRIB_GENERIC(index
));
1912 _mesa_EnableVertexArrayAttrib(GLuint vaobj
, GLuint index
)
1914 GET_CURRENT_CONTEXT(ctx
);
1915 struct gl_vertex_array_object
*vao
;
1917 /* The ARB_direct_state_access specification says:
1919 * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
1920 * and DisableVertexArrayAttrib if <vaobj> is not
1921 * [compatibility profile: zero or] the name of an existing vertex
1924 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glEnableVertexArrayAttrib");
1928 enable_vertex_array_attrib(ctx
, vao
, index
, "glEnableVertexArrayAttrib");
1932 _mesa_EnableVertexArrayAttribEXT(GLuint vaobj
, GLuint index
)
1934 GET_CURRENT_CONTEXT(ctx
);
1935 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
1937 "glEnableVertexArrayAttribEXT");
1941 enable_vertex_array_attrib(ctx
, vao
, index
, "glEnableVertexArrayAttribEXT");
1946 _mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj
, GLuint index
)
1948 GET_CURRENT_CONTEXT(ctx
);
1949 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
1950 _mesa_enable_vertex_array_attrib(ctx
, vao
, VERT_ATTRIB_GENERIC(index
));
1955 _mesa_disable_vertex_array_attribs(struct gl_context
*ctx
,
1956 struct gl_vertex_array_object
*vao
,
1957 GLbitfield attrib_bits
)
1959 assert((attrib_bits
& ~VERT_BIT_ALL
) == 0);
1960 assert(!vao
->SharedAndImmutable
);
1962 /* Only work on bits that are enabled */
1963 attrib_bits
&= vao
->Enabled
;
1965 /* was enabled, now being disabled */
1966 vao
->Enabled
&= ~attrib_bits
;
1967 vao
->NewArrays
|= attrib_bits
;
1969 /* Update the map mode if needed */
1970 if (attrib_bits
& (VERT_BIT_POS
|VERT_BIT_GENERIC0
))
1971 update_attribute_map_mode(ctx
, vao
);
1977 _mesa_DisableVertexAttribArray(GLuint index
)
1979 GET_CURRENT_CONTEXT(ctx
);
1981 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
1982 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDisableVertexAttribArray(index)");
1986 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
1987 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attrib
);
1992 _mesa_DisableVertexAttribArray_no_error(GLuint index
)
1994 GET_CURRENT_CONTEXT(ctx
);
1995 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
1996 _mesa_disable_vertex_array_attrib(ctx
, ctx
->Array
.VAO
, attrib
);
2001 _mesa_DisableVertexArrayAttrib(GLuint vaobj
, GLuint index
)
2003 GET_CURRENT_CONTEXT(ctx
);
2004 struct gl_vertex_array_object
*vao
;
2006 /* The ARB_direct_state_access specification says:
2008 * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
2009 * and DisableVertexArrayAttrib if <vaobj> is not
2010 * [compatibility profile: zero or] the name of an existing vertex
2013 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glDisableVertexArrayAttrib");
2017 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2018 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDisableVertexArrayAttrib(index)");
2022 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
2023 _mesa_disable_vertex_array_attrib(ctx
, vao
, attrib
);
2027 _mesa_DisableVertexArrayAttribEXT(GLuint vaobj
, GLuint index
)
2029 GET_CURRENT_CONTEXT(ctx
);
2030 struct gl_vertex_array_object
* vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
2032 "glEnableVertexArrayAttribEXT");
2036 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2037 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDisableVertexArrayAttrib(index)");
2041 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
2042 _mesa_disable_vertex_array_attrib(ctx
, vao
, attrib
);
2047 _mesa_DisableVertexArrayAttrib_no_error(GLuint vaobj
, GLuint index
)
2049 GET_CURRENT_CONTEXT(ctx
);
2050 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
2051 const gl_vert_attrib attrib
= VERT_ATTRIB_GENERIC(index
);
2052 _mesa_disable_vertex_array_attrib(ctx
, vao
, attrib
);
2057 * Return info for a vertex attribute array (no alias with legacy
2058 * vertex attributes (pos, normal, color, etc)). This function does
2059 * not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
2062 get_vertex_array_attrib(struct gl_context
*ctx
,
2063 const struct gl_vertex_array_object
*vao
,
2064 GLuint index
, GLenum pname
,
2067 const struct gl_array_attributes
*array
;
2069 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2070 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(index=%u)", caller
, index
);
2074 assert(VERT_ATTRIB_GENERIC(index
) < ARRAY_SIZE(vao
->VertexAttrib
));
2076 array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)];
2079 case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB
:
2080 return !!(vao
->Enabled
& VERT_BIT_GENERIC(index
));
2081 case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB
:
2082 return (array
->Format
.Format
== GL_BGRA
) ? GL_BGRA
: array
->Format
.Size
;
2083 case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB
:
2084 return array
->Stride
;
2085 case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB
:
2086 return array
->Format
.Type
;
2087 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB
:
2088 return array
->Format
.Normalized
;
2089 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
2090 return vao
->BufferBinding
[array
->BufferBindingIndex
].BufferObj
->Name
;
2091 case GL_VERTEX_ATTRIB_ARRAY_INTEGER
:
2092 if ((_mesa_is_desktop_gl(ctx
)
2093 && (ctx
->Version
>= 30 || ctx
->Extensions
.EXT_gpu_shader4
))
2094 || _mesa_is_gles3(ctx
)) {
2095 return array
->Format
.Integer
;
2098 case GL_VERTEX_ATTRIB_ARRAY_LONG
:
2099 if (_mesa_is_desktop_gl(ctx
)) {
2100 return array
->Format
.Doubles
;
2103 case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB
:
2104 if ((_mesa_is_desktop_gl(ctx
) && ctx
->Extensions
.ARB_instanced_arrays
)
2105 || _mesa_is_gles3(ctx
)) {
2106 return vao
->BufferBinding
[array
->BufferBindingIndex
].InstanceDivisor
;
2109 case GL_VERTEX_ATTRIB_BINDING
:
2110 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles31(ctx
)) {
2111 return array
->BufferBindingIndex
- VERT_ATTRIB_GENERIC0
;
2114 case GL_VERTEX_ATTRIB_RELATIVE_OFFSET
:
2115 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles31(ctx
)) {
2116 return array
->RelativeOffset
;
2120 ; /* fall-through */
2124 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(pname=0x%x)", caller
, pname
);
2129 static const GLfloat
*
2130 get_current_attrib(struct gl_context
*ctx
, GLuint index
, const char *function
)
2133 if (_mesa_attr_zero_aliases_vertex(ctx
)) {
2134 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(index==0)", function
);
2138 else if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2139 _mesa_error(ctx
, GL_INVALID_VALUE
,
2140 "%s(index>=GL_MAX_VERTEX_ATTRIBS)", function
);
2144 assert(VERT_ATTRIB_GENERIC(index
) <
2145 ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
2147 FLUSH_CURRENT(ctx
, 0);
2148 return ctx
->Current
.Attrib
[VERT_ATTRIB_GENERIC(index
)];
2152 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
)
2154 GET_CURRENT_CONTEXT(ctx
);
2156 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2157 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribfv");
2163 params
[0] = (GLfloat
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2165 "glGetVertexAttribfv");
2171 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
)
2173 GET_CURRENT_CONTEXT(ctx
);
2175 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2176 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribdv");
2178 params
[0] = (GLdouble
) v
[0];
2179 params
[1] = (GLdouble
) v
[1];
2180 params
[2] = (GLdouble
) v
[2];
2181 params
[3] = (GLdouble
) v
[3];
2185 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2187 "glGetVertexAttribdv");
2192 _mesa_GetVertexAttribLdv(GLuint index
, GLenum pname
, GLdouble
*params
)
2194 GET_CURRENT_CONTEXT(ctx
);
2196 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2198 (const GLdouble
*)get_current_attrib(ctx
, index
,
2199 "glGetVertexAttribLdv");
2208 params
[0] = (GLdouble
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2210 "glGetVertexAttribLdv");
2215 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
)
2217 GET_CURRENT_CONTEXT(ctx
);
2219 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2220 const GLfloat
*v
= get_current_attrib(ctx
, index
, "glGetVertexAttribiv");
2222 /* XXX should floats in[0,1] be scaled to full int range? */
2223 params
[0] = (GLint
) v
[0];
2224 params
[1] = (GLint
) v
[1];
2225 params
[2] = (GLint
) v
[2];
2226 params
[3] = (GLint
) v
[3];
2230 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2232 "glGetVertexAttribiv");
2237 _mesa_GetVertexAttribLui64vARB(GLuint index
, GLenum pname
, GLuint64EXT
*params
)
2239 GET_CURRENT_CONTEXT(ctx
);
2241 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2243 (const GLuint64
*)get_current_attrib(ctx
, index
,
2244 "glGetVertexAttribLui64vARB");
2253 params
[0] = (GLuint64
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2255 "glGetVertexAttribLui64vARB");
2262 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
)
2264 GET_CURRENT_CONTEXT(ctx
);
2266 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2267 const GLint
*v
= (const GLint
*)
2268 get_current_attrib(ctx
, index
, "glGetVertexAttribIiv");
2274 params
[0] = (GLint
) get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2276 "glGetVertexAttribIiv");
2283 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
)
2285 GET_CURRENT_CONTEXT(ctx
);
2287 if (pname
== GL_CURRENT_VERTEX_ATTRIB_ARB
) {
2288 const GLuint
*v
= (const GLuint
*)
2289 get_current_attrib(ctx
, index
, "glGetVertexAttribIuiv");
2295 params
[0] = get_vertex_array_attrib(ctx
, ctx
->Array
.VAO
,
2297 "glGetVertexAttribIuiv");
2303 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
)
2305 GET_CURRENT_CONTEXT(ctx
);
2307 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2308 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerARB(index)");
2312 if (pname
!= GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB
) {
2313 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerARB(pname)");
2317 assert(VERT_ATTRIB_GENERIC(index
) <
2318 ARRAY_SIZE(ctx
->Array
.VAO
->VertexAttrib
));
2320 *pointer
= (GLvoid
*)
2321 ctx
->Array
.VAO
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Ptr
;
2325 /** ARB_direct_state_access */
2327 _mesa_GetVertexArrayIndexediv(GLuint vaobj
, GLuint index
,
2328 GLenum pname
, GLint
*params
)
2330 GET_CURRENT_CONTEXT(ctx
);
2331 struct gl_vertex_array_object
*vao
;
2333 /* The ARB_direct_state_access specification says:
2335 * "An INVALID_OPERATION error is generated if <vaobj> is not
2336 * [compatibility profile: zero or] the name of an existing
2337 * vertex array object."
2339 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glGetVertexArrayIndexediv");
2343 /* The ARB_direct_state_access specification says:
2345 * "For GetVertexArrayIndexediv, <pname> must be one of
2346 * VERTEX_ATTRIB_ARRAY_ENABLED, VERTEX_ATTRIB_ARRAY_SIZE,
2347 * VERTEX_ATTRIB_ARRAY_STRIDE, VERTEX_ATTRIB_ARRAY_TYPE,
2348 * VERTEX_ATTRIB_ARRAY_NORMALIZED, VERTEX_ATTRIB_ARRAY_INTEGER,
2349 * VERTEX_ATTRIB_ARRAY_LONG, VERTEX_ATTRIB_ARRAY_DIVISOR, or
2350 * VERTEX_ATTRIB_RELATIVE_OFFSET."
2354 * "Add GetVertexArrayIndexediv in 'Get Command' for
2355 * VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
2356 * VERTEX_ATTRIB_BINDING,
2357 * VERTEX_ATTRIB_RELATIVE_OFFSET,
2358 * VERTEX_BINDING_OFFSET, and
2359 * VERTEX_BINDING_STRIDE states"
2361 * The only parameter name common to both lists is
2362 * VERTEX_ATTRIB_RELATIVE_OFFSET. Also note that VERTEX_BINDING_BUFFER
2363 * and VERTEX_BINDING_DIVISOR are missing from both lists. It seems
2364 * pretty clear however that the intent is that it should be possible
2365 * to query all vertex attrib and binding states that can be set with
2369 case GL_VERTEX_BINDING_OFFSET
:
2370 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2372 case GL_VERTEX_BINDING_STRIDE
:
2373 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Stride
;
2375 case GL_VERTEX_BINDING_DIVISOR
:
2376 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].InstanceDivisor
;
2378 case GL_VERTEX_BINDING_BUFFER
:
2379 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].BufferObj
->Name
;
2382 params
[0] = get_vertex_array_attrib(ctx
, vao
, index
, pname
,
2383 "glGetVertexArrayIndexediv");
2390 _mesa_GetVertexArrayIndexed64iv(GLuint vaobj
, GLuint index
,
2391 GLenum pname
, GLint64
*params
)
2393 GET_CURRENT_CONTEXT(ctx
);
2394 struct gl_vertex_array_object
*vao
;
2396 /* The ARB_direct_state_access specification says:
2398 * "An INVALID_OPERATION error is generated if <vaobj> is not
2399 * [compatibility profile: zero or] the name of an existing
2400 * vertex array object."
2402 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glGetVertexArrayIndexed64iv");
2406 /* The ARB_direct_state_access specification says:
2408 * "For GetVertexArrayIndexed64iv, <pname> must be
2409 * VERTEX_BINDING_OFFSET."
2413 * "An INVALID_ENUM error is generated if <pname> is not one of
2414 * the valid values listed above for the corresponding command."
2416 if (pname
!= GL_VERTEX_BINDING_OFFSET
) {
2417 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexArrayIndexed64iv("
2418 "pname != GL_VERTEX_BINDING_OFFSET)");
2422 /* The ARB_direct_state_access specification says:
2424 * "An INVALID_VALUE error is generated if <index> is greater than
2425 * or equal to the value of MAX_VERTEX_ATTRIBS."
2427 * Since the index refers to a buffer binding in this case, the intended
2428 * limit must be MAX_VERTEX_ATTRIB_BINDINGS. Both limits are currently
2429 * required to be the same, so in practice this doesn't matter.
2431 if (index
>= ctx
->Const
.MaxVertexAttribBindings
) {
2432 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexArrayIndexed64iv(index"
2433 "%d >= the value of GL_MAX_VERTEX_ATTRIB_BINDINGS (%d))",
2434 index
, ctx
->Const
.MaxVertexAttribBindings
);
2438 params
[0] = vao
->BufferBinding
[VERT_ATTRIB_GENERIC(index
)].Offset
;
2443 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
2444 GLsizei count
, const GLvoid
*ptr
)
2447 _mesa_VertexPointer(size
, type
, stride
, ptr
);
2452 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
2456 _mesa_NormalPointer(type
, stride
, ptr
);
2461 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
2465 _mesa_ColorPointer(size
, type
, stride
, ptr
);
2470 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
2474 _mesa_IndexPointer(type
, stride
, ptr
);
2479 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
2480 GLsizei count
, const GLvoid
*ptr
)
2483 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
2488 _mesa_MultiTexCoordPointerEXT(GLenum texunit
, GLint size
, GLenum type
,
2489 GLsizei stride
, const GLvoid
*ptr
)
2491 GET_CURRENT_CONTEXT(ctx
);
2492 const GLint sizeMin
= 1;
2493 const GLuint unit
= texunit
- GL_TEXTURE0
;
2495 GLenum format
= GL_RGBA
;
2496 const GLbitfield legalTypes
= (SHORT_BIT
| INT_BIT
|
2497 HALF_BIT
| FLOAT_BIT
| DOUBLE_BIT
|
2498 UNSIGNED_INT_2_10_10_10_REV_BIT
|
2499 INT_2_10_10_10_REV_BIT
);
2501 if (!validate_array_and_format(ctx
, "glMultiTexCoordPointerEXT",
2502 ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
2503 VERT_ATTRIB_TEX(unit
), legalTypes
,
2504 sizeMin
, 4, size
, type
, stride
,
2505 GL_FALSE
, GL_FALSE
, GL_FALSE
, format
, ptr
))
2508 update_array(ctx
, ctx
->Array
.VAO
, ctx
->Array
.ArrayBufferObj
,
2509 VERT_ATTRIB_TEX(unit
), format
, 4, size
, type
,
2510 stride
, GL_FALSE
, GL_FALSE
, GL_FALSE
, ptr
);
2515 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
2518 _mesa_EdgeFlagPointer(stride
, ptr
);
2523 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
2525 GET_CURRENT_CONTEXT(ctx
);
2526 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
2527 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
2528 GLenum ctype
= 0; /* color type */
2529 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
2530 const GLint toffset
= 0; /* always zero */
2531 GLint defstride
; /* default stride */
2534 f
= sizeof(GLfloat
);
2535 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
2538 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
2544 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2545 tcomps
= 0; ccomps
= 0; vcomps
= 2;
2550 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2551 tcomps
= 0; ccomps
= 0; vcomps
= 3;
2556 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2557 tcomps
= 0; ccomps
= 4; vcomps
= 2;
2558 ctype
= GL_UNSIGNED_BYTE
;
2561 defstride
= c
+ 2*f
;
2564 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2565 tcomps
= 0; ccomps
= 4; vcomps
= 3;
2566 ctype
= GL_UNSIGNED_BYTE
;
2569 defstride
= c
+ 3*f
;
2572 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2573 tcomps
= 0; ccomps
= 3; vcomps
= 3;
2580 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
2581 tcomps
= 0; ccomps
= 0; vcomps
= 3;
2586 case GL_C4F_N3F_V3F
:
2587 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
2588 tcomps
= 0; ccomps
= 4; vcomps
= 3;
2596 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2597 tcomps
= 2; ccomps
= 0; vcomps
= 3;
2602 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
2603 tcomps
= 4; ccomps
= 0; vcomps
= 4;
2607 case GL_T2F_C4UB_V3F
:
2608 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2609 tcomps
= 2; ccomps
= 4; vcomps
= 3;
2610 ctype
= GL_UNSIGNED_BYTE
;
2615 case GL_T2F_C3F_V3F
:
2616 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
2617 tcomps
= 2; ccomps
= 3; vcomps
= 3;
2623 case GL_T2F_N3F_V3F
:
2624 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
2625 tcomps
= 2; ccomps
= 0; vcomps
= 3;
2630 case GL_T2F_C4F_N3F_V3F
:
2631 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
2632 tcomps
= 2; ccomps
= 4; vcomps
= 3;
2639 case GL_T4F_C4F_N3F_V4F
:
2640 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
2641 tcomps
= 4; ccomps
= 4; vcomps
= 4;
2649 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
2657 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
2658 _mesa_DisableClientState( GL_INDEX_ARRAY
);
2659 /* XXX also disable secondary color and generic arrays? */
2663 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
2664 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
2665 (GLubyte
*) pointer
+ toffset
);
2668 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
2673 _mesa_EnableClientState( GL_COLOR_ARRAY
);
2674 _mesa_ColorPointer( ccomps
, ctype
, stride
,
2675 (GLubyte
*) pointer
+ coffset
);
2678 _mesa_DisableClientState( GL_COLOR_ARRAY
);
2684 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
2685 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
2688 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
2692 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
2693 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
2694 (GLubyte
*) pointer
+ voffset
);
2699 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
2701 GET_CURRENT_CONTEXT(ctx
);
2703 if (MESA_VERBOSE
& VERBOSE_API
)
2704 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
2707 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
2711 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
2714 if (ctx
->Array
.LockCount
!= 0) {
2715 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
2719 ctx
->Array
.LockFirst
= first
;
2720 ctx
->Array
.LockCount
= count
;
2725 _mesa_UnlockArraysEXT( void )
2727 GET_CURRENT_CONTEXT(ctx
);
2729 if (MESA_VERBOSE
& VERBOSE_API
)
2730 _mesa_debug(ctx
, "glUnlockArrays\n");
2732 if (ctx
->Array
.LockCount
== 0) {
2733 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
2737 ctx
->Array
.LockFirst
= 0;
2738 ctx
->Array
.LockCount
= 0;
2743 primitive_restart_index(struct gl_context
*ctx
, GLuint index
)
2745 ctx
->Array
.RestartIndex
= index
;
2750 * GL_NV_primitive_restart and GL 3.1
2753 _mesa_PrimitiveRestartIndex_no_error(GLuint index
)
2755 GET_CURRENT_CONTEXT(ctx
);
2756 primitive_restart_index(ctx
, index
);
2761 _mesa_PrimitiveRestartIndex(GLuint index
)
2763 GET_CURRENT_CONTEXT(ctx
);
2765 if (!ctx
->Extensions
.NV_primitive_restart
&& ctx
->Version
< 31) {
2766 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glPrimitiveRestartIndexNV()");
2770 primitive_restart_index(ctx
, index
);
2775 _mesa_VertexAttribDivisor_no_error(GLuint index
, GLuint divisor
)
2777 GET_CURRENT_CONTEXT(ctx
);
2779 const gl_vert_attrib genericIndex
= VERT_ATTRIB_GENERIC(index
);
2780 struct gl_vertex_array_object
* const vao
= ctx
->Array
.VAO
;
2782 assert(genericIndex
< ARRAY_SIZE(vao
->VertexAttrib
));
2784 /* The ARB_vertex_attrib_binding spec says:
2788 * void VertexAttribDivisor(uint index, uint divisor);
2790 * is equivalent to (assuming no errors are generated):
2792 * VertexAttribBinding(index, index);
2793 * VertexBindingDivisor(index, divisor);"
2795 _mesa_vertex_attrib_binding(ctx
, vao
, genericIndex
, genericIndex
);
2796 vertex_binding_divisor(ctx
, vao
, genericIndex
, divisor
);
2801 * See GL_ARB_instanced_arrays.
2802 * Note that the instance divisor only applies to generic arrays, not
2803 * the legacy vertex arrays.
2806 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
)
2808 GET_CURRENT_CONTEXT(ctx
);
2810 const gl_vert_attrib genericIndex
= VERT_ATTRIB_GENERIC(index
);
2811 struct gl_vertex_array_object
* const vao
= ctx
->Array
.VAO
;
2813 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
2814 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexAttribDivisor()");
2818 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2819 _mesa_error(ctx
, GL_INVALID_VALUE
,
2820 "glVertexAttribDivisor(index = %u)", index
);
2824 assert(genericIndex
< ARRAY_SIZE(vao
->VertexAttrib
));
2826 /* The ARB_vertex_attrib_binding spec says:
2830 * void VertexAttribDivisor(uint index, uint divisor);
2832 * is equivalent to (assuming no errors are generated):
2834 * VertexAttribBinding(index, index);
2835 * VertexBindingDivisor(index, divisor);"
2837 _mesa_vertex_attrib_binding(ctx
, vao
, genericIndex
, genericIndex
);
2838 vertex_binding_divisor(ctx
, vao
, genericIndex
, divisor
);
2843 _mesa_VertexArrayVertexAttribDivisorEXT(GLuint vaobj
, GLuint index
, GLuint divisor
)
2845 GET_CURRENT_CONTEXT(ctx
);
2847 const gl_vert_attrib genericIndex
= VERT_ATTRIB_GENERIC(index
);
2848 struct gl_vertex_array_object
* vao
;
2849 /* The ARB_instanced_arrays spec says:
2851 * "The vertex array object named by vaobj must
2852 * be generated by GenVertexArrays (and not since deleted);
2853 * otherwise an INVALID_OPERATION error is generated."
2855 vao
= _mesa_lookup_vao_err(ctx
, vaobj
,
2857 "glVertexArrayVertexAttribDivisorEXT");
2861 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
2862 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glVertexArrayVertexAttribDivisorEXT()");
2866 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
2867 _mesa_error(ctx
, GL_INVALID_VALUE
,
2868 "glVertexArrayVertexAttribDivisorEXT(index = %u)", index
);
2872 assert(genericIndex
< ARRAY_SIZE(vao
->VertexAttrib
));
2874 /* The ARB_vertex_attrib_binding spec says:
2878 * void VertexAttribDivisor(uint index, uint divisor);
2880 * is equivalent to (assuming no errors are generated):
2882 * VertexAttribBinding(index, index);
2883 * VertexBindingDivisor(index, divisor);"
2885 _mesa_vertex_attrib_binding(ctx
, vao
, genericIndex
, genericIndex
);
2886 vertex_binding_divisor(ctx
, vao
, genericIndex
, divisor
);
2891 static ALWAYS_INLINE
void
2892 vertex_array_vertex_buffer(struct gl_context
*ctx
,
2893 struct gl_vertex_array_object
*vao
,
2894 GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
2895 GLsizei stride
, bool no_error
, const char *func
)
2897 struct gl_buffer_object
*vbo
;
2899 vao
->BufferBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
->Name
) {
2900 vbo
= vao
->BufferBinding
[VERT_ATTRIB_GENERIC(bindingIndex
)].BufferObj
;
2901 } else if (buffer
!= 0) {
2902 vbo
= _mesa_lookup_bufferobj(ctx
, buffer
);
2904 if (!no_error
&& !vbo
&& _mesa_is_gles31(ctx
)) {
2905 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s(non-gen name)", func
);
2908 /* From the GL_ARB_vertex_attrib_array spec:
2910 * "[Core profile only:]
2911 * An INVALID_OPERATION error is generated if buffer is not zero or a
2912 * name returned from a previous call to GenBuffers, or if such a name
2913 * has since been deleted with DeleteBuffers.
2915 * Otherwise, we fall back to the same compat profile behavior as other
2916 * object references (automatically gen it).
2918 if (!_mesa_handle_bind_buffer_gen(ctx
, buffer
, &vbo
, func
))
2921 /* The ARB_vertex_attrib_binding spec says:
2923 * "If <buffer> is zero, any buffer object attached to this
2924 * bindpoint is detached."
2926 vbo
= ctx
->Shared
->NullBufferObj
;
2929 _mesa_bind_vertex_buffer(ctx
, vao
, VERT_ATTRIB_GENERIC(bindingIndex
),
2930 vbo
, offset
, stride
);
2935 * GL_ARB_vertex_attrib_binding
2938 vertex_array_vertex_buffer_err(struct gl_context
*ctx
,
2939 struct gl_vertex_array_object
*vao
,
2940 GLuint bindingIndex
, GLuint buffer
,
2941 GLintptr offset
, GLsizei stride
,
2944 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2946 /* The ARB_vertex_attrib_binding spec says:
2948 * "An INVALID_VALUE error is generated if <bindingindex> is greater than
2949 * the value of MAX_VERTEX_ATTRIB_BINDINGS."
2951 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
2952 _mesa_error(ctx
, GL_INVALID_VALUE
,
2953 "%s(bindingindex=%u > "
2954 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
2955 func
, bindingIndex
);
2959 /* The ARB_vertex_attrib_binding spec says:
2961 * "The error INVALID_VALUE is generated if <stride> or <offset>
2965 _mesa_error(ctx
, GL_INVALID_VALUE
,
2966 "%s(offset=%" PRId64
" < 0)",
2967 func
, (int64_t) offset
);
2972 _mesa_error(ctx
, GL_INVALID_VALUE
,
2973 "%s(stride=%d < 0)", func
, stride
);
2977 if (((_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 44) || _mesa_is_gles31(ctx
)) &&
2978 stride
> ctx
->Const
.MaxVertexAttribStride
) {
2979 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(stride=%d > "
2980 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, stride
);
2984 vertex_array_vertex_buffer(ctx
, vao
, bindingIndex
, buffer
, offset
,
2985 stride
, false, func
);
2990 _mesa_BindVertexBuffer_no_error(GLuint bindingIndex
, GLuint buffer
,
2991 GLintptr offset
, GLsizei stride
)
2993 GET_CURRENT_CONTEXT(ctx
);
2994 vertex_array_vertex_buffer(ctx
, ctx
->Array
.VAO
, bindingIndex
,
2995 buffer
, offset
, stride
, true,
2996 "glBindVertexBuffer");
3001 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
3004 GET_CURRENT_CONTEXT(ctx
);
3006 /* The ARB_vertex_attrib_binding spec says:
3008 * "An INVALID_OPERATION error is generated if no vertex array object
3011 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
3012 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3013 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3014 "glBindVertexBuffer(No array object bound)");
3018 vertex_array_vertex_buffer_err(ctx
, ctx
->Array
.VAO
, bindingIndex
,
3019 buffer
, offset
, stride
,
3020 "glBindVertexBuffer");
3025 _mesa_VertexArrayVertexBuffer_no_error(GLuint vaobj
, GLuint bindingIndex
,
3026 GLuint buffer
, GLintptr offset
,
3029 GET_CURRENT_CONTEXT(ctx
);
3031 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
3032 vertex_array_vertex_buffer(ctx
, vao
, bindingIndex
, buffer
, offset
,
3033 stride
, true, "glVertexArrayVertexBuffer");
3038 _mesa_VertexArrayVertexBuffer(GLuint vaobj
, GLuint bindingIndex
, GLuint buffer
,
3039 GLintptr offset
, GLsizei stride
)
3041 GET_CURRENT_CONTEXT(ctx
);
3042 struct gl_vertex_array_object
*vao
;
3044 /* The ARB_direct_state_access specification says:
3046 * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
3047 * if <vaobj> is not [compatibility profile: zero or] the name of an
3048 * existing vertex array object."
3050 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayVertexBuffer");
3054 vertex_array_vertex_buffer_err(ctx
, vao
, bindingIndex
, buffer
, offset
,
3055 stride
, "glVertexArrayVertexBuffer");
3060 _mesa_VertexArrayBindVertexBufferEXT(GLuint vaobj
, GLuint bindingIndex
, GLuint buffer
,
3061 GLintptr offset
, GLsizei stride
)
3063 GET_CURRENT_CONTEXT(ctx
);
3064 struct gl_vertex_array_object
*vao
;
3065 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true, "glVertexArrayBindVertexBufferEXT");
3069 vertex_array_vertex_buffer_err(ctx
, vao
, bindingIndex
, buffer
, offset
,
3070 stride
, "glVertexArrayBindVertexBufferEXT");
3074 static ALWAYS_INLINE
void
3075 vertex_array_vertex_buffers(struct gl_context
*ctx
,
3076 struct gl_vertex_array_object
*vao
,
3077 GLuint first
, GLsizei count
, const GLuint
*buffers
,
3078 const GLintptr
*offsets
, const GLsizei
*strides
,
3079 bool no_error
, const char *func
)
3085 * The ARB_multi_bind spec says:
3087 * "If <buffers> is NULL, each affected vertex buffer binding point
3088 * from <first> through <first>+<count>-1 will be reset to have no
3089 * bound buffer object. In this case, the offsets and strides
3090 * associated with the binding points are set to default values,
3091 * ignoring <offsets> and <strides>."
3093 struct gl_buffer_object
*vbo
= ctx
->Shared
->NullBufferObj
;
3095 for (i
= 0; i
< count
; i
++)
3096 _mesa_bind_vertex_buffer(ctx
, vao
, VERT_ATTRIB_GENERIC(first
+ i
),
3102 /* Note that the error semantics for multi-bind commands differ from
3103 * those of other GL commands.
3105 * The Issues section in the ARB_multi_bind spec says:
3107 * "(11) Typically, OpenGL specifies that if an error is generated by
3108 * a command, that command has no effect. This is somewhat
3109 * unfortunate for multi-bind commands, because it would require
3110 * a first pass to scan the entire list of bound objects for
3111 * errors and then a second pass to actually perform the
3112 * bindings. Should we have different error semantics?
3114 * RESOLVED: Yes. In this specification, when the parameters for
3115 * one of the <count> binding points are invalid, that binding
3116 * point is not updated and an error will be generated. However,
3117 * other binding points in the same command will be updated if
3118 * their parameters are valid and no other error occurs."
3121 _mesa_HashLockMutex(ctx
->Shared
->BufferObjects
);
3123 for (i
= 0; i
< count
; i
++) {
3124 struct gl_buffer_object
*vbo
;
3127 /* The ARB_multi_bind spec says:
3129 * "An INVALID_VALUE error is generated if any value in
3130 * <offsets> or <strides> is negative (per binding)."
3132 if (offsets
[i
] < 0) {
3133 _mesa_error(ctx
, GL_INVALID_VALUE
,
3134 "%s(offsets[%u]=%" PRId64
" < 0)",
3135 func
, i
, (int64_t) offsets
[i
]);
3139 if (strides
[i
] < 0) {
3140 _mesa_error(ctx
, GL_INVALID_VALUE
,
3141 "%s(strides[%u]=%d < 0)",
3142 func
, i
, strides
[i
]);
3146 if (_mesa_is_desktop_gl(ctx
) && ctx
->Version
>= 44 &&
3147 strides
[i
] > ctx
->Const
.MaxVertexAttribStride
) {
3148 _mesa_error(ctx
, GL_INVALID_VALUE
,
3149 "%s(strides[%u]=%d > "
3150 "GL_MAX_VERTEX_ATTRIB_STRIDE)", func
, i
, strides
[i
]);
3156 struct gl_vertex_buffer_binding
*binding
=
3157 &vao
->BufferBinding
[VERT_ATTRIB_GENERIC(first
+ i
)];
3159 if (buffers
[i
] == binding
->BufferObj
->Name
)
3160 vbo
= binding
->BufferObj
;
3162 vbo
= _mesa_multi_bind_lookup_bufferobj(ctx
, buffers
, i
, func
);
3167 vbo
= ctx
->Shared
->NullBufferObj
;
3170 _mesa_bind_vertex_buffer(ctx
, vao
, VERT_ATTRIB_GENERIC(first
+ i
),
3171 vbo
, offsets
[i
], strides
[i
]);
3174 _mesa_HashUnlockMutex(ctx
->Shared
->BufferObjects
);
3179 vertex_array_vertex_buffers_err(struct gl_context
*ctx
,
3180 struct gl_vertex_array_object
*vao
,
3181 GLuint first
, GLsizei count
,
3182 const GLuint
*buffers
, const GLintptr
*offsets
,
3183 const GLsizei
*strides
, const char *func
)
3185 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3187 /* The ARB_multi_bind spec says:
3189 * "An INVALID_OPERATION error is generated if <first> + <count>
3190 * is greater than the value of MAX_VERTEX_ATTRIB_BINDINGS."
3192 if (first
+ count
> ctx
->Const
.MaxVertexAttribBindings
) {
3193 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3194 "%s(first=%u + count=%d > the value of "
3195 "GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
3196 func
, first
, count
, ctx
->Const
.MaxVertexAttribBindings
);
3200 vertex_array_vertex_buffers(ctx
, vao
, first
, count
, buffers
, offsets
,
3201 strides
, false, func
);
3206 _mesa_BindVertexBuffers_no_error(GLuint first
, GLsizei count
,
3207 const GLuint
*buffers
, const GLintptr
*offsets
,
3208 const GLsizei
*strides
)
3210 GET_CURRENT_CONTEXT(ctx
);
3212 vertex_array_vertex_buffers(ctx
, ctx
->Array
.VAO
, first
, count
,
3213 buffers
, offsets
, strides
, true,
3214 "glBindVertexBuffers");
3219 _mesa_BindVertexBuffers(GLuint first
, GLsizei count
, const GLuint
*buffers
,
3220 const GLintptr
*offsets
, const GLsizei
*strides
)
3222 GET_CURRENT_CONTEXT(ctx
);
3224 /* The ARB_vertex_attrib_binding spec says:
3226 * "An INVALID_OPERATION error is generated if no
3227 * vertex array object is bound."
3229 if (ctx
->API
== API_OPENGL_CORE
&&
3230 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3231 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3232 "glBindVertexBuffers(No array object bound)");
3236 vertex_array_vertex_buffers_err(ctx
, ctx
->Array
.VAO
, first
, count
,
3237 buffers
, offsets
, strides
,
3238 "glBindVertexBuffers");
3243 _mesa_VertexArrayVertexBuffers_no_error(GLuint vaobj
, GLuint first
,
3244 GLsizei count
, const GLuint
*buffers
,
3245 const GLintptr
*offsets
,
3246 const GLsizei
*strides
)
3248 GET_CURRENT_CONTEXT(ctx
);
3250 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
3251 vertex_array_vertex_buffers(ctx
, vao
, first
, count
,
3252 buffers
, offsets
, strides
, true,
3253 "glVertexArrayVertexBuffers");
3258 _mesa_VertexArrayVertexBuffers(GLuint vaobj
, GLuint first
, GLsizei count
,
3259 const GLuint
*buffers
,
3260 const GLintptr
*offsets
, const GLsizei
*strides
)
3262 GET_CURRENT_CONTEXT(ctx
);
3263 struct gl_vertex_array_object
*vao
;
3265 /* The ARB_direct_state_access specification says:
3267 * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
3268 * if <vaobj> is not [compatibility profile: zero or] the name of an
3269 * existing vertex array object."
3271 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayVertexBuffers");
3275 vertex_array_vertex_buffers_err(ctx
, vao
, first
, count
,
3276 buffers
, offsets
, strides
,
3277 "glVertexArrayVertexBuffers");
3282 vertex_attrib_format(GLuint attribIndex
, GLint size
, GLenum type
,
3283 GLboolean normalized
, GLboolean integer
,
3284 GLboolean doubles
, GLbitfield legalTypes
,
3285 GLsizei sizeMax
, GLuint relativeOffset
,
3288 GET_CURRENT_CONTEXT(ctx
);
3289 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3291 GLenum format
= get_array_format(ctx
, sizeMax
, &size
);
3293 if (!_mesa_is_no_error_enabled(ctx
)) {
3294 /* The ARB_vertex_attrib_binding spec says:
3296 * "An INVALID_OPERATION error is generated under any of the
3297 * following conditions:
3298 * - if no vertex array object is currently bound (see section
3302 * This error condition only applies to VertexAttribFormat and
3303 * VertexAttribIFormat in the extension spec, but we assume that this
3304 * is an oversight. In the OpenGL 4.3 (Core Profile) spec, it applies
3305 * to all three functions.
3307 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
3308 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3309 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3310 "%s(No array object bound)", func
);
3314 /* The ARB_vertex_attrib_binding spec says:
3316 * "The error INVALID_VALUE is generated if index is greater than or
3317 * equal to the value of MAX_VERTEX_ATTRIBS."
3319 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
3320 _mesa_error(ctx
, GL_INVALID_VALUE
,
3321 "%s(attribindex=%u > "
3322 "GL_MAX_VERTEX_ATTRIBS)",
3327 if (!validate_array_format(ctx
, func
, ctx
->Array
.VAO
,
3328 VERT_ATTRIB_GENERIC(attribIndex
),
3329 legalTypes
, 1, sizeMax
, size
, type
,
3330 normalized
, integer
, doubles
, relativeOffset
,
3336 _mesa_update_array_format(ctx
, ctx
->Array
.VAO
,
3337 VERT_ATTRIB_GENERIC(attribIndex
), size
, type
,
3338 format
, normalized
, integer
, doubles
,
3344 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
3345 GLboolean normalized
, GLuint relativeOffset
)
3347 vertex_attrib_format(attribIndex
, size
, type
, normalized
,
3348 GL_FALSE
, GL_FALSE
, ATTRIB_FORMAT_TYPES_MASK
,
3349 BGRA_OR_4
, relativeOffset
,
3350 "glVertexAttribFormat");
3355 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
3356 GLuint relativeOffset
)
3358 vertex_attrib_format(attribIndex
, size
, type
, GL_FALSE
,
3359 GL_TRUE
, GL_FALSE
, ATTRIB_IFORMAT_TYPES_MASK
, 4,
3360 relativeOffset
, "glVertexAttribIFormat");
3365 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
3366 GLuint relativeOffset
)
3368 vertex_attrib_format(attribIndex
, size
, type
, GL_FALSE
, GL_FALSE
,
3369 GL_TRUE
, ATTRIB_LFORMAT_TYPES_MASK
, 4,
3370 relativeOffset
, "glVertexAttribLFormat");
3375 vertex_array_attrib_format(GLuint vaobj
, bool isExtDsa
, GLuint attribIndex
,
3376 GLint size
, GLenum type
, GLboolean normalized
,
3377 GLboolean integer
, GLboolean doubles
,
3378 GLbitfield legalTypes
, GLsizei sizeMax
,
3379 GLuint relativeOffset
, const char *func
)
3381 GET_CURRENT_CONTEXT(ctx
);
3382 struct gl_vertex_array_object
*vao
;
3384 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3386 GLenum format
= get_array_format(ctx
, sizeMax
, &size
);
3388 if (_mesa_is_no_error_enabled(ctx
)) {
3389 vao
= _mesa_lookup_vao(ctx
, vaobj
);
3393 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, isExtDsa
, func
);
3397 /* The ARB_vertex_attrib_binding spec says:
3399 * "The error INVALID_VALUE is generated if index is greater than or
3400 * equal to the value of MAX_VERTEX_ATTRIBS."
3402 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
3403 _mesa_error(ctx
, GL_INVALID_VALUE
,
3404 "%s(attribindex=%u > GL_MAX_VERTEX_ATTRIBS)",
3409 if (!validate_array_format(ctx
, func
, vao
,
3410 VERT_ATTRIB_GENERIC(attribIndex
),
3411 legalTypes
, 1, sizeMax
, size
, type
,
3412 normalized
, integer
, doubles
, relativeOffset
,
3418 _mesa_update_array_format(ctx
, vao
, VERT_ATTRIB_GENERIC(attribIndex
), size
,
3419 type
, format
, normalized
, integer
, doubles
,
3425 _mesa_VertexArrayAttribFormat(GLuint vaobj
, GLuint attribIndex
, GLint size
,
3426 GLenum type
, GLboolean normalized
,
3427 GLuint relativeOffset
)
3429 vertex_array_attrib_format(vaobj
, false, attribIndex
, size
, type
, normalized
,
3430 GL_FALSE
, GL_FALSE
, ATTRIB_FORMAT_TYPES_MASK
,
3431 BGRA_OR_4
, relativeOffset
,
3432 "glVertexArrayAttribFormat");
3437 _mesa_VertexArrayVertexAttribFormatEXT(GLuint vaobj
, GLuint attribIndex
, GLint size
,
3438 GLenum type
, GLboolean normalized
,
3439 GLuint relativeOffset
)
3441 vertex_array_attrib_format(vaobj
, true, attribIndex
, size
, type
, normalized
,
3442 GL_FALSE
, GL_FALSE
, ATTRIB_FORMAT_TYPES_MASK
,
3443 BGRA_OR_4
, relativeOffset
,
3444 "glVertexArrayVertexAttribFormatEXT");
3449 _mesa_VertexArrayAttribIFormat(GLuint vaobj
, GLuint attribIndex
,
3450 GLint size
, GLenum type
,
3451 GLuint relativeOffset
)
3453 vertex_array_attrib_format(vaobj
, false, attribIndex
, size
, type
, GL_FALSE
,
3454 GL_TRUE
, GL_FALSE
, ATTRIB_IFORMAT_TYPES_MASK
,
3456 "glVertexArrayAttribIFormat");
3461 _mesa_VertexArrayVertexAttribIFormatEXT(GLuint vaobj
, GLuint attribIndex
,
3462 GLint size
, GLenum type
,
3463 GLuint relativeOffset
)
3465 vertex_array_attrib_format(vaobj
, true, attribIndex
, size
, type
, GL_FALSE
,
3466 GL_TRUE
, GL_FALSE
, ATTRIB_IFORMAT_TYPES_MASK
,
3468 "glVertexArrayVertexAttribIFormatEXT");
3473 _mesa_VertexArrayAttribLFormat(GLuint vaobj
, GLuint attribIndex
,
3474 GLint size
, GLenum type
,
3475 GLuint relativeOffset
)
3477 vertex_array_attrib_format(vaobj
, false, attribIndex
, size
, type
, GL_FALSE
,
3478 GL_FALSE
, GL_TRUE
, ATTRIB_LFORMAT_TYPES_MASK
,
3480 "glVertexArrayAttribLFormat");
3485 _mesa_VertexArrayVertexAttribLFormatEXT(GLuint vaobj
, GLuint attribIndex
,
3486 GLint size
, GLenum type
,
3487 GLuint relativeOffset
)
3489 vertex_array_attrib_format(vaobj
, true, attribIndex
, size
, type
, GL_FALSE
,
3490 GL_FALSE
, GL_TRUE
, ATTRIB_LFORMAT_TYPES_MASK
,
3492 "glVertexArrayVertexAttribLFormatEXT");
3497 vertex_array_attrib_binding(struct gl_context
*ctx
,
3498 struct gl_vertex_array_object
*vao
,
3499 GLuint attribIndex
, GLuint bindingIndex
,
3502 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3504 /* The ARB_vertex_attrib_binding spec says:
3506 * "<attribindex> must be less than the value of MAX_VERTEX_ATTRIBS and
3507 * <bindingindex> must be less than the value of
3508 * MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
3511 if (attribIndex
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
3512 _mesa_error(ctx
, GL_INVALID_VALUE
,
3513 "%s(attribindex=%u >= "
3514 "GL_MAX_VERTEX_ATTRIBS)",
3519 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
3520 _mesa_error(ctx
, GL_INVALID_VALUE
,
3521 "%s(bindingindex=%u >= "
3522 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
3523 func
, bindingIndex
);
3527 assert(VERT_ATTRIB_GENERIC(attribIndex
) < ARRAY_SIZE(vao
->VertexAttrib
));
3529 _mesa_vertex_attrib_binding(ctx
, vao
,
3530 VERT_ATTRIB_GENERIC(attribIndex
),
3531 VERT_ATTRIB_GENERIC(bindingIndex
));
3536 _mesa_VertexAttribBinding_no_error(GLuint attribIndex
, GLuint bindingIndex
)
3538 GET_CURRENT_CONTEXT(ctx
);
3539 _mesa_vertex_attrib_binding(ctx
, ctx
->Array
.VAO
,
3540 VERT_ATTRIB_GENERIC(attribIndex
),
3541 VERT_ATTRIB_GENERIC(bindingIndex
));
3546 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
)
3548 GET_CURRENT_CONTEXT(ctx
);
3550 /* The ARB_vertex_attrib_binding spec says:
3552 * "An INVALID_OPERATION error is generated if no vertex array object
3555 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
3556 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3557 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3558 "glVertexAttribBinding(No array object bound)");
3562 vertex_array_attrib_binding(ctx
, ctx
->Array
.VAO
,
3563 attribIndex
, bindingIndex
,
3564 "glVertexAttribBinding");
3569 _mesa_VertexArrayAttribBinding_no_error(GLuint vaobj
, GLuint attribIndex
,
3570 GLuint bindingIndex
)
3572 GET_CURRENT_CONTEXT(ctx
);
3574 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
3575 _mesa_vertex_attrib_binding(ctx
, vao
,
3576 VERT_ATTRIB_GENERIC(attribIndex
),
3577 VERT_ATTRIB_GENERIC(bindingIndex
));
3582 _mesa_VertexArrayAttribBinding(GLuint vaobj
, GLuint attribIndex
, GLuint bindingIndex
)
3584 GET_CURRENT_CONTEXT(ctx
);
3585 struct gl_vertex_array_object
*vao
;
3587 /* The ARB_direct_state_access specification says:
3589 * "An INVALID_OPERATION error is generated by VertexArrayAttribBinding
3590 * if <vaobj> is not [compatibility profile: zero or] the name of an
3591 * existing vertex array object."
3593 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayAttribBinding");
3597 vertex_array_attrib_binding(ctx
, vao
, attribIndex
, bindingIndex
,
3598 "glVertexArrayAttribBinding");
3603 _mesa_VertexArrayVertexAttribBindingEXT(GLuint vaobj
, GLuint attribIndex
, GLuint bindingIndex
)
3605 GET_CURRENT_CONTEXT(ctx
);
3606 struct gl_vertex_array_object
*vao
;
3607 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true, "glVertexArrayVertexAttribBindingEXT");
3611 vertex_array_attrib_binding(ctx
, vao
, attribIndex
, bindingIndex
,
3612 "glVertexArrayVertexAttribBindingEXT");
3617 vertex_array_binding_divisor(struct gl_context
*ctx
,
3618 struct gl_vertex_array_object
*vao
,
3619 GLuint bindingIndex
, GLuint divisor
,
3622 ASSERT_OUTSIDE_BEGIN_END(ctx
);
3624 if (!ctx
->Extensions
.ARB_instanced_arrays
) {
3625 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s()", func
);
3629 /* The ARB_vertex_attrib_binding spec says:
3631 * "An INVALID_VALUE error is generated if <bindingindex> is greater
3632 * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS."
3634 if (bindingIndex
>= ctx
->Const
.MaxVertexAttribBindings
) {
3635 _mesa_error(ctx
, GL_INVALID_VALUE
,
3636 "%s(bindingindex=%u > "
3637 "GL_MAX_VERTEX_ATTRIB_BINDINGS)",
3638 func
, bindingIndex
);
3642 vertex_binding_divisor(ctx
, vao
, VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
3647 _mesa_VertexBindingDivisor_no_error(GLuint bindingIndex
, GLuint divisor
)
3649 GET_CURRENT_CONTEXT(ctx
);
3650 vertex_binding_divisor(ctx
, ctx
->Array
.VAO
,
3651 VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
3656 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
)
3658 GET_CURRENT_CONTEXT(ctx
);
3660 /* The ARB_vertex_attrib_binding spec says:
3662 * "An INVALID_OPERATION error is generated if no vertex array object
3665 if ((ctx
->API
== API_OPENGL_CORE
|| _mesa_is_gles31(ctx
)) &&
3666 ctx
->Array
.VAO
== ctx
->Array
.DefaultVAO
) {
3667 _mesa_error(ctx
, GL_INVALID_OPERATION
,
3668 "glVertexBindingDivisor(No array object bound)");
3672 vertex_array_binding_divisor(ctx
, ctx
->Array
.VAO
,
3673 bindingIndex
, divisor
,
3674 "glVertexBindingDivisor");
3679 _mesa_VertexArrayBindingDivisor_no_error(GLuint vaobj
, GLuint bindingIndex
,
3682 GET_CURRENT_CONTEXT(ctx
);
3684 struct gl_vertex_array_object
*vao
= _mesa_lookup_vao(ctx
, vaobj
);
3685 vertex_binding_divisor(ctx
, vao
, VERT_ATTRIB_GENERIC(bindingIndex
), divisor
);
3690 _mesa_VertexArrayBindingDivisor(GLuint vaobj
, GLuint bindingIndex
,
3693 struct gl_vertex_array_object
*vao
;
3694 GET_CURRENT_CONTEXT(ctx
);
3696 /* The ARB_direct_state_access specification says:
3698 * "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
3699 * if <vaobj> is not [compatibility profile: zero or] the name of an
3700 * existing vertex array object."
3702 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, false, "glVertexArrayBindingDivisor");
3706 vertex_array_binding_divisor(ctx
, vao
, bindingIndex
, divisor
,
3707 "glVertexArrayBindingDivisor");
3712 _mesa_VertexArrayVertexBindingDivisorEXT(GLuint vaobj
, GLuint bindingIndex
,
3715 struct gl_vertex_array_object
*vao
;
3716 GET_CURRENT_CONTEXT(ctx
);
3718 /* The ARB_direct_state_access specification says:
3720 * "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
3721 * if <vaobj> is not [compatibility profile: zero or] the name of an
3722 * existing vertex array object."
3724 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true, "glVertexArrayVertexBindingDivisorEXT");
3728 vertex_array_binding_divisor(ctx
, vao
, bindingIndex
, divisor
,
3729 "glVertexArrayVertexBindingDivisorEXT");
3734 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
3735 struct gl_array_attributes
*dst
,
3736 const struct gl_array_attributes
*src
)
3738 dst
->Ptr
= src
->Ptr
;
3739 dst
->RelativeOffset
= src
->RelativeOffset
;
3740 dst
->Format
= src
->Format
;
3741 dst
->Stride
= src
->Stride
;
3742 dst
->BufferBindingIndex
= src
->BufferBindingIndex
;
3743 dst
->_EffBufferBindingIndex
= src
->_EffBufferBindingIndex
;
3744 dst
->_EffRelativeOffset
= src
->_EffRelativeOffset
;
3748 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
3749 struct gl_vertex_buffer_binding
*dst
,
3750 const struct gl_vertex_buffer_binding
*src
)
3752 dst
->Offset
= src
->Offset
;
3753 dst
->Stride
= src
->Stride
;
3754 dst
->InstanceDivisor
= src
->InstanceDivisor
;
3755 dst
->_BoundArrays
= src
->_BoundArrays
;
3756 dst
->_EffBoundArrays
= src
->_EffBoundArrays
;
3757 dst
->_EffOffset
= src
->_EffOffset
;
3759 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, src
->BufferObj
);
3763 * Print current vertex object/array info. For debug.
3766 _mesa_print_arrays(struct gl_context
*ctx
)
3768 const struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
3770 fprintf(stderr
, "Array Object %u\n", vao
->Name
);
3772 GLbitfield mask
= vao
->Enabled
;
3774 const gl_vert_attrib i
= u_bit_scan(&mask
);
3775 const struct gl_array_attributes
*array
= &vao
->VertexAttrib
[i
];
3777 const struct gl_vertex_buffer_binding
*binding
=
3778 &vao
->BufferBinding
[array
->BufferBindingIndex
];
3779 const struct gl_buffer_object
*bo
= binding
->BufferObj
;
3781 fprintf(stderr
, " %s: Ptr=%p, Type=%s, Size=%d, ElemSize=%u, "
3782 "Stride=%d, Buffer=%u(Size %lu)\n",
3783 gl_vert_attrib_name((gl_vert_attrib
)i
),
3784 array
->Ptr
, _mesa_enum_to_string(array
->Format
.Type
),
3786 array
->Format
._ElementSize
, binding
->Stride
, bo
->Name
,
3787 (unsigned long) bo
->Size
);
3793 * Initialize vertex array state for given context.
3796 _mesa_init_varray(struct gl_context
*ctx
)
3798 ctx
->Array
.DefaultVAO
= _mesa_new_vao(ctx
, 0);
3799 _mesa_reference_vao(ctx
, &ctx
->Array
.VAO
, ctx
->Array
.DefaultVAO
);
3800 ctx
->Array
._EmptyVAO
= _mesa_new_vao(ctx
, ~0u);
3801 _mesa_reference_vao(ctx
, &ctx
->Array
._DrawVAO
, ctx
->Array
._EmptyVAO
);
3802 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */
3804 ctx
->Array
.Objects
= _mesa_NewHashTable();
3809 * Callback for deleting an array object. Called by _mesa_HashDeleteAll().
3812 delete_arrayobj_cb(GLuint id
, void *data
, void *userData
)
3814 struct gl_vertex_array_object
*vao
= (struct gl_vertex_array_object
*) data
;
3815 struct gl_context
*ctx
= (struct gl_context
*) userData
;
3816 _mesa_delete_vao(ctx
, vao
);
3821 * Free vertex array state for given context.
3824 _mesa_free_varray_data(struct gl_context
*ctx
)
3826 _mesa_HashDeleteAll(ctx
->Array
.Objects
, delete_arrayobj_cb
, ctx
);
3827 _mesa_DeleteHashTable(ctx
->Array
.Objects
);
3831 _mesa_GetVertexArrayIntegervEXT(GLuint vaobj
, GLenum pname
, GLint
*param
)
3833 GET_CURRENT_CONTEXT(ctx
);
3834 struct gl_vertex_array_object
* vao
;
3837 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true,
3838 "glGetVertexArrayIntegervEXT");
3842 /* The EXT_direct_state_access spec says:
3844 * "For GetVertexArrayIntegervEXT, pname must be one of the "Get value" tokens
3845 * in tables 6.6, 6.7, 6.8, and 6.9 that use GetIntegerv, IsEnabled, or
3846 * GetPointerv for their "Get command" (so excluding the VERTEX_ATTRIB_*
3850 /* Tokens using GetIntegerv */
3851 case GL_CLIENT_ACTIVE_TEXTURE
:
3852 *param
= GL_TEXTURE0_ARB
+ ctx
->Array
.ActiveTexture
;
3854 case GL_VERTEX_ARRAY_SIZE
:
3855 *param
= vao
->VertexAttrib
[VERT_ATTRIB_POS
].Format
.Size
;
3857 case GL_VERTEX_ARRAY_TYPE
:
3858 *param
= vao
->VertexAttrib
[VERT_ATTRIB_POS
].Format
.Type
;
3860 case GL_VERTEX_ARRAY_STRIDE
:
3861 *param
= vao
->VertexAttrib
[VERT_ATTRIB_POS
].Stride
;
3863 case GL_VERTEX_ARRAY_BUFFER_BINDING
:
3864 *param
= vao
->BufferBinding
[VERT_ATTRIB_POS
].BufferObj
->Name
;
3866 case GL_COLOR_ARRAY_SIZE
:
3867 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Format
.Size
;
3869 case GL_COLOR_ARRAY_TYPE
:
3870 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Format
.Type
;
3872 case GL_COLOR_ARRAY_STRIDE
:
3873 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Stride
;
3875 case GL_COLOR_ARRAY_BUFFER_BINDING
:
3876 *param
= vao
->BufferBinding
[VERT_ATTRIB_COLOR0
].BufferObj
->Name
;
3878 case GL_EDGE_FLAG_ARRAY_STRIDE
:
3879 *param
= vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Stride
;
3881 case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING
:
3882 *param
= vao
->BufferBinding
[VERT_ATTRIB_EDGEFLAG
].BufferObj
->Name
;
3884 case GL_INDEX_ARRAY_TYPE
:
3885 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Format
.Type
;
3887 case GL_INDEX_ARRAY_STRIDE
:
3888 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Stride
;
3890 case GL_INDEX_ARRAY_BUFFER_BINDING
:
3891 *param
= vao
->BufferBinding
[VERT_ATTRIB_COLOR_INDEX
].BufferObj
->Name
;
3893 case GL_NORMAL_ARRAY_TYPE
:
3894 *param
= vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Format
.Type
;
3896 case GL_NORMAL_ARRAY_STRIDE
:
3897 *param
= vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Stride
;
3899 case GL_NORMAL_ARRAY_BUFFER_BINDING
:
3900 *param
= vao
->BufferBinding
[VERT_ATTRIB_NORMAL
].BufferObj
->Name
;
3902 case GL_TEXTURE_COORD_ARRAY_SIZE
:
3903 *param
= vao
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Format
.Size
;
3905 case GL_TEXTURE_COORD_ARRAY_TYPE
:
3906 *param
= vao
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Format
.Type
;
3908 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
3909 *param
= vao
->VertexAttrib
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].Stride
;
3911 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING
:
3912 *param
= vao
->BufferBinding
[VERT_ATTRIB_TEX(ctx
->Array
.ActiveTexture
)].BufferObj
->Name
;
3914 case GL_FOG_COORD_ARRAY_TYPE
:
3915 *param
= vao
->VertexAttrib
[VERT_ATTRIB_FOG
].Format
.Type
;
3917 case GL_FOG_COORD_ARRAY_STRIDE
:
3918 *param
= vao
->VertexAttrib
[VERT_ATTRIB_FOG
].Stride
;
3920 case GL_FOG_COORD_ARRAY_BUFFER_BINDING
:
3921 *param
= vao
->BufferBinding
[VERT_ATTRIB_FOG
].BufferObj
->Name
;
3923 case GL_SECONDARY_COLOR_ARRAY_SIZE
:
3924 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Format
.Size
;
3926 case GL_SECONDARY_COLOR_ARRAY_TYPE
:
3927 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Format
.Type
;
3929 case GL_SECONDARY_COLOR_ARRAY_STRIDE
:
3930 *param
= vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Stride
;
3932 case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING
:
3933 *param
= vao
->BufferBinding
[VERT_ATTRIB_COLOR1
].BufferObj
->Name
;
3936 /* Tokens using IsEnabled */
3937 case GL_VERTEX_ARRAY
:
3938 *param
= !!(vao
->Enabled
& VERT_BIT_POS
);
3940 case GL_COLOR_ARRAY
:
3941 *param
= !!(vao
->Enabled
& VERT_BIT_COLOR0
);
3943 case GL_EDGE_FLAG_ARRAY
:
3944 *param
= !!(vao
->Enabled
& VERT_BIT_EDGEFLAG
);
3946 case GL_INDEX_ARRAY
:
3947 *param
= !!(vao
->Enabled
& VERT_BIT_COLOR_INDEX
);
3949 case GL_NORMAL_ARRAY
:
3950 *param
= !!(vao
->Enabled
& VERT_BIT_NORMAL
);
3952 case GL_TEXTURE_COORD_ARRAY
:
3953 *param
= !!(vao
->Enabled
& VERT_BIT_TEX(ctx
->Array
.ActiveTexture
));
3955 case GL_FOG_COORD_ARRAY
:
3956 *param
= !!(vao
->Enabled
& VERT_BIT_FOG
);
3958 case GL_SECONDARY_COLOR_ARRAY
:
3959 *param
= !!(vao
->Enabled
& VERT_BIT_COLOR1
);
3962 /* Tokens using GetPointerv */
3963 case GL_VERTEX_ARRAY_POINTER
:
3964 case GL_COLOR_ARRAY_POINTER
:
3965 case GL_EDGE_FLAG_ARRAY_POINTER
:
3966 case GL_INDEX_ARRAY_POINTER
:
3967 case GL_NORMAL_ARRAY_POINTER
:
3968 case GL_TEXTURE_COORD_ARRAY_POINTER
:
3969 case GL_FOG_COORD_ARRAY_POINTER
:
3970 case GL_SECONDARY_COLOR_ARRAY_POINTER
:
3971 _get_vao_pointerv(pname
, vao
, &ptr
, "glGetVertexArrayIntegervEXT");
3972 *param
= (int) ((intptr_t) ptr
& 0xFFFFFFFF);
3976 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexArrayIntegervEXT(pname)");
3981 _mesa_GetVertexArrayPointervEXT(GLuint vaobj
, GLenum pname
, GLvoid
** param
)
3983 GET_CURRENT_CONTEXT(ctx
);
3984 struct gl_vertex_array_object
* vao
;
3986 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true,
3987 "glGetVertexArrayPointervEXT");
3991 /* The EXT_direct_state_access spec says:
3993 * "For GetVertexArrayPointervEXT, pname must be a *_ARRAY_POINTER token from
3994 * tables 6.6, 6.7, and 6.8 excluding VERTEX_ATTRIB_ARRAY_POINT."
3997 case GL_VERTEX_ARRAY_POINTER
:
3998 case GL_COLOR_ARRAY_POINTER
:
3999 case GL_EDGE_FLAG_ARRAY_POINTER
:
4000 case GL_INDEX_ARRAY_POINTER
:
4001 case GL_NORMAL_ARRAY_POINTER
:
4002 case GL_TEXTURE_COORD_ARRAY_POINTER
:
4003 case GL_FOG_COORD_ARRAY_POINTER
:
4004 case GL_SECONDARY_COLOR_ARRAY_POINTER
:
4008 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexArrayPointervEXT(pname)");
4012 /* pname has been validated, we can now use the helper function */
4013 _get_vao_pointerv(pname
, vao
, param
, "glGetVertexArrayPointervEXT");
4017 _mesa_GetVertexArrayIntegeri_vEXT(GLuint vaobj
, GLuint index
, GLenum pname
, GLint
*param
)
4019 GET_CURRENT_CONTEXT(ctx
);
4020 struct gl_vertex_array_object
* vao
;
4022 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true,
4023 "glGetVertexArrayIntegeri_vEXT");
4028 /* The EXT_direct_state_access spec says:
4030 * "For GetVertexArrayIntegeri_vEXT, pname must be one of the
4031 * "Get value" tokens in tables 6.8 and 6.9 that use GetVertexAttribiv
4032 * or GetVertexAttribPointerv (so allowing only the VERTEX_ATTRIB_*
4033 * tokens) or a token of the form TEXTURE_COORD_ARRAY (the enable) or
4034 * TEXTURE_COORD_ARRAY_*; index identifies the vertex attribute
4035 * array to query or texture coordinate set index respectively."
4039 case GL_TEXTURE_COORD_ARRAY
:
4040 *param
= !!(vao
->Enabled
& VERT_BIT_TEX(index
));
4042 case GL_TEXTURE_COORD_ARRAY_SIZE
:
4043 *param
= vao
->VertexAttrib
[VERT_ATTRIB_TEX(index
)].Format
.Size
;
4045 case GL_TEXTURE_COORD_ARRAY_TYPE
:
4046 *param
= vao
->VertexAttrib
[VERT_ATTRIB_TEX(index
)].Format
.Type
;
4048 case GL_TEXTURE_COORD_ARRAY_STRIDE
:
4049 *param
= vao
->VertexAttrib
[VERT_ATTRIB_TEX(index
)].Stride
;
4051 case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING
:
4052 *param
= vao
->BufferBinding
[VERT_ATTRIB_TEX(index
)].BufferObj
->Name
;
4055 *param
= get_vertex_array_attrib(ctx
, vao
, index
, pname
, "glGetVertexArrayIntegeri_vEXT");
4060 _mesa_GetVertexArrayPointeri_vEXT(GLuint vaobj
, GLuint index
, GLenum pname
, GLvoid
** param
)
4062 GET_CURRENT_CONTEXT(ctx
);
4063 struct gl_vertex_array_object
* vao
;
4065 vao
= _mesa_lookup_vao_err(ctx
, vaobj
, true,
4066 "glGetVertexArrayPointeri_vEXT");
4070 if (index
>= ctx
->Const
.Program
[MESA_SHADER_VERTEX
].MaxAttribs
) {
4071 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexArrayPointeri_vEXT(index)");
4075 /* The EXT_direct_state_access spec says:
4077 * "For GetVertexArrayPointeri_vEXT, pname must be VERTEX_ATTRIB_ARRAY_POINTER
4078 * or TEXTURE_COORD_ARRAY_POINTER with the index parameter indicating the vertex
4079 * attribute or texture coordindate set index."
4082 case GL_VERTEX_ATTRIB_ARRAY_POINTER
:
4083 *param
= (GLvoid
*) vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(index
)].Ptr
;
4085 case GL_TEXTURE_COORD_ARRAY_POINTER
:
4086 *param
= (GLvoid
*) vao
->VertexAttrib
[VERT_ATTRIB_TEX(index
)].Ptr
;
4089 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexArrayPointeri_vEXT(pname)");