victory-gpu: a vram line every 5 s: how the card is shared and what letting copies go costs #216

Open
github-bot wants to merge 1 commit from github-bot/gh-216 into main AGit
Owner

@⁠skalel on GitHub · 2026-12-02 19:07 UTC · original
skalel:feat/texture-low-vram → main · +410 −7 · 7 files · 1 commits · open

A stats: vram line every 5 s, after the frame line: how the card's memory is shared between title memory and host copies of textures, and what letting copies go costs. It changes nothing a run does; it is what a change to how they share the card can be measured by.

This PR used to carry two switches as well. As suggested in review it is split in three: this line, then VICTORY_RESERVE_RELEASE (#481), then VICTORY_SMALL_FIRST, left out (below).

The line

  • How the card is shared: budget, use, the card's free memory; what the texture side compares with its keep line (texture_side_mb) and the band it falls in; the room kept for render targets (kept_mb); title memory on the card, movable and fixed, and its room; host copies of textures and those idle; render targets; free room in texture blocks; the rest.
  • What letting copies go costs, since the last line: copies let go and their MB; copies made again within 5 s of their let-go (remade_soon); slots the texture pass found waiting for a copy that was let go (slots_after_let_go, which read nothing until it is made again); textures let go at least once; streamed out; refused passes.

The band comes from host::keep_band, which holds the percentages and which vram_keep now goes by too, so the line cannot drift from it (it used to map vram_keep's idle times back to bands).

stats: vram budget_mb=11564 used_mb=8778 free_mb=2754 texture_side_mb=10425 band=2 kept_mb=1647 title_movable_mb=880 title_fixed_mb=144 title_room_mb=1024 held_back=2065 pressed=0 copies_mb=3636 idle_copies_mb=1090 targets_mb=1425 block_free_mb=535 others_mb=2157 let_go=8787 let_go_mb=768 remade_soon=308 remade_soon_mb=19 slots_after_let_go=1054 textures_let_go=52944 streamed_out=7360 refused_passes=6

(Series X, 1080p, FSR 4 quality, in the world.)

Checked

  • Tests under Wine: the band follows vram_keep at every percentage; the texture side's value is what vram_plan compares; a stale look is none; counts since the last line count once; a copy made again within 5 s counts as remade soon; a texture made again no longer counts as let go.
  • RX 6750 XT 12 GB, Ryzen 7 5700X, CachyOS: ten rounds of about five minutes on this line (Series S at 1080p with FSR 4 on the host, Series X at 1080p with FSR 4 quality), the numbers in #481.

Small-first, held back

VICTORY_SMALL_FIRST is not in either PR. An earlier version of this body said it "did not help" from slots_after_let_go, which cannot show it: that counter counts a let-go texture's slot when the pass makes its copy again, whole or small, the same event either way. A local build that also counted the slots the pass holds back black for lack of room (for up to some four seconds) found that none of them were of a let-go texture: a slot already made from its view is never held back (has_its_texture), so a let-go copy is made again at once, room or not. The long black waits are slots of textures not made yet, which small-first does not reach. In an off/on pair on Series S without the reserve given back, on was worse:

off on
slots held back black, per line 581 809
of them, of a let-go texture 0 0
small copies made / grown / parked 20,529 / 13,765 / 10,628
fps in the world (median) 18.3 16.8

So it stays out. The held-back slots are the next thing to look at (a counter for them, and why they wait out their four seconds once the card has room again).

@⁠abomalocaris's device loss with both switches on (with #342, spin test, ray tracing off) did not reproduce here in a 3-minute spin with small-first on, 37,000 small copies, without #342.

🤖 Generated with Claude Code

**@⁠skalel** on GitHub · 2026-12-02 19:07 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216) `skalel:feat/texture-low-vram` → `main` · +410 −7 · 7 files · 1 commits · open A `stats: vram` line every 5 s, after the frame line: how the card's memory is shared between title memory and host copies of textures, and what letting copies go costs. It changes nothing a run does; it is what a change to how they share the card can be measured by. This PR used to carry two switches as well. As suggested in review it is split in three: this line, then `VICTORY_RESERVE_RELEASE` (#481), then `VICTORY_SMALL_FIRST`, left out (below). ## The line - **How the card is shared:** budget, use, the card's free memory; what the texture side compares with its keep line (`texture_side_mb`) and the band it falls in; the room kept for render targets (`kept_mb`); title memory on the card, movable and fixed, and its room; host copies of textures and those idle; render targets; free room in texture blocks; the rest. - **What letting copies go costs, since the last line:** copies let go and their MB; copies made again within 5 s of their let-go (`remade_soon`); slots the texture pass found waiting for a copy that was let go (`slots_after_let_go`, which read nothing until it is made again); textures let go at least once; streamed out; refused passes. The band comes from `host::keep_band`, which holds the percentages and which `vram_keep` now goes by too, so the line cannot drift from it (it used to map `vram_keep`'s idle times back to bands). ``` stats: vram budget_mb=11564 used_mb=8778 free_mb=2754 texture_side_mb=10425 band=2 kept_mb=1647 title_movable_mb=880 title_fixed_mb=144 title_room_mb=1024 held_back=2065 pressed=0 copies_mb=3636 idle_copies_mb=1090 targets_mb=1425 block_free_mb=535 others_mb=2157 let_go=8787 let_go_mb=768 remade_soon=308 remade_soon_mb=19 slots_after_let_go=1054 textures_let_go=52944 streamed_out=7360 refused_passes=6 ``` (Series X, 1080p, FSR 4 quality, in the world.) ## Checked - Tests under Wine: the band follows `vram_keep` at every percentage; the texture side's value is what `vram_plan` compares; a stale look is none; counts since the last line count once; a copy made again within 5 s counts as remade soon; a texture made again no longer counts as let go. - RX 6750 XT 12 GB, Ryzen 7 5700X, CachyOS: ten rounds of about five minutes on this line (Series S at 1080p with FSR 4 on the host, Series X at 1080p with FSR 4 quality), the numbers in #481. ## Small-first, held back `VICTORY_SMALL_FIRST` is not in either PR. An earlier version of this body said it "did not help" from `slots_after_let_go`, which cannot show it: that counter counts a let-go texture's slot when the pass makes its copy again, whole or small, the same event either way. A local build that also counted the slots the pass holds back black for lack of room (for up to some four seconds) found that none of them were of a let-go texture: a slot already made from its view is never held back (`has_its_texture`), so a let-go copy is made again at once, room or not. The long black waits are slots of textures not made yet, which small-first does not reach. In an off/on pair on Series S without the reserve given back, on was worse: | | off | on | |---|---|---| | slots held back black, per line | 581 | 809 | | of them, of a let-go texture | 0 | 0 | | small copies made / grown / parked | | 20,529 / 13,765 / 10,628 | | fps in the world (median) | 18.3 | 16.8 | So it stays out. The held-back slots are the next thing to look at (a counter for them, and why they wait out their four seconds once the card has room again). @⁠abomalocaris's device loss with both switches on (with #342, spin test, ray tracing off) did not reproduce here in a 3-minute spin with small-first on, 37,000 small copies, without #342. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y2Qqrun6kxcg5bnqZExNca
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:27:51 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:07 UTC · original · edited 2026-12-02 19:13 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T19:13:35.157872Z ce2ad5d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-02 19:07 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7355666475) · edited 2026-12-02 19:13 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"ce2ad5de81fcfb9d47ccccead340946487f92e2f","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-12-02T19:13:35.157872Z">2026-12-02T19:13:35.157872Z</relative-time> | `ce2ad5d` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:13 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce2ad5de81

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-02 19:13 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#pullrequestreview-6157187667) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `ce2ad5de81` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -1676,0 +1775,4 @@
let small = small_level(&r.desc);
if small > base {
base = small;
made_small = true;
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:13 UTC · original

P2 Badge Mark already-partial copies as small-first

When VICTORY_SMALL_FIRST=1 is enabled and the first post-eviction view starts at a mip later than small_level, base_level is already at or beyond small, so this branch leaves made_small false even though the returned host copy is partial. If a later pass asks for an earlier mip, want_level_in sees SMALL_NO and takes the ordinary growth path without checking for room, so a full copy can be allocated while the card is full and the slot can go black until upload instead of keeping the blurred copy. Mark post-let-go copies that still lack earlier levels as small-first, not only cases where this branch changed base.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-02 19:13 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#discussion_r4774597812) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Mark already-partial copies as small-first** When `VICTORY_SMALL_FIRST=1` is enabled and the first post-eviction view starts at a mip later than `small_level`, `base_level` is already at or beyond `small`, so this branch leaves `made_small` false even though the returned host copy is partial. If a later pass asks for an earlier mip, `want_level_in` sees `SMALL_NO` and takes the ordinary growth path without checking for room, so a full copy can be allocated while the card is full and the slot can go black until upload instead of keeping the blurred copy. Mark post-let-go copies that still lack earlier levels as small-first, not only cases where this branch changed `base`. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -1407,0 +1466,4 @@
Growth::Park => {
if park_once(&host.small_first) {
crate::vram::SMALL_FIRST[3].fetch_add(1, Relaxed);
let parked = (r.data() as u64, host.clone());
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-02 19:13 UTC · original

P2 Badge Avoid pinning parked copies in the growth queue

When a copy is parked because room_lately() is false, this clone leaves a second strong Arc in GROW_PARKED until grow_parked() drains it on a room-positive texture pass. take_idle() only evicts a copy when Arc::strong_count(host) == 1, so after this texture stops being used and its slots and lists release it, the queue alone prevents eviction. Under sustained VRAM pressure the parked copy cannot help recover room, and if room never returns the allocation remains pinned; use a weak reference or remove the queue entry when the copy is no longer current.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-02 19:13 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#discussion_r4774597823) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Avoid pinning parked copies in the growth queue** When a copy is parked because `room_lately()` is false, this clone leaves a second strong `Arc` in `GROW_PARKED` until `grow_parked()` drains it on a room-positive texture pass. `take_idle()` only evicts a copy when `Arc::strong_count(host) == 1`, so after this texture stops being used and its slots and lists release it, the queue alone prevents eviction. Under sustained VRAM pressure the parked copy cannot help recover room, and if room never returns the allocation remains pinned; use a weak reference or remove the queue entry when the copy is no longer current. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
# Conflicts:
#	README.md
#	crates/victory-gpu/src/draw.rs
#	crates/victory-gpu/src/host.rs
# Conflicts:
#	docs/SETTINGS.md
Author
Owner

@⁠abomalocaris on GitHub · 2026-12-04 04:14 UTC · original

Crashes with VICTORY_SMALL_FIRST=1 VICTORY_RESERVE_RELEASE=1 on current main + #342, 16 GB card

Setup: RX 9070 XT 16 GB, Ryzen 7 9800X3D, 32 GB RAM, CachyOS (kernel 7.3.7), proton-cachyos-slr, this repo's patched Mesa 26.3.1 and vkd3d-proton. Series X profile, 2560x1440 output with FSR 4 quality, ray tracing on, VICTORY_PAGES=0, VICTORY_PLACED_COPIED=1, VICTORY_VRAM_BUDGET_MB=17000, VICTORY_TEXTURE_ROOM_PERCENT=87, VICTORY_TEXTURE_ROOM_CAP_PERCENT=87.

First the good part, on main at 842767a with this PR and #262/#274 merged. A scripted 3.4 minute walk-and-pan on one save, summing slots_after_let_go from the stats: vram line:

slots that waited of them shown small first
both switches off 3,372 0
both switches on 1,776 1,775
off, with the budget settings above 360 0
on, with the budget settings above 88 85

A 10 minute run with both on and the budget settings: 4,287 waited, 4,202 shown small first, no crash. So it does what it says on a 16 GB card too.

The problem, on main at 00aa4d3 with this PR, #342 and #344 merged, hardware ray tracing off: a scripted test that turns the camera in place for 3 minutes ended in a lost device (0x887A0005) in 3 of 5 runs with both switches on, between about 30 and 140 seconds into the scene. The kernel log shows a GPU page fault each time ([gfxhub] page fault, Faulty UTCL2 client ID: SQC (data)), then a ring timeout.

  • Same build, same test, both switches off: 0 of 4 runs.
  • Same build, both switches on, with VICTORY_HW_RT=1 and its companions: 0 of 4 runs (3 spin, 1 walk).
  • The walk-and-pan test did not crash with the switches on (3 of 3).

I did not test the two switches separately, so I can't say which one it is. The spin test streams very hard (about 200,000 new texture slots in 3 minutes), which may be what it takes to hit it. I can run either switch alone or a diagnostics build if that helps.

Written with AI assistance (Claude Code); the runs and observations are from my own machine.

**@⁠abomalocaris** on GitHub · 2026-12-04 04:14 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7400986766) **Crashes with `VICTORY_SMALL_FIRST=1 VICTORY_RESERVE_RELEASE=1` on current `main` + #342, 16 GB card** Setup: RX 9070 XT 16 GB, Ryzen 7 9800X3D, 32 GB RAM, CachyOS (kernel 7.3.7), `proton-cachyos-slr`, this repo's patched Mesa 26.3.1 and vkd3d-proton. Series X profile, 2560x1440 output with FSR 4 quality, ray tracing on, `VICTORY_PAGES=0`, `VICTORY_PLACED_COPIED=1`, `VICTORY_VRAM_BUDGET_MB=17000`, `VICTORY_TEXTURE_ROOM_PERCENT=87`, `VICTORY_TEXTURE_ROOM_CAP_PERCENT=87`. First the good part, on `main` at `842767a` with this PR and #262/#274 merged. A scripted 3.4 minute walk-and-pan on one save, summing `slots_after_let_go` from the `stats: vram` line: | | slots that waited | of them shown small first | |---|---|---| | both switches off | 3,372 | 0 | | both switches on | 1,776 | 1,775 | | off, with the budget settings above | 360 | 0 | | on, with the budget settings above | 88 | 85 | A 10 minute run with both on and the budget settings: 4,287 waited, 4,202 shown small first, no crash. So it does what it says on a 16 GB card too. The problem, on `main` at `00aa4d3` with this PR, #342 and #344 merged, hardware ray tracing **off**: a scripted test that turns the camera in place for 3 minutes ended in a lost device (`0x887A0005`) in **3 of 5 runs** with both switches on, between about 30 and 140 seconds into the scene. The kernel log shows a GPU page fault each time (`[gfxhub] page fault`, `Faulty UTCL2 client ID: SQC (data)`), then a ring timeout. - Same build, same test, both switches off: 0 of 4 runs. - Same build, both switches on, with `VICTORY_HW_RT=1` and its companions: 0 of 4 runs (3 spin, 1 walk). - The walk-and-pan test did not crash with the switches on (3 of 3). I did not test the two switches separately, so I can't say which one it is. The spin test streams very hard (about 200,000 new texture slots in 3 minutes), which may be what it takes to hit it. I can run either switch alone or a diagnostics build if that helps. _Written with AI assistance (Claude Code); the runs and observations are from my own machine._
Author
Owner

@⁠Widget9337 on GitHub · 2026-12-04 06:17 UTC · original

Results from a 16 GB card on the Series X profile with ray tracing on, which the PR lists as untested. RX 9070 XT, 7950X3D, 64 GB RAM, CachyOS (kernel 7.2), this repo's Mesa and vkd3d-proton, 1080p output with FSR 4 Balanced, 30 cap. The build is 8585cd4 with this PR's own commits and #428 picked on top (not current main, and not #342 like @⁠abomalocaris). Three runs of about 6 minutes each, walking, turning back and some driving, summed from the stats: vram line:

switches off, budget 17000 both on, budget 17000 both on, system budget (15,388)
copies made again within 5 s 3,221 404 5,003
slots that waited for a let go copy 11,054 405 16,862
small copies made / grown 403 / 347 16,692 / 13,599
small copies at a time, at the end 40 about 1,400
refused passes 262 0 207

"Budget 17000" is VICTORY_VRAM_BUDGET_MB=17000 with VICTORY_TEXTURE_ROOM_PERCENT=87 and VICTORY_TEXTURE_ROOM_CAP_PERCENT=87, as in abomalocaris's runs.

The reserve matters on Series X too. With the switches off, the render targets sat at 1.45 to 1.53 GB for the first 5 minutes, just under the 1.5 GiB that gives the room back, so kept_mb stayed at 1.5 to 1.9 GB and the texture side sat in band 2 (copies idle 2 s let go) with 1.3 to 1.7 GB of the card free. Once the targets passed 1.5 GiB the room came back and letting go nearly stopped. With VICTORY_RESERVE_RELEASE=1 that happened about 90 s in.

Without the raised budget, small first works against itself here. The keep line is 80 % of a 15.4 GB budget, so the card sat in band 2 and 3 with 1.6 to 3 GB free, small copies had no room by the budget's count to grow, and about 1,400 stayed small from 3 minutes on. That run was worse than the switches off on every count. With the budget raised, small copies at a time stayed flat around 40.

Frame rate: the three runs averaged 26.8, 26.0 and 26.2 fps, and that spread follows the scenes, so I can't claim a gain or a loss.

No crash in the two runs with both switches on (about 13 minutes), no lost device and no GPU page fault in the kernel log. I didn't run a spin test like abomalocaris's, and this build has no #342.

By eye: the flickering didn't improve at all. What I notice most is the one frame black flashes in #69, which this PR isn't meant to fix, so the drop in waiting slots didn't show as anything I could point to. I'm keeping both switches on with the raised budget.

**@⁠Widget9337** on GitHub · 2026-12-04 06:17 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7403288703) Results from a 16 GB card on the Series X profile with ray tracing on, which the PR lists as untested. RX 9070 XT, 7950X3D, 64 GB RAM, CachyOS (kernel 7.2), this repo's Mesa and vkd3d-proton, 1080p output with FSR 4 Balanced, 30 cap. The build is `8585cd4` with this PR's own commits and #428 picked on top (not current `main`, and not #342 like @⁠abomalocaris). Three runs of about 6 minutes each, walking, turning back and some driving, summed from the `stats: vram` line: | | switches off, budget 17000 | both on, budget 17000 | both on, system budget (15,388) | |---|---|---|---| | copies made again within 5 s | 3,221 | 404 | 5,003 | | slots that waited for a let go copy | 11,054 | 405 | 16,862 | | small copies made / grown | | 403 / 347 | 16,692 / 13,599 | | small copies at a time, at the end | | 40 | about 1,400 | | refused passes | 262 | 0 | 207 | "Budget 17000" is `VICTORY_VRAM_BUDGET_MB=17000` with `VICTORY_TEXTURE_ROOM_PERCENT=87` and `VICTORY_TEXTURE_ROOM_CAP_PERCENT=87`, as in abomalocaris's runs. **The reserve matters on Series X too.** With the switches off, the render targets sat at 1.45 to 1.53 GB for the first 5 minutes, just under the 1.5 GiB that gives the room back, so `kept_mb` stayed at 1.5 to 1.9 GB and the texture side sat in band 2 (copies idle 2 s let go) with 1.3 to 1.7 GB of the card free. Once the targets passed 1.5 GiB the room came back and letting go nearly stopped. With `VICTORY_RESERVE_RELEASE=1` that happened about 90 s in. **Without the raised budget, small first works against itself here.** The keep line is 80 % of a 15.4 GB budget, so the card sat in band 2 and 3 with 1.6 to 3 GB free, small copies had no room by the budget's count to grow, and about 1,400 stayed small from 3 minutes on. That run was worse than the switches off on every count. With the budget raised, small copies at a time stayed flat around 40. **Frame rate:** the three runs averaged 26.8, 26.0 and 26.2 fps, and that spread follows the scenes, so I can't claim a gain or a loss. **No crash** in the two runs with both switches on (about 13 minutes), no lost device and no GPU page fault in the kernel log. I didn't run a spin test like abomalocaris's, and this build has no #342. **By eye:** the flickering didn't improve at all. What I notice most is the one frame black flashes in #69, which this PR isn't meant to fix, so the drop in waiting slots didn't show as anything I could point to. I'm keeping both switches on with the raised budget.
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 12:02 UTC · original

The diagnostics half is good work and reviewable in five minutes; the memory-policy half is a state machine that decides what a frame sees, and it is in the same PR. Splitting would help more than anything else you could do here.

The one thing to check before anything else: crates/victory-gpu/src/resource.rs:1727 — hosted_for now hands out a copy smaller than the level the view asked for under VICTORY_SMALL_FIRST, while crates/victory-gpu/src/descriptor/host.rs:5228 still builds the slot from the title's full desc[..10], mip count included. So a shader can be told there are N levels over a host texture holding fewer. If the slot's mip count is clamped somewhere, say where; if not, that is an out-of-bounds read on the card.

Smaller:

  • crates/victory-gpu/src/vram.rs:39 maps host::vram_keep's return through the literals 600_000 / 4_000 / 2_000, mirroring KEPT_MS/GENTLE_MS in host.rs:170-180 with nothing tying them together; the test at vram.rs:300 uses literals too, so a constant change silently mislabels the telemetry.
  • Both switches are in docs/SETTINGS.md:65-66 but not in run.conf.default, so they get no # choices: line and never appear in the menu template.

Suggested split: (1) the vram line alone; (2) small-first; (3) reserve-release. And for 2 and 3, one before/after each — the vram line plus fps and copies let go on a 12 GB card, since the whole PR exists because of a trial on issue #119 that the diff does not reproduce.

**@⁠Luxuride** on GitHub · 2026-12-04 12:02 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7410885614) The diagnostics half is good work and reviewable in five minutes; the memory-policy half is a state machine that decides what a frame sees, and it is in the same PR. Splitting would help more than anything else you could do here. The one thing to check before anything else: `crates/victory-gpu/src/resource.rs:1727` — `hosted_for` now hands out a copy *smaller than the level the view asked for* under `VICTORY_SMALL_FIRST`, while `crates/victory-gpu/src/descriptor/host.rs:5228` still builds the slot from the title's full `desc[..10]`, mip count included. So a shader can be told there are N levels over a host texture holding fewer. If the slot's mip count is clamped somewhere, say where; if not, that is an out-of-bounds read on the card. Smaller: - `crates/victory-gpu/src/vram.rs:39` maps `host::vram_keep`'s return through the literals `600_000 / 4_000 / 2_000`, mirroring `KEPT_MS`/`GENTLE_MS` in `host.rs:170-180` with nothing tying them together; the test at `vram.rs:300` uses literals too, so a constant change silently mislabels the telemetry. - Both switches are in `docs/SETTINGS.md:65-66` but not in `run.conf.default`, so they get no `# choices:` line and never appear in the menu template. Suggested split: (1) the `vram` line alone; (2) small-first; (3) reserve-release. And for 2 and 3, one before/after each — the `vram` line plus fps and copies let go on a 12 GB card, since the whole PR exists because of a trial on issue #119 that the diff does not reproduce.
Author
Owner

@⁠skalel on GitHub · 2026-12-04 14:21 UTC · original

@⁠abomalocaris thank you, the spin test is exactly what this needed. I can't tell yet which switch it is, or whether it takes #342 too. Reading the code, the growth of a small copy goes through the replacement path main already has (the old copy is kept for at least a second, then dropped 128 submissions after the last that may use it), so I don't see a use-after-free there. Small-first just runs that path far more often, about 10,000 times in a round here.

If you can spare the time, these three would split it, with the same spin test, ray tracing off, on the same build as your crashing one:

  1. VICTORY_SMALL_FIRST=1 alone
  2. VICTORY_RESERVE_RELEASE=1 alone
  3. Both, on main + this PR without #342

For a crashing run, the last stats: vram lines before the loss and the dmesg page-fault lines (the faulting address and Faulty UTCL2 client ID) would help most. I'll try to reproduce it here on 12 GB with a scripted spin as well.

@⁠Widget9337 thank you too: the reserve sitting just under 1.5 GiB on Series X is a second case for VICTORY_RESERVE_RELEASE. Small copies stuck small under the system budget are a real flaw: they grow only while the card has room by the budget's count, and in bands 2 and 3 that never comes. I'll fix that in the small-first part.

As @⁠Luxuride suggested, I'm splitting this into three: the vram line alone (no change in behaviour), the reserve release, then small-first. This PR will keep the vram line, and I'll link the other two here.

**@⁠skalel** on GitHub · 2026-12-04 14:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7414218973) @⁠abomalocaris thank you, the spin test is exactly what this needed. I can't tell yet which switch it is, or whether it takes #342 too. Reading the code, the growth of a small copy goes through the replacement path `main` already has (the old copy is kept for at least a second, then dropped 128 submissions after the last that may use it), so I don't see a use-after-free there. Small-first just runs that path far more often, about 10,000 times in a round here. If you can spare the time, these three would split it, with the same spin test, ray tracing off, on the same build as your crashing one: 1. `VICTORY_SMALL_FIRST=1` alone 2. `VICTORY_RESERVE_RELEASE=1` alone 3. Both, on `main` + this PR **without #342** For a crashing run, the last `stats: vram` lines before the loss and the `dmesg` page-fault lines (the faulting address and `Faulty UTCL2 client ID`) would help most. I'll try to reproduce it here on 12 GB with a scripted spin as well. @⁠Widget9337 thank you too: the reserve sitting just under 1.5 GiB on Series X is a second case for `VICTORY_RESERVE_RELEASE`. Small copies stuck small under the system budget are a real flaw: they grow only while the card has room by the budget's count, and in bands 2 and 3 that never comes. I'll fix that in the small-first part. As @⁠Luxuride suggested, I'm splitting this into three: the `vram` line alone (no change in behaviour), the reserve release, then small-first. This PR will keep the `vram` line, and I'll link the other two here.
Author
Owner

