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