Mesa (main): vbo: delay vbo_exec_vtx_map call

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 17 07:36:21 UTC 2021


Module: Mesa
Branch: main
Commit: 84dca32c51e9f70b20515afd304826091c775a92
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=84dca32c51e9f70b20515afd304826091c775a92

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Wed Jun  9 10:26:14 2021 +0200

vbo: delay vbo_exec_vtx_map call

Instead of doing vbo_exec_vtx_map during initialization,
defer it until the first actual user.

v2: move init to vbo_exec_wrap_upgrade_vertex (Emma Anholt)

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11296>

---

 src/mesa/vbo/vbo_exec_api.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 4f19dbe781f..6b61b739289 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -268,6 +268,13 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
 
    assert(attr < VBO_ATTRIB_MAX);
 
+   if (unlikely(!exec->vtx.buffer_ptr)) {
+      /* We should only hit this when use_buffer_objects=true */
+      assert(exec->vtx.bufferobj);
+      vbo_exec_vtx_map(exec);
+      assert(exec->vtx.buffer_ptr);
+   }
+
    /* Run pipeline on current vertices, copy wrapped vertices
     * to exec->vtx.copied.
     */
@@ -488,7 +495,6 @@ do {                                                                    \
    int sz = (sizeof(C) / sizeof(GLfloat));                              \
                                                                         \
    assert(sz == 1 || sz == 2);                                          \
-                                                                        \
    /* store a copy of the attribute in exec except for glVertex */      \
    if ((A) != 0) {                                                      \
       /* Check if attribute size or type is changing. */                \
@@ -1031,12 +1037,7 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec, bool use_buffer_objects)
    if (use_buffer_objects) {
       /* Use buffer objects for immediate mode. */
       struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
-
       exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, IMM_BUFFER_NAME);
-
-      /* Map the buffer. */
-      vbo_exec_vtx_map(exec);
-      assert(exec->vtx.buffer_ptr);
    } else {
       /* Use allocated memory for immediate mode. */
       exec->vtx.bufferobj = NULL;



More information about the mesa-commit mailing list