vk: imports given back under system-heap pressure on 16 GB PCs #479
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!479
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/16gb-import-giveback"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imports given back under system-heap pressure (16 GB PCs)
Problem
The renderer imports the game's memory pools with
VK_EXT_external_memory_host. The driver pins those pages and counts them in the system heap the GPU reaches, whose budget is about half the PC's RAM: 7503 MB on an RTX 3060 with 16 GB. Imports are kept for the whole session, so on a 16 GB PC that heap fills up:no-visual-studio) climbed to 7199 of 7503 MB in under 20 minutes (2320 → 5267 → 6289 → 6796 → 7199 MB);VK_ERROR_OUT_OF_DEVICE_MEMORY(seen at 7758 of 7503 MB): terrain left out, load zones stuck while the import is retried.Change
Every 16 submissions,
memory_begin_submissionasks VMA for the system heaps' use and budget (system_heap_usage, a fresh frame index so the driver is asked again). PastRX_VK_IMPORT_HIGHpercent of the budget (default 85), the pools bound least lately give their imports back down toRX_VK_IMPORT_LOWpercent (default 75):MIRROR_NONE/MIRROR_REFUSED), not bound for 600 submissions and done on the GPU (last_value <= mem_completed);pools_genbumped, the pool caches emptied) and are imported again at their next binding;retired_value = mem_rec_value, checked againstmem_completed), the same rule as the dead mirrors;gpu_buffer()(texture uploads) now marks the pool in use too, so a pool only touched by uploads is not given back under them.On by default only where the system heap's budget is under 12 GB (16 GB PCs and less), where it ran out; larger PCs are unchanged.
RX_VK_IMPORT_HIGH=0turns it off,RX_VK_IMPORT_HIGH=85turns it on anywhere.Caveat
last_valuecounts bindings, not shaders that reach a pool through the guest page table. A pool reached only that way could be given back while idle by bindings and would read zeros until it is bound again. I have not seen it in play (the pools given back were long unbound), but it is the reason this stays limited to small budgets and to pools idle for 600 submissions. If you know a better "in use" signal for page-table reads, I'd happily switch to it.Testing
foliageandno-visual-studioreleases (applied locally): the heap stays at or under ~85%, no terrain loss, no stuck load zones, no device lost attributable to it (the device losses seen came from other changes and were bisected away).mainthe port builds cleanly (RX_VK_ONLY=1); I could not run it there, becauseMKWVK_API_VERSIONwent to 4 and my installed game is the release build. Happy to do a full build frommainand test if you'd like.🤖 Generated with Claude Code