No longer alias generic vertex attribs with conventional attribs for GL_ARB_vertex_pr...
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 25 Apr 2006 00:21:32 +0000 (00:21 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 25 Apr 2006 00:21:32 +0000 (00:21 +0000)
src/mesa/main/api_arrayelt.c
src/mesa/main/dd.h
src/mesa/main/mtypes.h
src/mesa/main/varray.c
src/mesa/main/vtxfmt.c
src/mesa/shader/arbprogparse.c
src/mesa/tnl/t_context.h
src/mesa/tnl/t_vtx_api.c
src/mesa/tnl/t_vtx_api.h
src/mesa/tnl/t_vtx_generic.c

index e905f16..9c65ae5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -147,7 +147,10 @@ static const int NormalFuncs[8] = {
 static int SecondaryColorFuncs[8];
 static int FogCoordFuncs[8];
 
-/**********************************************************************/
+
+/**
+ ** GL_NV_vertex_program
+ **/
 
 /* GL_BYTE attributes */
 
@@ -580,6 +583,442 @@ static attrib_func AttribFuncsNV[2][4][8] = {
    }
 };
 
+
+/**
+ ** GL_ARB_vertex_program
+ **/
+
+/* GL_BYTE attributes */
+
+static void GLAPIENTRY VertexAttrib1NbvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1bvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NbvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2bvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NbvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
+                                              BYTE_TO_FLOAT(v[1]),
+                                              BYTE_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3bvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NbvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
+                                              BYTE_TO_FLOAT(v[1]),
+                                              BYTE_TO_FLOAT(v[2]),
+                                              BYTE_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4bvARB(GLuint index, const GLbyte *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_UNSIGNED_BYTE attributes */
+
+static void GLAPIENTRY VertexAttrib1NubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1ubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
+                                              UBYTE_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2ubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
+                                              UBYTE_TO_FLOAT(v[1]),
+                                              UBYTE_TO_FLOAT(v[2])));
+}
+static void GLAPIENTRY VertexAttrib3ubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
+                                     UBYTE_TO_FLOAT(v[1]),
+                                     UBYTE_TO_FLOAT(v[2]),
+                                     UBYTE_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4ubvARB(GLuint index, const GLubyte *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_SHORT attributes */
+
+static void GLAPIENTRY VertexAttrib1NsvARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1svARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NsvARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
+                                              SHORT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2svARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NsvARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
+                            SHORT_TO_FLOAT(v[1]),
+                            SHORT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3svARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NsvARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
+                            SHORT_TO_FLOAT(v[1]),
+                            SHORT_TO_FLOAT(v[2]),
+                            SHORT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4svARB(GLuint index, const GLshort *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_UNSIGNED_SHORT attributes */
+
+static void GLAPIENTRY VertexAttrib1NusvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1usvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NusvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
+                            USHORT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2usvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NusvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
+                                              USHORT_TO_FLOAT(v[1]),
+                                              USHORT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3usvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NusvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
+                                              USHORT_TO_FLOAT(v[1]),
+                                              USHORT_TO_FLOAT(v[2]),
+                                              USHORT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4usvARB(GLuint index, const GLushort *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_INT attributes */
+
+static void GLAPIENTRY VertexAttrib1NivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1ivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
+                                              INT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2ivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
+                                              INT_TO_FLOAT(v[1]),
+                                              INT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3ivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
+                                              INT_TO_FLOAT(v[1]),
+                                              INT_TO_FLOAT(v[2]),
+                                              INT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4ivARB(GLuint index, const GLint *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_UNSIGNED_INT attributes */
+
+static void GLAPIENTRY VertexAttrib1NuivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1uivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib1fARB(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NuivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
+                                              UINT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2uivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib2fARB(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NuivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
+                                              UINT_TO_FLOAT(v[1]),
+                                              UINT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3uivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib3fARB(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NuivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
+                                              UINT_TO_FLOAT(v[1]),
+                                              UINT_TO_FLOAT(v[2]),
+                                              UINT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4uivARB(GLuint index, const GLuint *v)
+{
+   CALL_VertexAttrib4fARB(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_FLOAT attributes */
+
+static void GLAPIENTRY VertexAttrib1fvARB(GLuint index, const GLfloat *v)
+{
+   CALL_VertexAttrib1fvARB(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib2fvARB(GLuint index, const GLfloat *v)
+{
+   CALL_VertexAttrib2fvARB(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib3fvARB(GLuint index, const GLfloat *v)
+{
+   CALL_VertexAttrib3fvARB(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib4fvARB(GLuint index, const GLfloat *v)
+{
+   CALL_VertexAttrib4fvARB(GET_DISPATCH(), (index, v));
+}
+
+/* GL_DOUBLE attributes */
+
+static void GLAPIENTRY VertexAttrib1dvARB(GLuint index, const GLdouble *v)
+{
+   CALL_VertexAttrib1dvARB(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib2dvARB(GLuint index, const GLdouble *v)
+{
+   CALL_VertexAttrib2dvARB(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib3dvARB(GLuint index, const GLdouble *v)
+{
+   CALL_VertexAttrib3dvARB(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib4dvARB(GLuint index, const GLdouble *v)
+{
+   CALL_VertexAttrib4dvARB(GET_DISPATCH(), (index, v));
+}
+
+
+/*
+ * Array [size][type] of VertexAttrib functions
+ */
+static attrib_func AttribFuncsARB[2][4][8] = {
+   {
+      /* non-normalized */
+      {
+         /* size 1 */
+         (attrib_func) VertexAttrib1bvARB,
+         (attrib_func) VertexAttrib1ubvARB,
+         (attrib_func) VertexAttrib1svARB,
+         (attrib_func) VertexAttrib1usvARB,
+         (attrib_func) VertexAttrib1ivARB,
+         (attrib_func) VertexAttrib1uivARB,
+         (attrib_func) VertexAttrib1fvARB,
+         (attrib_func) VertexAttrib1dvARB
+      },
+      {
+         /* size 2 */
+         (attrib_func) VertexAttrib2bvARB,
+         (attrib_func) VertexAttrib2ubvARB,
+         (attrib_func) VertexAttrib2svARB,
+         (attrib_func) VertexAttrib2usvARB,
+         (attrib_func) VertexAttrib2ivARB,
+         (attrib_func) VertexAttrib2uivARB,
+         (attrib_func) VertexAttrib2fvARB,
+         (attrib_func) VertexAttrib2dvARB
+      },
+      {
+         /* size 3 */
+         (attrib_func) VertexAttrib3bvARB,
+         (attrib_func) VertexAttrib3ubvARB,
+         (attrib_func) VertexAttrib3svARB,
+         (attrib_func) VertexAttrib3usvARB,
+         (attrib_func) VertexAttrib3ivARB,
+         (attrib_func) VertexAttrib3uivARB,
+         (attrib_func) VertexAttrib3fvARB,
+         (attrib_func) VertexAttrib3dvARB
+      },
+      {
+         /* size 4 */
+         (attrib_func) VertexAttrib4bvARB,
+         (attrib_func) VertexAttrib4ubvARB,
+         (attrib_func) VertexAttrib4svARB,
+         (attrib_func) VertexAttrib4usvARB,
+         (attrib_func) VertexAttrib4ivARB,
+         (attrib_func) VertexAttrib4uivARB,
+         (attrib_func) VertexAttrib4fvARB,
+         (attrib_func) VertexAttrib4dvARB
+      }
+   },
+   {
+      /* normalized (except for float/double) */
+      {
+         /* size 1 */
+         (attrib_func) VertexAttrib1NbvARB,
+         (attrib_func) VertexAttrib1NubvARB,
+         (attrib_func) VertexAttrib1NsvARB,
+         (attrib_func) VertexAttrib1NusvARB,
+         (attrib_func) VertexAttrib1NivARB,
+         (attrib_func) VertexAttrib1NuivARB,
+         (attrib_func) VertexAttrib1fvARB,
+         (attrib_func) VertexAttrib1dvARB
+      },
+      {
+         /* size 2 */
+         (attrib_func) VertexAttrib2NbvARB,
+         (attrib_func) VertexAttrib2NubvARB,
+         (attrib_func) VertexAttrib2NsvARB,
+         (attrib_func) VertexAttrib2NusvARB,
+         (attrib_func) VertexAttrib2NivARB,
+         (attrib_func) VertexAttrib2NuivARB,
+         (attrib_func) VertexAttrib2fvARB,
+         (attrib_func) VertexAttrib2dvARB
+      },
+      {
+         /* size 3 */
+         (attrib_func) VertexAttrib3NbvARB,
+         (attrib_func) VertexAttrib3NubvARB,
+         (attrib_func) VertexAttrib3NsvARB,
+         (attrib_func) VertexAttrib3NusvARB,
+         (attrib_func) VertexAttrib3NivARB,
+         (attrib_func) VertexAttrib3NuivARB,
+         (attrib_func) VertexAttrib3fvARB,
+         (attrib_func) VertexAttrib3dvARB
+      },
+      {
+         /* size 4 */
+         (attrib_func) VertexAttrib4NbvARB,
+         (attrib_func) VertexAttrib4NubvARB,
+         (attrib_func) VertexAttrib4NsvARB,
+         (attrib_func) VertexAttrib4NusvARB,
+         (attrib_func) VertexAttrib4NivARB,
+         (attrib_func) VertexAttrib4NuivARB,
+         (attrib_func) VertexAttrib4fvARB,
+         (attrib_func) VertexAttrib4dvARB
+      }
+   }
+};
+
 /**********************************************************************/
 
 
@@ -670,14 +1109,16 @@ static void _ae_update_state( GLcontext *ctx )
       aa++;
    }
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-      if (ctx->Array.TexCoord[i].Enabled) {
-         /* NOTE: we use generic glVertexAttrib functions here.
-          * If we ever de-alias conventional/generic vertex attribs this
-          * will have to change.
+      struct gl_client_array *attribArray = &ctx->Array.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.
           */
-         struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
          at->array = attribArray;
-         at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
+         ASSERT(!at->array->Normalized);
+         at->func = AttribFuncsNV[at->array->Normalized]
+                                 [at->array->Size-1]
+                                 [TYPE_IDX(at->array->Type)];
          at->index = VERT_ATTRIB_TEX0 + i;
          at++;
       }
@@ -685,15 +1126,25 @@ static void _ae_update_state( GLcontext *ctx )
 
    /* generic vertex attribute arrays */
    for (i = 1; i < VERT_ATTRIB_MAX; i++) {  /* skip zero! */
-      if (ctx->Array.VertexAttrib[i].Enabled) {
-         struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
+      struct gl_client_array *attribArray = &ctx->Array.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
           * the next.  Doing so caused UT to break.
           */
-         at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
+         if (ctx->VertexProgram._Enabled
+             && ctx->VertexProgram.Current->IsNVProgram) {
+            at->func = AttribFuncsNV[at->array->Normalized]
+                                    [at->array->Size-1]
+                                    [TYPE_IDX(at->array->Type)];
+         }
+         else {
+            at->func = AttribFuncsARB[at->array->Normalized]
+                                     [at->array->Size-1]
+                                     [TYPE_IDX(at->array->Type)];
+         }
          at->index = i;
          at++;
       }
@@ -702,7 +1153,7 @@ static void _ae_update_state( GLcontext *ctx )
    /* finally, vertex position */
    if (ctx->Array.VertexAttrib[0].Enabled) {
       /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
-       * issued as the last (proviking) attribute).
+       * issued as the last (provoking) attribute).
        */
       aa->array = &ctx->Array.VertexAttrib[0];
       assert(aa->array->Size >= 2); /* XXX fix someday? */
index 4f1a962..b1c78f2 100644 (file)
@@ -1017,6 +1017,7 @@ typedef struct {
    void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * );    /* NOTE */
    void (GLAPIENTRYP Begin)( GLenum );
    void (GLAPIENTRYP End)( void );
+   /* GL_NV_vertex_program */
    void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x );
    void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v );
    void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y );
@@ -1025,6 +1026,7 @@ typedef struct {
    void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
    void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
    void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
+#if FEATURE_ARB_vertex_program
    void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x );
    void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v );
    void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y );
@@ -1033,6 +1035,7 @@ typedef struct {
    void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v );
    void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
    void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v );
+#endif
    /*@}*/
 
    /*
index a78a7d1..244d1c6 100644 (file)
@@ -613,29 +613,27 @@ struct gl_colorbuffer_attrib
 struct gl_current_attrib
 {
    /**
-    * \name Values valid only when FLUSH_VERTICES has been called.
+    * \name Current vertex attributes.
+    * \note Values are valid only after FLUSH_VERTICES has been called.
     */
    /*@{*/
-   GLfloat Attrib[VERT_ATTRIB_MAX][4];         /**< Current vertex attributes
-                                                 *  indexed by VERT_ATTRIB_* */
-   GLfloat Index;                              /**< Current color index */
-   GLboolean EdgeFlag;                         /**< Current edge flag */
+   GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
+   GLfloat Index;                      /**< Current color index */
+   GLboolean EdgeFlag;                 /**< Current edge flag */
    /*@}*/
 
    /**
-    * \name Values are always valid.  
-    * 
-    * \note BTW, note how similar this set of attributes is to the SWvertex
-    * data type in the software rasterizer...
+    * \name Current raster position attributes (always valid).
+    * \note This set of attributes is very similar to the SWvertex struct.
     */
    /*@{*/
-   GLfloat RasterPos[4];                       /**< Current raster position */
-   GLfloat RasterDistance;                     /**< Current raster distance */
-   GLfloat RasterColor[4];                     /**< Current raster color */
-   GLfloat RasterSecondaryColor[4];             /**< Current raster secondary color */
-   GLfloat RasterIndex;                                /**< Current raster index */
+   GLfloat RasterPos[4];
+   GLfloat RasterDistance;
+   GLfloat RasterColor[4];
+   GLfloat RasterSecondaryColor[4];
+   GLfloat RasterIndex;
    GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4];
-   GLboolean RasterPosValid;                   /**< Raster pos valid flag */
+   GLboolean RasterPosValid;
    /*@}*/
 };
 
@@ -1641,7 +1639,9 @@ struct gl_client_array
  */
 struct gl_array_attrib
 {
-   struct gl_client_array Vertex;           /**< client data descriptors */
+   /** Conventional vertex arrays */
+   /*@{*/
+   struct gl_client_array Vertex;
    struct gl_client_array Normal;
    struct gl_client_array Color;
    struct gl_client_array SecondaryColor;
@@ -1649,15 +1649,17 @@ struct gl_array_attrib
    struct gl_client_array Index;
    struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
    struct gl_client_array EdgeFlag;
+   /*@}*/
 
-   struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];  /**< GL_NV_vertex_program */
+   /** Generic arrays for vertex programs/shaders; */
+   struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];
 
    GLint ActiveTexture;                /**< Client Active Texture */
    GLuint LockFirst;            /**< GL_EXT_compiled_vertex_array */
    GLuint LockCount;            /**< GL_EXT_compiled_vertex_array */
 
-   GLbitfield _Enabled;                /**< _NEW_ARRAY_* - bit set if array enabled */
-   GLbitfield NewState;                /**< _NEW_ARRAY_* */
+   GLbitfield _Enabled;                /**< mask of _NEW_ARRAY_* values */
+   GLbitfield NewState;                /**< mask of _NEW_ARRAY_* values */
 
 #if FEATURE_ARB_vertex_buffer_object
    struct gl_buffer_object *NullBufferObj;
index 87d9660..97b0214 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -29,8 +29,6 @@
 #include "context.h"
 #include "enable.h"
 #include "enums.h"
-#include "dlist.h"
-#include "texstate.h"
 #include "mtypes.h"
 #include "varray.h"
 #include "dispatch.h"
@@ -47,7 +45,7 @@
  */
 static void
 update_array(GLcontext *ctx, struct gl_client_array *array,
-             GLuint dirtyFlag, GLsizei elementSize,
+             GLbitfield dirtyFlag, GLsizei elementSize,
              GLint size, GLenum type,
              GLsizei stride, GLboolean normalized, const GLvoid *ptr)
 {
@@ -437,6 +435,7 @@ void GLAPIENTRY
 _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
                             GLsizei stride, const GLvoid *ptr)
 {
+   const GLboolean normalized = GL_FALSE;
    GLsizei elementSize;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -481,7 +480,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
    }
 
    update_array(ctx, &ctx->Array.VertexAttrib[index], _NEW_ARRAY_ATTRIB(index),
-                elementSize, size, type, stride, GL_FALSE, ptr);
+                elementSize, size, type, stride, normalized, ptr);
 
    if (ctx->Driver.VertexAttribPointer)
       ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
@@ -754,6 +753,7 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
 
    _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
    _mesa_DisableClientState( GL_INDEX_ARRAY );
+   /* XXX also disable secondary color and generic arrays? */
 
    /* Texcoords */
    if (tflag) {
@@ -917,12 +917,11 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
 }
 
 
-/**********************************************************************/
-/*****                      Initialization                        *****/
-/**********************************************************************/
-
+/**
+ * Initialize vertex array state for given context.
+ */
 void 
-_mesa_init_varray( GLcontext * ctx )
+_mesa_init_varray(GLcontext *ctx)
 {
    GLuint i;
 
@@ -981,7 +980,6 @@ _mesa_init_varray( GLcontext * ctx )
    ctx->Array.EdgeFlag.Ptr = NULL;
    ctx->Array.EdgeFlag.Enabled = GL_FALSE;
    ctx->Array.EdgeFlag.Flags = CA_CLIENT_DATA;
-   ctx->Array.ActiveTexture = 0;   /* GL_ARB_multitexture */
    for (i = 0; i < VERT_ATTRIB_MAX; i++) {
       ctx->Array.VertexAttrib[i].Size = 4;
       ctx->Array.VertexAttrib[i].Type = GL_FLOAT;
@@ -989,6 +987,9 @@ _mesa_init_varray( GLcontext * ctx )
       ctx->Array.VertexAttrib[i].StrideB = 0;
       ctx->Array.VertexAttrib[i].Ptr = NULL;
       ctx->Array.VertexAttrib[i].Enabled = GL_FALSE;
+      ctx->Array.VertexAttrib[i].Normalized = GL_FALSE;
       ctx->Array.VertexAttrib[i].Flags = CA_CLIENT_DATA;
    }
+
+   ctx->Array.ActiveTexture = 0;   /* GL_ARB_multitexture */
 }
index b3c6398..99583a2 100644 (file)
 #include "vtxfmt_tmp.h"
 
 
-
+/**
+ * Use the per-vertex functions found in <vfmt> to initialze the given
+ * API dispatch table.
+ */
 static void
 install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
 {
@@ -124,6 +127,15 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_CallLists(tab, vfmt->CallLists);
    SET_Begin(tab, vfmt->Begin);
    SET_End(tab, vfmt->End);
+   SET_Rectf(tab, vfmt->Rectf);
+   SET_DrawArrays(tab, vfmt->DrawArrays);
+   SET_DrawElements(tab, vfmt->DrawElements);
+   SET_DrawRangeElements(tab, vfmt->DrawRangeElements);
+   SET_EvalMesh1(tab, vfmt->EvalMesh1);
+   SET_EvalMesh2(tab, vfmt->EvalMesh2);
+   ASSERT(tab->EvalMesh2);
+
+   /* GL_NV_vertex_program */
    SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV);
    SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV);
    SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV);
@@ -132,6 +144,7 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV);
    SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV);
    SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV);
+#if FEATURE_ARB_vertex_program
    SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB);
    SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB);
    SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB);
@@ -140,13 +153,7 @@ install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
    SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB);
    SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB);
    SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB);
