gpu: load optional D3D12 Agility SDK at runtime for SM 6.6+ on Windows 10 #75

Manually merged
github merged 2 commits from gh-pr/75/head into gh-pr/75/base 2026-11-26 04:08:10 +00:00
Owner

@⁠certified-retart on GitHub · 2026-11-23 01:14 UTC · original
certified-retart:feat/d3d12-agility-sdk → main · +751 −50 · 10 files · 2 commits · merged 2026-11-23 10:29 UTC

Summary

Adds optional run-time DirectX 12 Agility SDK loading (ID3D12SDKConfiguration1::CreateDeviceFactory) so Windows 10 22H2 (build 19045.3393+, KB5029331) machines can run Shader Model 6.6+ GPU tests and titles without Developer Mode or static D3D12SDKVersion / D3D12SDKPath exports.

Windows 10's inbox System32\D3D12Core.dll stops at SM 6.5 even on modern GPUs and drivers (such as RTX 5070 and RDNA 2/3 iGPUs), causing every SM 6.6+ GPU test in xcl to skip on Windows 10.

What changed

  • New gpu::agility loader (+ 6 unit tests in agility_tests.rs):
    • Searches %XCL_D3D12_DIR% (exclusive when set), <exe_dir>\D3D12, <exe_dir>, and %LOCALAPPDATA%\XCL\D3D12 for D3D12Core.dll.
    • Reads D3D12SDKVersion directly from D3D12Core.dll's PE exports on disk without loading or executing the DLL (rejecting non-DLLs, forwarders, zero versions, and malformed export/section bounds).
    • Encodes the SDK directory path using the process's active code page (GetACP()), respecting the WideCharToMultiByte contract for both CP_UTF8 (65001) / GB18030 (54936) and legacy ANSI code pages.
    • Initializes an ID3D12DeviceFactory once via ID3D12SDKConfiguration1::CreateDeviceFactory, sets ALLOW_RETURNING_EXISTING_DEVICE, and applies it to global state once before any XCL device exists (so global D3D12SerializeVersionedRootSignature accepts SM 6.6 directly-indexed heap flags). Falls back transparently to inbox D3D12CreateDevice when no Agility SDK is present or the OS lacks ID3D12SDKConfiguration1.
    • Routes configuration_interface (ID3D12Debug, DRED) through factory.GetConfigurationInterface when loaded (without falling back to inbox global D3D12GetDebugInterface).
  • Wired all XCL device creation sites (gpu::recomp::runner, hle::d3d12x::real, and test helpers in gpu::texture / hle::mfplat) through gpu::agility::create_device.
  • Command list vtable transition preservation (hle::d3d12x::real & list_x):
    • Agility SDK 1.620+ swaps a command list's native vtable pointer during Close and Reset. Without re-adopting the new state vtable, e2e failed on KickoffX / CopyBufferRegion (0xc0000005).
    • Added real::preserve_vtable (re-adopting the runtime's new native table under the same Kind via the CLASSES cache so subsequent calls dispatch through the current native state table) across cl_close, cl_reset, kickoff_x, reset_x, and dma_close_x.
  • PE bounds hardening (pe.rs):
    • Added checked RVA arithmetic and directory size validation in Pe::exports and Exports::is_forwarder_rva, clamped data directories to SizeOfOptionalHeader, and bounded Layout::File RVA reads (bytes_at, u16_at, u32_at, u64_at, cstr_at) to their containing section/header raw slice.
  • Docs (README.md): Documented XCL_D3D12_DIR and the default Agility SDK search paths for Windows 10.

Verification

Tested on Windows 10 Pro (10.0.19045.5794, inbox D3D12Core.dll = SM 6.5 max) with Microsoft DirectX 12 Agility SDK 1.620.2 (D3D12SDKVersion = 620):

  • Before: All SM 6.6+ GPU tests skipped (no SM 6.6); e2e crashed on Agility SDK 1.620.2 before preserve_vtable.
  • After (XCL_D3D12_DIR=<agility>, XCL_ADAPTER=1 AMD Radeon iGPU, XCL_REQUIRE_GPU=wave64,mesh):
    • cargo test --workspace -- --test-threads=2: 378 passed, 0 failed, 34 ignored, 0 GPU skips (xcl --lib: 349 passed, e2e: 2 passed, console_dlls_e2e: 12 passed, gpu_pso_e2e: 6 passed, console_shaders: 3 passed, xg_oracle: 3 passed, rpf_e2e: 2 passed, disasm_e2e: 1 passed).
  • After (XCL_D3D12_DIR=<agility>, XCL_ADAPTER=0 NVIDIA GeForce RTX 5070):
    • cargo test -p xcl --test e2e: 2 passed, 0 failed.
  • After (inbox Windows 10 fallback, XCL_D3D12_DIR unset):
    • cargo test -p xcl --test e2e: 2 passed, 0 failed.
    • cargo test -p xcl --lib agility (6 passed) and pe:: (3 passed).
**@⁠certified-retart** on GitHub · 2026-11-23 01:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/75) `certified-retart:feat/d3d12-agility-sdk` → `main` · +751 −50 · 10 files · 2 commits · merged 2026-11-23 10:29 UTC ## Summary Adds optional run-time DirectX 12 Agility SDK loading (`ID3D12SDKConfiguration1::CreateDeviceFactory`) so Windows 10 22H2 (build 19045.3393+, KB5029331) machines can run Shader Model 6.6+ GPU tests and titles without Developer Mode or static `D3D12SDKVersion` / `D3D12SDKPath` exports. Windows 10's inbox `System32\D3D12Core.dll` stops at SM 6.5 even on modern GPUs and drivers (such as RTX 5070 and RDNA 2/3 iGPUs), causing every SM 6.6+ GPU test in `xcl` to skip on Windows 10. ### What changed - **New [`gpu::agility`](crates/xcl/src/gpu/agility.rs) loader (+ 6 unit tests in [`agility_tests.rs`](crates/xcl/src/gpu/agility_tests.rs)):** - Searches `%XCL_D3D12_DIR%` (exclusive when set), `<exe_dir>\D3D12`, `<exe_dir>`, and `%LOCALAPPDATA%\XCL\D3D12` for `D3D12Core.dll`. - Reads `D3D12SDKVersion` directly from `D3D12Core.dll`'s PE exports on disk without loading or executing the DLL (rejecting non-DLLs, forwarders, zero versions, and malformed export/section bounds). - Encodes the SDK directory path using the process's active code page (`GetACP()`), respecting the `WideCharToMultiByte` contract for both `CP_UTF8` (65001) / GB18030 (54936) and legacy ANSI code pages. - Initializes an `ID3D12DeviceFactory` once via `ID3D12SDKConfiguration1::CreateDeviceFactory`, sets `ALLOW_RETURNING_EXISTING_DEVICE`, and applies it to global state once before any XCL device exists (so global `D3D12SerializeVersionedRootSignature` accepts SM 6.6 directly-indexed heap flags). Falls back transparently to inbox `D3D12CreateDevice` when no Agility SDK is present or the OS lacks `ID3D12SDKConfiguration1`. - Routes `configuration_interface` (`ID3D12Debug`, DRED) through `factory.GetConfigurationInterface` when loaded (without falling back to inbox global `D3D12GetDebugInterface`). - **Wired all XCL device creation sites** (`gpu::recomp::runner`, `hle::d3d12x::real`, and test helpers in `gpu::texture` / `hle::mfplat`) through `gpu::agility::create_device`. - **Command list vtable transition preservation (`hle::d3d12x::real` & `list_x`):** - Agility SDK 1.620+ swaps a command list's native vtable pointer during `Close` and `Reset`. Without re-adopting the new state vtable, `e2e` failed on `KickoffX` / `CopyBufferRegion` (`0xc0000005`). - Added `real::preserve_vtable` (re-adopting the runtime's new native table under the same `Kind` via the `CLASSES` cache so subsequent calls dispatch through the current native state table) across `cl_close`, `cl_reset`, `kickoff_x`, `reset_x`, and `dma_close_x`. - **PE bounds hardening (`pe.rs`):** - Added checked RVA arithmetic and directory size validation in `Pe::exports` and `Exports::is_forwarder_rva`, clamped data directories to `SizeOfOptionalHeader`, and bounded `Layout::File` RVA reads (`bytes_at`, `u16_at`, `u32_at`, `u64_at`, `cstr_at`) to their containing section/header raw slice. - **Docs (`README.md`):** Documented `XCL_D3D12_DIR` and the default Agility SDK search paths for Windows 10. ## Verification Tested on Windows 10 Pro (`10.0.19045.5794`, inbox `D3D12Core.dll` = SM 6.5 max) with Microsoft DirectX 12 Agility SDK `1.620.2` (`D3D12SDKVersion = 620`): - **Before:** All SM 6.6+ GPU tests skipped (`no SM 6.6`); `e2e` crashed on Agility SDK `1.620.2` before `preserve_vtable`. - **After (`XCL_D3D12_DIR=<agility>`, `XCL_ADAPTER=1` AMD Radeon iGPU, `XCL_REQUIRE_GPU=wave64,mesh`):** - `cargo test --workspace -- --test-threads=2`: **378 passed, 0 failed, 34 ignored, 0 GPU skips** (`xcl --lib`: 349 passed, `e2e`: 2 passed, `console_dlls_e2e`: 12 passed, `gpu_pso_e2e`: 6 passed, `console_shaders`: 3 passed, `xg_oracle`: 3 passed, `rpf_e2e`: 2 passed, `disasm_e2e`: 1 passed). - **After (`XCL_D3D12_DIR=<agility>`, `XCL_ADAPTER=0` NVIDIA GeForce RTX 5070):** - `cargo test -p xcl --test e2e`: **2 passed, 0 failed**. - **After (inbox Windows 10 fallback, `XCL_D3D12_DIR` unset):** - `cargo test -p xcl --test e2e`: **2 passed, 0 failed**. - `cargo test -p xcl --lib agility` (6 passed) and `pe::` (3 passed).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:08 +00:00
github manually merged commit 4ee1b6ed60 into gh-pr/75/base 2026-11-26 04:08:10 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 10:29 UTC · original

Merged. On Windows 11 without an Agility SDK in any of the search paths (so the inbox fallback, plus preserve_vtable and the new PC-list Reset override) everything above still holds – XDefiant's copy-list resets included. I have no Windows 10 box to check the Agility path itself; your numbers in the description cover that. Tested on Windows 11 with an RX 9070 (RDNA4): cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), also with XCL_SPLIT_WAVE64=1 (the 32-lane split path forced on RDNA). Unicorn Overlord and XDefiant run with this round merged. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 10:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/75#issuecomment-7098054329) Merged. On Windows 11 without an Agility SDK in any of the search paths (so the inbox fallback, plus `preserve_vtable` and the new PC-list `Reset` override) everything above still holds – XDefiant's copy-list resets included. I have no Windows 10 box to check the Agility path itself; your numbers in the description cover that. Tested on Windows 11 with an RX 9070 (RDNA4): `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), also with `XCL_SPLIT_WAVE64=1` (the 32-lane split path forced on RDNA). Unicorn Overlord and XDefiant run with this round merged. Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.