VulkanMemoryAllocator
VulkanMemoryAllocator copied to clipboard
Stack corruption calling vmaGetHeapBudgets without VK_EXT_memory_budget
The readme indicates that this should work regardless:
VK_EXT_memory_budget: Used internally if available to query for current usage and budget. If not available, it falls back to an estimation based on memory heap sizes.
However, the following code triggers a stack corruption assert in Visual Studio if called without the extension enabled:
size_t DeviceVk::GetCurrentVRAMInUse() const
{
VmaBudget budgets;
vmaGetHeapBudgets(vkallocator, &budgets);
return budgets.usage;
}
The issue does not occur if the extension is enabled. Because only 5% of Android devices have this extension, it is important for this functionality to work without VK_EXT_memory_budget.
Please read the documentation of function vmaGetHeapBudgets. The name uses plural form "heap budgets" for a reason. It returns budgets for all the memory heaps available in the Vulkan device. Parameter pBudgets:
Must point to array with number of elements at least equal to number of memory heaps in physical device used.
You pass a pointer to a single budget struct, hence the stack corruption.