From c30eff59868f6d07d6a651090dc252973b8cdf3e Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Fri, 24 Jan 2025 00:08:29 -0300 Subject: [PATCH] Fix performance regression introduced in #90993 PR #90993 needed to get rid of VMA_MEMORY_USAGE_AUTO_PREFER_HOST because we no longer used vmaCreateBuffer so we could specify the allocation callbacks. This however resulted in the wrong memory pool being chosen, causing signficant performance slowdown. Indicate additional preferred flags to help VMA select the proper pool. Fixes #101905 --- drivers/vulkan/rendering_device_driver_vulkan.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 45c574914d6..f46015f1fc3 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -1530,10 +1530,12 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie if (is_src && !is_dst) { // Looks like a staging buffer: CPU maps, writes sequentially, then GPU copies to VRAM. alloc_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT; + alloc_create_info.preferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; } if (is_dst && !is_src) { // Looks like a readback buffer: GPU copies from VRAM, then CPU maps and reads. alloc_create_info.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT; + alloc_create_info.preferredFlags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT; } alloc_create_info.requiredFlags = (VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); } break;