-   SET_Rectf(tab, vfmt->Rectf);
-   SET_DrawArrays(tab, vfmt->DrawArrays);
-   SET_DrawElements(tab, vfmt->DrawElements);
-   SET_DrawRangeElements(tab, vfmt->DrawRangeElements);
-   SET_EvalMesh1(tab, vfmt->EvalMesh1);
-   SET_EvalMesh2(tab, vfmt->EvalMesh2);
-   ASSERT(tab->EvalMesh2);
+#endif
 }
 
 
index f8809c5..de63c50 100644 (file)
@@ -1537,7 +1537,12 @@ parse_attrib_binding(GLcontext * ctx, GLubyte ** inst,
                GLuint attrib;
                if (!parse_generic_attrib_num(ctx, inst, Program, &attrib)) {
                   *is_generic = 1;
-                  *inputReg = attrib;
+                  /* Add VERT_ATTRIB_GENERIC0 here because ARB_vertex_program's
+                   * attributes do not alias the conventional vertex
+                   * attributes.
+                   */
+                  if (attrib > 0)
+                     *inputReg = attrib + VERT_ATTRIB_GENERIC0;
                }
             }
             break;
index 7a0ca6f..7a80e34 100644 (file)
@@ -152,6 +152,9 @@ enum {
 #define _TNL_ATTRIB_TEX(u)       (_TNL_ATTRIB_TEX0 + (u))
 #define _TNL_ATTRIB_ATTRIBUTE(n) (_TNL_ATTRIB_ATTRIBUTE0 + (n))
 
+/* special index used for handing invalid glVertexAttribute() indices */
+#define _TNL_ATTRIB_ERROR    (_TNL_ATTRIB_ATTRIBUTE15 + 1)
+
 /* Define bit ranges instead of bit masks.
  */
 #define _TNL_FIRST_PROG      _TNL_ATTRIB_WEIGHT
@@ -228,10 +231,11 @@ struct _tnl_dynfn_generators {
    struct _tnl_dynfn *(*Attribute[4])( GLcontext *ctx, int key );
 };
 
-#define _TNL_MAX_ATTR_CODEGEN 16 
+#define _TNL_MAX_ATTR_CODEGEN 32
 
 
-/* The assembly of vertices in immediate mode is separated from
+/**
+ * The assembly of vertices in immediate mode is separated from
  * display list compilation.  This allows a simpler immediate mode
  * treatment and a display list compiler better suited to
  * hardware-acceleration.
@@ -250,7 +254,8 @@ struct tnl_vtx {
    GLuint counter, initial_counter;
    struct tnl_copied_vtx copied;
 
-   tnl_attrfv_func tabfv[_TNL_MAX_ATTR_CODEGEN+1][4]; /* plus 1 for ERROR_ATTRIB */
+   /** Note extra space for error handler: */
+   tnl_attrfv_func tabfv[_TNL_ATTRIB_ERROR+1][4];
 
    struct _tnl_dynfn_lists cache;
    struct _tnl_dynfn_generators gen;
index feb462b..e8f63f2 100644 (file)
@@ -47,7 +47,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 static void reset_attrfv( TNLcontext *tnl );
 
-static tnl_attrfv_func choose[_TNL_MAX_ATTR_CODEGEN+1][4]; /* +1 for ERROR_ATTRIB */
+/** Note extra space for error index: */
+static tnl_attrfv_func choose[_TNL_ATTRIB_ERROR+1][4];
 static tnl_attrfv_func generic_attr_func[_TNL_MAX_ATTR_CODEGEN][4];
 
 
@@ -191,8 +192,7 @@ static void _tnl_copy_from_current( GLcontext *ctx )
 
    /* Edgeflag requires additional treatment:
     */
-   tnl->vtx.CurrentFloatEdgeFlag = 
-      (GLfloat)ctx->Current.EdgeFlag;
+   tnl->vtx.CurrentFloatEdgeFlag = (GLfloat) ctx->Current.EdgeFlag;
    
    for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_MAX ; i++) 
       switch (tnl->vtx.attrsz[i]) {
@@ -435,6 +435,7 @@ static tnl_attrfv_func do_choose( GLuint attr, GLuint sz )
    if (!tnl->vtx.tabfv[attr][sz-1])
       tnl->vtx.tabfv[attr][sz-1] = generic_attr_func[attr][sz-1];
 
+   ASSERT(tnl->vtx.tabfv[attr][sz-1]);
    return tnl->vtx.tabfv[attr][sz-1];
 }
 
