Repository navigation
GPU: load an app-local D3D12 Agility SDK runtime when present - #463
Shaun-Fong wants to merge 1 commit into
Conversation
Windows 10's inbox D3D12 runtime stops at shader model 6.5, while the shaders victory translates target 6.6 and bind through descriptor heaps. The title's root signatures (flags 0xc01) therefore fail to serialize, its renderer never finishes initializing, and it crashes during Game Init. When target/<profile>/D3D12/D3D12Core.dll exists, export the loader's D3D12SDKVersion (614) and D3D12SDKPath (.\D3D12\) opt-in symbols so d3d12.dll loads that runtime instead of the system copy, and warn when the runtime is missing at run time. The build script enables the exports only when the file is present, so builds without it behave unchanged. Verified on Windows 10 19045 with an i5-10400F and an RTX 2070 SUPER: the device reports shader model 6.6, the title's root signatures serialize, and its menus render and respond at 30 fps.
|
The head The branch carries its own No game data here, so the Agility SDK loading itself was not exercised either. |
Windows 10's in-box D3D12 runtime stops at shader model 6.5, so `Host::new` returns `Err` and the seven `emit::valu_tests` panic on `assert!(ran > 0)`. The application has an opt-in for this (Marvisak#463); the test binaries do not, so `cargo test -p victory-shader` keeps running against the in-box runtime and those seven tests keep failing on a Windows 10 host. `build.rs` looks for the runtime where the application puts it, `target/<profile>/D3D12/D3D12Core.dll`, mirrors it into `target/<profile>/deps/D3D12/` because the loader resolves `D3D12SDKPath` next to the running module and test binaries run from `deps`, then exports `D3D12SDKVersion` and `D3D12SDKPath`. Both steps happen only when the file is present, so a build without it behaves exactly as before. The two symbols are exported with the linker's `/EXPORT:...,DATA` rather than a `.def` file, because `.def` is not on the asset-policy allowlist. Before: 62 passed; 7 failed After: 69 passed; 0 failed The version in `agility.rs` must match the shipped runtime's `D3D12_SDK_VERSION`; with a mismatched pair the loader silently falls back to the in-box runtime and the tests fail again with no warning.
|
I merged I found an incremental build issue. After a build without the SDK, I copied Watching the The rebuilt CLI passed the startup SM 6.6 check with Agility 614 and WARP 1.0.22, and accepted one header-only synthetic DXBC container. With the same WARP package and no Agility exports, the CLI reported SM 6.5. The opt-in executable also printed its missing-runtime warning when copied without AI-assisted. Verified with synthetic input and software D3D12. Incremental patch on f47a36ediff --git a/apps/victory/build.rs b/apps/victory/build.rs
index 80f65f2..5ed6983 100644
--- a/apps/victory/build.rs
+++ b/apps/victory/build.rs
@@ -38,8 +38,11 @@ fn main() {
else {
return;
};
- let runtime = profile_dir.join("D3D12").join("D3D12Core.dll");
- println!("cargo:rerun-if-changed={}", runtime.display());
+ let runtime_dir = profile_dir.join("D3D12");
+ // A copied DLL can have an older timestamp than the last build. The
+ // directory changes when the DLL is added or removed.
+ println!("cargo:rerun-if-changed={}", runtime_dir.display());
+ let runtime = runtime_dir.join("D3D12Core.dll");
if !runtime.is_file() {
return;
} |
|
Automated triage for the maintainers. Needs rebase. This pull request conflicts with Generated by Claude Code |
Windows 10's in-box D3D12 runtime stops at shader model 6.5, so `Host::new` returns `Err` and the seven `emit::valu_tests` panic on `assert!(ran > 0)`. The application has an opt-in for this (Marvisak#463); the test binaries do not, so `cargo test -p victory-shader` keeps running against the in-box runtime and those seven tests keep failing on a Windows 10 host. `build.rs` looks for the runtime where the application puts it, `target/<profile>/D3D12/D3D12Core.dll`, mirrors it into `target/<profile>/deps/D3D12/` because the loader resolves `D3D12SDKPath` next to the running module and test binaries run from `deps`, then exports `D3D12SDKVersion` and `D3D12SDKPath`. Both steps happen only when the file is present, so a build without it behaves exactly as before. The two symbols are exported with the linker's `/EXPORT:...,DATA` rather than a `.def` file, because `.def` is not on the asset-policy allowlist. Before: 62 passed; 7 failed After: 69 passed; 0 failed The version in `agility.rs` must match the shipped runtime's `D3D12_SDK_VERSION`; with a mismatched pair the loader silently falls back to the in-box runtime and the tests fail again with no warning. Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
`cargo:rustc-link-arg` applies to every target of the package, so asking for
`/EXPORT:D3D12SDKVersion,DATA` broke the `guard_runs` bench with LNK2001: the
bench links this crate without `cfg(test)`, so it defines neither symbol the
export names. `cargo:rustc-link-arg-tests` is not an option either — the SM 6.6
checks are library unit tests, and cargo rejects that instruction outright for a
package with no `#[test]` target ("The package victory-shader does not have a
test target").
Put the directive in the module that defines the symbols instead. The linker
reads `.drectve` sections out of object files as extra command-line options, so
a `#[used] #[link_section = ".drectve"]` static carries both `/EXPORT` options in
the one object that has the statics. A binary that does not compile this module
is never asked to export anything, which also keeps the selectors out of a
binary that defines its own copy (`apps/victory`, Marvisak#463) — two definitions in one
binary collide at link time.
`build.rs` now only reports whether the runtime is staged, with
`cfg(agility_runtime)`, and the symbols and the directive sit behind it:
exporting them without the DLL next to the executable makes the loader refuse to
create a device (`0x887e0003`), so a build that has not staged the runtime has
to stay opted out rather than export and fail.
`rerun-if-changed` on the runtime moves below the `is_file` check, which was the
other review point: watching a path that does not exist reran this script on
every build.
Verified on Windows 10 19045 + RTX 3080, runtime staged:
- `cargo build -p victory-shader --benches` links clean, and the bench binary
exports nothing.
- `cargo test -p victory-shader valu_tests`: 28 passed, 0 failed, no
"no SM 6.6 hardware device" skip line.
- `cargo build -p victory`: links clean, no duplicate selector symbols.
- The test binary's export table lists `D3D12SDKVersion` and `D3D12SDKPath`.
Moving `target/<profile>/deps/D3D12/D3D12Core.dll` away afterwards makes
device creation fail with "the host exe's D3D12 SDK version configuration is
invalid", which is what shows the loader is reading those exports and not
silently falling back to the in-box runtime.
Co-authored-by: Claude (claude-opus-5-5) <noreply@anthropic.com>
|
Two small additions to the verifications above, from a third host (Windows 10 IoT Enterprise LTSC 2021 19044.7846, RTX 4090, Agility 1.614.1 as staged, #463 + #486 cherry-picked with the same single
The downstream value of merging this is a hardware picture nobody can publish without it: with the opt-in we completed a full |
|
Tested on Windows 10 with an RTX 4070 Ti: works. With this PR the title gets past the root-signature failure, into the world and through the opening cutscene to the Prologue, with no device removal. Setup: Windows 10 22H2 (19045), RTX 4070 Ti 12 GB, driver 621.14, i9-12900K, 32 GB. Build: this PR's Runtime:
Without the opt-in (same tree): every root signature is refused with With this PR:
Two things worth knowing:
Note: Nsight Aftermath's Global mode was off for these runs; with it on, the world load hangs here (see #71). No game files or captures attached. AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title on my machine, read the logs, and drafted this comment. |
|
With a runtime in Reproduced on Without a runtime, the exports aren't emitted and the tests build. That's probably why CI and the earlier test runs here didn't hit it. The change in - println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKVersion");
- println!("cargo:rustc-link-arg=/EXPORT:D3D12SDKPath");
+ println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKVersion");
+ println!("cargo:rustc-link-arg-bins=/EXPORT:D3D12SDKPath");With it, I'm testing with Claude's help, and Claude drafted this comment. |
Windows 10's inbox D3D12 runtime stops at shader model 6.5, while the shaders victory translates target 6.6 and bind through descriptor heaps. The title's root signatures (flags 0xc01) therefore fail to serialize, its renderer never finishes initializing, and it crashes during Game Init.
When target//D3D12/D3D12Core.dll exists, export the loader's D3D12SDKVersion (614) and D3D12SDKPath (.\D3D12) opt-in symbols so d3d12.dll loads that runtime instead of the system copy, and warn when the runtime is missing at run time. The build script enables the exports only when the file is present, so builds without it behave unchanged.
Verified on Windows 10 19045 with an i5-10400F and an RTX 2070 SUPER: the device reports shader model 6.6, the title's root signatures serialize, and its menus render and respond at 30 fps.