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 <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8858>
This commit is contained in:
Erik Faye-Lund
2021-02-03 17:22:29 +01:00
committed by Marge Bot
parent 5e4ae3466b
commit 708327472b
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -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);
+1
View File
@@ -52,6 +52,7 @@ struct zink_resource {
VkImageLayout layout;
VkImageAspectFlags aspect;
bool optimal_tiling;
bool host_visible;
};
};
VkDeviceMemory mem;