From 8e4efdc895eacca931b94a0c1fa01aae5c34463b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 12 Jan 2018 13:18:25 -0700 Subject: 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 --- src/mesa/vbo/vbo_save.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/mesa/vbo/vbo_save.h') diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h index 9d13e0aa18d..274d667be78 100644 --- a/src/mesa/vbo/vbo_save.h +++ b/src/mesa/vbo/vbo_save.h @@ -86,6 +86,20 @@ struct vbo_save_vertex_list { struct vbo_save_primitive_store *prim_store; }; + +/** + * Is the vertex lists's buffer offset an exact multiple of the + * vertex size (in bytes)? This is used to check for a vertex array / + * drawing optimization. + */ +static inline bool +aligned_vertex_buffer_offset(const struct vbo_save_vertex_list *node) +{ + unsigned vertex_size = node->vertex_size * sizeof(GLfloat); /* in bytes */ + return vertex_size != 0 && node->buffer_offset % vertex_size == 0; +} + + /* These buffers should be a reasonable size to support upload to * hardware. Current vbo implementation will re-upload on any * changes, so don't make too big or apps which dynamically create -- cgit v1.2.3