Mesa (main): iris: Map scanout buffers WC instead of WB [v2]

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 31 21:15:35 UTC 2021


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

Author: Keith Packard <keithp at keithp.com>
Date:   Fri Aug  6 16:11:18 2021 -0700

iris: Map scanout buffers WC instead of WB [v2]

The scanout engine is not coherent with rendering, so make sure
scanout buffers are mapped WC. This ensures that CPU rendering as done
by the Xserver gets flushed to the frame buffer immediately instead of
waiting for some future time.

v2:
    Also mark shared buffers to be allocated for scanout
    in case they are being used for scanout elsewhere.

Signed-off-by: Keith Packard <keithp at keithp.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5231
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12259>

---

 src/gallium/drivers/iris/iris_bufmgr.c   | 3 ++-
 src/gallium/drivers/iris/iris_bufmgr.h   | 1 +
 src/gallium/drivers/iris/iris_resource.c | 6 ++++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 437aa589a86..a8e2ab73cfc 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -617,8 +617,9 @@ iris_bo_alloc(struct iris_bufmgr *bufmgr,
    bool is_coherent = bufmgr->has_llc ||
                       (bufmgr->vram.size > 0 && !local) ||
                       (flags & BO_ALLOC_COHERENT);
+   bool is_scanout = (flags & BO_ALLOC_SCANOUT) != 0;
    enum iris_mmap_mode mmap_mode =
-      !local && is_coherent ? IRIS_MMAP_WB : IRIS_MMAP_WC;
+      !local && is_coherent && !is_scanout ? IRIS_MMAP_WB : IRIS_MMAP_WC;
 
    simple_mtx_lock(&bufmgr->lock);
 
diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h
index 1f43456bae4..700636f9007 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.h
+++ b/src/gallium/drivers/iris/iris_bufmgr.h
@@ -247,6 +247,7 @@ struct iris_bo {
 #define BO_ALLOC_ZEROED     (1<<0)
 #define BO_ALLOC_COHERENT   (1<<1)
 #define BO_ALLOC_SMEM       (1<<2)
+#define BO_ALLOC_SCANOUT    (1<<3)
 
 /**
  * Allocate a buffer object.
diff --git a/src/gallium/drivers/iris/iris_resource.c b/src/gallium/drivers/iris/iris_resource.c
index 18a8f842f56..56c5f4c19ea 100644
--- a/src/gallium/drivers/iris/iris_resource.c
+++ b/src/gallium/drivers/iris/iris_resource.c
@@ -430,6 +430,12 @@ iris_resource_alloc_flags(const struct iris_screen *screen,
       break;
    }
 
+   /* Scanout and shared buffers need to be WC (shared because they might be
+    * used for scanout)
+    */
+   if (templ->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_SHARED))
+      flags |= BO_ALLOC_SCANOUT;
+
    if (templ->flags & (PIPE_RESOURCE_FLAG_MAP_COHERENT |
                        PIPE_RESOURCE_FLAG_MAP_PERSISTENT))
       flags |= BO_ALLOC_SMEM;



More information about the mesa-commit mailing list