Skip to content

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

Merged
ivall merged 2 commits into
xcl-dev:mainfrom
certified-retart:feat/d3d12-agility-sdk
Nov 23, 2026
Merged

ivall merged 2 commits into
xcl-dev:mainfrom
certified-retart:feat/d3d12-agility-sdk

Conversation

@certified-retart

Copy link
Copy Markdown
Contributor

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).

@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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!

Lum7nt added a commit to Lum7nt/xcl that referenced this pull request Nov 23, 2026
… and add console stubs

Scarlett GDK uses subobject type 23 for Amplification Shaders (AS) and 24 for Mesh Shaders (MS), whereas PC Direct3D 12 uses slot 24 for AS and 25 for MS. Console streams passing an MS container in slot 24 previously failed pipeline stream translation as an unsupported AS, returning E_INVALIDARG.

- Disambiguate slot 24 in real.rs and null.rs by checking shader container stage and NGG hardware stage.
- Direct console slot 24 MS containers to mesh shader translation and fallback.
- In fallback_stream, rewrite console slot 24 to PC slot 25 with dummy mesh bytecode so PC drivers accept the SM 6.5 stream.
- Add unit tests for subobject payload and fallback stream rewriting.
- Add console stubs for command list xcl-dev#75, xcl-dev#126, #131, xcl-dev#132, xcl-dev#142, allocator xcl-dev#9, and queue xcl-dev#31 extension.
heretic1321 pushed a commit to heretic1321/xcl that referenced this pull request Nov 23, 2026
… and add console stubs

Scarlett GDK uses subobject type 23 for Amplification Shaders (AS) and 24 for Mesh Shaders (MS), whereas PC Direct3D 12 uses slot 24 for AS and 25 for MS. Console streams passing an MS container in slot 24 previously failed pipeline stream translation as an unsupported AS, returning E_INVALIDARG.

- Disambiguate slot 24 in real.rs and null.rs by checking shader container stage and NGG hardware stage.
- Direct console slot 24 MS containers to mesh shader translation and fallback.
- In fallback_stream, rewrite console slot 24 to PC slot 25 with dummy mesh bytecode so PC drivers accept the SM 6.5 stream.
- Add unit tests for subobject payload and fallback stream rewriting.
- Add console stubs for command list xcl-dev#75, xcl-dev#126, #131, xcl-dev#132, xcl-dev#142, allocator xcl-dev#9, and queue xcl-dev#31 extension.
AdrianGM2001 pushed a commit to AdrianGM2001/xcl that referenced this pull request Nov 24, 2026
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.

2 participants