@@ -444,6 +445,7 @@ static tnl_attrfv_func do_choose( GLuint attr, GLuint sz )
 static void choose_##ATTR##_##N( const GLfloat *v )    \
 {                                                      \
    tnl_attrfv_func f = do_choose(ATTR, N);             \
+   ASSERT(f); \
    f( v );                                             \
 }
 
@@ -455,11 +457,13 @@ static void choose_##ATTR##_##N( const GLfloat *v )       \
 
 
 #define INIT_CHOOSERS(ATTR)                    \
+   ASSERT(ATTR <= _TNL_ATTRIB_ERROR);\
    choose[ATTR][0] = choose_##ATTR##_1;                \
    choose[ATTR][1] = choose_##ATTR##_2;                \
    choose[ATTR][2] = choose_##ATTR##_3;                \
    choose[ATTR][3] = choose_##ATTR##_4;
 
+/* conventional attributes */
 CHOOSERS( 0 )
 CHOOSERS( 1 )
 CHOOSERS( 2 )
@@ -477,6 +481,23 @@ CHOOSERS( 13 )
 CHOOSERS( 14 )
 CHOOSERS( 15 )
 
+/* generic attributes */
+CHOOSERS( 16 )
+CHOOSERS( 17 )
+CHOOSERS( 18 )
+CHOOSERS( 19 )
+CHOOSERS( 20 )
+CHOOSERS( 21 )
+CHOOSERS( 22 )
+CHOOSERS( 23 )
+CHOOSERS( 24 )
+CHOOSERS( 25 )
+CHOOSERS( 26 )
+CHOOSERS( 27 )
+CHOOSERS( 28 )
+CHOOSERS( 29 )
+CHOOSERS( 30 )
+CHOOSERS( 31 )
 
 
 /**
@@ -935,6 +956,7 @@ void _tnl_vtx_init( GLcontext *ctx )
    if (firsttime) {
       firsttime = 0;
 
+      /* conventional attributes */
       INIT_CHOOSERS( 0 );
       INIT_CHOOSERS( 1 );
       INIT_CHOOSERS( 2 );
@@ -952,10 +974,28 @@ void _tnl_vtx_init( GLcontext *ctx )
       INIT_CHOOSERS( 14 );
       INIT_CHOOSERS( 15 );
 
-      choose[ERROR_ATTRIB][0] = error_attrib;
-      choose[ERROR_ATTRIB][1] = error_attrib;
-      choose[ERROR_ATTRIB][2] = error_attrib;
-      choose[ERROR_ATTRIB][3] = error_attrib;
+      /* generic attributes */
+      INIT_CHOOSERS( 16 );
+      INIT_CHOOSERS( 17 );
+      INIT_CHOOSERS( 18 );
+      INIT_CHOOSERS( 19 );
+      INIT_CHOOSERS( 20 );
+      INIT_CHOOSERS( 21 );
+      INIT_CHOOSERS( 22 );
+      INIT_CHOOSERS( 23 );
+      INIT_CHOOSERS( 24 );
+      INIT_CHOOSERS( 25 );
+      INIT_CHOOSERS( 26 );
+      INIT_CHOOSERS( 27 );
+      INIT_CHOOSERS( 28 );
+      INIT_CHOOSERS( 29 );
+      INIT_CHOOSERS( 30 );
+      INIT_CHOOSERS( 31 );
+
+      choose[_TNL_ATTRIB_ERROR][0] = error_attrib;
+      choose[_TNL_ATTRIB_ERROR][1] = error_attrib;
+      choose[_TNL_ATTRIB_ERROR][2] = error_attrib;
+      choose[_TNL_ATTRIB_ERROR][3] = error_attrib;
 
 #ifdef USE_X86_ASM
       if (tnl->AllowCodegen) {
index 9818c08..53f57a1 100644 (file)
@@ -37,9 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "t_context.h"
 
-#define ERROR_ATTRIB 16
-
-
 
 /* t_vtx_api.c:
  */
index d59ce90..bfae296 100644 (file)
@@ -96,6 +96,7 @@ static void attrib_##ATTR##_##N( const GLfloat *v )   \
    ATTRFV( ATTRIB, 3 )                         \
    ATTRFV( ATTRIB, 4 )                 
 
+/* conventional attribs */
 ATTRS( 0 )
 ATTRS( 1 )
 ATTRS( 2 )
@@ -113,8 +114,28 @@ ATTRS( 13 )
 ATTRS( 14 )
 ATTRS( 15 )
 
+/* generic attribs */
+ATTRS( 16 )
+ATTRS( 17 )
+ATTRS( 18 )
+ATTRS( 19 )
+ATTRS( 20 )
+ATTRS( 21 )
+ATTRS( 22 )
+ATTRS( 23 )
+ATTRS( 24 )
+ATTRS( 25 )
+ATTRS( 26 )
+ATTRS( 27 )
+ATTRS( 28 )
+ATTRS( 29 )
+ATTRS( 30 )
+ATTRS( 31 )
+
+
 void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] )
 {
+   /* conventional attribs */
    INIT( tab, 0 );
    INIT( tab, 1 );
    INIT( tab, 2 );
@@ -131,6 +152,24 @@ void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] )
    INIT( tab, 13 );
    INIT( tab, 14 );
    INIT( tab, 15 );
