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