[Mesa-dev] [PATCH 08/10] mesa: Use VERT_ATTRIB_* indexed array in gl_array_object

Brian Paul brianp at vmware.com
Wed Nov 23 08:24:23 PST 2011


On 11/11/2011 10:10 AM, Mathias Fröhlich wrote:
>
> Replace the distinct struct gl_client_array members in gl_array_object by
> an array of gl_client_arrays indexed by VERT_ATTRIB_*.
> Renumber the vertex attributes slightly to keep the old semantics of the
> distinct array members. Make use of the upper 32 bits in VERT_BIT_*.
> Update all occurances of the distinct struct members with the array
> aequivalents.

equivalents.

A few other things below.


> ---
>   src/mesa/main/api_arrayelt.c  |   38 ++++++++--------
>   src/mesa/main/api_validate.c  |    6 +-
>   src/mesa/main/arrayobj.c      |   94 ++++++++++++++++-----------------------
>   src/mesa/main/attrib.c        |   13 -----
>   src/mesa/main/bufferobj.c     |   11 -----
>   src/mesa/main/enable.c        |   44 +++++++++---------
>   src/mesa/main/get.c           |   98 ++++++++++++++++++++--------------------
>   src/mesa/main/getstring.c     |   18 ++++----
>   src/mesa/main/mtypes.h        |   65 ++++++++++-----------------
>   src/mesa/main/nvprogram.c     |    8 ++--
>   src/mesa/main/state.c         |   78 ++++++++++++++++----------------
>   src/mesa/main/varray.c        |   98
> ++++++++++++++++++-----------------------
>   src/mesa/vbo/vbo_attrib.h     |   59 ++++++++++++------------
>   src/mesa/vbo/vbo_exec_array.c |   41 ++---------------
>   14 files changed, 285 insertions(+), 386 deletions(-)
>
> diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
> index b93a057..829f97b 100644
> --- a/src/mesa/main/api_arrayelt.c
> +++ b/src/mesa/main/api_arrayelt.c
> @@ -1474,44 +1474,44 @@ static void _ae_update_state( struct gl_context *ctx )
>      actx->nr_vbos = 0;
>
>      /* conventional vertex arrays */
> -   if (arrayObj->Index.Enabled) {
> -      aa->array =&arrayObj->Index;
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX];
>         aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
>         check_vbo(actx, aa->array->BufferObj);
>         aa++;
>      }
> -   if (arrayObj->EdgeFlag.Enabled) {
> -      aa->array =&arrayObj->EdgeFlag;
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG];
>         aa->offset = _gloffset_EdgeFlagv;
>         check_vbo(actx, aa->array->BufferObj);
>         aa++;
>      }
> -   if (arrayObj->Normal.Enabled) {
> -      aa->array =&arrayObj->Normal;
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL];
>         aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
>         check_vbo(actx, aa->array->BufferObj);
>         aa++;
>      }
> -   if (arrayObj->Color.Enabled) {
> -      aa->array =&arrayObj->Color;
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0];
>         aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
>         check_vbo(actx, aa->array->BufferObj);
>         aa++;
>      }
> -   if (arrayObj->SecondaryColor.Enabled) {
> -      aa->array =&arrayObj->SecondaryColor;
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1];
>         aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
>         check_vbo(actx, aa->array->BufferObj);
>         aa++;
>      }
> -   if (arrayObj->FogCoord.Enabled) {
> -      aa->array =&arrayObj->FogCoord;
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_FOG];
>         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 =&arrayObj->TexCoord[i];
> +      struct gl_client_array *attribArray =&arrayObj-
>> VertexAttrib[VERT_ATTRIB_TEX(i)];
>         if (attribArray->Enabled) {
>            /* NOTE: we use generic glVertexAttribNV functions here.
>             * If we ever remove GL_NV_vertex_program this will have to change.
> @@ -1528,8 +1528,8 @@ static void _ae_update_state( struct gl_context *ctx )
>      }
>
>      /* generic vertex attribute arrays */
> -   for (i = 1; i<  Elements(arrayObj->VertexAttrib); i++) {  /* skip zero! */
> -      struct gl_client_array *attribArray =&arrayObj->VertexAttrib[i];
> +   for (i = 1; i<  VERT_ATTRIB_GENERIC_MAX; i++) {  /* skip zero! */
> +      struct gl_client_array *attribArray =&arrayObj-
>> VertexAttrib[VERT_ATTRIB_GENERIC(i)];
>         if (attribArray->Enabled) {
>            at->array = attribArray;
>            /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
> @@ -1563,18 +1563,18 @@ static void _ae_update_state( struct gl_context *ctx )
>      }
>
>      /* finally, vertex position */
> -   if (arrayObj->VertexAttrib[0].Enabled) {
> +   if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
>         /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
>          * issued as the last (provoking) attribute).
>          */
> -      aa->array =&arrayObj->VertexAttrib[0];
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0];
>         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 (arrayObj->Vertex.Enabled) {
> -      aa->array =&arrayObj->Vertex;
> +   else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
> +      aa->array =&arrayObj->VertexAttrib[VERT_ATTRIB_POS];
>         aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
>         check_vbo(actx, aa->array->BufferObj);
>         aa++;
> diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
> index 1fcf5cd..ff2d334 100644
> --- a/src/mesa/main/api_validate.c
> +++ b/src/mesa/main/api_validate.c
> @@ -120,7 +120,7 @@ check_valid_to_render(struct gl_context *ctx, const char
> *function)
>      case API_OPENGLES:
>         /* For OpenGL ES, only draw if we have vertex positions
>          */
> -      if (!ctx->Array.ArrayObj->Vertex.Enabled)
> +      if (!ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled)
>   	 return GL_FALSE;
>         break;
>   #endif
> @@ -142,8 +142,8 @@ check_valid_to_render(struct gl_context *ctx, const char
> *function)
>               /* Draw if we have vertex positions (GL_VERTEX_ARRAY or generic
>                * array [0]).
>                */
> -            return (ctx->Array.ArrayObj->Vertex.Enabled ||
> -                    ctx->Array.ArrayObj->VertexAttrib[0].Enabled);
> +            return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_POS].Enabled ||
> +                    ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled);
>            }
>         }
>         break;
> diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
> index 5524f1f..933466d 100644
> --- a/src/mesa/main/arrayobj.c
> +++ b/src/mesa/main/arrayobj.c
> @@ -85,24 +85,8 @@ unbind_array_object_vbos(struct gl_context *ctx, struct
> gl_array_object *obj)
>   {
>      GLuint i;
>
> -   _mesa_reference_buffer_object(ctx,&obj->Vertex.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->Weight.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->Normal.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->Color.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->SecondaryColor.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->FogCoord.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->Index.BufferObj, NULL);
> -   _mesa_reference_buffer_object(ctx,&obj->EdgeFlag.BufferObj, NULL);
> -
> -   for (i = 0; i<  Elements(obj->TexCoord); i++)
> -      _mesa_reference_buffer_object(ctx,&obj->TexCoord[i].BufferObj, NULL);
> -
>      for (i = 0; i<  Elements(obj->VertexAttrib); i++)
> -      _mesa_reference_buffer_object(ctx,&obj->VertexAttrib[i].BufferObj,NULL);
> -
> -#if FEATURE_point_size_array
> -   _mesa_reference_buffer_object(ctx,&obj->PointSize.BufferObj, NULL);
> -#endif
> +      _mesa_reference_buffer_object(ctx,&obj->VertexAttrib[i].BufferObj,
> NULL);
>   }
>
>
> @@ -234,24 +218,36 @@ _mesa_initialize_array_object( struct gl_context *ctx,
>      obj->RefCount = 1;
>
>      /* Init the individual arrays */
> -   init_array(ctx,&obj->Vertex, 4, GL_FLOAT);
> -   init_array(ctx,&obj->Weight, 1, GL_FLOAT);
> -   init_array(ctx,&obj->Normal, 3, GL_FLOAT);
> -   init_array(ctx,&obj->Color, 4, GL_FLOAT);
> -   init_array(ctx,&obj->SecondaryColor, 3, GL_FLOAT);
> -   init_array(ctx,&obj->FogCoord, 1, GL_FLOAT);
> -   init_array(ctx,&obj->Index, 1, GL_FLOAT);
> -   for (i = 0; i<  Elements(obj->TexCoord); i++) {
> -      init_array(ctx,&obj->TexCoord[i], 4, GL_FLOAT);
> -   }
> -   init_array(ctx,&obj->EdgeFlag, 1, GL_BOOL);
>      for (i = 0; i<  Elements(obj->VertexAttrib); i++) {
> -      init_array(ctx,&obj->VertexAttrib[i], 4, GL_FLOAT);
> -   }
> -
> +      switch (i) {
> +      case VERT_ATTRIB_WEIGHT:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_WEIGHT], 1,
> GL_FLOAT);
> +         break;
> +      case VERT_ATTRIB_NORMAL:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_NORMAL], 3,
> GL_FLOAT);
> +         break;
> +      case VERT_ATTRIB_COLOR1:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_COLOR1], 3,
> GL_FLOAT);
> +         break;
> +      case VERT_ATTRIB_FOG:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_FOG], 1, GL_FLOAT);
> +         break;
> +      case VERT_ATTRIB_COLOR_INDEX:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX], 1,
> GL_FLOAT);
> +         break;
> +      case VERT_ATTRIB_EDGEFLAG:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_EDGEFLAG], 1,
> GL_BOOL);
> +         break;
>   #if FEATURE_point_size_array
> -   init_array(ctx,&obj->PointSize, 1, GL_FLOAT);
> +      case VERT_ATTRIB_POINT_SIZE:
> +         init_array(ctx,&obj->VertexAttrib[VERT_ATTRIB_POINT_SIZE], 1,
> GL_FLOAT);
> +         break;
>   #endif
> +      default:
> +         init_array(ctx,&obj->VertexAttrib[i], 4, GL_FLOAT);
> +         break;
> +      }
> +   }
>   }
>
>
> @@ -290,12 +286,9 @@ remove_array_object( struct gl_context *ctx, struct
> gl_array_object *obj )
>   static GLuint
>   update_min(GLuint min, struct gl_client_array *array)
>   {
> -   if (array->Enabled) {
> -      _mesa_update_array_max_element(array);
> -      return MIN2(min, array->_MaxElement);
> -   }
> -   else
> -      return min;
> +   assert(array->Enabled);
> +   _mesa_update_array_max_element(array);
> +   return MIN2(min, array->_MaxElement);
>   }
>
>
> @@ -306,23 +299,14 @@ void
>   _mesa_update_array_object_max_element(struct gl_context *ctx,
>                                         struct gl_array_object *arrayObj)
>   {
> -   GLuint i, min = ~0;
> -
> -   min = update_min(min,&arrayObj->Vertex);
> -   min = update_min(min,&arrayObj->Weight);
> -   min = update_min(min,&arrayObj->Normal);
> -   min = update_min(min,&arrayObj->Color);
> -   min = update_min(min,&arrayObj->SecondaryColor);
> -   min = update_min(min,&arrayObj->FogCoord);
> -   min = update_min(min,&arrayObj->Index);
> -   min = update_min(min,&arrayObj->EdgeFlag);
> -#if FEATURE_point_size_array
> -   min = update_min(min,&arrayObj->PointSize);
> -#endif
> -   for (i = 0; i<  ctx->Const.MaxTextureCoordUnits; i++)
> -      min = update_min(min,&arrayObj->TexCoord[i]);
> -   for (i = 0; i<  Elements(arrayObj->VertexAttrib); i++)
> -      min = update_min(min,&arrayObj->VertexAttrib[i]);
> +   GLbitfield64 enabled = arrayObj->_Enabled;
> +   GLuint min = ~0u;
> +
> +   while (enabled) {
> +      GLint attrib = _mesa_ffsll(enabled) - 1;
> +      enabled&= ~BITFIELD64_BIT(attrib);
> +      min = update_min(min,&arrayObj->VertexAttrib[attrib]);
> +   }
>
>      /* _MaxElement is one past the last legal array element */
>      arrayObj->_MaxElement = min;
> diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
> index f368eec..8418d27 100644
> --- a/src/mesa/main/attrib.c
> +++ b/src/mesa/main/attrib.c
> @@ -1322,19 +1322,6 @@ copy_array_object(struct gl_context *ctx,
>      /* In theory must be the same anyway, but on recreate make sure it matches
> */
>      dest->VBOonly = src->VBOonly;
>
> -   _mesa_copy_client_array(ctx,&dest->Vertex,&src->Vertex);
> -   _mesa_copy_client_array(ctx,&dest->Weight,&src->Weight);
> -   _mesa_copy_client_array(ctx,&dest->Normal,&src->Normal);
> -   _mesa_copy_client_array(ctx,&dest->Color,&src->Color);
> -   _mesa_copy_client_array(ctx,&dest->SecondaryColor,&src->SecondaryColor);
> -   _mesa_copy_client_array(ctx,&dest->FogCoord,&src->FogCoord);
> -   _mesa_copy_client_array(ctx,&dest->Index,&src->Index);
> -   _mesa_copy_client_array(ctx,&dest->EdgeFlag,&src->EdgeFlag);
> -#if FEATURE_point_size_array
> -   _mesa_copy_client_array(ctx,&dest->PointSize,&src->PointSize);
> -#endif
> -   for (i = 0; i<  Elements(src->TexCoord); i++)
> -      _mesa_copy_client_array(ctx,&dest->TexCoord[i],&src->TexCoord[i]);
>      for (i = 0; i<  Elements(src->VertexAttrib); i++)
>         _mesa_copy_client_array(ctx,&dest->VertexAttrib[i],&src-
>> VertexAttrib[i]);
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 4c77397..d977d57 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -741,17 +741,6 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
>            }
>
>            /* unbind any vertex pointers bound to this buffer */
> -         unbind(ctx,&arrayObj->Vertex.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->Weight.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->Normal.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->Color.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->SecondaryColor.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->FogCoord.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->Index.BufferObj, bufObj);
> -         unbind(ctx,&arrayObj->EdgeFlag.BufferObj, bufObj);
> -         for (j = 0; j<  Elements(arrayObj->TexCoord); j++) {
> -            unbind(ctx,&arrayObj->TexCoord[j].BufferObj, bufObj);
> -         }
>            for (j = 0; j<  Elements(arrayObj->VertexAttrib); j++) {
>               unbind(ctx,&arrayObj->VertexAttrib[j].BufferObj, bufObj);
>            }
> diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
> index f45589f..6461ac1 100644
> --- a/src/mesa/main/enable.c
> +++ b/src/mesa/main/enable.c
> @@ -59,41 +59,41 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean
> state)
>
>      switch (cap) {
>         case GL_VERTEX_ARRAY:
> -         var =&arrayObj->Vertex.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled;
>            flag = VERT_BIT_POS;
>            break;
>         case GL_NORMAL_ARRAY:
> -         var =&arrayObj->Normal.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
>            flag = VERT_BIT_NORMAL;
>            break;
>         case GL_COLOR_ARRAY:
> -         var =&arrayObj->Color.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
>            flag = VERT_BIT_COLOR0;
>            break;
>         case GL_INDEX_ARRAY:
> -         var =&arrayObj->Index.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
>            flag = VERT_BIT_COLOR_INDEX;
>            break;
>         case GL_TEXTURE_COORD_ARRAY:
> -         var =&arrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx-
>> Array.ActiveTexture)].Enabled;
>            flag = VERT_BIT_TEX(ctx->Array.ActiveTexture);
>            break;
>         case GL_EDGE_FLAG_ARRAY:
> -         var =&arrayObj->EdgeFlag.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
>            flag = VERT_BIT_EDGEFLAG;
>            break;
>         case GL_FOG_COORDINATE_ARRAY_EXT:
> -         var =&arrayObj->FogCoord.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
>            flag = VERT_BIT_FOG;
>            break;
>         case GL_SECONDARY_COLOR_ARRAY_EXT:
> -         var =&arrayObj->SecondaryColor.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
>            flag = VERT_BIT_COLOR1;
>            break;
>
>   #if FEATURE_point_size_array
>         case GL_POINT_SIZE_ARRAY_OES:
> -         var =&arrayObj->PointSize.Enabled;
> +         var =&arrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
>            flag = VERT_BIT_POINT_SIZE;
>            break;
>   #endif

