mesa: remove FEATURE_evaluators define.
[mesa.git] / src / mesa / vbo / vbo_context.c
index 9992cc347396741710c482aca5a0f1709e03bd28..fd15fb6a9c30370e9c882ddc2e355f3dd1729c94 100644 (file)
 #include "vbo.h"
 #include "vbo_context.h"
 
-
-
-#define NR_LEGACY_ATTRIBS 16
-#define NR_GENERIC_ATTRIBS 16
 #define NR_MAT_ATTRIBS 12
 
-
 static GLuint check_size( const GLfloat *attr )
 {
    if (attr[3] != 1.0) return 4;
@@ -52,15 +47,15 @@ static GLuint check_size( const GLfloat *attr )
 static void init_legacy_currval(struct gl_context *ctx)
 {
    struct vbo_context *vbo = vbo_context(ctx);
-   struct gl_client_array *arrays = vbo->legacy_currval;
+   struct gl_client_array *arrays = &vbo->currval[VBO_ATTRIB_POS];
    GLuint i;
 
-   memset(arrays, 0, sizeof(*arrays) * NR_LEGACY_ATTRIBS);
+   memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_FF_MAX);
 
    /* Set up a constant (StrideB == 0) array for each current
     * attribute:
     */
-   for (i = 0; i < NR_LEGACY_ATTRIBS; i++) {
+   for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
       struct gl_client_array *cl = &arrays[i];
 
       /* Size will have to be determined at runtime:
@@ -72,6 +67,7 @@ static void init_legacy_currval(struct gl_context *ctx)
       cl->Type = GL_FLOAT;
       cl->Format = GL_RGBA;
       cl->Ptr = (const void *)ctx->Current.Attrib[i];
+      cl->_ElementSize = cl->Size * sizeof(GLfloat);
       _mesa_reference_buffer_object(ctx, &cl->BufferObj,
                                     ctx->Shared->NullBufferObj);
    }
@@ -81,12 +77,12 @@ static void init_legacy_currval(struct gl_context *ctx)
 static void init_generic_currval(struct gl_context *ctx)
 {
    struct vbo_context *vbo = vbo_context(ctx);
-   struct gl_client_array *arrays = vbo->generic_currval;
+   struct gl_client_array *arrays = &vbo->currval[VBO_ATTRIB_GENERIC0];
    GLuint i;
 
-   memset(arrays, 0, sizeof(*arrays) * NR_GENERIC_ATTRIBS);
+   memset(arrays, 0, sizeof(*arrays) * VERT_ATTRIB_GENERIC_MAX);
 
-   for (i = 0; i < NR_GENERIC_ATTRIBS; i++) {
+   for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
       struct gl_client_array *cl = &arrays[i];
 
       /* This will have to be determined at runtime:
@@ -98,6 +94,7 @@ static void init_generic_currval(struct gl_context *ctx)
       cl->Stride = 0;
       cl->StrideB = 0;
       cl->Enabled = 1;
+      cl->_ElementSize = cl->Size * sizeof(GLfloat);
       _mesa_reference_buffer_object(ctx, &cl->BufferObj,
                                     ctx->Shared->NullBufferObj);
    }
@@ -107,7 +104,8 @@ static void init_generic_currval(struct gl_context *ctx)
 static void init_mat_currval(struct gl_context *ctx)
 {
    struct vbo_context *vbo = vbo_context(ctx);
-   struct gl_client_array *arrays = vbo->mat_currval;
+   struct gl_client_array *arrays =
+      &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];
    GLuint i;
 
    ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX);
@@ -143,6 +141,7 @@ static void init_mat_currval(struct gl_context *ctx)
       cl->Stride = 0;
       cl->StrideB = 0;
       cl->Enabled = 1;
+      cl->_ElementSize = cl->Size * sizeof(GLfloat);
       _mesa_reference_buffer_object(ctx, &cl->BufferObj,
                                     ctx->Shared->NullBufferObj);
    }
@@ -162,12 +161,6 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
       return GL_FALSE;
    }
 
-   /* TODO: remove these pointers.
-    */
-   vbo->legacy_currval = &vbo->currval[VBO_ATTRIB_POS];
-   vbo->generic_currval = &vbo->currval[VBO_ATTRIB_GENERIC0];
-   vbo->mat_currval = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT];
-
    init_legacy_currval( ctx );
    init_generic_currval( ctx );
    init_mat_currval( ctx );
@@ -178,16 +171,14 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
    {
       GLuint i;
 
-      /* When no vertex program, pull in the material attributes in
-       * the 16..32 generic range.
-       */
-      for (i = 0; i < 16; i++) 
+      /* identity mapping */
+      for (i = 0; i < Elements(vbo->map_vp_none); i++) 
         vbo->map_vp_none[i] = i;
-      for (i = 0; i < 12; i++) 
-        vbo->map_vp_none[16+i] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
-      for (i = 0; i < 4; i++)
-        vbo->map_vp_none[28+i] = i;    
-      
+      /* map material attribs to generic slots */
+      for (i = 0; i < NR_MAT_ATTRIBS; i++) 
+        vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)]
+            = VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
+
       for (i = 0; i < Elements(vbo->map_vp_arb); i++)
         vbo->map_vp_arb[i] = i;
    }
@@ -209,7 +200,6 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
 
 void _vbo_InvalidateState( struct gl_context *ctx, GLuint new_state )
 {
-   _ae_invalidate_state(ctx, new_state);
    vbo_exec_invalidate_state(ctx, new_state);
 }
 
@@ -233,7 +223,7 @@ void _vbo_DestroyContext( struct gl_context *ctx )
       vbo_exec_destroy(ctx);
       if (ctx->API == API_OPENGL)
          vbo_save_destroy(ctx);
-      FREE(vbo);
+      free(vbo);
       ctx->swtnl_im = NULL;
    }
 }