@⁠skalel on GitHub · 2026-12-04 14:21 UTC · original

@⁠Luxuride thanks. On the one to check first: a slot never claims more levels than the copy holds. When the slot is written from a host copy that starts at a later level, descriptor/host.rs:4776 calls from_base(desc, copy.base, own_mips) (:4971), which moves MostDetailedMip down by the copy's base, clamps it and MipLevels to the copy's own mip count, and lowers ResourceMinLODClamp by the base. The title's desc[..10] that placed() carries (:5265) is what that starts from, not what reaches CreateShaderResourceView. from_base is on main already (:4748/:4943 there), for copies that start at the first level views ask for; small-first just gives it a later base more often.

The smaller two: vram::band will take KEPT_MS/GENTLE_MS from host.rs instead of the literals, with the test going by the same constants, and both switches get their lines in run.conf.default with choices, so F1 lists them.

Split as you suggest: (1) the vram line, here; (2) reserve release; (3) small-first. Each one gets its own before/after on this 12 GB card, vram line and fps.

**@⁠skalel** on GitHub · 2026-12-04 14:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7414219661) @⁠Luxuride thanks. On the one to check first: a slot never claims more levels than the copy holds. When the slot is written from a host copy that starts at a later level, `descriptor/host.rs:4776` calls `from_base(desc, copy.base, own_mips)` (`:4971`), which moves `MostDetailedMip` down by the copy's base, clamps it and `MipLevels` to the copy's own mip count, and lowers `ResourceMinLODClamp` by the base. The title's `desc[..10]` that `placed()` carries (`:5265`) is what that starts from, not what reaches `CreateShaderResourceView`. `from_base` is on `main` already (`:4748`/`:4943` there), for copies that start at the first level views ask for; small-first just gives it a later base more often. The smaller two: `vram::band` will take `KEPT_MS`/`GENTLE_MS` from `host.rs` instead of the literals, with the test going by the same constants, and both switches get their lines in `run.conf.default` with choices, so F1 lists them. Split as you suggest: (1) the `vram` line, here; (2) reserve release; (3) small-first. Each one gets its own before/after on this 12 GB card, `vram` line and fps.
Author
Owner

