Mesa (master): vbo: Redeclare bind_array() as non-static vbo_bind_array()

Chad Versace chadversary at kemper.freedesktop.org
Tue Oct 18 11:44:21 PDT 2011


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

Author: Chad Versace <chad at chad-versace.us>
Date:   Thu Oct  6 11:38:29 2011 -0700

vbo: Redeclare bind_array() as non-static vbo_bind_array()

This is necessary because i965 will need to call vbo_bind_array() when
cleaning up after a buffer resolve meta-op.

Detailed Explanation
--------------------
The vbo module tracks vertex attributes separately from the gl_context.
Specifically, the vbo module maintins vertex attributes in
vbo_exec_context::array::inputs, which is synchronized with
gl_context::Array::ArrayObj::VertexAttrib by vbo_bind_array().
vbo_draw_arrays() calls vbo_bind_array() to perform the synchronization
before calling the real draw call, vbo_context::draw_arrays.

Intel hardware accomplishes buffer resolves with a meta-op. Frequently,
that meta-op must be performed within glDraw* in the moment immediately
before the draw occurs (The hardware designers hate us...). After
performing the meta-op, but before calling vbo_bind_array(), the
gl_context's vertex attributes will have been restored to their original
state (that is, their state before the meta-op began), but the vbo
module's vertex attribute are those used in the last meta-op. Therefore we
must manually synchronize the two with vbo_bind_array() before continuing
with the original draw command (that is, the one requested with glDraw*).

See brw_predraw_resolve_buffers(), which will be added in a future commit.

Reviewed-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/vbo/vbo.h            |    1 +
 src/mesa/vbo/vbo_exec_array.c |   10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 26c3d4e..9fbb07f 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -133,6 +133,7 @@ void vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
 
 void vbo_check_buffers_are_unmapped(struct gl_context *ctx);
 
+void vbo_bind_arrays(struct gl_context *ctx);
 
 void GLAPIENTRY
 _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index ceb6a64..4e4f2c9 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -563,8 +563,8 @@ recalculate_input_bindings(struct gl_context *ctx)
  * Note that this might set the _NEW_ARRAY dirty flag so state validation
  * must be done after this call.
  */
-static void
-bind_arrays(struct gl_context *ctx)
+void
+vbo_bind_arrays(struct gl_context *ctx)
 {
    if (!ctx->Array.RebindArrays) {
       return;
@@ -590,7 +590,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
    struct vbo_exec_context *exec = &vbo->exec;
    struct _mesa_prim prim[2];
 
-   bind_arrays(ctx);
+   vbo_bind_arrays(ctx);
 
    /* Again... because we may have changed the bitmask of per-vertex varying
     * attributes.  If we regenerate the fixed-function vertex program now
@@ -804,7 +804,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
       return;
    }
 
-   bind_arrays( ctx );
+   vbo_bind_arrays( ctx );
 
    /* check for dirty state again */
    if (ctx->NewState)
@@ -1129,7 +1129,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
     * same index buffer, or if we have to reset the index pointer per
     * primitive.
     */
-   bind_arrays( ctx );
+   vbo_bind_arrays( ctx );
 
    /* check for dirty state again */
    if (ctx->NewState)



More information about the mesa-commit mailing list