Mesa (master): vbo: bind arrays only when necessary

Marek Olšák mareko at kemper.freedesktop.org
Mon Feb 14 21:06:48 UTC 2011


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sat Feb 12 03:57:19 2011 +0100

vbo: bind arrays only when necessary

We don't need to call bind_arrays in the vbo module if the states
which the function depends on are not dirty.

---

 src/mesa/main/mtypes.h        |    1 +
 src/mesa/main/state.c         |    2 ++
 src/mesa/vbo/vbo_exec_array.c |    5 +++++
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 09e17d9..b7473e1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1643,6 +1643,7 @@ struct gl_array_attrib
    GLuint RestartIndex;
 
    GLbitfield NewState;		/**< mask of _NEW_ARRAY_* values */
+   GLboolean RebindArrays; /**< whether the VBO module should rebind arrays */
 
    /* GL_ARB_vertex_buffer_object */
    struct gl_buffer_object *ArrayBufferObj;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index cce1b46..502c429 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -662,6 +662,8 @@ _mesa_update_state_locked( struct gl_context *ctx )
    ctx->NewState = 0;
    ctx->Driver.UpdateState(ctx, new_state);
    ctx->Array.NewState = 0;
+   if (!ctx->Array.RebindArrays)
+      ctx->Array.RebindArrays = (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) != 0;
 }
 
 
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 80085c1..6749541 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -502,8 +502,13 @@ recalculate_input_bindings(struct gl_context *ctx)
 static void
 bind_arrays(struct gl_context *ctx)
 {
+   if (!ctx->Array.RebindArrays) {
+      return;
+   }
+
    bind_array_obj(ctx);
    recalculate_input_bindings(ctx);
+   ctx->Array.RebindArrays = GL_FALSE;
 }
 
 




More information about the mesa-commit mailing list