vkback: the GTT line takes the free bytes of GTT arena blocks off its use #111

Manually merged
github merged 1 commit from github-bot/gh-111 into gh-pr/111/base 2026-12-01 15:07:37 +00:00 AGit
Owner

@⁠Flezzonkeys on GitHub · 2026-12-01 14:57 UTC · original
Flezzonkeys:gtt-line-arena-free → main · +71 −8 · 3 files · 1 commits · merged 2026-12-01 15:03 UTC

What

over_line takes the free bytes inside the image arena's blocks off the card's use, but not off GTT's. Arena blocks are not freed while the game runs, so once a new GTT block (made while textures spill) pushes GTT use past its line, the line stays passed: letting textures go adds their bytes to the blocks' free space and leaves the heap's usage unchanged, so the let-go sweep can never bring it back under. With the card over its line too, texture_place answers Place::None from then on, every refused texture's slot reads null, and faces and parts of the world stay black for the rest of the session.

Both lines now go through one function, past_line, which takes the free bytes of that heap's own arena blocks off its use. The next texture of that heap goes into that free space before a new block is made (Arena::alloc, first fit over the blocks of its memory type), so those bytes are not in use. The memory summary also reports how much of the arena's free space is in GTT blocks, so the case shows up in the log.

This is one concrete way into "Black world after long sessions" and the refusals in "8 GB cards" (docs/TASKS.md). I have not shown that it is the whole cause of either.

The reference

D3D12 path, crates/victory-gpu/src/resource.rs evict_unused (Marvisak/VIctory 219878a0e7): before comparing against BUDGET_HIGH, it takes placement::free_bytes() off the card's use ("Free space in the heaps of textures takes the card's memory but is not in use: new textures go there first"). It has no GTT line, so the GTT side has no counterpart. I carry the same rule over to the GTT line. vkd3d-proton has no residency line of this kind.

Same pattern checked elsewhere (rule 22): umem's can_grow also compares heap use with the budget without taking arena free space off. That is correct there, because title pool chunks cannot use the free space of image blocks, so I left it unchanged.

Evidence

  • Unit tests (residency::tests, calling past_line): free arena bytes do not count as used; letting textures go (usage flat, free grows) brings a passed line back under; free larger than used saturates. cargo test -p vkback passes and cargo clippy -p vkback --all-targets -- -D warnings is clean.
  • Player runs, RX 9070 XT 16 GB, Ryzen 7 9800X3D, 32 GB, Mesa 26.3, Proton Experimental, Series X, own save:
    • Without the change (e9759ee, bar mission after ~20 min of free roam): GTT went 13,277 -> 13,525 MB with one new block, past its 86 % line of 13,388 MB (budget 15,568 MB). It then stayed at exactly 13,525 MB for the rest of the run, while "refused past both lines" went from 0 to 4,514 in the next stats window and to 1,447,589 by the end. Faces and parts of the world were black.
    • With the change (four runs on the same PC, 11-29 min each, on main of 2026-11-30 to 2026-12-01 up to 7c7bba5, plus this commit and local-only changes that do not touch residency: present sharpening, a resolution patch left off, trace fields): 0 refused past both lines, GTT up to 13.8 GB. In one of them GTT stood at 13,517 of 15,662 MB, 48 MB past its line, with 1,573 MB of the arena's free space in GTT blocks: without the change that run would have been past the GTT line too.
  • Not run: no validation run (rule 30), and no A/B on current main. The change only alters when a texture may be made in GTT (the same make_image path as before, at a different moment), not which Vulkan calls exist or how they are made. If you want the validation run before merging, I can't do it on my side at the moment.

