gpu(book,indirect): cache AMD adapter check to fix texture-streaming cliff #71

Merged
Androtim merged 1 commit from upstream-pr/71 into main 2026-11-29 00:05:22 +00:00
Androtim commented 2026-11-28 23:10:52 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-28T23:10:52Z.


Summary

Fixes the severe texture-streaming regression introduced on non-AMD GPUs in #2 (e4b05ff), where crates/victory-gpu/src/book.rs::texture_address called crate::indirect::amd(&host.device) uncached on every texture creation (book::made, where_the_card_reads, book::block). Because indirect::amd() recreated a DXGI factory and enumerated adapters (CreateDXGIFactory2 + EnumAdapterByLuid + GetDesc1) on every call, diagnostics builds stalled for 522–1,863 ms per 5s making host copies and 230–334 ms per 5s making slots' views, dropping uploaded textures from ~46k down to ~16.7k–21.9k in 75s and leaving the main house exterior / character model untextured/black.

  • crates/victory-gpu/src/indirect.rs: Cache amd(device) lock-free by adapter LUID via amd_cached() + std::sync::OnceLock, falling back to querying directly if a different adapter LUID is supplied; add unit test amd_vendor_query_is_cached_per_adapter_luid.
  • crates/victory-gpu/src/book.rs: Cache IS_AMD once in texture_address() for the process-wide host device.

Rig Specs Tested On

  • CPU: 13th Gen Intel(R) Core(TM) i7-13700F
  • GPU & VRAM: NVIDIA GeForce RTX 4060 Ti (8188 MiB)
  • System RAM: 31.8 GiB
  • OS & GPU Driver: Microsoft Windows 11 Home, NVIDIA Driver 621.24

Run Settings & Profile

  • Build & Commit SHA: release & release --features diagnostics @ 640b8a1
  • Console Profile & Internal Resolution / Scale: series-s (via scripts/verify-world.ps1 -WorldSeconds 75 -AutoNudgeMenu)
  • Ray Tracing: off
  • Upscaling: DLSS quality
  • Frame Generation: off
  • Launcher Command / Preset & Extra VICTORY_* Overrides: verify-world.ps1 baseline (VICTORY_THIN=1, VICTORY_TEXTURE_POOL=1, VICTORY_UPLOAD_AHEAD=1, VICTORY_SHOW_AFTER=1, etc.; VICTORY_LEVELS_ON_DEMAND=0)
  • Scene / Area & Session Length: Opening world scene, 75s in-world (draws >= 500, 14 windows, max 12,556 draws/frame)

Measurements & Verification

  • Before (origin/main 8dfb64e, bisect-origin-main-8dfb64e / e4b05ff):
    • 16,846 textures uploaded in 75s (21,505 final waiting, 30,361 max waiting) on 8dfb64e (16,735 uploaded / 22,062 waiting on e4b05ff)
    • 548–587 ms making host copies / 265–334 ms making slots' views per 5s window (522–809 ms / 230–301 ms on e4b05ff)
    • Dark untextured house exterior (frame-8950.png / frame-7196.png) and solid-black character face/neck (frame-7948.png on e4b05ff)
  • After (640b8a1, pr-fix-book-amd-cache): 11/11 gates PASS
    • Base FPS (without Frame Gen): 10.8 fps median / 9.16 fps mean (min 0.5 fps, +1.90 fps vs baseline 8.9 fps)
    • Texture Streaming: 46,243 textures uploaded (2,060 MB), 3,153 final waiting (-3,968 vs baseline 7,121)
    • Pass Timings (last 5s windows): 1 ms making host copies (down from 522–1,863 ms), 14–15 ms making slots' views (down from 230–334 ms)
    • Visuals: luma=105.66, near_black=0.0%, edge_energy=7.04, magenta=0.0% (frame-10197.png, frame-11221.png verified: full exterior siding & normal skin-toned character model)
  • Frame-Gen FPS (if enabled): N/A (off)
  • VRAM / RAM Usage: 5,563 MB max VRAM / 6,496 MB min budget (0 MB over budget, 8.3% room=false)
  • Crashes / DRED Resets: 0 crashes, 0 no_host_texture_errors
  • Automated Checks:
    • cargo clippy --workspace --all-targets -- -D warnings
    • cargo clippy --workspace --all-targets --features diagnostics -- -D warnings
    • cargo test -p xtask (6 passed) & cargo run -p xtask -- policy (301 files ok)
    • cargo test -p victory-gpu --lib amd_vendor_query_is_cached_per_adapter_luid -- --test-threads=1 (1 passed) & cargo test -p victory-gpu --features diagnostics --lib book:: -- --test-threads=1 (3 passed)
    • Plain --release build (objdump -p confirmed Windows system DLLs only)
