Skip to content

GPU: load the Agility SDK through ID3D12SDKConfiguration1 (#749) - #969

Open
mgunes1311-lab wants to merge 14 commits into
Marvisak:mainfrom
mgunes1311-lab:agility-device-factory
Open

mgunes1311-lab wants to merge 14 commits into
Marvisak:mainfrom
mgunes1311-lab:agility-device-factory

Conversation

@mgunes1311-lab

@mgunes1311-lab mgunes1311-lab commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Loads the DirectX 12 Agility SDK (D3D12Core.dll) at runtime via ID3D12SDKConfiguration1::CreateDeviceFactory without exporting D3D12SDKVersion or D3D12SDKPath from victory.exe.

Summary of Changes

  • crates/victory-shader/src/emit/agility.rs & mod.rs:
    • Resolves D3D12Core.dll from VICTORY_D3D12_AGILITY (if set) or D3D12\D3D12Core.dll beside the executable, supporting a DLL path, directory, or unpacked NuGet package (build\native\bin\x64\D3D12Core.dll).
    • Parses D3D12SDKVersion from D3D12Core.dll's PE export table (sdk_version) without loading or executing the DLL.
    • Queries ID3D12SDKConfiguration1 and creates a process-wide ID3D12DeviceFactory (Factory::load), configuring D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_EXISTING_DEVICE, ApplyToGlobalState, CLSID_D3D12Debug, and CLSID_D3D12DeviceRemovedExtendedData.
    • Adds serialize_versioned_root_signature, routing serialization through ID3D12DeviceConfiguration::SerializeVersionedRootSignature when supported by the device so 0xc01 heap-indexing root signatures work on Windows 10 without touching an older in-box d3d12.dll serializer.
    • The main GPU host falls back to system d3d12.dll when no Agility SDK is configured or loading fails. The shader test/host path uses the system runtime when no SDK is configured, but propagates an SDK loading error instead of falling back.
    • Adds unit tests for PE export parsing, core discovery, relative path formatting, and a live VICTORY_D3D12_AGILITY device + 0xc01 root-signature test.
  • crates/victory-shader/src/emit/host.rs: Uses agility::Factory::load() and agility::serialize_versioned_root_signature.
  • crates/victory-gpu/Cargo.toml, src/host.rs, src/pipeline/host.rs: Enables the host feature on victory-shader for Windows and wires Factory (including apply_global, debug layer, DRED, WARP/hardware device creation) and serialize_versioned_root_signature into the host GPU.
  • README.md: Documents Windows 10 (22H2 with KB5029331 or newer) Agility SDK setup (D3D12\D3D12Core.dll or VICTORY_D3D12_AGILITY=<dir>).

Verification

  • Verified with cargo test, Clippy, xtask asset policy checks, and live GPU tests against Agility SDK v620.

Closes #749

@EduBertozzi

Copy link
Copy Markdown
Contributor

Tested f3457f8 (on current main) on Windows 10 22H2 19045.6456 with a GTX 1060 6 GB (Pascal, driver 32.0.15.8266). The in-box runtime there stops at SM 6.5. I used the 1.620.2 D3D12Core.dll.

VICTORY_D3D12_AGILITY unset set to the folder holding D3D12Core.dll
cargo test -p victory-shader --lib GPU tests fail: neither hardware nor WARP SM 6.6 device available 123 passed, 0 failed, 1 ignored, including creates_device_and_serializes_heap_indexed_root_signature_when_configured
cargo test -p victory-gpu --lib n/a 50 passed, 0 failed, 1 ignored

So on this Windows 10 build, CreateDeviceFactory loads the newer core and the 0xc01 root signatures serialize, without D3D12SDKVersion / D3D12SDKPath exports.

One consequence worth noting next to #175, #463, #362 and #486: because no exe exports are needed, test binaries get SM 6.6 from the environment variable alone. On this machine that made the Windows 10 test-binary work (#486, #362) unnecessary for these two crates.

AI-assisted (Claude Code).

@Zipettte

Copy link
Copy Markdown

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at f3457f8: cargo test -p victory-gpu -p victory-shader passes, 173 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

@mauri9911

Copy link
Copy Markdown

Tested this branch (f3457f8) on a configuration that is not in the PR description:

  • Windows 10 IoT Enterprise LTSC 21H2, build 19044, without KB5029331 (Get-HotFix shows it is not installed), so below the 22H2 + KB5029331 the README asks for
  • NVIDIA GeForce RTX 5060 Ti (driver 32.0.16.2101, WDDM 2.7)
  • Agility SDK 1.619.6, VICTORY_D3D12_AGILITY pointing at the folder with D3D12Core.dll

Results:

  • cargo test -p victory-shader --release: 123 passed, 1 ignored. On main the GPU ones (valu_tests, waterfall_tests) fail here with "neither hardware nor WARP SM 6.6 device available".
  • cargo test -p victory-gpu --release: 50 passed, 1 ignored.
  • Running the title (run ... --execute, 45 s): log shows Agility SDK ready version=619, no root signature flags c01 warnings, and frames presented with draws=5319 drawn=5319 (on main it was drawn=0).

So the CreateDeviceFactory route works on 19044 too. In my own attempt (#1518, exports only) the runtime-only ID3D12SDKConfiguration::SetSDKVersion returned DXGI_ERROR_INVALID_CALL for every path and version I tried, and the exe-exports route needs the exe to carry them and leaves the unit tests without SM 6.6.

I'll close #1518 as a duplicate of this one if the maintainer prefers this approach.

AI-assisted (Claude Code).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main (conflict in crates/victory-shader/src/emit/host.rs). It will be reviewed again once it is rebased.

From the earlier needs-work note: the code read as sound, but it needs the maintainer's decision, since it loads and runs a user-chosen D3D12Core.dll from outside the repo (one of several approaches to #749).


Generated by Claude Code

@AsterionXeity

Copy link
Copy Markdown

Can confirm this works on my 4080S on windows 10

@HAL9000RELOADED

Copy link
Copy Markdown

Windows 10 + AMD data point for bb176b6: RX 7900 XTX (RDNA3), driver 32.0.32015.7029, Windows 10 22H2 (19045.6456), Agility SDK 1.620.2 from NuGet, VICTORY_D3D12_AGILITY pointing at its folder. Merged on main 13f91ca.

  • victory-shader: 273 passed, 0 failed. The new creates_device_and_serializes_heap_indexed_root_signature_when_configured passes, so CreateDeviceFactory works on this Windows 10 build with a Radeon.
  • victory-gpu: 195 passed, 0 failed.
  • Same build without the variable: the in-box runtime stops at SM 6.5 and 80 victory-shader tests fail, as on main. So the opt-in leaves the default path unchanged.

No Developer Mode, no exports on the test executables.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows 10 + KB5029331: in-box d3d12 still refuses 1.1 heap-indexing flags; explicit Agility core load works (XCL proves it on this box)

7 participants