gpu: add VICTORY_TEXTURE_MAX and VRAM-budget mip cap for 8 GB cards #318

Closed
github-bot wants to merge 0 commits from github-bot/gh-318 into main AGit
Owner

@⁠neversuptou on GitHub · 2026-12-01 13:11 UTC · original
neversuptou:pr-texture-max → main · +14 −47 · 1 files · 73 commits · closed without merging

Summary

Implements the VRAM-budget mip cap discussed in #68 to reduce PC-memory texture spill on 8 GB GPUs:

  • Adds VICTORY_TEXTURE_MAX=<n> (0 disables capping; any positive value sets a fixed max texture side in pixels).
  • When unset, caps streamed placed 2D textures dynamically by local VRAM usage percentage (cached per 100 ms moment() tick):
    • < 95%: 1024 px
    • >= 95%: 512 px
    • >= 98%: 256 px
  • Feeds the skip count into the existing base_level() path in crates/victory-gpu/src/resource.rs (preserving BC block alignment and tail mip layout) and applies the same floor in want_level() to prevent thrashing when views request mip 0.

Testing

  • Added unit tests texture_max_side_follows_vram_budget_and_override and over_cap_skips_mips_down_to_cap.
  • Verified cargo test --locked -p victory-gpu --lib -- --test-threads=1 over_cap texture_max_side a_placed_texture_is_kept_from_the_level_viewed (3 passed, 0 failed).
  • Tested in-game on RTX 5060 8 GB (Series S profile, VICTORY_TEXTURE_MAX=512) — kept VRAM within budget and eliminated spill stalls.
**@⁠neversuptou** on GitHub · 2026-12-01 13:11 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/318) `neversuptou:pr-texture-max` → `main` · +14 −47 · 1 files · 73 commits · closed without merging ## Summary Implements the VRAM-budget mip cap discussed in #68 to reduce PC-memory texture spill on 8 GB GPUs: - Adds `VICTORY_TEXTURE_MAX=<n>` (`0` disables capping; any positive value sets a fixed max texture side in pixels). - When unset, caps streamed placed 2D textures dynamically by local VRAM usage percentage (cached per 100 ms `moment()` tick): - `< 95%`: 1024 px - `>= 95%`: 512 px - `>= 98%`: 256 px - Feeds the skip count into the existing `base_level()` path in `crates/victory-gpu/src/resource.rs` (preserving BC block alignment and tail mip layout) and applies the same floor in `want_level()` to prevent thrashing when views request mip 0. ## Testing - Added unit tests `texture_max_side_follows_vram_budget_and_override` and `over_cap_skips_mips_down_to_cap`. - Verified `cargo test --locked -p victory-gpu --lib -- --test-threads=1 over_cap texture_max_side a_placed_texture_is_kept_from_the_level_viewed` (3 passed, 0 failed). - Tested in-game on RTX 5060 8 GB (Series S profile, `VICTORY_TEXTURE_MAX=512`) — kept VRAM within budget and eliminated spill stalls.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 13:12:08 +00:00
Author
Owner

@⁠Aniseto on GitHub · 2026-12-01 13:18 UTC · original

Ran the named over_cap / texture_max_side / a_placed_texture_is_kept_from_the_level_viewed tests at 80dd4c0 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own CARGO_TARGET_DIR, no local patches.

cargo test -q --locked -p victory-gpu --lib -- --test-threads=1 over_cap texture_max_side a_placed_texture_is_kept_from_the_level_viewed
3 passed; 0 failed; 0 ignored; 511 filtered out      (exit 0)

All three named tests pass here, including texture_max_side_follows_vram_budget_and_override and over_cap_skips_mips_down_to_cap. The description's in-game check was on an 8 GB RTX 5060; this card has 16 GB of VRAM and 64 GB of host RAM, so the budget-driven cap path was exercised only by the synthetic tests, not by a scene that approaches the limit.