<!-- greyfinch-sync:Androtim/MiniVI:issue:5545501490 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/71). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-28T23:10:52Z. --- ## Summary Fixes the severe texture-streaming regression introduced on non-AMD GPUs in #2 (`e4b05ff`), where `crates/victory-gpu/src/book.rs::texture_address` called `crate::indirect::amd(&host.device)` uncached on every texture creation (`book::made`, `where_the_card_reads`, `book::block`). Because `indirect::amd()` recreated a DXGI factory and enumerated adapters (`CreateDXGIFactory2` + `EnumAdapterByLuid` + `GetDesc1`) on every call, diagnostics builds stalled for `522–1,863 ms` per 5s making host copies and `230–334 ms` per 5s making slots' views, dropping uploaded textures from ~46k down to ~16.7k–21.9k in 75s and leaving the main house exterior / character model untextured/black. - `crates/victory-gpu/src/indirect.rs`: Cache `amd(device)` lock-free by adapter LUID via `amd_cached()` + `std::sync::OnceLock`, falling back to querying directly if a different adapter LUID is supplied; add unit test `amd_vendor_query_is_cached_per_adapter_luid`. - `crates/victory-gpu/src/book.rs`: Cache `IS_AMD` once in `texture_address()` for the process-wide host device. ## Rig Specs Tested On - **CPU:** 13th Gen Intel(R) Core(TM) i7-13700F - **GPU & VRAM:** NVIDIA GeForce RTX 4060 Ti (8188 MiB) - **System RAM:** 31.8 GiB - **OS & GPU Driver:** Microsoft Windows 11 Home, NVIDIA Driver 621.24 ## Run Settings & Profile - **Build & Commit SHA:** `release` & `release --features diagnostics` @ `640b8a1` - **Console Profile & Internal Resolution / Scale:** `series-s` (via `scripts/verify-world.ps1 -WorldSeconds 75 -AutoNudgeMenu`) - **Ray Tracing:** `off` - **Upscaling:** `DLSS quality` - **Frame Generation:** `off` - **Launcher Command / Preset & Extra `VICTORY_*` Overrides:** `verify-world.ps1` baseline (`VICTORY_THIN=1`, `VICTORY_TEXTURE_POOL=1`, `VICTORY_UPLOAD_AHEAD=1`, `VICTORY_SHOW_AFTER=1`, etc.; `VICTORY_LEVELS_ON_DEMAND=0`) - **Scene / Area & Session Length:** Opening world scene, `75s` in-world (`draws >= 500`, `14` windows, max `12,556` draws/frame) ## Measurements & Verification - **Before (`origin/main` `8dfb64e`, `bisect-origin-main-8dfb64e` / `e4b05ff`):** - `16,846` textures uploaded in `75s` (`21,505` final waiting, `30,361` max waiting) on `8dfb64e` (`16,735` uploaded / `22,062` waiting on `e4b05ff`) - `548–587 ms` making host copies / `265–334 ms` making slots' views per 5s window (`522–809 ms` / `230–301 ms` on `e4b05ff`) - Dark untextured house exterior (`frame-8950.png` / `frame-7196.png`) and solid-black character face/neck (`frame-7948.png` on `e4b05ff`) - **After (`640b8a1`, `pr-fix-book-amd-cache`):** **11/11 gates PASS** - **Base FPS (without Frame Gen):** `10.8 fps` median / `9.16 fps` mean (min `0.5 fps`, `+1.90 fps` vs baseline `8.9 fps`) - **Texture Streaming:** `46,243` textures uploaded (`2,060 MB`), `3,153` final waiting (`-3,968` vs baseline `7,121`) - **Pass Timings (last 5s windows):** `1 ms` making host copies (down from `522–1,863 ms`), `14–15 ms` making slots' views (down from `230–334 ms`) - **Visuals:** `luma=105.66`, `near_black=0.0%`, `edge_energy=7.04`, `magenta=0.0%` (`frame-10197.png`, `frame-11221.png` verified: full exterior siding & normal skin-toned character model) - **Frame-Gen FPS (if enabled):** N/A (`off`) - **VRAM / RAM Usage:** `5,563 MB` max VRAM / `6,496 MB` min budget (`0 MB` over budget, `8.3%` `room=false`) - **Crashes / DRED Resets:** `0` crashes, `0` `no_host_texture_errors` - **Automated Checks:** - [x] `cargo clippy --workspace --all-targets -- -D warnings` - [x] `cargo clippy --workspace --all-targets --features diagnostics -- -D warnings` - [x] `cargo test -p xtask` (6 passed) & `cargo run -p xtask -- policy` (301 files ok) - [x] `cargo test -p victory-gpu --lib amd_vendor_query_is_cached_per_adapter_luid -- --test-threads=1` (1 passed) & `cargo test -p victory-gpu --features diagnostics --lib book:: -- --test-threads=1` (3 passed) - [x] Plain `--release` build (`objdump -p` confirmed Windows system DLLs only)
Androtim commented 2026-11-29 00:02:46 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-11-29T00:02:46Z.


