zink: rejigger PIPE_MAP_ONCE for internal qbo reads
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 30 Jul 2021 15:34:40 +0000 (11:34 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 17 Aug 2021 19:40:27 +0000 (19:40 +0000)
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@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12410>

src/gallium/drivers/zink/zink_query.c
src/gallium/drivers/zink/zink_resource.c

index b30bf2c..cdfb15f 100644 (file)
@@ -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;
index 3bef1b2..8aa21c0 100644 (file)
@@ -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)) {