vbo: use new _is_vertex_position() helper in vbo_attrib_tmp.h
[mesa.git] / src / mesa / vbo / vbo_attrib_tmp.h
1 /**************************************************************************
2
3 Copyright 2002 VMware, Inc.
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 VMWARE 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 #include "util/format_r11g11b10f.h"
29 #include "main/varray.h"
30
31
32 /* ATTR */
33 #define ATTRI( A, N, V0, V1, V2, V3 ) \
34 ATTR_UNION(A, N, GL_INT, fi_type, INT_AS_UNION(V0), INT_AS_UNION(V1), \
35 INT_AS_UNION(V2), INT_AS_UNION(V3))
36 #define ATTRUI( A, N, V0, V1, V2, V3 ) \
37 ATTR_UNION(A, N, GL_UNSIGNED_INT, fi_type, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \
38 UINT_AS_UNION(V2), UINT_AS_UNION(V3))
39 #define ATTRF( A, N, V0, V1, V2, V3 ) \
40 ATTR_UNION(A, N, GL_FLOAT, fi_type, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\
41 FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3))
42 #define ATTRD( A, N, V0, V1, V2, V3 ) \
43 ATTR_UNION(A, N, GL_DOUBLE, double, V0, V1, V2, V3)
44 #define ATTRUI64( A, N, V0, V1, V2, V3 ) \
45 ATTR_UNION(A, N, GL_UNSIGNED_INT64_ARB, uint64_t, V0, V1, V2, V3)
46
47
48 /* float */
49 #define ATTR1FV( A, V ) ATTRF( A, 1, (V)[0], 0, 0, 1 )
50 #define ATTR2FV( A, V ) ATTRF( A, 2, (V)[0], (V)[1], 0, 1 )
51 #define ATTR3FV( A, V ) ATTRF( A, 3, (V)[0], (V)[1], (V)[2], 1 )
52 #define ATTR4FV( A, V ) ATTRF( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
53
54 #define ATTR1F( A, X ) ATTRF( A, 1, X, 0, 0, 1 )
55 #define ATTR2F( A, X, Y ) ATTRF( A, 2, X, Y, 0, 1 )
56 #define ATTR3F( A, X, Y, Z ) ATTRF( A, 3, X, Y, Z, 1 )
57 #define ATTR4F( A, X, Y, Z, W ) ATTRF( A, 4, X, Y, Z, W )
58
59
60 /* int */
61 #define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 )
62 #define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 )
63 #define ATTR4IV( A, V ) ATTRI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
64
65 #define ATTR1I( A, X ) ATTRI( A, 1, X, 0, 0, 1 )
66 #define ATTR2I( A, X, Y ) ATTRI( A, 2, X, Y, 0, 1 )
67 #define ATTR3I( A, X, Y, Z ) ATTRI( A, 3, X, Y, Z, 1 )
68 #define ATTR4I( A, X, Y, Z, W ) ATTRI( A, 4, X, Y, Z, W )
69
70
71 /* uint */
72 #define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 )
73 #define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 )
74 #define ATTR4UIV( A, V ) ATTRUI( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
75
76 #define ATTR1UI( A, X ) ATTRUI( A, 1, X, 0, 0, 1 )
77 #define ATTR2UI( A, X, Y ) ATTRUI( A, 2, X, Y, 0, 1 )
78 #define ATTR3UI( A, X, Y, Z ) ATTRUI( A, 3, X, Y, Z, 1 )
79 #define ATTR4UI( A, X, Y, Z, W ) ATTRUI( A, 4, X, Y, Z, W )
80
81 #define MAT_ATTR( A, N, V ) ATTRF( A, N, (V)[0], (V)[1], (V)[2], (V)[3] )
82
83 static inline float conv_ui10_to_norm_float(unsigned ui10)
84 {
85 return ui10 / 1023.0f;
86 }
87
88 static inline float conv_ui2_to_norm_float(unsigned ui2)
89 {
90 return ui2 / 3.0f;
91 }
92
93 #define ATTRUI10_1( A, UI ) ATTRF( A, 1, (UI) & 0x3ff, 0, 0, 1 )
94 #define ATTRUI10_2( A, UI ) ATTRF( A, 2, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, 0, 1 )
95 #define ATTRUI10_3( A, UI ) ATTRF( A, 3, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, 1 )
96 #define ATTRUI10_4( A, UI ) ATTRF( A, 4, (UI) & 0x3ff, ((UI) >> 10) & 0x3ff, ((UI) >> 20) & 0x3ff, ((UI) >> 30) & 0x3 )
97
98 #define ATTRUI10N_1( A, UI ) ATTRF( A, 1, conv_ui10_to_norm_float((UI) & 0x3ff), 0, 0, 1 )
99 #define ATTRUI10N_2( A, UI ) ATTRF( A, 2, \
100 conv_ui10_to_norm_float((UI) & 0x3ff), \
101 conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), 0, 1 )
102 #define ATTRUI10N_3( A, UI ) ATTRF( A, 3, \
103 conv_ui10_to_norm_float((UI) & 0x3ff), \
104 conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \
105 conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), 1 )
106 #define ATTRUI10N_4( A, UI ) ATTRF( A, 4, \
107 conv_ui10_to_norm_float((UI) & 0x3ff), \
108 conv_ui10_to_norm_float(((UI) >> 10) & 0x3ff), \
109 conv_ui10_to_norm_float(((UI) >> 20) & 0x3ff), \
110 conv_ui2_to_norm_float(((UI) >> 30) & 0x3) )
111
112 struct attr_bits_10 {signed int x:10;};
113 struct attr_bits_2 {signed int x:2;};
114
115 static inline float conv_i10_to_i(int i10)
116 {
117 struct attr_bits_10 val;
118 val.x = i10;
119 return (float)val.x;
120 }
121
122 static inline float conv_i2_to_i(int i2)
123 {
124 struct attr_bits_2 val;
125 val.x = i2;
126 return (float)val.x;
127 }
128
129 static inline float conv_i10_to_norm_float(const struct gl_context *ctx, int i10)
130 {
131 struct attr_bits_10 val;
132 val.x = i10;
133
134 /* Traditionally, OpenGL has had two equations for converting from
135 * normalized fixed-point data to floating-point data. In the OpenGL 3.2
136 * specification, these are equations 2.2 and 2.3, respectively:
137 *
138 * f = (2c + 1)/(2^b - 1). (2.2)
139 *
140 * Comments below this equation state: "In general, this representation is
141 * used for signed normalized fixed-point parameters in GL commands, such
142 * as vertex attribute values." Which is what we're doing here.
143 *
144 * f = max{c/(2^(b-1) - 1), -1.0} (2.3)
145 *
146 * Comments below this equation state: "In general, this representation is
147 * used for signed normalized fixed-point texture or floating point values."
148 *
149 * OpenGL 4.2+ and ES 3.0 remedy this and state that equation 2.3 (above)
150 * is used in every case. They remove equation 2.2 completely.
151 */
152 if (_mesa_is_gles3(ctx) ||
153 (ctx->API == API_OPENGL_CORE && ctx->Version >= 42)) {
154 /* Equation 2.3 above. */
155 float f = ((float) val.x) / 511.0F;
156 return MAX2(f, -1.0f);
157 } else {
158 /* Equation 2.2 above. */
159 return (2.0F * (float)val.x + 1.0F) * (1.0F / 1023.0F);
160 }
161 }
162
163 static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2)
164 {
165 struct attr_bits_2 val;
166 val.x = i2;
167
168 if (_mesa_is_gles3(ctx) ||
169 (ctx->API == API_OPENGL_CORE && ctx->Version >= 42)) {
170 /* Equation 2.3 above. */
171 float f = (float) val.x;
172 return MAX2(f, -1.0f);
173 } else {
174 /* Equation 2.2 above. */
175 return (2.0F * (float)val.x + 1.0F) * (1.0F / 3.0F);
176 }
177 }
178
179 #define ATTRI10_1( A, I10 ) ATTRF( A, 1, conv_i10_to_i((I10) & 0x3ff), 0, 0, 1 )
180 #define ATTRI10_2( A, I10 ) ATTRF( A, 2, \
181 conv_i10_to_i((I10) & 0x3ff), \
182 conv_i10_to_i(((I10) >> 10) & 0x3ff), 0, 1 )
183 #define ATTRI10_3( A, I10 ) ATTRF( A, 3, \
184 conv_i10_to_i((I10) & 0x3ff), \
185 conv_i10_to_i(((I10) >> 10) & 0x3ff), \
186 conv_i10_to_i(((I10) >> 20) & 0x3ff), 1 )
187 #define ATTRI10_4( A, I10 ) ATTRF( A, 4, \
188 conv_i10_to_i((I10) & 0x3ff), \
189 conv_i10_to_i(((I10) >> 10) & 0x3ff), \
190 conv_i10_to_i(((I10) >> 20) & 0x3ff), \
191 conv_i2_to_i(((I10) >> 30) & 0x3))
192
193
194 #define ATTRI10N_1(ctx, A, I10) ATTRF(A, 1, conv_i10_to_norm_float(ctx, (I10) & 0x3ff), 0, 0, 1 )
195 #define ATTRI10N_2(ctx, A, I10) ATTRF(A, 2, \
196 conv_i10_to_norm_float(ctx, (I10) & 0x3ff), \
197 conv_i10_to_norm_float(ctx, ((I10) >> 10) & 0x3ff), 0, 1 )
198 #define ATTRI10N_3(ctx, A, I10) ATTRF(A, 3, \
199 conv_i10_to_norm_float(ctx, (I10) & 0x3ff), \
200 conv_i10_to_norm_float(ctx, ((I10) >> 10) & 0x3ff), \
201 conv_i10_to_norm_float(ctx, ((I10) >> 20) & 0x3ff), 1 )
202 #define ATTRI10N_4(ctx, A, I10) ATTRF(A, 4, \
203 conv_i10_to_norm_float(ctx, (I10) & 0x3ff), \
204 conv_i10_to_norm_float(ctx, ((I10) >> 10) & 0x3ff), \
205 conv_i10_to_norm_float(ctx, ((I10) >> 20) & 0x3ff), \
206 conv_i2_to_norm_float(ctx, ((I10) >> 30) & 0x3))
207
208 #define ATTR_UI(ctx, val, type, normalized, attr, arg) do { \
209 if ((type) == GL_UNSIGNED_INT_2_10_10_10_REV) { \
210 if (normalized) { \
211 ATTRUI10N_##val((attr), (arg)); \
212 } else { \
213 ATTRUI10_##val((attr), (arg)); \
214 } \
215 } else if ((type) == GL_INT_2_10_10_10_REV) { \
216 if (normalized) { \
217 ATTRI10N_##val(ctx, (attr), (arg)); \
218 } else { \
219 ATTRI10_##val((attr), (arg)); \
220 } \
221 } else if ((type) == GL_UNSIGNED_INT_10F_11F_11F_REV) { \
222 float res[4]; \
223 res[3] = 1; \
224 r11g11b10f_to_float3((arg), res); \
225 ATTR##val##FV((attr), res); \
226 } else \
227 ERROR(GL_INVALID_VALUE); \
228 } while(0)
229
230 #define ATTR_UI_INDEX(ctx, val, type, normalized, index, arg) do { \
231 if ((index) == 0 && _mesa_attr_zero_aliases_vertex(ctx)) { \
232 ATTR_UI(ctx, val, (type), normalized, 0, (arg)); \
233 } else if ((index) < MAX_VERTEX_GENERIC_ATTRIBS) { \
234 ATTR_UI(ctx, val, (type), normalized, VBO_ATTRIB_GENERIC0 + (index), (arg)); \
235 } else \
236 ERROR(GL_INVALID_VALUE); \
237 } while(0)
238
239
240 /* Doubles */
241 #define ATTR1DV( A, V ) ATTRD( A, 1, (V)[0], 0, 0, 1 )
242 #define ATTR2DV( A, V ) ATTRD( A, 2, (V)[0], (V)[1], 0, 1 )
243 #define ATTR3DV( A, V ) ATTRD( A, 3, (V)[0], (V)[1], (V)[2], 1 )
244 #define ATTR4DV( A, V ) ATTRD( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
245
246 #define ATTR1D( A, X ) ATTRD( A, 1, X, 0, 0, 1 )
247 #define ATTR2D( A, X, Y ) ATTRD( A, 2, X, Y, 0, 1 )
248 #define ATTR3D( A, X, Y, Z ) ATTRD( A, 3, X, Y, Z, 1 )
249 #define ATTR4D( A, X, Y, Z, W ) ATTRD( A, 4, X, Y, Z, W )
250
251 #define ATTR1UIV64( A, V ) ATTRUI64( A, 1, (V)[0], 0, 0, 0 )
252 #define ATTR1UI64( A, X ) ATTRUI64( A, 1, X, 0, 0, 0 )
253
254
255 static void GLAPIENTRY
256 TAG(Vertex2f)(GLfloat x, GLfloat y)
257 {
258 GET_CURRENT_CONTEXT(ctx);
259 ATTR2F(VBO_ATTRIB_POS, x, y);
260 }
261
262 static void GLAPIENTRY
263 TAG(Vertex2fv)(const GLfloat * v)
264 {
265 GET_CURRENT_CONTEXT(ctx);
266 ATTR2FV(VBO_ATTRIB_POS, v);
267 }
268
269 static void GLAPIENTRY
270 TAG(Vertex3f)(GLfloat x, GLfloat y, GLfloat z)
271 {
272 GET_CURRENT_CONTEXT(ctx);
273 ATTR3F(VBO_ATTRIB_POS, x, y, z);
274 }
275
276 static void GLAPIENTRY
277 TAG(Vertex3fv)(const GLfloat * v)
278 {
279 GET_CURRENT_CONTEXT(ctx);
280 ATTR3FV(VBO_ATTRIB_POS, v);
281 }
282
283 static void GLAPIENTRY
284 TAG(Vertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
285 {
286 GET_CURRENT_CONTEXT(ctx);
287 ATTR4F(VBO_ATTRIB_POS, x, y, z, w);
288 }
289
290 static void GLAPIENTRY
291 TAG(Vertex4fv)(const GLfloat * v)
292 {
293 GET_CURRENT_CONTEXT(ctx);
294 ATTR4FV(VBO_ATTRIB_POS, v);
295 }
296
297
298
299 static void GLAPIENTRY
300 TAG(TexCoord1f)(GLfloat x)
301 {
302 GET_CURRENT_CONTEXT(ctx);
303 ATTR1F(VBO_ATTRIB_TEX0, x);
304 }
305
306 static void GLAPIENTRY
307 TAG(TexCoord1fv)(const GLfloat * v)
308 {
309 GET_CURRENT_CONTEXT(ctx);
310 ATTR1FV(VBO_ATTRIB_TEX0, v);
311 }
312
313 static void GLAPIENTRY
314 TAG(TexCoord2f)(GLfloat x, GLfloat y)
315 {
316 GET_CURRENT_CONTEXT(ctx);
317 ATTR2F(VBO_ATTRIB_TEX0, x, y);
318 }
319
320 static void GLAPIENTRY
321 TAG(TexCoord2fv)(const GLfloat * v)
322 {
323 GET_CURRENT_CONTEXT(ctx);
324 ATTR2FV(VBO_ATTRIB_TEX0, v);
325 }
326
327 static void GLAPIENTRY
328 TAG(TexCoord3f)(GLfloat x, GLfloat y, GLfloat z)
329 {
330 GET_CURRENT_CONTEXT(ctx);
331 ATTR3F(VBO_ATTRIB_TEX0, x, y, z);
332 }
333
334 static void GLAPIENTRY
335 TAG(TexCoord3fv)(const GLfloat * v)
336 {
337 GET_CURRENT_CONTEXT(ctx);
338 ATTR3FV(VBO_ATTRIB_TEX0, v);
339 }
340
341 static void GLAPIENTRY
342 TAG(TexCoord4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
343 {
344 GET_CURRENT_CONTEXT(ctx);
345 ATTR4F(VBO_ATTRIB_TEX0, x, y, z, w);
346 }
347
348 static void GLAPIENTRY
349 TAG(TexCoord4fv)(const GLfloat * v)
350 {
351 GET_CURRENT_CONTEXT(ctx);
352 ATTR4FV(VBO_ATTRIB_TEX0, v);
353 }
354
355
356
357 static void GLAPIENTRY
358 TAG(Normal3f)(GLfloat x, GLfloat y, GLfloat z)
359 {
360 GET_CURRENT_CONTEXT(ctx);
361 ATTR3F(VBO_ATTRIB_NORMAL, x, y, z);
362 }
363
364 static void GLAPIENTRY
365 TAG(Normal3fv)(const GLfloat * v)
366 {
367 GET_CURRENT_CONTEXT(ctx);
368 ATTR3FV(VBO_ATTRIB_NORMAL, v);
369 }
370
371
372
373 static void GLAPIENTRY
374 TAG(FogCoordfEXT)(GLfloat x)
375 {
376 GET_CURRENT_CONTEXT(ctx);
377 ATTR1F(VBO_ATTRIB_FOG, x);
378 }
379
380
381
382 static void GLAPIENTRY
383 TAG(FogCoordfvEXT)(const GLfloat * v)
384 {
385 GET_CURRENT_CONTEXT(ctx);
386 ATTR1FV(VBO_ATTRIB_FOG, v);
387 }
388
389 static void GLAPIENTRY
390 TAG(Color3f)(GLfloat x, GLfloat y, GLfloat z)
391 {
392 GET_CURRENT_CONTEXT(ctx);
393 ATTR3F(VBO_ATTRIB_COLOR0, x, y, z);
394 }
395
396 static void GLAPIENTRY
397 TAG(Color3fv)(const GLfloat * v)
398 {
399 GET_CURRENT_CONTEXT(ctx);
400 ATTR3FV(VBO_ATTRIB_COLOR0, v);
401 }
402
403 static void GLAPIENTRY
404 TAG(Color4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
405 {
406 GET_CURRENT_CONTEXT(ctx);
407 ATTR4F(VBO_ATTRIB_COLOR0, x, y, z, w);
408 }
409
410 static void GLAPIENTRY
411 TAG(Color4fv)(const GLfloat * v)
412 {
413 GET_CURRENT_CONTEXT(ctx);
414 ATTR4FV(VBO_ATTRIB_COLOR0, v);
415 }
416
417
418
419 static void GLAPIENTRY
420 TAG(SecondaryColor3fEXT)(GLfloat x, GLfloat y, GLfloat z)
421 {
422 GET_CURRENT_CONTEXT(ctx);
423 ATTR3F(VBO_ATTRIB_COLOR1, x, y, z);
424 }
425
426 static void GLAPIENTRY
427 TAG(SecondaryColor3fvEXT)(const GLfloat * v)
428 {
429 GET_CURRENT_CONTEXT(ctx);
430 ATTR3FV(VBO_ATTRIB_COLOR1, v);
431 }
432
433
434
435 static void GLAPIENTRY
436 TAG(EdgeFlag)(GLboolean b)
437 {
438 GET_CURRENT_CONTEXT(ctx);
439 ATTR1F(VBO_ATTRIB_EDGEFLAG, (GLfloat) b);
440 }
441
442
443
444 static void GLAPIENTRY
445 TAG(Indexf)(GLfloat f)
446 {
447 GET_CURRENT_CONTEXT(ctx);
448 ATTR1F(VBO_ATTRIB_INDEX, f);
449 }
450
451 static void GLAPIENTRY
452 TAG(Indexfv)(const GLfloat * f)
453 {
454 GET_CURRENT_CONTEXT(ctx);
455 ATTR1FV(VBO_ATTRIB_INDEX, f);
456 }
457
458
459
460 static void GLAPIENTRY
461 TAG(MultiTexCoord1f)(GLenum target, GLfloat x)
462 {
463 GET_CURRENT_CONTEXT(ctx);
464 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
465 ATTR1F(attr, x);
466 }
467
468 static void GLAPIENTRY
469 TAG(MultiTexCoord1fv)(GLenum target, const GLfloat * v)
470 {
471 GET_CURRENT_CONTEXT(ctx);
472 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
473 ATTR1FV(attr, v);
474 }
475
476 static void GLAPIENTRY
477 TAG(MultiTexCoord2f)(GLenum target, GLfloat x, GLfloat y)
478 {
479 GET_CURRENT_CONTEXT(ctx);
480 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
481 ATTR2F(attr, x, y);
482 }
483
484 static void GLAPIENTRY
485 TAG(MultiTexCoord2fv)(GLenum target, const GLfloat * v)
486 {
487 GET_CURRENT_CONTEXT(ctx);
488 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
489 ATTR2FV(attr, v);
490 }
491
492 static void GLAPIENTRY
493 TAG(MultiTexCoord3f)(GLenum target, GLfloat x, GLfloat y, GLfloat z)
494 {
495 GET_CURRENT_CONTEXT(ctx);
496 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
497 ATTR3F(attr, x, y, z);
498 }
499
500 static void GLAPIENTRY
501 TAG(MultiTexCoord3fv)(GLenum target, const GLfloat * v)
502 {
503 GET_CURRENT_CONTEXT(ctx);
504 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
505 ATTR3FV(attr, v);
506 }
507
508 static void GLAPIENTRY
509 TAG(MultiTexCoord4f)(GLenum target, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
510 {
511 GET_CURRENT_CONTEXT(ctx);
512 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
513 ATTR4F(attr, x, y, z, w);
514 }
515
516 static void GLAPIENTRY
517 TAG(MultiTexCoord4fv)(GLenum target, const GLfloat * v)
518 {
519 GET_CURRENT_CONTEXT(ctx);
520 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
521 ATTR4FV(attr, v);
522 }
523
524
525 /**
526 * If index=0, does glVertexAttrib*() alias glVertex() to emit a vertex?
527 */
528 static inline bool
529 is_vertex_position(const struct gl_context *ctx, GLuint index)
530 {
531 return index == 0 && _mesa_attr_zero_aliases_vertex(ctx);
532 }
533
534
535
536 static void GLAPIENTRY
537 TAG(VertexAttrib1fARB)(GLuint index, GLfloat x)
538 {
539 GET_CURRENT_CONTEXT(ctx);
540 if (is_vertex_position(ctx, index))
541 ATTR1F(0, x);
542 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
543 ATTR1F(VBO_ATTRIB_GENERIC0 + index, x);
544 else
545 ERROR(GL_INVALID_VALUE);
546 }
547
548 static void GLAPIENTRY
549 TAG(VertexAttrib1fvARB)(GLuint index, const GLfloat * v)
550 {
551 GET_CURRENT_CONTEXT(ctx);
552 if (is_vertex_position(ctx, index))
553 ATTR1FV(0, v);
554 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
555 ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v);
556 else
557 ERROR(GL_INVALID_VALUE);
558 }
559
560 static void GLAPIENTRY
561 TAG(VertexAttrib2fARB)(GLuint index, GLfloat x, GLfloat y)
562 {
563 GET_CURRENT_CONTEXT(ctx);
564 if (is_vertex_position(ctx, index))
565 ATTR2F(0, x, y);
566 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
567 ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y);
568 else
569 ERROR(GL_INVALID_VALUE);
570 }
571
572 static void GLAPIENTRY
573 TAG(VertexAttrib2fvARB)(GLuint index, const GLfloat * v)
574 {
575 GET_CURRENT_CONTEXT(ctx);
576 if (is_vertex_position(ctx, index))
577 ATTR2FV(0, v);
578 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
579 ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v);
580 else
581 ERROR(GL_INVALID_VALUE);
582 }
583
584 static void GLAPIENTRY
585 TAG(VertexAttrib3fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
586 {
587 GET_CURRENT_CONTEXT(ctx);
588 if (is_vertex_position(ctx, index))
589 ATTR3F(0, x, y, z);
590 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
591 ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z);
592 else
593 ERROR(GL_INVALID_VALUE);
594 }
595
596 static void GLAPIENTRY
597 TAG(VertexAttrib3fvARB)(GLuint index, const GLfloat * v)
598 {
599 GET_CURRENT_CONTEXT(ctx);
600 if (is_vertex_position(ctx, index))
601 ATTR3FV(0, v);
602 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
603 ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v);
604 else
605 ERROR(GL_INVALID_VALUE);
606 }
607
608 static void GLAPIENTRY
609 TAG(VertexAttrib4fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
610 {
611 GET_CURRENT_CONTEXT(ctx);
612 if (is_vertex_position(ctx, index))
613 ATTR4F(0, x, y, z, w);
614 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
615 ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
616 else
617 ERROR(GL_INVALID_VALUE);
618 }
619
620 static void GLAPIENTRY
621 TAG(VertexAttrib4fvARB)(GLuint index, const GLfloat * v)
622 {
623 GET_CURRENT_CONTEXT(ctx);
624 if (is_vertex_position(ctx, index))
625 ATTR4FV(0, v);
626 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
627 ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v);
628 else
629 ERROR(GL_INVALID_VALUE);
630 }
631
632
633
634 /* Integer-valued generic attributes.
635 * XXX: the integers just get converted to floats at this time
636 */
637 static void GLAPIENTRY
638 TAG(VertexAttribI1i)(GLuint index, GLint x)
639 {
640 GET_CURRENT_CONTEXT(ctx);
641 if (is_vertex_position(ctx, index))
642 ATTR1I(0, x);
643 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
644 ATTR1I(VBO_ATTRIB_GENERIC0 + index, x);
645 else
646 ERROR(GL_INVALID_VALUE);
647 }
648
649 static void GLAPIENTRY
650 TAG(VertexAttribI2i)(GLuint index, GLint x, GLint y)
651 {
652 GET_CURRENT_CONTEXT(ctx);
653 if (is_vertex_position(ctx, index))
654 ATTR2I(0, x, y);
655 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
656 ATTR2I(VBO_ATTRIB_GENERIC0 + index, x, y);
657 else
658 ERROR(GL_INVALID_VALUE);
659 }
660
661 static void GLAPIENTRY
662 TAG(VertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z)
663 {
664 GET_CURRENT_CONTEXT(ctx);
665 if (is_vertex_position(ctx, index))
666 ATTR3I(0, x, y, z);
667 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
668 ATTR3I(VBO_ATTRIB_GENERIC0 + index, x, y, z);
669 else
670 ERROR(GL_INVALID_VALUE);
671 }
672
673 static void GLAPIENTRY
674 TAG(VertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w)
675 {
676 GET_CURRENT_CONTEXT(ctx);
677 if (is_vertex_position(ctx, index))
678 ATTR4I(0, x, y, z, w);
679 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
680 ATTR4I(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
681 else
682 ERROR(GL_INVALID_VALUE);
683 }
684
685 static void GLAPIENTRY
686 TAG(VertexAttribI2iv)(GLuint index, const GLint *v)
687 {
688 GET_CURRENT_CONTEXT(ctx);
689 if (is_vertex_position(ctx, index))
690 ATTR2IV(0, v);
691 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
692 ATTR2IV(VBO_ATTRIB_GENERIC0 + index, v);
693 else
694 ERROR(GL_INVALID_VALUE);
695 }
696
697 static void GLAPIENTRY
698 TAG(VertexAttribI3iv)(GLuint index, const GLint *v)
699 {
700 GET_CURRENT_CONTEXT(ctx);
701 if (is_vertex_position(ctx, index))
702 ATTR3IV(0, v);
703 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
704 ATTR3IV(VBO_ATTRIB_GENERIC0 + index, v);
705 else
706 ERROR(GL_INVALID_VALUE);
707 }
708
709 static void GLAPIENTRY
710 TAG(VertexAttribI4iv)(GLuint index, const GLint *v)
711 {
712 GET_CURRENT_CONTEXT(ctx);
713 if (is_vertex_position(ctx, index))
714 ATTR4IV(0, v);
715 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
716 ATTR4IV(VBO_ATTRIB_GENERIC0 + index, v);
717 else
718 ERROR(GL_INVALID_VALUE);
719 }
720
721
722
723 /* Unsigned integer-valued generic attributes.
724 * XXX: the integers just get converted to floats at this time
725 */
726 static void GLAPIENTRY
727 TAG(VertexAttribI1ui)(GLuint index, GLuint x)
728 {
729 GET_CURRENT_CONTEXT(ctx);
730 if (is_vertex_position(ctx, index))
731 ATTR1UI(0, x);
732 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
733 ATTR1UI(VBO_ATTRIB_GENERIC0 + index, x);
734 else
735 ERROR(GL_INVALID_VALUE);
736 }
737
738 static void GLAPIENTRY
739 TAG(VertexAttribI2ui)(GLuint index, GLuint x, GLuint y)
740 {
741 GET_CURRENT_CONTEXT(ctx);
742 if (is_vertex_position(ctx, index))
743 ATTR2UI(0, x, y);
744 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
745 ATTR2UI(VBO_ATTRIB_GENERIC0 + index, x, y);
746 else
747 ERROR(GL_INVALID_VALUE);
748 }
749
750 static void GLAPIENTRY
751 TAG(VertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z)
752 {
753 GET_CURRENT_CONTEXT(ctx);
754 if (is_vertex_position(ctx, index))
755 ATTR3UI(0, x, y, z);
756 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
757 ATTR3UI(VBO_ATTRIB_GENERIC0 + index, x, y, z);
758 else
759 ERROR(GL_INVALID_VALUE);
760 }
761
762 static void GLAPIENTRY
763 TAG(VertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
764 {
765 GET_CURRENT_CONTEXT(ctx);
766 if (is_vertex_position(ctx, index))
767 ATTR4UI(0, x, y, z, w);
768 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
769 ATTR4UI(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
770 else
771 ERROR(GL_INVALID_VALUE);
772 }
773
774 static void GLAPIENTRY
775 TAG(VertexAttribI2uiv)(GLuint index, const GLuint *v)
776 {
777 GET_CURRENT_CONTEXT(ctx);
778 if (is_vertex_position(ctx, index))
779 ATTR2UIV(0, v);
780 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
781 ATTR2UIV(VBO_ATTRIB_GENERIC0 + index, v);
782 else
783 ERROR(GL_INVALID_VALUE);
784 }
785
786 static void GLAPIENTRY
787 TAG(VertexAttribI3uiv)(GLuint index, const GLuint *v)
788 {
789 GET_CURRENT_CONTEXT(ctx);
790 if (is_vertex_position(ctx, index))
791 ATTR3UIV(0, v);
792 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
793 ATTR3UIV(VBO_ATTRIB_GENERIC0 + index, v);
794 else
795 ERROR(GL_INVALID_VALUE);
796 }
797
798 static void GLAPIENTRY
799 TAG(VertexAttribI4uiv)(GLuint index, const GLuint *v)
800 {
801 GET_CURRENT_CONTEXT(ctx);
802 if (is_vertex_position(ctx, index))
803 ATTR4UIV(0, v);
804 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
805 ATTR4UIV(VBO_ATTRIB_GENERIC0 + index, v);
806 else
807 ERROR(GL_INVALID_VALUE);
808 }
809
810
811
812 /* These entrypoints are no longer used for NV_vertex_program but they are
813 * used by the display list and other code specifically because of their
814 * property of aliasing with the legacy Vertex, TexCoord, Normal, etc
815 * attributes. (See vbo_save_loopback.c)
816 */
817 static void GLAPIENTRY
818 TAG(VertexAttrib1fNV)(GLuint index, GLfloat x)
819 {
820 GET_CURRENT_CONTEXT(ctx);
821 if (index < VBO_ATTRIB_MAX)
822 ATTR1F(index, x);
823 }
824
825 static void GLAPIENTRY
826 TAG(VertexAttrib1fvNV)(GLuint index, const GLfloat * v)
827 {
828 GET_CURRENT_CONTEXT(ctx);
829 if (index < VBO_ATTRIB_MAX)
830 ATTR1FV(index, v);
831 }
832
833 static void GLAPIENTRY
834 TAG(VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y)
835 {
836 GET_CURRENT_CONTEXT(ctx);
837 if (index < VBO_ATTRIB_MAX)
838 ATTR2F(index, x, y);
839 }
840
841 static void GLAPIENTRY
842 TAG(VertexAttrib2fvNV)(GLuint index, const GLfloat * v)
843 {
844 GET_CURRENT_CONTEXT(ctx);
845 if (index < VBO_ATTRIB_MAX)
846 ATTR2FV(index, v);
847 }
848
849 static void GLAPIENTRY
850 TAG(VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
851 {
852 GET_CURRENT_CONTEXT(ctx);
853 if (index < VBO_ATTRIB_MAX)
854 ATTR3F(index, x, y, z);
855 }
856
857 static void GLAPIENTRY
858 TAG(VertexAttrib3fvNV)(GLuint index,
859 const GLfloat * v)
860 {
861 GET_CURRENT_CONTEXT(ctx);
862 if (index < VBO_ATTRIB_MAX)
863 ATTR3FV(index, v);
864 }
865
866 static void GLAPIENTRY
867 TAG(VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
868 {
869 GET_CURRENT_CONTEXT(ctx);
870 if (index < VBO_ATTRIB_MAX)
871 ATTR4F(index, x, y, z, w);
872 }
873
874 static void GLAPIENTRY
875 TAG(VertexAttrib4fvNV)(GLuint index, const GLfloat * v)
876 {
877 GET_CURRENT_CONTEXT(ctx);
878 if (index < VBO_ATTRIB_MAX)
879 ATTR4FV(index, v);
880 }
881
882
883 #define ERROR_IF_NOT_PACKED_TYPE(ctx, type, func) \
884 if (type != GL_INT_2_10_10_10_REV && type != GL_UNSIGNED_INT_2_10_10_10_REV) { \
885 _mesa_error(ctx, GL_INVALID_ENUM, "%s(type)", func); \
886 return; \
887 }
888
889 /* Extended version of ERROR_IF_NOT_PACKED_TYPE which also
890 * accepts GL_UNSIGNED_INT_10F_11F_11F_REV.
891 *
892 * Only used for VertexAttribP[123]ui[v]; VertexAttribP4* cannot use this type,
893 * and neither can legacy vertex attribs.
894 */
895 #define ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, func) \
896 if (type != GL_INT_2_10_10_10_REV && type != GL_UNSIGNED_INT_2_10_10_10_REV && \
897 type != GL_UNSIGNED_INT_10F_11F_11F_REV) { \
898 _mesa_error(ctx, GL_INVALID_ENUM, "%s(type)", func); \
899 return; \
900 }
901
902 static void GLAPIENTRY
903 TAG(VertexP2ui)(GLenum type, GLuint value)
904 {
905 GET_CURRENT_CONTEXT(ctx);
906 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexP2ui");
907 ATTR_UI(ctx, 2, type, 0, VBO_ATTRIB_POS, value);
908 }
909
910 static void GLAPIENTRY
911 TAG(VertexP2uiv)(GLenum type, const GLuint *value)
912 {
913 GET_CURRENT_CONTEXT(ctx);
914 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexP2uiv");
915 ATTR_UI(ctx, 2, type, 0, VBO_ATTRIB_POS, value[0]);
916 }
917
918 static void GLAPIENTRY
919 TAG(VertexP3ui)(GLenum type, GLuint value)
920 {
921 GET_CURRENT_CONTEXT(ctx);
922 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexP3ui");
923 ATTR_UI(ctx, 3, type, 0, VBO_ATTRIB_POS, value);
924 }
925
926 static void GLAPIENTRY
927 TAG(VertexP3uiv)(GLenum type, const GLuint *value)
928 {
929 GET_CURRENT_CONTEXT(ctx);
930 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexP3uiv");
931 ATTR_UI(ctx, 3, type, 0, VBO_ATTRIB_POS, value[0]);
932 }
933
934 static void GLAPIENTRY
935 TAG(VertexP4ui)(GLenum type, GLuint value)
936 {
937 GET_CURRENT_CONTEXT(ctx);
938 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexP4ui");
939 ATTR_UI(ctx, 4, type, 0, VBO_ATTRIB_POS, value);
940 }
941
942 static void GLAPIENTRY
943 TAG(VertexP4uiv)(GLenum type, const GLuint *value)
944 {
945 GET_CURRENT_CONTEXT(ctx);
946 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexP4uiv");
947 ATTR_UI(ctx, 4, type, 0, VBO_ATTRIB_POS, value[0]);
948 }
949
950 static void GLAPIENTRY
951 TAG(TexCoordP1ui)(GLenum type, GLuint coords)
952 {
953 GET_CURRENT_CONTEXT(ctx);
954 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP1ui");
955 ATTR_UI(ctx, 1, type, 0, VBO_ATTRIB_TEX0, coords);
956 }
957
958 static void GLAPIENTRY
959 TAG(TexCoordP1uiv)(GLenum type, const GLuint *coords)
960 {
961 GET_CURRENT_CONTEXT(ctx);
962 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP1uiv");
963 ATTR_UI(ctx, 1, type, 0, VBO_ATTRIB_TEX0, coords[0]);
964 }
965
966 static void GLAPIENTRY
967 TAG(TexCoordP2ui)(GLenum type, GLuint coords)
968 {
969 GET_CURRENT_CONTEXT(ctx);
970 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP2ui");
971 ATTR_UI(ctx, 2, type, 0, VBO_ATTRIB_TEX0, coords);
972 }
973
974 static void GLAPIENTRY
975 TAG(TexCoordP2uiv)(GLenum type, const GLuint *coords)
976 {
977 GET_CURRENT_CONTEXT(ctx);
978 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP2uiv");
979 ATTR_UI(ctx, 2, type, 0, VBO_ATTRIB_TEX0, coords[0]);
980 }
981
982 static void GLAPIENTRY
983 TAG(TexCoordP3ui)(GLenum type, GLuint coords)
984 {
985 GET_CURRENT_CONTEXT(ctx);
986 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP3ui");
987 ATTR_UI(ctx, 3, type, 0, VBO_ATTRIB_TEX0, coords);
988 }
989
990 static void GLAPIENTRY
991 TAG(TexCoordP3uiv)(GLenum type, const GLuint *coords)
992 {
993 GET_CURRENT_CONTEXT(ctx);
994 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP3uiv");
995 ATTR_UI(ctx, 3, type, 0, VBO_ATTRIB_TEX0, coords[0]);
996 }
997
998 static void GLAPIENTRY
999 TAG(TexCoordP4ui)(GLenum type, GLuint coords)
1000 {
1001 GET_CURRENT_CONTEXT(ctx);
1002 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP4ui");
1003 ATTR_UI(ctx, 4, type, 0, VBO_ATTRIB_TEX0, coords);
1004 }
1005
1006 static void GLAPIENTRY
1007 TAG(TexCoordP4uiv)(GLenum type, const GLuint *coords)
1008 {
1009 GET_CURRENT_CONTEXT(ctx);
1010 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glTexCoordP4uiv");
1011 ATTR_UI(ctx, 4, type, 0, VBO_ATTRIB_TEX0, coords[0]);
1012 }
1013
1014 static void GLAPIENTRY
1015 TAG(MultiTexCoordP1ui)(GLenum target, GLenum type, GLuint coords)
1016 {
1017 GET_CURRENT_CONTEXT(ctx);
1018 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1019 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP1ui");
1020 ATTR_UI(ctx, 1, type, 0, attr, coords);
1021 }
1022
1023 static void GLAPIENTRY
1024 TAG(MultiTexCoordP1uiv)(GLenum target, GLenum type, const GLuint *coords)
1025 {
1026 GET_CURRENT_CONTEXT(ctx);
1027 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1028 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP1uiv");
1029 ATTR_UI(ctx, 1, type, 0, attr, coords[0]);
1030 }
1031
1032 static void GLAPIENTRY
1033 TAG(MultiTexCoordP2ui)(GLenum target, GLenum type, GLuint coords)
1034 {
1035 GET_CURRENT_CONTEXT(ctx);
1036 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1037 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP2ui");
1038 ATTR_UI(ctx, 2, type, 0, attr, coords);
1039 }
1040
1041 static void GLAPIENTRY
1042 TAG(MultiTexCoordP2uiv)(GLenum target, GLenum type, const GLuint *coords)
1043 {
1044 GET_CURRENT_CONTEXT(ctx);
1045 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1046 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP2uiv");
1047 ATTR_UI(ctx, 2, type, 0, attr, coords[0]);
1048 }
1049
1050 static void GLAPIENTRY
1051 TAG(MultiTexCoordP3ui)(GLenum target, GLenum type, GLuint coords)
1052 {
1053 GET_CURRENT_CONTEXT(ctx);
1054 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1055 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP3ui");
1056 ATTR_UI(ctx, 3, type, 0, attr, coords);
1057 }
1058
1059 static void GLAPIENTRY
1060 TAG(MultiTexCoordP3uiv)(GLenum target, GLenum type, const GLuint *coords)
1061 {
1062 GET_CURRENT_CONTEXT(ctx);
1063 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1064 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP3uiv");
1065 ATTR_UI(ctx, 3, type, 0, attr, coords[0]);
1066 }
1067
1068 static void GLAPIENTRY
1069 TAG(MultiTexCoordP4ui)(GLenum target, GLenum type, GLuint coords)
1070 {
1071 GET_CURRENT_CONTEXT(ctx);
1072 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1073 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP4ui");
1074 ATTR_UI(ctx, 4, type, 0, attr, coords);
1075 }
1076
1077 static void GLAPIENTRY
1078 TAG(MultiTexCoordP4uiv)(GLenum target, GLenum type, const GLuint *coords)
1079 {
1080 GET_CURRENT_CONTEXT(ctx);
1081 GLuint attr = (target & 0x7) + VBO_ATTRIB_TEX0;
1082 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glMultiTexCoordP4uiv");
1083 ATTR_UI(ctx, 4, type, 0, attr, coords[0]);
1084 }
1085
1086 static void GLAPIENTRY
1087 TAG(NormalP3ui)(GLenum type, GLuint coords)
1088 {
1089 GET_CURRENT_CONTEXT(ctx);
1090 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glNormalP3ui");
1091 ATTR_UI(ctx, 3, type, 1, VBO_ATTRIB_NORMAL, coords);
1092 }
1093
1094 static void GLAPIENTRY
1095 TAG(NormalP3uiv)(GLenum type, const GLuint *coords)
1096 {
1097 GET_CURRENT_CONTEXT(ctx);
1098 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glNormalP3uiv");
1099 ATTR_UI(ctx, 3, type, 1, VBO_ATTRIB_NORMAL, coords[0]);
1100 }
1101
1102 static void GLAPIENTRY
1103 TAG(ColorP3ui)(GLenum type, GLuint color)
1104 {
1105 GET_CURRENT_CONTEXT(ctx);
1106 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glColorP3ui");
1107 ATTR_UI(ctx, 3, type, 1, VBO_ATTRIB_COLOR0, color);
1108 }
1109
1110 static void GLAPIENTRY
1111 TAG(ColorP3uiv)(GLenum type, const GLuint *color)
1112 {
1113 GET_CURRENT_CONTEXT(ctx);
1114 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glColorP3uiv");
1115 ATTR_UI(ctx, 3, type, 1, VBO_ATTRIB_COLOR0, color[0]);
1116 }
1117
1118 static void GLAPIENTRY
1119 TAG(ColorP4ui)(GLenum type, GLuint color)
1120 {
1121 GET_CURRENT_CONTEXT(ctx);
1122 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glColorP4ui");
1123 ATTR_UI(ctx, 4, type, 1, VBO_ATTRIB_COLOR0, color);
1124 }
1125
1126 static void GLAPIENTRY
1127 TAG(ColorP4uiv)(GLenum type, const GLuint *color)
1128 {
1129 GET_CURRENT_CONTEXT(ctx);
1130 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glColorP4uiv");
1131 ATTR_UI(ctx, 4, type, 1, VBO_ATTRIB_COLOR0, color[0]);
1132 }
1133
1134 static void GLAPIENTRY
1135 TAG(SecondaryColorP3ui)(GLenum type, GLuint color)
1136 {
1137 GET_CURRENT_CONTEXT(ctx);
1138 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glSecondaryColorP3ui");
1139 ATTR_UI(ctx, 3, type, 1, VBO_ATTRIB_COLOR1, color);
1140 }
1141
1142 static void GLAPIENTRY
1143 TAG(SecondaryColorP3uiv)(GLenum type, const GLuint *color)
1144 {
1145 GET_CURRENT_CONTEXT(ctx);
1146 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glSecondaryColorP3uiv");
1147 ATTR_UI(ctx, 3, type, 1, VBO_ATTRIB_COLOR1, color[0]);
1148 }
1149
1150 static void GLAPIENTRY
1151 TAG(VertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized,
1152 GLuint value)
1153 {
1154 GET_CURRENT_CONTEXT(ctx);
1155 ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP1ui");
1156 ATTR_UI_INDEX(ctx, 1, type, normalized, index, value);
1157 }
1158
1159 static void GLAPIENTRY
1160 TAG(VertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized,
1161 GLuint value)
1162 {
1163 GET_CURRENT_CONTEXT(ctx);
1164 ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP2ui");
1165 ATTR_UI_INDEX(ctx, 2, type, normalized, index, value);
1166 }
1167
1168 static void GLAPIENTRY
1169 TAG(VertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized,
1170 GLuint value)
1171 {
1172 GET_CURRENT_CONTEXT(ctx);
1173 ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP3ui");
1174 ATTR_UI_INDEX(ctx, 3, type, normalized, index, value);
1175 }
1176
1177 static void GLAPIENTRY
1178 TAG(VertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized,
1179 GLuint value)
1180 {
1181 GET_CURRENT_CONTEXT(ctx);
1182 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP4ui");
1183 ATTR_UI_INDEX(ctx, 4, type, normalized, index, value);
1184 }
1185
1186 static void GLAPIENTRY
1187 TAG(VertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized,
1188 const GLuint *value)
1189 {
1190 GET_CURRENT_CONTEXT(ctx);
1191 ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP1uiv");
1192 ATTR_UI_INDEX(ctx, 1, type, normalized, index, *value);
1193 }
1194
1195 static void GLAPIENTRY
1196 TAG(VertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized,
1197 const GLuint *value)
1198 {
1199 GET_CURRENT_CONTEXT(ctx);
1200 ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP2uiv");
1201 ATTR_UI_INDEX(ctx, 2, type, normalized, index, *value);
1202 }
1203
1204 static void GLAPIENTRY
1205 TAG(VertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized,
1206 const GLuint *value)
1207 {
1208 GET_CURRENT_CONTEXT(ctx);
1209 ERROR_IF_NOT_PACKED_TYPE_EXT(ctx, type, "glVertexAttribP3uiv");
1210 ATTR_UI_INDEX(ctx, 3, type, normalized, index, *value);
1211 }
1212
1213 static void GLAPIENTRY
1214 TAG(VertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized,
1215 const GLuint *value)
1216 {
1217 GET_CURRENT_CONTEXT(ctx);
1218 ERROR_IF_NOT_PACKED_TYPE(ctx, type, "glVertexAttribP4uiv");
1219 ATTR_UI_INDEX(ctx, 4, type, normalized, index, *value);
1220 }
1221
1222
1223
1224 static void GLAPIENTRY
1225 TAG(VertexAttribL1d)(GLuint index, GLdouble x)
1226 {
1227 GET_CURRENT_CONTEXT(ctx);
1228 if (is_vertex_position(ctx, index))
1229 ATTR1D(0, x);
1230 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1231 ATTR1D(VBO_ATTRIB_GENERIC0 + index, x);
1232 else
1233 ERROR(GL_INVALID_VALUE);
1234 }
1235
1236 static void GLAPIENTRY
1237 TAG(VertexAttribL1dv)(GLuint index, const GLdouble * v)
1238 {
1239 GET_CURRENT_CONTEXT(ctx);
1240 if (is_vertex_position(ctx, index))
1241 ATTR1DV(0, v);
1242 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1243 ATTR1DV(VBO_ATTRIB_GENERIC0 + index, v);
1244 else
1245 ERROR(GL_INVALID_VALUE);
1246 }
1247
1248 static void GLAPIENTRY
1249 TAG(VertexAttribL2d)(GLuint index, GLdouble x, GLdouble y)
1250 {
1251 GET_CURRENT_CONTEXT(ctx);
1252 if (is_vertex_position(ctx, index))
1253 ATTR2D(0, x, y);
1254 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1255 ATTR2D(VBO_ATTRIB_GENERIC0 + index, x, y);
1256 else
1257 ERROR(GL_INVALID_VALUE);
1258 }
1259
1260 static void GLAPIENTRY
1261 TAG(VertexAttribL2dv)(GLuint index, const GLdouble * v)
1262 {
1263 GET_CURRENT_CONTEXT(ctx);
1264 if (is_vertex_position(ctx, index))
1265 ATTR2DV(0, v);
1266 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1267 ATTR2DV(VBO_ATTRIB_GENERIC0 + index, v);
1268 else
1269 ERROR(GL_INVALID_VALUE);
1270 }
1271
1272 static void GLAPIENTRY
1273 TAG(VertexAttribL3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z)
1274 {
1275 GET_CURRENT_CONTEXT(ctx);
1276 if (is_vertex_position(ctx, index))
1277 ATTR3D(0, x, y, z);
1278 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1279 ATTR3D(VBO_ATTRIB_GENERIC0 + index, x, y, z);
1280 else
1281 ERROR(GL_INVALID_VALUE);
1282 }
1283
1284 static void GLAPIENTRY
1285 TAG(VertexAttribL3dv)(GLuint index, const GLdouble * v)
1286 {
1287 GET_CURRENT_CONTEXT(ctx);
1288 if (is_vertex_position(ctx, index))
1289 ATTR3DV(0, v);
1290 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1291 ATTR3DV(VBO_ATTRIB_GENERIC0 + index, v);
1292 else
1293 ERROR(GL_INVALID_VALUE);
1294 }
1295
1296 static void GLAPIENTRY
1297 TAG(VertexAttribL4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
1298 {
1299 GET_CURRENT_CONTEXT(ctx);
1300 if (is_vertex_position(ctx, index))
1301 ATTR4D(0, x, y, z, w);
1302 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1303 ATTR4D(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
1304 else
1305 ERROR(GL_INVALID_VALUE);
1306 }
1307
1308 static void GLAPIENTRY
1309 TAG(VertexAttribL4dv)(GLuint index, const GLdouble * v)
1310 {
1311 GET_CURRENT_CONTEXT(ctx);
1312 if (is_vertex_position(ctx, index))
1313 ATTR4DV(0, v);
1314 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1315 ATTR4DV(VBO_ATTRIB_GENERIC0 + index, v);
1316 else
1317 ERROR(GL_INVALID_VALUE);
1318 }
1319
1320 static void GLAPIENTRY
1321 TAG(VertexAttribL1ui64ARB)(GLuint index, GLuint64EXT x)
1322 {
1323 GET_CURRENT_CONTEXT(ctx);
1324 if (is_vertex_position(ctx, index))
1325 ATTR1UI64(0, x);
1326 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1327 ATTR1UI64(VBO_ATTRIB_GENERIC0 + index, x);
1328 else
1329 ERROR(GL_INVALID_VALUE);
1330 }
1331
1332 static void GLAPIENTRY
1333 TAG(VertexAttribL1ui64vARB)(GLuint index, const GLuint64EXT *v)
1334 {
1335 GET_CURRENT_CONTEXT(ctx);
1336 if (is_vertex_position(ctx, index))
1337 ATTR1UIV64(0, v);
1338 else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
1339 ATTR1UIV64(VBO_ATTRIB_GENERIC0 + index, v);
1340 else
1341 ERROR(GL_INVALID_VALUE);
1342 }
1343
1344 #undef ATTR1FV
1345 #undef ATTR2FV
1346 #undef ATTR3FV
1347 #undef ATTR4FV
1348
1349 #undef ATTR1F
1350 #undef ATTR2F
1351 #undef ATTR3F
1352 #undef ATTR4F
1353
1354 #undef ATTR_UI
1355
1356 #undef MAT