Skip to content

Commit ba335cf

Browse files
Fixed threading bug with mapping vs binding. Added functions vmaBindBufferMemory, vmaBindImageMemory. Removed class VmaDeviceMemoryMapping. Minor fixes in documentation.
1 parent 57fa558 commit ba335cf

File tree

9 files changed

+432
-212
lines changed

9 files changed

+432
-212
lines changed

docs/html/choosing_memory_type.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<ol type="1">
7171
<li>If you just want to find memory type index that meets your requirements, you can use function <a class="el" href="vk__mem__alloc_8h.html#aef15a94b58fbcb0fe706d5720e84a74a" title="Helps to find memoryTypeIndex, given memoryTypeBits and VmaAllocationCreateInfo. ">vmaFindMemoryTypeIndex()</a>.</li>
7272
<li>If you want to allocate a region of device memory without association with any specific image or buffer, you can use function <a class="el" href="vk__mem__alloc_8h.html#abf28077dbf82d0908b8acbe8ee8dd9b8" title="General purpose memory allocation. ">vmaAllocateMemory()</a>. Usage of this function is not recommended and usually not needed.</li>
73-
<li>If you already have a buffer or an image created, you want to allocate memory for it and then you will bind it yourself, you can use function <a class="el" href="vk__mem__alloc_8h.html#a7fdf64415b6c3d83c454f28d2c53df7b">vmaAllocateMemoryForBuffer()</a>, <a class="el" href="vk__mem__alloc_8h.html#a0faa3f9e5fb233d29d1e00390650febb" title="Function similar to vmaAllocateMemoryForBuffer(). ">vmaAllocateMemoryForImage()</a>.</li>
73+
<li>If you already have a buffer or an image created, you want to allocate memory for it and then you will bind it yourself, you can use function <a class="el" href="vk__mem__alloc_8h.html#a7fdf64415b6c3d83c454f28d2c53df7b">vmaAllocateMemoryForBuffer()</a>, <a class="el" href="vk__mem__alloc_8h.html#a0faa3f9e5fb233d29d1e00390650febb" title="Function similar to vmaAllocateMemoryForBuffer(). ">vmaAllocateMemoryForImage()</a>. For binding you should use functions: <a class="el" href="vk__mem__alloc_8h.html#a6b0929b914b60cf2d45cac4bf3547470" title="Binds buffer to allocation. ">vmaBindBufferMemory()</a>, <a class="el" href="vk__mem__alloc_8h.html#a3d3ca45799923aa5d138e9e5f9eb2da5" title="Binds image to allocation. ">vmaBindImageMemory()</a>.</li>
7474
<li>If you want to create a buffer or an image, allocate memory for it and bind them together, all in one call, you can use function <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>. This is the recommended way to use this library.</li>
7575
</ol>
7676
<p>When using 3. or 4., the library internally queries Vulkan for memory types supported for that buffer or image (function <code>vkGetBufferMemoryRequirements()</code>) and uses only one of these types.</p>

docs/html/globals.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ <h3><a id="index_v"></a>- v -</h3><ul>
158158
<li>VmaAllocatorCreateInfo
159159
: <a class="el" href="vk__mem__alloc_8h.html#ae0f6d1d733dded220d28134da46b4283">vk_mem_alloc.h</a>
160160
</li>
161+
<li>vmaBindBufferMemory()
162+
: <a class="el" href="vk__mem__alloc_8h.html#a6b0929b914b60cf2d45cac4bf3547470">vk_mem_alloc.h</a>
163+
</li>
164+
<li>vmaBindImageMemory()
165+
: <a class="el" href="vk__mem__alloc_8h.html#a3d3ca45799923aa5d138e9e5f9eb2da5">vk_mem_alloc.h</a>
166+
</li>
161167
<li>vmaBuildStatsString()
162168
: <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0">vk_mem_alloc.h</a>
163169
</li>

