From 86c124c7728c262ffc0768441502eaf6567b4950 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Sat, 26 Feb 2022 11:49:51 +0100 Subject: [PATCH] VMA_MEMORY_USAGE_AUTO* flags: Added support for rare case when a resource used on the device, not used on the host, may still be preferred in host memory An update in the documentation. --- include/vk_mem_alloc.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index 297dccb..c596e76 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -600,7 +600,7 @@ typedef enum VmaAllocationCreateFlagBits This includes allocations created in \ref custom_memory_pools. Declares that mapped memory can be read, written, and accessed in random order, - so a `HOST_CACHED` memory type is preferred. + so a `HOST_CACHED` memory type is required. */ VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT = 0x00000800, /** @@ -3639,7 +3639,11 @@ static bool FindMemoryPreferences( // GPU access, no CPU access (e.g. a color attachment image) - prefer GPU memory if(deviceAccess) { - outPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + // ...unless there is a clear preference from the user not to do so. + if(preferHost) + outNotPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + else + outPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; } // No direct GPU access, no CPU access, just transfers. // It may be staging copy intended for e.g. preserving image for next frame (then better GPU memory) or