victory: opt into a staged D3D12 Agility SDK runtime #3667

Open
kotekompotek wants to merge 1 commit from upstream-pr/3667 into main
kotekompotek commented 2026-11-28 04:47:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-28T04:47:25Z.


Summary

Windows 10's inbox D3D12 runtime stops at shader model 6.5. The shaders victory translates target 6.6 and index descriptor heaps directly, so their root signatures carry D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED (flags 0xc00, 0xc01 with input assembly) — see crates/victory-shader/src/emit/host.rs:321. The inbox runtime refuses every one of them with E_INVALIDARG, and the title crashes early in boot. This is #753.

This PR opts the executable into the D3D12 Agility SDK when — and only when — a runtime is staged next to the build output:

  • apps/victory/build.rs (new): when target/<profile>/D3D12/D3D12Core.dll exists, parses that DLL's PE export table for its real D3D12SDKVersion and emits the MSVC /EXPORT link arguments. The version is never hard-coded, so the export cannot silently disagree with the staged runtime (the loader refuses a mismatch outright). The exports are scoped with rustc-link-arg-bin=victory and carry the ,DATA suffix, so integration-test binaries still link. The watched input is the D3D12 directory rather than the DLL, so copying a runtime in or out reconfigures the build even when the DLL keeps an older timestamp. Without the file the build behaves exactly as before: no exports, no opt-in, system runtime.
  • apps/victory/src/main.rs: the D3D12SDKVersion / D3D12SDKPath exported statics (compiled only when the build script opted in), a startup check that names the missing file instead of failing later with what reads as a GPU problem, and the probe wiring.
  • apps/victory/src/agility_probe.rs (new): hidden victory agility-probe command that serializes 0xc00/0xc01 root signatures through the same title-facing victory_gpu::root::serialize_versioned path the game uses, then creates the hardware SM 6.6 device victory-shader's host builds — verifies a staged runtime without any title data.

Supersedes the approach of #463 (credit to @Shaun-Fong for getting there first), addressing its review feedback: the integration-test link failure (@walterwallaceson: rustc-link-arg exported from every binary — here scoped to bin=victory), the missing ,DATA suffix, the stale incremental build after copying an older-timestamped DLL (@andrewpozdnakov7-jpg — here the directory is the watched input), the silent opt-in failure (@reboot0000-cmd — here a build-time cargo:warning either way plus a run-time check), and the hard-coded version 614 (here parsed from the staged DLL itself). It is also based on current main.

Closes #753.

Evidence

victory agility-probe on Windows 10 22H2, GTX 1050, Agility SDK 1.616 staged in target/debug/D3D12:

agility probe: executable configured for Agility SDK 616
root serialize flags 0xc00: hresult 0x0 succeeded
root serialize flags 0xc01: hresult 0x0 succeeded
hardware SM 6.6 device: created (NVIDIA GeForce GTX 1050, 4004 MiB dedicated)
hardware root signature 0xc01: created

exit code 0. On the same host without the runtime, the inbox runtime rejects flags 0x400/0x800/0xc00/0xc01 with E_INVALIDARG — matching #753's report exactly.

Boot evidence, GTA VI: boot previously crashed at frame 1024 — victory-image+0xb5a5f8, a null effect-variant dereference downstream of 21,507 failed root-signature serializations. With this change and the runtime staged, boot passes frames 1024 / 2048 / 4096 / 5980 with drawn == frame count at every checkpoint, zero exceptions, zero serialization failures.

Runtime layout

The runtime cannot be redistributed in this repository, so users supply it themselves: download the Microsoft.Direct3D.D3D12 NuGet package and copy build/native/bin/x64/D3D12Core.dll (optionally d3d12SDKLayers.dll) into:

target/<profile>/D3D12/D3D12Core.dll

i.e. target/release/D3D12/D3D12Core.dll next to victory.exe, then rebuild — the build script picks the directory up on its own. Any Agility SDK version works; the exported D3D12SDKVersion is read from whatever DLL is staged. Removing the directory and rebuilding returns to the inbox runtime.

