Skip to content

Commit 6a6d8c6

Browse files
Merge branch 'master' into sparse_binding_example
# Conflicts: # docs/html/vk__mem__alloc_8h.html # docs/html/vk__mem__alloc_8h_source.html # src/Tests.cpp # src/VulkanSample.cpp # src/vk_mem_alloc.h
2 parents a7d7769 + 3b39225 commit 6a6d8c6

18 files changed

+654
-20
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Easy to integrate Vulkan memory allocation library.
2020
Memory allocation and resource (buffer and image) creation in Vulkan is difficult (comparing to older graphics API-s, like D3D11 or OpenGL) for several reasons:
2121

2222
- It requires a lot of boilerplate code, just like everything else in Vulkan, because it is a low-level and high-performance API.
23-
- There is additional level of indirection: `VkDeviceMemory` is allocated separately from creating `VkBuffer`/`VkImage` and they must be bound together. The binding cannot be changed later - resource must be recreated.
23+
- There is additional level of indirection: `VkDeviceMemory` is allocated separately from creating `VkBuffer`/`VkImage` and they must be bound together.
2424
- Driver must be queried for supported memory heaps and memory types. Different IHVs provide different types of it.
2525
- It is recommended practice to allocate bigger chunks of memory and assign parts of them to particular resources.
2626

@@ -41,7 +41,7 @@ Additional features:
4141
- Configuration: Fill optional members of CreateInfo structure to provide custom CPU memory allocator, pointers to Vulkan functions and other parameters.
4242
- Customization: Predefine appropriate macros to provide your own implementation of all external facilities used by the library, from assert, mutex, and atomic, to vector and linked list.
4343
- Support for memory mapping, reference-counted internally. Support for persistently mapped memory: Just allocate with appropriate flag and you get access to mapped pointer.
44-
- Support for non-coherent memory. Functions that flush/invalidate memory. nonCoherentAtomSize is respected automatically.
44+
- Support for non-coherent memory. Functions that flush/invalidate memory. `nonCoherentAtomSize` is respected automatically.
4545
- Custom memory pools: Create a pool with desired parameters (e.g. fixed or limited maximum size) and allocate memory out of it.
4646
- Linear allocator: Create a pool with linear algorithm and use it for much faster allocations and deallocations in free-at-once, stack, double stack, or ring buffer fashion.
4747
- Support for VK_KHR_dedicated_allocation extension: Just enable it and it will be used automatically by the library.
@@ -60,7 +60,7 @@ Additional features:
6060
- Public interface in C, in same convention as Vulkan API. Implementation in C++.
6161
- Error handling implemented by returning `VkResult` error codes - same way as in Vulkan.
6262
- Interface documented using Doxygen-style comments.
63-
- Platform-independent, but developed and tested on Windows using Visual Studio. Continuous integration setup for Windows and Linux. Tested also on Android and MacOS.
63+
- Platform-independent, but developed and tested on Windows using Visual Studio. Continuous integration setup for Windows and Linux. Tested also on Android, MacOS, and other platforms.
6464

6565
# Example
6666

