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