mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2025-05-14 16:58:34 +00:00
Added macro VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE
Default to 1. Also changed VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT to default to 1. Fixes #338
This commit is contained in:
parent
c578a4f4f1
commit
89d3a6a5ea
1 changed files with 21 additions and 3 deletions
|
@ -3276,7 +3276,18 @@ If providing your own implementation, you need to implement a subset of std::ato
|
|||
Set this to 1 to make VMA never exceed VkPhysicalDeviceLimits::maxMemoryAllocationCount
|
||||
and return error instead of leaving up to Vulkan implementation what to do in such cases.
|
||||
*/
|
||||
#define VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT (0)
|
||||
#define VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT (1)
|
||||
#endif
|
||||
|
||||
#ifndef VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE
|
||||
/*
|
||||
Set this to 1 to make VMA never exceed VkPhysicalDeviceMemoryProperties::memoryHeaps[i].size
|
||||
with a single allocation size VkMemoryAllocateInfo::allocationSize
|
||||
and return error instead of leaving up to Vulkan implementation what to do in such cases.
|
||||
It protects agaist validation error VUID-vkAllocateMemory-pAllocateInfo-01713.
|
||||
On the other hand, allowing exceeding this size may result in a successful allocation despite the validation error.
|
||||
*/
|
||||
#define VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE (1)
|
||||
#endif
|
||||
|
||||
#ifndef VMA_SMALL_HEAP_MAX_SIZE
|
||||
|
@ -14415,6 +14426,15 @@ VkResult VmaAllocator_T::CheckCorruption(uint32_t memoryTypeBits)
|
|||
|
||||
VkResult VmaAllocator_T::AllocateVulkanMemory(const VkMemoryAllocateInfo* pAllocateInfo, VkDeviceMemory* pMemory)
|
||||
{
|
||||
const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(pAllocateInfo->memoryTypeIndex);
|
||||
|
||||
#if VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE
|
||||
if (pAllocateInfo->allocationSize > m_MemProps.memoryHeaps[heapIndex].size)
|
||||
{
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
#endif
|
||||
|
||||
AtomicTransactionalIncrement<VMA_ATOMIC_UINT32> deviceMemoryCountIncrement;
|
||||
const uint64_t prevDeviceMemoryCount = deviceMemoryCountIncrement.Increment(&m_DeviceMemoryCount);
|
||||
#if VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT
|
||||
|
@ -14424,8 +14444,6 @@ VkResult VmaAllocator_T::AllocateVulkanMemory(const VkMemoryAllocateInfo* pAlloc
|
|||
}
|
||||
#endif
|
||||
|
||||
const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(pAllocateInfo->memoryTypeIndex);
|
||||
|
||||
// HeapSizeLimit is in effect for this heap.
|
||||
if((m_HeapSizeLimitMask & (1u << heapIndex)) != 0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue