Repository navigation
vk: imports given back under system-heap pressure on 16 GB PCs - #479
Merged
Merged
Conversation
The driver pins every imported pool and counts it in the system heap the GPU reaches, whose budget is about half the PC's RAM (7.5 GB with 16 GB). Imports were kept for the session: on an RTX 3060 with 16 GB the heap went past its budget (7758 of 7503 MB) and new imports failed with VK_ERROR_OUT_OF_DEVICE_MEMORY (terrain left out, load zones stuck); a vanilla session climbed to 7199 of 7503 MB in under 20 minutes. Past RX_VK_IMPORT_HIGH percent of the budget (85) the pools bound least lately give their imports back down to RX_VK_IMPORT_LOW percent (75): only pools without a mirror, unbound for 600 submissions and done on the GPU. They leave the table as a retired pool does and are imported again at their next binding; their memory is freed once everything recorded until then is done. On by default only where that budget is under 12 GB; RX_VK_IMPORT_HIGH=0: off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NotRexed
added a commit
that referenced
this pull request
Nov 8, 2026
Off by default on _WIN32 (RX_VK_IMPORT_HIGH=85 turns it on), as giving retired imports back is (RX_VK_KEEP_RETIRED); on Linux the default stays the PR's. A pool given back also frees its dma-buf pieces (#448's sparse pools). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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