Defined VMA_FALLTHROUGH to fix more compiler warnings

See #321
This commit is contained in:
Adam Sawicki 2023-02-24 14:15:41 +01:00
parent 729b7c1408
commit 4c58c1fefe

View File

@ -2651,8 +2651,7 @@ VmaAllocatorCreateInfo::pVulkanFunctions. Other members can be null.
#endif
#ifndef VMA_USE_STL_SHARED_MUTEX
// Compiler conforms to C++17.
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L // C++17
#define VMA_USE_STL_SHARED_MUTEX 1
// Visual studio defines __cplusplus properly only when passed additional parameter: /Zc:__cplusplus
// Otherwise it is always 199711L, despite shared_mutex works since Visual Studio 2015 Update 2.
@ -2697,6 +2696,14 @@ remove them if not needed.
#define VMA_NULL nullptr
#endif
#ifndef VMA_FALLTHROUGH
#if __cplusplus >= 201703L || _MSVC_LANG >= 201703L // C++17
#define VMA_FALLTHROUGH [[fallthrough]]
#else
#define VMA_FALLTHROUGH
#endif
#endif
// Normal assert to check for programmer's errors, especially in Debug configuration.
#ifndef VMA_ASSERT
#ifdef NDEBUG
@ -2773,7 +2780,7 @@ static void* vma_aligned_alloc(size_t alignment, size_t size)
{
return _aligned_malloc(size, alignment);
}
#elif __cplusplus >= 201703L // Compiler conforms to C++17.
#elif __cplusplus >= 201703L || _MSVC_LANG >= 201703L // C++17
static void* vma_aligned_alloc(size_t alignment, size_t size)
{
return aligned_alloc(alignment, size);
@ -5663,7 +5670,6 @@ void VmaJsonWriter::ContinueString(const char* pStr)
break;
default:
VMA_ASSERT(0 && "Character not currently supported.");
break;
}
}
}
@ -13216,11 +13222,8 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
m_PassStats.bytesFreed += freedBlockSize;
}
switch (m_Algorithm)
{
case VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT:
{
if (m_AlgorithmState != VMA_NULL)
if(m_Algorithm == VMA_DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT &&
m_AlgorithmState != VMA_NULL)
{
// Avoid unnecessary tries to allocate when new free block is available
StateExtensive& state = reinterpret_cast<StateExtensive*>(m_AlgorithmState)[vectorIndex];
@ -13238,8 +13241,6 @@ VkResult VmaDefragmentationContext_T::DefragmentPassEnd(VmaDefragmentationPassMo
}
}
}
}
}
moveInfo.moveCount = 0;
moveInfo.pMoves = VMA_NULL;
m_Moves.clear();
@ -13796,6 +13797,8 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Extensive(VmaBlockVecto
vectorState.operation = StateExtensive::Operation::MoveBuffers;
bufferPresent = false;
otherPresent = false;
VMA_FALLTHROUGH; // Fallthrough
}
else
break;
@ -13820,6 +13823,8 @@ bool VmaDefragmentationContext_T::ComputeDefragmentation_Extensive(VmaBlockVecto
// No more buffers to move, check all others
vectorState.operation = StateExtensive::Operation::MoveAll;
otherPresent = false;
VMA_FALLTHROUGH; // Fallthrough
}
else
break;
@ -15570,6 +15575,7 @@ VkResult VmaAllocator_T::Map(VmaAllocation hAllocation, void** ppData)
}
return res;
}
VMA_FALLTHROUGH; // Fallthrough
case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED:
return hAllocation->DedicatedAllocMap(this, ppData);
default: