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