Mesa (main): gallium/u_vbuf: add a fast path to skip refcounting for uploaded user buffers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 27 02:11:22 UTC 2021
Module: Mesa
Branch: main
Commit: b8d59e68beb27b1308d726c2e515b23e87e47f79
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8d59e68beb27b1308d726c2e515b23e87e47f79
Author: Marek Olšák <marek.olsak at amd.com>
Date: Tue May 25 14:55:42 2021 -0400
gallium/u_vbuf: add a fast path to skip refcounting for uploaded user buffers
This improves performance by 23% with radeonsi and Ryzen 3900X running
the game torcs.
All vertex buffers must be user buffers to get this.
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10992>
---
src/gallium/auxiliary/util/u_vbuf.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index af6f56e4ac3..02a6ba00300 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -1271,8 +1271,25 @@ static void u_vbuf_set_driver_vertex_buffers(struct u_vbuf *mgr)
start_slot = ffs(mgr->dirty_real_vb_mask) - 1;
count = util_last_bit(mgr->dirty_real_vb_mask >> start_slot);
- pipe->set_vertex_buffers(pipe, start_slot, count, 0, false,
- mgr->real_vertex_buffer + start_slot);
+ if (mgr->dirty_real_vb_mask == mgr->enabled_vb_mask &&
+ mgr->dirty_real_vb_mask == mgr->user_vb_mask) {
+ /* Fast path that allows us to transfer the VBO references to the driver
+ * to skip atomic reference counting there. These are freshly uploaded
+ * user buffers that can be discarded after this call.
+ */
+ pipe->set_vertex_buffers(pipe, start_slot, count, 0, true,
+ mgr->real_vertex_buffer + start_slot);
+
+ /* We don't own the VBO references now. Set them to NULL. */
+ for (unsigned i = 0; i < count; i++) {
+ assert(!mgr->real_vertex_buffer[start_slot + i].is_user_buffer);
+ mgr->real_vertex_buffer[start_slot + i].buffer.resource = NULL;
+ }
+ } else {
+ /* Slow path where we have to keep VBO references. */
+ pipe->set_vertex_buffers(pipe, start_slot, count, 0, false,
+ mgr->real_vertex_buffer + start_slot);
+ }
mgr->dirty_real_vb_mask = 0;
}
More information about the mesa-commit
mailing list