@@ -94,12 +94,16 @@ See **[Documentation](https://gpuopen-librariesandsdks.github.io/VulkanMemoryAll
9494
# Software using this library
9595
9696
- **[Filament](https://github.com/google/filament)** - physically based rendering engine for Android, Windows, Linux and macOS, from Google. Apache License 2.0.
97+
- **[Skia](https://github.com/google/skia)** - complete 2D graphic library for drawing Text, Geometries, and Images, from Google.
98+
- **[PowerVR SDK](https://github.com/powervr-graphics/Native_SDK)** - C++ cross-platform 3D graphics SDK, from Imagination. License: MIT.
9799
- **[Anvil](https://github.com/GPUOpen-LibrariesAndSDKs/Anvil)** - cross-platform framework for Vulkan. License: MIT.
98100
- **[vkDOOM3](https://github.com/DustinHLand/vkDOOM3)** - Vulkan port of GPL DOOM 3 BFG Edition. License: GNU GPL.
99101
- **[Lightweight Java Game Library (LWJGL)](https://www.lwjgl.org/)** - includes binding of the library for Java. License: BSD.
100102
- **[The Forge](https://github.com/ConfettiFX/The-Forge)** - cross-platform rendering framework. Apache License 2.0.
101103
- **[VK9](https://github.com/disks86/VK9)** - Direct3D 9 compatibility layer using Vulkan. Zlib lincese.
102104
105+
[Many other projects on GitHub](https://github.com/search?q=AMD_VULKAN_MEMORY_ALLOCATOR_H&type=Code) and some game development studios that use Vulkan in their games.
106+
103107
# See also
104108
105109
- **[Awesome Vulkan](https://github.com/vinjn/awesome-vulkan)** - a curated list of awesome Vulkan libraries, debuggers and resources.

docs/Recording file format.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Formats with only minor version incremented are backward compatible.
2323
VmaReplay application supports all older versions.
2424
Current version is:
2525

26-
1,3
26+
1,4
2727

2828
# Configuration
2929

@@ -204,6 +204,11 @@ No parameters.
204204

205205
- pool : pointer
206206

207+
**vmaResizeAllocation** (min format version: 1.4)
208+
209+
- allocation : pointer
210+
- newSize : uint64
211+
207212
# Data types
208213

209214
**bool**
@@ -228,7 +233,7 @@ It should not contain end-of-line characters - results are then undefined.
228233
# Example file
229234

230235
Vulkan Memory Allocator,Calls recording
231-
1,3
236+
1,4
232237
Config,Begin
233238
PhysicalDevice,apiVersion,4198477
234239
PhysicalDevice,driverVersion,8388653
@@ -284,4 +289,4 @@ It should not contain end-of-line characters - results are then undefined.
284289
12552,0.695,0,vmaDestroyImage,000001D85B8B1620
285290
12552,0.695,0,vmaDestroyBuffer,000001D85B8B16C0
286291
12552,0.695,0,vmaDestroyBuffer,000001D85B8B1A80
287-
12552,0.695,0,vmaDestroyAllocator
292+
12552,0.695,0,vmaDestroyAllocator

docs/html/general_considerations.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ <h1><a class="anchor" id="general_considerations_features_not_supported"></a>
110110
Features not supported</h1>
111111
<p>Features deliberately excluded from the scope of this library:</p>
112112
<ul>
113-
<li>Support for sparse binding and sparse residency. You can still use these features (when supported by the device) with VMA. You just need to do it yourself. Any explicit support for sparse binding/residency would rather require another, higher-level library on top of VMA.</li>
113+
<li>Support for sparse binding and sparse residency. You can still use these features (when supported by the device) with VMA. You just need to do it yourself. Allocate memory pages with <a class="el" href="vk__mem__alloc_8h.html#abf28077dbf82d0908b8acbe8ee8dd9b8" title="General purpose memory allocation. ">vmaAllocateMemory()</a>. Any explicit support for sparse binding/residency would rather require another, higher-level library on top of VMA.</li>
114114
<li>Data transfer - issuing commands that transfer data between buffers or images, any usage of <code>VkCommandList</code> or <code>VkQueue</code> and related synchronization is responsibility of the user.</li>
115115
<li>Allocations for imported/exported external memory. They tend to require explicit memory type index and dedicated allocation anyway, so they don't interact with main features of this library. Such special purpose allocations should be made manually, using <code>vkCreateBuffer()</code> and <code>vkAllocateMemory()</code>.</li>
116+
<li>Recreation of buffers and images. Although the library has functions for buffer and image creation (<a class="el" href="vk__mem__alloc_8h.html#ac72ee55598617e8eecca384e746bab51">vmaCreateBuffer()</a>, <a class="el" href="vk__mem__alloc_8h.html#a02a94f25679275851a53e82eacbcfc73" title="Function similar to vmaCreateBuffer(). ">vmaCreateImage()</a>), you need to recreate these objects yourself after defragmentation. That's because the big structures <code>VkBufferCreateInfo</code>, <code>VkImageCreateInfo</code> are not stored in <a class="el" href="struct_vma_allocation.html" title="Represents single memory allocation. ">VmaAllocation</a> object.</li>
117+
<li>Handling CPU memory allocation failures. When dynamically creating small C++ objects in CPU memory (not Vulkan memory), allocation failures are not checked and handled gracefully, because that would complicate code significantly and is usually not needed in desktop PC applications anyway.</li>
118+
<li>Code free of any compiler warnings. Maintaining the library to compile and work correctly on so many different platforms is hard enough. Being free of any warnings, on any version of any compiler, is simply not feasible.</li>
116119
<li>Support for any programming languages other than C/C++. Bindings to other languages are welcomed as external projects. </li>
117120
</ul>
118121
</div></div><!-- contents -->

docs/html/globals.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ <h3><a id="index_v"></a>- v -</h3><ul>
322322
: <a class="el" href="vk__mem__alloc_8h.html#ad63b2113c0bfdbeade1cb498f5a8580d">vk_mem_alloc.h</a>
323323
</li>
324324
<li>VmaPoolCreateFlagBits
325-
: <a class="el" href="vk__mem__alloc_8h.html#a9a7c45f9c863695d98c83fa5ac940fe7">vk_mem_alloc.h</a>
325+
: <a class="el" href="vk__mem__alloc_8h.html#a8f93195158e0e2ac80ca352064e71c1f">vk_mem_alloc.h</a>
326326
</li>
327327
<li>VmaPoolCreateFlags
328328
: <a class="el" href="vk__mem__alloc_8h.html#a2770e325ea42e087c1b91fdf46d0292a">vk_mem_alloc.h</a>
@@ -342,6 +342,9 @@ <h3><a id="index_v"></a>- v -</h3><ul>
342342
<li>VmaRecordSettings
343343
: <a class="el" href="vk__mem__alloc_8h.html#a0ab61e87ff6365f1d59915eadc37a9f0">vk_mem_alloc.h</a>
344344
</li>
345+
<li>vmaResizeAllocation()
346+
: <a class="el" href="vk__mem__alloc_8h.html#a0ff488958ca72b28e545880463cb8696">vk_mem_alloc.h</a>
347+
</li>
345348
<li>vmaSetAllocationUserData()
346349
: <a class="el" href="vk__mem__alloc_8h.html#af9147d31ffc11d62fc187bde283ed14f">vk_mem_alloc.h</a>
347350
</li>

docs/html/globals_func.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ <h3><a id="index_v"></a>- v -</h3><ul>
169169
<li>vmaMapMemory()
170170
: <a class="el" href="vk__mem__alloc_8h.html#ad5bd1243512d099706de88168992f069">vk_mem_alloc.h</a>
171171
</li>
172+
<li>vmaResizeAllocation()
173+
: <a class="el" href="vk__mem__alloc_8h.html#a0ff488958ca72b28e545880463cb8696">vk_mem_alloc.h</a>
174+
</li>
172175
<li>vmaSetAllocationUserData()
173176
: <a class="el" href="vk__mem__alloc_8h.html#af9147d31ffc11d62fc187bde283ed14f">vk_mem_alloc.h</a>
174177
</li>

docs/html/memory_mapping.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ <h1><a class="anchor" id="memory_mapping_persistently_mapped_memory"></a>
8282
<div class="fragment"><div class="line">VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };</div><div class="line">bufCreateInfo.size = <span class="keyword">sizeof</span>(ConstantBuffer);</div><div class="line">bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;</div><div class="line"></div><div class="line"><a class="code" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a> allocCreateInfo = {};</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#accb8b06b1f677d858cb9af20705fa910">usage</a> = <a class="code" href="vk__mem__alloc_8h.html#aa5846affa1e9da3800e3e78fae2305cca40bdf4cddeffeb12f43d45ca1286e0a5">VMA_MEMORY_USAGE_CPU_ONLY</a>;</div><div class="line">allocCreateInfo.<a class="code" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">flags</a> = <a class="code" href="vk__mem__alloc_8h.html#ad9889c10c798b040d59c92f257cae597a11da372cc3a82931c5e5d6146cd9dd1f">VMA_ALLOCATION_CREATE_MAPPED_BIT</a>;</div><div class="line"></div><div class="line">VkBuffer buf;</div><div class="line"><a class="code" href="struct_vma_allocation.html">VmaAllocation</a> alloc;</div><div class="line"><a class="code" href="struct_vma_allocation_info.html">VmaAllocationInfo</a> allocInfo;</div><div class="line"><a class="code" href="vk__mem__alloc_8h.html#ac72ee55598617e8eecca384e746bab51">vmaCreateBuffer</a>(allocator, &amp;bufCreateInfo, &amp;allocCreateInfo, &amp;buf, &amp;alloc, &amp;allocInfo);</div><div class="line"></div><div class="line"><span class="comment">// Buffer is already mapped. You can access its memory.</span></div><div class="line">memcpy(allocInfo.<a class="code" href="struct_vma_allocation_info.html#a5eeffbe2d2f30f53370ff14aefbadbe2">pMappedData</a>, &amp;constantBufferData, <span class="keyword">sizeof</span>(constantBufferData));</div></div><!-- fragment --><p>There are some exceptions though, when you should consider mapping memory only for a short period of time:</p>
8383
<ul>
8484
<li>When operating system is Windows 7 or 8.x (Windows 10 is not affected because it uses WDDM2), device is discrete AMD GPU, and memory type is the special 256 MiB pool of <code>DEVICE_LOCAL + HOST_VISIBLE</code> memory (selected when you use <a class="el" href="vk__mem__alloc_8h.html#aa5846affa1e9da3800e3e78fae2305cca9066b52c5a7079bb74a69aaf8b92ff67">VMA_MEMORY_USAGE_CPU_TO_GPU</a>), then whenever a memory block allocated from this memory type stays mapped for the time of any call to <code>vkQueueSubmit()</code> or <code>vkQueuePresentKHR()</code>, this block is migrated by WDDM to system RAM, which degrades performance. It doesn't matter if that particular memory block is actually used by the command buffer being submitted.</li>
85+
<li>On Mac/MoltenVK there is a known bug - <a href="https://github.com/KhronosGroup/MoltenVK/issues/175">Issue #175</a> which requires unmapping before GPU can see updated texture.</li>
8586
<li>Keeping many large memory blocks mapped may impact performance or stability of some debugging tools.</li>
8687
</ul>
8788
<h1><a class="anchor" id="memory_mapping_cache_control"></a>

docs/html/quick_start.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<li>In exacly one CPP file define following macro before this include. It enables also internal definitions.</li>
8080
</ol>
8181
<div class="fragment"><div class="line"><span class="preprocessor">#define VMA_IMPLEMENTATION</span></div><div class="line"><span class="preprocessor">#include &quot;vk_mem_alloc.h&quot;</span></div></div><!-- fragment --><p>It may be a good idea to create dedicated CPP file just for this purpose.</p>
82+
<p>Note on language: This library is written in C++, but has C-compatible interface. Thus you can include and use <a class="el" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a> in C or C++ code, but full implementation with <code>VMA_IMPLEMENTATION</code> macro must be compiled as C++, NOT as C.</p>
8283
<p>Please note that this library includes header <code>&lt;vulkan/vulkan.h&gt;</code>, which in turn includes <code>&lt;windows.h&gt;</code> on Windows. If you need some specific macros defined before including these headers (like <code>WIN32_LEAN_AND_MEAN</code> or <code>WINVER</code> for Windows, <code>VK_USE_PLATFORM_WIN32_KHR</code> for Vulkan), you must define them before every <code>#include</code> of this library.</p>
8384
<h1><a class="anchor" id="quick_start_initialization"></a>
8485
Initialization</h1>

docs/html/search/all_10.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/html/search/functions_0.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/html/search/variables_c.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html><head><title></title>
3+
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
4+
<meta name="generator" content="Doxygen 1.8.14"/>
5+
<link rel="stylesheet" type="text/css" href="search.css"/>
6+
<script type="text/javascript" src="variables_c.js"></script>
7+
<script type="text/javascript" src="search.js"></script>
8+
</head>
9+
<body class="SRPage">
10+
<div id="SRIndex">
11+
<div class="SRStatus" id="Loading">Loading...</div>
12+
<div id="SRResults"></div>
13+
<script type="text/javascript"><!--
14+
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
15+
createResults();
16+
/* @license-end */
17+
--></script>
18+
<div class="SRStatus" id="Searching">Searching...</div>
19+
<div class="SRStatus" id="NoMatches">No Matches</div>
20+
<script type="text/javascript"><!--
21+
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
22+
document.getElementById("Loading").style.display="none";
23+
document.getElementById("NoMatches").style.display="none";
24+
var searchResults = new SearchResults("searchResults");
25+
searchResults.Search();
26+
/* @license-end */
27+
--></script>
28+
</div>
29+
</body>
30+
</html>

0 commit comments

Comments
 (0)