Mesa (master): vbo: add vbo_always_unmap_buffers()

Brian Paul brianp at kemper.freedesktop.org
Wed Mar 2 00:31:17 UTC 2011


Module: Mesa
Branch: master
Commit: 8731f0363fea81394417b2da8a9ac9788a0dcfc6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8731f0363fea81394417b2da8a9ac9788a0dcfc6

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Mar  1 17:16:53 2011 -0700

vbo: add vbo_always_unmap_buffers()

Drivers can call this function as needed.  It tells the VBO module to
always unmap the current glBegin/glEnd VBO when we flush.  Otherwise
it's possible to be in a flushed state but still have the VBO mapped.

---

 src/mesa/vbo/vbo.h          |    1 +
 src/mesa/vbo/vbo_exec.h     |    3 +++
 src/mesa/vbo/vbo_exec_api.c |   19 ++++++++++++++++++-
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 6834f3b..26c3d4e 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -127,6 +127,7 @@ vbo_get_minmax_index(struct gl_context *ctx, const struct _mesa_prim *prim,
 
 void vbo_use_buffer_objects(struct gl_context *ctx);
 
+void vbo_always_unmap_buffers(struct gl_context *ctx);
 
 void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
 
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 1b0ed79..d52a557 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -143,6 +143,9 @@ struct vbo_exec_context
       const struct gl_client_array *inputs[VERT_ATTRIB_MAX];
    } array;
 
+   /* Which flags to set in vbo_exec_BeginVertices() */
+   GLbitfield begin_vertices_flags;
+
 #ifdef DEBUG
    GLint flush_call_depth;
 #endif
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 0116c17..fcd544d 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -839,6 +839,19 @@ void vbo_use_buffer_objects(struct gl_context *ctx)
 }
 
 
+/**
+ * If this function is called, all VBO buffers will be unmapped when
+ * we flush.
+ * Otherwise, if a simple command like glColor3f() is called and we flush,
+ * the current VBO may be left mapped.
+ */
+void
+vbo_always_unmap_buffers(struct gl_context *ctx)
+{
+   struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
+   exec->begin_vertices_flags |= FLUSH_STORED_VERTICES;
+}
+
 
 void vbo_exec_vtx_init( struct vbo_exec_context *exec )
 {
@@ -894,6 +907,8 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
    }
 
    exec->vtx.vertex_size = 0;
+
+   exec->begin_vertices_flags = FLUSH_UPDATE_CURRENT;
 }
 
 
@@ -942,7 +957,9 @@ void vbo_exec_BeginVertices( struct gl_context *ctx )
    vbo_exec_vtx_map( exec );
 
    assert((ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0);
-   ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
+   assert(exec->begin_vertices_flags);
+
+   ctx->Driver.NeedFlush |= exec->begin_vertices_flags;
 }
 
 




More information about the mesa-commit mailing list