2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
26 * This file implements the glArrayElement() function.
27 * It involves looking at the format/type of all the enabled vertex arrays
28 * and emitting a list of pointers to functions which set the per-vertex
29 * state for the element/index.
34 * Keith Whitwell <keithw@vmware.com>
39 #include "api_arrayelt.h"
40 #include "bufferobj.h"
45 #include "main/dispatch.h"
48 typedef void (GLAPIENTRY
*array_func
)( const void * );
51 const struct gl_array_attributes
*array
;
52 const struct gl_vertex_buffer_binding
*binding
;
56 typedef void (GLAPIENTRY
*attrib_func
)( GLuint indx
, const void *data
);
59 const struct gl_array_attributes
*array
;
60 const struct gl_vertex_buffer_binding
*binding
;
67 AEattrib attribs
[VERT_ATTRIB_MAX
+ 1];
69 /* List of VBOs we need to map before executing ArrayElements */
70 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
72 GLboolean mapped_vbos
; /**< Any currently mapped VBOs? */
79 static inline AEcontext
*
80 AE_CONTEXT(struct gl_context
*ctx
)
82 return (AEcontext
*) ctx
->aelt_context
;
87 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
88 * in the range [0, 7]. Luckily these type tokens are sequentially
89 * numbered in gl.h, except for GL_DOUBLE.
94 return t
== GL_DOUBLE
? 7 : t
& 7;
99 _ae_is_state_dirty(struct gl_context
*ctx
)
101 return AE_CONTEXT(ctx
)->dirty_state
;
108 static const int ColorFuncs
[2][NUM_TYPES
] = {
131 static const int VertexFuncs
[3][NUM_TYPES
] = {
164 static const int IndexFuncs
[NUM_TYPES
] = {
175 static const int NormalFuncs
[NUM_TYPES
] = {
186 /* Note: _gloffset_* for these may not be a compile-time constant. */
187 static int SecondaryColorFuncs
[NUM_TYPES
];
188 static int FogCoordFuncs
[NUM_TYPES
];
192 ** GL_NV_vertex_program
195 /* GL_BYTE attributes */
197 static void GLAPIENTRY
198 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
200 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
203 static void GLAPIENTRY
204 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
206 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
209 static void GLAPIENTRY
210 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
212 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
215 static void GLAPIENTRY
216 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
218 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
221 static void GLAPIENTRY
222 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
224 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
226 BYTE_TO_FLOAT(v
[2])));
229 static void GLAPIENTRY
230 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
232 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
235 static void GLAPIENTRY
236 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
238 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
241 BYTE_TO_FLOAT(v
[3])));
244 static void GLAPIENTRY
245 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
247 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
250 /* GL_UNSIGNED_BYTE attributes */
252 static void GLAPIENTRY
253 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
255 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
258 static void GLAPIENTRY
259 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
261 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
264 static void GLAPIENTRY
265 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
267 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
268 UBYTE_TO_FLOAT(v
[1])));
271 static void GLAPIENTRY
272 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
274 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
277 static void GLAPIENTRY
278 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
280 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
281 UBYTE_TO_FLOAT(v
[1]),
282 UBYTE_TO_FLOAT(v
[2])));
284 static void GLAPIENTRY
285 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
287 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
288 (GLfloat
)v
[1], (GLfloat
)v
[2]));
291 static void GLAPIENTRY
292 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
294 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
295 UBYTE_TO_FLOAT(v
[1]),
296 UBYTE_TO_FLOAT(v
[2]),
297 UBYTE_TO_FLOAT(v
[3])));
300 static void GLAPIENTRY
301 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
303 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
304 (GLfloat
)v
[1], (GLfloat
)v
[2],
308 /* GL_SHORT attributes */
310 static void GLAPIENTRY
311 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
313 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
316 static void GLAPIENTRY
317 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
319 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
322 static void GLAPIENTRY
323 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
325 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
326 SHORT_TO_FLOAT(v
[1])));
329 static void GLAPIENTRY
330 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
332 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
335 static void GLAPIENTRY
336 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
338 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
339 SHORT_TO_FLOAT(v
[1]),
340 SHORT_TO_FLOAT(v
[2])));
343 static void GLAPIENTRY
344 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
346 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
350 static void GLAPIENTRY
351 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
353 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
354 SHORT_TO_FLOAT(v
[1]),
355 SHORT_TO_FLOAT(v
[2]),
356 SHORT_TO_FLOAT(v
[3])));
359 static void GLAPIENTRY
360 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
362 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
363 (GLfloat
)v
[2], (GLfloat
)v
[3]));
366 /* GL_UNSIGNED_SHORT attributes */
368 static void GLAPIENTRY
369 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
371 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
374 static void GLAPIENTRY
375 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
377 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
380 static void GLAPIENTRY
381 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
383 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
384 USHORT_TO_FLOAT(v
[1])));
387 static void GLAPIENTRY
388 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
390 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
394 static void GLAPIENTRY
395 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
397 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
398 USHORT_TO_FLOAT(v
[1]),
399 USHORT_TO_FLOAT(v
[2])));
402 static void GLAPIENTRY
403 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
405 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
409 static void GLAPIENTRY
410 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
412 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
413 USHORT_TO_FLOAT(v
[1]),
414 USHORT_TO_FLOAT(v
[2]),
415 USHORT_TO_FLOAT(v
[3])));
418 static void GLAPIENTRY
419 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
421 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
422 (GLfloat
)v
[2], (GLfloat
)v
[3]));
425 /* GL_INT attributes */
427 static void GLAPIENTRY
428 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
430 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
433 static void GLAPIENTRY
434 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
436 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
439 static void GLAPIENTRY
440 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
442 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
443 INT_TO_FLOAT(v
[1])));
446 static void GLAPIENTRY
447 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
449 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
452 static void GLAPIENTRY
453 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
455 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
457 INT_TO_FLOAT(v
[2])));
460 static void GLAPIENTRY
461 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
463 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
467 static void GLAPIENTRY
468 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
470 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
473 INT_TO_FLOAT(v
[3])));
476 static void GLAPIENTRY
477 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
479 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
480 (GLfloat
)v
[2], (GLfloat
)v
[3]));
483 /* GL_UNSIGNED_INT attributes */
485 static void GLAPIENTRY
486 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
488 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
491 static void GLAPIENTRY
492 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
494 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
497 static void GLAPIENTRY
498 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
500 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
501 UINT_TO_FLOAT(v
[1])));
504 static void GLAPIENTRY
505 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
507 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
511 static void GLAPIENTRY
512 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
514 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
516 UINT_TO_FLOAT(v
[2])));
519 static void GLAPIENTRY
520 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
522 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
526 static void GLAPIENTRY
527 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
529 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
532 UINT_TO_FLOAT(v
[3])));
535 static void GLAPIENTRY
536 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
538 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
539 (GLfloat
)v
[2], (GLfloat
)v
[3]));
542 /* GL_FLOAT attributes */
544 static void GLAPIENTRY
545 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
547 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
550 static void GLAPIENTRY
551 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
553 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
556 static void GLAPIENTRY
557 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
559 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
562 static void GLAPIENTRY
563 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
565 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
568 /* GL_DOUBLE attributes */
570 static void GLAPIENTRY
571 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
573 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
576 static void GLAPIENTRY
577 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
579 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
582 static void GLAPIENTRY
583 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
585 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
588 static void GLAPIENTRY
589 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
591 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
596 * Array [size][type] of VertexAttrib functions
598 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
603 (attrib_func
) VertexAttrib1bvNV
,
604 (attrib_func
) VertexAttrib1ubvNV
,
605 (attrib_func
) VertexAttrib1svNV
,
606 (attrib_func
) VertexAttrib1usvNV
,
607 (attrib_func
) VertexAttrib1ivNV
,
608 (attrib_func
) VertexAttrib1uivNV
,
609 (attrib_func
) VertexAttrib1fvNV
,
610 (attrib_func
) VertexAttrib1dvNV
614 (attrib_func
) VertexAttrib2bvNV
,
615 (attrib_func
) VertexAttrib2ubvNV
,
616 (attrib_func
) VertexAttrib2svNV
,
617 (attrib_func
) VertexAttrib2usvNV
,
618 (attrib_func
) VertexAttrib2ivNV
,
619 (attrib_func
) VertexAttrib2uivNV
,
620 (attrib_func
) VertexAttrib2fvNV
,
621 (attrib_func
) VertexAttrib2dvNV
625 (attrib_func
) VertexAttrib3bvNV
,
626 (attrib_func
) VertexAttrib3ubvNV
,
627 (attrib_func
) VertexAttrib3svNV
,
628 (attrib_func
) VertexAttrib3usvNV
,
629 (attrib_func
) VertexAttrib3ivNV
,
630 (attrib_func
) VertexAttrib3uivNV
,
631 (attrib_func
) VertexAttrib3fvNV
,
632 (attrib_func
) VertexAttrib3dvNV
636 (attrib_func
) VertexAttrib4bvNV
,
637 (attrib_func
) VertexAttrib4ubvNV
,
638 (attrib_func
) VertexAttrib4svNV
,
639 (attrib_func
) VertexAttrib4usvNV
,
640 (attrib_func
) VertexAttrib4ivNV
,
641 (attrib_func
) VertexAttrib4uivNV
,
642 (attrib_func
) VertexAttrib4fvNV
,
643 (attrib_func
) VertexAttrib4dvNV
647 /* normalized (except for float/double) */
650 (attrib_func
) VertexAttrib1NbvNV
,
651 (attrib_func
) VertexAttrib1NubvNV
,
652 (attrib_func
) VertexAttrib1NsvNV
,
653 (attrib_func
) VertexAttrib1NusvNV
,
654 (attrib_func
) VertexAttrib1NivNV
,
655 (attrib_func
) VertexAttrib1NuivNV
,
656 (attrib_func
) VertexAttrib1fvNV
,
657 (attrib_func
) VertexAttrib1dvNV
661 (attrib_func
) VertexAttrib2NbvNV
,
662 (attrib_func
) VertexAttrib2NubvNV
,
663 (attrib_func
) VertexAttrib2NsvNV
,
664 (attrib_func
) VertexAttrib2NusvNV
,
665 (attrib_func
) VertexAttrib2NivNV
,
666 (attrib_func
) VertexAttrib2NuivNV
,
667 (attrib_func
) VertexAttrib2fvNV
,
668 (attrib_func
) VertexAttrib2dvNV
672 (attrib_func
) VertexAttrib3NbvNV
,
673 (attrib_func
) VertexAttrib3NubvNV
,
674 (attrib_func
) VertexAttrib3NsvNV
,
675 (attrib_func
) VertexAttrib3NusvNV
,
676 (attrib_func
) VertexAttrib3NivNV
,
677 (attrib_func
) VertexAttrib3NuivNV
,
678 (attrib_func
) VertexAttrib3fvNV
,
679 (attrib_func
) VertexAttrib3dvNV
683 (attrib_func
) VertexAttrib4NbvNV
,
684 (attrib_func
) VertexAttrib4NubvNV
,
685 (attrib_func
) VertexAttrib4NsvNV
,
686 (attrib_func
) VertexAttrib4NusvNV
,
687 (attrib_func
) VertexAttrib4NivNV
,
688 (attrib_func
) VertexAttrib4NuivNV
,
689 (attrib_func
) VertexAttrib4fvNV
,
690 (attrib_func
) VertexAttrib4dvNV
697 ** GL_ARB_vertex_program
700 /* GL_BYTE attributes */
702 static void GLAPIENTRY
703 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
705 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
708 static void GLAPIENTRY
709 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
711 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
714 static void GLAPIENTRY
715 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
717 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
720 static void GLAPIENTRY
721 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
723 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
726 static void GLAPIENTRY
727 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
729 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
731 BYTE_TO_FLOAT(v
[2])));
734 static void GLAPIENTRY
735 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
737 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
740 static void GLAPIENTRY
741 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
743 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
746 BYTE_TO_FLOAT(v
[3])));
749 static void GLAPIENTRY
750 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
752 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
755 /* GL_UNSIGNED_BYTE attributes */
757 static void GLAPIENTRY
758 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
760 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
763 static void GLAPIENTRY
764 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
766 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
769 static void GLAPIENTRY
770 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
772 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
773 UBYTE_TO_FLOAT(v
[0]),
774 UBYTE_TO_FLOAT(v
[1])));
777 static void GLAPIENTRY
778 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
780 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
781 (GLfloat
)v
[0], (GLfloat
)v
[1]));
784 static void GLAPIENTRY
785 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
787 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
788 UBYTE_TO_FLOAT(v
[0]),
789 UBYTE_TO_FLOAT(v
[1]),
790 UBYTE_TO_FLOAT(v
[2])));
792 static void GLAPIENTRY
793 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
795 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
801 static void GLAPIENTRY
802 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
804 CALL_VertexAttrib4fARB(GET_DISPATCH(),
806 UBYTE_TO_FLOAT(v
[0]),
807 UBYTE_TO_FLOAT(v
[1]),
808 UBYTE_TO_FLOAT(v
[2]),
809 UBYTE_TO_FLOAT(v
[3])));
812 static void GLAPIENTRY
813 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
815 CALL_VertexAttrib4fARB(GET_DISPATCH(),
817 (GLfloat
)v
[0], (GLfloat
)v
[1],
818 (GLfloat
)v
[2], (GLfloat
)v
[3]));
821 /* GL_SHORT attributes */
823 static void GLAPIENTRY
824 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
826 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
829 static void GLAPIENTRY
830 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
832 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
835 static void GLAPIENTRY
836 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
838 CALL_VertexAttrib2fARB(GET_DISPATCH(),
839 (index
, SHORT_TO_FLOAT(v
[0]),
840 SHORT_TO_FLOAT(v
[1])));
843 static void GLAPIENTRY
844 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
846 CALL_VertexAttrib2fARB(GET_DISPATCH(),
847 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
850 static void GLAPIENTRY
851 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
853 CALL_VertexAttrib3fARB(GET_DISPATCH(),
855 SHORT_TO_FLOAT(v
[0]),
856 SHORT_TO_FLOAT(v
[1]),
857 SHORT_TO_FLOAT(v
[2])));
860 static void GLAPIENTRY
861 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
863 CALL_VertexAttrib3fARB(GET_DISPATCH(),
865 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
868 static void GLAPIENTRY
869 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
871 CALL_VertexAttrib4fARB(GET_DISPATCH(),
873 SHORT_TO_FLOAT(v
[0]),
874 SHORT_TO_FLOAT(v
[1]),
875 SHORT_TO_FLOAT(v
[2]),
876 SHORT_TO_FLOAT(v
[3])));
879 static void GLAPIENTRY
880 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
882 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
883 (GLfloat
)v
[2], (GLfloat
)v
[3]));
886 /* GL_UNSIGNED_SHORT attributes */
888 static void GLAPIENTRY
889 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
891 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
894 static void GLAPIENTRY
895 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
897 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
900 static void GLAPIENTRY
901 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
903 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
904 USHORT_TO_FLOAT(v
[1])));
907 static void GLAPIENTRY
908 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
910 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
914 static void GLAPIENTRY
915 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
917 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
918 USHORT_TO_FLOAT(v
[1]),
919 USHORT_TO_FLOAT(v
[2])));
922 static void GLAPIENTRY
923 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
925 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
926 (GLfloat
)v
[1], (GLfloat
)v
[2]));
929 static void GLAPIENTRY
930 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
932 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
933 USHORT_TO_FLOAT(v
[1]),
934 USHORT_TO_FLOAT(v
[2]),
935 USHORT_TO_FLOAT(v
[3])));
938 static void GLAPIENTRY
939 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
941 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
944 /* GL_INT attributes */
946 static void GLAPIENTRY
947 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
949 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
952 static void GLAPIENTRY
953 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
955 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
958 static void GLAPIENTRY
959 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
961 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
962 INT_TO_FLOAT(v
[1])));
965 static void GLAPIENTRY
966 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
968 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
972 static void GLAPIENTRY
973 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
975 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
977 INT_TO_FLOAT(v
[2])));
980 static void GLAPIENTRY
981 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
983 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
984 (GLfloat
)v
[1], (GLfloat
)v
[2]));
987 static void GLAPIENTRY
988 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
990 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
993 INT_TO_FLOAT(v
[3])));
996 static void GLAPIENTRY
997 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
999 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1000 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1003 /* GL_UNSIGNED_INT attributes */
1005 static void GLAPIENTRY
1006 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
1008 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
1011 static void GLAPIENTRY
1012 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
1014 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
1017 static void GLAPIENTRY
1018 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1020 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1021 UINT_TO_FLOAT(v
[1])));
1024 static void GLAPIENTRY
1025 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1027 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1031 static void GLAPIENTRY
1032 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1034 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1035 UINT_TO_FLOAT(v
[1]),
1036 UINT_TO_FLOAT(v
[2])));
1039 static void GLAPIENTRY
1040 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1042 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1043 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1046 static void GLAPIENTRY
1047 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1049 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1050 UINT_TO_FLOAT(v
[1]),
1051 UINT_TO_FLOAT(v
[2]),
1052 UINT_TO_FLOAT(v
[3])));
1055 static void GLAPIENTRY
1056 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1058 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1059 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1062 /* GL_FLOAT attributes */
1064 static void GLAPIENTRY
1065 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1067 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1070 static void GLAPIENTRY
1071 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1073 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1076 static void GLAPIENTRY
1077 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1079 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1082 static void GLAPIENTRY
1083 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1085 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1088 /* GL_DOUBLE attributes */
1090 static void GLAPIENTRY
1091 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1093 CALL_VertexAttrib1dv(GET_DISPATCH(), (index
, v
));
1096 static void GLAPIENTRY
1097 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1099 CALL_VertexAttrib2dv(GET_DISPATCH(), (index
, v
));
1102 static void GLAPIENTRY
1103 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1105 CALL_VertexAttrib3dv(GET_DISPATCH(), (index
, v
));
1108 static void GLAPIENTRY
1109 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1111 CALL_VertexAttrib4dv(GET_DISPATCH(), (index
, v
));
1116 * Integer-valued attributes
1118 static void GLAPIENTRY
1119 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1121 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1124 static void GLAPIENTRY
1125 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1127 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1130 static void GLAPIENTRY
1131 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1133 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1136 static void GLAPIENTRY
1137 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1139 CALL_VertexAttribI4bv(GET_DISPATCH(), (index
, v
));
1143 static void GLAPIENTRY
1144 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1146 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1149 static void GLAPIENTRY
1150 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1152 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1155 static void GLAPIENTRY
1156 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1158 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1161 static void GLAPIENTRY
1162 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1164 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index
, v
));
1169 static void GLAPIENTRY
1170 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1172 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1175 static void GLAPIENTRY
1176 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1178 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1181 static void GLAPIENTRY
1182 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1184 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1187 static void GLAPIENTRY
1188 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1190 CALL_VertexAttribI4sv(GET_DISPATCH(), (index
, v
));
1194 static void GLAPIENTRY
1195 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1197 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1200 static void GLAPIENTRY
1201 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1203 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1206 static void GLAPIENTRY
1207 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1209 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1212 static void GLAPIENTRY
1213 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1215 CALL_VertexAttribI4usv(GET_DISPATCH(), (index
, v
));
1220 static void GLAPIENTRY
1221 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1223 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1226 static void GLAPIENTRY
1227 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1229 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1232 static void GLAPIENTRY
1233 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1235 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1238 static void GLAPIENTRY
1239 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1241 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1245 static void GLAPIENTRY
1246 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1248 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1251 static void GLAPIENTRY
1252 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1254 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1257 static void GLAPIENTRY
1258 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1260 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1263 static void GLAPIENTRY
1264 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1266 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1269 /* GL_DOUBLE unconverted attributes */
1271 static void GLAPIENTRY
1272 VertexAttribL1dv(GLuint index
, const GLdouble
*v
)
1274 CALL_VertexAttribL1dv(GET_DISPATCH(), (index
, v
));
1277 static void GLAPIENTRY
1278 VertexAttribL2dv(GLuint index
, const GLdouble
*v
)
1280 CALL_VertexAttribL2dv(GET_DISPATCH(), (index
, v
));
1283 static void GLAPIENTRY
1284 VertexAttribL3dv(GLuint index
, const GLdouble
*v
)
1286 CALL_VertexAttribL3dv(GET_DISPATCH(), (index
, v
));
1289 static void GLAPIENTRY
1290 VertexAttribL4dv(GLuint index
, const GLdouble
*v
)
1292 CALL_VertexAttribL4dv(GET_DISPATCH(), (index
, v
));
1296 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1299 static const attrib_func AttribFuncsARB
[4][4][NUM_TYPES
] = {
1301 /* non-normalized */
1304 (attrib_func
) VertexAttrib1bvARB
,
1305 (attrib_func
) VertexAttrib1ubvARB
,
1306 (attrib_func
) VertexAttrib1svARB
,
1307 (attrib_func
) VertexAttrib1usvARB
,
1308 (attrib_func
) VertexAttrib1ivARB
,
1309 (attrib_func
) VertexAttrib1uivARB
,
1310 (attrib_func
) VertexAttrib1fvARB
,
1311 (attrib_func
) VertexAttrib1dvARB
1315 (attrib_func
) VertexAttrib2bvARB
,
1316 (attrib_func
) VertexAttrib2ubvARB
,
1317 (attrib_func
) VertexAttrib2svARB
,
1318 (attrib_func
) VertexAttrib2usvARB
,
1319 (attrib_func
) VertexAttrib2ivARB
,
1320 (attrib_func
) VertexAttrib2uivARB
,
1321 (attrib_func
) VertexAttrib2fvARB
,
1322 (attrib_func
) VertexAttrib2dvARB
1326 (attrib_func
) VertexAttrib3bvARB
,
1327 (attrib_func
) VertexAttrib3ubvARB
,
1328 (attrib_func
) VertexAttrib3svARB
,
1329 (attrib_func
) VertexAttrib3usvARB
,
1330 (attrib_func
) VertexAttrib3ivARB
,
1331 (attrib_func
) VertexAttrib3uivARB
,
1332 (attrib_func
) VertexAttrib3fvARB
,
1333 (attrib_func
) VertexAttrib3dvARB
1337 (attrib_func
) VertexAttrib4bvARB
,
1338 (attrib_func
) VertexAttrib4ubvARB
,
1339 (attrib_func
) VertexAttrib4svARB
,
1340 (attrib_func
) VertexAttrib4usvARB
,
1341 (attrib_func
) VertexAttrib4ivARB
,
1342 (attrib_func
) VertexAttrib4uivARB
,
1343 (attrib_func
) VertexAttrib4fvARB
,
1344 (attrib_func
) VertexAttrib4dvARB
1348 /* normalized (except for float/double) */
1351 (attrib_func
) VertexAttrib1NbvARB
,
1352 (attrib_func
) VertexAttrib1NubvARB
,
1353 (attrib_func
) VertexAttrib1NsvARB
,
1354 (attrib_func
) VertexAttrib1NusvARB
,
1355 (attrib_func
) VertexAttrib1NivARB
,
1356 (attrib_func
) VertexAttrib1NuivARB
,
1357 (attrib_func
) VertexAttrib1fvARB
,
1358 (attrib_func
) VertexAttrib1dvARB
1362 (attrib_func
) VertexAttrib2NbvARB
,
1363 (attrib_func
) VertexAttrib2NubvARB
,
1364 (attrib_func
) VertexAttrib2NsvARB
,
1365 (attrib_func
) VertexAttrib2NusvARB
,
1366 (attrib_func
) VertexAttrib2NivARB
,
1367 (attrib_func
) VertexAttrib2NuivARB
,
1368 (attrib_func
) VertexAttrib2fvARB
,
1369 (attrib_func
) VertexAttrib2dvARB
1373 (attrib_func
) VertexAttrib3NbvARB
,
1374 (attrib_func
) VertexAttrib3NubvARB
,
1375 (attrib_func
) VertexAttrib3NsvARB
,
1376 (attrib_func
) VertexAttrib3NusvARB
,
1377 (attrib_func
) VertexAttrib3NivARB
,
1378 (attrib_func
) VertexAttrib3NuivARB
,
1379 (attrib_func
) VertexAttrib3fvARB
,
1380 (attrib_func
) VertexAttrib3dvARB
1384 (attrib_func
) VertexAttrib4NbvARB
,
1385 (attrib_func
) VertexAttrib4NubvARB
,
1386 (attrib_func
) VertexAttrib4NsvARB
,
1387 (attrib_func
) VertexAttrib4NusvARB
,
1388 (attrib_func
) VertexAttrib4NivARB
,
1389 (attrib_func
) VertexAttrib4NuivARB
,
1390 (attrib_func
) VertexAttrib4fvARB
,
1391 (attrib_func
) VertexAttrib4dvARB
1396 /* integer-valued */
1399 (attrib_func
) VertexAttribI1bv
,
1400 (attrib_func
) VertexAttribI1ubv
,
1401 (attrib_func
) VertexAttribI1sv
,
1402 (attrib_func
) VertexAttribI1usv
,
1403 (attrib_func
) VertexAttribI1iv
,
1404 (attrib_func
) VertexAttribI1uiv
,
1405 NULL
, /* GL_FLOAT */
1406 NULL
/* GL_DOUBLE */
1410 (attrib_func
) VertexAttribI2bv
,
1411 (attrib_func
) VertexAttribI2ubv
,
1412 (attrib_func
) VertexAttribI2sv
,
1413 (attrib_func
) VertexAttribI2usv
,
1414 (attrib_func
) VertexAttribI2iv
,
1415 (attrib_func
) VertexAttribI2uiv
,
1416 NULL
, /* GL_FLOAT */
1417 NULL
/* GL_DOUBLE */
1421 (attrib_func
) VertexAttribI3bv
,
1422 (attrib_func
) VertexAttribI3ubv
,
1423 (attrib_func
) VertexAttribI3sv
,
1424 (attrib_func
) VertexAttribI3usv
,
1425 (attrib_func
) VertexAttribI3iv
,
1426 (attrib_func
) VertexAttribI3uiv
,
1427 NULL
, /* GL_FLOAT */
1428 NULL
/* GL_DOUBLE */
1432 (attrib_func
) VertexAttribI4bv
,
1433 (attrib_func
) VertexAttribI4ubv
,
1434 (attrib_func
) VertexAttribI4sv
,
1435 (attrib_func
) VertexAttribI4usv
,
1436 (attrib_func
) VertexAttribI4iv
,
1437 (attrib_func
) VertexAttribI4uiv
,
1438 NULL
, /* GL_FLOAT */
1439 NULL
/* GL_DOUBLE */
1453 (attrib_func
) VertexAttribL1dv
,
1464 (attrib_func
) VertexAttribL2dv
,
1475 (attrib_func
) VertexAttribL3dv
,
1486 (attrib_func
) VertexAttribL4dv
,
1494 _ae_create_context(struct gl_context
*ctx
)
1496 if (ctx
->aelt_context
)
1499 /* These _gloffset_* values may not be compile-time constants */
1500 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bv
;
1501 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubv
;
1502 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3sv
;
1503 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usv
;
1504 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3iv
;
1505 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uiv
;
1506 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1507 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dv
;
1509 FogCoordFuncs
[0] = -1;
1510 FogCoordFuncs
[1] = -1;
1511 FogCoordFuncs
[2] = -1;
1512 FogCoordFuncs
[3] = -1;
1513 FogCoordFuncs
[4] = -1;
1514 FogCoordFuncs
[5] = -1;
1515 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1516 FogCoordFuncs
[7] = _gloffset_FogCoorddv
;
1518 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1519 if (!ctx
->aelt_context
)
1522 AE_CONTEXT(ctx
)->dirty_state
= true;
1528 _ae_destroy_context(struct gl_context
*ctx
)
1530 if (AE_CONTEXT(ctx
)) {
1531 free(ctx
->aelt_context
);
1532 ctx
->aelt_context
= NULL
;
1538 * Check if the given vertex buffer object exists and is not mapped.
1539 * If so, add it to the list of buffers we must map before executing
1540 * an glArrayElement call.
1543 check_vbo(AEcontext
*actx
, struct gl_buffer_object
*vbo
)
1545 if (_mesa_is_bufferobj(vbo
) &&
1546 !_mesa_bufferobj_mapped(vbo
, MAP_INTERNAL
)) {
1548 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1549 if (actx
->vbo
[i
] == vbo
)
1550 return; /* already in the list, we're done */
1551 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1552 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1558 * Make a list of per-vertex functions to call for each glArrayElement call.
1559 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1561 * Note: this may be called during display list construction.
1564 _ae_update_state(struct gl_context
*ctx
)
1566 AEcontext
*actx
= AE_CONTEXT(ctx
);
1567 AEarray
*aa
= actx
->arrays
; /* non-indexed arrays (ex: glNormal) */
1568 AEattrib
*at
= actx
->attribs
; /* indexed arrays (ex: glMultiTexCoord) */
1570 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1574 /* conventional vertex arrays */
1575 if (vao
->Enabled
& VERT_BIT_COLOR_INDEX
) {
1576 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1577 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1578 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1579 check_vbo(actx
, aa
->binding
->BufferObj
);
1583 if (vao
->Enabled
& VERT_BIT_EDGEFLAG
) {
1584 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1585 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1586 aa
->offset
= _gloffset_EdgeFlagv
;
1587 check_vbo(actx
, aa
->binding
->BufferObj
);
1591 if (vao
->Enabled
& VERT_BIT_NORMAL
) {
1592 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1593 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1594 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1595 check_vbo(actx
, aa
->binding
->BufferObj
);
1599 if (vao
->Enabled
& VERT_BIT_COLOR0
) {
1600 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1601 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1602 aa
->offset
= ColorFuncs
[aa
->array
->Format
.Size
-3][TYPE_IDX(aa
->array
->Format
.Type
)];
1603 check_vbo(actx
, aa
->binding
->BufferObj
);
1607 if (vao
->Enabled
& VERT_BIT_COLOR1
) {
1608 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1609 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1610 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1611 check_vbo(actx
, aa
->binding
->BufferObj
);
1615 if (vao
->Enabled
& VERT_BIT_FOG
) {
1616 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_FOG
];
1617 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1618 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Format
.Type
)];
1619 check_vbo(actx
, aa
->binding
->BufferObj
);
1623 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1624 if (vao
->Enabled
& VERT_BIT_TEX(i
)) {
1625 struct gl_array_attributes
*attribArray
=
1626 &vao
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1627 /* NOTE: we use generic glVertexAttribNV functions here.
1628 * If we ever remove GL_NV_vertex_program this will have to change.
1630 at
->array
= attribArray
;
1631 at
->binding
= &vao
->BufferBinding
[attribArray
->BufferBindingIndex
];
1632 assert(!at
->array
->Format
.Normalized
);
1633 at
->func
= AttribFuncsNV
[at
->array
->Format
.Normalized
]
1634 [at
->array
->Format
.Size
-1]
1635 [TYPE_IDX(at
->array
->Format
.Type
)];
1636 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1637 check_vbo(actx
, at
->binding
->BufferObj
);
1642 /* generic vertex attribute arrays */
1643 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1644 if (vao
->Enabled
& VERT_BIT_GENERIC(i
)) {
1645 struct gl_array_attributes
*attribArray
=
1646 &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1648 at
->array
= attribArray
;
1649 at
->binding
= &vao
->BufferBinding
[attribArray
->BufferBindingIndex
];
1650 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1651 * function pointer here (for float arrays) since the pointer may
1652 * change from one execution of _ae_ArrayElement() to
1653 * the next. Doing so caused UT to break.
1655 if (at
->array
->Format
.Doubles
)
1657 else if (at
->array
->Format
.Integer
)
1659 else if (at
->array
->Format
.Normalized
)
1664 at
->func
= AttribFuncsARB
[intOrNorm
]
1665 [at
->array
->Format
.Size
-1]
1666 [TYPE_IDX(at
->array
->Format
.Type
)];
1669 check_vbo(actx
, at
->binding
->BufferObj
);
1674 /* finally, vertex position */
1675 if (vao
->Enabled
& VERT_BIT_GENERIC0
) {
1676 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1677 * issued as the last (provoking) attribute).
1679 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1680 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1681 assert(aa
->array
->Format
.Size
>= 2); /* XXX fix someday? */
1682 aa
->offset
= VertexFuncs
[aa
->array
->Format
.Size
-2][TYPE_IDX(aa
->array
->Format
.Type
)];
1683 check_vbo(actx
, aa
->binding
->BufferObj
);
1686 else if (vao
->Enabled
& VERT_BIT_POS
) {
1687 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_POS
];
1688 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1689 aa
->offset
= VertexFuncs
[aa
->array
->Format
.Size
-2][TYPE_IDX(aa
->array
->Format
.Type
)];
1690 check_vbo(actx
, aa
->binding
->BufferObj
);
1694 check_vbo(actx
, vao
->IndexBufferObj
);
1696 assert(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1697 assert(aa
- actx
->arrays
< 32);
1698 at
->func
= NULL
; /* terminate the list */
1699 aa
->offset
= -1; /* terminate the list */
1701 actx
->dirty_state
= false;
1706 * Before replaying glArrayElements calls we need to map (for reading) any
1707 * VBOs referenced by the enabled vertex arrays.
1710 _ae_map_vbos(struct gl_context
*ctx
)
1712 AEcontext
*actx
= AE_CONTEXT(ctx
);
1715 if (actx
->mapped_vbos
)
1718 if (actx
->dirty_state
)
1719 _ae_update_state(ctx
);
1721 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1722 ctx
->Driver
.MapBufferRange(ctx
, 0,
1729 actx
->mapped_vbos
= GL_TRUE
;
1737 _ae_unmap_vbos(struct gl_context
*ctx
)
1739 AEcontext
*actx
= AE_CONTEXT(ctx
);
1742 if (!actx
->mapped_vbos
)
1745 assert (!actx
->dirty_state
);
1747 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1748 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
], MAP_INTERNAL
);
1750 actx
->mapped_vbos
= GL_FALSE
;
1755 _mesa_array_element(struct gl_context
*ctx
,
1756 struct _glapi_table
*disp
, GLint elt
)
1758 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1760 if (actx
->dirty_state
)
1761 _ae_update_state(ctx
);
1763 /* emit generic attribute elements */
1764 for (const AEattrib
*at
= actx
->attribs
; at
->func
; at
++) {
1766 = ADD_POINTERS(at
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1767 _mesa_vertex_attrib_address(at
->array
, at
->binding
))
1768 + elt
* at
->binding
->Stride
;
1769 at
->func(at
->index
, src
);
1772 /* emit conventional arrays elements */
1773 for (const AEarray
*aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1775 = ADD_POINTERS(aa
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1776 _mesa_vertex_attrib_address(aa
->array
, aa
->binding
))
1777 + elt
* aa
->binding
->Stride
;
1778 CALL_by_offset(disp
, (array_func
), aa
->offset
, ((const void *) src
));
1784 * Called via glArrayElement() and glDrawArrays().
1785 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1786 * for all enabled vertex arrays (for elt-th element).
1787 * Note: this may be called during display list construction.
1790 _ae_ArrayElement(GLint elt
)
1792 GET_CURRENT_CONTEXT(ctx
);
1793 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1794 const struct _glapi_table
* const disp
= GET_DISPATCH();
1795 struct gl_vertex_array_object
*vao
;
1797 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1798 * then we call PrimitiveRestartNV and return.
1800 if (ctx
->Array
.PrimitiveRestart
&& (elt
== ctx
->Array
.RestartIndex
)) {
1801 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1805 if (actx
->dirty_state
) {
1806 assert(!actx
->mapped_vbos
);
1807 _ae_update_state(ctx
);
1810 vao
= ctx
->Array
.VAO
;
1811 _mesa_vao_map_arrays(ctx
, vao
, GL_MAP_READ_BIT
);
1813 _mesa_array_element(ctx
, (struct _glapi_table
*)disp
, elt
);
1815 _mesa_vao_unmap_arrays(ctx
, vao
);
1820 _ae_invalidate_state(struct gl_context
*ctx
)
1822 AEcontext
*actx
= AE_CONTEXT(ctx
);
1824 /* Only interested in this subset of mesa state. Need to prune
1825 * this down as both tnl/ and the drivers can raise statechanges
1826 * for arcane reasons in the middle of seemingly atomic operations
1827 * like DrawElements, over which we'd like to keep a known set of
1828 * arrays and vbo's mapped.
1830 * Luckily, neither the drivers nor tnl muck with the state that
1833 assert(ctx
->NewState
& _NEW_ARRAY
);
1835 assert(!actx
->mapped_vbos
);
1836 actx
->dirty_state
= true;
1841 _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1842 const GLvertexformat
*vfmt
)
1844 SET_ArrayElement(disp
, vfmt
->ArrayElement
);