Mesa (main): zink: rejigger PIPE_MAP_ONCE for internal qbo reads

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 17 19:59:56 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Jul 30 11:34:40 2021 -0400

zink: rejigger PIPE_MAP_ONCE for internal qbo reads

DONTBLOCK is only used internally for this case, and promoting it over
the staging buffer case ensures that it's always reached when it should be

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>

---

 src/gallium/drivers/zink/zink_query.c    |  2 +-
 src/gallium/drivers/zink/zink_resource.c | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_query.c b/src/gallium/drivers/zink/zink_query.c
index b30bf2c767d..cdfb15f3c50 100644
--- a/src/gallium/drivers/zink/zink_query.c
+++ b/src/gallium/drivers/zink/zink_query.c
@@ -428,7 +428,7 @@ get_query_result(struct pipe_context *pctx,
 {
    struct zink_screen *screen = zink_screen(pctx->screen);
    struct zink_query *query = (struct zink_query *)q;
-   unsigned flags = PIPE_MAP_READ | PIPE_MAP_ONCE;
+   unsigned flags = PIPE_MAP_READ;
 
    if (!wait)
       flags |= PIPE_MAP_DONTBLOCK;
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 3bef1b228c1..8aa21c0cef5 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -1136,6 +1136,13 @@ buffer_transfer_map(struct zink_context *ctx, struct zink_resource *res, unsigne
          /* At this point, the buffer is always idle (we checked it above). */
          usage |= PIPE_MAP_UNSYNCHRONIZED;
       }
+   } else if (usage & PIPE_MAP_DONTBLOCK) {
+      /* sparse/device-local will always need to wait since it has to copy */
+      if (!res->obj->host_visible)
+         return NULL;
+      if (!zink_resource_usage_check_completion(screen, res, ZINK_RESOURCE_ACCESS_WRITE))
+         return NULL;
+      usage |= PIPE_MAP_UNSYNCHRONIZED;
    } else if (!(usage & PIPE_MAP_UNSYNCHRONIZED) &&
               (((usage & PIPE_MAP_READ) && !(usage & PIPE_MAP_PERSISTENT) && res->base.b.usage != PIPE_USAGE_STAGING) || !res->obj->host_visible)) {
       assert(!(usage & (TC_TRANSFER_MAP_THREADED_UNSYNC | PIPE_MAP_THREAD_SAFE)));
@@ -1151,13 +1158,6 @@ buffer_transfer_map(struct zink_context *ctx, struct zink_resource *res, unsigne
          ptr = map_resource(screen, res);
          ptr = ((uint8_t *)ptr) + trans->offset;
       }
-   } else if (usage & PIPE_MAP_DONTBLOCK) {
-      /* sparse/device-local will always need to wait since it has to copy */
-      if (!res->obj->host_visible)
-         return NULL;
-      if (!zink_resource_usage_check_completion(screen, res, ZINK_RESOURCE_ACCESS_WRITE))
-         return NULL;
-      usage |= PIPE_MAP_UNSYNCHRONIZED;
    }
 
    if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) {



More information about the mesa-commit mailing list