vbo: fix incorrect min/max_index values in display list draw call
authorBrian Paul <brianp@vmware.com>
Tue, 23 Jan 2018 17:48:51 +0000 (10:48 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 24 Jan 2018 17:12:49 +0000 (10:12 -0700)
This fixes another regression from commit 8e4efdc895ea ("vbo: optimize
some display list drawing").  The problem was the min_index, max_index
values passed to the vbo drawing function were not computed to compensate
for the biased prim::start values.

https://bugs.freedesktop.org/show_bug.cgi?id=104746
https://bugs.freedesktop.org/show_bug.cgi?id=104742
https://bugs.freedesktop.org/show_bug.cgi?id=104690
Tested-by: Clayton Craft <clayton.a.craft@intel.com>
Fixes: 8e4efdc895ea ("vbo: optimize some display list drawing")
Reviewed-by: Emil Velikov <emil.velikov@collabora.co.uk>
src/mesa/vbo/vbo_save.h
src/mesa/vbo/vbo_save_api.c
src/mesa/vbo/vbo_save_draw.c

index 04b9e388f41ffb1a72c87143c5cfe89d12e35a0b..51ea9ccb3d065b8f36599d651028cb1c937eac9e 100644 (file)
@@ -74,7 +74,8 @@ struct vbo_save_vertex_list {
    GLuint current_size;
 
    GLuint buffer_offset;        /**< in bytes */
-   GLuint vertex_count;
+   GLuint start_vertex;         /**< first vertex used by any primitive */
+   GLuint vertex_count;         /**< number of vertices in this list */
    GLuint wrap_count;          /* number of copied vertices at start */
    GLboolean dangling_attr_ref;        /* current attr implicitly referenced
                                    outside the list */
index e0fe5fd9ac973627cfee02113efaa48a3a4435c1..11c40a26429f77db09ac98325041b14234977101 100644 (file)
@@ -563,6 +563,9 @@ compile_vertex_list(struct gl_context *ctx)
       for (unsigned i = 0; i < save->prim_count; i++) {
          save->prims[i].start += start_offset;
       }
+      node->start_vertex = start_offset;
+   } else {
+      node->start_vertex = 0;
    }
 
    /* Reset our structures for the next run of vertices:
index 3a6083fdf45fdc3aac930e72d68f32735623e3a2..8cfe10bdc55b81caaffed4935b6dd14d6403818c 100644 (file)
@@ -325,13 +325,14 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
          _mesa_update_state(ctx);
 
       if (node->vertex_count > 0) {
+         GLuint min_index = node->start_vertex;
+         GLuint max_index = min_index + node->vertex_count - 1;
          vbo_context(ctx)->draw_prims(ctx,
                                       node->prims,
                                       node->prim_count,
                                       NULL,
                                       GL_TRUE,
-                                      0,    /* Node is a VBO, so this is ok */
-                                      node->vertex_count - 1,
+                                      min_index, max_index,
                                       NULL, 0, NULL);
       }
    }