Skip to content

Commit 86c124c

Browse files
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.
1 parent 75446de commit 86c124c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

include/vk_mem_alloc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ typedef enum VmaAllocationCreateFlagBits
600600
This includes allocations created in \ref custom_memory_pools.
601601

602602
Declares that mapped memory can be read, written, and accessed in random order,
603-
so a `HOST_CACHED` memory type is preferred.
603+
so a `HOST_CACHED` memory type is required.
604604
*/
605605
VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT = 0x00000800,
606606
/**
@@ -3639,7 +3639,11 @@ static bool FindMemoryPreferences(
36393639
// GPU access, no CPU access (e.g. a color attachment image) - prefer GPU memory
36403640
if(deviceAccess)
36413641
{
3642-
outPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
3642+
// ...unless there is a clear preference from the user not to do so.
3643+
if(preferHost)
3644+
outNotPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
3645+
else
3646+
outPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
36433647
}
36443648
// No direct GPU access, no CPU access, just transfers.
36453649
// It may be staging copy intended for e.g. preserving image for next frame (then better GPU memory) or

0 commit comments

Comments
 (0)