Video memory: every VMA allocation by the heaps' live budgets, with room kept for FidelityFX

The heap limits were fixed at device creation, and only texture images looked at the budget. FidelityFX allocates
outside VMA (FSR 3.1 contexts, frame generation): 882 MiB of it with 4644 MiB of VMA's filled the 5526 MiB budget of
heap 0 while heap 2 had 1757 MiB free, and an upload submit failed with VK_ERROR_OUT_OF_DEVICE_MEMORY. vmaCreateImage,
vmaCreateBuffer and vmaAllocateMemory now go through vk_vma_budget.c, which leaves out a device-local heap whose
driver-reported use is within NX2NAVI_VRAM_RESERVE_MB (default 512) of its budget; a Lama patches row sets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tobim6
2026-11-12 16:23:16 +01:00
parent 81cdd67086
commit 39db2ae2a1
6 changed files with 149 additions and 0 deletions

View File

@@ -6,6 +6,20 @@
#pragma clang diagnostic ignored "-Wnullability-completeness"
#include "vk_mem_alloc.h"
#pragma clang diagnostic pop
// Every VMA allocation goes by the device-local heaps' live budgets (vk_vma_budget.c): a heap within the reserve of its
// budget takes nothing new while another heap can.
VkResult vk_vma_create_image(VmaAllocator vma, const VkImageCreateInfo *ici, const VmaAllocationCreateInfo *ai, VkImage *img,
VmaAllocation *a, VmaAllocationInfo *info);
VkResult vk_vma_create_buffer(VmaAllocator vma, const VkBufferCreateInfo *bci, const VmaAllocationCreateInfo *ai,
VkBuffer *buf, VmaAllocation *a, VmaAllocationInfo *info);
VkResult vk_vma_allocate_memory(VmaAllocator vma, const VkMemoryRequirements *req, const VmaAllocationCreateInfo *ai,
VmaAllocation *a, VmaAllocationInfo *info);
uint64_t vk_vma_moved(void); // allocations placed outside a full heap so far
#ifndef VK_VMA_BUDGET_IMPL
#define vmaCreateImage vk_vma_create_image
#define vmaCreateBuffer vk_vma_create_buffer
#define vmaAllocateMemory vk_vma_allocate_memory
#endif
#include "nvn_obj.h" // pool_t, tex_t, view_t, samp_par, NVNcopyRegion (memory and textures block)
#include "gfx.h" // GfxShader, GfxShaderRes, GfxShaderAnswers (pipelines block)