mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-22 15:04:34 +00:00
Updated tests and documentation for VMA_DEBUG_MARGIN
Fixed type of VmaVirtualBlockCreateInfo::flags. Rebuilt the docs.
This commit is contained in:
parent
ab134958f5
commit
ab16036dd5
Binary file not shown.
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 6.4 KiB |
@ -82,23 +82,23 @@ Memory initialization</h1>
|
||||
Margins</h1>
|
||||
<p >By default, allocations are laid out in memory blocks next to each other if possible (considering required alignment, <code>bufferImageGranularity</code>, and <code>nonCoherentAtomSize</code>).</p>
|
||||
<p ><img src="../gfx/Margins_1.png" alt="Allocations without margin" class="inline"/></p>
|
||||
<p >Define macro <code>VMA_DEBUG_MARGIN</code> to some non-zero value (e.g. 16) to enforce specified number of bytes as a margin before and after every allocation.</p>
|
||||
<p >Define macro <code>VMA_DEBUG_MARGIN</code> to some non-zero value (e.g. 16) to enforce specified number of bytes as a margin after every allocation.</p>
|
||||
<div class="fragment"><div class="line"><span class="preprocessor">#define VMA_DEBUG_MARGIN 16</span></div>
|
||||
<div class="line"><span class="preprocessor">#include "vk_mem_alloc.h"</span></div>
|
||||
</div><!-- fragment --><p ><img src="../gfx/Margins_2.png" alt="Allocations with margin" class="inline"/></p>
|
||||
<p >If your bug goes away after enabling margins, it means it may be caused by memory being overwritten outside of allocation boundaries. It is not 100% certain though. Change in application behavior may also be caused by different order and distribution of allocations across memory blocks after margins are applied.</p>
|
||||
<p >The margin is applied also before first and after last allocation in a block. It may occur only once between two adjacent allocations.</p>
|
||||
<p >Margins work with all types of memory.</p>
|
||||
<p >Margin is applied only to allocations made out of memory blocks and not to dedicated allocations, which have their own memory block of specific size. It is thus not applied to allocations made using <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> flag or those automatically decided to put into dedicated allocations, e.g. due to its large size or recommended by VK_KHR_dedicated_allocation extension. Margins are also not active in custom pools created with <a class="el" href="group__group__alloc.html#gga9a7c45f9c863695d98c83fa5ac940fe7a97a0dc38e5161b780594d998d313d35e" title="Enables alternative, buddy allocation algorithm in this pool.">VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT</a> flag.</p>
|
||||
<p >Margins appear in <a class="el" href="statistics.html#statistics_json_dump">JSON dump</a> as part of free space.</p>
|
||||
<p >Note that enabling margins increases memory usage and fragmentation.</p>
|
||||
<p >Margins do not apply to <a class="el" href="virtual_allocator.html">Virtual allocator</a>.</p>
|
||||
<h1><a class="anchor" id="debugging_memory_usage_corruption_detection"></a>
|
||||
Corruption detection</h1>
|
||||
<p >You can additionally define macro <code>VMA_DEBUG_DETECT_CORRUPTION</code> to 1 to enable validation of contents of the margins.</p>
|
||||
<div class="fragment"><div class="line"><span class="preprocessor">#define VMA_DEBUG_MARGIN 16</span></div>
|
||||
<div class="line"><span class="preprocessor">#define VMA_DEBUG_DETECT_CORRUPTION 1</span></div>
|
||||
<div class="line"><span class="preprocessor">#include "vk_mem_alloc.h"</span></div>
|
||||
</div><!-- fragment --><p >When this feature is enabled, number of bytes specified as <code>VMA_DEBUG_MARGIN</code> (it must be multiply of 4) before and after every allocation is filled with a magic number. This idea is also know as "canary". Memory is automatically mapped and unmapped if necessary.</p>
|
||||
</div><!-- fragment --><p >When this feature is enabled, number of bytes specified as <code>VMA_DEBUG_MARGIN</code> (it must be multiply of 4) after every allocation is filled with a magic number. This idea is also know as "canary". Memory is automatically mapped and unmapped if necessary.</p>
|
||||
<p >This number is validated automatically when the allocation is destroyed. If it is not equal to the expected value, <code>VMA_ASSERT()</code> is executed. It clearly means that either CPU or GPU overwritten the memory outside of boundaries of the allocation, which indicates a serious bug.</p>
|
||||
<p >You can also explicitly request checking margins of all allocations in all memory blocks that belong to specified memory types by using function <a class="el" href="group__group__alloc.html#ga49329a7f030dafcf82f7b73334c22e98" title="Checks magic number in margins around all allocations in given memory types (in both default and cust...">vmaCheckCorruption()</a>, or in memory blocks that belong to specified custom pool, by using function <a class="el" href="group__group__alloc.html#gad535935619c7a549bf837e1bb0068f89" title="Checks magic number in margins around all allocations in given memory pool in search for corruptions.">vmaCheckPoolCorruption()</a>.</p>
|
||||
<p >Margin validation (corruption detection) works only for memory types that are <code>HOST_VISIBLE</code> and <code>HOST_COHERENT</code>. </p>
|
||||
|
@ -99,7 +99,7 @@ $(function() {
|
||||
|
||||
|
||||
<h3><a id="index_f" name="index_f"></a>- f -</h3><ul>
|
||||
<li>flags : <a class="el" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">VmaAllocationCreateInfo</a>, <a class="el" href="struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9">VmaDefragmentationInfo2</a>, <a class="el" href="struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446">VmaPoolCreateInfo</a>, <a class="el" href="struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4">VmaVirtualAllocationCreateInfo</a>, <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09">VmaVirtualBlockCreateInfo</a></li>
|
||||
<li>flags : <a class="el" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">VmaAllocationCreateInfo</a>, <a class="el" href="struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9">VmaDefragmentationInfo2</a>, <a class="el" href="struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446">VmaPoolCreateInfo</a>, <a class="el" href="struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4">VmaVirtualAllocationCreateInfo</a>, <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912">VmaVirtualBlockCreateInfo</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -99,7 +99,7 @@ $(function() {
|
||||
|
||||
|
||||
<h3><a id="index_f" name="index_f"></a>- f -</h3><ul>
|
||||
<li>flags : <a class="el" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">VmaAllocationCreateInfo</a>, <a class="el" href="struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9">VmaDefragmentationInfo2</a>, <a class="el" href="struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446">VmaPoolCreateInfo</a>, <a class="el" href="struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4">VmaVirtualAllocationCreateInfo</a>, <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09">VmaVirtualBlockCreateInfo</a></li>
|
||||
<li>flags : <a class="el" href="struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b">VmaAllocationCreateInfo</a>, <a class="el" href="struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346">VmaAllocatorCreateInfo</a>, <a class="el" href="struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9">VmaDefragmentationInfo2</a>, <a class="el" href="struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446">VmaPoolCreateInfo</a>, <a class="el" href="struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4">VmaVirtualAllocationCreateInfo</a>, <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912">VmaVirtualBlockCreateInfo</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -95,10 +95,10 @@ Classes</h2></td></tr>
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="typedef-members" name="typedef-members"></a>
|
||||
Typedefs</h2></td></tr>
|
||||
<tr class="memitem:ga0860ba1c0a67178fae4aecb63a78573e"><td class="memItemLeft" align="right" valign="top">typedef enum <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">VmaVirtualBlockCreateFlagBits</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e">VmaVirtualBlockCreateFlagBits</a></td></tr>
|
||||
<tr class="memdesc:ga0860ba1c0a67178fae4aecb63a78573e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga0860ba1c0a67178fae4aecb63a78573e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga0860ba1c0a67178fae4aecb63a78573e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="memItemLeft" align="right" valign="top">typedef VkFlags </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">VmaVirtualBlockCreateFlags</a></td></tr>
|
||||
<tr class="memdesc:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. See <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. <a href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. See <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. <a href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga936815e64946a6b6d812d08d10184c23"><td class="memItemLeft" align="right" valign="top">typedef enum <a class="el" href="group__group__virtual.html#ga2e9c64d405b14156fea7e10c4ad06cb6">VmaVirtualAllocationCreateFlagBits</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga936815e64946a6b6d812d08d10184c23">VmaVirtualAllocationCreateFlagBits</a></td></tr>
|
||||
<tr class="memdesc:ga936815e64946a6b6d812d08d10184c23"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4" title="Use combination of VmaVirtualAllocationCreateFlagBits.">VmaVirtualAllocationCreateInfo::flags</a>. <a href="group__group__virtual.html#ga936815e64946a6b6d812d08d10184c23">More...</a><br /></td></tr>
|
||||
@ -127,7 +127,7 @@ Enumerations</h2></td></tr>
|
||||
  <a class="el" href="group__group__virtual.html#gga88bcf8c1cd3bb1610ff7343811c65bcaa5fc0d333c3d5687a8bbf57df9b377a87">VMA_VIRTUAL_BLOCK_CREATE_FLAG_BITS_MAX_ENUM</a> = 0x7FFFFFFF
|
||||
<br />
|
||||
}</td></tr>
|
||||
<tr class="memdesc:ga88bcf8c1cd3bb1610ff7343811c65bca"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga88bcf8c1cd3bb1610ff7343811c65bca"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga88bcf8c1cd3bb1610ff7343811c65bca"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga2e9c64d405b14156fea7e10c4ad06cb6"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga2e9c64d405b14156fea7e10c4ad06cb6">VmaVirtualAllocationCreateFlagBits</a> { <br />
|
||||
  <a class="el" href="group__group__virtual.html#gga2e9c64d405b14156fea7e10c4ad06cb6a9524a329a55b5ec390d57d90b67ad78e">VMA_VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a> = VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT
|
||||
@ -252,7 +252,7 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. </p>
|
||||
<p>Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -268,7 +268,7 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. See <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. </p>
|
||||
<p>Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. See <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -330,7 +330,7 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
||||
<p>Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. </p>
|
||||
<p>Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. </p>
|
||||
<table class="fieldtable">
|
||||
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga88bcf8c1cd3bb1610ff7343811c65bcaae6423e2fa2f3c9211b21c819e3f10f96" name="gga88bcf8c1cd3bb1610ff7343811c65bcaae6423e2fa2f3c9211b21c819e3f10f96"></a>VMA_VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT </td><td class="fielddoc"><p >Enables alternative, linear allocation algorithm in this virtual block. </p>
|
||||
<p >Specify this flag to enable linear allocation algorithm, which always creates new allocations after last one and doesn't reuse space from allocations freed in between. It trades memory consumption for simplified algorithm and data structure, which has better performance and uses less memory for metadata.</p>
|
||||
|
@ -1,4 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['flags_0',['flags',['../struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346',1,'VmaAllocatorCreateInfo::flags()'],['../struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b',1,'VmaAllocationCreateInfo::flags()'],['../struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446',1,'VmaPoolCreateInfo::flags()'],['../struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9',1,'VmaDefragmentationInfo2::flags()'],['../struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09',1,'VmaVirtualBlockCreateInfo::flags()'],['../struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4',1,'VmaVirtualAllocationCreateInfo::flags()']]]
|
||||
['flags_0',['flags',['../struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346',1,'VmaAllocatorCreateInfo::flags()'],['../struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b',1,'VmaAllocationCreateInfo::flags()'],['../struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446',1,'VmaPoolCreateInfo::flags()'],['../struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9',1,'VmaDefragmentationInfo2::flags()'],['../struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912',1,'VmaVirtualBlockCreateInfo::flags()'],['../struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4',1,'VmaVirtualAllocationCreateInfo::flags()']]]
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
var searchData=
|
||||
[
|
||||
['flags_0',['flags',['../struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346',1,'VmaAllocatorCreateInfo::flags()'],['../struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b',1,'VmaAllocationCreateInfo::flags()'],['../struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446',1,'VmaPoolCreateInfo::flags()'],['../struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9',1,'VmaDefragmentationInfo2::flags()'],['../struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09',1,'VmaVirtualBlockCreateInfo::flags()'],['../struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4',1,'VmaVirtualAllocationCreateInfo::flags()']]]
|
||||
['flags_0',['flags',['../struct_vma_allocator_create_info.html#a392ea2ecbaff93f91a7c49f735ad4346',1,'VmaAllocatorCreateInfo::flags()'],['../struct_vma_allocation_create_info.html#add09658ac14fe290ace25470ddd6d41b',1,'VmaAllocationCreateInfo::flags()'],['../struct_vma_pool_create_info.html#a8405139f63d078340ae74513a59f5446',1,'VmaPoolCreateInfo::flags()'],['../struct_vma_defragmentation_info2.html#a53e844ee5633e229cf6daf14b2d9fff9',1,'VmaDefragmentationInfo2::flags()'],['../struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912',1,'VmaVirtualBlockCreateInfo::flags()'],['../struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4',1,'VmaVirtualAllocationCreateInfo::flags()']]]
|
||||
];
|
||||
|
@ -68,7 +68,7 @@ $(function() {
|
||||
|
||||
<p>This is the complete list of members for <a class="el" href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a>, including all inherited members.</p>
|
||||
<table class="directory">
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09">flags</a></td><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></td><td class="entry"></td></tr>
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912">flags</a></td><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></td><td class="entry"></td></tr>
|
||||
<tr class="odd"><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html#a290283bf915c257d24584872d793ad30">pAllocationCallbacks</a></td><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></td><td class="entry"></td></tr>
|
||||
<tr class="even"><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">size</a></td><td class="entry"><a class="el" href="struct_vma_virtual_block_create_info.html">VmaVirtualBlockCreateInfo</a></td><td class="entry"></td></tr>
|
||||
</table></div><!-- contents -->
|
||||
|
@ -79,9 +79,9 @@ Public Attributes</h2></td></tr>
|
||||
<tr class="memitem:a670ab8c6a6e822f3c36781d79e8824e9"><td class="memItemLeft" align="right" valign="top">VkDeviceSize </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">size</a></td></tr>
|
||||
<tr class="memdesc:a670ab8c6a6e822f3c36781d79e8824e9"><td class="mdescLeft"> </td><td class="mdescRight">Total size of the virtual block. <a href="struct_vma_virtual_block_create_info.html#a670ab8c6a6e822f3c36781d79e8824e9">More...</a><br /></td></tr>
|
||||
<tr class="separator:a670ab8c6a6e822f3c36781d79e8824e9"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a5838b15c053a0370420e4e1d82d09c09"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">VmaVirtualBlockCreateFlagBits</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09">flags</a></td></tr>
|
||||
<tr class="memdesc:a5838b15c053a0370420e4e1d82d09c09"><td class="mdescLeft"> </td><td class="mdescRight">Use combination of <a class="el" href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. <a href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09">More...</a><br /></td></tr>
|
||||
<tr class="separator:a5838b15c053a0370420e4e1d82d09c09"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:aaab9bf7e2d228c02ab6d90a72a6e6912"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">VmaVirtualBlockCreateFlags</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912">flags</a></td></tr>
|
||||
<tr class="memdesc:aaab9bf7e2d228c02ab6d90a72a6e6912"><td class="mdescLeft"> </td><td class="mdescRight">Use combination of <a class="el" href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. <a href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912">More...</a><br /></td></tr>
|
||||
<tr class="separator:aaab9bf7e2d228c02ab6d90a72a6e6912"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:a290283bf915c257d24584872d793ad30"><td class="memItemLeft" align="right" valign="top">const VkAllocationCallbacks * </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_vma_virtual_block_create_info.html#a290283bf915c257d24584872d793ad30">pAllocationCallbacks</a></td></tr>
|
||||
<tr class="memdesc:a290283bf915c257d24584872d793ad30"><td class="mdescLeft"> </td><td class="mdescRight">Custom CPU memory allocation callbacks. Optional. <a href="struct_vma_virtual_block_create_info.html#a290283bf915c257d24584872d793ad30">More...</a><br /></td></tr>
|
||||
<tr class="separator:a290283bf915c257d24584872d793ad30"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
@ -89,14 +89,14 @@ Public Attributes</h2></td></tr>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p >Parameters of created <a class="el" href="struct_vma_virtual_block.html" title="Handle to a virtual block object that allows to use core allocation algorithm without allocating any ...">VmaVirtualBlock</a> object to be passed to <a class="el" href="group__group__virtual.html#gab585754076877265fdae33e5c40ef13b" title="Creates new VmaVirtualBlock object.">vmaCreateVirtualBlock()</a>. </p>
|
||||
</div><h2 class="groupheader">Member Data Documentation</h2>
|
||||
<a id="a5838b15c053a0370420e4e1d82d09c09" name="a5838b15c053a0370420e4e1d82d09c09"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a5838b15c053a0370420e4e1d82d09c09">◆ </a></span>flags</h2>
|
||||
<a id="aaab9bf7e2d228c02ab6d90a72a6e6912" name="aaab9bf7e2d228c02ab6d90a72a6e6912"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#aaab9bf7e2d228c02ab6d90a72a6e6912">◆ </a></span>flags</h2>
|
||||
|
||||
<div class="memitem">
|
||||
<div class="memproto">
|
||||
<table class="memname">
|
||||
<tr>
|
||||
<td class="memname"><a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">VmaVirtualBlockCreateFlagBits</a> VmaVirtualBlockCreateInfo::flags</td>
|
||||
<td class="memname"><a class="el" href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">VmaVirtualBlockCreateFlags</a> VmaVirtualBlockCreateInfo::flags</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
|
@ -177,10 +177,10 @@ Typedefs</h2></td></tr>
|
||||
<tr class="memitem:ga88a77cef37e5d3c4fc9eb328885d048d"><td class="memItemLeft" align="right" valign="top">typedef VkFlags </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__alloc.html#ga88a77cef37e5d3c4fc9eb328885d048d">VmaDefragmentationFlags</a></td></tr>
|
||||
<tr class="separator:ga88a77cef37e5d3c4fc9eb328885d048d"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga0860ba1c0a67178fae4aecb63a78573e"><td class="memItemLeft" align="right" valign="top">typedef enum <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">VmaVirtualBlockCreateFlagBits</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e">VmaVirtualBlockCreateFlagBits</a></td></tr>
|
||||
<tr class="memdesc:ga0860ba1c0a67178fae4aecb63a78573e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga0860ba1c0a67178fae4aecb63a78573e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga0860ba1c0a67178fae4aecb63a78573e">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga0860ba1c0a67178fae4aecb63a78573e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="memItemLeft" align="right" valign="top">typedef VkFlags </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">VmaVirtualBlockCreateFlags</a></td></tr>
|
||||
<tr class="memdesc:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. See <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. <a href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. See <a class="el" href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca" title="Flags to be passed as VmaVirtualBlockCreateInfo::flags.">VmaVirtualBlockCreateFlagBits</a>. <a href="group__group__virtual.html#ga4e49c2f0ab7f6b4868833e5bac78d91e">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga4e49c2f0ab7f6b4868833e5bac78d91e"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga936815e64946a6b6d812d08d10184c23"><td class="memItemLeft" align="right" valign="top">typedef enum <a class="el" href="group__group__virtual.html#ga2e9c64d405b14156fea7e10c4ad06cb6">VmaVirtualAllocationCreateFlagBits</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga936815e64946a6b6d812d08d10184c23">VmaVirtualAllocationCreateFlagBits</a></td></tr>
|
||||
<tr class="memdesc:ga936815e64946a6b6d812d08d10184c23"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_allocation_create_info.html#ab10e16956cc4bf20ced9de77d1129ea4" title="Use combination of VmaVirtualAllocationCreateFlagBits.">VmaVirtualAllocationCreateInfo::flags</a>. <a href="group__group__virtual.html#ga936815e64946a6b6d812d08d10184c23">More...</a><br /></td></tr>
|
||||
@ -330,7 +330,7 @@ Enumerations</h2></td></tr>
|
||||
  <a class="el" href="group__group__virtual.html#gga88bcf8c1cd3bb1610ff7343811c65bcaa5fc0d333c3d5687a8bbf57df9b377a87">VMA_VIRTUAL_BLOCK_CREATE_FLAG_BITS_MAX_ENUM</a> = 0x7FFFFFFF
|
||||
<br />
|
||||
}</td></tr>
|
||||
<tr class="memdesc:ga88bcf8c1cd3bb1610ff7343811c65bca"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#a5838b15c053a0370420e4e1d82d09c09" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">More...</a><br /></td></tr>
|
||||
<tr class="memdesc:ga88bcf8c1cd3bb1610ff7343811c65bca"><td class="mdescLeft"> </td><td class="mdescRight">Flags to be passed as <a class="el" href="struct_vma_virtual_block_create_info.html#aaab9bf7e2d228c02ab6d90a72a6e6912" title="Use combination of VmaVirtualBlockCreateFlagBits.">VmaVirtualBlockCreateInfo::flags</a>. <a href="group__group__virtual.html#ga88bcf8c1cd3bb1610ff7343811c65bca">More...</a><br /></td></tr>
|
||||
<tr class="separator:ga88bcf8c1cd3bb1610ff7343811c65bca"><td class="memSeparator" colspan="2"> </td></tr>
|
||||
<tr class="memitem:ga2e9c64d405b14156fea7e10c4ad06cb6"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__virtual.html#ga2e9c64d405b14156fea7e10c4ad06cb6">VmaVirtualAllocationCreateFlagBits</a> { <br />
|
||||
  <a class="el" href="group__group__virtual.html#gga2e9c64d405b14156fea7e10c4ad06cb6a9524a329a55b5ec390d57d90b67ad78e">VMA_VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT</a> = VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT
|
||||
|
@ -1450,7 +1450,7 @@ typedef struct VmaVirtualBlockCreateInfo
|
||||
|
||||
/** \brief Use combination of #VmaVirtualBlockCreateFlagBits.
|
||||
*/
|
||||
VmaVirtualBlockCreateFlagBits flags;
|
||||
VmaVirtualBlockCreateFlags flags;
|
||||
|
||||
/** \brief Custom CPU memory allocation callbacks. Optional.
|
||||
|
||||
@ -2831,7 +2831,7 @@ If providing your own implementation, you need to implement a subset of std::ato
|
||||
|
||||
#ifndef VMA_DEBUG_MARGIN
|
||||
/**
|
||||
Minimum margin before and after every allocation, in bytes.
|
||||
Minimum margin after every allocation, in bytes.
|
||||
Set nonzero for debugging purposes only.
|
||||
*/
|
||||
#define VMA_DEBUG_MARGIN (0)
|
||||
@ -2848,7 +2848,7 @@ If providing your own implementation, you need to implement a subset of std::ato
|
||||
#ifndef VMA_DEBUG_DETECT_CORRUPTION
|
||||
/**
|
||||
Define this macro to 1 together with non-zero value of VMA_DEBUG_MARGIN to
|
||||
enable writing magic value to the margin before and after every allocation and
|
||||
enable writing magic value to the margin after every allocation and
|
||||
validating it, so that memory corruptions (out-of-bounds writes) are detected.
|
||||
*/
|
||||
#define VMA_DEBUG_DETECT_CORRUPTION (0)
|
||||
@ -19276,7 +19276,7 @@ By default, allocations are laid out in memory blocks next to each other if poss
|
||||
![Allocations without margin](../gfx/Margins_1.png)
|
||||
|
||||
Define macro `VMA_DEBUG_MARGIN` to some non-zero value (e.g. 16) to enforce specified
|
||||
number of bytes as a margin before and after every allocation.
|
||||
number of bytes as a margin after every allocation.
|
||||
|
||||
\code
|
||||
#define VMA_DEBUG_MARGIN 16
|
||||
@ -19290,9 +19290,6 @@ being overwritten outside of allocation boundaries. It is not 100% certain thoug
|
||||
Change in application behavior may also be caused by different order and distribution
|
||||
of allocations across memory blocks after margins are applied.
|
||||
|
||||
The margin is applied also before first and after last allocation in a block.
|
||||
It may occur only once between two adjacent allocations.
|
||||
|
||||
Margins work with all types of memory.
|
||||
|
||||
Margin is applied only to allocations made out of memory blocks and not to dedicated
|
||||
@ -19306,6 +19303,8 @@ Margins appear in [JSON dump](@ref statistics_json_dump) as part of free space.
|
||||
|
||||
Note that enabling margins increases memory usage and fragmentation.
|
||||
|
||||
Margins do not apply to \ref virtual_allocator.
|
||||
|
||||
\section debugging_memory_usage_corruption_detection Corruption detection
|
||||
|
||||
You can additionally define macro `VMA_DEBUG_DETECT_CORRUPTION` to 1 to enable validation
|
||||
@ -19318,7 +19317,7 @@ of contents of the margins.
|
||||
\endcode
|
||||
|
||||
When this feature is enabled, number of bytes specified as `VMA_DEBUG_MARGIN`
|
||||
(it must be multiply of 4) before and after every allocation is filled with a magic number.
|
||||
(it must be multiply of 4) after every allocation is filled with a magic number.
|
||||
This idea is also know as "canary".
|
||||
Memory is automatically mapped and unmapped if necessary.
|
||||
|
||||
|
132
src/Tests.cpp
132
src/Tests.cpp
@ -3291,6 +3291,8 @@ static void TestPoolsAndAllocationParameters()
|
||||
|
||||
void TestHeapSizeLimit()
|
||||
{
|
||||
wprintf(L"Test heap size limit\n");
|
||||
|
||||
const VkDeviceSize HEAP_SIZE_LIMIT = 100ull * 1024 * 1024; // 100 MB
|
||||
const VkDeviceSize BLOCK_SIZE = 10ull * 1024 * 1024; // 10 MB
|
||||
|
||||
@ -3402,58 +3404,109 @@ static void TestDebugMargin()
|
||||
return;
|
||||
}
|
||||
|
||||
wprintf(L"Test VMA_DEBUG_MARGIN = %u\n", (uint32_t)VMA_DEBUG_MARGIN);
|
||||
|
||||
VkBufferCreateInfo bufInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
|
||||
bufInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
bufInfo.size = 256; // Doesn't matter
|
||||
|
||||
VmaAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY;
|
||||
|
||||
// Create few buffers of different size.
|
||||
const size_t BUF_COUNT = 10;
|
||||
BufferInfo buffers[BUF_COUNT];
|
||||
VmaAllocationInfo allocInfo[BUF_COUNT];
|
||||
for(size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
bufInfo.size = (VkDeviceSize)(i + 1) * 64;
|
||||
// Last one will be mapped.
|
||||
allocCreateInfo.flags = (i == BUF_COUNT - 1) ? VMA_ALLOCATION_CREATE_MAPPED_BIT : 0;
|
||||
VmaPoolCreateInfo poolCreateInfo = {};
|
||||
TEST(vmaFindMemoryTypeIndexForBufferInfo(
|
||||
g_hAllocator, &bufInfo, &allocCreateInfo, &poolCreateInfo.memoryTypeIndex) == VK_SUCCESS);
|
||||
|
||||
VkResult res = vmaCreateBuffer(g_hAllocator, &bufInfo, &allocCreateInfo, &buffers[i].Buffer, &buffers[i].Allocation, &allocInfo[i]);
|
||||
for(size_t algorithmIndex = 0; algorithmIndex < 2; ++algorithmIndex)
|
||||
{
|
||||
poolCreateInfo.flags = (algorithmIndex == 1 ? VMA_POOL_CREATE_TLSF_ALGORITHM_BIT : 0);
|
||||
VmaPool pool = VK_NULL_HANDLE;
|
||||
TEST(vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool) == VK_SUCCESS && pool);
|
||||
|
||||
allocCreateInfo.pool = pool;
|
||||
|
||||
// Create few buffers of different size.
|
||||
const size_t BUF_COUNT = 10;
|
||||
BufferInfo buffers[BUF_COUNT];
|
||||
VmaAllocationInfo allocInfo[BUF_COUNT];
|
||||
for(size_t allocIndex = 0; allocIndex < 10; ++allocIndex)
|
||||
{
|
||||
const bool isLast = allocIndex == BUF_COUNT - 1;
|
||||
bufInfo.size = (VkDeviceSize)(allocIndex + 1) * 256;
|
||||
// Last one will be mapped.
|
||||
allocCreateInfo.flags = isLast ? VMA_ALLOCATION_CREATE_MAPPED_BIT : 0;
|
||||
|
||||
VkResult res = vmaCreateBuffer(g_hAllocator, &bufInfo, &allocCreateInfo, &buffers[allocIndex].Buffer, &buffers[allocIndex].Allocation, &allocInfo[allocIndex]);
|
||||
TEST(res == VK_SUCCESS);
|
||||
|
||||
if(isLast)
|
||||
{
|
||||
// Fill with data.
|
||||
TEST(allocInfo[allocIndex].pMappedData != nullptr);
|
||||
// Uncomment this "+ 1" to overwrite past end of allocation and check corruption detection.
|
||||
memset(allocInfo[allocIndex].pMappedData, 0xFF, bufInfo.size /* + 1 */);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if their offsets preserve margin between them.
|
||||
std::sort(allocInfo, allocInfo + BUF_COUNT, [](const VmaAllocationInfo& lhs, const VmaAllocationInfo& rhs) -> bool
|
||||
{
|
||||
if(lhs.deviceMemory != rhs.deviceMemory)
|
||||
{
|
||||
return lhs.deviceMemory < rhs.deviceMemory;
|
||||
}
|
||||
return lhs.offset < rhs.offset;
|
||||
});
|
||||
for(size_t i = 1; i < BUF_COUNT; ++i)
|
||||
{
|
||||
if(allocInfo[i].deviceMemory == allocInfo[i - 1].deviceMemory)
|
||||
{
|
||||
TEST(allocInfo[i].offset >= allocInfo[i - 1].offset + VMA_DEBUG_MARGIN);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult res = vmaCheckCorruption(g_hAllocator, UINT32_MAX);
|
||||
TEST(res == VK_SUCCESS);
|
||||
|
||||
if(i == BUF_COUNT - 1)
|
||||
// JSON dump
|
||||
char* json = nullptr;
|
||||
vmaBuildStatsString(g_hAllocator, &json, VK_TRUE);
|
||||
int I = 1; // Put breakpoint here to manually inspect json in a debugger.
|
||||
vmaFreeStatsString(g_hAllocator, json);
|
||||
|
||||
// Destroy all buffers.
|
||||
for(size_t i = BUF_COUNT; i--; )
|
||||
{
|
||||
// Fill with data.
|
||||
TEST(allocInfo[i].pMappedData != nullptr);
|
||||
// Uncomment this "+ 1" to overwrite past end of allocation and check corruption detection.
|
||||
memset(allocInfo[i].pMappedData, 0xFF, bufInfo.size /* + 1 */);
|
||||
vmaDestroyBuffer(g_hAllocator, buffers[i].Buffer, buffers[i].Allocation);
|
||||
}
|
||||
|
||||
vmaDestroyPool(g_hAllocator, pool);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if their offsets preserve margin between them.
|
||||
std::sort(allocInfo, allocInfo + BUF_COUNT, [](const VmaAllocationInfo& lhs, const VmaAllocationInfo& rhs) -> bool
|
||||
static void TestDebugMarginNotInVirtualAllocator()
|
||||
{
|
||||
constexpr size_t ALLOCATION_COUNT = 10;
|
||||
for(size_t algorithm = 0; algorithm < 2; ++algorithm)
|
||||
{
|
||||
if(lhs.deviceMemory != rhs.deviceMemory)
|
||||
VmaVirtualBlockCreateInfo blockCreateInfo = {};
|
||||
blockCreateInfo.size = ALLOCATION_COUNT * MEGABYTE;
|
||||
blockCreateInfo.flags = (algorithm == 1 ? VMA_VIRTUAL_BLOCK_CREATE_TLSF_ALGORITHM_BIT : 0);
|
||||
|
||||
VmaVirtualBlock block = VK_NULL_HANDLE;
|
||||
TEST(vmaCreateVirtualBlock(&blockCreateInfo, &block) == VK_SUCCESS);
|
||||
|
||||
// Fill the entire block
|
||||
VmaVirtualAllocation allocs[ALLOCATION_COUNT];
|
||||
for(size_t i = 0; i < ALLOCATION_COUNT; ++i)
|
||||
{
|
||||
return lhs.deviceMemory < rhs.deviceMemory;
|
||||
VmaVirtualAllocationCreateInfo allocCreateInfo = {};
|
||||
allocCreateInfo.size = 1 * MEGABYTE;
|
||||
TEST(vmaVirtualAllocate(block, &allocCreateInfo, &allocs[i], nullptr) == VK_SUCCESS);
|
||||
}
|
||||
return lhs.offset < rhs.offset;
|
||||
});
|
||||
for(size_t i = 1; i < BUF_COUNT; ++i)
|
||||
{
|
||||
if(allocInfo[i].deviceMemory == allocInfo[i - 1].deviceMemory)
|
||||
{
|
||||
TEST(allocInfo[i].offset >= allocInfo[i - 1].offset + VMA_DEBUG_MARGIN);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult res = vmaCheckCorruption(g_hAllocator, UINT32_MAX);
|
||||
TEST(res == VK_SUCCESS);
|
||||
|
||||
// Destroy all buffers.
|
||||
for(size_t i = BUF_COUNT; i--; )
|
||||
{
|
||||
vmaDestroyBuffer(g_hAllocator, buffers[i].Buffer, buffers[i].Allocation);
|
||||
vmaClearVirtualBlock(block);
|
||||
vmaDestroyVirtualBlock(block);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -6947,21 +7000,21 @@ void Test()
|
||||
|
||||
// # Simple tests
|
||||
|
||||
#if VMA_DEBUG_MARGIN
|
||||
TestDebugMargin();
|
||||
TestDebugMarginNotInVirtualAllocator();
|
||||
#else
|
||||
TestBasics();
|
||||
TestVirtualBlocks();
|
||||
TestVirtualBlocksAlgorithms();
|
||||
TestVirtualBlocksAlgorithmsBenchmark();
|
||||
TestAllocationVersusResourceSize();
|
||||
//TestGpuData(); // Not calling this because it's just testing the testing environment.
|
||||
#if VMA_DEBUG_MARGIN
|
||||
TestDebugMargin();
|
||||
#else
|
||||
TestPool_SameSize();
|
||||
TestPool_MinBlockCount();
|
||||
TestPool_MinAllocationAlignment();
|
||||
TestPoolsAndAllocationParameters();
|
||||
TestHeapSizeLimit();
|
||||
#endif
|
||||
#if VMA_DEBUG_INITIALIZE_ALLOCATIONS
|
||||
TestAllocationsInitialization();
|
||||
#endif
|
||||
@ -7017,6 +7070,7 @@ void Test()
|
||||
//PerformCustomPoolTest(file);
|
||||
|
||||
fclose(file);
|
||||
#endif // #if defined(VMA_DEBUG_MARGIN) && VMA_DEBUG_MARGIN > 0
|
||||
|
||||
wprintf(L"Done, all PASSED.\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user