summaryrefslogtreecommitdiffstats
path: root/src/mesa/vbo/vbo_save_api.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2018-01-12 13:18:25 -0700
committerBrian Paul <[email protected]>2018-01-17 11:17:56 -0700
commit8e4efdc895eacca931b94a0c1fa01aae5c34463b (patch)
tree83ef3f782cb0994875794ad504f6d2d746ad87f8 /src/mesa/vbo/vbo_save_api.c
parent4edc8fdcdc8df2a37930241b803383d46e6d7f5f (diff)
vbo: optimize some display list drawing (v2)
The vbo_save_vertex_list structure records one or more glBegin/End primitives which all have the same vertex format. To draw these primitives, we setup the vertex array state, then issue the drawing command. Before, the 'start' vertex was typically zero and we used the vertex array pointer to indicate where the vertex data starts. This patch checks if the vertex buffer offset is an exact multiple of the vertex size. If so, that means we can use zero-based vertex array pointers and use the draw's start value to indicate where the vertex data starts. This means a series of display list drawing commands may have identical vertex array state. This will get filtered out by the Gallium CSO module so we can issue a tight series of drawing commands without state changes to the device. Note that this also works for a series of glCallList commands (not just one list that contains multiple glBegin/End pairs). No Piglit or conform changes. v2: minor fixes suggested by Ian. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_save_api.c')
-rw-r--r--src/mesa/vbo/vbo_save_api.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 42d883fed4d..1c575448773 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -546,6 +546,20 @@ compile_vertex_list(struct gl_context *ctx)
save->prim_store = alloc_prim_store();
}
+ /*
+ * If the vertex buffer offset is a multiple of the vertex size,
+ * we can use the _mesa_prim::start value to indicate where the
+ * vertices starts, instead of the buffer offset. Also see the
+ * bind_vertex_list() function.
+ */
+ if (aligned_vertex_buffer_offset(node)) {
+ const unsigned start_offset =
+ node->buffer_offset / (node->vertex_size * sizeof(GLfloat));
+ for (unsigned i = 0; i < save->prim_count; i++) {
+ save->prims[i].start += start_offset;
+ }
+ }
+
/* Reset our structures for the next run of vertices:
*/
reset_counters(ctx);