From 5e281a053a08c9c1c6a90c93b78c28d1e92f13d7 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 13 Aug 2021 16:16:32 +0200 Subject: [PATCH] vbo/dlist: add documentation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a bit of documentation to describe the logic of vbo_save_api. while at it improve the packing of vbo_save_context. Reviewed-by: Marek Olšák Part-of: --- src/mesa/vbo/vbo.h | 9 ++++----- src/mesa/vbo/vbo_save_api.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index a8eb0d2..ce4364e 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -162,10 +162,6 @@ struct vbo_save_context { GLuint vertex_size; /**< size in GLfloats */ struct gl_vertex_array_object *VAO[VP_MODE_MAX]; - GLboolean out_of_memory; /**< True if last VBO allocation failed */ - - bool no_current_update; - struct vbo_save_vertex_store *vertex_store; struct vbo_save_primitive_store *prim_store; struct gl_buffer_object *current_bo; @@ -173,7 +169,6 @@ struct vbo_save_context { fi_type vertex[VBO_ATTRIB_MAX*4]; /* current values */ fi_type *attrptr[VBO_ATTRIB_MAX]; - GLboolean dangling_attr_ref; struct { fi_type *buffer; @@ -182,6 +177,10 @@ struct vbo_save_context { fi_type *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ GLubyte *currentsz[VBO_ATTRIB_MAX]; + + GLboolean dangling_attr_ref; + GLboolean out_of_memory; /**< True if last VBO allocation failed */ + bool no_current_update; }; GLboolean diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index d865085..6bdcb2c 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -64,6 +64,39 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * * This could be improved to fallback only when a mix of EvalCoord and * Vertex commands are issued within a single primitive. + * + * The compilation process works as follows. All vertex attributes + * except position are copied to vbo_save_context::attrptr (see ATTR_UNION). + * 'attrptr' are pointers to vbo_save_context::vertex ordered according to the enabled + * attributes (se upgrade_vertex). + * When the position attribute is received, all the attributes are then + * copied to the vertex_store (see the end of ATTR_UNION). + * The vertex_store is simply an extensible float array. + * When the vertex list needs to be compiled (see compile_vertex_list), + * several transformations are performed: + * - some primitives are merged together (eg: two consecutive GL_TRIANGLES + * with 3 vertices can be merged in a single GL_TRIANGLES with 6 vertices). + * - an index buffer is built. + * - identical vertices are detected and only one is kept. + * At the end of this transformation, the index buffer and the vertex buffer + * are uploaded in vRAM in the same buffer object. + * This buffer object is shared between multiple display list to allow + * draw calls merging later. + * + * The layout of this buffer for two display lists is: + * V0A0|V0A1|V1A0|V1A1|P0I0|P0I1|V0A0V0A1V0A2|V1A1V1A1V1A2|... + * ` new list starts + * - VxAy: vertex x, attributes y + * - PxIy: draw x, index y + * + * To allow draw call merging, display list must use the same VAO, including + * the same Offset in the buffer object. To achieve this, the start values of + * the primitive are shifted and the indices adjusted (see offset_diff and + * start_offset in compile_vertex_list). + * + * Display list using the loopback code (see vbo_save_playback_vertex_list_loopback), + * can't be drawn with an index buffer so this transformation is disabled + * in this case. */ -- 2.7.4