zink: check for cached mem correctly when mapping buffer
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 7 Jun 2023 12:48:19 +0000 (08:48 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 8 Jun 2023 14:30:39 +0000 (14:30 +0000)
bo placement is the mem index, not the mem flags

Fixes: 52f27cda05b ("zink: allow direct memory mapping for any COHERENT+CACHED buffer")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23511>

src/gallium/drivers/zink/zink_resource.c

index 8cf5304..4046996 100644 (file)
@@ -1978,7 +1978,7 @@ zink_buffer_map(struct pipe_context *pctx,
       usage |= PIPE_MAP_UNSYNCHRONIZED;
    } else if (!(usage & PIPE_MAP_UNSYNCHRONIZED) &&
               (((usage & PIPE_MAP_READ) && !(usage & PIPE_MAP_PERSISTENT) &&
-               ((res->obj->bo->base.placement & VK_STAGING_RAM) != VK_STAGING_RAM)) ||
+               ((screen->info.mem_props.memoryTypes[res->obj->bo->base.placement].propertyFlags & VK_STAGING_RAM) != VK_STAGING_RAM)) ||
               !res->obj->host_visible)) {
       /* the above conditional catches uncached reads and non-HV writes */
       assert(!(usage & (TC_TRANSFER_MAP_THREADED_UNSYNC)));