@⁠skalel on GitHub · 2026-12-04 14:22 UTC · original
On crates/victory-gpu/src/resource.rs line 1778 (outdated):

@@ -1673,6 +1767,17 @@ fn hosted_for(this: This, make: bool, fit: Option<(u32, &std::cell::Cell<bool>)>
             let viewed = crate::descriptor::host::first_viewed(r.data() as u64).unwrap_or(u32::MAX);
             let first = wanted.min(viewed);
             base = base_level(&r.desc, if first == u32::MAX { 0 } else { first });
+            // (Not a texture copies go into: it must be whole.)
+            if small_first
+                && !r.host.copy_destination.load(Relaxed)
+                && !crate::texture::host_wrote(this as usize)
+            {
+                let small = small_level(&r.desc);
+                if small > base {
+                    base = small;
+                    made_small = true;

Fixed in ffa02f7: a copy made after a let-go with the switch on is marked small first whenever it is made from the first page's level or a later one (base.max(small_level) inside the small_first branch sets made_small either way), so its growth waits for the upload, the pass and room like any small copy. a_texture_back_at_its_first_page_level_is_small_first covers a first view at the first page's level.

**@⁠skalel** on GitHub · 2026-12-04 14:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#discussion_r4801026315) On `crates/victory-gpu/src/resource.rs` line 1778 (outdated): ```diff @@ -1673,6 +1767,17 @@ fn hosted_for(this: This, make: bool, fit: Option<(u32, &std::cell::Cell<bool>)> let viewed = crate::descriptor::host::first_viewed(r.data() as u64).unwrap_or(u32::MAX); let first = wanted.min(viewed); base = base_level(&r.desc, if first == u32::MAX { 0 } else { first }); + // (Not a texture copies go into: it must be whole.) + if small_first + && !r.host.copy_destination.load(Relaxed) + && !crate::texture::host_wrote(this as usize) + { + let small = small_level(&r.desc); + if small > base { + base = small; + made_small = true; ``` Fixed in ffa02f7: a copy made after a let-go with the switch on is marked small first whenever it is made from the first page's level or a later one (`base.max(small_level)` inside the `small_first` branch sets `made_small` either way), so its growth waits for the upload, the pass and room like any small copy. `a_texture_back_at_its_first_page_level_is_small_first` covers a first view at the first page's level.
Author
Owner

@⁠skalel on GitHub · 2026-12-04 14:22 UTC · original
On crates/victory-gpu/src/resource.rs line 1469 (outdated):

@@ -1399,11 +1446,37 @@ pub(crate) fn want_level(this: This, first: u32) {
     let mut made = r.host.made.lock().unwrap_or_else(|e| e.into_inner());
     let Some((host, _)) = made.as_ref() else {
         r.host.wanted.fetch_min(first, Relaxed);
+        // What needs every level does not come back small first.
+        if asked == Asked::Copy {
+            r.host.small_first.store(false, Relaxed);
+        }
         return;
     };
     if host.base == 0 || host.base <= base_level(&r.desc, first) {
         return;
     }
+    // Slice 2b: a copy that came back small first (decided under the lock
+    // that holds it).
+    let state = host.small_first.load(Relaxed);
+    if state != SMALL_NO && asked != Asked::Copy {
+        let pass = asked == Asked::Pass;
+        let room = state == SMALL_FILLED && pass && room_lately();
+        match growth(state, pass, room) {
+            Growth::Keep => return,
+            Growth::Park => {
+                if park_once(&host.small_first) {
+                    crate::vram::SMALL_FIRST[3].fetch_add(1, Relaxed);
+                    let parked = (r.data() as u64, host.clone());

Fixed in ffa02f7: GROW_PARKED holds a Weak<HostTexture>, so the queue keeps nothing alive and take_idle can let a parked copy go; when the queue is drained, a copy already gone is skipped. a_parked_copy_is_not_held_by_the_queue checks the strong count is unchanged by parking.

**@⁠skalel** on GitHub · 2026-12-04 14:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#discussion_r4801026818) On `crates/victory-gpu/src/resource.rs` line 1469 (outdated): ```diff @@ -1399,11 +1446,37 @@ pub(crate) fn want_level(this: This, first: u32) { let mut made = r.host.made.lock().unwrap_or_else(|e| e.into_inner()); let Some((host, _)) = made.as_ref() else { r.host.wanted.fetch_min(first, Relaxed); + // What needs every level does not come back small first. + if asked == Asked::Copy { + r.host.small_first.store(false, Relaxed); + } return; }; if host.base == 0 || host.base <= base_level(&r.desc, first) { return; } + // Slice 2b: a copy that came back small first (decided under the lock + // that holds it). + let state = host.small_first.load(Relaxed); + if state != SMALL_NO && asked != Asked::Copy { + let pass = asked == Asked::Pass; + let room = state == SMALL_FILLED && pass && room_lately(); + match growth(state, pass, room) { + Growth::Keep => return, + Growth::Park => { + if park_once(&host.small_first) { + crate::vram::SMALL_FIRST[3].fetch_add(1, Relaxed); + let parked = (r.data() as u64, host.clone()); ``` Fixed in ffa02f7: `GROW_PARKED` holds a `Weak<HostTexture>`, so the queue keeps nothing alive and `take_idle` can let a parked copy go; when the queue is drained, a copy already gone is skipped. `a_parked_copy_is_not_held_by_the_queue` checks the strong count is unchanged by parking.
github-bot force-pushed github-bot/gh-216 from bc332db5f1 to 7d9e57e947 2026-12-04 16:59:38 +00:00 Compare
github-bot changed title from textures on 12 GB cards: give the render targets' room back, and bring a let-go texture back blurred instead of black (both opt-in) to victory-gpu: a vram line every 5 s: how the card is shared and what letting copies go costs 2026-12-04 17:05:01 +00:00
github-bot force-pushed github-bot/gh-216 from 7d9e57e947 to 624d18ca10 2026-12-04 18:42:09 +00:00 Compare
Author
Owner

@⁠skalel on GitHub · 2026-12-04 18:40 UTC · original

@⁠Widget9337 a correction to what I said above: small-first is out, not fixed. Measured with a counter of the slots held back black for lack of room, none of those were of a let-go texture (a slot already made from its view is never held back, so a let-go copy is made again at once), and on was worse in an off/on pair; the body has the numbers. The reserve part, where your Series X case applies, is #481.

**@⁠skalel** on GitHub · 2026-12-04 18:40 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/216#issuecomment-7420749924) @⁠Widget9337 a correction to what I said above: small-first is out, not fixed. Measured with a counter of the slots held back black for lack of room, none of those were of a let-go texture (a slot already made from its view is never held back, so a let-go copy is made again at once), and on was worse in an off/on pair; the body has the numbers. The reserve part, where your Series X case applies, is #481.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/216/head:github-bot/gh-216'
git switch 'github-bot/gh-216'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-216'
git switch 'github-bot/gh-216'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-216'
git switch 'github-bot/gh-216'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-216'
git switch 'main'
git merge --squash 'github-bot/gh-216'
git switch 'main'
git merge --ff-only 'github-bot/gh-216'
git switch 'main'
git merge 'github-bot/gh-216'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.