Skip to content

Commit b3cbbb4

Browse files
authored
Merge pull request #526 from sawickiap/master
New updates to Vulkan Memory Allocator
2 parents e722e57 + 91fed8d commit b3cbbb4

File tree

110 files changed

+1239
-941
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1239
-941
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# 3.4.0 (2026-??-??)
2+
3+
- Added member `VmaAllocationCreateInfo::minAlignment` (#523).
4+
- Remember to always fully initialize structures with zeros and don't rely on their specific `sizeof` to ensure backward compatibility!
5+
- Function `vmaCreateBufferWithAlignment` is now deprecated.
6+
- Improvements for external memory export & import (#503):
7+
- Added functions `vmaCreateDedicatedBuffer`, `vmaCreateDedicatedImage`, `vmaAllocateDedicatedMemory` offering extra parameter `void* pMemoryAllocateNext`.
8+
- Added function `vmaGetMemoryWin32Handle2` offering extra parameter `VkExternalMemoryHandleTypeFlagBits handleType`.
9+
- Added `VMA_VERSION` macro with library version number (#507).
10+
- Improvements in the algorithm choosing memory type when `VMA_MEMORY_USAGE_AUTO*` is used (#520).
11+
- Fixes for compatibility with C++20 modules on Clang 21 and GCC15 (#513, #514).
12+
- Other fixes and improvements, including compatibility with various platforms and compilers, improvements in documentation, sample application, and tests.
13+
114
# 3.3.0 (2025-05-12)
215

316
Additions to the library API:

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2017-2025 Advanced Micro Devices, Inc. All rights reserved.
2+
# Copyright (c) 2017-2026 Advanced Micro Devices, Inc. All rights reserved.
33
#
44
# Permission is hereby granted, free of charge, to any person obtaining a copy
55
# of this software and associated documentation files (the "Software"), to deal
@@ -26,6 +26,7 @@ project(VMA VERSION 3.3.0 LANGUAGES CXX)
2626

2727
add_library(VulkanMemoryAllocator INTERFACE)
2828
add_library(GPUOpen::VulkanMemoryAllocator ALIAS VulkanMemoryAllocator)
29+
add_library(VulkanMemoryAllocator::Headers ALIAS VulkanMemoryAllocator)
2930

3031
target_include_directories(VulkanMemoryAllocator INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
3132

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017-2025 Advanced Micro Devices, Inc. All rights reserved.
1+
Copyright (c) 2017-2026 Advanced Micro Devices, Inc. All rights reserved.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

docs/html/allocation_annotation.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
55
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
6-
<meta name="generator" content="Doxygen 1.14.0"/>
6+
<meta name="generator" content="Doxygen 1.16.1"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1"/>
88
<title>Vulkan Memory Allocator: Allocation names and user data</title>
99
<link href="tabs.css" rel="stylesheet" type="text/css"/>
@@ -31,7 +31,7 @@
3131
</table>
3232
</div>
3333
<!-- end header part -->
34-
<!-- Generated by Doxygen 1.14.0 -->
34+
<!-- Generated by Doxygen 1.16.1 -->
3535
<script type="text/javascript">
3636
var searchBox = new SearchBox("searchBox", "search/",'.html');
3737
</script>
@@ -80,7 +80,7 @@
8080
<div class="contents">
8181
<div class="textblock"><h1 class="doxsection"><a class="anchor" id="allocation_user_data"></a>
8282
Allocation user data</h1>
83-
<p>You can annotate allocations with your own information, e.g. for debugging purposes. To do that, fill <a class="el" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19" title="Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...">VmaAllocationCreateInfo::pUserData</a> field when creating an allocation. It is an opaque <span class="tt">void*</span> pointer. You can use it e.g. as a pointer, some handle, index, key, ordinal number or any other value that would associate the allocation with your custom metadata. It is useful to identify appropriate data structures in your engine given <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a>, e.g. when doing <a class="el" href="defragmentation.html">Defragmentation</a>.</p>
83+
<p>You can annotate allocations with your own information, e.g. for debugging purposes. To do that, fill <a class="el" href="struct_vma_allocation_create_info.html#a8259e85c272683434f4abb4ddddffe19" title="Custom general-purpose pointer that will be stored in VmaAllocation, can be read as VmaAllocationInfo...">VmaAllocationCreateInfo::pUserData</a> field when creating an allocation. It is an opaque <span class="tt">void*</span> pointer. You can use it e.g. as a pointer, some handle, index, key, ordinal number or any other value that would associate the allocation with your custom metadata. It is useful to identify appropriate data structures in your engine given <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation.">VmaAllocation</a>, e.g. when doing <a class="el" href="defragmentation.html" title="Defragmentation">Defragmentation</a>.</p>
8484
<div class="fragment"><div class="line">VkBufferCreateInfo bufCreateInfo = ...</div>
8585
<div class="line"> </div>
8686
<div class="line">MyBufferMetadata* pMetadata = CreateBufferMetadata();</div>
@@ -103,8 +103,8 @@
103103
<div class="line"><a class="code hl_function" href="group__group__alloc.html#ga86dd08aba8633bfa4ad0df2e76481d8b">vmaGetAllocationInfo</a>(allocator, allocation, &amp;allocInfo);</div>
104104
<div class="line">MyBufferMetadata* pMetadata = (MyBufferMetadata*)allocInfo.<a class="code hl_variable" href="struct_vma_allocation_info.html#adc507656149c04de7ed95d0042ba2a13">pUserData</a>;</div>
105105
<div class="ttc" id="agroup__group__alloc_html_ga86dd08aba8633bfa4ad0df2e76481d8b"><div class="ttname"><a href="group__group__alloc.html#ga86dd08aba8633bfa4ad0df2e76481d8b">vmaGetAllocationInfo</a></div><div class="ttdeci">void vmaGetAllocationInfo(VmaAllocator allocator, VmaAllocation allocation, VmaAllocationInfo *pAllocationInfo)</div><div class="ttdoc">Returns current information about specified allocation.</div></div>
106-
<div class="ttc" id="astruct_vma_allocation_info_html"><div class="ttname"><a href="struct_vma_allocation_info.html">VmaAllocationInfo</a></div><div class="ttdef"><b>Definition</b> vk_mem_alloc.h:1413</div></div>
107-
<div class="ttc" id="astruct_vma_allocation_info_html_adc507656149c04de7ed95d0042ba2a13"><div class="ttname"><a href="struct_vma_allocation_info.html#adc507656149c04de7ed95d0042ba2a13">VmaAllocationInfo::pUserData</a></div><div class="ttdeci">void * pUserData</div><div class="ttdoc">Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...</div><div class="ttdef"><b>Definition</b> vk_mem_alloc.h:1460</div></div>
106+
<div class="ttc" id="astruct_vma_allocation_info_html"><div class="ttname"><a href="struct_vma_allocation_info.html">VmaAllocationInfo</a></div><div class="ttdef"><b>Definition</b> vk_mem_alloc.h:1432</div></div>
107+
<div class="ttc" id="astruct_vma_allocation_info_html_adc507656149c04de7ed95d0042ba2a13"><div class="ttname"><a href="struct_vma_allocation_info.html#adc507656149c04de7ed95d0042ba2a13">VmaAllocationInfo::pUserData</a></div><div class="ttdeci">void * pUserData</div><div class="ttdoc">Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vma...</div><div class="ttdef"><b>Definition</b> vk_mem_alloc.h:1479</div></div>
108108
</div><!-- fragment --><p>It can also be changed using function <a class="el" href="group__group__alloc.html#gaf9147d31ffc11d62fc187bde283ed14f" title="Sets pUserData in given allocation to new value.">vmaSetAllocationUserData()</a>.</p>
109109
<p>Values of (non-zero) allocations' <span class="tt">pUserData</span> are printed in JSON report created by <a class="el" href="group__group__stats.html#gaa4fee7eb5253377599ef4fd38c93c2a0" title="Builds and returns statistics as a null-terminated string in JSON format.">vmaBuildStatsString()</a> in hexadecimal form.</p>
110110
<h1 class="doxsection"><a class="anchor" id="allocation_names"></a>
@@ -120,7 +120,7 @@ <h1 class="doxsection"><a class="anchor" id="allocation_names"></a>
120120
</div><!-- PageDoc -->
121121
<!-- start footer part -->
122122
<hr class="footer"/><address class="footer"><small>
123-
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0
123+
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1
124124
</small></address>
125125
</div><!-- doc-content -->
126126
</body>

docs/html/annotated.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
55
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
6-
<meta name="generator" content="Doxygen 1.14.0"/>
6+
<meta name="generator" content="Doxygen 1.16.1"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1"/>
88
<title>Vulkan Memory Allocator: Class List</title>
99
<link href="tabs.css" rel="stylesheet" type="text/css"/>
@@ -31,7 +31,7 @@
3131
</table>
3232
</div>
3333
<!-- end header part -->
34-
<!-- Generated by Doxygen 1.14.0 -->
34+
<!-- Generated by Doxygen 1.16.1 -->
3535
<script type="text/javascript">
3636
var searchBox = new SearchBox("searchBox", "search/",'.html');
3737
</script>
@@ -106,7 +106,7 @@
106106
</div><!-- contents -->
107107
<!-- start footer part -->
108108
<hr class="footer"/><address class="footer"><small>
109-
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0
109+
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1
110110
</small></address>
111111
</div><!-- doc-content -->
112112
</body>

docs/html/choosing_memory_type.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
55
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
6-
<meta name="generator" content="Doxygen 1.14.0"/>
6+
<meta name="generator" content="Doxygen 1.16.1"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1"/>
88
<title>Vulkan Memory Allocator: Choosing memory type</title>
99
<link href="tabs.css" rel="stylesheet" type="text/css"/>
@@ -31,7 +31,7 @@
3131
</table>
3232
</div>
3333
<!-- end header part -->
34-
<!-- Generated by Doxygen 1.14.0 -->
34+
<!-- Generated by Doxygen 1.16.1 -->
3535
<script type="text/javascript">
3636
var searchBox = new SearchBox("searchBox", "search/",'.html');
3737
</script>
@@ -123,9 +123,9 @@ <h1 class="doxsection"><a class="anchor" id="choosing_memory_type_usage"></a>
123123
<div class="line"><a class="code hl_function" href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51">vmaCreateBuffer</a>(allocator, &amp;stagingBufferInfo, &amp;stagingAllocInfo, &amp;stagingBuffer, &amp;stagingAllocation, <span class="keyword">nullptr</span>);</div>
124124
<div class="ttc" id="agroup__group__alloc_html_ggad9889c10c798b040d59c92f257cae597a9be224df3bfc1cfa06203aed689a30c5"><div class="ttname"><a href="group__group__alloc.html#ggad9889c10c798b040d59c92f257cae597a9be224df3bfc1cfa06203aed689a30c5">VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT</a></div><div class="ttdeci">@ VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT</div><div class="ttdef"><b>Definition</b> vk_mem_alloc.h:662</div></div>
125125
<div class="ttc" id="astruct_vma_allocation_create_info_html_add09658ac14fe290ace25470ddd6d41b"><div class="ttname"><a href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">VmaAllocationCreateInfo::flags</a></div><div class="ttdeci">VmaAllocationCreateFlags flags</div><div class="ttdoc">Use VmaAllocationCreateFlagBits enum.</div><div class="ttdef"><b>Definition</b> vk_mem_alloc.h:1296</div></div>
126-
</div><!-- fragment --><p>For more examples of creating different kinds of resources, see chapter <a class="el" href="usage_patterns.html">Recommended usage patterns</a>. See also: <a class="el" href="memory_mapping.html">Memory mapping</a>.</p>
126+
</div><!-- fragment --><p>For more examples of creating different kinds of resources, see chapter <a class="el" href="usage_patterns.html" title="Recommended usage patterns">Recommended usage patterns</a>. See also: <a class="el" href="memory_mapping.html" title="Memory mapping">Memory mapping</a>.</p>
127127
<p>Usage values <span class="tt">VMA_MEMORY_USAGE_AUTO*</span> are legal to use only when the library knows about the resource being created by having <span class="tt">VkBufferCreateInfo</span> / <span class="tt">VkImageCreateInfo</span> passed, so they work with functions like: <a class="el" href="group__group__alloc.html#gac72ee55598617e8eecca384e746bab51" title="Creates a new VkBuffer, allocates and binds memory for it.">vmaCreateBuffer()</a>, <a class="el" href="group__group__alloc.html#ga02a94f25679275851a53e82eacbcfc73" title="Function similar to vmaCreateBuffer() but for images.">vmaCreateImage()</a>, <a class="el" href="group__group__alloc.html#gae790ab9ffaf7667fb8f62523e6897888" title="Helps to find memoryTypeIndex, given VkBufferCreateInfo and VmaAllocationCreateInfo.">vmaFindMemoryTypeIndexForBufferInfo()</a> etc. If you allocate raw memory using function <a class="el" href="group__group__alloc.html#gabf28077dbf82d0908b8acbe8ee8dd9b8" title="General purpose memory allocation.">vmaAllocateMemory()</a>, you have to use other means of selecting memory type, as described below.</p>
128-
<dl class="section note"><dt>Note</dt><dd>Old usage values (<span class="tt">VMA_MEMORY_USAGE_GPU_ONLY</span>, <span class="tt">VMA_MEMORY_USAGE_CPU_ONLY</span>, <span class="tt">VMA_MEMORY_USAGE_CPU_TO_GPU</span>, <span class="tt">VMA_MEMORY_USAGE_GPU_TO_CPU</span>, <span class="tt">VMA_MEMORY_USAGE_CPU_COPY</span>) are still available and work same way as in previous versions of the library for backward compatibility, but they are deprecated.</dd></dl>
128+
<dl class="section note"><dt>Note</dt><dd>Old usage values (<span class="tt"><a class="el" href="group__group__alloc.html#ggaa5846affa1e9da3800e3e78fae2305ccac6b5dc1432d88647aa4cd456246eadf7">VMA_MEMORY_USAGE_GPU_ONLY</a></span>, <span class="tt"><a class="el" href="group__group__alloc.html#ggaa5846affa1e9da3800e3e78fae2305cca40bdf4cddeffeb12f43d45ca1286e0a5">VMA_MEMORY_USAGE_CPU_ONLY</a></span>, <span class="tt"><a class="el" href="group__group__alloc.html#ggaa5846affa1e9da3800e3e78fae2305cca9066b52c5a7079bb74a69aaf8b92ff67">VMA_MEMORY_USAGE_CPU_TO_GPU</a></span>, <span class="tt"><a class="el" href="group__group__alloc.html#ggaa5846affa1e9da3800e3e78fae2305cca7b586d2fdaf82a463b58f581ed72be27">VMA_MEMORY_USAGE_GPU_TO_CPU</a></span>, <span class="tt"><a class="el" href="group__group__alloc.html#ggaa5846affa1e9da3800e3e78fae2305cca416a444d4d0fc20067c3f76f32ff2500">VMA_MEMORY_USAGE_CPU_COPY</a></span>) are still available and work same way as in previous versions of the library for backward compatibility, but they are deprecated.</dd></dl>
129129
<h1 class="doxsection"><a class="anchor" id="choosing_memory_type_required_preferred_flags"></a>
130130
Required and preferred flags</h1>
131131
<p>You can specify more detailed requirements by filling members <a class="el" href="struct_vma_allocation_create_info.html#a9166390303ff42d783305bc31c2b6b90" title="Flags that must be set in a Memory Type chosen for an allocation.">VmaAllocationCreateInfo::requiredFlags</a> and <a class="el" href="struct_vma_allocation_create_info.html#a7fe8d81a1ad10b2a2faacacee5b15d6d" title="Flags that preferably should be set in a memory type chosen for an allocation.">VmaAllocationCreateInfo::preferredFlags</a> with a combination of bits from enum <span class="tt">VkMemoryPropertyFlags</span>. For example, if you want to create a buffer that will be persistently mapped on host (so it must be <span class="tt">HOST_VISIBLE</span>) and preferably will also be <span class="tt">HOST_COHERENT</span> and <span class="tt">HOST_CACHED</span>, use following code:</p>
@@ -165,20 +165,20 @@ <h1 class="doxsection"><a class="anchor" id="choosing_memory_type_explicit_memor
165165
<div class="line"><span class="comment">// ...</span></div>
166166
</div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="choosing_memory_type_custom_memory_pools"></a>
167167
Custom memory pools</h1>
168-
<p>If you allocate from custom memory pool, all the ways of specifying memory requirements described above are not applicable and the aforementioned members of <a class="el" href="struct_vma_allocation_create_info.html" title="Parameters of new VmaAllocation.">VmaAllocationCreateInfo</a> structure are ignored. Memory type is selected explicitly when creating the pool and then used to make all the allocations from that pool. For further details, see <a class="el" href="custom_memory_pools.html">Custom memory pools</a>.</p>
168+
<p>If you allocate from custom memory pool, all the ways of specifying memory requirements described above are not applicable and the aforementioned members of <a class="el" href="struct_vma_allocation_create_info.html" title="Parameters of new VmaAllocation.">VmaAllocationCreateInfo</a> structure are ignored. Memory type is selected explicitly when creating the pool and then used to make all the allocations from that pool. For further details, see <a class="el" href="custom_memory_pools.html" title="Custom memory pools">Custom memory pools</a>.</p>
169169
<h1 class="doxsection"><a class="anchor" id="choosing_memory_type_dedicated_allocations"></a>
170170
Dedicated allocations</h1>
171171
<p>Memory for allocations is reserved out of larger block of <span class="tt">VkDeviceMemory</span> allocated from Vulkan internally. That is the main feature of this whole library. You can still request a separate memory block to be created for an allocation, just like you would do in a trivial solution without using any allocator. In that case, a buffer or image is always bound to that memory at offset 0. This is called a "dedicated allocation". You can explicitly request it by using flag <a class="el" href="group__group__alloc.html#ggad9889c10c798b040d59c92f257cae597a3fc311d855c2ff53f1090ef5c722b38f" title="Set this flag if the allocation should have its own memory block.">VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT</a>. The library can also internally decide to use dedicated allocation in some cases, e.g.:</p>
172172
<ul>
173173
<li>When the size of the allocation is large.</li>
174-
<li>When <a class="el" href="vk_khr_dedicated_allocation.html">VK_KHR_dedicated_allocation</a> extension is enabled and it reports that dedicated allocation is required or recommended for the resource.</li>
174+
<li>When <a class="el" href="vk_khr_dedicated_allocation.html" title="VK_KHR_dedicated_allocation">VK_KHR_dedicated_allocation</a> extension is enabled and it reports that dedicated allocation is required or recommended for the resource.</li>
175175
<li>When allocation of next big memory block fails due to not enough device memory, but allocation with the exact requested size succeeds. </li>
176176
</ul>
177177
</div></div><!-- contents -->
178178
</div><!-- PageDoc -->
179179
<!-- start footer part -->
180180
<hr class="footer"/><address class="footer"><small>
181-
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0
181+
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1
182182
</small></address>
183183
</div><!-- doc-content -->
184184
</body>

docs/html/classes.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
55
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
6-
<meta name="generator" content="Doxygen 1.14.0"/>
6+
<meta name="generator" content="Doxygen 1.16.1"/>
77
<meta name="viewport" content="width=device-width, initial-scale=1"/>
88
<title>Vulkan Memory Allocator: Class Index</title>
99
<link href="tabs.css" rel="stylesheet" type="text/css"/>
@@ -31,7 +31,7 @@
3131
</table>
3232
</div>
3333
<!-- end header part -->
34-
<!-- Generated by Doxygen 1.14.0 -->
34+
<!-- Generated by Doxygen 1.16.1 -->
3535
<script type="text/javascript">
3636
var searchBox = new SearchBox("searchBox", "search/",'.html');
3737
</script>
@@ -83,7 +83,7 @@
8383
</div><!-- contents -->
8484
<!-- start footer part -->
8585
<hr class="footer"/><address class="footer"><small>
86-
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0
86+
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1
8787
</small></address>
8888
</div><!-- doc-content -->
8989
</body>

0 commit comments

Comments
 (0)