mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2025-05-15 01:08:31 +00:00
Small but important fix in the documentation
This commit is contained in:
parent
fadfc3fd13
commit
6b098e457e
140 changed files with 731 additions and 595 deletions
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.9.2"/>
|
||||
<meta name="generator" content="Doxygen 1.9.3"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Vulkan Memory Allocator: Debugging incorrect memory usage</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
|
@ -19,8 +19,8 @@
|
|||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<tr id="projectrow">
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Vulkan Memory Allocator
|
||||
</div>
|
||||
</td>
|
||||
|
@ -29,7 +29,7 @@
|
|||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.2 -->
|
||||
<!-- Generated by Doxygen 1.9.3 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
|
||||
|
@ -74,7 +74,8 @@ $(function() {
|
|||
Memory initialization</h1>
|
||||
<p >If you experience a bug with incorrect and nondeterministic data in your program and you suspect uninitialized memory to be used, you can enable automatic memory initialization to verify this. To do it, define macro <code>VMA_DEBUG_INITIALIZE_ALLOCATIONS</code> to 1.</p>
|
||||
<div class="fragment"><div class="line"><span class="preprocessor">#define VMA_DEBUG_INITIALIZE_ALLOCATIONS 1</span></div>
|
||||
<div class="line"><span class="preprocessor">#include "vk_mem_alloc.h"</span></div>
|
||||
<div class="line"><span class="preprocessor">#include "<a class="code" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a>"</span></div>
|
||||
<div class="ttc" id="avk__mem__alloc_8h_html"><div class="ttname"><a href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a></div></div>
|
||||
</div><!-- fragment --><p >It makes memory of all new allocations initialized to bit pattern <code>0xDCDCDCDC</code>. Before an allocation is destroyed, its memory is filled with bit pattern <code>0xEFEFEFEF</code>. Memory is automatically mapped and unmapped if necessary.</p>
|
||||
<p >If you find these values while debugging your program, good chances are that you incorrectly read Vulkan memory that is allocated but not initialized, or already freed, respectively.</p>
|
||||
<p >Memory initialization works only with memory types that are <code>HOST_VISIBLE</code>. It works also with dedicated allocations.</p>
|
||||
|
@ -84,7 +85,7 @@ Margins</h1>
|
|||
<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 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 class="line"><span class="preprocessor">#include "<a class="code" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a>"</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 >Margins work with all types of memory.</p>
|
||||
|
@ -97,7 +98,7 @@ 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 class="line"><span class="preprocessor">#include "<a class="code" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a>"</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) 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>
|
||||
|
@ -106,7 +107,7 @@ Corruption detection</h1>
|
|||
</div><!-- PageDoc -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
|
||||
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue