Mesa (master): gallium/pipebuffer: Use persistent maps for slabs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 29 14:05:08 UTC 2020


Module: Mesa
Branch: master
Commit: 422148de52fc57f9f33e632883400fff49b3ad9d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=422148de52fc57f9f33e632883400fff49b3ad9d

Author: Thomas Hellstrom <thellstrom at vmware.com>
Date:   Wed Apr 22 13:27:35 2020 +0200

gallium/pipebuffer: Use persistent maps for slabs

Instead of the ugly practice of relying on the provider caching maps,
introduce and use persistent pipebuffer maps. Providers that can't handle
persistent maps can't use the slab manager.

The only current user is the svga drm winsys which always maps
persistently.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
Reviewed-by: Charmaine Lee <charmainel at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4804>

---

 src/gallium/auxiliary/pipebuffer/pb_buffer.h      | 8 +++++++-
 src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 8 +++++---
 src/gallium/winsys/svga/drm/vmw_buffer.c          | 2 ++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index bd60eba1432..9c71fc86c9c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -66,6 +66,11 @@ enum pb_usage_flags {
    PB_USAGE_GPU_WRITE = (1 << 3),
    PB_USAGE_DONTBLOCK = (1 << 9),
    PB_USAGE_UNSYNCHRONIZED = (1 << 10),
+   /* Persistent mappings may remain across a flush. Note that contrary
+    * to OpenGL persistent maps, there is no requirement at the pipebuffer
+    * api level to explicitly enforce coherency by barriers or range flushes.
+    */
+   PB_USAGE_PERSISTENT = (1 << 13)
 };
 
 /* For error checking elsewhere */
@@ -74,7 +79,8 @@ enum pb_usage_flags {
                       PB_USAGE_GPU_READ | \
                       PB_USAGE_GPU_WRITE | \
                       PB_USAGE_DONTBLOCK | \
-                      PB_USAGE_UNSYNCHRONIZED)
+                      PB_USAGE_UNSYNCHRONIZED | \
+                      PB_USAGE_PERSISTENT)
 
 #define PB_USAGE_CPU_READ_WRITE  (PB_USAGE_CPU_READ | PB_USAGE_CPU_WRITE)
 #define PB_USAGE_GPU_READ_WRITE  (PB_USAGE_GPU_READ | PB_USAGE_GPU_WRITE)
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index dd59733fe9b..c936096210a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -215,6 +215,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
    if (slab->numFree == slab->numBuffers) {
       list = &slab->head;
       list_delinit(list);
+      pb_unmap(slab->bo);
       pb_reference(&slab->bo, NULL);
       FREE(slab->buffers);
       FREE(slab);
@@ -315,15 +316,16 @@ pb_slab_create(struct pb_slab_manager *mgr)
    }
 
    /* Note down the slab virtual address. All mappings are accessed directly 
-    * through this address so it is required that the buffer is pinned. */
+    * through this address so it is required that the buffer is mapped
+    * persistent */
    slab->virtual = pb_map(slab->bo, 
                           PB_USAGE_CPU_READ |
-                          PB_USAGE_CPU_WRITE, NULL);
+                          PB_USAGE_CPU_WRITE |
+                          PB_USAGE_PERSISTENT, NULL);
    if(!slab->virtual) {
       ret = PIPE_ERROR_OUT_OF_MEMORY;
       goto out_err1;
    }
-   pb_unmap(slab->bo);
 
    numBuffers = slab->bo->size / mgr->bufSize;
 
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c
index 34c5e341782..e2ddf78ed2e 100644
--- a/src/gallium/winsys/svga/drm/vmw_buffer.c
+++ b/src/gallium/winsys/svga/drm/vmw_buffer.c
@@ -364,6 +364,8 @@ vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
                  (unsigned) PIPE_TRANSFER_DONTBLOCK);
    STATIC_ASSERT((unsigned) PB_USAGE_UNSYNCHRONIZED ==
                  (unsigned) PIPE_TRANSFER_UNSYNCHRONIZED);
+   STATIC_ASSERT((unsigned) PB_USAGE_PERSISTENT ==
+                 (unsigned) PIPE_TRANSFER_PERSISTENT);
 
    map = pb_map(vmw_pb_buffer(buf), flags & PB_USAGE_ALL, NULL);
 



More information about the mesa-commit mailing list