Mesa (staging/22.0): zink: handle device-local unsynchronized maps

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 22:22:07 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: b3cf66f34342709815871a831c9abb79b6c67f37
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b3cf66f34342709815871a831c9abb79b6c67f37

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Apr 15 13:25:00 2022 -0400

zink: handle device-local unsynchronized maps

this is only possible when tc determines the buffer is not in use
and decides to return a pointer immediately, so just give back a staging
buffer

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15979>
(cherry picked from commit d7256043b3ac3652a070ed0384db80effc99ed96)

---

 .pick_status.json                        | 2 +-
 src/gallium/drivers/zink/zink_resource.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index f31c86c8284..5b13c019a54 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -340,7 +340,7 @@
         "description": "zink: handle device-local unsynchronized maps",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "because_sha": null
     },
     {
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index a44089a7281..cb6b1e0e077 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -1490,6 +1490,15 @@ zink_buffer_map(struct pipe_context *pctx,
          ptr = map_resource(screen, res);
          ptr = ((uint8_t *)ptr) + trans->offset;
       }
+   } else if ((usage & PIPE_MAP_UNSYNCHRONIZED) && !res->obj->host_visible) {
+      trans->offset = box->x % screen->info.props.limits.minMemoryMapAlignment;
+      trans->staging_res = pipe_buffer_create(&screen->base, PIPE_BIND_LINEAR, PIPE_USAGE_STAGING, box->width + trans->offset);
+      if (!trans->staging_res)
+         goto fail;
+      struct zink_resource *staging_res = zink_resource(trans->staging_res);
+      res = staging_res;
+      ptr = map_resource(screen, res);
+      ptr = ((uint8_t *)ptr) + trans->offset;
    }
 
    if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) {



More information about the mesa-commit mailing list