1/**************************************************************************
2
3Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
4Copyright 2011 Dave Airlie (ARB_vertex_type_2_10_10_10_rev support)
5All Rights Reserved.
6
7Permission is hereby granted, free of charge, to any person obtaining a
8copy of this software and associated documentation files (the "Software"),
9to deal in the Software without restriction, including without limitation
10on the rights to use, copy, modify, merge, publish, distribute, sub
11license, and/or sell copies of the Software, and to permit persons to whom
12the Software is furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice (including the next
15paragraph) shall be included in all copies or substantial portions of the
16Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26**************************************************************************/
27
28/* float */
29#define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 )
30#define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 )
31#define ATTR3FV( A, V ) ATTR( A, 3, GL_FLOAT, (V)[0], (V)[1], (V)[2], 1 )
32#define ATTR4FV( A, V ) ATTR( A, 4, GL_FLOAT, (V)[0], (V)[1], (V)[2], (V)[3] )
33
34#define ATTR1F( A, X )          ATTR( A, 1, GL_FLOAT, X, 0, 0, 1 )
35#define ATTR2F( A, X, Y )       ATTR( A, 2, GL_FLOAT, X, Y, 0, 1 )
36#define ATTR3F( A, X, Y, Z )    ATTR( A, 3, GL_FLOAT, X, Y, Z, 1 )
37#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, GL_FLOAT, X, Y, Z, W )
38
39/* int */
40#define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \
41                                       INT_AS_FLT(X), INT_AS_FLT(Y), \
42                                       INT_AS_FLT(Z), INT_AS_FLT(W) )
43
44#define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 )
45#define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 )
46#define ATTR4IV( A, V ) ATTRI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
47
48#define ATTR1I( A, X )          ATTRI( A, 1, X, 0, 0, 1 )
49#define ATTR2I( A, X, Y )       ATTRI( A, 2, X, Y, 0, 1 )
50#define ATTR3I( A, X, Y, Z )    ATTRI( A, 3, X, Y, Z, 1 )
51#define ATTR4I( A, X, Y, Z, W ) ATTRI( A, 4, X, Y, Z, W )
52
53
54/* uint */
55#define ATTRUI( A, N, X, Y, Z, W) ATTR( A, N, GL_UNSIGNED_INT, \
56                                        UINT_AS_FLT(X), UINT_AS_FLT(Y), \
57                                        UINT_AS_FLT(Z), UINT_AS_FLT(W) )
58
59#define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 )
60#define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 )
61#define ATTR4UIV( A, V ) ATTRUI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
62
63#define ATTR1UI( A, X )          ATTRUI( A, 1, X, 0, 0, 1 )
64#define ATTR2UI( A, X, Y )       ATTRUI( A, 2, X, Y, 0, 1 )
65#define ATTR3UI( A, X, Y, Z )    ATTRUI( A, 3, X, Y, Z, 1 )
66#define ATTR4UI( A, X, Y, Z, W ) ATTRUI( A, 4, X, Y, Z, W )
67
68#define MAT_ATTR( A, N, V ) ATTR( A, N, GL_FLOAT, (V)[0], (V)[1], (V)[2], (V)[3] )
69
70static inline float conv_ui10_to_norm_float(unsigned ui10)
71{
72   return (float)(ui10) / 1023.0;
73}
74
75static inline float conv_ui2_to_norm_float(unsigned ui2)
76{
77   return (float)(ui2) / 3.0;
78}
79
80#define ATTRUI10_1( A, UI ) ATTR( A, 1, GL_FLOAT, (UI) & 0x3ff, 0, 0, 1 )
81#define ATTRUI10_2( A, UI ) ATTR( A, 2, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 )
82#define ATTRUI10_3( A, UI ) ATTR( A, 3, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 )
83#define ATTRUI10_4( A, UI ) ATTR( A, 4, GL_FLOAT, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 )
84
85#define ATTRUI10N_1( A, UI ) ATTR( A, 1, GL_FLOAT, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 )
86#define ATTRUI10N_2( A, UI ) ATTR( A, 2, GL_FLOAT, \
87				   conv_ui10_to_norm_float((UI) & 0x3ff), \
88				   conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), 0, 1 )
89#define ATTRUI10N_3( A, UI ) ATTR( A, 3, GL_FLOAT, \
90				   conv_ui10_to_norm_float((UI) & 0x3ff), \
91				   conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \
92				   conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), 1 )
93#define ATTRUI10N_4( A, UI ) ATTR( A, 4, GL_FLOAT, \
94				   conv_ui10_to_norm_float((UI) & 0x3ff), \
95				   conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \
96				   conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), \
97				   conv_ui2_to_norm_float(((UI) >> 30) & 0x3) )
98
99struct attr_bits_10 {signed int x:10;};
100struct attr_bits_2 {signed int x:2;};
101
102static inline float conv_i10_to_i(int i10)
103{
104   struct attr_bits_10 val;
105   val.x = i10;
106   return (float)val.x;
107}
108
109static inline float conv_i2_to_i(int i2)
110{
111   struct attr_bits_2 val;
112   val.x = i2;
113   return (float)val.x;
114}
115
116static inline float conv_i10_to_norm_float(int i10)
117{
118   struct attr_bits_10 val;
119   val.x = i10;
120   return (2.0F * (float)val.x + 1.0F) * (1.0F  / 511.0F);
121}
122
123static inline float conv_i2_to_norm_float(int i2)
124{
125   struct attr_bits_2 val;
126   val.x = i2;
127   return (float)val.x;
128}
129
130#define ATTRI10_1( A, I10 ) ATTR( A, 1, GL_FLOAT, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 )
131#define ATTRI10_2( A, I10 ) ATTR( A, 2, GL_FLOAT, \
132				conv_i10_to_i((I10) & 0x3ff),		\
133				conv_i10_to_i(((I10) >> 10) & 0x3ff), 0, 1 )
134#define ATTRI10_3( A, I10 ) ATTR( A, 3, GL_FLOAT, \
135				conv_i10_to_i((I10) & 0x3ff),	    \
136				conv_i10_to_i(((I10) >> 10) & 0x3ff), \
137				conv_i10_to_i(((I10) >> 20) & 0x3ff), 1 )
138#define ATTRI10_4( A, I10 ) ATTR( A, 4, GL_FLOAT, \
139				conv_i10_to_i((I10) & 0x3ff),		\
140				conv_i10_to_i(((I10) >> 10) & 0x3ff), \
141				conv_i10_to_i(((I10) >> 20) & 0x3ff), \
142				conv_i2_to_i(((I10) >> 30) & 0x3))
143
144
145#define ATTRI10N_1( A, I10 ) ATTR( A, 1, GL_FLOAT, conv_i10_to_norm_float((I10) & 0x3ff), 0, 0, 1 )
146#define ATTRI10N_2( A, I10 ) ATTR( A, 2, GL_FLOAT, \
147				conv_i10_to_norm_float((I10) & 0x3ff),		\
148				conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), 0, 1 )
149#define ATTRI10N_3( A, I10 ) ATTR( A, 3, GL_FLOAT, \
150				conv_i10_to_norm_float((I10) & 0x3ff),	    \
151				conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), \
152				conv_i10_to_norm_float(((I10) >> 20) & 0x3ff), 1 )
153#define ATTRI10N_4( A, I10 ) ATTR( A, 4, GL_FLOAT, \
154				conv_i10_to_norm_float((I10) & 0x3ff),		\
155				conv_i10_to_norm_float(((I10) >> 10) & 0x3ff), \
156				conv_i10_to_norm_float(((I10) >> 20) & 0x3ff), \
157				conv_i2_to_norm_float(((I10) >> 30) & 0x3))
158
159#define ATTR_UI(val, type, normalized, attr, arg) do {		\
160   if ((type) == GL_UNSIGNED_INT_2_10_10_10_REV) {		\
161      if (normalized) {						\
162	 ATTRUI10N_##val((attr), (arg));			\
163      } else {							\
164	 ATTRUI10_##val((attr), (arg));				\
165      }								\
166   }   else if ((type) == GL_INT_2_10_10_10_REV) {		\
167      if (normalized) {						\
168	 ATTRI10N_##val((attr), (arg));				\
169      } else {							\
170	 ATTRI10_##val((attr), (arg));				\
171      }								\
172   } else							\
173      ERROR(GL_INVALID_VALUE);					\
174   } while(0)
175
176#define ATTR_UI_INDEX(val, type, normalized, index, arg) do {	\
177      if ((index) == 0) {					\
178	 ATTR_UI(val, (type), normalized, 0, (arg));			\
179      } else if ((index) < MAX_VERTEX_GENERIC_ATTRIBS) {		\
180	 ATTR_UI(val, (type), normalized, VBO_ATTRIB_GENERIC0 + (index), (arg)); \
181      } else								\
182	 ERROR(GL_INVALID_VALUE);					\
183   } while(0)
184
185static void GLAPIENTRY
186TAG(Vertex2f)(GLfloat x, GLfloat y)
187{
188   GET_CURRENT_CONTEXT(ctx);
189   ATTR2F(VBO_ATTRIB_POS, x, y);
190}
191
192static void GLAPIENTRY
193TAG(Vertex2fv)(const GLfloat * v)
194{
195   GET_CURRENT_CONTEXT(ctx);
196   ATTR2FV(VBO_ATTRIB_POS, v);
197}
198
199static void GLAPIENTRY
200TAG(Vertex3f)(GLfloat x, GLfloat y, GLfloat z)
201{
202   GET_CURRENT_CONTEXT(ctx);
203   ATTR3F(VBO_ATTRIB_POS, x, y, z);
204}
205
206static void GLAPIENTRY
207TAG(Vertex3fv)(const GLfloat * v)
208{
209   GET_CURRENT_CONTEXT(ctx);
210   ATTR3FV(VBO_ATTRIB_POS, v);
211}
212
213static void GLAPIENTRY
214TAG(Vertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
215{
216   GET_CURRENT_CONTEXT(ctx);
217   ATTR4F(VBO_ATTRIB_POS, x, y, z, w);
218}
219
220static void GLAPIENTRY
221TAG(Vertex4fv)(const GLfloat * v)
222{
223   GET_CURRENT_CONTEXT(ctx);
224   ATTR4FV(VBO_ATTRIB_POS, v);
225}
226
227
228
229static void GLAPIENTRY
230TAG(TexCoord1f)(GLfloat x)
231{
232   GET_CURRENT_CONTEXT(ctx);
233   ATTR1F(VBO_ATTRIB_TEX0, x);
234}
235
236static void GLAPIENTRY
237TAG(TexCoord1fv)(const GLfloat * v)
238{
239   GET_CURRENT_CONTEXT(ctx);
240   ATTR1FV(VBO_ATTRIB_TEX0, v);
241}
242
243static void GLAPIENTRY
244TAG(TexCoord2f)(GLfloat x, GLfloat y)
245{
246   GET_CURRENT_CONTEXT(ctx);
247   ATTR2F(VBO_ATTRIB_TEX0, x, y);
248}
249
250static void GLAPIENTRY
251TAG(TexCoord2fv)(const GLfloat * v)
252{
253   GET_CURRENT_CONTEXT(ctx);
254   ATTR2FV(VBO_ATTRIB_TEX0, v);
255}
256
257static void GLAPIENTRY
258TAG(TexCoord3f)(GLfloat x, GLfloat y, GLfloat z)
259{
260   GET_CURRENT_CONTEXT(ctx);
261   ATTR3F(VBO_ATTRIB_TEX0, x, y, z);
262}
263
264static void GLAPIENTRY
265TAG(TexCoord3fv)(const GLfloat * v)
266{
267   GET_CURRENT_CONTEXT(ctx);
268   ATTR3FV(VBO_ATTRIB_TEX0, v);
269}
270
271static void GLAPIENTRY
272TAG(TexCoord4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
273{
274   GET_CURRENT_CONTEXT(ctx);
275   ATTR4F(VBO_ATTRIB_TEX0, x, y, z, w);
276}
277
278static void GLAPIENTRY
279TAG(TexCoord4fv)(const GLfloat * v)
280{
281   GET_CURRENT_CONTEXT(ctx);
282   ATTR4FV(VBO_ATTRIB_TEX0, v);
283}
284
285
286
287static void GLAPIENTRY
288TAG(Normal3f)(GLfloat x, GLfloat y, GLfloat z)
289{
290   GET_CURRENT_CONTEXT(ctx);
291   ATTR3F(VBO_ATTRIB_NORMAL, x, y, z);
292}
293
294static void GLAPIENTRY
295TAG(Normal3fv)(const GLfloat * v)
296{
297   GET_CURRENT_CONTEXT(ctx);
298   ATTR3FV(VBO_ATTRIB_NORMAL, v);
299}
300
301
302
303static void GLAPIENTRY
304TAG(FogCoordfEXT)(GLfloat x)
305{
306   GET_CURRENT_CONTEXT(ctx);
307   ATTR1F(VBO_ATTRIB_FOG, x);
308}
309
310
311
312static void GLAPIENTRY
313TAG(FogCoordfvEXT)(const GLfloat * v)
314{
315   GET_CURRENT_CONTEXT(ctx);
316   ATTR1FV(VBO_ATTRIB_FOG, v);
317}
318
319static void GLAPIENTRY
320TAG(Color3f)(GLfloat x, GLfloat y, GLfloat z)
321{
322   GET_CURRENT_CONTEXT(ctx);
323   ATTR3F(VBO_ATTRIB_COLOR0, x, y, z);
324}
325
326static void GLAPIENTRY
327TAG(Color3fv)(const GLfloat * v)
328{
329   GET_CURRENT_CONTEXT(ctx);
330   ATTR3FV(VBO_ATTRIB_COLOR0, v);
331}
332
333static void GLAPIENTRY
334TAG(Color4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
335{
336   GET_CURRENT_CONTEXT(ctx);
337   ATTR4F(VBO_ATTRIB_COLOR0, x, y, z, w);
338}
339
340static void GLAPIENTRY
341TAG(Color4fv)(const GLfloat * v)
342{
343   GET_CURRENT_CONTEXT(ctx);
344   ATTR4FV(VBO_ATTRIB_COLOR0, v);
345}
346
347
348
349static void GLAPIENTRY
350TAG(SecondaryColor3fEXT)(GLfloat x, GLfloat y, GLfloat z)
351{
352   GET_CURRENT_CONTEXT(ctx);
353   ATTR3F(VBO_ATTRIB_COLOR1, x, y, z);
354}
355
356static void GLAPIENTRY
357TAG(SecondaryColor3fvEXT)(const GLfloat * v)
358{
359   GET_CURRENT_CONTEXT(ctx);
360   ATTR3FV(VBO_ATTRIB_COLOR1, v);
361}
362
363
364
365static void GLAPIENTRY
366TAG(EdgeFlag)(GLboolean b)
367{
368   GET_CURRENT_CONTEXT(ctx);
369   ATTR1F(VBO_ATTRIB_EDGEFLAG, (GLfloat) b);
370}
371
372
373
374static void GLAPIENTRY
375TAG(Indexf)(GLfloat f)
376{
377   GET_CURRENT_CONTEXT(ctx);
378   ATTR1F(VBO_ATTRIB_INDEX, f);
379}
380
381static void GLAPIENTRY
382TAG(Indexfv)(const GLfloat * f)
383{
384   GET_CURRENT_CONTEXT(ctx);
385   ATTR1FV(VBO_ATTRIB_INDEX, f);
386}
387
388
389
390static void GLAPIENTRY
391TAG(MultiTexCoord1f)(GLenum target, GLfloat x)
392{
393   GET_CURRENT_CONTEXT(ctx);
394   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
395   ATTR1F(attr, x);
396}
397
398static void GLAPIENTRY
399TAG(MultiTexCoord1fv)(GLenum target, const GLfloat * v)
400{
401   GET_CURRENT_CONTEXT(ctx);
402   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
403   ATTR1FV(attr, v);
404}
405
406static void GLAPIENTRY
407TAG(MultiTexCoord2f)(GLenum target, GLfloat x, GLfloat y)
408{
409   GET_CURRENT_CONTEXT(ctx);
410   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
411   ATTR2F(attr, x, y);
412}
413
414static void GLAPIENTRY
415TAG(MultiTexCoord2fv)(GLenum target, const GLfloat * v)
416{
417   GET_CURRENT_CONTEXT(ctx);
418   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
419   ATTR2FV(attr, v);
420}
421
422static void GLAPIENTRY
423TAG(MultiTexCoord3f)(GLenum target, GLfloat x, GLfloat y, GLfloat z)
424{
425   GET_CURRENT_CONTEXT(ctx);
426   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
427   ATTR3F(attr, x, y, z);
428}
429
430static void GLAPIENTRY
431TAG(MultiTexCoord3fv)(GLenum target, const GLfloat * v)
432{
433   GET_CURRENT_CONTEXT(ctx);
434   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
435   ATTR3FV(attr, v);
436}
437
438static void GLAPIENTRY
439TAG(MultiTexCoord4f)(GLenum target, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
440{
441   GET_CURRENT_CONTEXT(ctx);
442   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
443   ATTR4F(attr, x, y, z, w);
444}
445
446static void GLAPIENTRY
447TAG(MultiTexCoord4fv)(GLenum target, const GLfloat * v)
448{
449   GET_CURRENT_CONTEXT(ctx);
450   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
451   ATTR4FV(attr, v);
452}
453
454
455
456static void GLAPIENTRY
457TAG(VertexAttrib1fARB)(GLuint index, GLfloat x)
458{
459   GET_CURRENT_CONTEXT(ctx);
460   if (index == 0)
461      ATTR1F(0, x);
462   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
463      ATTR1F(VBO_ATTRIB_GENERIC0 + index, x);
464   else
465      ERROR(GL_INVALID_VALUE);
466}
467
468static void GLAPIENTRY
469TAG(VertexAttrib1fvARB)(GLuint index, const GLfloat * v)
470{
471   GET_CURRENT_CONTEXT(ctx);
472   if (index == 0)
473      ATTR1FV(0, v);
474   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
475      ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v);
476   else
477      ERROR(GL_INVALID_VALUE);
478}
479
480static void GLAPIENTRY
481TAG(VertexAttrib2fARB)(GLuint index, GLfloat x, GLfloat y)
482{
483   GET_CURRENT_CONTEXT(ctx);
484   if (index == 0)
485      ATTR2F(0, x, y);
486   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
487      ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y);
488   else
489      ERROR(GL_INVALID_VALUE);
490}
491
492static void GLAPIENTRY
493TAG(VertexAttrib2fvARB)(GLuint index, const GLfloat * v)
494{
495   GET_CURRENT_CONTEXT(ctx);
496   if (index == 0)
497      ATTR2FV(0, v);
498   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
499      ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v);
500   else
501      ERROR(GL_INVALID_VALUE);
502}
503
504static void GLAPIENTRY
505TAG(VertexAttrib3fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
506{
507   GET_CURRENT_CONTEXT(ctx);
508   if (index == 0)
509      ATTR3F(0, x, y, z);
510   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
511      ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z);
512   else
513      ERROR(GL_INVALID_VALUE);
514}
515
516static void GLAPIENTRY
517TAG(VertexAttrib3fvARB)(GLuint index, const GLfloat * v)
518{
519   GET_CURRENT_CONTEXT(ctx);
520   if (index == 0)
521      ATTR3FV(0, v);
522   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
523      ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v);
524   else
525      ERROR(GL_INVALID_VALUE);
526}
527
528static void GLAPIENTRY
529TAG(VertexAttrib4fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
530{
531   GET_CURRENT_CONTEXT(ctx);
532   if (index == 0)
533      ATTR4F(0, x, y, z, w);
534   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
535      ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
536   else
537      ERROR(GL_INVALID_VALUE);
538}
539
540static void GLAPIENTRY
541TAG(VertexAttrib4fvARB)(GLuint index, const GLfloat * v)
542{
543   GET_CURRENT_CONTEXT(ctx);
544   if (index == 0)
545      ATTR4FV(0, v);
546   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
547      ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v);
548   else
549      ERROR(GL_INVALID_VALUE);
550}
551
552
553
554/* Integer-valued generic attributes.
555 * XXX: the integers just get converted to floats at this time
556 */
557static void GLAPIENTRY
558TAG(VertexAttribI1i)(GLuint index, GLint x)
559{
560   GET_CURRENT_CONTEXT(ctx);
561   if (index == 0)
562      ATTR1I(0, x);
563   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
564      ATTR1I(VBO_ATTRIB_GENERIC0 + index, x);
565   else
566      ERROR(GL_INVALID_VALUE);
567}
568
569static void GLAPIENTRY
570TAG(VertexAttribI2i)(GLuint index, GLint x, GLint y)
571{
572   GET_CURRENT_CONTEXT(ctx);
573   if (index == 0)
574      ATTR2I(0, x, y);
575   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
576      ATTR2I(VBO_ATTRIB_GENERIC0 + index, x, y);
577   else
578      ERROR(GL_INVALID_VALUE);
579}
580
581static void GLAPIENTRY
582TAG(VertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z)
583{
584   GET_CURRENT_CONTEXT(ctx);
585   if (index == 0)
586      ATTR3I(0, x, y, z);
587   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
588      ATTR3I(VBO_ATTRIB_GENERIC0 + index, x, y, z);
589   else
590      ERROR(GL_INVALID_VALUE);
591}
592
593static void GLAPIENTRY
594TAG(VertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w)
595{
596   GET_CURRENT_CONTEXT(ctx);
597   if (index == 0)
598      ATTR4I(0, x, y, z, w);
599   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
600      ATTR4I(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
601   else
602      ERROR(GL_INVALID_VALUE);
603}
604
605static void GLAPIENTRY
606TAG(VertexAttribI2iv)(GLuint index, const GLint *v)
607{
608   GET_CURRENT_CONTEXT(ctx);
609   if (index == 0)
610      ATTR2IV(0, v);
611   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
612      ATTR2IV(VBO_ATTRIB_GENERIC0 + index, v);
613   else
614      ERROR(GL_INVALID_VALUE);
615}
616
617static void GLAPIENTRY
618TAG(VertexAttribI3iv)(GLuint index, const GLint *v)
619{
620   GET_CURRENT_CONTEXT(ctx);
621   if (index == 0)
622      ATTR3IV(0, v);
623   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
624      ATTR3IV(VBO_ATTRIB_GENERIC0 + index, v);
625   else
626      ERROR(GL_INVALID_VALUE);
627}
628
629static void GLAPIENTRY
630TAG(VertexAttribI4iv)(GLuint index, const GLint *v)
631{
632   GET_CURRENT_CONTEXT(ctx);
633   if (index == 0)
634      ATTR4IV(0, v);
635   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
636      ATTR4IV(VBO_ATTRIB_GENERIC0 + index, v);
637   else
638      ERROR(GL_INVALID_VALUE);
639}
640
641
642
643/* Unsigned integer-valued generic attributes.
644 * XXX: the integers just get converted to floats at this time
645 */
646static void GLAPIENTRY
647TAG(VertexAttribI1ui)(GLuint index, GLuint x)
648{
649   GET_CURRENT_CONTEXT(ctx);
650   if (index == 0)
651      ATTR1UI(0, x);
652   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
653      ATTR1UI(VBO_ATTRIB_GENERIC0 + index, x);
654   else
655      ERROR(GL_INVALID_VALUE);
656}
657
658static void GLAPIENTRY
659TAG(VertexAttribI2ui)(GLuint index, GLuint x, GLuint y)
660{
661   GET_CURRENT_CONTEXT(ctx);
662   if (index == 0)
663      ATTR2UI(0, x, y);
664   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
665      ATTR2UI(VBO_ATTRIB_GENERIC0 + index, x, y);
666   else
667      ERROR(GL_INVALID_VALUE);
668}
669
670static void GLAPIENTRY
671TAG(VertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z)
672{
673   GET_CURRENT_CONTEXT(ctx);
674   if (index == 0)
675      ATTR3UI(0, x, y, z);
676   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
677      ATTR3UI(VBO_ATTRIB_GENERIC0 + index, x, y, z);
678   else
679      ERROR(GL_INVALID_VALUE);
680}
681
682static void GLAPIENTRY
683TAG(VertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
684{
685   GET_CURRENT_CONTEXT(ctx);
686   if (index == 0)
687      ATTR4UI(0, x, y, z, w);
688   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
689      ATTR4UI(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
690   else
691      ERROR(GL_INVALID_VALUE);
692}
693
694static void GLAPIENTRY
695TAG(VertexAttribI2uiv)(GLuint index, const GLuint *v)
696{
697   GET_CURRENT_CONTEXT(ctx);
698   if (index == 0)
699      ATTR2UIV(0, v);
700   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
701      ATTR2UIV(VBO_ATTRIB_GENERIC0 + index, v);
702   else
703      ERROR(GL_INVALID_VALUE);
704}
705
706static void GLAPIENTRY
707TAG(VertexAttribI3uiv)(GLuint index, const GLuint *v)
708{
709   GET_CURRENT_CONTEXT(ctx);
710   if (index == 0)
711      ATTR3UIV(0, v);
712   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
713      ATTR3UIV(VBO_ATTRIB_GENERIC0 + index, v);
714   else
715      ERROR(GL_INVALID_VALUE);
716}
717
718static void GLAPIENTRY
719TAG(VertexAttribI4uiv)(GLuint index, const GLuint *v)
720{
721   GET_CURRENT_CONTEXT(ctx);
722   if (index == 0)
723      ATTR4UIV(0, v);
724   else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
725      ATTR4UIV(VBO_ATTRIB_GENERIC0 + index, v);
726   else
727      ERROR(GL_INVALID_VALUE);
728}
729
730
731
732/* In addition to supporting NV_vertex_program, these entrypoints are
733 * used by the display list and other code specifically because of
734 * their property of aliasing with other attributes.  (See
735 * vbo_save_loopback.c)
736 */
737static void GLAPIENTRY
738TAG(VertexAttrib1fNV)(GLuint index, GLfloat x)
739{
740   GET_CURRENT_CONTEXT(ctx);
741   if (index < VBO_ATTRIB_MAX)
742      ATTR1F(index, x);
743}
744
745static void GLAPIENTRY
746TAG(VertexAttrib1fvNV)(GLuint index, const GLfloat * v)
747{
748   GET_CURRENT_CONTEXT(ctx);
749   if (index < VBO_ATTRIB_MAX)
750      ATTR1FV(index, v);
751}
752
753static void GLAPIENTRY
754TAG(VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y)
755{
756   GET_CURRENT_CONTEXT(ctx);
757   if (index < VBO_ATTRIB_MAX)
758      ATTR2F(index, x, y);
759}
760
761static void GLAPIENTRY
762TAG(VertexAttrib2fvNV)(GLuint index, const GLfloat * v)
763{
764   GET_CURRENT_CONTEXT(ctx);
765   if (index < VBO_ATTRIB_MAX)
766      ATTR2FV(index, v);
767}
768
769static void GLAPIENTRY
770TAG(VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
771{
772   GET_CURRENT_CONTEXT(ctx);
773   if (index < VBO_ATTRIB_MAX)
774      ATTR3F(index, x, y, z);
775}
776
777static void GLAPIENTRY
778TAG(VertexAttrib3fvNV)(GLuint index,
779 const GLfloat * v)
780{
781   GET_CURRENT_CONTEXT(ctx);
782   if (index < VBO_ATTRIB_MAX)
783      ATTR3FV(index, v);
784}
785
786static void GLAPIENTRY
787TAG(VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
788{
789   GET_CURRENT_CONTEXT(ctx);
790   if (index < VBO_ATTRIB_MAX)
791      ATTR4F(index, x, y, z, w);
792}
793
794static void GLAPIENTRY
795TAG(VertexAttrib4fvNV)(GLuint index, const GLfloat * v)
796{
797   GET_CURRENT_CONTEXT(ctx);
798   if (index < VBO_ATTRIB_MAX)
799      ATTR4FV(index, v);
800}
801
802
803static void GLAPIENTRY
804TAG(VertexP2ui)(GLenum type, GLuint value)
805{
806   GET_CURRENT_CONTEXT(ctx);
807   ATTR_UI(2, type, 0, VBO_ATTRIB_POS, value);
808}
809
810static void GLAPIENTRY
811TAG(VertexP2uiv)(GLenum type, const GLuint *value)
812{
813   GET_CURRENT_CONTEXT(ctx);
814   ATTR_UI(2, type, 0, VBO_ATTRIB_POS, value[0]);
815}
816
817static void GLAPIENTRY
818TAG(VertexP3ui)(GLenum type, GLuint value)
819{
820   GET_CURRENT_CONTEXT(ctx);
821   ATTR_UI(3, type, 0, VBO_ATTRIB_POS, value);
822}
823
824static void GLAPIENTRY
825TAG(VertexP3uiv)(GLenum type, const GLuint *value)
826{
827   GET_CURRENT_CONTEXT(ctx);
828   ATTR_UI(3, type, 0, VBO_ATTRIB_POS, value[0]);
829}
830
831static void GLAPIENTRY
832TAG(VertexP4ui)(GLenum type, GLuint value)
833{
834   GET_CURRENT_CONTEXT(ctx);
835   ATTR_UI(4, type, 0, VBO_ATTRIB_POS, value);
836}
837
838static void GLAPIENTRY
839TAG(VertexP4uiv)(GLenum type, const GLuint *value)
840{
841   GET_CURRENT_CONTEXT(ctx);
842   ATTR_UI(4, type, 0, VBO_ATTRIB_POS, value[0]);
843}
844
845static void GLAPIENTRY
846TAG(TexCoordP1ui)(GLenum type, GLuint coords)
847{
848   GET_CURRENT_CONTEXT(ctx);
849   ATTR_UI(1, type, 0, VBO_ATTRIB_TEX0, coords);
850}
851
852static void GLAPIENTRY
853TAG(TexCoordP1uiv)(GLenum type, const GLuint *coords)
854{
855   GET_CURRENT_CONTEXT(ctx);
856   ATTR_UI(1, type, 0, VBO_ATTRIB_TEX0, coords[0]);
857}
858
859static void GLAPIENTRY
860TAG(TexCoordP2ui)(GLenum type, GLuint coords)
861{
862   GET_CURRENT_CONTEXT(ctx);
863   ATTR_UI(2, type, 0, VBO_ATTRIB_TEX0, coords);
864}
865
866static void GLAPIENTRY
867TAG(TexCoordP2uiv)(GLenum type, const GLuint *coords)
868{
869   GET_CURRENT_CONTEXT(ctx);
870   ATTR_UI(2, type, 0, VBO_ATTRIB_TEX0, coords[0]);
871}
872
873static void GLAPIENTRY
874TAG(TexCoordP3ui)(GLenum type, GLuint coords)
875{
876   GET_CURRENT_CONTEXT(ctx);
877   ATTR_UI(3, type, 0, VBO_ATTRIB_TEX0, coords);
878}
879
880static void GLAPIENTRY
881TAG(TexCoordP3uiv)(GLenum type, const GLuint *coords)
882{
883   GET_CURRENT_CONTEXT(ctx);
884   ATTR_UI(3, type, 0, VBO_ATTRIB_TEX0, coords[0]);
885}
886
887static void GLAPIENTRY
888TAG(TexCoordP4ui)(GLenum type, GLuint coords)
889{
890   GET_CURRENT_CONTEXT(ctx);
891   ATTR_UI(4, type, 0, VBO_ATTRIB_TEX0, coords);
892}
893
894static void GLAPIENTRY
895TAG(TexCoordP4uiv)(GLenum type, const GLuint *coords)
896{
897   GET_CURRENT_CONTEXT(ctx);
898   ATTR_UI(4, type, 0, VBO_ATTRIB_TEX0, coords[0]);
899}
900
901static void GLAPIENTRY
902TAG(MultiTexCoordP1ui)(GLenum target, GLenum type, GLuint coords)
903{
904   GET_CURRENT_CONTEXT(ctx);
905   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
906   ATTR_UI(1, type, 0, attr, coords);
907}
908
909static void GLAPIENTRY
910TAG(MultiTexCoordP1uiv)(GLenum target, GLenum type, const GLuint *coords)
911{
912   GET_CURRENT_CONTEXT(ctx);
913   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
914   ATTR_UI(1, type, 0, attr, coords[0]);
915}
916
917static void GLAPIENTRY
918TAG(MultiTexCoordP2ui)(GLenum target, GLenum type, GLuint coords)
919{
920   GET_CURRENT_CONTEXT(ctx);
921   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
922   ATTR_UI(2, type, 0, attr, coords);
923}
924
925static void GLAPIENTRY
926TAG(MultiTexCoordP2uiv)(GLenum target, GLenum type, const GLuint *coords)
927{
928   GET_CURRENT_CONTEXT(ctx);
929   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
930   ATTR_UI(2, type, 0, attr, coords[0]);
931}
932
933static void GLAPIENTRY
934TAG(MultiTexCoordP3ui)(GLenum target, GLenum type, GLuint coords)
935{
936   GET_CURRENT_CONTEXT(ctx);
937   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
938   ATTR_UI(3, type, 0, attr, coords);
939}
940
941static void GLAPIENTRY
942TAG(MultiTexCoordP3uiv)(GLenum target, GLenum type, const GLuint *coords)
943{
944   GET_CURRENT_CONTEXT(ctx);
945   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
946   ATTR_UI(3, type, 0, attr, coords[0]);
947}
948
949static void GLAPIENTRY
950TAG(MultiTexCoordP4ui)(GLenum target, GLenum type, GLuint coords)
951{
952   GET_CURRENT_CONTEXT(ctx);
953   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
954   ATTR_UI(4, type, 0, attr, coords);
955}
956
957static void GLAPIENTRY
958TAG(MultiTexCoordP4uiv)(GLenum target, GLenum type, const GLuint *coords)
959{
960   GET_CURRENT_CONTEXT(ctx);
961   GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
962   ATTR_UI(4, type, 0, attr, coords[0]);
963}
964
965static void GLAPIENTRY
966TAG(NormalP3ui)(GLenum type, GLuint coords)
967{
968   GET_CURRENT_CONTEXT(ctx);
969   ATTR_UI(3, type, 1, VBO_ATTRIB_NORMAL, coords);
970}
971
972static void GLAPIENTRY
973TAG(NormalP3uiv)(GLenum type, const GLuint *coords)
974{
975   GET_CURRENT_CONTEXT(ctx);
976   ATTR_UI(3, type, 1, VBO_ATTRIB_NORMAL, coords[0]);
977}
978
979static void GLAPIENTRY
980TAG(ColorP3ui)(GLenum type, GLuint color)
981{
982   GET_CURRENT_CONTEXT(ctx);
983   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR0, color);
984}
985
986static void GLAPIENTRY
987TAG(ColorP3uiv)(GLenum type, const GLuint *color)
988{
989   GET_CURRENT_CONTEXT(ctx);
990   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR0, color[0]);
991}
992
993static void GLAPIENTRY
994TAG(ColorP4ui)(GLenum type, GLuint color)
995{
996   GET_CURRENT_CONTEXT(ctx);
997   ATTR_UI(4, type, 1, VBO_ATTRIB_COLOR0, color);
998}
999
1000static void GLAPIENTRY
1001TAG(ColorP4uiv)(GLenum type, const GLuint *color)
1002{
1003   GET_CURRENT_CONTEXT(ctx);
1004   ATTR_UI(4, type, 1, VBO_ATTRIB_COLOR0, color[0]);
1005}
1006
1007static void GLAPIENTRY
1008TAG(SecondaryColorP3ui)(GLenum type, GLuint color)
1009{
1010   GET_CURRENT_CONTEXT(ctx);
1011   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR1, color);
1012}
1013
1014static void GLAPIENTRY
1015TAG(SecondaryColorP3uiv)(GLenum type, const GLuint *color)
1016{
1017   GET_CURRENT_CONTEXT(ctx);
1018   ATTR_UI(3, type, 1, VBO_ATTRIB_COLOR1, color[0]);
1019}
1020
1021static void GLAPIENTRY
1022TAG(VertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized,
1023		      GLuint value)
1024{
1025   GET_CURRENT_CONTEXT(ctx);
1026   ATTR_UI_INDEX(1, type, normalized, index, value);
1027}
1028
1029static void GLAPIENTRY
1030TAG(VertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized,
1031		      GLuint value)
1032{
1033   GET_CURRENT_CONTEXT(ctx);
1034   ATTR_UI_INDEX(2, type, normalized, index, value);
1035}
1036
1037static void GLAPIENTRY
1038TAG(VertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized,
1039		      GLuint value)
1040{
1041   GET_CURRENT_CONTEXT(ctx);
1042   ATTR_UI_INDEX(3, type, normalized, index, value);
1043}
1044
1045static void GLAPIENTRY
1046TAG(VertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized,
1047		      GLuint value)
1048{
1049   GET_CURRENT_CONTEXT(ctx);
1050   ATTR_UI_INDEX(4, type, normalized, index, value);
1051}
1052
1053static void GLAPIENTRY
1054TAG(VertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized,
1055		       const GLuint *value)
1056{
1057   GET_CURRENT_CONTEXT(ctx);
1058   ATTR_UI_INDEX(1, type, normalized, index, *value);
1059}
1060
1061static void GLAPIENTRY
1062TAG(VertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized,
1063		       const GLuint *value)
1064{
1065   GET_CURRENT_CONTEXT(ctx);
1066   ATTR_UI_INDEX(2, type, normalized, index, *value);
1067}
1068
1069static void GLAPIENTRY
1070TAG(VertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized,
1071		       const GLuint *value)
1072{
1073   GET_CURRENT_CONTEXT(ctx);
1074   ATTR_UI_INDEX(3, type, normalized, index, *value);
1075}
1076
1077static void GLAPIENTRY
1078TAG(VertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized,
1079		      const GLuint *value)
1080{
1081   GET_CURRENT_CONTEXT(ctx);
1082   ATTR_UI_INDEX(4, type, normalized, index, *value);
1083}
1084
1085
1086#undef ATTR1FV
1087#undef ATTR2FV
1088#undef ATTR3FV
1089#undef ATTR4FV
1090
1091#undef ATTR1F
1092#undef ATTR2F
1093#undef ATTR3F
1094#undef ATTR4F
1095
1096#undef ATTR_UI
1097
1098#undef MAT
1099