Mesa (main): zink: change a bunch of sparse buffer resource checks to host-visible checks

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 17 01:17:17 UTC 2021


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu May  6 09:51:02 2021 -0400

zink: change a bunch of sparse buffer resource checks to host-visible checks

(sparse buffer) is a subset of !host-visible, and !host-visible is actually the
more correct check to be using

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11397>

---

 src/gallium/drivers/zink/zink_resource.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index 9dbc7c49754..c612773a3ed 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -844,7 +844,7 @@ map_resource(struct zink_screen *screen, struct zink_resource *res)
    VkResult result = VK_SUCCESS;
    if (res->obj->map)
       return res->obj->map;
-   assert(!(res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE));
+   assert(res->obj->host_visible);
    result = vkMapMemory(screen->dev, res->obj->mem, res->obj->offset,
                         res->obj->size, 0, &res->obj->map);
    return result == VK_SUCCESS ? res->obj->map : NULL;
@@ -895,13 +895,13 @@ buffer_transfer_map(struct zink_context *ctx, struct zink_resource *res, unsigne
 
    if ((usage & PIPE_MAP_WRITE) &&
        (usage & PIPE_MAP_DISCARD_RANGE || (!(usage & PIPE_MAP_READ) && zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_RW))) &&
-       ((res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE) || !(usage & (PIPE_MAP_UNSYNCHRONIZED | PIPE_MAP_PERSISTENT)))) {
+       ((!res->obj->host_visible) || !(usage & (PIPE_MAP_UNSYNCHRONIZED | PIPE_MAP_PERSISTENT)))) {
 
       /* Check if mapping this buffer would cause waiting for the GPU.
        */
 
       uint32_t latest_access = get_most_recent_access(res, ZINK_RESOURCE_ACCESS_RW);
-      if (res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE ||
+      if (!res->obj->host_visible ||
           zink_resource_has_curr_read_usage(ctx, res) ||
           (latest_access && !zink_check_batch_completion(ctx, latest_access))) {
          /* Do a wait-free write-only transfer using a temporary buffer. */
@@ -929,15 +929,15 @@ buffer_transfer_map(struct zink_context *ctx, struct zink_resource *res, unsigne
       assert(!(usage & (TC_TRANSFER_MAP_THREADED_UNSYNC | PIPE_MAP_THREAD_SAFE)));
       uint32_t latest_write = get_most_recent_access(res, ZINK_RESOURCE_ACCESS_WRITE);
       if (usage & PIPE_MAP_DONTBLOCK) {
-         /* sparse will always need to wait since it has to copy */
-         if (res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE)
+         /* sparse/device-local will always need to wait since it has to copy */
+         if (!res->obj->host_visible)
             return NULL;
          if (latest_write &&
              (latest_write == ctx->curr_batch || !zink_check_batch_completion(ctx, latest_write)))
             return NULL;
          latest_write = 0;
       }
-      if (res->base.b.flags & PIPE_RESOURCE_FLAG_SPARSE) {
+      if (!res->obj->host_visible) {
          zink_fence_wait(&ctx->base);
          trans->staging_res = pipe_buffer_create(&screen->base, PIPE_BIND_LINEAR, PIPE_USAGE_STAGING, box->x + box->width);
          if (!trans->staging_res)



More information about the mesa-commit mailing list