Automated triage for the maintainers (not an approval).

Verdict: merge-candidate · CI (check): passing

Review Summary

Clean, minimal fix that memoizes the AMD adapter vendor check so texture creation in diagnostics builds no longer recreates a DXGI factory and enumerates adapters on every call.

Verified changes:

  • crates/victory-gpu/src/indirect.rs (amd_cached, amd): Caches the VendorId == 0x1002 lookup in a lock-free OnceLock<((i32, u32), bool)> keyed by (luid.HighPart, luid.LowPart). Correctly falls back to querying DXGI directly when a different adapter LUID is passed (e.g. WARP/multi-adapter tests) without poisoning or overwriting the cached entry.
  • crates/victory-gpu/src/indirect.rs (amd_vendor_query_is_cached_per_adapter_luid): Unit test verifies cache hit on matching LUID, direct fallback on mismatched LUID, and preservation of the original cached entry.
  • crates/victory-gpu/src/book.rs (texture_address): Caches IS_AMD once in a OnceLock<bool> for the process-wide made_host() device (consistent with the existing process-wide SLOT descriptor heap cache in the same function), avoiding even the GetAdapterLuid() COM call on the hot texture-creation path.

Checks & Risk:

  • CI is passing and static checks report no policy or security flags.
  • Pure CPU-side memoization of an immutable adapter vendor ID with no changes to shaders, GPU commands, or memory budgets; no additional local GPU test is needed before merge.

Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7247835290 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/71#issuecomment-7247835290). Originally posted by [Androtim](https://github.com/Androtim) on 2026-11-29T00:02:46Z. --- <!-- minivi-triage v1 head=640b8a17b8dca0f5b2539b0ec962bd3641661bd0 verdict=merge-candidate ci=passing at=2026-11-29T00:03:12Z --> Automated triage for the maintainers (not an approval). **Verdict:** `merge-candidate` · **CI (`check`):** `passing` ### Review Summary Clean, minimal fix that memoizes the AMD adapter vendor check so texture creation in diagnostics builds no longer recreates a DXGI factory and enumerates adapters on every call. **Verified changes:** - `crates/victory-gpu/src/indirect.rs` (`amd_cached`, `amd`): Caches the `VendorId == 0x1002` lookup in a lock-free `OnceLock<((i32, u32), bool)>` keyed by `(luid.HighPart, luid.LowPart)`. Correctly falls back to querying DXGI directly when a different adapter LUID is passed (e.g. WARP/multi-adapter tests) without poisoning or overwriting the cached entry. - `crates/victory-gpu/src/indirect.rs` (`amd_vendor_query_is_cached_per_adapter_luid`): Unit test verifies cache hit on matching LUID, direct fallback on mismatched LUID, and preservation of the original cached entry. - `crates/victory-gpu/src/book.rs` (`texture_address`): Caches `IS_AMD` once in a `OnceLock<bool>` for the process-wide `made_host()` device (consistent with the existing process-wide `SLOT` descriptor heap cache in the same function), avoiding even the `GetAdapterLuid()` COM call on the hot texture-creation path. **Checks & Risk:** - CI is passing and static checks report no policy or security flags. - Pure CPU-side memoization of an immutable adapter vendor ID with no changes to shaders, GPU commands, or memory budgets; no additional local GPU test is needed before merge. --- _Generated with Antigravity CLI (`agy`)._
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Androtim/MiniVI!71
No description provided.