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