feat(victory-gpu): add opt-in tile reclamation and zero-alloc single-run mappings #429

Manually merged
github merged 2 commits from github-bot/gh-429 into gh-pr/429/base 2026-11-26 18:47:09 +00:00 AGit
Owner

@⁠Lewandox on GitHub · 2026-11-26 18:19 UTC · original
Lewandox:feat/tiles-opt-in-reclaim-unheld-mips → main · +254 −44 · 1 files · 2 commits · merged 2026-11-26 18:47 UTC

Summary

Adds opt-in VRAM tile reclamation for mip levels the title no longer holds (VICTORY_LEVELS_RECLAIM=1, off by default) and avoids unnecessary per-call heap allocations in Tiled::give_locked and Drop for Tiled (third_party/victory/crates/victory-gpu/src/tiles.rs):

  1. Opt-in tile reclamation (VICTORY_LEVELS_RECLAIM=1, off by default):
    • Tracks per-level tile runs on Given (level_runs: Vec<Vec<(usize, u32, u32)>> for standard mips + packed_runs).
    • When VICTORY_LEVELS_RECLAIM=1 is set and a standard mip level is no longer held by the title or written by the card (!named), give_locked unmaps that subresource (D3D12_TILE_RANGE_FLAG_NULL via UpdateTileMappings) and returns its tiles to the heap pool (updating STATS[2]), allowing freed VRAM to be reused by other textures (and allowing empty 64 MiB heaps to return to the GPU).
    • Off by default so existing behavior is 100% unchanged unless explicitly opted in.
  2. Avoid per-call heap allocations for single-run mappings & single-heap drops:
    • In give_locked, uses stack arrays for single-run tile mappings (runs.len() == 1, the common case) instead of allocating three Vecs (flags, starts, counts) on every UpdateTileMappings call.
  3. Unit tests:
    • Verifies reclaim_on parsing and reclaim_unheld unmapping/returning tiles for unheld standard mips while preserving held/card-written levels and updating given_bytes accurately.

Verification

  • cargo test -p victory-gpu --lib tiles::tests (default and --features diagnostics)
  • cargo xtask policy inside third_party/victory
**@⁠Lewandox** on GitHub · 2026-11-26 18:19 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/429) `Lewandox:feat/tiles-opt-in-reclaim-unheld-mips` → `main` · +254 −44 · 1 files · 2 commits · merged 2026-11-26 18:47 UTC ## Summary Adds opt-in VRAM tile reclamation for mip levels the title no longer holds (`VICTORY_LEVELS_RECLAIM=1`, off by default) and avoids unnecessary per-call heap allocations in `Tiled::give_locked` and `Drop for Tiled` (`third_party/victory/crates/victory-gpu/src/tiles.rs`): 1. **Opt-in tile reclamation (`VICTORY_LEVELS_RECLAIM=1`, off by default)**: - Tracks per-level tile runs on `Given` (`level_runs: Vec<Vec<(usize, u32, u32)>>` for standard mips + `packed_runs`). - When `VICTORY_LEVELS_RECLAIM=1` is set and a standard mip level is no longer held by the title or written by the card (`!named`), `give_locked` unmaps that subresource (`D3D12_TILE_RANGE_FLAG_NULL` via `UpdateTileMappings`) and returns its tiles to the heap pool (updating `STATS[2]`), allowing freed VRAM to be reused by other textures (and allowing empty 64 MiB heaps to return to the GPU). - Off by default so existing behavior is 100% unchanged unless explicitly opted in. 2. **Avoid per-call heap allocations for single-run mappings & single-heap drops**: - In `give_locked`, uses stack arrays for single-run tile mappings (`runs.len() == 1`, the common case) instead of allocating three `Vec`s (`flags`, `starts`, `counts`) on every `UpdateTileMappings` call. 3. **Unit tests**: - Verifies `reclaim_on` parsing and `reclaim_unheld` unmapping/returning tiles for unheld standard mips while preserving held/card-written levels and updating `given_bytes` accurately. ## Verification - `cargo test -p victory-gpu --lib tiles::tests` (default and `--features diagnostics`) - `cargo xtask policy` inside `third_party/victory`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:22:12 +00:00
github-bot changed target branch from main to gh-pr/429/base 2026-11-26 18:47:07 +00:00
github manually merged commit 0d20059eee into gh-pr/429/base 2026-11-26 18:47:09 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.