Not tested: the full workspace suite, a retail title, VRAM spill on an 8 GB card, VICTORY_TEXTURE_MAX in a scene, Wine, AMD adapters, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-12-01 13:18 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/318#issuecomment-7312410348) Ran the named `over_cap` / `texture_max_side` / `a_placed_texture_is_kept_from_the_level_viewed` tests at `80dd4c0` on an NVIDIA Blackwell desktop part with 16 GB of VRAM. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own `CARGO_TARGET_DIR`, no local patches. ``` cargo test -q --locked -p victory-gpu --lib -- --test-threads=1 over_cap texture_max_side a_placed_texture_is_kept_from_the_level_viewed 3 passed; 0 failed; 0 ignored; 511 filtered out (exit 0) ``` All three named tests pass here, including `texture_max_side_follows_vram_budget_and_override` and `over_cap_skips_mips_down_to_cap`. The description's in-game check was on an 8 GB RTX 5060; this card has 16 GB of VRAM and 64 GB of host RAM, so the budget-driven cap path was exercised only by the synthetic tests, not by a scene that approaches the limit. Not tested: the full workspace suite, a retail title, VRAM spill on an 8 GB card, `VICTORY_TEXTURE_MAX` in a scene, Wine, AMD adapters, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 14:32 UTC · original

Thanks. The explicit switch is welcome; the default is the problem.

With VICTORY_TEXTURE_MAX unset, texture_max_side returns 1,024 for any card below 95% of its budget, so every streamed 2D texture is cut to 1,024 pixels on every card, a 12 or 16 GB card with room to spare included. That takes detail from everyone to help the cards that are full, and the project does not trade fidelity away on cards that have the room.

It can come in one of two ways:

  1. The explicit switch only. VICTORY_TEXTURE_MAX=<n> as you have it, and no cap when it is unset. The launcher can then offer it on small cards.
  2. A default that starts at the card's limit. No cap below the point where the card is actually full (your 95% and 98% steps), and none at all below that.

Either way, please keep it on the same road as the existing level mechanisms in resource.rs (the level a view asks for, and textures made from their small levels when there is no room) so there are not three rules deciding a texture's first level; another change in that area is in progress and I can point to where they meet. A before/after on an 8 GB card with the fps line and the card-memory line would be the measurement that decides it.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 14:32 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/318#issuecomment-7314437640) Thanks. The explicit switch is welcome; the default is the problem. With `VICTORY_TEXTURE_MAX` unset, `texture_max_side` returns 1,024 for any card below 95% of its budget, so every streamed 2D texture is cut to 1,024 pixels on every card, a 12 or 16 GB card with room to spare included. That takes detail from everyone to help the cards that are full, and the project does not trade fidelity away on cards that have the room. It can come in one of two ways: 1. **The explicit switch only.** `VICTORY_TEXTURE_MAX=<n>` as you have it, and no cap when it is unset. The launcher can then offer it on small cards. 2. **A default that starts at the card's limit.** No cap below the point where the card is actually full (your 95% and 98% steps), and none at all below that. Either way, please keep it on the same road as the existing level mechanisms in `resource.rs` (the level a view asks for, and textures made from their small levels when there is no room) so there are not three rules deciding a texture's first level; another change in that area is in progress and I can point to where they meet. A before/after on an 8 GB card with the fps line and the card-memory line would be the measurement that decides it.
Review: the unset default capped every card to 1024 whether or not it
was full, taking detail from cards with room to spare. The cap is now
only what the switch asks for; the launcher can offer it on small
cards.
Author
Owner

@⁠Aniseto on GitHub · 2026-12-01 14:53 UTC · original

This is a new response on the same thread as my report at 80dd4c0 (#318); the head moved to 5be3373 (the cap is now explicit-only, no cap when VICTORY_TEXTURE_MAX is unset), so I am not editing that comment.

Ran the named over_cap / texture_max_side / a_placed_texture_is_kept_from_the_level_viewed tests at 5be3373 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own CARGO_TARGET_DIR, no local patches.

cargo test -q -p victory-gpu --lib -- --test-threads=1 over_cap texture_max_side a_placed_texture_is_kept_from_the_level_viewed
3 passed; 0 failed; 0 ignored; 511 filtered out      (exit 0)

The same three tests still pass at the new head, with the same counts as at 80dd4c0. The description's in-game check was on an 8 GB RTX 5060; this card has 16 GB and no title was run.

Not tested: the full workspace suite, a retail title, VRAM spill on an 8 GB card, VICTORY_TEXTURE_MAX in a scene, Wine, AMD adapters, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-12-01 14:53 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/318#issuecomment-7315009445) This is a new response on the same thread as my report at `80dd4c0` (https://git.gtahub.st/github/readmet3xt-lab--foxhound/pulls/318); the head moved to `5be3373` (the cap is now explicit-only, no cap when `VICTORY_TEXTURE_MAX` is unset), so I am not editing that comment. Ran the named `over_cap` / `texture_max_side` / `a_placed_texture_is_kept_from_the_level_viewed` tests at `5be3373` on an NVIDIA Blackwell desktop part with 16 GB of VRAM. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own `CARGO_TARGET_DIR`, no local patches. ``` cargo test -q -p victory-gpu --lib -- --test-threads=1 over_cap texture_max_side a_placed_texture_is_kept_from_the_level_viewed 3 passed; 0 failed; 0 ignored; 511 filtered out (exit 0) ``` The same three tests still pass at the new head, with the same counts as at `80dd4c0`. The description's in-game check was on an 8 GB RTX 5060; this card has 16 GB and no title was run. Not tested: the full workspace suite, a retail title, VRAM spill on an 8 GB card, `VICTORY_TEXTURE_MAX` in a scene, Wine, AMD adapters, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Author
Owner

@⁠neversuptou on GitHub · 2026-12-01 15:02 UTC · original

Measured A/B on the RTX 5060 8 GB with the explicit-only build (same switches, cap removed vs VICTORY_TEXTURE_MAX=512): VRAM settled at ~82% of budget in both runs (5663/6880 vs 5656/6874 MB), no no room for more stalls, no E_OUTOFMEMORY, and frame times were scene-bound rather than texture-bound — the cap never engaged because the card was never near full. Median fps 18.9 (uncapped run) vs 30 (capped run) reflects a lighter scene in the second run, not the cap: the uncapped run carried ~13 ms/frame of copies against ~4.8 in the capped one.

For contrast, the same card without the whole current patch set — and with the old always-on 1024 default absent — did fill the card: textures picked by index: the card has no room for more; they wait plus E_OUTOFMEMORY (0x8007000E) on pipeline creation, with dips to 3 fps. So the cap is a tool for cards that actually fill; on this title the card sits at ~82% either way, and the explicit switch is the right shape.

Happy to align with the in-progress resource.rs level work when you can point me to where it lands.

**@⁠neversuptou** on GitHub · 2026-12-01 15:02 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/318#issuecomment-7315255522) Measured A/B on the RTX 5060 8 GB with the explicit-only build (same switches, cap removed vs `VICTORY_TEXTURE_MAX=512`): VRAM settled at ~82% of budget in **both** runs (5663/6880 vs 5656/6874 MB), no `no room for more` stalls, no E_OUTOFMEMORY, and frame times were scene-bound rather than texture-bound — the cap never engaged because the card was never near full. Median fps 18.9 (uncapped run) vs 30 (capped run) reflects a lighter scene in the second run, not the cap: the uncapped run carried ~13 ms/frame of copies against ~4.8 in the capped one. For contrast, the same card without the whole current patch set — and with the old always-on 1024 default absent — did fill the card: `textures picked by index: the card has no room for more; they wait` plus `E_OUTOFMEMORY (0x8007000E)` on pipeline creation, with dips to 3 fps. So the cap is a tool for cards that actually fill; on this title the card sits at ~82% either way, and the explicit switch is the right shape. Happy to align with the in-progress resource.rs level work when you can point me to where it lands.
github-bot closed this pull request 2026-12-02 07:54:44 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.