diff --git a/CHANGELOG.md b/CHANGELOG.md
index 47c8cf6..0c438d6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ Additions to the library API:
- Added callback `VmaDefragmentationInfo::pfnBreakCallback` that allows breaking long execution of `vmaBeginDefragmentation`.
Also added `PFN_vmaCheckDefragmentationBreakFunction`, `VmaDefragmentationInfo::pBreakCallbackUserData`.
- Added support for VK_KHR_maintenance4 extension - `VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE4_BIT` flag (#397).
+- Added support for VK_KHR_maintenance5 extension - `VMA_ALLOCATOR_CREATE_KHR_MAINTENANCE5_BIT` flag (#411).
Other changes:
diff --git a/Doxyfile b/Doxyfile
index 7d6534d..99b96fe 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -2459,8 +2459,14 @@ PREDEFINED = VMA_CALL_PRE= \
VMA_NOT_NULL_NON_DISPATCHABLE= \
VMA_NULLABLE_NON_DISPATCHABLE= \
VMA_VULKAN_VERSION=1003000 \
- VMA_EXTERNAL_MEMORY=1 \
+ VMA_DEDICATED_ALLOCATION=1 \
+ VMA_BIND_MEMORY2=1 \
+ VMA_MEMORY_BUDGET=1 \
+ VMA_BUFFER_DEVICE_ADDRESS=1 \
VMA_MEMORY_PRIORITY=1 \
+ VMA_KHR_MAINTENANCE4=1 \
+ VMA_KHR_MAINTENANCE5=1 \
+ VMA_EXTERNAL_MEMORY=1 \
VMA_EXTENDS_VK_STRUCT= \
VMA_STATS_STRING_ENABLED=1
diff --git a/README.md b/README.md
index 7f27077..5ce8d63 100644
--- a/README.md
+++ b/README.md
@@ -51,10 +51,13 @@ Additional features:
- Support for Vulkan 1.0, 1.1, 1.2, 1.3.
- Support for extensions (and equivalent functionality included in new Vulkan versions):
- VK_KHR_dedicated_allocation: Just enable it and it will be used automatically by the library.
- - VK_KHR_buffer_device_address: Flag `VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR` is automatically added to memory allocations where needed.
+ - VK_KHR_bind_memory2.
+ - VK_KHR_maintenance4.
+ - VK_KHR_maintenance5, including `VkBufferUsageFlags2CreateInfoKHR`.
- VK_EXT_memory_budget: Used internally if available to query for current usage and budget. If not available, it falls back to an estimation based on memory heap sizes.
+ - VK_KHR_buffer_device_address: Flag `VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR` is automatically added to memory allocations where needed.
- VK_EXT_memory_priority: Set `priority` of allocations or custom pools and it will be set automatically using this extension.
- - VK_AMD_device_coherent_memory
+ - VK_AMD_device_coherent_memory.
- Defragmentation of GPU and CPU memory: Let the library move data around to free some memory blocks and make your allocations better compacted.
- Statistics: Obtain brief or detailed statistics about the amount of memory used, unused, number of allocated blocks, number of allocations etc. - globally, per memory heap, and per memory type.
- Debug annotations: Associate custom `void* pUserData` and debug `char* pName` with each allocation.
diff --git a/docs/html/allocation_annotation.html b/docs/html/allocation_annotation.html
index 766b381..a068ad3 100644
--- a/docs/html/allocation_annotation.html
+++ b/docs/html/allocation_annotation.html
@@ -93,18 +93,18 @@ Allocation user data
vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buffer, &allocation,
nullptr);
VkResult vmaCreateBuffer(VmaAllocator allocator, const VkBufferCreateInfo *pBufferCreateInfo, const VmaAllocationCreateInfo *pAllocationCreateInfo, VkBuffer *pBuffer, VmaAllocation *pAllocation, VmaAllocationInfo *pAllocationInfo)
Creates a new VkBuffer, allocates and binds memory for it.
-@ VMA_MEMORY_USAGE_AUTO
Definition vk_mem_alloc.h:511
-Parameters of new VmaAllocation.
Definition vk_mem_alloc.h:1246
-void * pUserData
Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...
Definition vk_mem_alloc.h:1285
-VmaMemoryUsage usage
Intended usage of memory.
Definition vk_mem_alloc.h:1254
+@ VMA_MEMORY_USAGE_AUTO
Definition vk_mem_alloc.h:527
+Parameters of new VmaAllocation.
Definition vk_mem_alloc.h:1263
+void * pUserData
Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...
Definition vk_mem_alloc.h:1302
+VmaMemoryUsage usage
Intended usage of memory.
Definition vk_mem_alloc.h:1271
Represents single memory allocation.
The pointer may be later retrieved as VmaAllocationInfo::pUserData:
MyBufferMetadata* pMetadata = (MyBufferMetadata*)allocInfo.
pUserData;
void vmaGetAllocationInfo(VmaAllocator allocator, VmaAllocation allocation, VmaAllocationInfo *pAllocationInfo)
Returns current information about specified allocation.
-
Definition vk_mem_alloc.h:1365
-
void * pUserData
Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...
Definition vk_mem_alloc.h:1412
+
Definition vk_mem_alloc.h:1382
+
void * pUserData
Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...
Definition vk_mem_alloc.h:1429
It can also be changed using function vmaSetAllocationUserData().
Values of (non-zero) allocations' pUserData
are printed in JSON report created by vmaBuildStatsString() in hexadecimal form.
diff --git a/docs/html/choosing_memory_type.html b/docs/html/choosing_memory_type.html
index 073bcab..bb61e67 100644
--- a/docs/html/choosing_memory_type.html
+++ b/docs/html/choosing_memory_type.html
@@ -103,9 +103,9 @@ Usage
vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation,
nullptr);
VkResult vmaCreateBuffer(VmaAllocator allocator, const VkBufferCreateInfo *pBufferCreateInfo, const VmaAllocationCreateInfo *pAllocationCreateInfo, VkBuffer *pBuffer, VmaAllocation *pAllocation, VmaAllocationInfo *pAllocationInfo)
Creates a new VkBuffer, allocates and binds memory for it.
-@ VMA_MEMORY_USAGE_AUTO
Definition vk_mem_alloc.h:511
-Parameters of new VmaAllocation.
Definition vk_mem_alloc.h:1246
-VmaMemoryUsage usage
Intended usage of memory.
Definition vk_mem_alloc.h:1254
+@ VMA_MEMORY_USAGE_AUTO
Definition vk_mem_alloc.h:527
+Parameters of new VmaAllocation.
Definition vk_mem_alloc.h:1263
+VmaMemoryUsage usage
Intended usage of memory.
Definition vk_mem_alloc.h:1271
Represents single memory allocation.
If you have a preference for putting the resource in GPU (device) memory or CPU (host) memory on systems with discrete graphics card that have the memories separate, you can use VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE or VMA_MEMORY_USAGE_AUTO_PREFER_HOST.
When using VMA_MEMORY_USAGE_AUTO*
while you want to map the allocated memory, you also need to specify one of the host access flags: VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT or VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT. This will help the library decide about preferred memory type to ensure it has VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
so you can map it.
@@ -121,8 +121,8 @@ Usage
VkBuffer stagingBuffer;
vmaCreateBuffer(allocator, &stagingBufferInfo, &stagingAllocInfo, &stagingBuffer, &stagingAllocation,
nullptr);
-@ VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT
Definition vk_mem_alloc.h:620
-VmaAllocationCreateFlags flags
Use VmaAllocationCreateFlagBits enum.
Definition vk_mem_alloc.h:1248
+@ VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT
Definition vk_mem_alloc.h:636
+VmaAllocationCreateFlags flags
Use VmaAllocationCreateFlagBits enum.
Definition vk_mem_alloc.h:1265
For more examples of creating different kinds of resources, see chapter Recommended usage patterns. See also: Memory mapping.
Usage values VMA_MEMORY_USAGE_AUTO*
are legal to use only when the library knows about the resource being created by having VkBufferCreateInfo
/ VkImageCreateInfo
passed, so they work with functions like: vmaCreateBuffer(), vmaCreateImage(), vmaFindMemoryTypeIndexForBufferInfo() etc. If you allocate raw memory using function vmaAllocateMemory(), you have to use other means of selecting memory type, as described below.
- Note
- Old usage values (
VMA_MEMORY_USAGE_GPU_ONLY
, VMA_MEMORY_USAGE_CPU_ONLY
, VMA_MEMORY_USAGE_CPU_TO_GPU
, VMA_MEMORY_USAGE_GPU_TO_CPU
, VMA_MEMORY_USAGE_CPU_COPY
) are still available and work same way as in previous versions of the library for backward compatibility, but they are deprecated.
@@ -137,10 +137,10 @@ Required and preferred flags
VkBuffer buffer;
vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation,
nullptr);
-@ VMA_ALLOCATION_CREATE_MAPPED_BIT
Set this flag to use a memory that will be persistently mapped and retrieve pointer to it.
Definition vk_mem_alloc.h:571
-@ VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT
Definition vk_mem_alloc.h:632
-VkMemoryPropertyFlags preferredFlags
Flags that preferably should be set in a memory type chosen for an allocation.
Definition vk_mem_alloc.h:1264
-VkMemoryPropertyFlags requiredFlags
Flags that must be set in a Memory Type chosen for an allocation.
Definition vk_mem_alloc.h:1259
+@ VMA_ALLOCATION_CREATE_MAPPED_BIT
Set this flag to use a memory that will be persistently mapped and retrieve pointer to it.
Definition vk_mem_alloc.h:587
+@ VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT
Definition vk_mem_alloc.h:648
+VkMemoryPropertyFlags preferredFlags
Flags that preferably should be set in a memory type chosen for an allocation.
Definition vk_mem_alloc.h:1281
+VkMemoryPropertyFlags requiredFlags
Flags that must be set in a Memory Type chosen for an allocation.
Definition vk_mem_alloc.h:1276
A memory type is chosen that has all the required flags and as many preferred flags set as possible.
Value passed in VmaAllocationCreateInfo::usage is internally converted to a set of required and preferred flags, plus some extra "magic" (heuristics).
@@ -155,7 +155,7 @@ Explicit memory types
VkBuffer buffer;
vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation,
nullptr);
-uint32_t memoryTypeBits
Bitmask containing one bit set for every memory type acceptable for this allocation.
Definition vk_mem_alloc.h:1272
+uint32_t memoryTypeBits
Bitmask containing one bit set for every memory type acceptable for this allocation.
Definition vk_mem_alloc.h:1289
You can also use this parameter to exclude some memory types. If you inspect memory heaps and types available on the current physical device and you determine that for some reason you don't want to use a specific memory type for the allocation, you can enable automatic memory type selection but exclude certain memory type or types by setting all bits of memoryTypeBits
to 1 except the ones you choose.
uint32_t excludedMemoryTypeIndex = 2;
diff --git a/docs/html/custom_memory_pools.html b/docs/html/custom_memory_pools.html
index 98e4b0a..d4a052c 100644
--- a/docs/html/custom_memory_pools.html
+++ b/docs/html/custom_memory_pools.html
@@ -133,15 +133,15 @@ $(function() {
VkResult vmaCreatePool(VmaAllocator allocator, const VmaPoolCreateInfo *pCreateInfo, VmaPool *pPool)
Allocates Vulkan device memory and creates VmaPool object.
VkResult vmaCreateBuffer(VmaAllocator allocator, const VkBufferCreateInfo *pBufferCreateInfo, const VmaAllocationCreateInfo *pAllocationCreateInfo, VkBuffer *pBuffer, VmaAllocation *pAllocation, VmaAllocationInfo *pAllocationInfo)
Creates a new VkBuffer, allocates and binds memory for it.
VkResult vmaFindMemoryTypeIndexForBufferInfo(VmaAllocator allocator, const VkBufferCreateInfo *pBufferCreateInfo, const VmaAllocationCreateInfo *pAllocationCreateInfo, uint32_t *pMemoryTypeIndex)
Helps to find memoryTypeIndex, given VkBufferCreateInfo and VmaAllocationCreateInfo.
-
@ VMA_MEMORY_USAGE_AUTO
Definition vk_mem_alloc.h:511
-
Parameters of new VmaAllocation.
Definition vk_mem_alloc.h:1246
-
VmaPool pool
Pool that this allocation should be created in.
Definition vk_mem_alloc.h:1278
-
VmaMemoryUsage usage
Intended usage of memory.
Definition vk_mem_alloc.h:1254
+
@ VMA_MEMORY_USAGE_AUTO
Definition vk_mem_alloc.h:527
+
Parameters of new VmaAllocation.
Definition vk_mem_alloc.h:1263
+
VmaPool pool
Pool that this allocation should be created in.
Definition vk_mem_alloc.h:1295
+
VmaMemoryUsage usage
Intended usage of memory.
Definition vk_mem_alloc.h:1271
Represents single memory allocation.
-
Describes parameter of created VmaPool.
Definition vk_mem_alloc.h:1297
-
uint32_t memoryTypeIndex
Vulkan memory type index to allocate this pool from.
Definition vk_mem_alloc.h:1300
-
VkDeviceSize blockSize
Size of a single VkDeviceMemory block to be allocated as part of this pool, in bytes....
Definition vk_mem_alloc.h:1313
-
size_t maxBlockCount
Maximum number of blocks that can be allocated in this pool. Optional.
Definition vk_mem_alloc.h:1326
+
Describes parameter of created VmaPool.
Definition vk_mem_alloc.h:1314
+
uint32_t memoryTypeIndex
Vulkan memory type index to allocate this pool from.
Definition vk_mem_alloc.h:1317
+
VkDeviceSize blockSize
Size of a single VkDeviceMemory block to be allocated as part of this pool, in bytes....
Definition vk_mem_alloc.h:1330
+
size_t maxBlockCount
Maximum number of blocks that can be allocated in this pool. Optional.
Definition vk_mem_alloc.h:1343
Represents custom memory pool.
You have to free all allocations made from this pool before destroying it.
diff --git a/docs/html/defragmentation.html b/docs/html/defragmentation.html
index 35b8025..e690e15 100644
--- a/docs/html/defragmentation.html
+++ b/docs/html/defragmentation.html
@@ -143,18 +143,18 @@ $(function() {
VkResult vmaBeginDefragmentationPass(VmaAllocator allocator, VmaDefragmentationContext context, VmaDefragmentationPassMoveInfo *pPassInfo)
Starts single defragmentation pass.
VkResult vmaBeginDefragmentation(VmaAllocator allocator, const VmaDefragmentationInfo *pInfo, VmaDefragmentationContext *pContext)
Begins defragmentation process.
VkResult vmaEndDefragmentationPass(VmaAllocator allocator, VmaDefragmentationContext context, VmaDefragmentationPassMoveInfo *pPassInfo)
Ends single defragmentation pass.
-
@ VMA_DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT
Definition vk_mem_alloc.h:728
-
Definition vk_mem_alloc.h:1365
-
void * pUserData
Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...
Definition vk_mem_alloc.h:1412
+
@ VMA_DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT
Definition vk_mem_alloc.h:744
+
Definition vk_mem_alloc.h:1382
+
void * pUserData
Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...
Definition vk_mem_alloc.h:1429
An opaque object that represents started defragmentation process.
-
Parameters for defragmentation.
Definition vk_mem_alloc.h:1455
-
VmaPool pool
Custom pool to be defragmented.
Definition vk_mem_alloc.h:1462
-
VmaDefragmentationFlags flags
Use combination of VmaDefragmentationFlagBits.
Definition vk_mem_alloc.h:1457
-
VmaAllocation srcAllocation
Allocation that should be moved.
Definition vk_mem_alloc.h:1488
-
VmaAllocation dstTmpAllocation
Temporary allocation pointing to destination memory that will replace srcAllocation.
Definition vk_mem_alloc.h:1495
-
Parameters for incremental defragmentation steps.
Definition vk_mem_alloc.h:1503
-
uint32_t moveCount
Number of elements in the pMoves array.
Definition vk_mem_alloc.h:1505
-
VmaDefragmentationMove * pMoves
Array of moves to be performed by the user in the current defragmentation pass.
Definition vk_mem_alloc.h:1529
+
Parameters for defragmentation.
Definition vk_mem_alloc.h:1472
+
VmaPool pool
Custom pool to be defragmented.
Definition vk_mem_alloc.h:1479
+
VmaDefragmentationFlags flags
Use combination of VmaDefragmentationFlagBits.
Definition vk_mem_alloc.h:1474
+
VmaAllocation srcAllocation
Allocation that should be moved.
Definition vk_mem_alloc.h:1505
+
VmaAllocation dstTmpAllocation
Temporary allocation pointing to destination memory that will replace srcAllocation.
Definition vk_mem_alloc.h:1512
+
Parameters for incremental defragmentation steps.
Definition vk_mem_alloc.h:1520
+
uint32_t moveCount
Number of elements in the pMoves array.
Definition vk_mem_alloc.h:1522
+
VmaDefragmentationMove * pMoves
Array of moves to be performed by the user in the current defragmentation pass.
Definition vk_mem_alloc.h:1546
Although functions like vmaCreateBuffer(), vmaCreateImage(), vmaDestroyBuffer(), vmaDestroyImage() create/destroy an allocation and a buffer/image at once, these are just a shortcut for creating the resource, allocating memory, and binding them together. Defragmentation works on memory allocations only. You must handle the rest manually. Defragmentation is an iterative process that should repreat "passes" as long as related functions return VK_INCOMPLETE
not VK_SUCCESS
. In each pass:
- vmaBeginDefragmentationPass() function call:
diff --git a/docs/html/doxygen_crawl.html b/docs/html/doxygen_crawl.html
index fbce5c7..ad1c927 100644
--- a/docs/html/doxygen_crawl.html
+++ b/docs/html/doxygen_crawl.html
@@ -118,6 +118,5 @@
-