gpu: physical-page transient RT aliasing, lazy depth-UAV twins, and idle RT reclamation #1147

Closed
github-bot wants to merge 1 commit from github-bot/gh-1147 into main AGit
Owner

@⁠mikael-jarvinen on GitHub · 2026-11-28 14:15 UTC · original
mikael-jarvinen:pr-rt-physical-aliasing → main · +824 −40 · 5 files · 2 commits · closed without merging

Summary

Reduces non-texture VRAM consumption on 8–12 GB GPUs by ~509 MB (−355 MB from transient render-target aliasing + ~154 MB from lazy depth-UAV twins and unmapped/idle RT reclamation) with 0 GPU faults and 0 D3D12 errors.

What Changed

  1. Physical-page transient RT/DS/UAV aliasing (crates/victory-gpu/src/alias_rt.rs, inplace.rs, resource.rs, host.rs):
    • Detects transient render targets / depth-stencil / UAV textures whose title virtual addresses are backed by XMemMapPhysicalPages physical sections (inplace::aliased_section_pages).
    • On D3D12 Tier-2 resource heap / tiled-resource hardware (heap_tier >= 2), creates them via CreateReservedResource and maps their 64 KiB tiles synchronously onto lazily allocated 16 MiB D3D12_HEAP_FLAG_NONE chunks via UpdateTileMappings (plus a small private overflow tile pool for minor pitch padding), mirroring the title's physical-page aliasing on the host GPU.
    • Emits D3D12_RESOURCE_BARRIER_TYPE_ALIASING barriers in HostList::transition and HostList::prelude when switching between aliased resources sharing physical backing.
    • Controlled by VICTORY_ALIAS_TARGETS (default ON; set VICTORY_ALIAS_TARGETS=0 to disable and fall back to committed resources).
  2. Lazy depth-UAV color twins (crates/victory-gpu/src/resource.rs, host.rs):
    • Defers twin_texture allocation for depth textures with ALLOW_UNORDERED_ACCESS until the texture is actually bound as a UAV (resource::ensure_twin), avoiding unused color-twin allocations on plain depth draws.
  3. Unmapped & idle RT reclamation (crates/victory-gpu/src/resource.rs):
    • Periodically reclaims host copies of unmapped or 30 s-idle placed render targets inside let_go_idle (every 5 s), and accounts alias_rt::allocated_bytes() in targets_room_kept().

Verification

  • cargo clippy -p victory-gpu --all-targets --locked (0 warnings in touched files)
  • cargo clippy -p victory-gpu --all-targets --all-features --locked (0 warnings in touched files)
  • cargo test -p victory-gpu --lib --locked: 454 passed, 0 failed (36 ignored), including alias_rt::tests::coalesce_runs_merges_contiguous_tile_ranges
  • cargo xtask policy: 295 files ok
  • cargo build --release -p victory: 0 warnings

A/B Benchmark (origin/main 63b902f vs this PR)

Hardware: NVIDIA RTX 3080 10 GB, Windows 11, 1440p DLSS Performance, identical 115 s scripted startup + world run (VICTORY_WARMUP_RESTART=0, VICTORY_POOL_STATS=1).

