Windows 10: load an Agility SDK runtime put in the D3D12 folder #21

Open
wilu222 wants to merge 1 commit from upstream-pr/21 into main
wilu222 commented 2026-11-25 04:11:27 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by wilu222 on 2026-11-25T03:26:45Z.


The README lists Windows 10 as supported, but Windows 10's inbox D3D12 runtime stops at shader model 6.5. There the title's root signatures (flags 0xc01) are refused (root signature: Unsupported bit-flag set) and it crashes about 7 s after start (access violation at +0xb5a5f8). #16 got around it by patching in upstream VIctory's closed #175.

This makes victory.exe load Microsoft's Agility SDK runtime when one is put in the repository's D3D12/ folder (git already ignores *.dll): build.rs then adds the D3D12SDKVersion and D3D12SDKPath exports the system's d3d12.dll looks for, and copies the folder's DLLs to target/<profile>/D3D12/, so cargo clean does not lose the runtime. It is the same opt-in as upstream's open #463, with two differences:

  • The SDK version comes from the DLL's own D3D12SDKVersion export, so any Microsoft.Direct3D.D3D12 package works (#463 pins 614 and needs exactly 1.614.1).
  • The D3D12/ folder is tracked (a README says what goes in it) and the script watches the folder, not the DLL. Cargo reruns a build script that watches a missing path on every build, which would relink victory.exe each time for everyone without the runtime.

Without the file the build is unchanged: no exports, the system runtime.

What is in it

  • apps/victory/build.rs (new): detects the runtime, reads its version, adds the exports, copies it beside the executable.
  • D3D12/README.md (new): where the runtime goes.
  • apps/victory/src/main.rs: the two exported statics, and a note on stderr when an opted-in build runs without the runtime beside it.
  • crates/victory-pe/src/image.rs: ImageInfo::exported_u32, with a unit test on a synthetic image.
  • apps/victory/Cargo.toml: victory-pe as a build dependency (Cargo.lock unchanged).
  • README.md: the Windows 10 step.

Tested

  • NVIDIA GeForce RTX 5070, Windows 10 22H2 (19045), Rust 1.98.1, release build, on main 90b529f.
  • main as is: crash 7 s after start, as above.
  • This branch with Agility SDK 1.620.2 in D3D12/: the build reports using the Agility SDK runtime 620; victory.exe exports D3D12SDKVersion = 620 and D3D12SDKPath → .\D3D12\. A 90 s run: boot screens and menus at 30 fps (2,048+ frames), no root signature refused, no crash, crashes.log unchanged. After the change to the D3D12/ folder: a 60 s run, menus at 30 fps, no root signature refused, no crash.
  • Deleting target/release/D3D12 and running cargo clean --release -p victory, then building: the runtime is copied back.
  • Without the DLL: no exports, and a repeated build does not relink.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and the --all-features variant: clean. cargo xtask policy --staged: ok.
  • cargo test --workspace --locked --no-fail-fast: 474 passed, 23 failed, 7 ignored; main on the same machine: 473 passed, the same 23 failed. They are GPU tests that find no shader model 6.6 device on Windows 10 (the test binaries do not opt in), plus crash::tests::unwinds_like_the_system_walk, which fails intermittently on both.

Not tested

  • Windows 11 (the opt-in only adds exports when the DLL is there; without it nothing changes).
  • Gameplay past the menus with the opt-in; AMD GPUs.