docs/html/globals_func.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ <h3><a id="index_v"></a>- v -</h3><ul>
7070
<li>vmaAllocateMemoryForImage()
7171
: <a class="el" href="vk__mem__alloc_8h.html#a0faa3f9e5fb233d29d1e00390650febb">vk_mem_alloc.h</a>
7272
</li>
73+
<li>vmaBindBufferMemory()
74+
: <a class="el" href="vk__mem__alloc_8h.html#a6b0929b914b60cf2d45cac4bf3547470">vk_mem_alloc.h</a>
75+
</li>
76+
<li>vmaBindImageMemory()
77+
: <a class="el" href="vk__mem__alloc_8h.html#a3d3ca45799923aa5d138e9e5f9eb2da5">vk_mem_alloc.h</a>
78+
</li>
7379
<li>vmaBuildStatsString()
7480
: <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0">vk_mem_alloc.h</a>
7581
</li>

docs/html/search/all_f.js

Lines changed: 2 additions & 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: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/html/statistics.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ <h1><a class="anchor" id="statistics_numeric_statistics"></a>
7474
<p>You can query for information about specific allocation using function <a class="el" href="vk__mem__alloc_8h.html#a86dd08aba8633bfa4ad0df2e76481d8b" title="Returns current information about specified allocation and atomically marks it as used in current fra...">vmaGetAllocationInfo()</a>. It fill structure <a class="el" href="struct_vma_allocation_info.html" title="Parameters of VmaAllocation objects, that can be retrieved using function vmaGetAllocationInfo(). ">VmaAllocationInfo</a>.</p>
7575
<h1><a class="anchor" id="statistics_json_dump"></a>
7676
JSON dump</h1>
77-
<p>You can dump internal state of the allocator to a string in JSON format using function <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0" title="Builds and returns statistics as string in JSON format. ">vmaBuildStatsString()</a>. The result is guaranteed to be correct JSON. It uses ANSI encoding. Any strings provided by user (see <a class="el" href="allocation_annotation.html#allocation_names">Allocation names</a>) are copied as-is and properly escaped for JSON, so if they use UTF-8, ISO-8859-2 or any other encoding, this JSON string can be treted as using this encoding. It must be freed using function <a class="el" href="vk__mem__alloc_8h.html#a3104eb30d8122c84dd8541063f145288">vmaFreeStatsString()</a>.</p>
78-
<p>The format of this string is not part of official documentation of the library, but it will not change in backward-incompatible way without increasing library major version number and mention in changelog.</p>
79-
<p>The string contains all the data that can be obtained using <a class="el" href="vk__mem__alloc_8h.html#a333b61c1788cb23559177531e6a93ca3" title="Retrieves statistics from current state of the Allocator. ">vmaCalculateStats()</a>. It can also contain detailed map of allocated memory blocks and their regions - free and occupied by allocations. This allows e.g. to visualize the memory or assess fragmentation. </p>
77+
<p>You can dump internal state of the allocator to a string in JSON format using function <a class="el" href="vk__mem__alloc_8h.html#aa4fee7eb5253377599ef4fd38c93c2a0" title="Builds and returns statistics as string in JSON format. ">vmaBuildStatsString()</a>. The result is guaranteed to be correct JSON. It uses ANSI encoding. Any strings provided by user (see <a class="el" href="allocation_annotation.html#allocation_names">Allocation names</a>) are copied as-is and properly escaped for JSON, so if they use UTF-8, ISO-8859-2 or any other encoding, this JSON string can be treated as using this encoding. It must be freed using function <a class="el" href="vk__mem__alloc_8h.html#a3104eb30d8122c84dd8541063f145288">vmaFreeStatsString()</a>.</p>
78+
<p>The format of this JSON string is not part of official documentation of the library, but it will not change in backward-incompatible way without increasing library major version number and appropriate mention in changelog.</p>
79+
<p>The JSON string contains all the data that can be obtained using <a class="el" href="vk__mem__alloc_8h.html#a333b61c1788cb23559177531e6a93ca3" title="Retrieves statistics from current state of the Allocator. ">vmaCalculateStats()</a>. It can also contain detailed map of allocated memory blocks and their regions - free and occupied by allocations. This allows e.g. to visualize the memory or assess fragmentation. </p>
8080
</div></div><!-- contents -->
8181
<!-- start footer part -->
8282
<hr class="footer"/><address class="footer"><small>

