Skip to content

Commit 5ab8c17

Browse files
Fix assert when VMA_DEBUG_INITIALIZE_ALLOCATIONS is used with new memory usage flags
Only mappable allocations are filled with bit pattern. See #260
1 parent 7de5cc0 commit 5ab8c17

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

docs/html/debugging_memory_usage.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ <h1><a class="anchor" id="debugging_memory_usage_initialization"></a>
7676
<div class="fragment"><div class="line"><span class="preprocessor">#define VMA_DEBUG_INITIALIZE_ALLOCATIONS 1</span></div>
7777
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="vk__mem__alloc_8h.html">vk_mem_alloc.h</a>&quot;</span></div>
7878
<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>
79-
</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>
79+
</div><!-- fragment --><p >It makes memory of 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>
8080
<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>
81-
<p >Memory initialization works only with memory types that are <code>HOST_VISIBLE</code>. It works also with dedicated allocations.</p>
81+
<p >Memory initialization works only with memory types that are <code>HOST_VISIBLE</code> and with allocations that can be mapped. It works also with dedicated allocations.</p>
8282
<h1><a class="anchor" id="debugging_memory_usage_margins"></a>
8383
Margins</h1>
8484
<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>

include/vk_mem_alloc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15906,6 +15906,7 @@ void VmaAllocator_T::UpdateVulkanBudget()
1590615906
void VmaAllocator_T::FillAllocation(const VmaAllocation hAllocation, uint8_t pattern)
1590715907
{
1590815908
if(VMA_DEBUG_INITIALIZE_ALLOCATIONS &&
15909+
hAllocation->IsMappingAllowed() &&
1590915910
(m_MemProps.memoryTypes[hAllocation->GetMemoryTypeIndex()].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
1591015911
{
1591115912
void* pData = VMA_NULL;
@@ -18823,14 +18824,14 @@ To do it, define macro `VMA_DEBUG_INITIALIZE_ALLOCATIONS` to 1.
1882318824
#include "vk_mem_alloc.h"
1882418825
\endcode
1882518826

18826-
It makes memory of all new allocations initialized to bit pattern `0xDCDCDCDC`.
18827+
It makes memory of new allocations initialized to bit pattern `0xDCDCDCDC`.
1882718828
Before an allocation is destroyed, its memory is filled with bit pattern `0xEFEFEFEF`.
1882818829
Memory is automatically mapped and unmapped if necessary.
1882918830

1883018831
If you find these values while debugging your program, good chances are that you incorrectly
1883118832
read Vulkan memory that is allocated but not initialized, or already freed, respectively.
1883218833

18833-
Memory initialization works only with memory types that are `HOST_VISIBLE`.
18834+
Memory initialization works only with memory types that are `HOST_VISIBLE` and with allocations that can be mapped.
1883418835
It works also with dedicated allocations.
1883518836

1883618837
\section debugging_memory_usage_margins Margins

0 commit comments

Comments
 (0)