JBR-7766 Fix VKTexturePool OOM.

(cherry picked from commit 1a806f4f1b)
This commit is contained in:
Nikita Gubarkov
2024-10-18 18:33:21 +02:00
committed by jbrbot
parent ac6be0b9d5
commit 829494187e
2 changed files with 9 additions and 2 deletions

View File

@@ -191,6 +191,14 @@ void VKAllocator_FindMemoryType(VKMemoryRequirements* requirements,
static uint32_t VKAllocator_AllocatePage(VKAllocator* alloc, uint32_t memoryType, VkDeviceSize size,
VkImage dedicatedImage, VkBuffer dedicatedBuffer) {
assert(alloc != NULL);
assert(memoryType < VK_MAX_MEMORY_TYPES);
uint32_t heapIndex = alloc->memoryProperties.memoryTypes[memoryType].heapIndex;
VkDeviceSize heapSize = alloc->memoryProperties.memoryHeaps[heapIndex].size;
if (size > heapSize) {
J2dRlsTraceLn(J2D_TRACE_ERROR, "VKAllocator_AllocatePage: not enough memory in heap, heapIndex=%d, heapSize=%d, size=%d", heapIndex, heapSize, size);
return NO_PAGE_INDEX;
}
// Allocate memory.
VkBool32 dedicated = dedicatedImage != VK_NULL_HANDLE || dedicatedBuffer != VK_NULL_HANDLE;

View File

@@ -73,8 +73,7 @@ void VKTexturePoolLock_unlockImpl(ATexturePoolLockPrivPtr *lock) {
}
static void VKTexturePool_FindImageMemoryType(VKMemoryRequirements* requirements) {
// TODO both DEVICE_LOCAL and HOST_VISIBLE memory is very precious, we may need to use just DEVICE_LOCAL instead.
VKAllocator_FindMemoryType(requirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, VK_ALL_MEMORY_PROPERTIES);
VKAllocator_FindMemoryType(requirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_ALL_MEMORY_PROPERTIES);
}
/* Texture allocate/free API */