i965: Fix uploading user vertex arrays with basevertex set.
authorEric Anholt <eric@anholt.net>
Wed, 31 Oct 2012 20:39:26 +0000 (13:39 -0700)
committerEric Anholt <eric@anholt.net>
Sun, 4 Nov 2012 19:15:44 +0000 (11:15 -0800)
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

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_draw_upload.c

index 9fa4848af3acd600fc525346a33f014f43b8f1a4..97556cbd2c820700453b4ab5c9acd55b1022a48c 100644 (file)
@@ -1086,6 +1086,7 @@ struct brw_context
    } prim_restart;
 
    uint32_t num_instances;
+   int basevertex;
 };
 
 
index 22d18f91705c25a2d475779d591e3395c15fd050..97a1077187737381784a8badc12bf85942c90c8b 100644 (file)
@@ -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
index ad7fe7c7f74ac48f9a07479a91d7710e736084d9..51531ce90e46c5ec4e7e208266b03476325e3256 100644 (file)
@@ -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];