Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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