mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 10:00:40 +00:00
Avoid small memory heaps when allocating memory to reduce chance of OOM
This commit is contained in:
@@ -241,6 +241,25 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(bool buffer, VkMemoryR
|
||||
|
||||
uint32_t memoryTypeIndex = 0;
|
||||
|
||||
// Upload heaps are sometimes limited in size. To prevent OOM issues, deselect any memory types
|
||||
// corresponding to a small heap (<= 512MB) if there are other memory types available.
|
||||
for(uint32_t m = 0; m < 32; m++)
|
||||
{
|
||||
if(mrq.memoryTypeBits & (1U << m))
|
||||
{
|
||||
uint32_t heap = m_PhysicalDeviceData.memProps.memoryTypes[m].heapIndex;
|
||||
if(m_PhysicalDeviceData.memProps.memoryHeaps[heap].size <= 512 * 1024 * 1024)
|
||||
{
|
||||
if(mrq.memoryTypeBits > (1U << m))
|
||||
{
|
||||
RDCDEBUG("Avoiding memory type %u due to small heap size (%llu)", i,
|
||||
m_PhysicalDeviceData.memProps.memoryHeaps[heap].size);
|
||||
mrq.memoryTypeBits &= ~(1U << m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch(ret.type)
|
||||
{
|
||||
case MemoryType::Upload: memoryTypeIndex = GetUploadMemoryIndex(mrq.memoryTypeBits); break;
|
||||
|
||||
Reference in New Issue
Block a user