Module: Mesa Branch: master Commit: 708327472b95dae7bf2ce0585637e22c653fb344 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=708327472b95dae7bf2ce0585637e22c653fb344
Author: Erik Faye-Lund <[email protected]> Date: Wed Feb 3 17:22:29 2021 +0100 zink: do not use extra staging resource unless needed The reason we check for staging-resources here is really because they are the only images guaranteed to be host-visible. But on UMA architectures, it's quite likely to have memory that is *both* host-visible *and* device-local, so let's see what we found instead. Reviewed-By: Mike Blumenkrantz <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8858> --- src/gallium/drivers/zink/zink_resource.c | 9 ++++++++- src/gallium/drivers/zink/zink_resource.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index a72445bd4e9..867e1ae49ab 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -298,6 +298,13 @@ resource_create(struct pipe_screen *pscreen, mai.allocationSize = reqs.size; mai.memoryTypeIndex = get_memory_type_index(screen, &reqs, flags); + if (templ->target != PIPE_BUFFER) { + VkMemoryType mem_type = + screen->info.mem_props.memoryTypes[mai.memoryTypeIndex]; + res->host_visible = mem_type.propertyFlags & + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + } + VkExportMemoryAllocateInfo emai = {}; if (templ->bind & PIPE_BIND_SHARED) { emai.sType = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO; @@ -589,7 +596,7 @@ zink_transfer_map(struct pipe_context *pctx, trans->base.layer_stride = 0; ptr = ((uint8_t *)ptr) + box->x; } else { - if (res->optimal_tiling || (res->base.usage != PIPE_USAGE_STAGING)) { + if (res->optimal_tiling || !res->host_visible) { enum pipe_format format = pres->format; if (usage & PIPE_MAP_DEPTH_ONLY) format = util_format_get_depth_only(pres->format); diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h index ab90ccb44c6..d113f801b3d 100644 --- a/src/gallium/drivers/zink/zink_resource.h +++ b/src/gallium/drivers/zink/zink_resource.h @@ -52,6 +52,7 @@ struct zink_resource { VkImageLayout layout; VkImageAspectFlags aspect; bool optimal_tiling; + bool host_visible; }; }; VkDeviceMemory mem; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