docs/html/vk__mem__alloc_8h.html

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@
287287
<tr class="memitem:a6aced90fcc7b39882b6654a740a0b9bb"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vk__mem__alloc_8h.html#a6aced90fcc7b39882b6654a740a0b9bb">vmaDefragment</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> *pAllocations, size_t allocationCount, VkBool32 *pAllocationsChanged, const <a class="el" href="struct_vma_defragmentation_info.html">VmaDefragmentationInfo</a> *pDefragmentationInfo, <a class="el" href="struct_vma_defragmentation_stats.html">VmaDefragmentationStats</a> *pDefragmentationStats)</td></tr>
288288
<tr class="memdesc:a6aced90fcc7b39882b6654a740a0b9bb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compacts memory by moving allocations. <a href="#a6aced90fcc7b39882b6654a740a0b9bb">More...</a><br /></td></tr>
289289
<tr class="separator:a6aced90fcc7b39882b6654a740a0b9bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
290+
<tr class="memitem:a6b0929b914b60cf2d45cac4bf3547470"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vk__mem__alloc_8h.html#a6b0929b914b60cf2d45cac4bf3547470">vmaBindBufferMemory</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation, VkBuffer buffer)</td></tr>
291+
<tr class="memdesc:a6b0929b914b60cf2d45cac4bf3547470"><td class="mdescLeft">&#160;</td><td class="mdescRight">Binds buffer to allocation. <a href="#a6b0929b914b60cf2d45cac4bf3547470">More...</a><br /></td></tr>
292+
<tr class="separator:a6b0929b914b60cf2d45cac4bf3547470"><td class="memSeparator" colspan="2">&#160;</td></tr>
293+
<tr class="memitem:a3d3ca45799923aa5d138e9e5f9eb2da5"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vk__mem__alloc_8h.html#a3d3ca45799923aa5d138e9e5f9eb2da5">vmaBindImageMemory</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation, VkImage image)</td></tr>
294+
<tr class="memdesc:a3d3ca45799923aa5d138e9e5f9eb2da5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Binds image to allocation. <a href="#a3d3ca45799923aa5d138e9e5f9eb2da5">More...</a><br /></td></tr>
295+
<tr class="separator:a3d3ca45799923aa5d138e9e5f9eb2da5"><td class="memSeparator" colspan="2">&#160;</td></tr>
290296
<tr class="memitem:ac72ee55598617e8eecca384e746bab51"><td class="memItemLeft" align="right" valign="top">VkResult&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vk__mem__alloc_8h.html#ac72ee55598617e8eecca384e746bab51">vmaCreateBuffer</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, const VkBufferCreateInfo *pBufferCreateInfo, const <a class="el" href="struct_vma_allocation_create_info.html">VmaAllocationCreateInfo</a> *pAllocationCreateInfo, VkBuffer *pBuffer, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> *pAllocation, <a class="el" href="struct_vma_allocation_info.html">VmaAllocationInfo</a> *pAllocationInfo)</td></tr>
291297
<tr class="separator:ac72ee55598617e8eecca384e746bab51"><td class="memSeparator" colspan="2">&#160;</td></tr>
292298
<tr class="memitem:a0d9f4e4ba5bf9aab1f1c746387753d77"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="vk__mem__alloc_8h.html#a0d9f4e4ba5bf9aab1f1c746387753d77">vmaDestroyBuffer</a> (<a class="el" href="struct_vma_allocator.html">VmaAllocator</a> allocator, VkBuffer buffer, <a class="el" href="struct_vma_allocation.html">VmaAllocation</a> allocation)</td></tr>
@@ -929,6 +935,82 @@ <h2 class="memtitle"><span class="permalink"><a href="#a0faa3f9e5fb233d29d1e0039
929935

930936
<p>Function similar to <a class="el" href="vk__mem__alloc_8h.html#a7fdf64415b6c3d83c454f28d2c53df7b">vmaAllocateMemoryForBuffer()</a>. </p>
931937