Metric origin/main (63b902f) This PR (6ba7fa8) Delta
Aliased transient RTs/DSVs/UAVs 0 256 (731 MB virtual → 376 MB physical) −355 MB (~2:1 ratio, 12 fallbacks)
Non-texture VRAM (peak total − pool) 4,688 MB (8,336 − 3,648) 4,179 MB (8,083 − 3,904) −509 MB (−10.9%)
Peak local VRAM in use 8,336 / 8,679 MB (96%) 8,083 / 8,561 MB (pool grew +256 MB into reclaimed headroom) −253 MB
Texture pass lateness (late 5 s windows) 1.6–2.5 fr (12–15 max) 0.4–0.5 fr (1 max) −75% lateness
held back for room (total) 1,263,687 1,019,913 −19.3%
D3D12 errors / GPU faults 0 0 Clean
**@⁠mikael-jarvinen** on GitHub · 2026-11-28 14:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147) `mikael-jarvinen:pr-rt-physical-aliasing` → `main` · +824 −40 · 5 files · 2 commits · closed without merging ## Summary Reduces non-texture VRAM consumption on 8–12 GB GPUs by **~509 MB** (`−355 MB` from transient render-target aliasing + `~154 MB` from lazy depth-UAV twins and unmapped/idle RT reclamation) with **0 GPU faults and 0 D3D12 errors**. ### What Changed 1. **Physical-page transient RT/DS/UAV aliasing (`crates/victory-gpu/src/alias_rt.rs`, `inplace.rs`, `resource.rs`, `host.rs`)**: - Detects transient render targets / depth-stencil / UAV textures whose title virtual addresses are backed by `XMemMapPhysicalPages` physical sections (`inplace::aliased_section_pages`). - On D3D12 Tier-2 resource heap / tiled-resource hardware (`heap_tier >= 2`), creates them via `CreateReservedResource` and maps their 64 KiB tiles synchronously onto lazily allocated 16 MiB `D3D12_HEAP_FLAG_NONE` chunks via `UpdateTileMappings` (plus a small private overflow tile pool for minor pitch padding), mirroring the title's physical-page aliasing on the host GPU. - Emits `D3D12_RESOURCE_BARRIER_TYPE_ALIASING` barriers in `HostList::transition` and `HostList::prelude` when switching between aliased resources sharing physical backing. - Controlled by `VICTORY_ALIAS_TARGETS` (default ON; set `VICTORY_ALIAS_TARGETS=0` to disable and fall back to committed resources). 2. **Lazy depth-UAV color twins (`crates/victory-gpu/src/resource.rs`, `host.rs`)**: - Defers `twin_texture` allocation for depth textures with `ALLOW_UNORDERED_ACCESS` until the texture is actually bound as a UAV (`resource::ensure_twin`), avoiding unused color-twin allocations on plain depth draws. 3. **Unmapped & idle RT reclamation (`crates/victory-gpu/src/resource.rs`)**: - Periodically reclaims host copies of unmapped or 30 s-idle placed render targets inside `let_go_idle` (every 5 s), and accounts `alias_rt::allocated_bytes()` in `targets_room_kept()`. ## Verification - `cargo clippy -p victory-gpu --all-targets --locked` (0 warnings in touched files) - `cargo clippy -p victory-gpu --all-targets --all-features --locked` (0 warnings in touched files) - `cargo test -p victory-gpu --lib --locked`: **454 passed, 0 failed** (36 ignored), including `alias_rt::tests::coalesce_runs_merges_contiguous_tile_ranges` - `cargo xtask policy`: **295 files ok** - `cargo build --release -p victory`: **0 warnings** ## A/B Benchmark (`origin/main` `63b902f` vs this PR) Hardware: **NVIDIA RTX 3080 10 GB**, Windows 11, 1440p DLSS Performance, identical 115 s scripted startup + world run (`VICTORY_WARMUP_RESTART=0`, `VICTORY_POOL_STATS=1`). | Metric | `origin/main` (`63b902f`) | This PR (`6ba7fa8`) | Delta | |---|---:|---:|---:| | **Aliased transient RTs/DSVs/UAVs** | 0 | **256** (`731 MB` virtual → `376 MB` physical) | **−355 MB (~2:1 ratio, 12 fallbacks)** | | **Non-texture VRAM (peak total − pool)** | 4,688 MB (`8,336 − 3,648`) | **4,179 MB** (`8,083 − 3,904`) | **−509 MB (−10.9%)** | | **Peak local VRAM in use** | 8,336 / 8,679 MB (96%) | **8,083 / 8,561 MB** *(pool grew +256 MB into reclaimed headroom)* | **−253 MB** | | **Texture pass lateness (late 5 s windows)** | 1.6–2.5 fr (12–15 max) | **0.4–0.5 fr (1 max)** | **−75% lateness** | | **`held back for room` (total)** | 1,263,687 | **1,019,913** | **−19.3%** | | **D3D12 errors / GPU faults** | 0 | **0** | Clean |
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:34:26 +00:00
Author
Owner

@⁠rahmondg45 on GitHub · 2026-11-28 14:17 UTC · original

good work

**@⁠rahmondg45** on GitHub · 2026-11-28 14:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147#issuecomment-7240564617) good work
github-bot force-pushed github-bot/gh-1147 from 6ba7fa820c to 724e51feb7 2026-11-28 21:43:15 +00:00 Compare
Author
Owner

@⁠mikael-jarvinen on GitHub · 2026-11-28 21:45 UTC · original

Rebased cleanly onto main (923e38c, head 724e51f; 1/1 alias_rt + 29/29 resource::tests pass, 0 new warnings) and re-measured on RTX 3080 10 GB + Ryzen 7 7800X3D (diag build, warm shader cache, 1440p DLSS Performance, FG off, 115 s scripted run):