Test plan

  • cargo check -p victory without a staged runtime — negative path compiles, no opt-in, build unchanged
  • cargo build -p victory with the runtime staged — build script announces opting the host D3D12 runtime into Agility SDK 616
  • victory.exe agility-probe exits 0 with all four steps successful (output above)
  • cargo test -p victory --no-run links with the runtime staged — integration tests build with no LNK2001 (the failure mode reported on #463)
  • cargo test -p victory --bin victory — 14/14 pass
  • cargo clippy -p victory --all-targets --locked -- -D warnings clean, with and without --all-features
  • CI: workspace clippy + tests (no runtime staged there — exercises the negative path)
<!-- greyfinch-sync:Marvisak/VIctory:issue:5536772722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3667). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-28T04:47:25Z. --- ## Summary Windows 10's inbox D3D12 runtime stops at shader model 6.5. The shaders victory translates target 6.6 and index descriptor heaps directly, so their root signatures carry `D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED` (flags `0xc00`, `0xc01` with input assembly) — see `crates/victory-shader/src/emit/host.rs:321`. The inbox runtime refuses every one of them with `E_INVALIDARG`, and the title crashes early in boot. This is #753. This PR opts the executable into the D3D12 Agility SDK when — and only when — a runtime is staged next to the build output: - **`apps/victory/build.rs`** (new): when `target/<profile>/D3D12/D3D12Core.dll` exists, parses that DLL's PE export table for its real `D3D12SDKVersion` and emits the MSVC `/EXPORT` link arguments. The version is never hard-coded, so the export cannot silently disagree with the staged runtime (the loader refuses a mismatch outright). The exports are scoped with `rustc-link-arg-bin=victory` and carry the `,DATA` suffix, so integration-test binaries still link. The watched input is the `D3D12` directory rather than the DLL, so copying a runtime in or out reconfigures the build even when the DLL keeps an older timestamp. Without the file the build behaves exactly as before: no exports, no opt-in, system runtime. - **`apps/victory/src/main.rs`**: the `D3D12SDKVersion` / `D3D12SDKPath` exported statics (compiled only when the build script opted in), a startup check that names the missing file instead of failing later with what reads as a GPU problem, and the probe wiring. - **`apps/victory/src/agility_probe.rs`** (new): hidden `victory agility-probe` command that serializes `0xc00`/`0xc01` root signatures through the same title-facing `victory_gpu::root::serialize_versioned` path the game uses, then creates the hardware SM 6.6 device `victory-shader`'s host builds — verifies a staged runtime without any title data. Supersedes the approach of #463 (credit to @Shaun-Fong for getting there first), addressing its review feedback: the integration-test link failure (@walterwallaceson: `rustc-link-arg` exported from every binary — here scoped to `bin=victory`), the missing `,DATA` suffix, the stale incremental build after copying an older-timestamped DLL (@andrewpozdnakov7-jpg — here the directory is the watched input), the silent opt-in failure (@reboot0000-cmd — here a build-time `cargo:warning` either way plus a run-time check), and the hard-coded version 614 (here parsed from the staged DLL itself). It is also based on current `main`. Closes #753. ## Evidence `victory agility-probe` on Windows 10 22H2, GTX 1050, Agility SDK 1.616 staged in `target/debug/D3D12`: ``` agility probe: executable configured for Agility SDK 616 root serialize flags 0xc00: hresult 0x0 succeeded root serialize flags 0xc01: hresult 0x0 succeeded hardware SM 6.6 device: created (NVIDIA GeForce GTX 1050, 4004 MiB dedicated) hardware root signature 0xc01: created ``` exit code 0. On the same host without the runtime, the inbox runtime rejects flags `0x400`/`0x800`/`0xc00`/`0xc01` with `E_INVALIDARG` — matching #753's report exactly. Boot evidence, GTA VI: boot previously crashed at frame 1024 — `victory-image+0xb5a5f8`, a null effect-variant dereference downstream of **21,507** failed root-signature serializations. With this change and the runtime staged, boot passes frames **1024 / 2048 / 4096 / 5980** with drawn == frame count at every checkpoint, **zero exceptions, zero serialization failures**. ## Runtime layout The runtime cannot be redistributed in this repository, so users supply it themselves: download the [Microsoft.Direct3D.D3D12](https://www.nuget.org/packages/Microsoft.Direct3D.D3D12) NuGet package and copy `build/native/bin/x64/D3D12Core.dll` (optionally `d3d12SDKLayers.dll`) into: ``` target/<profile>/D3D12/D3D12Core.dll ``` i.e. `target/release/D3D12/D3D12Core.dll` next to `victory.exe`, then rebuild — the build script picks the directory up on its own. Any Agility SDK version works; the exported `D3D12SDKVersion` is read from whatever DLL is staged. Removing the directory and rebuilding returns to the inbox runtime. ## Test plan - [x] `cargo check -p victory` without a staged runtime — negative path compiles, no opt-in, build unchanged - [x] `cargo build -p victory` with the runtime staged — build script announces `opting the host D3D12 runtime into Agility SDK 616` - [x] `victory.exe agility-probe` exits 0 with all four steps successful (output above) - [x] `cargo test -p victory --no-run` links with the runtime staged — integration tests build with no `LNK2001` (the failure mode reported on #463) - [x] `cargo test -p victory --bin victory` — 14/14 pass - [x] `cargo clippy -p victory --all-targets --locked -- -D warnings` clean, with and without `--all-features` - [ ] CI: workspace clippy + tests (no runtime staged there — exercises the negative path)
andrewpozdnakov7-jpg commented 2026-11-28 05:40:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T05:40:59Z.