938+
</div>
939+
</div>
940+
<a id="a6b0929b914b60cf2d45cac4bf3547470"></a>
941+
<h2 class="memtitle"><span class="permalink"><a href="#a6b0929b914b60cf2d45cac4bf3547470">&#9670;&nbsp;</a></span>vmaBindBufferMemory()</h2>
942+
943+
<div class="memitem">
944+
<div class="memproto">
945+
<table class="memname">
946+
<tr>
947+
<td class="memname">VkResult vmaBindBufferMemory </td>
948+
<td>(</td>
949+
<td class="paramtype"><a class="el" href="struct_vma_allocator.html">VmaAllocator</a>&#160;</td>
950+
<td class="paramname"><em>allocator</em>, </td>
951+
</tr>
952+
<tr>
953+
<td class="paramkey"></td>
954+
<td></td>
955+
<td class="paramtype"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a>&#160;</td>
956+
<td class="paramname"><em>allocation</em>, </td>
957+
</tr>
958+
<tr>
959+
<td class="paramkey"></td>
960+
<td></td>
961+
<td class="paramtype">VkBuffer&#160;</td>
962+
<td class="paramname"><em>buffer</em>&#160;</td>
963+
</tr>
964+
<tr>
965+
<td></td>
966+
<td>)</td>
967+
<td></td><td></td>
968+
</tr>
969+
</table>
970+
</div><div class="memdoc">
971+
972+
<p>Binds buffer to allocation. </p>
973+
<p>Binds specified buffer to region of memory represented by specified allocation. Gets <code>VkDeviceMemory</code> handle and offset from the allocation. If you want to create a buffer, allocate memory for it and bind them together separately, you should use this function for binding instead of standard <code>vkBindBufferMemory()</code>, because it ensures proper synchronization so that when a <code>VkDeviceMemory</code> object is used by multiple allocations, calls to <code>vkBind*Memory()</code> or <code>vkMapMemory()</code> won't happen from multiple threads simultaneously (which is illegal in Vulkan).</p>
974+
<p>It is recommended to use function <a class="el" href="vk__mem__alloc_8h.html#ac72ee55598617e8eecca384e746bab51">vmaCreateBuffer()</a> instead of this one. </p>
975+
976+
</div>
977+
</div>
978+
<a id="a3d3ca45799923aa5d138e9e5f9eb2da5"></a>
979+
<h2 class="memtitle"><span class="permalink"><a href="#a3d3ca45799923aa5d138e9e5f9eb2da5">&#9670;&nbsp;</a></span>vmaBindImageMemory()</h2>
980+
981+
<div class="memitem">
982+
<div class="memproto">
983+
<table class="memname">
984+
<tr>
985+
<td class="memname">VkResult vmaBindImageMemory </td>
986+
<td>(</td>
987+
<td class="paramtype"><a class="el" href="struct_vma_allocator.html">VmaAllocator</a>&#160;</td>
988+
<td class="paramname"><em>allocator</em>, </td>
989+
</tr>
990+
<tr>
991+
<td class="paramkey"></td>
992+
<td></td>
993+
<td class="paramtype"><a class="el" href="struct_vma_allocation.html">VmaAllocation</a>&#160;</td>
994+
<td class="paramname"><em>allocation</em>, </td>
995+
</tr>
996+
<tr>
997+
<td class="paramkey"></td>
998+
<td></td>
999+
<td class="paramtype">VkImage&#160;</td>
1000+
<td class="paramname"><em>image</em>&#160;</td>
1001+
</tr>
1002+
<tr>
1003+
<td></td>
1004+
<td>)</td>
1005+
<td></td><td></td>
1006+
</tr>
1007+
</table>
1008+
</div><div class="memdoc">
1009+
1010+
<p>Binds image to allocation. </p>
1011+
<p>Binds specified image to region of memory represented by specified allocation. Gets <code>VkDeviceMemory</code> handle and offset from the allocation. If you want to create an image, allocate memory for it and bind them together separately, you should use this function for binding instead of standard <code>vkBindImageMemory()</code>, because it ensures proper synchronization so that when a <code>VkDeviceMemory</code> object is used by multiple allocations, calls to <code>vkBind*Memory()</code> or <code>vkMapMemory()</code> won't happen from multiple threads simultaneously (which is illegal in Vulkan).</p>
1012+
<p>It is recommended to use function <a class="el" href="vk__mem__alloc_8h.html#a02a94f25679275851a53e82eacbcfc73" title="Function similar to vmaCreateBuffer(). ">vmaCreateImage()</a> instead of this one. </p>
1013+
9321014
</div>
9331015
</div>
9341016
<a id="aa4fee7eb5253377599ef4fd38c93c2a0"></a>

docs/html/vk__mem__alloc_8h_source.html

Lines changed: 111 additions & 109 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)