From 30de94b91d7cae48cc60750206ded83a01f8342f Mon Sep 17 00:00:00 2001 From: Sid Pranjale Date: Fri, 28 Mar 2025 01:25:11 +0530 Subject: [PATCH] vulkan/wsi: add cached bit to wsi host memory selection Reviewed-by: Lionel Landwerlin Part-of: --- src/vulkan/wsi/wsi_common.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 6689b323ac0..8276717290b 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -1770,6 +1770,12 @@ wsi_select_memory_type(const struct wsi_device *wsi, return wsi_select_memory_type(wsi, req_props, deny_props, type_bits); } + if (req_props & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) { + req_props &= ~VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + // fallback to coherent if cached-coherent is requested but not found + return wsi_select_memory_type(wsi, req_props, deny_props, type_bits); + } + unreachable("No memory type found"); } @@ -1785,8 +1791,12 @@ static uint32_t wsi_select_host_memory_type(const struct wsi_device *wsi, uint32_t type_bits) { - return wsi_select_memory_type(wsi, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, - 0 /* deny_props */, type_bits); + VkMemoryPropertyFlags req_props = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + + if (wsi->sw) + req_props |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + + return wsi_select_memory_type(wsi, req_props, 0 /* deny_props */, type_bits); } VkResult