Checklist (docs/AGENTS.md)

  • One topic (rule 31); docs/TASKS.md not edited, the related items named above (rule 29)
  • "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen
  • No fallback or second path for a case that can't happen (rule 33); unexpected input fails loudly (rule 9)
  • Constants come from the console, the hardware or the title's data (rule 9b): no new constants
  • Every switch is listed, read in one place, and a bad value stops the start (rule 2): no new switches
  • Queues and other externally synchronized Vulkan objects are used under their lock (rule 35): not touched
  • Every unsafe block has a // SAFETY: comment (rule 36): no new unsafe
  • Clippy clean; tests call the production code; translator output unchanged (rule 27)
  • Comments say what is true now and name functions, not line numbers (rule 3)
  • Nothing from the title, and no pointers to where non-free data can be found

Learnings: new entry in docs/learnings/tex-letgo.md; docs/learnings/parity.md row "Residency line, idle let-go, target reserve" updated.

**@⁠Flezzonkeys** on GitHub · 2026-12-01 14:57 UTC · [original](https://github.com/vktory6/VKtory/pull/111) `Flezzonkeys:gtt-line-arena-free` → `main` · +71 −8 · 3 files · 1 commits · merged 2026-12-01 15:03 UTC ## What `over_line` takes the free bytes inside the image arena's blocks off the card's use, but not off GTT's. Arena blocks are not freed while the game runs, so once a new GTT block (made while textures spill) pushes GTT use past its line, the line stays passed: letting textures go adds their bytes to the blocks' free space and leaves the heap's usage unchanged, so the let-go sweep can never bring it back under. With the card over its line too, `texture_place` answers `Place::None` from then on, every refused texture's slot reads null, and faces and parts of the world stay black for the rest of the session. Both lines now go through one function, `past_line`, which takes the free bytes of that heap's own arena blocks off its use. The next texture of that heap goes into that free space before a new block is made (`Arena::alloc`, first fit over the blocks of its memory type), so those bytes are not in use. The memory summary also reports how much of the arena's free space is in GTT blocks, so the case shows up in the log. This is one concrete way into "Black world after long sessions" and the refusals in "8 GB cards" (docs/TASKS.md). I have not shown that it is the whole cause of either. ## The reference D3D12 path, `crates/victory-gpu/src/resource.rs` `evict_unused` (Marvisak/VIctory 219878a0e7): before comparing against `BUDGET_HIGH`, it takes `placement::free_bytes()` off the card's use ("Free space in the heaps of textures takes the card's memory but is not in use: new textures go there first"). It has no GTT line, so the GTT side has no counterpart. I carry the same rule over to the GTT line. vkd3d-proton has no residency line of this kind. Same pattern checked elsewhere (rule 22): umem's `can_grow` also compares heap use with the budget without taking arena free space off. That is correct there, because title pool chunks cannot use the free space of image blocks, so I left it unchanged. ## Evidence - **Unit tests** (`residency::tests`, calling `past_line`): free arena bytes do not count as used; letting textures go (usage flat, free grows) brings a passed line back under; free larger than used saturates. `cargo test -p vkback` passes and `cargo clippy -p vkback --all-targets -- -D warnings` is clean. - **Player runs**, RX 9070 XT 16 GB, Ryzen 7 9800X3D, 32 GB, Mesa 26.3, Proton Experimental, Series X, own save: - Without the change (e9759ee, bar mission after ~20 min of free roam): GTT went 13,277 -> 13,525 MB with one new block, past its 86 % line of 13,388 MB (budget 15,568 MB). It then stayed at exactly 13,525 MB for the rest of the run, while "refused past both lines" went from 0 to 4,514 in the next stats window and to 1,447,589 by the end. Faces and parts of the world were black. - With the change (four runs on the same PC, 11-29 min each, on main of 2026-11-30 to 2026-12-01 up to 7c7bba5, plus this commit and local-only changes that do not touch residency: present sharpening, a resolution patch left off, trace fields): 0 refused past both lines, GTT up to 13.8 GB. In one of them GTT stood at 13,517 of 15,662 MB, 48 MB past its line, with 1,573 MB of the arena's free space in GTT blocks: without the change that run would have been past the GTT line too. - **Not run:** no validation run (rule 30), and no A/B on current main. The change only alters when a texture may be made in GTT (the same `make_image` path as before, at a different moment), not which Vulkan calls exist or how they are made. If you want the validation run before merging, I can't do it on my side at the moment. ## Checklist (docs/AGENTS.md) - [x] One topic (rule 31); `docs/TASKS.md` not edited, the related items named above (rule 29) - [x] "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen - [x] No fallback or second path for a case that can't happen (rule 33); unexpected input fails loudly (rule 9) - [x] Constants come from the console, the hardware or the title's data (rule 9b): no new constants - [x] Every switch is listed, read in one place, and a bad value stops the start (rule 2): no new switches - [x] Queues and other externally synchronized Vulkan objects are used under their lock (rule 35): not touched - [x] Every `unsafe` block has a `// SAFETY:` comment (rule 36): no new `unsafe` - [x] Clippy clean; tests call the production code; translator output unchanged (rule 27) - [x] Comments say what is true now and name functions, not line numbers (rule 3) - [x] Nothing from the title, and no pointers to where non-free data can be found Learnings: new entry in `docs/learnings/tex-letgo.md`; `docs/learnings/parity.md` row "Residency line, idle let-go, target reserve" updated.
over_line took the free bytes inside the image arena's blocks off the
card's use but not off GTT's. Arena blocks are not freed while the game
runs, so once a new GTT block (made while textures spilled) pushed GTT
use past its line, the line stayed passed: letting textures go adds
their bytes to the blocks' free space and leaves the heap's usage as it
was. With the card over its line too, texture_place answered None from
then on, every refused texture's slot read null, and faces and parts of
the world went black for the rest of the session.

Seen in a player's run on e9759ee (RX 9070 XT 16 GB, Series X, bar
mission after ~20 min of free roam): GTT 13,277 -> 13,525 MB with one
new block, past its 86 % line of 13,388 MB; it then stayed at exactly
13,525 MB for the rest of the run while "refused past both lines" went
0 -> 1,447,589. Four later runs with this change: 0 refusals past both
lines, GTT up to 13.8 GB.

