mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.
[mesa.git] / src / mesa / main / api_arrayelt.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
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.
30 */
31
32
33 /* Author:
34 * Keith Whitwell <keith@tungstengraphics.com>
35 */
36
37 #include "glheader.h"
38 #include "api_arrayelt.h"
39 #include "bufferobj.h"
40 #include "context.h"
41 #include "imports.h"
42 #include "macros.h"
43 #include "mtypes.h"
44 #include "main/dispatch.h"
45
46 typedef void (GLAPIENTRY *array_func)( const void * );
47
48 typedef struct {
49 const struct gl_client_array *array;
50 int offset;
51 } AEarray;
52
53 typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
54
55 typedef struct {
56 const struct gl_client_array *array;
57 attrib_func func;
58 GLuint index;
59 } AEattrib;
60
61 typedef struct {
62 AEarray arrays[32];
63 AEattrib attribs[VERT_ATTRIB_MAX + 1];
64 GLuint NewState;
65
66 struct gl_buffer_object *vbo[VERT_ATTRIB_MAX];
67 GLuint nr_vbos;
68 GLboolean mapped_vbos;
69
70 } AEcontext;
71
72 #define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
73
74
75 /*
76 * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
77 * in the range [0, 7]. Luckily these type tokens are sequentially
78 * numbered in gl.h, except for GL_DOUBLE.
79 */
80 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
81
82 #define NUM_TYPES 8
83
84
85 static const int ColorFuncs[2][NUM_TYPES] = {
86 {
87 _gloffset_Color3bv,
88 _gloffset_Color3ubv,
89 _gloffset_Color3sv,
90 _gloffset_Color3usv,
91 _gloffset_Color3iv,
92 _gloffset_Color3uiv,
93 _gloffset_Color3fv,
94 _gloffset_Color3dv,
95 },
96 {
97 _gloffset_Color4bv,
98 _gloffset_Color4ubv,
99 _gloffset_Color4sv,
100 _gloffset_Color4usv,
101 _gloffset_Color4iv,
102 _gloffset_Color4uiv,
103 _gloffset_Color4fv,
104 _gloffset_Color4dv,
105 },
106 };
107
108 static const int VertexFuncs[3][NUM_TYPES] = {
109 {
110 -1,
111 -1,
112 _gloffset_Vertex2sv,
113 -1,
114 _gloffset_Vertex2iv,
115 -1,
116 _gloffset_Vertex2fv,
117 _gloffset_Vertex2dv,
118 },
119 {
120 -1,
121 -1,
122 _gloffset_Vertex3sv,
123 -1,
124 _gloffset_Vertex3iv,
125 -1,
126 _gloffset_Vertex3fv,
127 _gloffset_Vertex3dv,
128 },
129 {
130 -1,
131 -1,
132 _gloffset_Vertex4sv,
133 -1,
134 _gloffset_Vertex4iv,
135 -1,
136 _gloffset_Vertex4fv,
137 _gloffset_Vertex4dv,
138 },
139 };
140
141 static const int IndexFuncs[NUM_TYPES] = {
142 -1,
143 _gloffset_Indexubv,
144 _gloffset_Indexsv,
145 -1,
146 _gloffset_Indexiv,
147 -1,
148 _gloffset_Indexfv,
149 _gloffset_Indexdv,
150 };
151
152 static const int NormalFuncs[NUM_TYPES] = {
153 _gloffset_Normal3bv,
154 -1,
155 _gloffset_Normal3sv,
156 -1,
157 _gloffset_Normal3iv,
158 -1,
159 _gloffset_Normal3fv,
160 _gloffset_Normal3dv,
161 };
162
163 /* Note: _gloffset_* for these may not be a compile-time constant. */
164 static int SecondaryColorFuncs[NUM_TYPES];
165 static int FogCoordFuncs[NUM_TYPES];
166
167
168 /**
169 ** GL_NV_vertex_program
170 **/
171
172 /* GL_BYTE attributes */
173
174 static void GLAPIENTRY
175 VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
176 {
177 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
178 }
179
180 static void GLAPIENTRY
181 VertexAttrib1bvNV(GLuint index, const GLbyte *v)
182 {
183 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
184 }
185
186 static void GLAPIENTRY
187 VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
188 {
189 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
190 }
191
192 static void GLAPIENTRY
193 VertexAttrib2bvNV(GLuint index, const GLbyte *v)
194 {
195 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
196 }
197
198 static void GLAPIENTRY
199 VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
200 {
201 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
202 BYTE_TO_FLOAT(v[1]),
203 BYTE_TO_FLOAT(v[2])));
204 }
205
206 static void GLAPIENTRY
207 VertexAttrib3bvNV(GLuint index, const GLbyte *v)
208 {
209 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
210 }
211
212 static void GLAPIENTRY
213 VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
214 {
215 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
216 BYTE_TO_FLOAT(v[1]),
217 BYTE_TO_FLOAT(v[2]),
218 BYTE_TO_FLOAT(v[3])));
219 }
220
221 static void GLAPIENTRY
222 VertexAttrib4bvNV(GLuint index, const GLbyte *v)
223 {
224 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
225 }
226
227 /* GL_UNSIGNED_BYTE attributes */
228
229 static void GLAPIENTRY
230 VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
231 {
232 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
233 }
234
235 static void GLAPIENTRY
236 VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
237 {
238 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
239 }
240
241 static void GLAPIENTRY
242 VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
243 {
244 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
245 UBYTE_TO_FLOAT(v[1])));
246 }
247
248 static void GLAPIENTRY
249 VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
250 {
251 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
252 }
253
254 static void GLAPIENTRY
255 VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
256 {
257 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
258 UBYTE_TO_FLOAT(v[1]),
259 UBYTE_TO_FLOAT(v[2])));
260 }
261 static void GLAPIENTRY
262 VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
263 {
264 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
265 (GLfloat)v[1], (GLfloat)v[2]));
266 }
267
268 static void GLAPIENTRY
269 VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
270 {
271 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
272 UBYTE_TO_FLOAT(v[1]),
273 UBYTE_TO_FLOAT(v[2]),
274 UBYTE_TO_FLOAT(v[3])));
275 }
276
277 static void GLAPIENTRY
278 VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
279 {
280 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
281 (GLfloat)v[1], (GLfloat)v[2],
282 (GLfloat)v[3]));
283 }
284
285 /* GL_SHORT attributes */
286
287 static void GLAPIENTRY
288 VertexAttrib1NsvNV(GLuint index, const GLshort *v)
289 {
290 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
291 }
292
293 static void GLAPIENTRY
294 VertexAttrib1svNV(GLuint index, const GLshort *v)
295 {
296 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
297 }
298
299 static void GLAPIENTRY
300 VertexAttrib2NsvNV(GLuint index, const GLshort *v)
301 {
302 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
303 SHORT_TO_FLOAT(v[1])));
304 }
305
306 static void GLAPIENTRY
307 VertexAttrib2svNV(GLuint index, const GLshort *v)
308 {
309 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
310 }
311
312 static void GLAPIENTRY
313 VertexAttrib3NsvNV(GLuint index, const GLshort *v)
314 {
315 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
316 SHORT_TO_FLOAT(v[1]),
317 SHORT_TO_FLOAT(v[2])));
318 }
319
320 static void GLAPIENTRY
321 VertexAttrib3svNV(GLuint index, const GLshort *v)
322 {
323 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
324 (GLfloat)v[2]));
325 }
326
327 static void GLAPIENTRY
328 VertexAttrib4NsvNV(GLuint index, const GLshort *v)
329 {
330 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
331 SHORT_TO_FLOAT(v[1]),
332 SHORT_TO_FLOAT(v[2]),
333 SHORT_TO_FLOAT(v[3])));
334 }
335
336 static void GLAPIENTRY
337 VertexAttrib4svNV(GLuint index, const GLshort *v)
338 {
339 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
340 (GLfloat)v[2], (GLfloat)v[3]));
341 }
342
343 /* GL_UNSIGNED_SHORT attributes */
344
345 static void GLAPIENTRY
346 VertexAttrib1NusvNV(GLuint index, const GLushort *v)
347 {
348 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
349 }
350
351 static void GLAPIENTRY
352 VertexAttrib1usvNV(GLuint index, const GLushort *v)
353 {
354 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
355 }
356
357 static void GLAPIENTRY
358 VertexAttrib2NusvNV(GLuint index, const GLushort *v)
359 {
360 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
361 USHORT_TO_FLOAT(v[1])));
362 }
363
364 static void GLAPIENTRY
365 VertexAttrib2usvNV(GLuint index, const GLushort *v)
366 {
367 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
368 (GLfloat)v[1]));
369 }
370
371 static void GLAPIENTRY
372 VertexAttrib3NusvNV(GLuint index, const GLushort *v)
373 {
374 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
375 USHORT_TO_FLOAT(v[1]),
376 USHORT_TO_FLOAT(v[2])));
377 }
378
379 static void GLAPIENTRY
380 VertexAttrib3usvNV(GLuint index, const GLushort *v)
381 {
382 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
383 (GLfloat)v[2]));
384 }
385
386 static void GLAPIENTRY
387 VertexAttrib4NusvNV(GLuint index, const GLushort *v)
388 {
389 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
390 USHORT_TO_FLOAT(v[1]),
391 USHORT_TO_FLOAT(v[2]),
392 USHORT_TO_FLOAT(v[3])));
393 }
394
395 static void GLAPIENTRY
396 VertexAttrib4usvNV(GLuint index, const GLushort *v)
397 {
398 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
399 (GLfloat)v[2], (GLfloat)v[3]));
400 }
401
402 /* GL_INT attributes */
403
404 static void GLAPIENTRY
405 VertexAttrib1NivNV(GLuint index, const GLint *v)
406 {
407 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
408 }
409
410 static void GLAPIENTRY
411 VertexAttrib1ivNV(GLuint index, const GLint *v)
412 {
413 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
414 }
415
416 static void GLAPIENTRY
417 VertexAttrib2NivNV(GLuint index, const GLint *v)
418 {
419 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
420 INT_TO_FLOAT(v[1])));
421 }
422
423 static void GLAPIENTRY
424 VertexAttrib2ivNV(GLuint index, const GLint *v)
425 {
426 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
427 }
428
429 static void GLAPIENTRY
430 VertexAttrib3NivNV(GLuint index, const GLint *v)
431 {
432 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
433 INT_TO_FLOAT(v[1]),
434 INT_TO_FLOAT(v[2])));
435 }
436
437 static void GLAPIENTRY
438 VertexAttrib3ivNV(GLuint index, const GLint *v)
439 {
440 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
441 (GLfloat)v[2]));
442 }
443
444 static void GLAPIENTRY
445 VertexAttrib4NivNV(GLuint index, const GLint *v)
446 {
447 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
448 INT_TO_FLOAT(v[1]),
449 INT_TO_FLOAT(v[2]),
450 INT_TO_FLOAT(v[3])));
451 }
452
453 static void GLAPIENTRY
454 VertexAttrib4ivNV(GLuint index, const GLint *v)
455 {
456 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
457 (GLfloat)v[2], (GLfloat)v[3]));
458 }
459
460 /* GL_UNSIGNED_INT attributes */
461
462 static void GLAPIENTRY
463 VertexAttrib1NuivNV(GLuint index, const GLuint *v)
464 {
465 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
466 }
467
468 static void GLAPIENTRY
469 VertexAttrib1uivNV(GLuint index, const GLuint *v)
470 {
471 CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
472 }
473
474 static void GLAPIENTRY
475 VertexAttrib2NuivNV(GLuint index, const GLuint *v)
476 {
477 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
478 UINT_TO_FLOAT(v[1])));
479 }
480
481 static void GLAPIENTRY
482 VertexAttrib2uivNV(GLuint index, const GLuint *v)
483 {
484 CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0],
485 (GLfloat)v[1]));
486 }
487
488 static void GLAPIENTRY
489 VertexAttrib3NuivNV(GLuint index, const GLuint *v)
490 {
491 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
492 UINT_TO_FLOAT(v[1]),
493 UINT_TO_FLOAT(v[2])));
494 }
495
496 static void GLAPIENTRY
497 VertexAttrib3uivNV(GLuint index, const GLuint *v)
498 {
499 CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
500 (GLfloat)v[2]));
501 }
502
503 static void GLAPIENTRY
504 VertexAttrib4NuivNV(GLuint index, const GLuint *v)
505 {
506 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
507 UINT_TO_FLOAT(v[1]),
508 UINT_TO_FLOAT(v[2]),
509 UINT_TO_FLOAT(v[3])));
510 }
511
512 static void GLAPIENTRY
513 VertexAttrib4uivNV(GLuint index, const GLuint *v)
514 {
515 CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
516 (GLfloat)v[2], (GLfloat)v[3]));
517 }
518
519 /* GL_FLOAT attributes */
520
521 static void GLAPIENTRY
522 VertexAttrib1fvNV(GLuint index, const GLfloat *v)
523 {
524 CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
525 }
526
527 static void GLAPIENTRY
528 VertexAttrib2fvNV(GLuint index, const GLfloat *v)
529 {
530 CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
531 }
532
533 static void GLAPIENTRY
534 VertexAttrib3fvNV(GLuint index, const GLfloat *v)
535 {
536 CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
537 }
538
539 static void GLAPIENTRY
540 VertexAttrib4fvNV(GLuint index, const GLfloat *v)
541 {
542 CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
543 }
544
545 /* GL_DOUBLE attributes */
546
547 static void GLAPIENTRY
548 VertexAttrib1dvNV(GLuint index, const GLdouble *v)
549 {
550 CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
551 }
552
553 static void GLAPIENTRY
554 VertexAttrib2dvNV(GLuint index, const GLdouble *v)
555 {
556 CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
557 }
558
559 static void GLAPIENTRY
560 VertexAttrib3dvNV(GLuint index, const GLdouble *v)
561 {
562 CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
563 }
564
565 static void GLAPIENTRY
566 VertexAttrib4dvNV(GLuint index, const GLdouble *v)
567 {
568 CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
569 }
570
571
572 /*
573 * Array [size][type] of VertexAttrib functions
574 */
575 static attrib_func AttribFuncsNV[2][4][NUM_TYPES] = {
576 {
577 /* non-normalized */
578 {
579 /* size 1 */
580 (attrib_func) VertexAttrib1bvNV,
581 (attrib_func) VertexAttrib1ubvNV,
582 (attrib_func) VertexAttrib1svNV,
583 (attrib_func) VertexAttrib1usvNV,
584 (attrib_func) VertexAttrib1ivNV,
585 (attrib_func) VertexAttrib1uivNV,
586 (attrib_func) VertexAttrib1fvNV,
587 (attrib_func) VertexAttrib1dvNV
588 },
589 {
590 /* size 2 */
591 (attrib_func) VertexAttrib2bvNV,
592 (attrib_func) VertexAttrib2ubvNV,
593 (attrib_func) VertexAttrib2svNV,
594 (attrib_func) VertexAttrib2usvNV,
595 (attrib_func) VertexAttrib2ivNV,
596 (attrib_func) VertexAttrib2uivNV,
597 (attrib_func) VertexAttrib2fvNV,
598 (attrib_func) VertexAttrib2dvNV
599 },
600 {
601 /* size 3 */
602 (attrib_func) VertexAttrib3bvNV,
603 (attrib_func) VertexAttrib3ubvNV,
604 (attrib_func) VertexAttrib3svNV,
605 (attrib_func) VertexAttrib3usvNV,
606 (attrib_func) VertexAttrib3ivNV,
607 (attrib_func) VertexAttrib3uivNV,
608 (attrib_func) VertexAttrib3fvNV,
609 (attrib_func) VertexAttrib3dvNV
610 },
611 {
612 /* size 4 */
613 (attrib_func) VertexAttrib4bvNV,
614 (attrib_func) VertexAttrib4ubvNV,
615 (attrib_func) VertexAttrib4svNV,
616 (attrib_func) VertexAttrib4usvNV,
617 (attrib_func) VertexAttrib4ivNV,
618 (attrib_func) VertexAttrib4uivNV,
619 (attrib_func) VertexAttrib4fvNV,
620 (attrib_func) VertexAttrib4dvNV
621 }
622 },
623 {
624 /* normalized (except for float/double) */
625 {
626 /* size 1 */
627 (attrib_func) VertexAttrib1NbvNV,
628 (attrib_func) VertexAttrib1NubvNV,
629 (attrib_func) VertexAttrib1NsvNV,
630 (attrib_func) VertexAttrib1NusvNV,
631 (attrib_func) VertexAttrib1NivNV,
632 (attrib_func) VertexAttrib1NuivNV,
633 (attrib_func) VertexAttrib1fvNV,
634 (attrib_func) VertexAttrib1dvNV
635 },
636 {
637 /* size 2 */
638 (attrib_func) VertexAttrib2NbvNV,
639 (attrib_func) VertexAttrib2NubvNV,
640 (attrib_func) VertexAttrib2NsvNV,
641 (attrib_func) VertexAttrib2NusvNV,
642 (attrib_func) VertexAttrib2NivNV,
643 (attrib_func) VertexAttrib2NuivNV,
644 (attrib_func) VertexAttrib2fvNV,
645 (attrib_func) VertexAttrib2dvNV
646 },
647 {
648 /* size 3 */
649 (attrib_func) VertexAttrib3NbvNV,
650 (attrib_func) VertexAttrib3NubvNV,
651 (attrib_func) VertexAttrib3NsvNV,
652 (attrib_func) VertexAttrib3NusvNV,
653 (attrib_func) VertexAttrib3NivNV,
654 (attrib_func) VertexAttrib3NuivNV,
655 (attrib_func) VertexAttrib3fvNV,
656 (attrib_func) VertexAttrib3dvNV
657 },
658 {
659 /* size 4 */
660 (attrib_func) VertexAttrib4NbvNV,
661 (attrib_func) VertexAttrib4NubvNV,
662 (attrib_func) VertexAttrib4NsvNV,
663 (attrib_func) VertexAttrib4NusvNV,
664 (attrib_func) VertexAttrib4NivNV,
665 (attrib_func) VertexAttrib4NuivNV,
666 (attrib_func) VertexAttrib4fvNV,
667 (attrib_func) VertexAttrib4dvNV
668 }
669 }
670 };
671
672
673 /**
674 ** GL_ARB_vertex_program
675 **/
676
677 /* GL_BYTE attributes */
678
679 static void GLAPIENTRY
680 VertexAttrib1NbvARB(GLuint index, const GLbyte *v)
681 {
682 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
683 }
684
685 static void GLAPIENTRY
686 VertexAttrib1bvARB(GLuint index, const GLbyte *v)
687 {
688 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
689 }
690
691 static void GLAPIENTRY
692 VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
693 {
694 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
695 }
696
697 static void GLAPIENTRY
698 VertexAttrib2bvARB(GLuint index, const GLbyte *v)
699 {
700 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
701 }
702
703 static void GLAPIENTRY
704 VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
705 {
706 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
707 BYTE_TO_FLOAT(v[1]),
708 BYTE_TO_FLOAT(v[2])));
709 }
710
711 static void GLAPIENTRY
712 VertexAttrib3bvARB(GLuint index, const GLbyte *v)
713 {
714 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
715 }
716
717 static void GLAPIENTRY
718 VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
719 {
720 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
721 BYTE_TO_FLOAT(v[1]),
722 BYTE_TO_FLOAT(v[2]),
723 BYTE_TO_FLOAT(v[3])));
724 }
725
726 static void GLAPIENTRY
727 VertexAttrib4bvARB(GLuint index, const GLbyte *v)
728 {
729 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
730 }
731
732 /* GL_UNSIGNED_BYTE attributes */
733
734 static void GLAPIENTRY
735 VertexAttrib1NubvARB(GLuint index, const GLubyte *v)
736 {
737 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
738 }
739
740 static void GLAPIENTRY
741 VertexAttrib1ubvARB(GLuint index, const GLubyte *v)
742 {
743 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
744 }
745
746 static void GLAPIENTRY
747 VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
748 {
749 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,
750 UBYTE_TO_FLOAT(v[0]),
751 UBYTE_TO_FLOAT(v[1])));
752 }
753
754 static void GLAPIENTRY
755 VertexAttrib2ubvARB(GLuint index, const GLubyte *v)
756 {
757 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,
758 (GLfloat)v[0], (GLfloat)v[1]));
759 }
760
761 static void GLAPIENTRY
762 VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
763 {
764 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,
765 UBYTE_TO_FLOAT(v[0]),
766 UBYTE_TO_FLOAT(v[1]),
767 UBYTE_TO_FLOAT(v[2])));
768 }
769 static void GLAPIENTRY
770 VertexAttrib3ubvARB(GLuint index, const GLubyte *v)
771 {
772 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,
773 (GLfloat)v[0],
774 (GLfloat)v[1],
775 (GLfloat)v[2]));
776 }
777
778 static void GLAPIENTRY
779 VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
780 {
781 CALL_VertexAttrib4fARB(GET_DISPATCH(),
782 (index,
783 UBYTE_TO_FLOAT(v[0]),
784 UBYTE_TO_FLOAT(v[1]),
785 UBYTE_TO_FLOAT(v[2]),
786 UBYTE_TO_FLOAT(v[3])));
787 }
788
789 static void GLAPIENTRY
790 VertexAttrib4ubvARB(GLuint index, const GLubyte *v)
791 {
792 CALL_VertexAttrib4fARB(GET_DISPATCH(),
793 (index,
794 (GLfloat)v[0], (GLfloat)v[1],
795 (GLfloat)v[2], (GLfloat)v[3]));
796 }
797
798 /* GL_SHORT attributes */
799
800 static void GLAPIENTRY
801 VertexAttrib1NsvARB(GLuint index, const GLshort *v)
802 {
803 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
804 }
805
806 static void GLAPIENTRY
807 VertexAttrib1svARB(GLuint index, const GLshort *v)
808 {
809 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
810 }
811
812 static void GLAPIENTRY
813 VertexAttrib2NsvARB(GLuint index, const GLshort *v)
814 {
815 CALL_VertexAttrib2fARB(GET_DISPATCH(),
816 (index, SHORT_TO_FLOAT(v[0]),
817 SHORT_TO_FLOAT(v[1])));
818 }
819
820 static void GLAPIENTRY
821 VertexAttrib2svARB(GLuint index, const GLshort *v)
822 {
823 CALL_VertexAttrib2fARB(GET_DISPATCH(),
824 (index, (GLfloat)v[0], (GLfloat)v[1]));
825 }
826
827 static void GLAPIENTRY
828 VertexAttrib3NsvARB(GLuint index, const GLshort *v)
829 {
830 CALL_VertexAttrib3fARB(GET_DISPATCH(),
831 (index,
832 SHORT_TO_FLOAT(v[0]),
833 SHORT_TO_FLOAT(v[1]),
834 SHORT_TO_FLOAT(v[2])));
835 }
836
837 static void GLAPIENTRY
838 VertexAttrib3svARB(GLuint index, const GLshort *v)
839 {
840 CALL_VertexAttrib3fARB(GET_DISPATCH(),
841 (index,
842 (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
843 }
844
845 static void GLAPIENTRY
846 VertexAttrib4NsvARB(GLuint index, const GLshort *v)
847 {
848 CALL_VertexAttrib4fARB(GET_DISPATCH(),
849 (index,
850 SHORT_TO_FLOAT(v[0]),
851 SHORT_TO_FLOAT(v[1]),
852 SHORT_TO_FLOAT(v[2]),
853 SHORT_TO_FLOAT(v[3])));
854 }
855
856 static void GLAPIENTRY
857 VertexAttrib4svARB(GLuint index, const GLshort *v)
858 {
859 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
860 (GLfloat)v[2], (GLfloat)v[3]));
861 }
862
863 /* GL_UNSIGNED_SHORT attributes */
864
865 static void GLAPIENTRY
866 VertexAttrib1NusvARB(GLuint index, const GLushort *v)
867 {
868 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
869 }
870
871 static void GLAPIENTRY
872 VertexAttrib1usvARB(GLuint index, const GLushort *v)
873 {
874 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
875 }
876
877 static void GLAPIENTRY
878 VertexAttrib2NusvARB(GLuint index, const GLushort *v)
879 {
880 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
881 USHORT_TO_FLOAT(v[1])));
882 }
883
884 static void GLAPIENTRY
885 VertexAttrib2usvARB(GLuint index, const GLushort *v)
886 {
887 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
888 (GLfloat)v[1]));
889 }
890
891 static void GLAPIENTRY
892 VertexAttrib3NusvARB(GLuint index, const GLushort *v)
893 {
894 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
895 USHORT_TO_FLOAT(v[1]),
896 USHORT_TO_FLOAT(v[2])));
897 }
898
899 static void GLAPIENTRY
900 VertexAttrib3usvARB(GLuint index, const GLushort *v)
901 {
902 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
903 (GLfloat)v[1], (GLfloat)v[2]));
904 }
905
906 static void GLAPIENTRY
907 VertexAttrib4NusvARB(GLuint index, const GLushort *v)
908 {
909 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
910 USHORT_TO_FLOAT(v[1]),
911 USHORT_TO_FLOAT(v[2]),
912 USHORT_TO_FLOAT(v[3])));
913 }
914
915 static void GLAPIENTRY
916 VertexAttrib4usvARB(GLuint index, const GLushort *v)
917 {
918 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
919 }
920
921 /* GL_INT attributes */
922
923 static void GLAPIENTRY
924 VertexAttrib1NivARB(GLuint index, const GLint *v)
925 {
926 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
927 }
928
929 static void GLAPIENTRY
930 VertexAttrib1ivARB(GLuint index, const GLint *v)
931 {
932 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
933 }
934
935 static void GLAPIENTRY
936 VertexAttrib2NivARB(GLuint index, const GLint *v)
937 {
938 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
939 INT_TO_FLOAT(v[1])));
940 }
941
942 static void GLAPIENTRY
943 VertexAttrib2ivARB(GLuint index, const GLint *v)
944 {
945 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
946 (GLfloat)v[1]));
947 }
948
949 static void GLAPIENTRY
950 VertexAttrib3NivARB(GLuint index, const GLint *v)
951 {
952 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
953 INT_TO_FLOAT(v[1]),
954 INT_TO_FLOAT(v[2])));
955 }
956
957 static void GLAPIENTRY
958 VertexAttrib3ivARB(GLuint index, const GLint *v)
959 {
960 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
961 (GLfloat)v[1], (GLfloat)v[2]));
962 }
963
964 static void GLAPIENTRY
965 VertexAttrib4NivARB(GLuint index, const GLint *v)
966 {
967 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
968 INT_TO_FLOAT(v[1]),
969 INT_TO_FLOAT(v[2]),
970 INT_TO_FLOAT(v[3])));
971 }
972
973 static void GLAPIENTRY
974 VertexAttrib4ivARB(GLuint index, const GLint *v)
975 {
976 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
977 (GLfloat)v[2], (GLfloat)v[3]));
978 }
979
980 /* GL_UNSIGNED_INT attributes */
981
982 static void GLAPIENTRY
983 VertexAttrib1NuivARB(GLuint index, const GLuint *v)
984 {
985 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
986 }
987
988 static void GLAPIENTRY
989 VertexAttrib1uivARB(GLuint index, const GLuint *v)
990 {
991 CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
992 }
993
994 static void GLAPIENTRY
995 VertexAttrib2NuivARB(GLuint index, const GLuint *v)
996 {
997 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
998 UINT_TO_FLOAT(v[1])));
999 }
1000
1001 static void GLAPIENTRY
1002 VertexAttrib2uivARB(GLuint index, const GLuint *v)
1003 {
1004 CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
1005 (GLfloat)v[1]));
1006 }
1007
1008 static void GLAPIENTRY
1009 VertexAttrib3NuivARB(GLuint index, const GLuint *v)
1010 {
1011 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
1012 UINT_TO_FLOAT(v[1]),
1013 UINT_TO_FLOAT(v[2])));
1014 }
1015
1016 static void GLAPIENTRY
1017 VertexAttrib3uivARB(GLuint index, const GLuint *v)
1018 {
1019 CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0],
1020 (GLfloat)v[1], (GLfloat)v[2]));
1021 }
1022
1023 static void GLAPIENTRY
1024 VertexAttrib4NuivARB(GLuint index, const GLuint *v)
1025 {
1026 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
1027 UINT_TO_FLOAT(v[1]),
1028 UINT_TO_FLOAT(v[2]),
1029 UINT_TO_FLOAT(v[3])));
1030 }
1031
1032 static void GLAPIENTRY
1033 VertexAttrib4uivARB(GLuint index, const GLuint *v)
1034 {
1035 CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1],
1036 (GLfloat)v[2], (GLfloat)v[3]));
1037 }
1038
1039 /* GL_FLOAT attributes */
1040
1041 static void GLAPIENTRY
1042 VertexAttrib1fvARB(GLuint index, const GLfloat *v)
1043 {
1044 CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v));
1045 }
1046
1047 static void GLAPIENTRY
1048 VertexAttrib2fvARB(GLuint index, const GLfloat *v)
1049 {
1050 CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v));
1051 }
1052
1053 static void GLAPIENTRY
1054 VertexAttrib3fvARB(GLuint index, const GLfloat *v)
1055 {
1056 CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v));
1057 }
1058
1059 static void GLAPIENTRY
1060 VertexAttrib4fvARB(GLuint index, const GLfloat *v)
1061 {
1062 CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v));
1063 }
1064
1065 /* GL_DOUBLE attributes */
1066
1067 static void GLAPIENTRY
1068 VertexAttrib1dvARB(GLuint index, const GLdouble *v)
1069 {
1070 CALL_VertexAttrib1dv(GET_DISPATCH(), (index, v));
1071 }
1072
1073 static void GLAPIENTRY
1074 VertexAttrib2dvARB(GLuint index, const GLdouble *v)
1075 {
1076 CALL_VertexAttrib2dv(GET_DISPATCH(), (index, v));
1077 }
1078
1079 static void GLAPIENTRY
1080 VertexAttrib3dvARB(GLuint index, const GLdouble *v)
1081 {
1082 CALL_VertexAttrib3dv(GET_DISPATCH(), (index, v));
1083 }
1084
1085 static void GLAPIENTRY
1086 VertexAttrib4dvARB(GLuint index, const GLdouble *v)
1087 {
1088 CALL_VertexAttrib4dv(GET_DISPATCH(), (index, v));
1089 }
1090
1091
1092 /**
1093 * Integer-valued attributes
1094 */
1095 static void GLAPIENTRY
1096 VertexAttribI1bv(GLuint index, const GLbyte *v)
1097 {
1098 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1099 }
1100
1101 static void GLAPIENTRY
1102 VertexAttribI2bv(GLuint index, const GLbyte *v)
1103 {
1104 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1105 }
1106
1107 static void GLAPIENTRY
1108 VertexAttribI3bv(GLuint index, const GLbyte *v)
1109 {
1110 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1111 }
1112
1113 static void GLAPIENTRY
1114 VertexAttribI4bv(GLuint index, const GLbyte *v)
1115 {
1116 CALL_VertexAttribI4bv(GET_DISPATCH(), (index, v));
1117 }
1118
1119
1120 static void GLAPIENTRY
1121 VertexAttribI1ubv(GLuint index, const GLubyte *v)
1122 {
1123 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1124 }
1125
1126 static void GLAPIENTRY
1127 VertexAttribI2ubv(GLuint index, const GLubyte *v)
1128 {
1129 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1130 }
1131
1132 static void GLAPIENTRY
1133 VertexAttribI3ubv(GLuint index, const GLubyte *v)
1134 {
1135 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1136 }
1137
1138 static void GLAPIENTRY
1139 VertexAttribI4ubv(GLuint index, const GLubyte *v)
1140 {
1141 CALL_VertexAttribI4ubv(GET_DISPATCH(), (index, v));
1142 }
1143
1144
1145
1146 static void GLAPIENTRY
1147 VertexAttribI1sv(GLuint index, const GLshort *v)
1148 {
1149 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1150 }
1151
1152 static void GLAPIENTRY
1153 VertexAttribI2sv(GLuint index, const GLshort *v)
1154 {
1155 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1156 }
1157
1158 static void GLAPIENTRY
1159 VertexAttribI3sv(GLuint index, const GLshort *v)
1160 {
1161 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1162 }
1163
1164 static void GLAPIENTRY
1165 VertexAttribI4sv(GLuint index, const GLshort *v)
1166 {
1167 CALL_VertexAttribI4sv(GET_DISPATCH(), (index, v));
1168 }
1169
1170
1171 static void GLAPIENTRY
1172 VertexAttribI1usv(GLuint index, const GLushort *v)
1173 {
1174 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1175 }
1176
1177 static void GLAPIENTRY
1178 VertexAttribI2usv(GLuint index, const GLushort *v)
1179 {
1180 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1181 }
1182
1183 static void GLAPIENTRY
1184 VertexAttribI3usv(GLuint index, const GLushort *v)
1185 {
1186 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1187 }
1188
1189 static void GLAPIENTRY
1190 VertexAttribI4usv(GLuint index, const GLushort *v)
1191 {
1192 CALL_VertexAttribI4usv(GET_DISPATCH(), (index, v));
1193 }
1194
1195
1196
1197 static void GLAPIENTRY
1198 VertexAttribI1iv(GLuint index, const GLint *v)
1199 {
1200 CALL_VertexAttribI1iEXT(GET_DISPATCH(), (index, v[0]));
1201 }
1202
1203 static void GLAPIENTRY
1204 VertexAttribI2iv(GLuint index, const GLint *v)
1205 {
1206 CALL_VertexAttribI2iEXT(GET_DISPATCH(), (index, v[0], v[1]));
1207 }
1208
1209 static void GLAPIENTRY
1210 VertexAttribI3iv(GLuint index, const GLint *v)
1211 {
1212 CALL_VertexAttribI3iEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1213 }
1214
1215 static void GLAPIENTRY
1216 VertexAttribI4iv(GLuint index, const GLint *v)
1217 {
1218 CALL_VertexAttribI4ivEXT(GET_DISPATCH(), (index, v));
1219 }
1220
1221
1222 static void GLAPIENTRY
1223 VertexAttribI1uiv(GLuint index, const GLuint *v)
1224 {
1225 CALL_VertexAttribI1uiEXT(GET_DISPATCH(), (index, v[0]));
1226 }
1227
1228 static void GLAPIENTRY
1229 VertexAttribI2uiv(GLuint index, const GLuint *v)
1230 {
1231 CALL_VertexAttribI2uiEXT(GET_DISPATCH(), (index, v[0], v[1]));
1232 }
1233
1234 static void GLAPIENTRY
1235 VertexAttribI3uiv(GLuint index, const GLuint *v)
1236 {
1237 CALL_VertexAttribI3uiEXT(GET_DISPATCH(), (index, v[0], v[1], v[2]));
1238 }
1239
1240 static void GLAPIENTRY
1241 VertexAttribI4uiv(GLuint index, const GLuint *v)
1242 {
1243 CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v));
1244 }
1245
1246
1247
1248
1249 /*
1250 * Array [unnormalized/normalized/integer][size][type] of VertexAttrib
1251 * functions
1252 */
1253 static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = {
1254 {
1255 /* non-normalized */
1256 {
1257 /* size 1 */
1258 (attrib_func) VertexAttrib1bvARB,
1259 (attrib_func) VertexAttrib1ubvARB,
1260 (attrib_func) VertexAttrib1svARB,
1261 (attrib_func) VertexAttrib1usvARB,
1262 (attrib_func) VertexAttrib1ivARB,
1263 (attrib_func) VertexAttrib1uivARB,
1264 (attrib_func) VertexAttrib1fvARB,
1265 (attrib_func) VertexAttrib1dvARB
1266 },
1267 {
1268 /* size 2 */
1269 (attrib_func) VertexAttrib2bvARB,
1270 (attrib_func) VertexAttrib2ubvARB,
1271 (attrib_func) VertexAttrib2svARB,
1272 (attrib_func) VertexAttrib2usvARB,
1273 (attrib_func) VertexAttrib2ivARB,
1274 (attrib_func) VertexAttrib2uivARB,
1275 (attrib_func) VertexAttrib2fvARB,
1276 (attrib_func) VertexAttrib2dvARB
1277 },
1278 {
1279 /* size 3 */
1280 (attrib_func) VertexAttrib3bvARB,
1281 (attrib_func) VertexAttrib3ubvARB,
1282 (attrib_func) VertexAttrib3svARB,
1283 (attrib_func) VertexAttrib3usvARB,
1284 (attrib_func) VertexAttrib3ivARB,
1285 (attrib_func) VertexAttrib3uivARB,
1286 (attrib_func) VertexAttrib3fvARB,
1287 (attrib_func) VertexAttrib3dvARB
1288 },
1289 {
1290 /* size 4 */
1291 (attrib_func) VertexAttrib4bvARB,
1292 (attrib_func) VertexAttrib4ubvARB,
1293 (attrib_func) VertexAttrib4svARB,
1294 (attrib_func) VertexAttrib4usvARB,
1295 (attrib_func) VertexAttrib4ivARB,
1296 (attrib_func) VertexAttrib4uivARB,
1297 (attrib_func) VertexAttrib4fvARB,
1298 (attrib_func) VertexAttrib4dvARB
1299 }
1300 },
1301 {
1302 /* normalized (except for float/double) */
1303 {
1304 /* size 1 */
1305 (attrib_func) VertexAttrib1NbvARB,
1306 (attrib_func) VertexAttrib1NubvARB,
1307 (attrib_func) VertexAttrib1NsvARB,
1308 (attrib_func) VertexAttrib1NusvARB,
1309 (attrib_func) VertexAttrib1NivARB,
1310 (attrib_func) VertexAttrib1NuivARB,
1311 (attrib_func) VertexAttrib1fvARB,
1312 (attrib_func) VertexAttrib1dvARB
1313 },
1314 {
1315 /* size 2 */
1316 (attrib_func) VertexAttrib2NbvARB,
1317 (attrib_func) VertexAttrib2NubvARB,
1318 (attrib_func) VertexAttrib2NsvARB,
1319 (attrib_func) VertexAttrib2NusvARB,
1320 (attrib_func) VertexAttrib2NivARB,
1321 (attrib_func) VertexAttrib2NuivARB,
1322 (attrib_func) VertexAttrib2fvARB,
1323 (attrib_func) VertexAttrib2dvARB
1324 },
1325 {
1326 /* size 3 */
1327 (attrib_func) VertexAttrib3NbvARB,
1328 (attrib_func) VertexAttrib3NubvARB,
1329 (attrib_func) VertexAttrib3NsvARB,
1330 (attrib_func) VertexAttrib3NusvARB,
1331 (attrib_func) VertexAttrib3NivARB,
1332 (attrib_func) VertexAttrib3NuivARB,
1333 (attrib_func) VertexAttrib3fvARB,
1334 (attrib_func) VertexAttrib3dvARB
1335 },
1336 {
1337 /* size 4 */
1338 (attrib_func) VertexAttrib4NbvARB,
1339 (attrib_func) VertexAttrib4NubvARB,
1340 (attrib_func) VertexAttrib4NsvARB,
1341 (attrib_func) VertexAttrib4NusvARB,
1342 (attrib_func) VertexAttrib4NivARB,
1343 (attrib_func) VertexAttrib4NuivARB,
1344 (attrib_func) VertexAttrib4fvARB,
1345 (attrib_func) VertexAttrib4dvARB
1346 }
1347 },
1348
1349 {
1350 /* integer-valued */
1351 {
1352 /* size 1 */
1353 (attrib_func) VertexAttribI1bv,
1354 (attrib_func) VertexAttribI1ubv,
1355 (attrib_func) VertexAttribI1sv,
1356 (attrib_func) VertexAttribI1usv,
1357 (attrib_func) VertexAttribI1iv,
1358 (attrib_func) VertexAttribI1uiv,
1359 NULL, /* GL_FLOAT */
1360 NULL /* GL_DOUBLE */
1361 },
1362 {
1363 /* size 2 */
1364 (attrib_func) VertexAttribI2bv,
1365 (attrib_func) VertexAttribI2ubv,
1366 (attrib_func) VertexAttribI2sv,
1367 (attrib_func) VertexAttribI2usv,
1368 (attrib_func) VertexAttribI2iv,
1369 (attrib_func) VertexAttribI2uiv,
1370 NULL, /* GL_FLOAT */
1371 NULL /* GL_DOUBLE */
1372 },
1373 {
1374 /* size 3 */
1375 (attrib_func) VertexAttribI3bv,
1376 (attrib_func) VertexAttribI3ubv,
1377 (attrib_func) VertexAttribI3sv,
1378 (attrib_func) VertexAttribI3usv,
1379 (attrib_func) VertexAttribI3iv,
1380 (attrib_func) VertexAttribI3uiv,
1381 NULL, /* GL_FLOAT */
1382 NULL /* GL_DOUBLE */
1383 },
1384 {
1385 /* size 4 */
1386 (attrib_func) VertexAttribI4bv,
1387 (attrib_func) VertexAttribI4ubv,
1388 (attrib_func) VertexAttribI4sv,
1389 (attrib_func) VertexAttribI4usv,
1390 (attrib_func) VertexAttribI4iv,
1391 (attrib_func) VertexAttribI4uiv,
1392 NULL, /* GL_FLOAT */
1393 NULL /* GL_DOUBLE */
1394 }
1395 }
1396 };
1397
1398 /**********************************************************************/
1399
1400
1401 GLboolean _ae_create_context( struct gl_context *ctx )
1402 {
1403 if (ctx->aelt_context)
1404 return GL_TRUE;
1405
1406 /* These _gloffset_* values may not be compile-time constants */
1407 SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bv;
1408 SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubv;
1409 SecondaryColorFuncs[2] = _gloffset_SecondaryColor3sv;
1410 SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usv;
1411 SecondaryColorFuncs[4] = _gloffset_SecondaryColor3iv;
1412 SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uiv;
1413 SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
1414 SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dv;
1415
1416 FogCoordFuncs[0] = -1;
1417 FogCoordFuncs[1] = -1;
1418 FogCoordFuncs[2] = -1;
1419 FogCoordFuncs[3] = -1;
1420 FogCoordFuncs[4] = -1;
1421 FogCoordFuncs[5] = -1;
1422 FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
1423 FogCoordFuncs[7] = _gloffset_FogCoorddv;
1424
1425 ctx->aelt_context = calloc(1, sizeof(AEcontext));
1426 if (!ctx->aelt_context)
1427 return GL_FALSE;
1428
1429 AE_CONTEXT(ctx)->NewState = ~0;
1430 return GL_TRUE;
1431 }
1432
1433
1434 void _ae_destroy_context( struct gl_context *ctx )
1435 {
1436 if ( AE_CONTEXT( ctx ) ) {
1437 free(ctx->aelt_context);
1438 ctx->aelt_context = NULL;
1439 }
1440 }
1441
1442 static void check_vbo( AEcontext *actx,
1443 struct gl_buffer_object *vbo )
1444 {
1445 if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) {
1446 GLuint i;
1447 for (i = 0; i < actx->nr_vbos; i++)
1448 if (actx->vbo[i] == vbo)
1449 return;
1450 assert(actx->nr_vbos < VERT_ATTRIB_MAX);
1451 actx->vbo[actx->nr_vbos++] = vbo;
1452 }
1453 }
1454
1455
1456 /**
1457 * Make a list of per-vertex functions to call for each glArrayElement call.
1458 * These functions access the array data (i.e. glVertex, glColor, glNormal,
1459 * etc).
1460 * Note: this may be called during display list construction.
1461 */
1462 static void _ae_update_state( struct gl_context *ctx )
1463 {
1464 AEcontext *actx = AE_CONTEXT(ctx);
1465 AEarray *aa = actx->arrays;
1466 AEattrib *at = actx->attribs;
1467 GLuint i;
1468 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
1469
1470 actx->nr_vbos = 0;
1471
1472 /* conventional vertex arrays */
1473 if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
1474 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
1475 aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
1476 check_vbo(actx, aa->array->BufferObj);
1477 aa++;
1478 }
1479 if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
1480 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG];
1481 aa->offset = _gloffset_EdgeFlagv;
1482 check_vbo(actx, aa->array->BufferObj);
1483 aa++;
1484 }
1485 if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
1486 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL];
1487 aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
1488 check_vbo(actx, aa->array->BufferObj);
1489 aa++;
1490 }
1491 if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
1492 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0];
1493 aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
1494 check_vbo(actx, aa->array->BufferObj);
1495 aa++;
1496 }
1497 if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
1498 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1];
1499 aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
1500 check_vbo(actx, aa->array->BufferObj);
1501 aa++;
1502 }
1503 if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
1504 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_FOG];
1505 aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
1506 check_vbo(actx, aa->array->BufferObj);
1507 aa++;
1508 }
1509 for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
1510 struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)];
1511 if (attribArray->Enabled) {
1512 /* NOTE: we use generic glVertexAttribNV functions here.
1513 * If we ever remove GL_NV_vertex_program this will have to change.
1514 */
1515 at->array = attribArray;
1516 ASSERT(!at->array->Normalized);
1517 at->func = AttribFuncsNV[at->array->Normalized]
1518 [at->array->Size-1]
1519 [TYPE_IDX(at->array->Type)];
1520 at->index = VERT_ATTRIB_TEX0 + i;
1521 check_vbo(actx, at->array->BufferObj);
1522 at++;
1523 }
1524 }
1525
1526 /* generic vertex attribute arrays */
1527 for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */
1528 struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
1529 if (attribArray->Enabled) {
1530 GLint intOrNorm;
1531 at->array = attribArray;
1532 /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
1533 * function pointer here (for float arrays) since the pointer may
1534 * change from one execution of _ae_ArrayElement() to
1535 * the next. Doing so caused UT to break.
1536 */
1537 if (at->array->Integer)
1538 intOrNorm = 2;
1539 else if (at->array->Normalized)
1540 intOrNorm = 1;
1541 else
1542 intOrNorm = 0;
1543
1544 at->func = AttribFuncsARB[intOrNorm]
1545 [at->array->Size-1]
1546 [TYPE_IDX(at->array->Type)];
1547
1548 at->index = i;
1549 check_vbo(actx, at->array->BufferObj);
1550 at++;
1551 }
1552 }
1553
1554 /* finally, vertex position */
1555 if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
1556 /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
1557 * issued as the last (provoking) attribute).
1558 */
1559 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0];
1560 assert(aa->array->Size >= 2); /* XXX fix someday? */
1561 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1562 check_vbo(actx, aa->array->BufferObj);
1563 aa++;
1564 }
1565 else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
1566 aa->array = &arrayObj->VertexAttrib[VERT_ATTRIB_POS];
1567 aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
1568 check_vbo(actx, aa->array->BufferObj);
1569 aa++;
1570 }
1571
1572 check_vbo(actx, arrayObj->ElementArrayBufferObj);
1573
1574 ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
1575 ASSERT(aa - actx->arrays < 32);
1576 at->func = NULL; /* terminate the list */
1577 aa->offset = -1; /* terminate the list */
1578
1579 actx->NewState = 0;
1580 }
1581
1582 void _ae_map_vbos( struct gl_context *ctx )
1583 {
1584 AEcontext *actx = AE_CONTEXT(ctx);
1585 GLuint i;
1586
1587 if (actx->mapped_vbos)
1588 return;
1589
1590 if (actx->NewState)
1591 _ae_update_state(ctx);
1592
1593 for (i = 0; i < actx->nr_vbos; i++)
1594 ctx->Driver.MapBufferRange(ctx, 0,
1595 actx->vbo[i]->Size,
1596 GL_MAP_READ_BIT,
1597 actx->vbo[i]);
1598
1599 if (actx->nr_vbos)
1600 actx->mapped_vbos = GL_TRUE;
1601 }
1602
1603 void _ae_unmap_vbos( struct gl_context *ctx )
1604 {
1605 AEcontext *actx = AE_CONTEXT(ctx);
1606 GLuint i;
1607
1608 if (!actx->mapped_vbos)
1609 return;
1610
1611 assert (!actx->NewState);
1612
1613 for (i = 0; i < actx->nr_vbos; i++)
1614 ctx->Driver.UnmapBuffer(ctx, actx->vbo[i]);
1615
1616 actx->mapped_vbos = GL_FALSE;
1617 }
1618
1619
1620 /**
1621 * Called via glArrayElement() and glDrawArrays().
1622 * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
1623 * for all enabled vertex arrays (for elt-th element).
1624 * Note: this may be called during display list construction.
1625 */
1626 void GLAPIENTRY _ae_ArrayElement( GLint elt )
1627 {
1628 GET_CURRENT_CONTEXT(ctx);
1629 const AEcontext *actx = AE_CONTEXT(ctx);
1630 const AEarray *aa;
1631 const AEattrib *at;
1632 const struct _glapi_table * const disp = GET_DISPATCH();
1633 GLboolean do_map;
1634
1635 /* If PrimitiveRestart is enabled and the index is the RestartIndex
1636 * then we call PrimitiveRestartNV and return.
1637 */
1638 if (ctx->Array._PrimitiveRestart && (elt == ctx->Array._RestartIndex)) {
1639 CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
1640 return;
1641 }
1642
1643 if (actx->NewState) {
1644 assert(!actx->mapped_vbos);
1645 _ae_update_state( ctx );
1646 }
1647
1648 /* Determine if we need to map/unmap VBOs */
1649 do_map = actx->nr_vbos && !actx->mapped_vbos;
1650
1651 if (do_map)
1652 _ae_map_vbos(ctx);
1653
1654 /* emit generic attribute elements */
1655 for (at = actx->attribs; at->func; at++) {
1656 const GLubyte *src
1657 = ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr)
1658 + elt * at->array->StrideB;
1659 at->func( at->index, src );
1660 }
1661
1662 /* emit conventional arrays elements */
1663 for (aa = actx->arrays; aa->offset != -1 ; aa++) {
1664 const GLubyte *src
1665 = ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr)
1666 + elt * aa->array->StrideB;
1667 CALL_by_offset( disp, (array_func), aa->offset,
1668 ((const void *) src) );
1669 }
1670
1671 if (do_map)
1672 _ae_unmap_vbos(ctx);
1673 }
1674
1675
1676 void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state )
1677 {
1678 AEcontext *actx = AE_CONTEXT(ctx);
1679
1680
1681 /* Only interested in this subset of mesa state. Need to prune
1682 * this down as both tnl/ and the drivers can raise statechanges
1683 * for arcane reasons in the middle of seemingly atomic operations
1684 * like DrawElements, over which we'd like to keep a known set of
1685 * arrays and vbo's mapped.
1686 *
1687 * Luckily, neither the drivers nor tnl muck with the state that
1688 * concerns us here:
1689 */
1690 new_state &= _NEW_ARRAY | _NEW_PROGRAM;
1691 if (new_state) {
1692 assert(!actx->mapped_vbos);
1693 actx->NewState |= new_state;
1694 }
1695 }
1696
1697
1698 void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
1699 const GLvertexformat *vfmt)
1700 {
1701 SET_ArrayElement(disp, vfmt->ArrayElement);
1702 }