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];
70 /* List of VBOs we need to map before executing ArrayElements */
71 struct gl_buffer_object
*vbo
[VERT_ATTRIB_MAX
];
73 GLboolean mapped_vbos
; /**< Any currently mapped VBOs? */
78 static inline AEcontext
*
79 AE_CONTEXT(struct gl_context
*ctx
)
81 return (AEcontext
*) ctx
->aelt_context
;
86 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
87 * in the range [0, 7]. Luckily these type tokens are sequentially
88 * numbered in gl.h, except for GL_DOUBLE.
93 return t
== GL_DOUBLE
? 7 : t
& 7;
98 _ae_is_state_dirty(struct gl_context
*ctx
)
100 return AE_CONTEXT(ctx
)->NewState
;
107 static const int ColorFuncs
[2][NUM_TYPES
] = {
130 static const int VertexFuncs
[3][NUM_TYPES
] = {
163 static const int IndexFuncs
[NUM_TYPES
] = {
174 static const int NormalFuncs
[NUM_TYPES
] = {
185 /* Note: _gloffset_* for these may not be a compile-time constant. */
186 static int SecondaryColorFuncs
[NUM_TYPES
];
187 static int FogCoordFuncs
[NUM_TYPES
];
191 ** GL_NV_vertex_program
194 /* GL_BYTE attributes */
196 static void GLAPIENTRY
197 VertexAttrib1NbvNV(GLuint index
, const GLbyte
*v
)
199 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
202 static void GLAPIENTRY
203 VertexAttrib1bvNV(GLuint index
, const GLbyte
*v
)
205 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
208 static void GLAPIENTRY
209 VertexAttrib2NbvNV(GLuint index
, const GLbyte
*v
)
211 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
214 static void GLAPIENTRY
215 VertexAttrib2bvNV(GLuint index
, const GLbyte
*v
)
217 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
220 static void GLAPIENTRY
221 VertexAttrib3NbvNV(GLuint index
, const GLbyte
*v
)
223 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
225 BYTE_TO_FLOAT(v
[2])));
228 static void GLAPIENTRY
229 VertexAttrib3bvNV(GLuint index
, const GLbyte
*v
)
231 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
234 static void GLAPIENTRY
235 VertexAttrib4NbvNV(GLuint index
, const GLbyte
*v
)
237 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
240 BYTE_TO_FLOAT(v
[3])));
243 static void GLAPIENTRY
244 VertexAttrib4bvNV(GLuint index
, const GLbyte
*v
)
246 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
249 /* GL_UNSIGNED_BYTE attributes */
251 static void GLAPIENTRY
252 VertexAttrib1NubvNV(GLuint index
, const GLubyte
*v
)
254 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
257 static void GLAPIENTRY
258 VertexAttrib1ubvNV(GLuint index
, const GLubyte
*v
)
260 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
263 static void GLAPIENTRY
264 VertexAttrib2NubvNV(GLuint index
, const GLubyte
*v
)
266 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
267 UBYTE_TO_FLOAT(v
[1])));
270 static void GLAPIENTRY
271 VertexAttrib2ubvNV(GLuint index
, const GLubyte
*v
)
273 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
276 static void GLAPIENTRY
277 VertexAttrib3NubvNV(GLuint index
, const GLubyte
*v
)
279 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
280 UBYTE_TO_FLOAT(v
[1]),
281 UBYTE_TO_FLOAT(v
[2])));
283 static void GLAPIENTRY
284 VertexAttrib3ubvNV(GLuint index
, const GLubyte
*v
)
286 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
287 (GLfloat
)v
[1], (GLfloat
)v
[2]));
290 static void GLAPIENTRY
291 VertexAttrib4NubvNV(GLuint index
, const GLubyte
*v
)
293 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0]),
294 UBYTE_TO_FLOAT(v
[1]),
295 UBYTE_TO_FLOAT(v
[2]),
296 UBYTE_TO_FLOAT(v
[3])));
299 static void GLAPIENTRY
300 VertexAttrib4ubvNV(GLuint index
, const GLubyte
*v
)
302 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
303 (GLfloat
)v
[1], (GLfloat
)v
[2],
307 /* GL_SHORT attributes */
309 static void GLAPIENTRY
310 VertexAttrib1NsvNV(GLuint index
, const GLshort
*v
)
312 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
315 static void GLAPIENTRY
316 VertexAttrib1svNV(GLuint index
, const GLshort
*v
)
318 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
321 static void GLAPIENTRY
322 VertexAttrib2NsvNV(GLuint index
, const GLshort
*v
)
324 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
325 SHORT_TO_FLOAT(v
[1])));
328 static void GLAPIENTRY
329 VertexAttrib2svNV(GLuint index
, const GLshort
*v
)
331 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
334 static void GLAPIENTRY
335 VertexAttrib3NsvNV(GLuint index
, const GLshort
*v
)
337 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
338 SHORT_TO_FLOAT(v
[1]),
339 SHORT_TO_FLOAT(v
[2])));
342 static void GLAPIENTRY
343 VertexAttrib3svNV(GLuint index
, const GLshort
*v
)
345 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
349 static void GLAPIENTRY
350 VertexAttrib4NsvNV(GLuint index
, const GLshort
*v
)
352 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0]),
353 SHORT_TO_FLOAT(v
[1]),
354 SHORT_TO_FLOAT(v
[2]),
355 SHORT_TO_FLOAT(v
[3])));
358 static void GLAPIENTRY
359 VertexAttrib4svNV(GLuint index
, const GLshort
*v
)
361 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
362 (GLfloat
)v
[2], (GLfloat
)v
[3]));
365 /* GL_UNSIGNED_SHORT attributes */
367 static void GLAPIENTRY
368 VertexAttrib1NusvNV(GLuint index
, const GLushort
*v
)
370 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
373 static void GLAPIENTRY
374 VertexAttrib1usvNV(GLuint index
, const GLushort
*v
)
376 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
379 static void GLAPIENTRY
380 VertexAttrib2NusvNV(GLuint index
, const GLushort
*v
)
382 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
383 USHORT_TO_FLOAT(v
[1])));
386 static void GLAPIENTRY
387 VertexAttrib2usvNV(GLuint index
, const GLushort
*v
)
389 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
393 static void GLAPIENTRY
394 VertexAttrib3NusvNV(GLuint index
, const GLushort
*v
)
396 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
397 USHORT_TO_FLOAT(v
[1]),
398 USHORT_TO_FLOAT(v
[2])));
401 static void GLAPIENTRY
402 VertexAttrib3usvNV(GLuint index
, const GLushort
*v
)
404 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
408 static void GLAPIENTRY
409 VertexAttrib4NusvNV(GLuint index
, const GLushort
*v
)
411 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
412 USHORT_TO_FLOAT(v
[1]),
413 USHORT_TO_FLOAT(v
[2]),
414 USHORT_TO_FLOAT(v
[3])));
417 static void GLAPIENTRY
418 VertexAttrib4usvNV(GLuint index
, const GLushort
*v
)
420 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
421 (GLfloat
)v
[2], (GLfloat
)v
[3]));
424 /* GL_INT attributes */
426 static void GLAPIENTRY
427 VertexAttrib1NivNV(GLuint index
, const GLint
*v
)
429 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
432 static void GLAPIENTRY
433 VertexAttrib1ivNV(GLuint index
, const GLint
*v
)
435 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
438 static void GLAPIENTRY
439 VertexAttrib2NivNV(GLuint index
, const GLint
*v
)
441 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
442 INT_TO_FLOAT(v
[1])));
445 static void GLAPIENTRY
446 VertexAttrib2ivNV(GLuint index
, const GLint
*v
)
448 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
451 static void GLAPIENTRY
452 VertexAttrib3NivNV(GLuint index
, const GLint
*v
)
454 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
456 INT_TO_FLOAT(v
[2])));
459 static void GLAPIENTRY
460 VertexAttrib3ivNV(GLuint index
, const GLint
*v
)
462 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
466 static void GLAPIENTRY
467 VertexAttrib4NivNV(GLuint index
, const GLint
*v
)
469 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
472 INT_TO_FLOAT(v
[3])));
475 static void GLAPIENTRY
476 VertexAttrib4ivNV(GLuint index
, const GLint
*v
)
478 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
479 (GLfloat
)v
[2], (GLfloat
)v
[3]));
482 /* GL_UNSIGNED_INT attributes */
484 static void GLAPIENTRY
485 VertexAttrib1NuivNV(GLuint index
, const GLuint
*v
)
487 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
490 static void GLAPIENTRY
491 VertexAttrib1uivNV(GLuint index
, const GLuint
*v
)
493 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
496 static void GLAPIENTRY
497 VertexAttrib2NuivNV(GLuint index
, const GLuint
*v
)
499 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
500 UINT_TO_FLOAT(v
[1])));
503 static void GLAPIENTRY
504 VertexAttrib2uivNV(GLuint index
, const GLuint
*v
)
506 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
510 static void GLAPIENTRY
511 VertexAttrib3NuivNV(GLuint index
, const GLuint
*v
)
513 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
515 UINT_TO_FLOAT(v
[2])));
518 static void GLAPIENTRY
519 VertexAttrib3uivNV(GLuint index
, const GLuint
*v
)
521 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
525 static void GLAPIENTRY
526 VertexAttrib4NuivNV(GLuint index
, const GLuint
*v
)
528 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
531 UINT_TO_FLOAT(v
[3])));
534 static void GLAPIENTRY
535 VertexAttrib4uivNV(GLuint index
, const GLuint
*v
)
537 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
538 (GLfloat
)v
[2], (GLfloat
)v
[3]));
541 /* GL_FLOAT attributes */
543 static void GLAPIENTRY
544 VertexAttrib1fvNV(GLuint index
, const GLfloat
*v
)
546 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index
, v
));
549 static void GLAPIENTRY
550 VertexAttrib2fvNV(GLuint index
, const GLfloat
*v
)
552 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index
, v
));
555 static void GLAPIENTRY
556 VertexAttrib3fvNV(GLuint index
, const GLfloat
*v
)
558 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index
, v
));
561 static void GLAPIENTRY
562 VertexAttrib4fvNV(GLuint index
, const GLfloat
*v
)
564 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index
, v
));
567 /* GL_DOUBLE attributes */
569 static void GLAPIENTRY
570 VertexAttrib1dvNV(GLuint index
, const GLdouble
*v
)
572 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index
, v
));
575 static void GLAPIENTRY
576 VertexAttrib2dvNV(GLuint index
, const GLdouble
*v
)
578 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index
, v
));
581 static void GLAPIENTRY
582 VertexAttrib3dvNV(GLuint index
, const GLdouble
*v
)
584 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index
, v
));
587 static void GLAPIENTRY
588 VertexAttrib4dvNV(GLuint index
, const GLdouble
*v
)
590 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index
, v
));
595 * Array [size][type] of VertexAttrib functions
597 static attrib_func AttribFuncsNV
[2][4][NUM_TYPES
] = {
602 (attrib_func
) VertexAttrib1bvNV
,
603 (attrib_func
) VertexAttrib1ubvNV
,
604 (attrib_func
) VertexAttrib1svNV
,
605 (attrib_func
) VertexAttrib1usvNV
,
606 (attrib_func
) VertexAttrib1ivNV
,
607 (attrib_func
) VertexAttrib1uivNV
,
608 (attrib_func
) VertexAttrib1fvNV
,
609 (attrib_func
) VertexAttrib1dvNV
613 (attrib_func
) VertexAttrib2bvNV
,
614 (attrib_func
) VertexAttrib2ubvNV
,
615 (attrib_func
) VertexAttrib2svNV
,
616 (attrib_func
) VertexAttrib2usvNV
,
617 (attrib_func
) VertexAttrib2ivNV
,
618 (attrib_func
) VertexAttrib2uivNV
,
619 (attrib_func
) VertexAttrib2fvNV
,
620 (attrib_func
) VertexAttrib2dvNV
624 (attrib_func
) VertexAttrib3bvNV
,
625 (attrib_func
) VertexAttrib3ubvNV
,
626 (attrib_func
) VertexAttrib3svNV
,
627 (attrib_func
) VertexAttrib3usvNV
,
628 (attrib_func
) VertexAttrib3ivNV
,
629 (attrib_func
) VertexAttrib3uivNV
,
630 (attrib_func
) VertexAttrib3fvNV
,
631 (attrib_func
) VertexAttrib3dvNV
635 (attrib_func
) VertexAttrib4bvNV
,
636 (attrib_func
) VertexAttrib4ubvNV
,
637 (attrib_func
) VertexAttrib4svNV
,
638 (attrib_func
) VertexAttrib4usvNV
,
639 (attrib_func
) VertexAttrib4ivNV
,
640 (attrib_func
) VertexAttrib4uivNV
,
641 (attrib_func
) VertexAttrib4fvNV
,
642 (attrib_func
) VertexAttrib4dvNV
646 /* normalized (except for float/double) */
649 (attrib_func
) VertexAttrib1NbvNV
,
650 (attrib_func
) VertexAttrib1NubvNV
,
651 (attrib_func
) VertexAttrib1NsvNV
,
652 (attrib_func
) VertexAttrib1NusvNV
,
653 (attrib_func
) VertexAttrib1NivNV
,
654 (attrib_func
) VertexAttrib1NuivNV
,
655 (attrib_func
) VertexAttrib1fvNV
,
656 (attrib_func
) VertexAttrib1dvNV
660 (attrib_func
) VertexAttrib2NbvNV
,
661 (attrib_func
) VertexAttrib2NubvNV
,
662 (attrib_func
) VertexAttrib2NsvNV
,
663 (attrib_func
) VertexAttrib2NusvNV
,
664 (attrib_func
) VertexAttrib2NivNV
,
665 (attrib_func
) VertexAttrib2NuivNV
,
666 (attrib_func
) VertexAttrib2fvNV
,
667 (attrib_func
) VertexAttrib2dvNV
671 (attrib_func
) VertexAttrib3NbvNV
,
672 (attrib_func
) VertexAttrib3NubvNV
,
673 (attrib_func
) VertexAttrib3NsvNV
,
674 (attrib_func
) VertexAttrib3NusvNV
,
675 (attrib_func
) VertexAttrib3NivNV
,
676 (attrib_func
) VertexAttrib3NuivNV
,
677 (attrib_func
) VertexAttrib3fvNV
,
678 (attrib_func
) VertexAttrib3dvNV
682 (attrib_func
) VertexAttrib4NbvNV
,
683 (attrib_func
) VertexAttrib4NubvNV
,
684 (attrib_func
) VertexAttrib4NsvNV
,
685 (attrib_func
) VertexAttrib4NusvNV
,
686 (attrib_func
) VertexAttrib4NivNV
,
687 (attrib_func
) VertexAttrib4NuivNV
,
688 (attrib_func
) VertexAttrib4fvNV
,
689 (attrib_func
) VertexAttrib4dvNV
696 ** GL_ARB_vertex_program
699 /* GL_BYTE attributes */
701 static void GLAPIENTRY
702 VertexAttrib1NbvARB(GLuint index
, const GLbyte
*v
)
704 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0])));
707 static void GLAPIENTRY
708 VertexAttrib1bvARB(GLuint index
, const GLbyte
*v
)
710 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
713 static void GLAPIENTRY
714 VertexAttrib2NbvARB(GLuint index
, const GLbyte
*v
)
716 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]), BYTE_TO_FLOAT(v
[1])));
719 static void GLAPIENTRY
720 VertexAttrib2bvARB(GLuint index
, const GLbyte
*v
)
722 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
725 static void GLAPIENTRY
726 VertexAttrib3NbvARB(GLuint index
, const GLbyte
*v
)
728 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
730 BYTE_TO_FLOAT(v
[2])));
733 static void GLAPIENTRY
734 VertexAttrib3bvARB(GLuint index
, const GLbyte
*v
)
736 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
739 static void GLAPIENTRY
740 VertexAttrib4NbvARB(GLuint index
, const GLbyte
*v
)
742 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, BYTE_TO_FLOAT(v
[0]),
745 BYTE_TO_FLOAT(v
[3])));
748 static void GLAPIENTRY
749 VertexAttrib4bvARB(GLuint index
, const GLbyte
*v
)
751 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
754 /* GL_UNSIGNED_BYTE attributes */
756 static void GLAPIENTRY
757 VertexAttrib1NubvARB(GLuint index
, const GLubyte
*v
)
759 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UBYTE_TO_FLOAT(v
[0])));
762 static void GLAPIENTRY
763 VertexAttrib1ubvARB(GLuint index
, const GLubyte
*v
)
765 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
768 static void GLAPIENTRY
769 VertexAttrib2NubvARB(GLuint index
, const GLubyte
*v
)
771 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
772 UBYTE_TO_FLOAT(v
[0]),
773 UBYTE_TO_FLOAT(v
[1])));
776 static void GLAPIENTRY
777 VertexAttrib2ubvARB(GLuint index
, const GLubyte
*v
)
779 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
,
780 (GLfloat
)v
[0], (GLfloat
)v
[1]));
783 static void GLAPIENTRY
784 VertexAttrib3NubvARB(GLuint index
, const GLubyte
*v
)
786 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
787 UBYTE_TO_FLOAT(v
[0]),
788 UBYTE_TO_FLOAT(v
[1]),
789 UBYTE_TO_FLOAT(v
[2])));
791 static void GLAPIENTRY
792 VertexAttrib3ubvARB(GLuint index
, const GLubyte
*v
)
794 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
,
800 static void GLAPIENTRY
801 VertexAttrib4NubvARB(GLuint index
, const GLubyte
*v
)
803 CALL_VertexAttrib4fARB(GET_DISPATCH(),
805 UBYTE_TO_FLOAT(v
[0]),
806 UBYTE_TO_FLOAT(v
[1]),
807 UBYTE_TO_FLOAT(v
[2]),
808 UBYTE_TO_FLOAT(v
[3])));
811 static void GLAPIENTRY
812 VertexAttrib4ubvARB(GLuint index
, const GLubyte
*v
)
814 CALL_VertexAttrib4fARB(GET_DISPATCH(),
816 (GLfloat
)v
[0], (GLfloat
)v
[1],
817 (GLfloat
)v
[2], (GLfloat
)v
[3]));
820 /* GL_SHORT attributes */
822 static void GLAPIENTRY
823 VertexAttrib1NsvARB(GLuint index
, const GLshort
*v
)
825 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, SHORT_TO_FLOAT(v
[0])));
828 static void GLAPIENTRY
829 VertexAttrib1svARB(GLuint index
, const GLshort
*v
)
831 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
834 static void GLAPIENTRY
835 VertexAttrib2NsvARB(GLuint index
, const GLshort
*v
)
837 CALL_VertexAttrib2fARB(GET_DISPATCH(),
838 (index
, SHORT_TO_FLOAT(v
[0]),
839 SHORT_TO_FLOAT(v
[1])));
842 static void GLAPIENTRY
843 VertexAttrib2svARB(GLuint index
, const GLshort
*v
)
845 CALL_VertexAttrib2fARB(GET_DISPATCH(),
846 (index
, (GLfloat
)v
[0], (GLfloat
)v
[1]));
849 static void GLAPIENTRY
850 VertexAttrib3NsvARB(GLuint index
, const GLshort
*v
)
852 CALL_VertexAttrib3fARB(GET_DISPATCH(),
854 SHORT_TO_FLOAT(v
[0]),
855 SHORT_TO_FLOAT(v
[1]),
856 SHORT_TO_FLOAT(v
[2])));
859 static void GLAPIENTRY
860 VertexAttrib3svARB(GLuint index
, const GLshort
*v
)
862 CALL_VertexAttrib3fARB(GET_DISPATCH(),
864 (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2]));
867 static void GLAPIENTRY
868 VertexAttrib4NsvARB(GLuint index
, const GLshort
*v
)
870 CALL_VertexAttrib4fARB(GET_DISPATCH(),
872 SHORT_TO_FLOAT(v
[0]),
873 SHORT_TO_FLOAT(v
[1]),
874 SHORT_TO_FLOAT(v
[2]),
875 SHORT_TO_FLOAT(v
[3])));
878 static void GLAPIENTRY
879 VertexAttrib4svARB(GLuint index
, const GLshort
*v
)
881 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
882 (GLfloat
)v
[2], (GLfloat
)v
[3]));
885 /* GL_UNSIGNED_SHORT attributes */
887 static void GLAPIENTRY
888 VertexAttrib1NusvARB(GLuint index
, const GLushort
*v
)
890 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0])));
893 static void GLAPIENTRY
894 VertexAttrib1usvARB(GLuint index
, const GLushort
*v
)
896 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
899 static void GLAPIENTRY
900 VertexAttrib2NusvARB(GLuint index
, const GLushort
*v
)
902 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
903 USHORT_TO_FLOAT(v
[1])));
906 static void GLAPIENTRY
907 VertexAttrib2usvARB(GLuint index
, const GLushort
*v
)
909 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
913 static void GLAPIENTRY
914 VertexAttrib3NusvARB(GLuint index
, const GLushort
*v
)
916 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
917 USHORT_TO_FLOAT(v
[1]),
918 USHORT_TO_FLOAT(v
[2])));
921 static void GLAPIENTRY
922 VertexAttrib3usvARB(GLuint index
, const GLushort
*v
)
924 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
925 (GLfloat
)v
[1], (GLfloat
)v
[2]));
928 static void GLAPIENTRY
929 VertexAttrib4NusvARB(GLuint index
, const GLushort
*v
)
931 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, USHORT_TO_FLOAT(v
[0]),
932 USHORT_TO_FLOAT(v
[1]),
933 USHORT_TO_FLOAT(v
[2]),
934 USHORT_TO_FLOAT(v
[3])));
937 static void GLAPIENTRY
938 VertexAttrib4usvARB(GLuint index
, const GLushort
*v
)
940 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1], (GLfloat
)v
[2], (GLfloat
)v
[3]));
943 /* GL_INT attributes */
945 static void GLAPIENTRY
946 VertexAttrib1NivARB(GLuint index
, const GLint
*v
)
948 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0])));
951 static void GLAPIENTRY
952 VertexAttrib1ivARB(GLuint index
, const GLint
*v
)
954 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
957 static void GLAPIENTRY
958 VertexAttrib2NivARB(GLuint index
, const GLint
*v
)
960 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
961 INT_TO_FLOAT(v
[1])));
964 static void GLAPIENTRY
965 VertexAttrib2ivARB(GLuint index
, const GLint
*v
)
967 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
971 static void GLAPIENTRY
972 VertexAttrib3NivARB(GLuint index
, const GLint
*v
)
974 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
976 INT_TO_FLOAT(v
[2])));
979 static void GLAPIENTRY
980 VertexAttrib3ivARB(GLuint index
, const GLint
*v
)
982 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
983 (GLfloat
)v
[1], (GLfloat
)v
[2]));
986 static void GLAPIENTRY
987 VertexAttrib4NivARB(GLuint index
, const GLint
*v
)
989 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, INT_TO_FLOAT(v
[0]),
992 INT_TO_FLOAT(v
[3])));
995 static void GLAPIENTRY
996 VertexAttrib4ivARB(GLuint index
, const GLint
*v
)
998 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
999 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1002 /* GL_UNSIGNED_INT attributes */
1004 static void GLAPIENTRY
1005 VertexAttrib1NuivARB(GLuint index
, const GLuint
*v
)
1007 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0])));
1010 static void GLAPIENTRY
1011 VertexAttrib1uivARB(GLuint index
, const GLuint
*v
)
1013 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0]));
1016 static void GLAPIENTRY
1017 VertexAttrib2NuivARB(GLuint index
, const GLuint
*v
)
1019 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1020 UINT_TO_FLOAT(v
[1])));
1023 static void GLAPIENTRY
1024 VertexAttrib2uivARB(GLuint index
, const GLuint
*v
)
1026 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1030 static void GLAPIENTRY
1031 VertexAttrib3NuivARB(GLuint index
, const GLuint
*v
)
1033 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1034 UINT_TO_FLOAT(v
[1]),
1035 UINT_TO_FLOAT(v
[2])));
1038 static void GLAPIENTRY
1039 VertexAttrib3uivARB(GLuint index
, const GLuint
*v
)
1041 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0],
1042 (GLfloat
)v
[1], (GLfloat
)v
[2]));
1045 static void GLAPIENTRY
1046 VertexAttrib4NuivARB(GLuint index
, const GLuint
*v
)
1048 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, UINT_TO_FLOAT(v
[0]),
1049 UINT_TO_FLOAT(v
[1]),
1050 UINT_TO_FLOAT(v
[2]),
1051 UINT_TO_FLOAT(v
[3])));
1054 static void GLAPIENTRY
1055 VertexAttrib4uivARB(GLuint index
, const GLuint
*v
)
1057 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index
, (GLfloat
)v
[0], (GLfloat
)v
[1],
1058 (GLfloat
)v
[2], (GLfloat
)v
[3]));
1061 /* GL_FLOAT attributes */
1063 static void GLAPIENTRY
1064 VertexAttrib1fvARB(GLuint index
, const GLfloat
*v
)
1066 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index
, v
));
1069 static void GLAPIENTRY
1070 VertexAttrib2fvARB(GLuint index
, const GLfloat
*v
)
1072 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index
, v
));
1075 static void GLAPIENTRY
1076 VertexAttrib3fvARB(GLuint index
, const GLfloat
*v
)
1078 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index
, v
));
1081 static void GLAPIENTRY
1082 VertexAttrib4fvARB(GLuint index
, const GLfloat
*v
)
1084 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index
, v
));
1087 /* GL_DOUBLE attributes */
1089 static void GLAPIENTRY
1090 VertexAttrib1dvARB(GLuint index
, const GLdouble
*v
)
1092 CALL_VertexAttrib1dv(GET_DISPATCH(), (index
, v
));
1095 static void GLAPIENTRY
1096 VertexAttrib2dvARB(GLuint index
, const GLdouble
*v
)
1098 CALL_VertexAttrib2dv(GET_DISPATCH(), (index
, v
));
1101 static void GLAPIENTRY
1102 VertexAttrib3dvARB(GLuint index
, const GLdouble
*v
)
1104 CALL_VertexAttrib3dv(GET_DISPATCH(), (index
, v
));
1107 static void GLAPIENTRY
1108 VertexAttrib4dvARB(GLuint index
, const GLdouble
*v
)
1110 CALL_VertexAttrib4dv(GET_DISPATCH(), (index
, v
));
1115 * Integer-valued attributes
1117 static void GLAPIENTRY
1118 VertexAttribI1bv(GLuint index
, const GLbyte
*v
)
1120 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1123 static void GLAPIENTRY
1124 VertexAttribI2bv(GLuint index
, const GLbyte
*v
)
1126 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1129 static void GLAPIENTRY
1130 VertexAttribI3bv(GLuint index
, const GLbyte
*v
)
1132 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1135 static void GLAPIENTRY
1136 VertexAttribI4bv(GLuint index
, const GLbyte
*v
)
1138 CALL_VertexAttribI4bv(GET_DISPATCH(), (index
, v
));
1142 static void GLAPIENTRY
1143 VertexAttribI1ubv(GLuint index
, const GLubyte
*v
)
1145 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1148 static void GLAPIENTRY
1149 VertexAttribI2ubv(GLuint index
, const GLubyte
*v
)
1151 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1154 static void GLAPIENTRY
1155 VertexAttribI3ubv(GLuint index
, const GLubyte
*v
)
1157 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1160 static void GLAPIENTRY
1161 VertexAttribI4ubv(GLuint index
, const GLubyte
*v
)
1163 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index
, v
));
1168 static void GLAPIENTRY
1169 VertexAttribI1sv(GLuint index
, const GLshort
*v
)
1171 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1174 static void GLAPIENTRY
1175 VertexAttribI2sv(GLuint index
, const GLshort
*v
)
1177 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1180 static void GLAPIENTRY
1181 VertexAttribI3sv(GLuint index
, const GLshort
*v
)
1183 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1186 static void GLAPIENTRY
1187 VertexAttribI4sv(GLuint index
, const GLshort
*v
)
1189 CALL_VertexAttribI4sv(GET_DISPATCH(), (index
, v
));
1193 static void GLAPIENTRY
1194 VertexAttribI1usv(GLuint index
, const GLushort
*v
)
1196 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1199 static void GLAPIENTRY
1200 VertexAttribI2usv(GLuint index
, const GLushort
*v
)
1202 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1205 static void GLAPIENTRY
1206 VertexAttribI3usv(GLuint index
, const GLushort
*v
)
1208 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1211 static void GLAPIENTRY
1212 VertexAttribI4usv(GLuint index
, const GLushort
*v
)
1214 CALL_VertexAttribI4usv(GET_DISPATCH(), (index
, v
));
1219 static void GLAPIENTRY
1220 VertexAttribI1iv(GLuint index
, const GLint
*v
)
1222 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index
, v
[0]));
1225 static void GLAPIENTRY
1226 VertexAttribI2iv(GLuint index
, const GLint
*v
)
1228 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1231 static void GLAPIENTRY
1232 VertexAttribI3iv(GLuint index
, const GLint
*v
)
1234 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1237 static void GLAPIENTRY
1238 VertexAttribI4iv(GLuint index
, const GLint
*v
)
1240 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index
, v
));
1244 static void GLAPIENTRY
1245 VertexAttribI1uiv(GLuint index
, const GLuint
*v
)
1247 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index
, v
[0]));
1250 static void GLAPIENTRY
1251 VertexAttribI2uiv(GLuint index
, const GLuint
*v
)
1253 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1]));
1256 static void GLAPIENTRY
1257 VertexAttribI3uiv(GLuint index
, const GLuint
*v
)
1259 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index
, v
[0], v
[1], v
[2]));
1262 static void GLAPIENTRY
1263 VertexAttribI4uiv(GLuint index
, const GLuint
*v
)
1265 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index
, v
));
1268 /* GL_DOUBLE unconverted attributes */
1270 static void GLAPIENTRY
1271 VertexAttribL1dv(GLuint index
, const GLdouble
*v
)
1273 CALL_VertexAttribL1dv(GET_DISPATCH(), (index
, v
));
1276 static void GLAPIENTRY
1277 VertexAttribL2dv(GLuint index
, const GLdouble
*v
)
1279 CALL_VertexAttribL2dv(GET_DISPATCH(), (index
, v
));
1282 static void GLAPIENTRY
1283 VertexAttribL3dv(GLuint index
, const GLdouble
*v
)
1285 CALL_VertexAttribL3dv(GET_DISPATCH(), (index
, v
));
1288 static void GLAPIENTRY
1289 VertexAttribL4dv(GLuint index
, const GLdouble
*v
)
1291 CALL_VertexAttribL4dv(GET_DISPATCH(), (index
, v
));
1295 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1298 static const attrib_func AttribFuncsARB
[4][4][NUM_TYPES
] = {
1300 /* non-normalized */
1303 (attrib_func
) VertexAttrib1bvARB
,
1304 (attrib_func
) VertexAttrib1ubvARB
,
1305 (attrib_func
) VertexAttrib1svARB
,
1306 (attrib_func
) VertexAttrib1usvARB
,
1307 (attrib_func
) VertexAttrib1ivARB
,
1308 (attrib_func
) VertexAttrib1uivARB
,
1309 (attrib_func
) VertexAttrib1fvARB
,
1310 (attrib_func
) VertexAttrib1dvARB
1314 (attrib_func
) VertexAttrib2bvARB
,
1315 (attrib_func
) VertexAttrib2ubvARB
,
1316 (attrib_func
) VertexAttrib2svARB
,
1317 (attrib_func
) VertexAttrib2usvARB
,
1318 (attrib_func
) VertexAttrib2ivARB
,
1319 (attrib_func
) VertexAttrib2uivARB
,
1320 (attrib_func
) VertexAttrib2fvARB
,
1321 (attrib_func
) VertexAttrib2dvARB
1325 (attrib_func
) VertexAttrib3bvARB
,
1326 (attrib_func
) VertexAttrib3ubvARB
,
1327 (attrib_func
) VertexAttrib3svARB
,
1328 (attrib_func
) VertexAttrib3usvARB
,
1329 (attrib_func
) VertexAttrib3ivARB
,
1330 (attrib_func
) VertexAttrib3uivARB
,
1331 (attrib_func
) VertexAttrib3fvARB
,
1332 (attrib_func
) VertexAttrib3dvARB
1336 (attrib_func
) VertexAttrib4bvARB
,
1337 (attrib_func
) VertexAttrib4ubvARB
,
1338 (attrib_func
) VertexAttrib4svARB
,
1339 (attrib_func
) VertexAttrib4usvARB
,
1340 (attrib_func
) VertexAttrib4ivARB
,
1341 (attrib_func
) VertexAttrib4uivARB
,
1342 (attrib_func
) VertexAttrib4fvARB
,
1343 (attrib_func
) VertexAttrib4dvARB
1347 /* normalized (except for float/double) */
1350 (attrib_func
) VertexAttrib1NbvARB
,
1351 (attrib_func
) VertexAttrib1NubvARB
,
1352 (attrib_func
) VertexAttrib1NsvARB
,
1353 (attrib_func
) VertexAttrib1NusvARB
,
1354 (attrib_func
) VertexAttrib1NivARB
,
1355 (attrib_func
) VertexAttrib1NuivARB
,
1356 (attrib_func
) VertexAttrib1fvARB
,
1357 (attrib_func
) VertexAttrib1dvARB
1361 (attrib_func
) VertexAttrib2NbvARB
,
1362 (attrib_func
) VertexAttrib2NubvARB
,
1363 (attrib_func
) VertexAttrib2NsvARB
,
1364 (attrib_func
) VertexAttrib2NusvARB
,
1365 (attrib_func
) VertexAttrib2NivARB
,
1366 (attrib_func
) VertexAttrib2NuivARB
,
1367 (attrib_func
) VertexAttrib2fvARB
,
1368 (attrib_func
) VertexAttrib2dvARB
1372 (attrib_func
) VertexAttrib3NbvARB
,
1373 (attrib_func
) VertexAttrib3NubvARB
,
1374 (attrib_func
) VertexAttrib3NsvARB
,
1375 (attrib_func
) VertexAttrib3NusvARB
,
1376 (attrib_func
) VertexAttrib3NivARB
,
1377 (attrib_func
) VertexAttrib3NuivARB
,
1378 (attrib_func
) VertexAttrib3fvARB
,
1379 (attrib_func
) VertexAttrib3dvARB
1383 (attrib_func
) VertexAttrib4NbvARB
,
1384 (attrib_func
) VertexAttrib4NubvARB
,
1385 (attrib_func
) VertexAttrib4NsvARB
,
1386 (attrib_func
) VertexAttrib4NusvARB
,
1387 (attrib_func
) VertexAttrib4NivARB
,
1388 (attrib_func
) VertexAttrib4NuivARB
,
1389 (attrib_func
) VertexAttrib4fvARB
,
1390 (attrib_func
) VertexAttrib4dvARB
1395 /* integer-valued */
1398 (attrib_func
) VertexAttribI1bv
,
1399 (attrib_func
) VertexAttribI1ubv
,
1400 (attrib_func
) VertexAttribI1sv
,
1401 (attrib_func
) VertexAttribI1usv
,
1402 (attrib_func
) VertexAttribI1iv
,
1403 (attrib_func
) VertexAttribI1uiv
,
1404 NULL
, /* GL_FLOAT */
1405 NULL
/* GL_DOUBLE */
1409 (attrib_func
) VertexAttribI2bv
,
1410 (attrib_func
) VertexAttribI2ubv
,
1411 (attrib_func
) VertexAttribI2sv
,
1412 (attrib_func
) VertexAttribI2usv
,
1413 (attrib_func
) VertexAttribI2iv
,
1414 (attrib_func
) VertexAttribI2uiv
,
1415 NULL
, /* GL_FLOAT */
1416 NULL
/* GL_DOUBLE */
1420 (attrib_func
) VertexAttribI3bv
,
1421 (attrib_func
) VertexAttribI3ubv
,
1422 (attrib_func
) VertexAttribI3sv
,
1423 (attrib_func
) VertexAttribI3usv
,
1424 (attrib_func
) VertexAttribI3iv
,
1425 (attrib_func
) VertexAttribI3uiv
,
1426 NULL
, /* GL_FLOAT */
1427 NULL
/* GL_DOUBLE */
1431 (attrib_func
) VertexAttribI4bv
,
1432 (attrib_func
) VertexAttribI4ubv
,
1433 (attrib_func
) VertexAttribI4sv
,
1434 (attrib_func
) VertexAttribI4usv
,
1435 (attrib_func
) VertexAttribI4iv
,
1436 (attrib_func
) VertexAttribI4uiv
,
1437 NULL
, /* GL_FLOAT */
1438 NULL
/* GL_DOUBLE */
1452 (attrib_func
) VertexAttribL1dv
,
1463 (attrib_func
) VertexAttribL2dv
,
1474 (attrib_func
) VertexAttribL3dv
,
1485 (attrib_func
) VertexAttribL4dv
,
1493 _ae_create_context(struct gl_context
*ctx
)
1495 if (ctx
->aelt_context
)
1498 /* These _gloffset_* values may not be compile-time constants */
1499 SecondaryColorFuncs
[0] = _gloffset_SecondaryColor3bv
;
1500 SecondaryColorFuncs
[1] = _gloffset_SecondaryColor3ubv
;
1501 SecondaryColorFuncs
[2] = _gloffset_SecondaryColor3sv
;
1502 SecondaryColorFuncs
[3] = _gloffset_SecondaryColor3usv
;
1503 SecondaryColorFuncs
[4] = _gloffset_SecondaryColor3iv
;
1504 SecondaryColorFuncs
[5] = _gloffset_SecondaryColor3uiv
;
1505 SecondaryColorFuncs
[6] = _gloffset_SecondaryColor3fvEXT
;
1506 SecondaryColorFuncs
[7] = _gloffset_SecondaryColor3dv
;
1508 FogCoordFuncs
[0] = -1;
1509 FogCoordFuncs
[1] = -1;
1510 FogCoordFuncs
[2] = -1;
1511 FogCoordFuncs
[3] = -1;
1512 FogCoordFuncs
[4] = -1;
1513 FogCoordFuncs
[5] = -1;
1514 FogCoordFuncs
[6] = _gloffset_FogCoordfvEXT
;
1515 FogCoordFuncs
[7] = _gloffset_FogCoorddv
;
1517 ctx
->aelt_context
= calloc(1, sizeof(AEcontext
));
1518 if (!ctx
->aelt_context
)
1521 AE_CONTEXT(ctx
)->NewState
= ~0;
1527 _ae_destroy_context(struct gl_context
*ctx
)
1529 if (AE_CONTEXT(ctx
)) {
1530 free(ctx
->aelt_context
);
1531 ctx
->aelt_context
= NULL
;
1537 * Check if the given vertex buffer object exists and is not mapped.
1538 * If so, add it to the list of buffers we must map before executing
1539 * an glArrayElement call.
1542 check_vbo(AEcontext
*actx
, struct gl_buffer_object
*vbo
)
1544 if (_mesa_is_bufferobj(vbo
) &&
1545 !_mesa_bufferobj_mapped(vbo
, MAP_INTERNAL
)) {
1547 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1548 if (actx
->vbo
[i
] == vbo
)
1549 return; /* already in the list, we're done */
1550 assert(actx
->nr_vbos
< VERT_ATTRIB_MAX
);
1551 actx
->vbo
[actx
->nr_vbos
++] = vbo
;
1557 * Make a list of per-vertex functions to call for each glArrayElement call.
1558 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1560 * Note: this may be called during display list construction.
1563 _ae_update_state(struct gl_context
*ctx
)
1565 AEcontext
*actx
= AE_CONTEXT(ctx
);
1566 AEarray
*aa
= actx
->arrays
; /* non-indexed arrays (ex: glNormal) */
1567 AEattrib
*at
= actx
->attribs
; /* indexed arrays (ex: glMultiTexCoord) */
1569 struct gl_vertex_array_object
*vao
= ctx
->Array
.VAO
;
1573 /* conventional vertex arrays */
1574 if (vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Enabled
) {
1575 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
];
1576 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1577 aa
->offset
= IndexFuncs
[TYPE_IDX(aa
->array
->Type
)];
1578 check_vbo(actx
, aa
->binding
->BufferObj
);
1582 if (vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Enabled
) {
1583 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
];
1584 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1585 aa
->offset
= _gloffset_EdgeFlagv
;
1586 check_vbo(actx
, aa
->binding
->BufferObj
);
1590 if (vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Enabled
) {
1591 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_NORMAL
];
1592 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1593 aa
->offset
= NormalFuncs
[TYPE_IDX(aa
->array
->Type
)];
1594 check_vbo(actx
, aa
->binding
->BufferObj
);
1598 if (vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Enabled
) {
1599 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR0
];
1600 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1601 aa
->offset
= ColorFuncs
[aa
->array
->Size
-3][TYPE_IDX(aa
->array
->Type
)];
1602 check_vbo(actx
, aa
->binding
->BufferObj
);
1606 if (vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Enabled
) {
1607 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_COLOR1
];
1608 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1609 aa
->offset
= SecondaryColorFuncs
[TYPE_IDX(aa
->array
->Type
)];
1610 check_vbo(actx
, aa
->binding
->BufferObj
);
1614 if (vao
->VertexAttrib
[VERT_ATTRIB_FOG
].Enabled
) {
1615 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_FOG
];
1616 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1617 aa
->offset
= FogCoordFuncs
[TYPE_IDX(aa
->array
->Type
)];
1618 check_vbo(actx
, aa
->binding
->BufferObj
);
1622 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
1623 struct gl_array_attributes
*attribArray
=
1624 &vao
->VertexAttrib
[VERT_ATTRIB_TEX(i
)];
1625 if (attribArray
->Enabled
) {
1626 /* NOTE: we use generic glVertexAttribNV functions here.
1627 * If we ever remove GL_NV_vertex_program this will have to change.
1629 at
->array
= attribArray
;
1630 at
->binding
= &vao
->BufferBinding
[attribArray
->BufferBindingIndex
];
1631 assert(!at
->array
->Normalized
);
1632 at
->func
= AttribFuncsNV
[at
->array
->Normalized
]
1634 [TYPE_IDX(at
->array
->Type
)];
1635 at
->index
= VERT_ATTRIB_TEX0
+ i
;
1636 check_vbo(actx
, at
->binding
->BufferObj
);
1641 /* generic vertex attribute arrays */
1642 for (i
= 1; i
< VERT_ATTRIB_GENERIC_MAX
; i
++) { /* skip zero! */
1643 struct gl_array_attributes
*attribArray
=
1644 &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC(i
)];
1645 if (attribArray
->Enabled
) {
1647 at
->array
= attribArray
;
1648 at
->binding
= &vao
->BufferBinding
[attribArray
->BufferBindingIndex
];
1649 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1650 * function pointer here (for float arrays) since the pointer may
1651 * change from one execution of _ae_ArrayElement() to
1652 * the next. Doing so caused UT to break.
1654 if (at
->array
->Doubles
)
1656 else if (at
->array
->Integer
)
1658 else if (at
->array
->Normalized
)
1663 at
->func
= AttribFuncsARB
[intOrNorm
]
1665 [TYPE_IDX(at
->array
->Type
)];
1668 check_vbo(actx
, at
->binding
->BufferObj
);
1673 /* finally, vertex position */
1674 if (vao
->VertexAttrib
[VERT_ATTRIB_GENERIC0
].Enabled
) {
1675 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1676 * issued as the last (provoking) attribute).
1678 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_GENERIC0
];
1679 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1680 assert(aa
->array
->Size
>= 2); /* XXX fix someday? */
1681 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1682 check_vbo(actx
, aa
->binding
->BufferObj
);
1685 else if (vao
->VertexAttrib
[VERT_ATTRIB_POS
].Enabled
) {
1686 aa
->array
= &vao
->VertexAttrib
[VERT_ATTRIB_POS
];
1687 aa
->binding
= &vao
->BufferBinding
[aa
->array
->BufferBindingIndex
];
1688 aa
->offset
= VertexFuncs
[aa
->array
->Size
-2][TYPE_IDX(aa
->array
->Type
)];
1689 check_vbo(actx
, aa
->binding
->BufferObj
);
1693 check_vbo(actx
, vao
->IndexBufferObj
);
1695 assert(at
- actx
->attribs
<= VERT_ATTRIB_MAX
);
1696 assert(aa
- actx
->arrays
< 32);
1697 at
->func
= NULL
; /* terminate the list */
1698 aa
->offset
= -1; /* terminate the list */
1705 * Before replaying glArrayElements calls we need to map (for reading) any
1706 * VBOs referenced by the enabled vertex arrays.
1709 _ae_map_vbos(struct gl_context
*ctx
)
1711 AEcontext
*actx
= AE_CONTEXT(ctx
);
1714 if (actx
->mapped_vbos
)
1718 _ae_update_state(ctx
);
1720 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1721 ctx
->Driver
.MapBufferRange(ctx
, 0,
1728 actx
->mapped_vbos
= GL_TRUE
;
1736 _ae_unmap_vbos(struct gl_context
*ctx
)
1738 AEcontext
*actx
= AE_CONTEXT(ctx
);
1741 if (!actx
->mapped_vbos
)
1744 assert (!actx
->NewState
);
1746 for (i
= 0; i
< actx
->nr_vbos
; i
++)
1747 ctx
->Driver
.UnmapBuffer(ctx
, actx
->vbo
[i
], MAP_INTERNAL
);
1749 actx
->mapped_vbos
= GL_FALSE
;
1754 * Called via glArrayElement() and glDrawArrays().
1755 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1756 * for all enabled vertex arrays (for elt-th element).
1757 * Note: this may be called during display list construction.
1760 _ae_ArrayElement(GLint elt
)
1762 GET_CURRENT_CONTEXT(ctx
);
1763 const AEcontext
*actx
= AE_CONTEXT(ctx
);
1766 const struct _glapi_table
* const disp
= GET_DISPATCH();
1769 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1770 * then we call PrimitiveRestartNV and return.
1772 if (ctx
->Array
.PrimitiveRestart
&& (elt
== ctx
->Array
.RestartIndex
)) {
1773 CALL_PrimitiveRestartNV((struct _glapi_table
*)disp
, ());
1777 if (actx
->NewState
) {
1778 assert(!actx
->mapped_vbos
);
1779 _ae_update_state(ctx
);
1782 /* Determine if we need to map/unmap VBOs */
1783 do_map
= actx
->nr_vbos
&& !actx
->mapped_vbos
;
1788 /* emit generic attribute elements */
1789 for (at
= actx
->attribs
; at
->func
; at
++) {
1791 = ADD_POINTERS(at
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1792 _mesa_vertex_attrib_address(at
->array
, at
->binding
))
1793 + elt
* at
->binding
->Stride
;
1794 at
->func(at
->index
, src
);
1797 /* emit conventional arrays elements */
1798 for (aa
= actx
->arrays
; aa
->offset
!= -1 ; aa
++) {
1800 = ADD_POINTERS(aa
->binding
->BufferObj
->Mappings
[MAP_INTERNAL
].Pointer
,
1801 _mesa_vertex_attrib_address(aa
->array
, aa
->binding
))
1802 + elt
* aa
->binding
->Stride
;
1803 CALL_by_offset(disp
, (array_func
), aa
->offset
, ((const void *) src
));
1807 _ae_unmap_vbos(ctx
);
1812 _ae_invalidate_state(struct gl_context
*ctx
, GLbitfield new_state
)
1814 AEcontext
*actx
= AE_CONTEXT(ctx
);
1816 /* Only interested in this subset of mesa state. Need to prune
1817 * this down as both tnl/ and the drivers can raise statechanges
1818 * for arcane reasons in the middle of seemingly atomic operations
1819 * like DrawElements, over which we'd like to keep a known set of
1820 * arrays and vbo's mapped.
1822 * Luckily, neither the drivers nor tnl muck with the state that
1825 new_state
&= _NEW_ARRAY
| _NEW_PROGRAM
;
1827 assert(!actx
->mapped_vbos
);
1828 actx
->NewState
|= new_state
;
1834 _mesa_install_arrayelt_vtxfmt(struct _glapi_table
*disp
,
1835 const GLvertexformat
*vfmt
)
1837 SET_ArrayElement(disp
, vfmt
->ArrayElement
);