From 7426889729c8efc7b2c90dcecd3cdbd361dabd26 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 20 Feb 2024 16:23:39 -0500 Subject: [PATCH] zink: force host-visible allocations for MAP_COHERENT resources this fixes persistent maps for systems without any BAR cc: mesa-stable Part-of: (cherry picked from commit ccbf9b0ea7aec6559f8eb872d2da2984c2115453) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_resource.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 18de5953882..1c5bea6a44b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2104,7 +2104,7 @@ "description": "zink: force host-visible allocations for MAP_COHERENT resources", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index 0c692cff6e9..14f4e34351b 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -1181,6 +1181,10 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t mai.pNext = NULL; mai.allocationSize = reqs.size; enum zink_heap heap = zink_heap_from_domain_flags(flags, aflags); + if (templ->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) { + if (!(vk_domain_from_heap(heap) & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) + heap = zink_heap_from_domain_flags(flags & ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, aflags); + } VkMemoryDedicatedAllocateInfo ded_alloc_info = { .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,