@@ -4600,7 +4600,8 @@ void VmaVector<T, AllocatorT>::resize(size_t newCount)
4600
4600
4601
4601
if (newCapacity != m_Capacity)
4602
4602
{
4603
- T* const newArray = newCapacity ? VmaAllocateArray<T>(m_Allocator.m_pCallbacks, newCapacity) : VMA_NULL;
4603
+ VMA_HEAVY_ASSERT(newCapacity > 0);
4604
+ T* const newArray = VmaAllocateArray<T>(m_Allocator.m_pCallbacks, newCapacity);
4604
4605
const size_t elementsToCopy = VMA_MIN(m_Count, newCount);
4605
4606
if (elementsToCopy != 0)
4606
4607
{
@@ -11348,11 +11349,13 @@ bool VmaBlockVector::IsEmpty()
11348
11349
11349
11350
bool VmaBlockVector::IsCorruptionDetectionEnabled() const
11350
11351
{
11351
- const uint32_t requiredMemFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
11352
- return (VMA_DEBUG_DETECT_CORRUPTION != 0) &&
11353
- (VMA_DEBUG_MARGIN > 0) &&
11354
- (m_Algorithm == 0 || m_Algorithm == VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT) &&
11352
+ #if (VMA_DEBUG_DETECT_CORRUPTION == 0) || (VMA_DEBUG_MARGIN == 0)
11353
+ return false;
11354
+ #else
11355
+ constexpr uint32_t requiredMemFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
11356
+ return (m_Algorithm == 0 || m_Algorithm == VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT) &&
11355
11357
(m_hAllocator->m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags & requiredMemFlags) == requiredMemFlags;
11358
+ #endif
11356
11359
}
11357
11360
11358
11361
VkResult VmaBlockVector::Allocate(
@@ -11802,10 +11805,11 @@ VkResult VmaBlockVector::CommitAllocationRequest(
11802
11805
else
11803
11806
(*pAllocation)->SetUserData(m_hAllocator, pUserData);
11804
11807
m_hAllocator->m_Budget.AddAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), allocRequest.size);
11805
- if (VMA_DEBUG_INITIALIZE_ALLOCATIONS)
11806
- {
11807
- m_hAllocator->FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);
11808
- }
11808
+
11809
+ #if VMA_DEBUG_INITIALIZE_ALLOCATIONS
11810
+ m_hAllocator->FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);
11811
+ #endif
11812
+
11809
11813
if (IsCorruptionDetectionEnabled())
11810
11814
{
11811
11815
VkResult res = pBlock->WriteMagicValueAfterAllocation(m_hAllocator, (*pAllocation)->GetOffset(), allocRequest.size);
@@ -13825,10 +13829,10 @@ VkResult VmaAllocator_T::AllocateDedicatedMemoryPage(
13825
13829
else
13826
13830
(*pAllocation)->SetUserData(this, pUserData);
13827
13831
m_Budget.AddAllocation(MemoryTypeIndexToHeapIndex(memTypeIndex), size);
13828
- if(VMA_DEBUG_INITIALIZE_ALLOCATIONS)
13829
- {
13830
- FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);
13831
- }
13832
+
13833
+ #if VMA_DEBUG_INITIALIZE_ALLOCATIONS
13834
+ FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED);
13835
+ #endif
13832
13836
13833
13837
return VK_SUCCESS;
13834
13838
}
@@ -14027,11 +14031,12 @@ VkResult VmaAllocator_T::CalcAllocationParams(
14027
14031
return VK_ERROR_FEATURE_NOT_PRESENT;
14028
14032
}
14029
14033
14030
- if(VMA_DEBUG_ALWAYS_DEDICATED_MEMORY &&
14031
- (inoutCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0)
14034
+ #if VMA_DEBUG_ALWAYS_DEDICATED_MEMORY
14035
+ if( (inoutCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0)
14032
14036
{
14033
14037
inoutCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
14034
14038
}
14039
+ #endif
14035
14040
14036
14041
// Non-auto USAGE values imply HOST_ACCESS flags.
14037
14042
// And so does VMA_MEMORY_USAGE_UNKNOWN because it is used with custom pools.
@@ -14150,10 +14155,9 @@ void VmaAllocator_T::FreeMemory(
14150
14155
14151
14156
if(allocation != VK_NULL_HANDLE)
14152
14157
{
14153
- if(VMA_DEBUG_INITIALIZE_ALLOCATIONS)
14154
- {
14155
- FillAllocation(allocation, VMA_ALLOCATION_FILL_PATTERN_DESTROYED);
14156
- }
14158
+ #if VMA_DEBUG_INITIALIZE_ALLOCATIONS
14159
+ FillAllocation(allocation, VMA_ALLOCATION_FILL_PATTERN_DESTROYED);
14160
+ #endif
14157
14161
14158
14162
switch(allocation->GetType())
14159
14163
{
@@ -14997,8 +15001,8 @@ void VmaAllocator_T::UpdateVulkanBudget()
14997
15001
14998
15002
void VmaAllocator_T::FillAllocation(VmaAllocation hAllocation, uint8_t pattern)
14999
15003
{
15000
- if(VMA_DEBUG_INITIALIZE_ALLOCATIONS &&
15001
- hAllocation->IsMappingAllowed() &&
15004
+ #if VMA_DEBUG_INITIALIZE_ALLOCATIONS
15005
+ if( hAllocation->IsMappingAllowed() &&
15002
15006
(m_MemProps.memoryTypes[hAllocation->GetMemoryTypeIndex()].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
15003
15007
{
15004
15008
void* pData = VMA_NULL;
@@ -15014,6 +15018,7 @@ void VmaAllocator_T::FillAllocation(VmaAllocation hAllocation, uint8_t pattern)
15014
15018
VMA_ASSERT(0 && "VMA_DEBUG_INITIALIZE_ALLOCATIONS is enabled, but couldn't map memory to fill allocation.");
15015
15019
}
15016
15020
}
15021
+ #endif // #if VMA_DEBUG_INITIALIZE_ALLOCATIONS
15017
15022
}
15018
15023
15019
15024
uint32_t VmaAllocator_T::GetGpuDefragmentationMemoryTypeBits()
0 commit comments