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