Both lines now go through past_line. The D3D12 path takes the free bytes
of its texture heaps off the card's use the same way (resource.rs
evict_unused, placement::free_bytes); it has no GTT line. umem's
can_grow is not the same case: title pool chunks cannot use the free
space of image blocks. The memory summary also reports how much of the
arena's free space is in GTT blocks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 15:02:15 +00:00
github-bot changed target branch from main to gh-pr/111/base 2026-12-01 15:07:36 +00:00
github manually merged commit a1c10fab50 into gh-pr/111/base 2026-12-01 15:07:37 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 15:04 UTC · original

Merged as 1325b2f. Thank you, this is an excellent PR: the cause read from the code, the D3D12 counterpart named, the same pattern checked in umem with a reason to leave it, unit tests on the production function, a before/after from real play, and an honest "one way in, not shown to be the whole cause". Nothing to change on my side.

The task is updated (github.com/vktory6/VKtory@dab263d): one cause of the black world is fixed, and the next step is a 30+ minute run on main. It may also help the two 8 GB reports (#103, #106), which show the same refusal counters; I've asked there for a recheck.

**@⁠vktory6** on GitHub · 2026-12-01 15:04 UTC · [original](https://github.com/vktory6/VKtory/pull/111#issuecomment-7315297982) Merged as 1325b2f. Thank you, this is an excellent PR: the cause read from the code, the D3D12 counterpart named, the same pattern checked in umem with a reason to leave it, unit tests on the production function, a before/after from real play, and an honest "one way in, not shown to be the whole cause". Nothing to change on my side. The task is updated (https://github.com/vktory6/VKtory/commit/dab263d): one cause of the black world is fixed, and the next step is a 30+ minute run on main. It may also help the two 8 GB reports (#103, #106), which show the same refusal counters; I've asked there for a recheck.
This discussion has been locked. Commenting is limited to contributors.
No description provided.