[Mesa-dev] [PATCH 06/12] vbo: Remove reference to the vertex_store from the dlist node.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Tue Feb 27 06:12:25 UTC 2018


From: Mathias Fröhlich <mathias.froehlich at web.de>

Since we now store a set of VAOs in the display list, use these object
to get the reference to the VBO in several places.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/vbo/vbo_save.c     | 11 +++++------
 src/mesa/vbo/vbo_save.h     |  6 ++----
 src/mesa/vbo/vbo_save_api.c | 14 +++-----------
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index f106cf279a..361964195c 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -65,12 +65,11 @@ void vbo_save_destroy( struct gl_context *ctx )
          free(save->prim_store);
          save->prim_store = NULL;
       }
-      if ( --save->vertex_store->refcount == 0 ) {
-         _mesa_reference_buffer_object(ctx,
-                                       &save->vertex_store->bufferobj, NULL);
-         free(save->vertex_store);
-         save->vertex_store = NULL;
-      }
+   }
+   if (save->vertex_store) {
+      _mesa_reference_buffer_object(ctx, &save->vertex_store->bufferobj, NULL);
+      free(save->vertex_store);
+      save->vertex_store = NULL;
    }
 }
 
diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index f6e6415d75..751ea47ef3 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -81,7 +81,6 @@ struct vbo_save_vertex_list {
    struct _mesa_prim *prims;
    GLuint prim_count;
 
-   struct vbo_save_vertex_store *vertex_store;
    struct vbo_save_primitive_store *prim_store;
 };
 
@@ -161,15 +160,14 @@ _vbo_save_get_vertex_count(const struct vbo_save_vertex_list *node)
 
 #define VBO_SAVE_FALLBACK    0x10000000
 
-/* Storage to be shared among several vertex_lists.
- */
 struct vbo_save_vertex_store {
    struct gl_buffer_object *bufferobj;
    fi_type *buffer_map;
    GLuint used;           /**< Number of 4-byte words used in buffer */
-   GLuint refcount;
 };
 
+/* Storage to be shared among several vertex_lists.
+ */
 struct vbo_save_primitive_store {
    struct _mesa_prim prims[VBO_SAVE_PRIM_SIZE];
    GLuint used;
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index db9a3fbdfa..8dac6251c4 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -222,7 +222,6 @@ alloc_vertex_store(struct gl_context *ctx)
 
    vertex_store->buffer_map = NULL;
    vertex_store->used = 0;
-   vertex_store->refcount = 1;
 
    return vertex_store;
 }
@@ -574,7 +573,6 @@ compile_vertex_list(struct gl_context *ctx)
    node->wrap_count = save->copied.nr;
    node->prims = save->prims;
    node->prim_count = save->prim_count;
-   node->vertex_store = save->vertex_store;
    node->prim_store = save->prim_store;
 
    /* Create a pair of VAOs for the possible VERTEX_PROCESSING_MODEs
@@ -583,7 +581,7 @@ compile_vertex_list(struct gl_context *ctx)
    for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) {
       /* create or reuse the vao */
       update_vao(ctx, vpm, &save->VAO[vpm],
-                 node->vertex_store->bufferobj, buffer_offset,
+                 save->vertex_store->bufferobj, buffer_offset,
                  node->vertex_size*sizeof(GLfloat), node->enabled,
                  node->attrsz, node->attrtype, offsets);
       /* Reference the vao in the dlist */
@@ -591,7 +589,6 @@ compile_vertex_list(struct gl_context *ctx)
       _mesa_reference_vao(ctx, &node->VAO[vpm], save->VAO[vpm]);
    }
 
-   node->vertex_store->refcount++;
    node->prim_store->refcount++;
 
    if (node->prims[0].no_current_update) {
@@ -680,8 +677,7 @@ compile_vertex_list(struct gl_context *ctx)
 
       /* Release old reference:
        */
-      save->vertex_store->refcount--;
-      assert(save->vertex_store->refcount != 0);
+      free_vertex_store(ctx, save->vertex_store);
       save->vertex_store = NULL;
 
       /* Allocate and map new store:
@@ -1817,9 +1813,6 @@ vbo_destroy_vertex_list(struct gl_context *ctx, void *data)
    for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm)
       _mesa_reference_vao(ctx, &node->VAO[vpm], NULL);
 
-   if (--node->vertex_store->refcount == 0)
-      free_vertex_store(ctx, node->vertex_store);
-
    if (--node->prim_store->refcount == 0)
       free(node->prim_store);
 
@@ -1833,8 +1826,7 @@ vbo_print_vertex_list(struct gl_context *ctx, void *data, FILE *f)
 {
    struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data;
    GLuint i;
-   struct gl_buffer_object *buffer = node->vertex_store ?
-      node->vertex_store->bufferobj : NULL;
+   struct gl_buffer_object *buffer = node->VAO[0]->BufferBinding[0].BufferObj;
    (void) ctx;
 
    fprintf(f, "VBO-VERTEX-LIST, %u vertices, %d primitives, %d vertsize, "
-- 
2.14.3



More information about the mesa-dev mailing list