Mesa (master): i965: Don' t rebase the index buffer to min 0 if any arrays are in VBOs.

Eric Anholt anholt at kemper.freedesktop.org
Tue Oct 12 22:24:36 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Oct 12 14:39:12 2010 -0700

i965: Don't rebase the index buffer to min 0 if any arrays are in VBOs.

There was a check to only do the rebase if we didn't have everything
in VBOs, but nexuiz apparently hands us a mix of VBOs and arrays,
resulting in blocking on the GPU to do a rebase.

Improves nexuiz 800x600, high-settings performance on my Ironlake 41%
(+/- 1.3%), from 14.0fps to 19.7fps.

---

 src/mesa/drivers/dri/i965/brw_draw.c        |    2 +-
 src/mesa/drivers/dri/i965/brw_draw_upload.c |   11 +----------
 src/mesa/vbo/vbo.h                          |    1 +
 src/mesa/vbo/vbo_rebase.c                   |   12 ++++++++++++
 4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 6a4dda2..af5c375 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -441,7 +441,7 @@ void brw_draw_prims( GLcontext *ctx,
       /* Decide if we want to rebase.  If so we end up recursing once
        * only into this function.
        */
-      if (min_index != 0) {
+      if (min_index != 0 && !vbo_any_varyings_in_vbos(arrays)) {
 	 vbo_rebase_prims(ctx, arrays,
 			  prim, nr_prims,
 			  ib, min_index, max_index,
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 249e874..f24c414 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -383,7 +383,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
 	  */
 	 assert(input->offset < input->bo->size);
       } else {
-	 input->count = input->glarray->StrideB ? max_index + 1 - min_index : 1;
+	 input->count = input->glarray->StrideB ? max_index + 1 : 1;
 	 if (input->bo != NULL) {
 	    /* Already-uploaded vertex data is present from a previous
 	     * prepare_vertices, but we had to re-validate state due to
@@ -414,15 +414,6 @@ static void brw_prepare_vertices(struct brw_context *brw)
 	 }
 
 	 upload[nr_uploads++] = input;
-	 
-	 /* We rebase drawing to start at element zero only when
-	  * varyings are not in vbos, which means we can end up
-	  * uploading non-varying arrays (stride != 0) when min_index
-	  * is zero.  This doesn't matter as the amount to upload is
-	  * the same for these arrays whether the draw call is rebased
-	  * or not - we just have to upload the one element.
-	  */
-	 assert(min_index == 0 || input->glarray->StrideB == 0);
       }
    }
 
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 07d31f6..30b1448 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -106,6 +106,7 @@ void vbo_split_prims( GLcontext *ctx,
 /* Helpers for dealing translating away non-zero min_index.
  */
 GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] );
+GLboolean vbo_any_varyings_in_vbos( const struct gl_client_array *arrays[] );
 
 void vbo_rebase_prims( GLcontext *ctx,
 		       const struct gl_client_array *arrays[],
diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c
index ff7c7a6..e75253f 100644
--- a/src/mesa/vbo/vbo_rebase.c
+++ b/src/mesa/vbo/vbo_rebase.c
@@ -85,6 +85,18 @@ GLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] )
    return GL_TRUE;
 }
 
+GLboolean vbo_any_varyings_in_vbos( const struct gl_client_array *arrays[] )
+{
+   GLuint i;
+
+   for (i = 0; i < VERT_ATTRIB_MAX; i++)
+      if (arrays[i]->StrideB &&
+	  arrays[i]->BufferObj->Name != 0)
+	 return GL_TRUE;
+
+   return GL_FALSE;
+}
+
 /* Adjust primitives, indices and vertex definitions so that min_index
  * becomes zero. There are lots of reasons for wanting to do this, eg:
  *




More information about the mesa-commit mailing list