Skip to content

Commit 58a9e40

Browse files
VmaBlockVector::Defragment: Minor fix for case when VMA_DEBUG_DETECT_CORRUPTION != 0.
1 parent e31dd15 commit 58a9e40

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/vk_mem_alloc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12119,9 +12119,13 @@ void VmaBlockVector::Defragment(
1211912119

1212012120
const VkMemoryPropertyFlags memPropFlags =
1212112121
m_hAllocator->m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags;
12122+
const bool isHostVisible = (memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0;
12123+
const bool isHostCoherent = (memPropFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0;
12124+
1212212125
const bool canDefragmentOnCpu = maxCpuBytesToMove > 0 && maxCpuAllocationsToMove > 0 &&
12123-
(memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0;
12124-
const bool canDefragmentOnGpu = maxGpuBytesToMove > 0 && maxGpuAllocationsToMove > 0;
12126+
isHostVisible;
12127+
const bool canDefragmentOnGpu = maxGpuBytesToMove > 0 && maxGpuAllocationsToMove > 0 &&
12128+
(VMA_DEBUG_DETECT_CORRUPTION == 0 || !(isHostVisible && isHostCoherent));
1212512129

1212612130
// There are options to defragment this memory type.
1212712131
if(canDefragmentOnCpu || canDefragmentOnGpu)

0 commit comments

Comments
 (0)