Metric main (923e38c) This PR (724e51f) Delta
Steady 3D FPS (med / peak) 15.7 / 17.3 (stall to 5.9) 17.8 / 18.7 (0 stalls) +13.4% FPS
GPU busy (%) / idle behind CPU (ms) 66.0% / 21.65 ms 92.0% / 4.55 ms +26.0 pp / −79.0% idle
Submit prep TOTAL 58.50 ms 49.60 ms −8.90 ms (−15.2%)
VRAM in use (DXGI) 8,247 MB 8,005 MB −242 MB (with +187 MB more pool free)
Texture queue weighed VRAM 8,806 MB 8,237 MB −569 MB
Kept for render targets 692 MB 552 MB −140 MB
Unmapped placed copies alive 230–266 MB 106 MB −54%
**@⁠mikael-jarvinen** on GitHub · 2026-11-28 21:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147#issuecomment-7246246846) Rebased cleanly onto `main` (`923e38c`, head `724e51f`; 1/1 `alias_rt` + 29/29 `resource::tests` pass, 0 new warnings) and re-measured on RTX 3080 10 GB + Ryzen 7 7800X3D (`diag` build, warm shader cache, 1440p DLSS Performance, FG off, 115 s scripted run): | Metric | `main` (`923e38c`) | This PR (`724e51f`) | Delta | |---|---:|---:|---:| | Steady 3D FPS (med / peak) | 15.7 / 17.3 (stall to 5.9) | **17.8 / 18.7 (0 stalls)** | **+13.4% FPS** | | GPU busy (%) / idle behind CPU (ms) | 66.0% / 21.65 ms | **92.0% / 4.55 ms** | **+26.0 pp / −79.0% idle** | | Submit prep TOTAL | 58.50 ms | **49.60 ms** | **−8.90 ms (−15.2%)** | | VRAM in use (DXGI) | 8,247 MB | **8,005 MB** | **−242 MB** (with +187 MB more pool free) | | Texture queue weighed VRAM | 8,806 MB | **8,237 MB** | **−569 MB** | | `Kept for render targets` | 692 MB | **552 MB** | **−140 MB** | | Unmapped placed copies alive | 230–266 MB | **106 MB** | **−54%** |
github-bot referenced this pull request from a commit 2026-11-29 00:27:22 +00:00
Author
Owner

@⁠mikael-jarvinen on GitHub · 2026-11-29 08:17 UTC · original

Note: this PR was merged into main in d6e0670 (so this PR can be closed). Opened follow-up #2042 to fix the missing intra-list aliasing barrier on first aliased RT write and make VICTORY_ALIAS_TARGETS opt-in until DCC/DiscardResource tracking is added.

**@⁠mikael-jarvinen** on GitHub · 2026-11-29 08:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147#issuecomment-7253006258) Note: this PR was merged into `main` in `d6e0670` (so this PR can be closed). Opened follow-up #2042 to fix the missing intra-list aliasing barrier on first aliased RT write and make `VICTORY_ALIAS_TARGETS` opt-in until DCC/`DiscardResource` tracking is added.
Author
Owner

@⁠trustno1-coder on GitHub · 2026-11-29 08:28 UTC · original

Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.

**@⁠trustno1-coder** on GitHub · 2026-11-29 08:28 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147#issuecomment-7253124045) Thank you! An earlier version of this pull request was merged into main with its original commits and is part of [v2026.11.29.01](https://github.com/trustno1-coder/VIctory-NVIDIA/releases/tag/v2026.11.29.01), where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
github-bot closed this pull request 2026-11-29 08:44:44 +00:00
Author
Owner

@⁠mikael-jarvinen on GitHub · 2026-11-29 08:42 UTC · original

Thanks for merging the earlier commits into v2026.11.29.01! The only remaining commit on this branch (96fb6722) was half-superseded by main's alias_tracker.record_touch, and its other half (making VICTORY_ALIAS_TARGETS opt-in =1 until DiscardResource/DCC clearing is verified) is cleanly rebased onto latest main in #2042. Closing this PR to keep things tidy.

**@⁠mikael-jarvinen** on GitHub · 2026-11-29 08:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147#issuecomment-7253276255) Thanks for merging the earlier commits into v2026.11.29.01! The only remaining commit on this branch (`96fb6722`) was half-superseded by `main`'s `alias_tracker.record_touch`, and its other half (making `VICTORY_ALIAS_TARGETS` opt-in `=1` until `DiscardResource`/DCC clearing is verified) is cleanly rebased onto latest `main` in #2042. Closing this PR to keep things tidy.
Author
Owner

@⁠AlexeyYuditsky on GitHub · 2026-11-29 12:21 UTC · original

Because of this PR, ripples started appearing when enabling frame gen 2x and higher.
Скриншот-20261129-151650

**@⁠AlexeyYuditsky** on GitHub · 2026-11-29 12:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1147#issuecomment-7255751340) Because of this PR, ripples started appearing when enabling frame gen 2x and higher. <img width="2558" height="1433" alt="Скриншот-20261129-151650" src="https://github.com/user-attachments/assets/901ceb8c-1f2f-4667-809c-e3d437ac0ea7" />

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1147
No description provided.