Mesa (main): freedreno: Use staging transfer if mmap fails

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 27 23:33:33 UTC 2022


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Wed Apr 20 10:07:14 2022 -0700

freedreno: Use staging transfer if mmap fails

With externaly imported resources, we can have situations where we can't
mmap and directly access linear buffers.  So use the staging blit path
for this case.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16086>

---

 src/gallium/drivers/freedreno/freedreno_resource.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 78ea44079c9..8bbaaf87243 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -790,6 +790,16 @@ resource_transfer_map_unsync(struct pipe_context *pctx,
    char *buf;
 
    buf = fd_bo_map(rsc->bo);
+
+   /* With imported bo's allocated by something outside of mesa, when
+    * running in a VM (using virtio_gpu kernel driver) we could end up in
+    * a situation where we have a linear bo, but are unable to mmap it
+    * because it was allocated without the VIRTGPU_BLOB_FLAG_USE_MAPPABLE
+    * flag.  So we need end up needing to do a staging blit instead:
+    */
+   if (!buf)
+      return resource_transfer_map_staging(pctx, prsc, level, usage, box, trans);
+
    offset = box->y / util_format_get_blockheight(format) * trans->b.b.stride +
             box->x / util_format_get_blockwidth(format) * rsc->layout.cpp +
             fd_resource_offset(rsc, level, box->z);



More information about the mesa-commit mailing list