<!-- greyfinch-sync:Zettrox/ztrx:issue:6596498517 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/21). Originally posted by [wilu222](https://github.com/wilu222) on 2026-11-25T03:26:45Z. --- The README lists Windows 10 as supported, but Windows 10's inbox D3D12 runtime stops at shader model 6.5. There the title's root signatures (flags 0xc01) are refused (`root signature: Unsupported bit-flag set`) and it crashes about 7 s after start (access violation at `+0xb5a5f8`). #16 got around it by patching in upstream VIctory's closed #175. This makes `victory.exe` load Microsoft's Agility SDK runtime when one is put in the repository's `D3D12/` folder (git already ignores `*.dll`): `build.rs` then adds the `D3D12SDKVersion` and `D3D12SDKPath` exports the system's `d3d12.dll` looks for, and copies the folder's DLLs to `target/<profile>/D3D12/`, so `cargo clean` does not lose the runtime. It is the same opt-in as upstream's open #463, with two differences: - The SDK version comes from the DLL's own `D3D12SDKVersion` export, so any `Microsoft.Direct3D.D3D12` package works (#463 pins 614 and needs exactly 1.614.1). - The `D3D12/` folder is tracked (a README says what goes in it) and the script watches the folder, not the DLL. Cargo reruns a build script that watches a missing path on every build, which would relink `victory.exe` each time for everyone without the runtime. Without the file the build is unchanged: no exports, the system runtime. **What is in it** - `apps/victory/build.rs` (new): detects the runtime, reads its version, adds the exports, copies it beside the executable. - `D3D12/README.md` (new): where the runtime goes. - `apps/victory/src/main.rs`: the two exported statics, and a note on stderr when an opted-in build runs without the runtime beside it. - `crates/victory-pe/src/image.rs`: `ImageInfo::exported_u32`, with a unit test on a synthetic image. - `apps/victory/Cargo.toml`: `victory-pe` as a build dependency (`Cargo.lock` unchanged). - `README.md`: the Windows 10 step. **Tested** - NVIDIA GeForce RTX 5070, Windows 10 22H2 (19045), Rust 1.98.1, release build, on `main` `90b529f`. - `main` as is: crash 7 s after start, as above. - This branch with Agility SDK 1.620.2 in `D3D12/`: the build reports `using the Agility SDK runtime 620`; `victory.exe` exports `D3D12SDKVersion = 620` and `D3D12SDKPath` → `.\D3D12\`. A 90 s run: boot screens and menus at 30 fps (2,048+ frames), no root signature refused, no crash, `crashes.log` unchanged. After the change to the `D3D12/` folder: a 60 s run, menus at 30 fps, no root signature refused, no crash. - Deleting `target/release/D3D12` and running `cargo clean --release -p victory`, then building: the runtime is copied back. - Without the DLL: no exports, and a repeated build does not relink. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and the `--all-features` variant: clean. `cargo xtask policy --staged`: ok. - `cargo test --workspace --locked --no-fail-fast`: 474 passed, 23 failed, 7 ignored; `main` on the same machine: 473 passed, the same 23 failed. They are GPU tests that find no shader model 6.6 device on Windows 10 (the test binaries do not opt in), plus `crash::tests::unwinds_like_the_system_walk`, which fails intermittently on both. **Not tested** - Windows 11 (the opt-in only adds exports when the DLL is there; without it nothing changes). - Gameplay past the menus with the opt-in; AMD GPUs.
upstream-sync changed title from [PR #21] Windows 10: load an Agility SDK runtime placed beside victory.exe to [PR #21] Windows 10: load an Agility SDK runtime put in the D3D12 folder 2026-11-25 05:09:05 +00:00
Ekibunnel commented 2026-11-25 05:09:08 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Ekibunnel on 2026-11-25T04:42:06Z.


Your pr does what it say it does.
But hum... having the build touch the target folder is not a good thing.

as you said in the readme, a cargo clean deletes the folder so a :

cargo clean
cargo build --release -p victory

will just get rid of the files.

there is no real reason to check target/<profile>/D3D12/D3D12Core.dll at build time.
we should just check D3D12/D3D12Core.dll use that for the export and then copy it to target/<profile>/D3D12/D3D12Core.dll.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7153085317 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/21#issuecomment-7153085317). Originally posted by [Ekibunnel](https://github.com/Ekibunnel) on 2026-11-25T04:42:06Z. --- Your pr does what it say it does. But hum... having the build touch the target folder is not a good thing. as you said in the readme, a `cargo clean` deletes the folder so a : ``` cargo clean cargo build --release -p victory ``` will just get rid of the files. there is no real reason to check `target/<profile>/D3D12/D3D12Core.dll` at build time. we should just check `D3D12/D3D12Core.dll` use that for the export and then copy it to `target/<profile>/D3D12/D3D12Core.dll`.
wilu222 commented 2026-11-25 05:09:09 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by wilu222 on 2026-11-25T04:57:09Z.


Good idea, just updated. The DLL now goes in a D3D12/ folder at the repo root (already git-ignored as *.dll), the build reads the version from there and copies it to target/<profile>/D3D12/, so cargo clean doesn't lose it anymore. Retested: menus at 30 fps on Win10, and nothing changes when the folder is empty.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7153312385 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/21#issuecomment-7153312385). Originally posted by [wilu222](https://github.com/wilu222) on 2026-11-25T04:57:09Z. --- Good idea, just updated. The DLL now goes in a `D3D12/` folder at the repo root (already git-ignored as `*.dll`), the build reads the version from there and copies it to `target/<profile>/D3D12/`, so `cargo clean` doesn't lose it anymore. Retested: menus at 30 fps on Win10, and nothing changes when the folder is empty.
Ekibunnel commented 2026-11-25 06:06:46 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Ekibunnel on 2026-11-25T05:12:00Z.


tested 9e3ceecece and everything is working fine.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7153541585 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/21#issuecomment-7153541585). Originally posted by [Ekibunnel](https://github.com/Ekibunnel) on 2026-11-25T05:12:00Z. --- tested 9e3ceececef41e7e10fe610a668b64b29e132405 and everything is working fine.
bailu12300 commented 2026-11-25 06:06:47 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by bailu12300 on 2026-11-25T06:04:05Z.


Confirming this works on Windows 10 19045 (build 19041's inbox d3d12.dll is 10.0.19041.5794, so the title's SM 6.6 requirement is not met without it).

What I did, at 90b529f, nothing else changed:

  • copied D3D12Core.dll + d3d12SDKLayers.dll (1.614.0) into target\release\D3D12\
  • in apps/victory/src/main.rs, right after the //! block:
#[unsafe(no_mangle)]
pub static D3D12SDKVersion: u32 = 614;
#[unsafe(no_mangle)]
pub static mut D3D12SDKPath: *const i8 = c".\\D3D12\\".as_ptr();
  • a build.rs with:
println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKVersion,DATA");
println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKPath,DATA");

Before this: crash at ~frame 64 (0xc0000005 read 0x68), only 7 shaders translated, drawn=0.
After this: drawn=9382 dispatched=512, zero drops, 30 fps on the first-boot screens, and the prologue is reachable.

Note #[no_mangle] alone fails to link here (LNK2001 unresolved D3D12SDKPath/Version) unless the linker is told to export them, and from clause #[used] statics are not exported at all — the unsafe(no_mangle) + /EXPORT pair is what works. Might be worth putting one line about the Win10 path in README's Requirements.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7154407408 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/21#issuecomment-7154407408). Originally posted by [bailu12300](https://github.com/bailu12300) on 2026-11-25T06:04:05Z. --- Confirming this works on Windows 10 19045 (build 19041's inbox `d3d12.dll` is 10.0.19041.5794, so the title's SM 6.6 requirement is not met without it). What I did, at 90b529f, nothing else changed: - copied `D3D12Core.dll` + `d3d12SDKLayers.dll` (1.614.0) into `target\release\D3D12\` - in `apps/victory/src/main.rs`, right after the `//!` block: ```rust #[unsafe(no_mangle)] pub static D3D12SDKVersion: u32 = 614; #[unsafe(no_mangle)] pub static mut D3D12SDKPath: *const i8 = c".\\D3D12\\".as_ptr(); ``` - a `build.rs` with: ```rust println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKVersion,DATA"); println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKPath,DATA"); ``` Before this: crash at ~frame 64 (`0xc0000005 read 0x68`), only 7 shaders translated, `drawn=0`. After this: `drawn=9382 dispatched=512`, zero drops, 30 fps on the first-boot screens, and the prologue is reachable. Note `#[no_mangle]` alone fails to link here (LNK2001 unresolved D3D12SDKPath/Version) unless the linker is told to export them, and from clause `#[used]` statics are not exported at all — the `unsafe(no_mangle)` + `/EXPORT` pair is what works. Might be worth putting one line about the Win10 path in README's Requirements.
futurepro62 commented 2026-11-25 07:06:30 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by futurepro62 on 2026-11-25T06:38:41Z.


Full-suite run, to go with Ekibunnel's and bailu12300's checks of the build above. Tested exact head 9e3ceec (on its base 90b529f).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (rust-toolchain.toml), DXC + dxil.dll 1.9.2602.17, debug.
  • cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored (main 90b529f on this machine: 496 passed, 0 failed, 7 ignored).
  • cargo clippy --workspace --all-targets --locked -- -D warnings (the CI lint step): passed.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (the CI lint step): passed.
  • The new tests ran and passed: an_exported_u32_is_read_from_the_file.

Not tested

  • AMD (ztrx targets NVIDIA), a release build, the game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Zettrox/ztrx:comment:7155007741 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/21#issuecomment-7155007741). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T06:38:41Z. --- Full-suite run, to go with Ekibunnel's and bailu12300's checks of the build above. Tested exact head `9e3ceec` (on its base `90b529f`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (`rust-toolchain.toml`), DXC + dxil.dll 1.9.2602.17, debug. - `cargo test --workspace --locked`: **497 passed, 0 failed, 7 ignored** (main `90b529f` on this machine: 496 passed, 0 failed, 7 ignored). - `cargo clippy --workspace --all-targets --locked -- -D warnings` (the CI lint step): passed. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (the CI lint step): passed. - The new tests ran and passed: `an_exported_u32_is_read_from_the_file`. **Not tested** - AMD (ztrx targets NVIDIA), a release build, the game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/21:upstream-pr/21'
git switch 'upstream-pr/21'

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