Merge remote branch 'origin/master' into gallium_draw_llvm
[mesa.git] / src / mesa / main / api_arrayelt.c
index 49aa427d1a367530e111eff25fc74d4095aa973c..ffcd194240f37bc2f042ca11a44dbaf54bb366c1 100644 (file)
 
 #include "glheader.h"
 #include "api_arrayelt.h"
+#include "bufferobj.h"
 #include "context.h"
 #include "imports.h"
 #include "macros.h"
-#include "glapioffsets.h"
-#include "dispatch.h"
+#include "main/dispatch.h"
 
 typedef void (GLAPIENTRY *array_func)( const void * );
 
@@ -70,6 +70,10 @@ typedef struct {
  */
 #define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
 
+
+#if FEATURE_arrayelt
+
+
 static const int ColorFuncs[2][8] = {
    {
       _gloffset_Color3bv,
@@ -166,7 +170,7 @@ static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
@@ -176,7 +180,7 @@ static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
@@ -188,7 +192,7 @@ static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
@@ -201,7 +205,7 @@ static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_UNSIGNED_BYTE attributes */
@@ -213,7 +217,7 @@ static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
 
 static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
@@ -224,7 +228,7 @@ static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
 
 static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
@@ -235,7 +239,7 @@ static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
 }
 static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
@@ -248,7 +252,7 @@ static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
 
 static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_SHORT attributes */
@@ -260,7 +264,7 @@ static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
@@ -271,7 +275,7 @@ static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
@@ -283,7 +287,7 @@ static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
@@ -296,7 +300,7 @@ static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_UNSIGNED_SHORT attributes */
@@ -308,7 +312,7 @@ static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
@@ -319,7 +323,7 @@ static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
@@ -331,7 +335,7 @@ static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
@@ -344,7 +348,7 @@ static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_INT attributes */
@@ -356,7 +360,7 @@ static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
@@ -367,7 +371,7 @@ static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
@@ -379,7 +383,7 @@ static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
@@ -392,7 +396,7 @@ static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_UNSIGNED_INT attributes */
@@ -404,7 +408,7 @@ static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
@@ -415,7 +419,7 @@ static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
@@ -427,7 +431,7 @@ static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
@@ -440,7 +444,7 @@ static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_FLOAT attributes */
@@ -602,7 +606,7 @@ static void GLAPIENTRY VertexAttrib1NbvARB(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib1bvARB(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
@@ -612,7 +616,7 @@ static void GLAPIENTRY VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib2bvARB(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
@@ -624,7 +628,7 @@ static void GLAPIENTRY VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib3bvARB(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
@@ -637,7 +641,7 @@ static void GLAPIENTRY VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
 
 static void GLAPIENTRY VertexAttrib4bvARB(GLuint index, const GLbyte *v)
 {
-   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_UNSIGNED_BYTE attributes */
@@ -649,7 +653,7 @@ static void GLAPIENTRY VertexAttrib1NubvARB(GLuint index, const GLubyte *v)
 
 static void GLAPIENTRY VertexAttrib1ubvARB(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
@@ -660,7 +664,7 @@ static void GLAPIENTRY VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
 
 static void GLAPIENTRY VertexAttrib2ubvARB(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
@@ -671,7 +675,7 @@ static void GLAPIENTRY VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
 }
 static void GLAPIENTRY VertexAttrib3ubvARB(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
@@ -684,7 +688,7 @@ static void GLAPIENTRY VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
 
 static void GLAPIENTRY VertexAttrib4ubvARB(GLuint index, const GLubyte *v)
 {
-   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_SHORT attributes */
@@ -696,7 +700,7 @@ static void GLAPIENTRY VertexAttrib1NsvARB(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib1svARB(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NsvARB(GLuint index, const GLshort *v)
@@ -707,7 +711,7 @@ static void GLAPIENTRY VertexAttrib2NsvARB(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib2svARB(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NsvARB(GLuint index, const GLshort *v)
@@ -719,7 +723,7 @@ static void GLAPIENTRY VertexAttrib3NsvARB(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib3svARB(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NsvARB(GLuint index, const GLshort *v)
@@ -732,7 +736,7 @@ static void GLAPIENTRY VertexAttrib4NsvARB(GLuint index, const GLshort *v)
 
 static void GLAPIENTRY VertexAttrib4svARB(GLuint index, const GLshort *v)
 {
-   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_UNSIGNED_SHORT attributes */
@@ -744,7 +748,7 @@ static void GLAPIENTRY VertexAttrib1NusvARB(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib1usvARB(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NusvARB(GLuint index, const GLushort *v)
@@ -755,7 +759,7 @@ static void GLAPIENTRY VertexAttrib2NusvARB(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib2usvARB(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NusvARB(GLuint index, const GLushort *v)
@@ -767,7 +771,7 @@ static void GLAPIENTRY VertexAttrib3NusvARB(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib3usvARB(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NusvARB(GLuint index, const GLushort *v)
@@ -780,7 +784,7 @@ static void GLAPIENTRY VertexAttrib4NusvARB(GLuint index, const GLushort *v)
 
 static void GLAPIENTRY VertexAttrib4usvARB(GLuint index, const GLushort *v)
 {
-   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_INT attributes */
@@ -792,7 +796,7 @@ static void GLAPIENTRY VertexAttrib1NivARB(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib1ivARB(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NivARB(GLuint index, const GLint *v)
@@ -803,7 +807,7 @@ static void GLAPIENTRY VertexAttrib2NivARB(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib2ivARB(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NivARB(GLuint index, const GLint *v)
@@ -815,7 +819,7 @@ static void GLAPIENTRY VertexAttrib3NivARB(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib3ivARB(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NivARB(GLuint index, const GLint *v)
@@ -828,7 +832,7 @@ static void GLAPIENTRY VertexAttrib4NivARB(GLuint index, const GLint *v)
 
 static void GLAPIENTRY VertexAttrib4ivARB(GLuint index, const GLint *v)
 {
-   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_UNSIGNED_INT attributes */
@@ -840,7 +844,7 @@ static void GLAPIENTRY VertexAttrib1NuivARB(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib1uivARB(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, (GLfloat)v[0]));
 }
 
 static void GLAPIENTRY VertexAttrib2NuivARB(GLuint index, const GLuint *v)
@@ -851,7 +855,7 @@ static void GLAPIENTRY VertexAttrib2NuivARB(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib2uivARB(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1]));
 }
 
 static void GLAPIENTRY VertexAttrib3NuivARB(GLuint index, const GLuint *v)
@@ -863,7 +867,7 @@ static void GLAPIENTRY VertexAttrib3NuivARB(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib3uivARB(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]));
 }
 
 static void GLAPIENTRY VertexAttrib4NuivARB(GLuint index, const GLuint *v)
@@ -876,7 +880,7 @@ static void GLAPIENTRY VertexAttrib4NuivARB(GLuint index, const GLuint *v)
 
 static void GLAPIENTRY VertexAttrib4uivARB(GLuint index, const GLuint *v)
 {
-   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3]));
 }
 
 /* GL_FLOAT attributes */
@@ -1071,7 +1075,7 @@ void _ae_destroy_context( GLcontext *ctx )
 static void check_vbo( AEcontext *actx,
                       struct gl_buffer_object *vbo )
 {
-   if (vbo->Name && !vbo->Pointer) {
+   if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) {
       GLuint i;
       for (i = 0; i < actx->nr_vbos; i++)
         if (actx->vbo[i] == vbo)
@@ -1094,48 +1098,49 @@ static void _ae_update_state( GLcontext *ctx )
    AEarray *aa = actx->arrays;
    AEattrib *at = actx->attribs;
    GLuint i;
+   struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
 
    actx->nr_vbos = 0;
 
    /* conventional vertex arrays */
-  if (ctx->Array.ArrayObj->Index.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Index;
+   if (arrayObj->Index.Enabled) {
+      aa->array = &arrayObj->Index;
       aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->EdgeFlag.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->EdgeFlag;
+   if (arrayObj->EdgeFlag.Enabled) {
+      aa->array = &arrayObj->EdgeFlag;
       aa->offset = _gloffset_EdgeFlagv;
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->Normal.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Normal;
+   if (arrayObj->Normal.Enabled) {
+      aa->array = &arrayObj->Normal;
       aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->Color.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Color;
+   if (arrayObj->Color.Enabled) {
+      aa->array = &arrayObj->Color;
       aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->SecondaryColor.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->SecondaryColor;
+   if (arrayObj->SecondaryColor.Enabled) {
+      aa->array = &arrayObj->SecondaryColor;
       aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   if (ctx->Array.ArrayObj->FogCoord.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->FogCoord;
+   if (arrayObj->FogCoord.Enabled) {
+      aa->array = &arrayObj->FogCoord;
       aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-      struct gl_client_array *attribArray = &ctx->Array.ArrayObj->TexCoord[i];
+      struct gl_client_array *attribArray = &arrayObj->TexCoord[i];
       if (attribArray->Enabled) {
          /* NOTE: we use generic glVertexAttribNV functions here.
           * If we ever remove GL_NV_vertex_program this will have to change.
@@ -1152,13 +1157,13 @@ static void _ae_update_state( GLcontext *ctx )
    }
 
    /* generic vertex attribute arrays */   
-   for (i = 1; i < VERT_ATTRIB_MAX; i++) {  /* skip zero! */
-      struct gl_client_array *attribArray = &ctx->Array.ArrayObj->VertexAttrib[i];
+   for (i = 1; i < Elements(arrayObj->VertexAttrib); i++) {  /* skip zero! */
+      struct gl_client_array *attribArray = &arrayObj->VertexAttrib[i];
       if (attribArray->Enabled) {
          at->array = attribArray;
          /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
           * function pointer here (for float arrays) since the pointer may
-          * change from one execution of _ae_loopback_array_elt() to
+          * change from one execution of _ae_ArrayElement() to
           * the next.  Doing so caused UT to break.
           */
          if (ctx->VertexProgram._Enabled
@@ -1179,18 +1184,18 @@ static void _ae_update_state( GLcontext *ctx )
    }
 
    /* finally, vertex position */
-   if (ctx->Array.ArrayObj->VertexAttrib[0].Enabled) {
+   if (arrayObj->VertexAttrib[0].Enabled) {
       /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
        * issued as the last (provoking) attribute).
        */
-      aa->array = &ctx->Array.ArrayObj->VertexAttrib[0];
+      aa->array = &arrayObj->VertexAttrib[0];
       assert(aa->array->Size >= 2); /* XXX fix someday? */
       aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
    }
-   else if (ctx->Array.ArrayObj->Vertex.Enabled) {
-      aa->array = &ctx->Array.ArrayObj->Vertex;
+   else if (arrayObj->Vertex.Enabled) {
+      aa->array = &arrayObj->Vertex;
       aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
       check_vbo(actx, aa->array->BufferObj);
       aa++;
@@ -1252,7 +1257,7 @@ void _ae_unmap_vbos( GLcontext *ctx )
  * for all enabled vertex arrays (for elt-th element).
  * Note: this may be called during display list construction.
  */
-void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
+void GLAPIENTRY _ae_ArrayElement( GLint elt )
 {
    GET_CURRENT_CONTEXT(ctx);
    const AEcontext *actx = AE_CONTEXT(ctx);
@@ -1299,11 +1304,29 @@ void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
 {
    AEcontext *actx = AE_CONTEXT(ctx);
 
-   /* It is possible to raise a statechange between begin/end pairs as
-    * the glMaterial calls will raise _NEW_LIGHT eventually.  However,
-    * within a DrawArrays or DrawElements call (which cannot emit
-    * material data), it should never be possible.
+   
+   /* Only interested in this subset of mesa state.  Need to prune
+    * this down as both tnl/ and the drivers can raise statechanges
+    * for arcane reasons in the middle of seemingly atomic operations
+    * like DrawElements, over which we'd like to keep a known set of
+    * arrays and vbo's mapped.  
+    *
+    * Luckily, neither the drivers nor tnl muck with the state that
+    * concerns us here:
     */
-   assert(!actx->mapped_vbos);
-   actx->NewState |= new_state;
+   new_state &= _NEW_ARRAY | _NEW_PROGRAM;
+   if (new_state) {
+      assert(!actx->mapped_vbos);
+      actx->NewState |= new_state;
+   }
 }
+
+
+void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
+                                   const GLvertexformat *vfmt)
+{
+   SET_ArrayElement(disp, vfmt->ArrayElement);
+}
+
+
+#endif /* FEATURE_arrayelt */