perf(victory-gpu): opt-in persistent static sampler ordering (VICTORY_SAMPLER_ORDER=1) #577

Open
Vladimir-Human wants to merge 1 commit from upstream-pr/577 into main
Vladimir-Human commented 2026-11-28 07:52:12 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-28T07:52:12Z.


Summary

Opt-in (default OFF, VICTORY_SAMPLER_ORDER=1) persistent static sampler ordering ported from fxceless/victory-fork commit 9e90746 onto current main (132da61).

Why

Some D3D12 drivers assign each static sampler a hidden table index in root-signature creation order and embed those indices in compiled PSO blobs. Because worker threads reach root signatures in varying order across launches, multi-sampler PSOs can miss ID3D12PipelineLibrary1 and recompile. When VICTORY_SAMPLER_ORDER=1 (true/on) is set, pipeline/sampler_order.rs persists seen descriptors in static-samplers.txt beside the pipeline cache and warms root signatures in deterministic order at startup before first use.

Defaults & Honest Scope

  • Strictly opt-in (default OFF): When VICTORY_SAMPLER_ORDER is unset or 0, before() returns immediately with zero filesystem reads and zero D3D12 root signature creation, and pipeline::make / pipeline::library logs match main unchanged.
  • Modular pipeline/sampler_order.rs is 395 lines (<= 400).
  • Benchmark status: Upstream (fxceless, RTX 4070) reported cold/warm slow compute pipelines dropping 406 -> 211 -> 0 (all pipelines ready in 34 s on subsequent runs); in-game FPS/PSO timings on AnyXboxX are unmeasured (assumed).
  • Zero conflict with #347, #350, #354, or #555.

Verification

Verified locally on Windows 11 (third_party/victory workspace) after the final edit:

  • cargo xtask policy (378 files ok)
  • Hunk-accurate cargo clippy --no-deps -p victory-gpu --locked --all-targets (default & --features diagnostics: 0 errors, 0 own warnings, 10 pre-existing upstream warnings)
  • Both HW (VICTORY_D3D12_WARP=0) and WARP (VICTORY_D3D12_WARP=1, default env):
    • pipeline::sampler_order::tests: 6/6 passed (includes default-OFF check + 5 replay/persistence tests)
    • pipeline::library::tests: 9/9 passed
    • compose::tests::: 1/1 passed
    • pipeline:: on HW (--skip missing_distinguishes_omitted_and_pending_pipelines --skip skipped_hash_leaves_pipeline_unqueued_and_unmatched_queues_normally, which fail identically on untouched 132da61 under --features diagnostics) & pipeline::host::tests 5/5 on WARP

Checklist

  • Neutral naming (0 game, character, or console strings)
  • Rule 10 credits (Source: / Co-authored-by: trailers + THIRD_PARTY.md row)
  • Strictly opt-in (VICTORY_SAMPLER_ORDER=1 off by default)
  • In-game A/B benchmark on AnyXboxX (unmeasured)
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:5538065114 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/577). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-28T07:52:12Z. --- ## Summary Opt-in (**default OFF**, `VICTORY_SAMPLER_ORDER=1`) persistent static sampler ordering ported from `fxceless/victory-fork` commit [`9e90746`](https://github.com/fxceless/victory-fork/commit/9e907466c27001adf66c3f479412b15e093725b9) onto current `main` (`132da61`). ### Why Some D3D12 drivers assign each static sampler a hidden table index in root-signature creation order and embed those indices in compiled PSO blobs. Because worker threads reach root signatures in varying order across launches, multi-sampler PSOs can miss `ID3D12PipelineLibrary1` and recompile. When `VICTORY_SAMPLER_ORDER=1` (`true`/`on`) is set, `pipeline/sampler_order.rs` persists seen descriptors in `static-samplers.txt` beside the pipeline cache and warms root signatures in deterministic order at startup before first use. ### Defaults & Honest Scope - **Strictly opt-in (default OFF):** When `VICTORY_SAMPLER_ORDER` is unset or `0`, `before()` returns immediately with zero filesystem reads and zero D3D12 root signature creation, and `pipeline::make` / `pipeline::library` logs match `main` unchanged. - Modular `pipeline/sampler_order.rs` is `395` lines (`<= 400`). - **Benchmark status:** Upstream (`fxceless`, RTX 4070) reported cold/warm slow compute pipelines dropping `406 -> 211 -> 0` (all pipelines ready in 34 s on subsequent runs); **in-game FPS/PSO timings on `AnyXboxX` are unmeasured (assumed)**. - Zero conflict with `#347`, `#350`, `#354`, or `#555`. ## Verification Verified locally on Windows 11 (`third_party/victory` workspace) after the final edit: - `cargo xtask policy` (378 files ok) - Hunk-accurate `cargo clippy --no-deps -p victory-gpu --locked --all-targets` (default & `--features diagnostics`: 0 errors, 0 own warnings, 10 pre-existing upstream warnings) - Both HW (`VICTORY_D3D12_WARP=0`) and WARP (`VICTORY_D3D12_WARP=1`, default env): - `pipeline::sampler_order::tests`: 6/6 passed (includes default-OFF check + 5 replay/persistence tests) - `pipeline::library::tests`: 9/9 passed - `compose::tests::`: 1/1 passed - `pipeline::` on HW (`--skip missing_distinguishes_omitted_and_pending_pipelines --skip skipped_hash_leaves_pipeline_unqueued_and_unmatched_queues_normally`, which fail identically on untouched `132da61` under `--features diagnostics`) & `pipeline::host::tests` 5/5 on WARP ## Checklist - [x] Neutral naming (0 game, character, or console strings) - [x] Rule 10 credits (`Source:` / `Co-authored-by:` trailers + `THIRD_PARTY.md` row) - [x] Strictly opt-in (`VICTORY_SAMPLER_ORDER=1` off by default) - [ ] In-game A/B benchmark on `AnyXboxX` (unmeasured)
akimfomin commented 2026-11-28 11:37:57 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by akimfomin on 2026-11-28T11:37:57Z.