I built the exact 02d9d92 executable on Windows 10 22H2, build 19045, and ran its own agility-probe. This used the same Cargo target for all three builds.

Build SDK exports Title-facing serialization for both flags
System runtime 0 E_INVALIDARG for 0xc00 and 0xc01
Microsoft-signed Agility SDK 1.620.2 staged 2 S_OK for both
Runtime removed and rebuilt 0 E_INVALIDARG for both

The staged DLL's last-write time predated the baseline binary. Adding and removing it changed the build's exports. The probe's physical-device step was unavailable on the GeForce GTX 750 Ti in all three runs, so the staged probe still exited 1. This verifies the Windows 10 serialization path. A run with a supported hardware adapter is the next hardware check.

This probe also inherits VICTORY_WARP=1 through the shared device helper. 14f8acd makes its output adapter-neutral and documents that input. I built the follow-up and checked the updated label with the system runtime. kotekompotek can pick up the diagnostic wording if desired.

Please retain the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7234819515 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3667#issuecomment-7234819515). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T05:40:59Z. --- I built the exact `02d9d92` executable on Windows 10 22H2, build 19045, and ran its own `agility-probe`. This used the same Cargo target for all three builds. | Build | SDK exports | Title-facing serialization for both flags | |---|---:|---| | System runtime | 0 | `E_INVALIDARG` for `0xc00` and `0xc01` | | Microsoft-signed Agility SDK 1.620.2 staged | 2 | `S_OK` for both | | Runtime removed and rebuilt | 0 | `E_INVALIDARG` for both | The staged DLL's last-write time predated the baseline binary. Adding and removing it changed the build's exports. The probe's physical-device step was unavailable on the GeForce GTX 750 Ti in all three runs, so the staged probe still exited 1. This verifies the Windows 10 serialization path. A run with a supported hardware adapter is the next hardware check. This probe also inherits `VICTORY_WARP=1` through the shared device helper. [14f8acd](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/14f8acdff5e351b7b41d3e956c591cc74cc986e6) makes its output adapter-neutral and documents that input. I built the follow-up and checked the updated label with the system runtime. kotekompotek can pick up the diagnostic wording if desired. Please retain the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change into another commit. AI-assisted with OpenAI Codex.
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/3667:upstream-pr/3667'
git switch 'upstream-pr/3667'

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/3667'
git switch 'upstream-pr/3667'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3667'
git switch 'upstream-pr/3667'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3667'
git switch 'main'
git merge --squash 'upstream-pr/3667'
git switch 'main'
git merge --ff-only 'upstream-pr/3667'
git switch 'main'
git merge 'upstream-pr/3667'
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
Marvisak/VIctory!3667
No description provided.