Skip to content

GPU: a texture pass with no room gives up the oldest slots' host copies - #140

Draft
undeadhuman37 wants to merge 9 commits into
fxceless:mainfrom
undeadhuman37:fx/bindless-residency
Draft

undeadhuman37 wants to merge 9 commits into
fxceless:mainfrom
undeadhuman37:fx/bindless-residency

Conversation

@undeadhuman37

@undeadhuman37 undeadhuman37 commented Nov 24, 2026 •

Copy link
Copy Markdown

What

The index pass keeps a host copy for every slot it uploads, and a slot's copy is never idle to the sweep, so only unmapping frees it. Once the card passed 90% of its budget, room() stayed false: the pass refused 256 slots and stopped every frame for the rest of the run, and uploads froze (about 14 GB, thousands of slots still due).

Now, when a pass finds no room, up to 256 slots the pass made more than 4 s ago, oldest first, are made null so the sweep can free their copies. The memory line gets a count of slots given up. Marked shortcut: in the code: oldest made first, not least sampled, because a draw reading a texture by index leaves no trace. A slot given up stays empty until the title writes or maps it again, so a texture still on screen may draw empty meanwhile.

Tested

  • cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (499 passed, 0 failed) and cargo xtask policy pass.
  • New test eviction_takes_the_oldest_made_slots_and_spares_the_recent (synthetic, no game files).
  • Two 12-minute runs of the title, no device loss or errors. Textures waiting: about 5,250-7,260 without this change, 2,577 with it (2,314 with the descriptor-data fix as well). Frame rates were 4.5 and 4.2 against 5.1, but the runs differ in cache warmth, so they are not comparable.
  • Not tested: whether any scenery blinks out from a slot given up, and any other GPU. "Passed over, memory not mapped" stays high (10,472 and 13,924), so unmapped placed textures are the remaining blocker.
  • No game files, data, logs or captures are included.

AI use: an AI tool (Claude Code) wrote this change; a person ran and reviewed the checks.

Note on this branch: it is based on fx-main, so besides this change (one commit, 3 files) the diff also carries the other commits merged there. A one-commit version on main is prepared and not yet pushed. Eviction can leave a slot drawing empty; see the test comment below about visual differences, whose cause is not isolated.

NuraadGit and others added 9 commits November 24, 2026 15:22
The host removes the device for a constant buffer view of more than 65,536
bytes. The title's view heap holds larger sizes in slots it does not use,
and the size went to the host as it was.
No PC GPU renders to R9G9B9E5, so CreateRenderTargetView on such a
target removes the device. Add it to the existing stand-in table, next
to the 16-bit colour formats.
Slots hold the host copy of what they view, so the idle sweep never frees
copies the index pass made; once the card passed 90% of its budget room()
stayed false and uploads stopped for the rest of the run. When a pass finds
no room it now nulls up to 256 slots made more than 4 s ago, oldest first,
so the sweep can free them. The memory line counts the slots given up.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@m335671

m335671 commented Nov 24, 2026

Copy link
Copy Markdown

Test run on an RTX 4070: the texture queue stays short for the whole run. Note that this branch also carries #25, #32 and #24 (merged into fx-main under the commit), so what follows is the four of them together, not this commit alone.

Tested

Texture queue, last 30 samples (~3 minutes) of each run

without (1684989-based + #77, ~11 min) with this branch (~11 min)
slots in the queue median 3,850, max 5,031 median 2,451, max 3,022
due median 1,702, max 4,008 median 122, max 2,069
oldest written median 134, max 2,805 frames ago median 50, max 3,523 frames ago
fps / draws (median) 4.2 / 5,069 4.1 / 5,240
  • At the end: passes that made none for lack of room: 63 (14086 slots given up to make room), card 8,277 MB of a 10,808 MB budget.
  • Without the change, textures visibly went missing or stale as the run went on. With it they stayed current.

Visual differences I saw, cause not isolated (any of the four PRs could be behind them):

Not tested: this commit without #25/#32/#24, process memory (still about 23 GB committed), other GPUs.

AI use: the run was done on my machine. Claude Code (Claude Opus 5.5) built and ran it, read the logs, worked out the figures and wrote this comment.

triippywhale pushed a commit to triippywhale/victory-fork that referenced this pull request Nov 25, 2026
…ig block first; constant lane masks on host halves refused; failed title images unmapped

Cherry-picked from PalmVIDev, clean on this tree:
- 0a3ca499b (AscilCH) GPU: Counting::realloc unregisters a big block before the allocator can reuse its address
- c961a2ffa (LF2000 Builder) Shaders: a constant or opaque lane mask on host halves is refused
- d689ae079 (dharmon96) Loader: a title image whose TLS redirect or imports fail is unmapped
3036f78da (paired dword mask copies) is already in this tree.

The rest of fxceless#140 (AscilCH's lowering and IR fixes) conflicts and is
handled or recorded separately in PALM-PORTS.md.

Co-authored-by: LF2000 Builder <builder@lf2000.local>
Co-authored-by: dharmon96 <lettucedevils51@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants