[Mesa-dev] [PATCH 3/3] i965: Fix uploading user vertex arrays with basevertex set.

Eric Anholt eric at anholt.net
Wed Oct 31 14:26:41 PDT 2012


If the index buffer is full of values like "0 1 2 3", but basevertex is 4, we
need to upload at least vertex data for elements 4 5 6 7.  Whether we also
upload 0 1 2 3 is a question of whether there are VBOs present or not -- see
the code setting start_vertex_bias in brw_draw_upload.c.

Fixes piglit draw-elements*base-vertex user_varrays
---
 src/mesa/drivers/dri/i965/brw_context.h     |    1 +
 src/mesa/drivers/dri/i965/brw_draw.c        |    4 ++++
 src/mesa/drivers/dri/i965/brw_draw_upload.c |    4 ++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 19c6af7..195fd3d 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1088,6 +1088,7 @@ struct brw_context
    } prim_restart;
 
    uint32_t num_instances;
+   int basevertex;
 };
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 22d18f9..97a1077 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -478,6 +478,10 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
          brw->num_instances = prim->num_instances;
          brw->state.dirty.brw |= BRW_NEW_VERTICES;
       }
+      if (brw->basevertex != prim->basevertex) {
+         brw->basevertex = prim->basevertex;
+         brw->state.dirty.brw |= BRW_NEW_VERTICES;
+      }
       if (intel->gen < 6)
 	 brw_set_prim(brw, &prim[i]);
       else
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index ad7fe7c..51531ce 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -357,8 +357,8 @@ static void brw_prepare_vertices(struct brw_context *brw)
    GLbitfield64 vs_inputs = brw->vs.prog_data->inputs_read;
    const unsigned char *ptr = NULL;
    GLuint interleaved = 0;
-   unsigned int min_index = brw->vb.min_index;
-   unsigned int max_index = brw->vb.max_index;
+   unsigned int min_index = brw->vb.min_index + brw->basevertex;
+   unsigned int max_index = brw->vb.max_index + brw->basevertex;
    int delta, i, j;
 
    struct brw_vertex_element *upload[VERT_ATTRIB_MAX];
-- 
1.7.10.4



More information about the mesa-dev mailing list