Subversion Repositories Kolibri OS

Rev

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

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