@@ -3276,7 +3276,18 @@ If providing your own implementation, you need to implement a subset of std::ato
3276
3276
Set this to 1 to make VMA never exceed VkPhysicalDeviceLimits::maxMemoryAllocationCount
3277
3277
and return error instead of leaving up to Vulkan implementation what to do in such cases.
3278
3278
*/
3279
- #define VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT (0)
3279
+ #define VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT (1)
3280
+ #endif
3281
+
3282
+ #ifndef VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE
3283
+ /*
3284
+ Set this to 1 to make VMA never exceed VkPhysicalDeviceMemoryProperties::memoryHeaps[i].size
3285
+ with a single allocation size VkMemoryAllocateInfo::allocationSize
3286
+ and return error instead of leaving up to Vulkan implementation what to do in such cases.
3287
+ It protects agaist validation error VUID-vkAllocateMemory-pAllocateInfo-01713.
3288
+ On the other hand, allowing exceeding this size may result in a successful allocation despite the validation error.
3289
+ */
3290
+ #define VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE (1)
3280
3291
#endif
3281
3292
3282
3293
#ifndef VMA_SMALL_HEAP_MAX_SIZE
@@ -14415,6 +14426,15 @@ VkResult VmaAllocator_T::CheckCorruption(uint32_t memoryTypeBits)
14415
14426
14416
14427
VkResult VmaAllocator_T::AllocateVulkanMemory(const VkMemoryAllocateInfo* pAllocateInfo, VkDeviceMemory* pMemory)
14417
14428
{
14429
+ const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(pAllocateInfo->memoryTypeIndex);
14430
+
14431
+ #if VMA_DEBUG_DONT_EXCEED_HEAP_SIZE_WITH_ALLOCATION_SIZE
14432
+ if (pAllocateInfo->allocationSize > m_MemProps.memoryHeaps[heapIndex].size)
14433
+ {
14434
+ return VK_ERROR_OUT_OF_DEVICE_MEMORY;
14435
+ }
14436
+ #endif
14437
+
14418
14438
AtomicTransactionalIncrement<VMA_ATOMIC_UINT32> deviceMemoryCountIncrement;
14419
14439
const uint64_t prevDeviceMemoryCount = deviceMemoryCountIncrement.Increment(&m_DeviceMemoryCount);
14420
14440
#if VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT
@@ -14424,8 +14444,6 @@ VkResult VmaAllocator_T::AllocateVulkanMemory(const VkMemoryAllocateInfo* pAlloc
14424
14444
}
14425
14445
#endif
14426
14446
14427
- const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(pAllocateInfo->memoryTypeIndex);
14428
-
14429
14447
// HeapSizeLimit is in effect for this heap.
14430
14448
if((m_HeapSizeLimitMask & (1u << heapIndex)) != 0)
14431
14449
{
0 commit comments