I think there's a few places where we need to map GLenums for vertex 
arrays to VERT_ATTRIB_x values.  Maybe there should be a helper 
function for that:

gl_vert_attrib
array_enum_to_vert_attrib(GLenum vertexArray)
{
    switch (vertexArray) {
    case GL_VERTEX_ARRAY:
       return VERT_ATTRIB_POS;
    case GL_VERTEX_COLOR:
       return VERT_ATTRIB_COLOR0;
    ...
}

Then the code for all those switch cases could be collapsed together.


> @@ -118,8 +118,8 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean
> state)
>            CHECK_EXTENSION(NV_vertex_program, cap);
>            {
>               GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
> -            ASSERT(n<  Elements(ctx->Array.ArrayObj->VertexAttrib));
> -            var =&arrayObj->VertexAttrib[n].Enabled;
> +            ASSERT(VERT_ATTRIB_GENERIC(n)<  Elements(ctx->Array.ArrayObj-
>> VertexAttrib));
> +            var =&arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled;
>               flag = VERT_BIT_GENERIC(n);
>            }
>            break;
> @@ -1226,27 +1226,27 @@ _mesa_IsEnabled( GLenum cap )
>
>         /* client-side state */
>         case GL_VERTEX_ARRAY:
> -         return (ctx->Array.ArrayObj->Vertex.Enabled != 0);
> +         return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled
> != 0);
>         case GL_NORMAL_ARRAY:
> -         return (ctx->Array.ArrayObj->Normal.Enabled != 0);
> +         return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_NORMAL].Enabled != 0);
>         case GL_COLOR_ARRAY:
> -         return (ctx->Array.ArrayObj->Color.Enabled != 0);
> +         return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_COLOR0].Enabled != 0);
>         case GL_INDEX_ARRAY:
> -         return (ctx->Array.ArrayObj->Index.Enabled != 0);
> +         return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0);
>         case GL_TEXTURE_COORD_ARRAY:
> -         return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture]
> +         return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx-
>> Array.ActiveTexture)]
>                    .Enabled != 0);
>         case GL_EDGE_FLAG_ARRAY:
> -         return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0);
> +         return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0);
>         case GL_FOG_COORDINATE_ARRAY_EXT:
>            CHECK_EXTENSION(EXT_fog_coord);
> -         return (ctx->Array.ArrayObj->FogCoord.Enabled != 0);
> +         return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled
> != 0);
>         case GL_SECONDARY_COLOR_ARRAY_EXT:
>            CHECK_EXTENSION(EXT_secondary_color);
> -         return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0);
> +         return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_COLOR1].Enabled != 0);
>   #if FEATURE_point_size_array
>         case GL_POINT_SIZE_ARRAY_OES:
> -         return (ctx->Array.ArrayObj->PointSize.Enabled != 0);
> +         return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled != 0);
>   #endif
>
>         /* GL_ARB_texture_cube_map */
> @@ -1312,8 +1312,8 @@ _mesa_IsEnabled( GLenum cap )
>            CHECK_EXTENSION(NV_vertex_program);
>            {
>               GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
> -            ASSERT(n<  Elements(ctx->Array.ArrayObj->VertexAttrib));
> -            return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
> +            ASSERT(VERT_ATTRIB_GENERIC(n)<  Elements(ctx->Array.ArrayObj-
>> VertexAttrib));
> +            return (ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_GENERIC(n)].Enabled != 0);
>            }
>         case GL_MAP1_VERTEX_ATTRIB0_4_NV:
>         case GL_MAP1_VERTEX_ATTRIB1_4_NV:
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index d8a0638..551955c 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -589,17 +589,17 @@ static const struct value_desc values[] = {
>      { GL_TEXTURE_STACK_DEPTH, LOC_CUSTOM, TYPE_INT, 0,
>        extra_valid_texture_unit  },
>
> -   { GL_VERTEX_ARRAY, ARRAY_BOOL(Vertex.Enabled), NO_EXTRA },
> -   { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(Vertex.Size), NO_EXTRA },
> -   { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(Vertex.Type), NO_EXTRA },
> -   { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(Vertex.Stride), NO_EXTRA },
> -   { GL_NORMAL_ARRAY, ARRAY_BOOL(Normal.Enabled), NO_EXTRA },
> -   { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(Normal.Type), NO_EXTRA },
> -   { GL_NORMAL_ARRAY_STRIDE, ARRAY_INT(Normal.Stride), NO_EXTRA },
> -   { GL_COLOR_ARRAY, ARRAY_BOOL(Color.Enabled), NO_EXTRA },
> -   { GL_COLOR_ARRAY_SIZE, ARRAY_INT(Color.Size), NO_EXTRA },
> -   { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(Color.Type), NO_EXTRA },
> -   { GL_COLOR_ARRAY_STRIDE, ARRAY_INT(Color.Stride), NO_EXTRA },
> +   { GL_VERTEX_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_POS].Enabled),
> NO_EXTRA },
> +   { GL_VERTEX_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Size),
> NO_EXTRA },
> +   { GL_VERTEX_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_POS].Type),
> NO_EXTRA },
> +   { GL_VERTEX_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_POS].Stride),
> NO_EXTRA },
> +   { GL_NORMAL_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_NORMAL].Enabled),
> NO_EXTRA },
> +   { GL_NORMAL_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_NORMAL].Type),
> NO_EXTRA },
> +   { GL_NORMAL_ARRAY_STRIDE,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_NORMAL].Stride), NO_EXTRA },
> +   { GL_COLOR_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR0].Enabled),
> NO_EXTRA },
> +   { GL_COLOR_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Size),
> NO_EXTRA },
> +   { GL_COLOR_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR0].Type),
> NO_EXTRA },
> +   { GL_COLOR_ARRAY_STRIDE,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Stride), NO_EXTRA },
>      { GL_TEXTURE_COORD_ARRAY,
>        LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled),
> NO_EXTRA },
>      { GL_TEXTURE_COORD_ARRAY_SIZE,
> @@ -634,11 +634,11 @@ static const struct value_desc values[] = {
>
>      /* GL_ARB_vertex_buffer_object */
>      { GL_VERTEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, Vertex.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_POS].BufferObj),
> NO_EXTRA },
>      { GL_NORMAL_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, Normal.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object,
> VertexAttrib[VERT_ATTRIB_NORMAL].BufferObj), NO_EXTRA },
>      { GL_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, Color.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object,
> VertexAttrib[VERT_ATTRIB_COLOR0].BufferObj), NO_EXTRA },
>      { GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> NO_OFFSET, NO_EXTRA },
>
>      /* GL_OES_point_sprite */
> @@ -927,13 +927,13 @@ static const struct value_desc values[] = {
>      { GL_VERTEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
>      { GL_NORMAL_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
>      { GL_COLOR_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
> -   { GL_INDEX_ARRAY, ARRAY_BOOL(Index.Enabled), NO_EXTRA },
> -   { GL_INDEX_ARRAY_TYPE, ARRAY_ENUM(Index.Type), NO_EXTRA },
> -   { GL_INDEX_ARRAY_STRIDE, ARRAY_INT(Index.Stride), NO_EXTRA },
> +   { GL_INDEX_ARRAY,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled), NO_EXTRA },
> +   { GL_INDEX_ARRAY_TYPE,
> ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Type), NO_EXTRA },
> +   { GL_INDEX_ARRAY_STRIDE,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Stride), NO_EXTRA },
>      { GL_INDEX_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
>      { GL_TEXTURE_COORD_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
> -   { GL_EDGE_FLAG_ARRAY, ARRAY_BOOL(EdgeFlag.Enabled), NO_EXTRA },
> -   { GL_EDGE_FLAG_ARRAY_STRIDE, ARRAY_INT(EdgeFlag.Stride), NO_EXTRA },
> +   { GL_EDGE_FLAG_ARRAY,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled), NO_EXTRA },
> +   { GL_EDGE_FLAG_ARRAY_STRIDE,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_EDGEFLAG].Stride), NO_EXTRA },
>      { GL_EDGE_FLAG_ARRAY_COUNT_EXT, CONST(0), NO_EXTRA },
>
>      /* GL_ARB_texture_compression */
> @@ -958,24 +958,24 @@ static const struct value_desc values[] = {
>      { GL_CURRENT_SECONDARY_COLOR_EXT,
>        CONTEXT_FIELD(Current.Attrib[VERT_ATTRIB_COLOR1][0], TYPE_FLOATN_4),
>        extra_EXT_secondary_color_flush_current },
> -   { GL_SECONDARY_COLOR_ARRAY_EXT, ARRAY_BOOL(SecondaryColor.Enabled),
> +   { GL_SECONDARY_COLOR_ARRAY_EXT,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR1].Enabled),
>        extra_EXT_secondary_color },
> -   { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT, ARRAY_ENUM(SecondaryColor.Type),
> +   { GL_SECONDARY_COLOR_ARRAY_TYPE_EXT,
> ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR1].Type),
>        extra_EXT_secondary_color },
> -   { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT, ARRAY_INT(SecondaryColor.Stride),
> +   { GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Stride),
>        extra_EXT_secondary_color },
> -   { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT, ARRAY_INT(SecondaryColor.Size),
> +   { GL_SECONDARY_COLOR_ARRAY_SIZE_EXT,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Size),
>        extra_EXT_secondary_color },
>
>      /* GL_EXT_fog_coord */
>      { GL_CURRENT_FOG_COORDINATE_EXT,
>        CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]),
>        extra_EXT_fog_coord_flush_current },
> -   { GL_FOG_COORDINATE_ARRAY_EXT, ARRAY_BOOL(FogCoord.Enabled),
> +   { GL_FOG_COORDINATE_ARRAY_EXT,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_FOG].Enabled),
>        extra_EXT_fog_coord },
> -   { GL_FOG_COORDINATE_ARRAY_TYPE_EXT, ARRAY_ENUM(FogCoord.Type),
> +   { GL_FOG_COORDINATE_ARRAY_TYPE_EXT,
> ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_FOG].Type),
>        extra_EXT_fog_coord },
> -   { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT, ARRAY_INT(FogCoord.Stride),
> +   { GL_FOG_COORDINATE_ARRAY_STRIDE_EXT,
> ARRAY_INT(VertexAttrib[VERT_ATTRIB_FOG].Stride),
>        extra_EXT_fog_coord },
>      { GL_FOG_COORDINATE_SOURCE_EXT, CONTEXT_ENUM(Fog.FogCoordinateSource),
>        extra_EXT_fog_coord },
> @@ -998,37 +998,37 @@ static const struct value_desc values[] = {
>      /* GL_NV_vertex_program */
>      { GL_VERTEX_PROGRAM_BINDING_NV, LOC_CUSTOM, TYPE_INT, 0,
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY0_NV, ARRAY_BOOL(VertexAttrib[0].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY0_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(0)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY1_NV, ARRAY_BOOL(VertexAttrib[1].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY1_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(1)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY2_NV, ARRAY_BOOL(VertexAttrib[2].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY2_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(2)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY3_NV, ARRAY_BOOL(VertexAttrib[3].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY3_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(3)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY4_NV, ARRAY_BOOL(VertexAttrib[4].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY4_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(4)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY5_NV, ARRAY_BOOL(VertexAttrib[5].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY5_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(5)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY6_NV, ARRAY_BOOL(VertexAttrib[6].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY6_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(6)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY7_NV, ARRAY_BOOL(VertexAttrib[7].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY7_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(7)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY8_NV, ARRAY_BOOL(VertexAttrib[8].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY8_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(8)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY9_NV, ARRAY_BOOL(VertexAttrib[9].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY9_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(9)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY10_NV, ARRAY_BOOL(VertexAttrib[10].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY10_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(10)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY11_NV, ARRAY_BOOL(VertexAttrib[11].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY11_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(11)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY12_NV, ARRAY_BOOL(VertexAttrib[12].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY12_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(12)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY13_NV, ARRAY_BOOL(VertexAttrib[13].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY13_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(13)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY14_NV, ARRAY_BOOL(VertexAttrib[14].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY14_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(14)].Enabled),
>        extra_NV_vertex_program },
> -   { GL_VERTEX_ATTRIB_ARRAY15_NV, ARRAY_BOOL(VertexAttrib[15].Enabled),
> +   { GL_VERTEX_ATTRIB_ARRAY15_NV,
> ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_GENERIC(15)].Enabled),
>        extra_NV_vertex_program },
>      { GL_MAP1_VERTEX_ATTRIB0_4_NV, CONTEXT_BOOL(Eval.Map1Attrib[0]),
>        extra_NV_vertex_program },
> @@ -1099,13 +1099,13 @@ static const struct value_desc values[] = {
>
>      /* GL_ARB_vertex_buffer_object */
>      { GL_INDEX_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, Index.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object,
> VertexAttrib[VERT_ATTRIB_COLOR_INDEX].BufferObj), NO_EXTRA },
>      { GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, EdgeFlag.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object,
> VertexAttrib[VERT_ATTRIB_EDGEFLAG].BufferObj), NO_EXTRA },
>      { GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, SecondaryColor.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object,
> VertexAttrib[VERT_ATTRIB_COLOR1].BufferObj), NO_EXTRA },
>      { GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB, LOC_CUSTOM, TYPE_INT,
> -     offsetof(struct gl_array_object, FogCoord.BufferObj), NO_EXTRA },
> +     offsetof(struct gl_array_object, VertexAttrib[VERT_ATTRIB_FOG].BufferObj),
> NO_EXTRA },
>
>      /* GL_EXT_pixel_buffer_object */
>      { GL_PIXEL_PACK_BUFFER_BINDING_EXT, LOC_CUSTOM, TYPE_INT, 0,
> @@ -1487,7 +1487,7 @@ find_custom_value(struct gl_context *ctx, const struct
> value_desc *d, union valu
>      case GL_TEXTURE_COORD_ARRAY_SIZE:
>      case GL_TEXTURE_COORD_ARRAY_TYPE:
>      case GL_TEXTURE_COORD_ARRAY_STRIDE:
> -      array =&ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture];
> +      array =&ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx-
>> Array.ActiveTexture)];
>         v->value_int = *(GLuint *) ((char *) array + d->offset);
>         break;
>
> @@ -1627,7 +1627,7 @@ find_custom_value(struct gl_context *ctx, const struct
> value_desc *d, union valu
>         break;
>      case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
>         v->value_int =
> -	 ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
> +	 ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx-
>> Array.ActiveTexture)].BufferObj->Name;
>         break;
>      case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
>         v->value_int = ctx->Array.ElementArrayBufferObj->Name;
> @@ -1679,7 +1679,7 @@ find_custom_value(struct gl_context *ctx, const struct
> value_desc *d, union valu
>   	 ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
>         break;
>      case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
> -      v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name;
> +      v->value_int = ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_POINT_SIZE].BufferObj->Name;
>         break;
>
>      case GL_FOG_COLOR:
> diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
> index c381fb2..dbf6c3f 100644
> --- a/src/mesa/main/getstring.c
> +++ b/src/mesa/main/getstring.c
> @@ -190,28 +190,28 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
>
>      switch (pname) {
>         case GL_VERTEX_ARRAY_POINTER:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_POS].Ptr;
>            break;
>         case GL_NORMAL_ARRAY_POINTER:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->Normal.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_NORMAL].Ptr;
>            break;
>         case GL_COLOR_ARRAY_POINTER:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->Color.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_COLOR0].Ptr;
>            break;
>         case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->SecondaryColor.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_COLOR1].Ptr;
>            break;
>         case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->FogCoord.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_FOG].Ptr;
>            break;
>         case GL_INDEX_ARRAY_POINTER:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->Index.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr;
>            break;
>         case GL_TEXTURE_COORD_ARRAY_POINTER:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->TexCoord[clientUnit].Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr;
>            break;
>         case GL_EDGE_FLAG_ARRAY_POINTER:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->EdgeFlag.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr;
>            break;
>         case GL_FEEDBACK_BUFFER_POINTER:
>            *params = ctx->Feedback.Buffer;
> @@ -221,7 +221,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params )
>            break;
>   #if FEATURE_point_size_array
>         case GL_POINT_SIZE_ARRAY_POINTER_OES:
> -         *params = (GLvoid *) ctx->Array.ArrayObj->PointSize.Ptr;
> +         *params = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_POINT_SIZE].Ptr;
>            break;
>   #endif
>         default:
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 84e09d8..49999be 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -122,7 +122,6 @@ typedef enum
>      VERT_ATTRIB_COLOR1 = 4,
>      VERT_ATTRIB_FOG = 5,
>      VERT_ATTRIB_COLOR_INDEX = 6,
> -   VERT_ATTRIB_POINT_SIZE = 6,  /*alias*/
>      VERT_ATTRIB_EDGEFLAG = 7,
>      VERT_ATTRIB_TEX0 = 8,
>      VERT_ATTRIB_TEX1 = 9,
> @@ -132,23 +131,24 @@ typedef enum
>      VERT_ATTRIB_TEX5 = 13,
>      VERT_ATTRIB_TEX6 = 14,
>      VERT_ATTRIB_TEX7 = 15,
> -   VERT_ATTRIB_GENERIC0 = 16,
> -   VERT_ATTRIB_GENERIC1 = 17,
> -   VERT_ATTRIB_GENERIC2 = 18,
> -   VERT_ATTRIB_GENERIC3 = 19,
> -   VERT_ATTRIB_GENERIC4 = 20,
> -   VERT_ATTRIB_GENERIC5 = 21,
> -   VERT_ATTRIB_GENERIC6 = 22,
> -   VERT_ATTRIB_GENERIC7 = 23,
> -   VERT_ATTRIB_GENERIC8 = 24,
> -   VERT_ATTRIB_GENERIC9 = 25,
> -   VERT_ATTRIB_GENERIC10 = 26,
> -   VERT_ATTRIB_GENERIC11 = 27,
> -   VERT_ATTRIB_GENERIC12 = 28,
> -   VERT_ATTRIB_GENERIC13 = 29,
> -   VERT_ATTRIB_GENERIC14 = 30,
> -   VERT_ATTRIB_GENERIC15 = 31,
> -   VERT_ATTRIB_MAX = 32
> +   VERT_ATTRIB_POINT_SIZE = 16,
> +   VERT_ATTRIB_GENERIC0 = 17,
> +   VERT_ATTRIB_GENERIC1 = 18,
> +   VERT_ATTRIB_GENERIC2 = 19,
> +   VERT_ATTRIB_GENERIC3 = 20,
> +   VERT_ATTRIB_GENERIC4 = 21,
> +   VERT_ATTRIB_GENERIC5 = 22,
> +   VERT_ATTRIB_GENERIC6 = 23,
> +   VERT_ATTRIB_GENERIC7 = 24,
> +   VERT_ATTRIB_GENERIC8 = 25,
> +   VERT_ATTRIB_GENERIC9 = 26,
> +   VERT_ATTRIB_GENERIC10 = 27,
> +   VERT_ATTRIB_GENERIC11 = 28,
> +   VERT_ATTRIB_GENERIC12 = 29,
> +   VERT_ATTRIB_GENERIC13 = 30,
> +   VERT_ATTRIB_GENERIC14 = 31,
> +   VERT_ATTRIB_GENERIC15 = 32,
> +   VERT_ATTRIB_MAX = 33
>   } gl_vert_attrib;
>
>   /**
> @@ -192,7 +192,6 @@ typedef enum
>   #define VERT_BIT_COLOR1          BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
>   #define VERT_BIT_FOG             BITFIELD64_BIT(VERT_ATTRIB_FOG)
>   #define VERT_BIT_COLOR_INDEX     BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
> -#define VERT_BIT_POINT_SIZE      BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
>   #define VERT_BIT_EDGEFLAG        BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
>   #define VERT_BIT_TEX0            BITFIELD64_BIT(VERT_ATTRIB_TEX0)
>   #define VERT_BIT_TEX1            BITFIELD64_BIT(VERT_ATTRIB_TEX1)
> @@ -202,13 +201,14 @@ typedef enum
>   #define VERT_BIT_TEX5            BITFIELD64_BIT(VERT_ATTRIB_TEX5)
>   #define VERT_BIT_TEX6            BITFIELD64_BIT(VERT_ATTRIB_TEX6)
>   #define VERT_BIT_TEX7            BITFIELD64_BIT(VERT_ATTRIB_TEX7)
> +#define VERT_BIT_POINT_SIZE      BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE)
>   #define VERT_BIT_GENERIC0        BITFIELD64_BIT(VERT_ATTRIB_GENERIC0)
>
>   #define VERT_BIT(i)              BITFIELD64_BIT(i)
> -#define VERT_BIT_ALL             ((GLbitfield64)0xffffffff)
> +#define VERT_BIT_ALL             ((GLbitfield64)0x1ffffffff)
>
>   #define VERT_BIT_FF(i)           VERT_BIT(i)
> -#define VERT_BIT_FF_ALL          ((GLbitfield64)0xffff)
> +#define VERT_BIT_FF_ALL          ((GLbitfield64)0x1ffff)
>   #define VERT_BIT_TEX(i)          VERT_BIT(VERT_ATTRIB_TEX(i))
>   #define VERT_BIT_TEX_ALL         ((GLbitfield64)0xff<<  VERT_ATTRIB_TEX(0))
>   #define VERT_BIT_GENERIC_NV(i)   VERT_BIT(VERT_ATTRIB_GENERIC_NV(i))
> @@ -1626,27 +1626,8 @@ struct gl_array_object
>      _glthread_Mutex Mutex;
>      GLboolean VBOonly;  /**<  require all arrays to live in VBOs? */
>
> -   /** Conventional vertex arrays */
> -   /*@{*/
> -   struct gl_client_array Vertex;
> -   struct gl_client_array Weight;
> -   struct gl_client_array Normal;
> -   struct gl_client_array Color;
> -   struct gl_client_array SecondaryColor;
> -   struct gl_client_array FogCoord;
> -   struct gl_client_array Index;
> -   struct gl_client_array EdgeFlag;
> -   struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
> -   struct gl_client_array PointSize;
> -   /*@}*/
> -
> -   /**
> -    * Generic arrays for vertex programs/shaders.
> -    * For NV vertex programs, these attributes alias and take priority
> -    * over the conventional attribs above.  For ARB vertex programs and
> -    * GLSL vertex shaders, these attributes are separate.
> -    */
> -   struct gl_client_array VertexAttrib[MAX_VERTEX_GENERIC_ATTRIBS];
> +   /** Vertex attribute arrays */
> +   struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX];

At some point it might be nice to rename VertexAttrib to simply be 
Array.  It would be a bit more concise.


>
>      /** Mask of VERT_BIT_* values indicating which arrays are enabled */
>      GLbitfield64 _Enabled;
> diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c
> index a0e89b1..dae1156 100644
> --- a/src/mesa/main/nvprogram.c
> +++ b/src/mesa/main/nvprogram.c
> @@ -365,7 +365,7 @@ _mesa_GetVertexAttribdvNV(GLuint index, GLenum pname,
> GLdouble *params)
>         return;
>      }
>
> -   array =&ctx->Array.ArrayObj->VertexAttrib[index];
> +   array =&ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
>
>      switch (pname) {
>         case GL_ATTRIB_ARRAY_SIZE_NV:
> @@ -409,7 +409,7 @@ _mesa_GetVertexAttribfvNV(GLuint index, GLenum pname,
> GLfloat *params)
>         return;
>      }
>
> -   array =&ctx->Array.ArrayObj->VertexAttrib[index];
> +   array =&ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
>
>      switch (pname) {
>         case GL_ATTRIB_ARRAY_SIZE_NV:
> @@ -453,7 +453,7 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname,
> GLint *params)
>         return;
>      }
>
> -   array =&ctx->Array.ArrayObj->VertexAttrib[index];
> +   array =&ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
>
>      switch (pname) {
>         case GL_ATTRIB_ARRAY_SIZE_NV:
> @@ -508,7 +508,7 @@ _mesa_GetVertexAttribPointervNV(GLuint index, GLenum
> pname, GLvoid **pointer)
>         return;
>      }
>
> -   *pointer = (GLvoid *) ctx->Array.ArrayObj->VertexAttrib[index].Ptr;
> +   *pointer = (GLvoid *) ctx->Array.ArrayObj-
>> VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
>   }
>
>   void
> diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
> index f57579c..a2b1eca 100644
> --- a/src/mesa/main/state.c
> +++ b/src/mesa/main/state.c
> @@ -87,94 +87,94 @@ update_arrays( struct gl_context *ctx )
>
>      /* 0 */
>      if (ctx->VertexProgram._Current
> -&&  arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
> -      min = update_min(min,&arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
> +&&  arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
> +      min = update_min(min,&arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]);
>      }
> -   else if (arrayObj->Vertex.Enabled) {
> -      min = update_min(min,&arrayObj->Vertex);
> +   else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
> +      min = update_min(min,&arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
>      }


Hmmm, do the generic arrays take precedence over the legacy arrays?  I 
don't remember off-hand.  There should probably be a comment about 
that either way.

The rest looks good.

-Brian


More information about the mesa-dev mailing list