Skip to content

Commit 1076b34

Browse files
authored
Merge pull request #501 from sawickiap/master
Fixed for some compiler warnings
2 parents 6ec8481 + 1f0047a commit 1076b34

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

include/vk_mem_alloc.h

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4600,7 +4600,8 @@ void VmaVector<T, AllocatorT>::resize(size_t newCount)
46004600

46014601
if (newCapacity != m_Capacity)
46024602
{
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);
46044605
const size_t elementsToCopy = VMA_MIN(m_Count, newCount);
46054606
if (elementsToCopy != 0)
46064607
{
@@ -11348,11 +11349,13 @@ bool VmaBlockVector::IsEmpty()
1134811349

1134911350
bool VmaBlockVector::IsCorruptionDetectionEnabled() const
1135011351
{
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) &&
1135511357
(m_hAllocator->m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags & requiredMemFlags) == requiredMemFlags;
11358+
#endif
1135611359
}
1135711360

1135811361
VkResult VmaBlockVector::Allocate(
@@ -11802,10 +11805,11 @@ VkResult VmaBlockVector::CommitAllocationRequest(
1180211805
else
1180311806
(*pAllocation)->SetUserData(m_hAllocator, pUserData);
1180411807
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+
1180911813
if (IsCorruptionDetectionEnabled())
1181011814
{
1181111815
VkResult res = pBlock->WriteMagicValueAfterAllocation(m_hAllocator, (*pAllocation)->GetOffset(), allocRequest.size);
@@ -13825,10 +13829,10 @@ VkResult VmaAllocator_T::AllocateDedicatedMemoryPage(
1382513829
else
1382613830
(*pAllocation)->SetUserData(this, pUserData);
1382713831
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
1383213836

1383313837
return VK_SUCCESS;
1383413838
}
@@ -14027,11 +14031,12 @@ VkResult VmaAllocator_T::CalcAllocationParams(
1402714031
return VK_ERROR_FEATURE_NOT_PRESENT;
1402814032
}
1402914033

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)
1403214036
{
1403314037
inoutCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
1403414038
}
14039+
#endif
1403514040

1403614041
// Non-auto USAGE values imply HOST_ACCESS flags.
1403714042
// And so does VMA_MEMORY_USAGE_UNKNOWN because it is used with custom pools.
@@ -14150,10 +14155,9 @@ void VmaAllocator_T::FreeMemory(
1415014155

1415114156
if(allocation != VK_NULL_HANDLE)
1415214157
{
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
1415714161

1415814162
switch(allocation->GetType())
1415914163
{
@@ -14997,8 +15001,8 @@ void VmaAllocator_T::UpdateVulkanBudget()
1499715001

1499815002
void VmaAllocator_T::FillAllocation(VmaAllocation hAllocation, uint8_t pattern)
1499915003
{
15000-
if(VMA_DEBUG_INITIALIZE_ALLOCATIONS &&
15001-
hAllocation->IsMappingAllowed() &&
15004+
#if VMA_DEBUG_INITIALIZE_ALLOCATIONS
15005+
if(hAllocation->IsMappingAllowed() &&
1500215006
(m_MemProps.memoryTypes[hAllocation->GetMemoryTypeIndex()].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
1500315007
{
1500415008
void* pData = VMA_NULL;
@@ -15014,6 +15018,7 @@ void VmaAllocator_T::FillAllocation(VmaAllocation hAllocation, uint8_t pattern)
1501415018
VMA_ASSERT(0 && "VMA_DEBUG_INITIALIZE_ALLOCATIONS is enabled, but couldn't map memory to fill allocation.");
1501515019
}
1501615020
}
15021+
#endif // #if VMA_DEBUG_INITIALIZE_ALLOCATIONS
1501715022
}
1501815023

1501915024
uint32_t VmaAllocator_T::GetGpuDefragmentationMemoryTypeBits()

0 commit comments

Comments
 (0)