PortBridge checked the exact daaffd4f head against Vice-Tay's port. On NVIDIA, the host cache gate still passes no library name for a static-sampler pipeline when only VICTORY_SAMPLER_ORDER=1 is set. The inherited NVIDIA guard is independent of sampler ordering. Replay/persistence tests can therefore pass while the intended pipeline still never enters the host library.

Vice-Tay's scoped gate distinguishes keys from the startup replay and keys first seen in the current run. For the AnyXboxX port, one synthetic sampler pipeline with the override unset makes a useful test: first process learns it and declines library reuse, next process successfully primes it and gets a host library hit, and a refused replay or one new sampler forces compile. Keep the sampler-state override out of that test so it cannot mask the gate. This is a source check. PortBridge can help verify the exact synthetic receipt when the path is ready.

<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7238679662 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/577#issuecomment-7238679662). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T11:37:57Z. --- PortBridge checked the exact `daaffd4f` head against Vice-Tay's port. On NVIDIA, [the host cache gate](https://github.com/LooperSalty/AnyXboxX/blob/daaffd4fc095d4122680d98dacaf91f28ed5d833/third_party/victory/crates/victory-gpu/src/pipeline/host.rs#L590-L617) still passes no library name for a static-sampler pipeline when only `VICTORY_SAMPLER_ORDER=1` is set. [The inherited NVIDIA guard](https://github.com/LooperSalty/AnyXboxX/blob/daaffd4fc095d4122680d98dacaf91f28ed5d833/third_party/victory/crates/victory-gpu/src/pipeline/library.rs#L630-L641) is independent of sampler ordering. Replay/persistence tests can therefore pass while the intended pipeline still never enters the host library. [Vice-Tay's scoped gate](https://github.com/TaynanGT/Vice-Tay/blob/ca46856f8250ed0a2f79914fcf3f0d6f4a7ab842/crates/victory-gpu/src/pipeline/host.rs#L598-L606) distinguishes keys from the startup replay and keys first seen in the current run. For the AnyXboxX port, one synthetic sampler pipeline with the override unset makes a useful test: first process learns it and declines library reuse, next process successfully primes it and gets a host library hit, and a refused replay or one new sampler forces compile. Keep the sampler-state override out of that test so it cannot mask the gate. This is a source check. [PortBridge](https://github.com/akimfomin/PortBridge) can help verify the exact synthetic receipt when the path is ready.
Vladimir-Human commented 2026-11-28 15:22:24 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-28T15:22:24Z.


@akimfomin Thanks for catching that in PortBridge! Fixed in a22501b (rebased onto current main 66b92fb):

  • Ported Vice-Tay ca46856f / 33037537's scoped samplers_settled gate into third_party/victory/crates/victory-gpu/src/pipeline/host.rs and pipeline/sampler_order.rs (ALLOW_STATIC_SAMPLERS guard unchanged; only keys replayed cleanly at startup allow library entry when VICTORY_SAMPLER_ORDER=1, while newly-learned keys decline reuse).
  • Added synthetic two-process test suite in pipeline/sampler_order_library_tests.rs with VICTORY_LIBRARY_STATIC_SAMPLERS explicitly unset, verifying: (1) first process learns the sampler key and declines library reuse, (2) second process replays it and gets a host library hit, and (3) a refused replay or a newly introduced sampler forces compile instead of stale library reuse.
  • Verified on third_party/victory with --features diagnostics --locked: cargo clippy -p victory-gpu --all-targets --features diagnostics --locked (0 warnings in touched files), VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked --lib sampler_order (11/11 passed), VICTORY_D3D12_WARP=1 (11/11 passed); Cargo.lock untouched.
<!-- greyfinch-sync:LooperSalty/AnyXboxX:comment:7241416394 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/577#issuecomment-7241416394). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-28T15:22:24Z. --- @akimfomin Thanks for catching that in PortBridge! Fixed in `a22501b` (rebased onto current `main` `66b92fb`): - Ported Vice-Tay `ca46856f` / `33037537`'s scoped `samplers_settled` gate into `third_party/victory/crates/victory-gpu/src/pipeline/host.rs` and `pipeline/sampler_order.rs` (`ALLOW_STATIC_SAMPLERS` guard unchanged; only keys replayed cleanly at startup allow library entry when `VICTORY_SAMPLER_ORDER=1`, while newly-learned keys decline reuse). - Added synthetic two-process test suite in `pipeline/sampler_order_library_tests.rs` with `VICTORY_LIBRARY_STATIC_SAMPLERS` explicitly **unset**, verifying: (1) first process learns the sampler key and declines library reuse, (2) second process replays it and gets a host library hit, and (3) a refused replay or a newly introduced sampler forces compile instead of stale library reuse. - Verified on `third_party/victory` with `--features diagnostics --locked`: `cargo clippy -p victory-gpu --all-targets --features diagnostics --locked` (**0 warnings** in touched files), `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --locked --lib sampler_order` (**11/11 passed**), `VICTORY_D3D12_WARP=1` (**11/11 passed**); `Cargo.lock` untouched.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/577:upstream-pr/577'
git switch 'upstream-pr/577'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/577'
git switch 'upstream-pr/577'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/577'
git switch 'upstream-pr/577'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/577'
git switch 'main'
git merge --squash 'upstream-pr/577'
git switch 'main'
git merge --ff-only 'upstream-pr/577'
git switch 'main'
git merge 'upstream-pr/577'
git push origin 'main'
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
LooperSalty/AnyXboxX!577
No description provided.