[dxvk] Try harder to allocate memory from a given memory type

Before failing, see if we can't allocate a smaller chunk size.
This commit is contained in:
Philip Rebohle 2019-07-16 09:44:45 +02:00
parent 18aada29ef
commit 6936da17d9
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 9 additions and 8 deletions

View File

@ -295,16 +295,17 @@ namespace dxvk {
memory = type->chunks[i]->alloc(flags, size, align, priority);
if (!memory) {
DxvkDeviceMemory devMem = tryAllocDeviceMemory(
type, flags, type->heap->chunkSize, priority, nullptr);
if (devMem.memHandle == VK_NULL_HANDLE)
return DxvkMemory();
DxvkDeviceMemory devMem;
Rc<DxvkMemoryChunk> chunk = new DxvkMemoryChunk(this, type, devMem);
memory = chunk->alloc(flags, size, align, priority);
for (uint32_t i = 0; i < 6 && (type->heap->chunkSize >> i) >= size && !devMem.memHandle; i++)
devMem = tryAllocDeviceMemory(type, flags, type->heap->chunkSize >> i, priority, nullptr);
type->chunks.push_back(std::move(chunk));
if (devMem.memHandle) {
Rc<DxvkMemoryChunk> chunk = new DxvkMemoryChunk(this, type, devMem);
memory = chunk->alloc(flags, size, align, priority);
type->chunks.push_back(std::move(chunk));
}
}
}