From f8b98d48bffacc0a1b5393307c8405f4eda8e27c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 22 Jan 2020 18:07:02 -0500 Subject: [PATCH] vbo: keep the immediate mode buffer always mapped for simplicity MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It only unmaps when it draws with a non-persistent buffer. Reviewed-by: Mathias Fröhlich Part-of: --- src/mesa/vbo/vbo_exec.h | 2 +- src/mesa/vbo/vbo_exec_api.c | 26 ++++++++++++-------------- src/mesa/vbo/vbo_exec_draw.c | 14 +++----------- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index 33d12986e10..433df4fd8dd 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -133,7 +133,7 @@ void vbo_exec_vtx_destroy(struct vbo_exec_context *exec); void -vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean unmap); +vbo_exec_vtx_flush(struct vbo_exec_context *exec); void vbo_exec_vtx_map(struct vbo_exec_context *exec); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 315c2759b17..5c8db3bca75 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -99,7 +99,7 @@ vbo_exec_wrap_buffers(struct vbo_exec_context *exec) /* Execute the buffer and save copied vertices. */ if (exec->vtx.vert_count) - vbo_exec_vtx_flush(exec, GL_FALSE); + vbo_exec_vtx_flush(exec); else { exec->vtx.prim_count = 0; exec->vtx.copied.nr = 0; @@ -490,11 +490,6 @@ do { \ /* This is a glVertex call */ \ GLuint i; \ \ - if (unlikely(!exec->vtx.buffer_ptr)) { \ - vbo_exec_vtx_map(exec); \ - } \ - assert(exec->vtx.buffer_ptr); \ - \ /* copy 32-bit words */ \ for (i = 0; i < exec->vtx.vertex_size; i++) \ exec->vtx.buffer_ptr[i] = exec->vtx.vertex[i]; \ @@ -623,13 +618,12 @@ vbo_exec_Materialfv(GLenum face, GLenum pname, const GLfloat *params) /** * Flush (draw) vertices. - * \param unmap - leave VBO unmapped after flushing? */ static void -vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, GLboolean unmap) +vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec) { - if (exec->vtx.vert_count || unmap) { - vbo_exec_vtx_flush(exec, unmap); + if (exec->vtx.vert_count) { + vbo_exec_vtx_flush(exec); } if (exec->vtx.vertex_size) { @@ -768,7 +762,7 @@ vbo_exec_Begin(GLenum mode) * begin/end pairs. */ if (exec->vtx.vertex_size && !exec->vtx.attr[VBO_ATTRIB_POS].size) - vbo_exec_FlushVertices_internal(exec, GL_FALSE); + vbo_exec_FlushVertices_internal(exec); i = exec->vtx.prim_count++; exec->vtx.prim[i].mode = mode; @@ -888,7 +882,7 @@ vbo_exec_End(void) ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; if (exec->vtx.prim_count == VBO_MAX_PRIM) - vbo_exec_vtx_flush(exec, GL_FALSE); + vbo_exec_vtx_flush(exec); if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH) { _mesa_flush(ctx); @@ -957,6 +951,10 @@ vbo_use_buffer_objects(struct gl_context *ctx) /* Allocate a real buffer object now */ _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName); + + /* Map the buffer. */ + vbo_exec_vtx_map(exec); + assert(exec->vtx.buffer_ptr); } @@ -1050,8 +1048,8 @@ vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags) return; } - /* Flush (draw), and make sure VBO is left unmapped when done */ - vbo_exec_FlushVertices_internal(exec, GL_TRUE); + /* Flush (draw). */ + vbo_exec_FlushVertices_internal(exec); /* Clear the dirty flush flags, because the flush is finished. */ ctx->Driver.NeedFlush &= ~(FLUSH_UPDATE_CURRENT | flags); diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 6fbd8f3de47..a46a2b03568 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -371,16 +371,14 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec) /** * Execute the buffer and save copied verts. - * \param unmap if true, leave the VBO unmapped when we're done. */ void -vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean unmap) +vbo_exec_vtx_flush(struct vbo_exec_context *exec) { /* Only unmap if persistent mappings are unsupported. */ bool persistent_mapping = exec->ctx->Extensions.ARB_buffer_storage && _mesa_is_bufferobj(exec->vtx.bufferobj) && exec->vtx.buffer_map; - unmap = unmap && !persistent_mapping; if (0) vbo_exec_debug_verts(exec); @@ -413,17 +411,11 @@ vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean unmap) NULL, 0, NULL); /* Get new storage -- unless asked not to. */ - if (!persistent_mapping && !unmap) + if (!persistent_mapping) vbo_exec_vtx_map(exec); } } - /* May have to unmap explicitly if we didn't draw: - */ - if (unmap && exec->vtx.buffer_map) { - vbo_exec_vtx_unmap(exec); - } - if (persistent_mapping) { exec->vtx.buffer_used += (exec->vtx.buffer_ptr - exec->vtx.buffer_map) * sizeof(float); @@ -439,7 +431,7 @@ vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean unmap) } } - if (unmap || exec->vtx.vertex_size == 0) + if (exec->vtx.vertex_size == 0) exec->vtx.max_vert = 0; else exec->vtx.max_vert = vbo_compute_max_verts(exec); -- 2.30.2