[Mesa-dev] [PATCH 08/10] vbo: remove vbo_context::legacy_currval

Marek Olšák maraeo at gmail.com
Wed Apr 18 07:16:42 PDT 2012


It's not nice when you have several variables pointing to the same array
and you wanna ask your editor "where is this used" and you only get an answer
for one of the four currval, legacy_currval, generic_currval, mat_currval,
which is quite useless, because you never see the whole picture.

Let's get rid of the additional pointers.
---
 src/mesa/vbo/vbo_context.c    |    3 +--
 src/mesa/vbo/vbo_context.h    |    3 +--
 src/mesa/vbo/vbo_exec_api.c   |    4 ++--
 src/mesa/vbo/vbo_exec_array.c |    8 ++++----
 src/mesa/vbo/vbo_exec_draw.c  |    4 ++--
 src/mesa/vbo/vbo_save.c       |    4 ++--
 src/mesa/vbo/vbo_save_draw.c  |    4 ++--
 7 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index d83f2fd..2b31b62 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -47,7 +47,7 @@ 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) * VERT_ATTRIB_FF_MAX);
@@ -162,7 +162,6 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx )
 
    /* 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];
 
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index cae2407..77010b8 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -61,9 +61,8 @@
 struct vbo_context {
    struct gl_client_array currval[VBO_ATTRIB_MAX];
    
-   /* These point into the above.  TODO: remove. 
+   /* These point into the above.  TODO: remove.
     */
-   struct gl_client_array *legacy_currval;
    struct gl_client_array *generic_currval;
    struct gl_client_array *mat_currval;
 
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 3061990..8a16804 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -1089,14 +1089,14 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
       struct gl_client_array *arrays = exec->vtx.arrays;
       unsigned i;
 
-      memcpy(arrays, vbo->legacy_currval,
+      memcpy(arrays, &vbo->currval[VBO_ATTRIB_POS],
              VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
       for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
          struct gl_client_array *array;
          array = &arrays[VERT_ATTRIB_FF(i)];
          array->BufferObj = NULL;
          _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
-                                       vbo->legacy_currval[i].BufferObj);
+                                 vbo->currval[VBO_ATTRIB_POS+i].BufferObj);
       }
 
       memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval,
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 30a954a..7278c39 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -420,7 +420,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 	 if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
 	    inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
 	 else {
-	    inputs[i] = &vbo->legacy_currval[i];
+	    inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
             const_inputs |= VERT_BIT(i);
          }
       }
@@ -459,7 +459,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 	 else if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
 	    inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
 	 else {
-	    inputs[i] = &vbo->legacy_currval[i];
+	    inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
             const_inputs |= VERT_BIT_FF(i);
          }
       }
@@ -488,7 +488,7 @@ recalculate_input_bindings(struct gl_context *ctx)
       else if (vertexAttrib[VERT_ATTRIB_POS].Enabled)
 	 inputs[0] = &vertexAttrib[VERT_ATTRIB_POS];
       else {
-	 inputs[0] = &vbo->legacy_currval[0];
+	 inputs[0] = &vbo->currval[VBO_ATTRIB_POS];
          const_inputs |= VERT_BIT_POS;
       }
 
@@ -496,7 +496,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 	 if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
 	    inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
 	 else {
-	    inputs[i] = &vbo->legacy_currval[i];
+	    inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
             const_inputs |= VERT_BIT_FF(i);
          }
       }
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index a1d329f..96ff224 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -174,7 +174,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
    switch (get_program_mode(exec->ctx)) {
    case VP_NONE:
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-         exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+         exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
       for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
          ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs));
@@ -189,7 +189,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
        * nor attributes greater than VERT_ATTRIB_TEX7.  
        */
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-         exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+         exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
       for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
          ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs));
diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index e027061..dbe99ed 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -63,14 +63,14 @@ void vbo_save_init( struct gl_context *ctx )
       struct gl_client_array *arrays = save->arrays;
       unsigned i;
 
-      memcpy(arrays, vbo->legacy_currval,
+      memcpy(arrays, &vbo->currval[VBO_ATTRIB_POS],
              VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
       for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
          struct gl_client_array *array;
          array = &arrays[VERT_ATTRIB_FF(i)];
          array->BufferObj = NULL;
          _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
-                                       vbo->legacy_currval[i].BufferObj);
+                                       vbo->currval[VBO_ATTRIB_POS+i].BufferObj);
       }
 
       memcpy(arrays + VERT_ATTRIB_GENERIC(0), vbo->generic_currval,
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index b8e1e78..669023c 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -147,7 +147,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
    switch (get_program_mode(ctx)) {
    case VP_NONE:
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-         save->inputs[attr] = &vbo->legacy_currval[attr];
+         save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
       for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
          save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->mat_currval[attr];
@@ -161,7 +161,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
        * nor attributes greater than VERT_ATTRIB_TEX7.  
        */
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-         save->inputs[attr] = &vbo->legacy_currval[attr];
+         save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
       for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
          save->inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->generic_currval[attr];
-- 
1.7.5.4



More information about the mesa-dev mailing list