Stop the evictions from emptying VRAM, and give VRAM mirrors priority over textures.

A test run with the budget taken as 16 GiB showed two faults. The evictions measured the driver's heap use, which keeps counting a VMA block whole while one allocation lives in it, so freeing textures and mirrors in the middle of blocks did not move it: they went on until 5700 of 7232 textures and 395 of 410 mirrors were gone (9.2 GiB free inside blocks). And mirrors evicted under pressure during a menu were refused again when the world came back, so the draws read the pools over PCIe at 4 fps. The evictions now count the free space inside VMA's blocks as room (vk_mem_vram_live), mirrors are no longer evicted to make room for textures, and a mirror that does not fit after the idle mirrors made room asks idle textures for the rest (vk_texture_want_room) and is asked again 16 submissions later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 23:31:50 -05:00
parent fa8f8dc84d
commit 073ddc0c95
3 changed files with 72 additions and 38 deletions

View File

@@ -475,6 +475,9 @@ void vk_texture_stats(uint64_t *images, uint64_t *uploads, uint64_t *reuploads);
typedef struct { uint64_t live, released, own_live, own_released, bytes_live, bytes_released; } VkTexCensus;
void vk_texture_census(VkTexCensus *s);
void vk_texture_census_log(uint64_t frame); // vk_memory.c vram_log: the live entries' memory by kind and format
void vk_texture_want_room(uint64_t bytes); // a VRAM mirror that did not fit: idle textures make that much room
// vk_mem_vram's device-local use less the free space inside VMA's blocks (vk_memory.c), for the evictions
int vk_mem_vram_live(uint64_t *used, uint64_t *budget);
void vk_texture_shutdown(void); // vk_mem_shutdown calls it
void vk_texture_new_submit(void); // a queue submit starts: draw bindings check storage again
uint32_t vk_texture_epoch(void); // the write-watch snapshot epoch vk_texture_new_submit started