GPU: keep host pipeline libraries per adapter #1015

Merged
yumaste merged 2 commits from upstream-pr/1015 into main 2026-11-30 14:12:04 +00:00
yumaste commented 2026-11-28 11:10:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by yumaste on 2026-11-28T11:10:36Z.


Port of Marvisak/VIctory#2803. The NVIDIA fork currently uses one host pipeline library per cache directory. A run on another adapter can reject that library, then replace it with an incompatible one.

Scope the serialized library, pending replacement and temporary file to the actual D3D12 adapter. The shared early and slow lists stay at the cache root. A compatible legacy library can still load without modifying the legacy files. An unreadable scoped cache disables writes for that run. Keep the mapped-file lifetime and pending replacement path used by this fork.

Related to #555, which selects the device. This PR uses the identity of the device that was actually created.

Windows validation:

  • cargo test -p victory-gpu --locked --lib: 456 passed, 36 ignored.
  • All 9 pipeline-library tests passed with the default mapped path and with VICTORY_LIBRARY_MAP=0. The switching test serializes and reopens real D3D12 libraries on Intel hardware and Microsoft WARP.
  • All-target, all-feature GPU Clippy passed with the existing manual_is_multiple_of lint allowed.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5539507035 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1015). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-28T11:10:36Z. --- Port of Marvisak/VIctory#2803. The NVIDIA fork currently uses one host pipeline library per cache directory. A run on another adapter can reject that library, then replace it with an incompatible one. Scope the serialized library, pending replacement and temporary file to the actual D3D12 adapter. The shared early and slow lists stay at the cache root. A compatible legacy library can still load without modifying the legacy files. An unreadable scoped cache disables writes for that run. Keep the mapped-file lifetime and pending replacement path used by this fork. Related to #555, which selects the device. This PR uses the identity of the device that was actually created. Windows validation: - `cargo test -p victory-gpu --locked --lib`: 456 passed, 36 ignored. - All 9 pipeline-library tests passed with the default mapped path and with `VICTORY_LIBRARY_MAP=0`. The switching test serializes and reopens real D3D12 libraries on Intel hardware and Microsoft WARP. - All-target, all-feature GPU Clippy passed with the existing `manual_is_multiple_of` lint allowed.
Dukestar69 commented 2026-11-28 11:47:22 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T11:47:22Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests (RTX 5090 + WARP): cargo test -p victory-gpu --lib pipeline:: passed (28 passed; 0 failed, including switching_between_hardware_and_warp_preserves_each_cache, legacy_cache_is_read_only_and_an_unreadable_scope_is_protected, and a_new_save_supersedes_an_existing_pending_library) with 0 compiler warnings.

Clean per-adapter pipeline library isolation preventing cache clobbering across hardware/WARP switches. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6097607452 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1015#pullrequestreview-6097607452). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T11:47:22Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests (RTX 5090 + WARP)**: `cargo test -p victory-gpu --lib pipeline::` passed (`28 passed; 0 failed`, including `switching_between_hardware_and_warp_preserves_each_cache`, `legacy_cache_is_read_only_and_an_unreadable_scope_is_protected`, and `a_new_save_supersedes_an_existing_pending_library`) with 0 compiler warnings. Clean per-adapter pipeline library isolation preventing cache clobbering across hardware/WARP switches. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Exopus-0x65f7ad0 commented 2026-11-28 13:36:35 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Exopus-0x65f7ad0 on 2026-11-28T13:36:35Z.


Tested the upgrade path on native Windows, with an existing preloaded cache: the case most users will hit after updating.

Setup: RTX 5060 Ti 8 GB, Windows 11 26300, driver from today. 63b902f plus this PR, plus local commits (one local commit to library.rs, a save-cadence tweak, was reverted for this test so the PR runs as written). The cache was filled by victory preload this morning (host-pipelines.bin, 73,988,180 bytes, at the cache root). README launcher defaults. Two starts in a row.

start 1 (legacy cache only) start 2
load line host pipeline library loaded bytes=73988180 mapped=true (the legacy file, mapped) host pipeline library loaded bytes=75690220 mapped=true (the scoped file)
saves 3 saves, last bytes=75690220 … made=1189 loaded=963 no save at all: nothing new was made
files after adapters/hardware-10de-2d04-1444196e-a1/host-pipelines.bin created (75,690,220 B) unchanged
legacy host-pipelines.bin untouched (same size, mtime still from this morning) untouched

So:

  • The legacy library loads mapped, not read into memory. Blob::read tries Mapped::open first, which was my one worry for 16 GB machines.
  • The first save after the upgrade writes the full scoped copy, and from the next start on the scoped copy is the one used.
  • The old root files stay as they were, so an older exe still finds its cache.
  • loaded=963 on start 1 matches what the same save gives without the PR (loaded=961), so no warm-up was lost in the move.

One unrelated thing: start 1 stalled during world load (no frame lines after a 1,030 ms frame). It's the stall from #846, which I also got on a build without this PR this morning on the same machine, so it's not caused by this change.

Looks good from here. 👍

Edit: the stalls I mention here turned out to come from a local, unpublished commit in my own build (a dispatch that waits for its compute pipeline with no time limit). With it off, 0 stalls in 5 starts. They are not the upstream #846 stall; see my correction on #846.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7240057121 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1015#issuecomment-7240057121). Originally posted by [Exopus-0x65f7ad0](https://github.com/Exopus-0x65f7ad0) on 2026-11-28T13:36:35Z. --- Tested the upgrade path on native Windows, with an existing preloaded cache: the case most users will hit after updating. **Setup:** RTX 5060 Ti 8 GB, Windows 11 26300, driver from today. `63b902f` plus this PR, plus local commits (one local commit to `library.rs`, a save-cadence tweak, was reverted for this test so the PR runs as written). The cache was filled by `victory preload` this morning (`host-pipelines.bin`, 73,988,180 bytes, at the cache root). README launcher defaults. Two starts in a row. | | start 1 (legacy cache only) | start 2 | |---|---|---| | load line | `host pipeline library loaded bytes=73988180 mapped=true` (the legacy file, **mapped**) | `host pipeline library loaded bytes=75690220 mapped=true` (the scoped file) | | saves | 3 saves, last `bytes=75690220 … made=1189 loaded=963` | no save at all: nothing new was made | | files after | `adapters/hardware-10de-2d04-1444196e-a1/host-pipelines.bin` created (75,690,220 B) | unchanged | | legacy `host-pipelines.bin` | untouched (same size, mtime still from this morning) | untouched | So: - The legacy library loads **mapped**, not read into memory. `Blob::read` tries `Mapped::open` first, which was my one worry for 16 GB machines. - The first save after the upgrade writes the full scoped copy, and from the next start on the scoped copy is the one used. - The old root files stay as they were, so an older exe still finds its cache. - `loaded=963` on start 1 matches what the same save gives without the PR (`loaded=961`), so no warm-up was lost in the move. One unrelated thing: start 1 stalled during world load (no frame lines after a 1,030 ms frame). It's the stall from #846, which I also got on a build without this PR this morning on the same machine, so it's not caused by this change. Looks good from here. 👍 **Edit:** the stalls I mention here turned out to come from a local, unpublished commit in my own build (a dispatch that waits for its compute pipeline with no time limit). With it off, 0 stalls in 5 starts. They are not the upstream #846 stall; see my correction on #846.
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
trustno1-coder/VIctory-NVIDIA!1015
No description provided.