+
+   /* generic attribs */
+   INIT( tab, 16 );
+   INIT( tab, 17 );
+   INIT( tab, 18 );
+   INIT( tab, 19 );
+   INIT( tab, 20 );
+   INIT( tab, 21 );
+   INIT( tab, 22 );
+   INIT( tab, 23 );
+   INIT( tab, 24 );
+   INIT( tab, 25 );
+   INIT( tab, 26 );
+   INIT( tab, 27 );
+   INIT( tab, 28 );
+   INIT( tab, 29 );
+   INIT( tab, 30 );
+   INIT( tab, 31 );
 }
 
 /* These can be made efficient with codegen.  Further, by adding more
@@ -311,22 +350,19 @@ static void GLAPIENTRY _tnl_MultiTexCoord1f( GLenum target, GLfloat x  )
    DISPATCH_ATTR1F( attr, x );
 }
 
-static void GLAPIENTRY _tnl_MultiTexCoord1fv( GLenum target,
-                                             const GLfloat *v )
+static void GLAPIENTRY _tnl_MultiTexCoord1fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
    DISPATCH_ATTR1FV( attr, v );
 }
 
-static void GLAPIENTRY _tnl_MultiTexCoord2f( GLenum target, GLfloat x, 
-                                            GLfloat y )
+static void GLAPIENTRY _tnl_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
 {
    GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
    DISPATCH_ATTR2F( attr, x, y );
 }
 
-static void GLAPIENTRY _tnl_MultiTexCoord2fv( GLenum target, 
-                                             const GLfloat *v )
+static void GLAPIENTRY _tnl_MultiTexCoord2fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
    DISPATCH_ATTR2FV( attr, v );
@@ -339,8 +375,7 @@ static void GLAPIENTRY _tnl_MultiTexCoord3f( GLenum target, GLfloat x,
    DISPATCH_ATTR3F( attr, x, y, z );
 }
 
-static void GLAPIENTRY _tnl_MultiTexCoord3fv( GLenum target, 
-                                             const GLfloat *v )
+static void GLAPIENTRY _tnl_MultiTexCoord3fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
    DISPATCH_ATTR3FV( attr, v );
@@ -354,52 +389,59 @@ static void GLAPIENTRY _tnl_MultiTexCoord4f( GLenum target, GLfloat x,
    DISPATCH_ATTR4F( attr, x, y, z, w );
 }
 
-static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target, 
-                                             const GLfloat *v )
+static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v )
 {
    GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
    DISPATCH_ATTR4FV( attr, v );
 }
 
 
+/**
+ * GL_NV_vertex_program Vertex Attributes
+ * Note that these attributes DO alias the conventional attributes.
+ * Also, calling glVertexAttribNV(0, xxx) is equivalent to glVertex(xxx).
+ */
+
 static void GLAPIENTRY _tnl_VertexAttrib1fNV( GLuint index, GLfloat x )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR1F( index, x );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib1fvNV( GLuint index, 
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR1FV( index, v );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib2fNV( GLuint index, GLfloat x, 
-                                             GLfloat y )
+static void GLAPIENTRY _tnl_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR2F( index, x, y );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib2fvNV( GLuint index,
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR2FV( index, v );
 }
 
 static void GLAPIENTRY _tnl_VertexAttrib3fNV( GLuint index, GLfloat x,
                                              GLfloat y, GLfloat z )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR3F( index, x, y, z );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib3fvNV( GLuint index,
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR3FV( index, v );
 }
 
@@ -407,32 +449,40 @@ static void GLAPIENTRY _tnl_VertexAttrib4fNV( GLuint index, GLfloat x,
                                              GLfloat y, GLfloat z,
                                              GLfloat w )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR4F( index, x, y, z, w );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib4fvNV( GLuint index, 
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
 {
-   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) index = ERROR_ATTRIB;
+   if (index >= MAX_VERTEX_PROGRAM_ATTRIBS)
+      index = _TNL_ATTRIB_ERROR;
    DISPATCH_ATTR4FV( index, v );
 }
 
+
+
+/**
+ * GL_ARB_vertex_program Vertex Attributes
+ * Note that these attributes do NOT alias the conventional attributes.
+ * Also, calling glVertexAttribARB(0, xxx) is equivalent to glVertex(xxx).
+ */
+
 static void GLAPIENTRY _tnl_VertexAttrib1fARB( GLuint index, GLfloat x )
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR1F( index, x );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib1fvARB( GLuint index, 
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib1fvARB(GLuint index, const GLfloat *v)
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR1FV( index, v );
 }
@@ -441,59 +491,55 @@ static void GLAPIENTRY _tnl_VertexAttrib2fARB( GLuint index, GLfloat x,
                                              GLfloat y )
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR2F( index, x, y );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib2fvARB( GLuint index,
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib2fvARB(GLuint index, const GLfloat *v)
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR2FV( index, v );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib3fARB( GLuint index, GLfloat x,
-                                             GLfloat y, GLfloat z )
+static void GLAPIENTRY _tnl_VertexAttrib3fARB(GLuint index, GLfloat x,
+                                             GLfloat y, GLfloat z)
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR3F( index, x, y, z );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib3fvARB( GLuint index,
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib3fvARB(GLuint index, const GLfloat *v)
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR3FV( index, v );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib4fARB( GLuint index, GLfloat x,
-                                             GLfloat y, GLfloat z,
-                                             GLfloat w )
+static void GLAPIENTRY _tnl_VertexAttrib4fARB(GLuint index, GLfloat x,
+                                             GLfloat y, GLfloat z, GLfloat w)
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR4F( index, x, y, z, w );
 }
 
-static void GLAPIENTRY _tnl_VertexAttrib4fvARB( GLuint index, 
-                                              const GLfloat *v )
+static void GLAPIENTRY _tnl_VertexAttrib4fvARB(GLuint index, const GLfloat *v)
 {
    if (index >= MAX_VERTEX_ATTRIBS)
-      index = ERROR_ATTRIB;
-   else
+      index = _TNL_ATTRIB_ERROR;
+   else if (index > 0)
       index += VERT_ATTRIB_GENERIC0;
    DISPATCH_ATTR4FV( index, v );
 }