Skip to content

Windows 10: load the D3D12 Agility SDK runtime (0 of 27,044 pipelines without it) - #856

Open
gabrielfriasw wants to merge 1 commit into
fxceless:mainfrom
gabrielfriasw:win10-agility
Open

gabrielfriasw wants to merge 1 commit into
fxceless:mainfrom
gabrielfriasw:win10-agility

Conversation

@gabrielfriasw

Copy link
Copy Markdown

Why

On Windows 10, the in-box d3d12.dll stops at shader model 6.5 and refuses every translated pipeline's root signature:

Unsupported bit-flag set (root signature flags c00)

0xc00 = CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED (0x400) | SAMPLER_HEAP_DIRECTLY_INDEXED (0x800): the bindless flags every translated pipeline uses. The failure is at D3D12SerializeVersionedRootSignature, so nothing is drawn.

Measured on this machine (Windows 10 22H2 19045, Ryzen 9 5900XT, RTX 3070, driver 32.0.16.2140) with victory translate --pipelines over the title's shader pack:

pipelines made refused by the host
without the Agility runtime 0 27,044
with it 23,034 (+3,607 from the library) 403

The fork's test machine is Windows 11, where the in-box runtime already does this, so the fork never needed it. Windows 10 users get nothing at all.

What

  • apps/victory/build.rs exports D3D12SDKVersion and D3D12SDKPath as data symbols (MSVC only).
  • apps/victory/src/agility.rs defines D3D12SDKVersion = 620 and D3D12SDKPath = ".\D3D12\".
  • main.rs keeps both symbols alive.

D3D12 reads these two symbols from the process executable and, when they name a runtime newer than the system's, loads D3D12Core.dll from D3D12SDKPath relative to the executable.

Getting D3D12Core.dll

The DLLs are Microsoft's, so they must not enter the repository (upstream's asset policy, and this fork inherits it). They are the Microsoft.Direct3D.D3D12 1.620.2 NuGet package — the minor version is the number exported above:

https://api.nuget.org/v3-flatcontainer/microsoft.direct3d.d3d12/1.620.2/microsoft.direct3d.d3d12.1.620.2.nupkg
SHA-512 d683ff7f5726906c3f43d299f6cdd4b1cad22f8329ccd27b3492d0a1413d9904102b8d543419bec3b3545c86bf49f6a500ebf42d95c999aa0969e5d693032735

build/native/bin/x64/D3D12Core.dll and d3d12SDKLayers.dll go to target\<profile>\D3D12\. A cargo xtask subcommand could do the fetch; I left it out of this PR to keep the diff to the load path — say if you'd rather have it included.

Tested

Windows 10 22H2, RTX 3070, real title, this branch on top of f85101b:

  • 0 root-signature refusals, 0 device removals, 30 fps in the menus.
  • Reaches the profile art screen and then the loading screen (2 fps, 222 draws a frame, audio playing).
  • The same binary without D3D12\ reproduces the flags-c00 failure, so the effect is the runtime and not something else in the branch.

I have not tested Windows 11: the folder is absent there and the in-box runtime is used, which is the previous behaviour.

Notes

  • This changes victory.exe only; no other crate is touched.
  • Building exports data symbols, so the MSVC linker also writes victory.lib/victory.exp next to the exe; harmless, and cargo reports it as a linker_messages warning.
  • An upstream VIctory issue with the same root cause, if useful as a reference: the same measurement there is 0 to 26,641 pipelines.

AI-assisted: written with an agent that ran everything above on the machine described.

Windows 10's in-box d3d12.dll stops at shader model 6.5 and refuses root
signatures that index the descriptor heaps directly (flags 0x400, 0x800),
which every translated pipeline uses:

    Unsupported bit-flag set (root signature flags c00)

Measured here (Windows 10 22H2 19045, RTX 3070): without the runtime
`translate --pipelines` makes 0 of 28,164 pipelines and refuses 27,044; with
it, 23,034 are made and 3,607 come from the library.

victory.exe now exports D3D12SDKVersion = 620 and D3D12SDKPath = ".\D3D12\",
and D3D12 loads D3D12Core.dll from that folder beside the executable when it
is newer than the system's runtime. The DLLs are Microsoft's and never enter
the repository: they are the Microsoft.Direct3D.D3D12 1.620.2 NuGet package
(SHA-512 d683ff7f...693032735), unpacked into target/<profile>/D3D12/.

Windows 11 keeps its in-box runtime, and a missing folder changes nothing.
@HAL9000RELOADED

Copy link
Copy Markdown

Tried on Windows 10 22H2 / RX 7900 XTX, merged on main d510ee4, debug build of victory. As a probe I used victory translate --pipelines <empty folder>, which creates the D3D12 device and checks SM 6.6 (Host::new):

  • main, with or without D3D12Core.dll beside the exe: the device supports SM 0x65 only, as expected without the exports.
  • this PR, D3D12Core.dll 1.620.2 in target\debug\D3D12\: the device is created, exit 0. dumpbin shows both exports.
  • this PR, no D3D12\ folder: D3D12CreateDevice fails, "La configurazione della versione di D3D12 SDK dell'eseguibile host non è valida" (Italian locale: the host exe's D3D12 SDK version configuration is invalid, the 0x887E0003 / D3D12_ERROR_INVALID_REDIST I hit on Windows 10: the D3D12 Agility SDK runtime for shader model 6.6 (upstream #362) #69). So on Windows 10 a missing folder doesn't keep the in-box runtime, as agility.rs says. It fails earlier, with a less clear message than main's. I didn't test Windows 11.

This overlaps #402, which makes the same exports only when the runtime is present and adds cargo xtask agility to fetch it. Also, the new files still carry LOCAL-ONLY (… never pushed) comments.

@LeonardoS11

Copy link
Copy Markdown

Two results for this, one for and one to watch out for.

Windows 10 — it is what makes the title run. A second machine, RTX 5070 Ti 16 GB, Ryzen 7 7700X, Windows 10 Pro 19045, NVIDIA 32.0.16.2140. Without this PR: 6 launches of 6 ended 4 to 7 seconds in with 0xc0000005 at +0xb5a5f8, after "root signature: Unsupported bit-flag set (root signature flags c01)" and "host root signature refused … 0x80070057" for the pipelines. With this PR merged (on 9c184b3 with other open PRs) and the two DLLs of Microsoft.Direct3D.D3D12 1.620.2 in D3D12\: no refusal of that kind, the boot and loading screens show, the world is black while the pipelines are still being made on the first launch and complete after it, and the first room in the Series S profile runs at about 113 ms a frame — the same as an RTX 3080 Ti on Windows 11 with the same build.

Windows 11 — the same executable needs the folder too. The description says that without D3D12\ the in-box runtime is used. On Windows 11 build 26200 here (in-box D3D12Core 10.0.26100) that is not what happens: 7 launches of 7 of an executable with these exports and no D3D12\ beside it ended at start-up with

unhandled exception 0xe06d7363 at KERNELBASE.dll+0xc569a (C++ .J = 0x887e0003 thrown)

0x887E0003 is D3D12_ERROR_INVALID_REDIST: the exports ask for SDK version 620, the in-box runtime is older, and with no redistributable to load the device is not made. With the folder copied beside the executable the same build starts. So once this is in, a build without the DLLs would stop working on Windows 11 machines whose in-box runtime is older than 620 — worth either a line in the README, a start-up message naming the missing folder, or making the version a build option.

(Runs on two machines of ours; read from the logs and written with Claude Code.)

@LeonardoS11

Copy link
Copy Markdown

Following up on the Windows 11 failure above with something that fixes it, in case you want it in this PR: commit 41b0841 in LeonardoS11/victory-fork (branch port/v11-sections; 78 lines in apps/victory/build.rs, agility.rs and main.rs, on top of this PR).

With it the same executable runs with and without the folder. Checked on Windows 11 build 26200, RTX 3080 Ti, by the module list of the process:

  • no D3D12\ beside the executable: C:\WINDOWS\SYSTEM32\D3D12Core.dll is loaded, the device is made, the title goes on;
  • with it: …\D3D12\D3D12Core.dll (1.620.2) is loaded.

The launcher says on stderr which one it used. Two things were needed:

  1. The exported D3D12SDKVersion is a mutable static, and main sets it before anything touches D3D12. Setting it to 0 does not work — D3D12 answers with the same 0x887E0003. What works is the in-box runtime's own version: it is read from the export table of System32\D3D12Core.dll as a file, without loading it (616 here), and written to our export when there is no .\D3D12\D3D12Core.dll.
  2. d3d12.dll has to be delay-loaded (/DELAYLOAD:d3d12.dll plus delayimp.lib). As a static import it is loaded with the executable and reads the exports before main runs.

Not covered: a system with no System32\D3D12Core.dll at all keeps 620, so there the folder stays required, as now. Tested with launches of 12 to 15 seconds each way, not a full session.

(Written and tested with Claude Code on the machine above.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants