GPU: load an optional D3D12 Agility SDK #3033
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3033
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3033"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Auroraooy on GitHub · 2026-11-26 04:06 UTC · original
Auroraooy:feat/agility-sdk→main· +378 −22 · 9 files · 2 commits · openWindows 10's inbox
D3D12Core.dllstops at Shader Model 6.5, even on GPUs and drivers that support SM 6.6. This adds an optional app-local Agility SDK loader so a Windows 10 / Turing machine can provide SM 6.6 without changing the OS.Search order for
D3D12Core.dll:%VICTORY_D3D12_DIR%(explicit; a bad path is reported instead of silently ignored),<exe_dir>\D3D12,<exe_dir>,%LOCALAPPDATA%\Victory\D3D12.When a valid SDK is found,
ID3D12SDKConfiguration1::CreateDeviceFactorycreates the device factory andApplyToGlobalStatemakes free functions dispatch through the app-local runtime.Hostnow creates its device and debug/DRED interfaces through this loader; without an SDK it falls back to inboxD3D12CreateDevice/D3D12GetDebugInterface.Validation:
CARGO_BUILD_JOBS=18(2 cores left for the system).cargo build -p victory-gpu: clean.cargo test -p victory-gpu --lib agility::tests -- --test-threads=18: 3 passed, including a real SDK check that readsD3D12SDKVersionfrom Microsoft'sMicrosoft.Direct3D.D3D121.620.2D3D12Core.dll.This does not by itself make wave64 shader emulation or GFX10 translation work; it only fixes the D3D12 runtime/SM 6.6 detection gap.
AI use: AI-assisted (WorkBuddy) for drafting the patch and tests; build/test results are from real local runs.
@Marvisak on GitHub · 2026-11-26 04:15 UTC · original · edited 2026-11-26 07:20 UTC
Automated triage for the maintainers.
Needs work; needs the maintainer's decision. Thanks for rebasing; it now merges cleanly. The new head adds a
victory-agilitycrate (workspaceCargo.toml,Cargo.lock, and dependencies invictory-gpuandvictory-shader). It also changes how the host D3D12 runtime is chosen:D3D12Core.dllis now picked up fromVICTORY_D3D12_DIR,<exe_dir>,<exe_dir>\D3D12or%LOCALAPPDATA%\Victory\D3D12. That means VIctory loads and runs a native DLL from user-writable folders, so a maintainer has to decide whether to take this, not triage. It also affects every user, not only Windows 10 machines without SM 6.6, whenever such a folder exists.Before that review, CI must pass.
cargo clippy ... -D warningsfails incrates/victory-agility/src/lib.rsresolve_get_interface, as noted in the comments: usec"D3D12GetInterface"instead of theb"...\0"literal, and annotate thetransmutetypes. It would also help to explain why the inbox runtime's SM 6.5 cap needs fixing in VIctory itself rather than by updating Windows.CI: failing (
check, clippy).Generated by Claude Code
@Auroraooy on GitHub · 2026-11-26 04:16 UTC · original
Update: the loader is now a shared
victory-agilitycrate, used by bothvictory-gpuandvictory-shader's D3D12 test host. This meansVICTORY_D3D12_DIRalso applies to the shader/host SM 6.6 checks, not only the runtime device.Validation on RTX 2080 Ti (Turing, SM 6.5 hardware) with Microsoft
Microsoft.Direct3D.D3D121.620.2:The last line confirms
Host::new(false)now creates a hardware D3D12 device through the app-local Agility SDK on Windows 10; previously this machine reportedSM 0x65 only. No game files were used.@Auroraooy on GitHub · 2026-11-26 05:24 UTC · original
Rebased onto current
main(63bcca4) and squashed to one commit (7e2e129) after the automated triage marked this needs-rebase. The four touchpoints that conflicted (README,victory-gpu/src/host.rs,victory-shader's host, workspace Cargo.toml) were re-applied on top of the new code, including the shader-host changes from #244. Verified with 18 build threads on the machine from the report (RTX 2080 Ti, Windows 10):cargo check -p victory-gpu -p victory-shader --testsclean, andcargo test -p victory-agility --lib3 passed, including the real Microsoft Agility SDK 1.620.2D3D12Core.dllversion-parse test.AI use: WorkBuddy agent re-applied the patch and ran the checks; the account owner reviewed the result.
@fuzeofficlal on GitHub · 2026-11-26 06:19 UTC · original
Checked the CI failure on
7e2e1294—cargo clippy --workspace --all-targets --locked -- -D warningsfailed on two lints incrates/victory-agility/src/lib.rs:clippy::manual_c_str_literals):b"D3D12GetInterface\0".as_ptr()→c"D3D12GetInterface".as_ptr().cast()clippy::missing_transmute_annotations): replace_with the explicit sourceFARPROCfn type (unsafe extern "system" fn() -> isize).Happy to re-review once CI is green.
@fuzeofficlal on GitHub · 2026-11-26 04:15 UTC · original · requested changes
Several issues to address on
2b9e580b:Merge conflict & Clippy failure in
crates/victory-gpu/src/host.rs:origin/mainathost.rs:198(wheremainqueriesD3D12_FEATURE_D3D12_OPTIONS2fordepth_bounds_supported); please rebase and preserve that query on the created device.if dred_on() { if let Ok(dred) = ... }(host.rs:176-182) will tripclippy::collapsible_ifunder CI's-D warnings(collapse withif dred_on() && let Ok(dred) = ...).No inbox fallback once
State::Loadedis cached (crates/victory-gpu/src/agility.rs:244-252,host.rs:187-196):CreateDeviceFactorysucceeds,agility::create_devicepropagatesfactory.CreateDevice(...)?with no fallback to inboxD3D12CreateDevice. If the selectedD3D12Core.dllfails to create a device on the host driver or WARP adapter,host()cachesNonefor the lifetime of the process and disables GPU execution even when inbox D3D12 would succeed.Process-wide state mutation & ANSI/UTF-8 path mismatch (
agility.rs:141-150,agility.rs:191-193):factory.ApplyToGlobalState()mutates process-wide D3D12 state (affecting independentD3D12CreateDevicecallers likevictory-shader/src/emit/host.rs:110and preventing clean fallback to inboxD3D12CreateDevice). Keeping device creation scoped to the factory avoids leaking optional SDK state globally.format_sdk_pathpasses UTF-8 bytes toCreateDeviceFactory'sPCSTR(which interprets the string in the process ANSI code page unless a UTF-8 ACP manifest is active), whereasprobe_diropensD3D12Core.dllvia wide Win32 paths. Non-ASCII directories (e.g.C:\Users\José\D3D12) can passprobe_dirand fail to resolve inCreateDeviceFactory.PE export bounds & implicit candidate fallback (
agility.rs:70-96,agility.rs:112-137,agility.rs:165):rva_to_offsetfalls back toSome(rva as usize)when an RVA lies outside every section (treating an unmapped RVA as a file offset) and does not checkdelta + 4 <= section.file_size, allowing a 4-byte read across a section boundary.<exe_dir>\D3D12,<exe_dir>,%LOCALAPPDATA%\Victory\D3D12),resolve_dirstops at the first candidate with a parseableD3D12SDKVersionexport — if that candidate failsCreateDeviceFactory, remaining implicit candidates are skipped.resolve_get_interface, ifGetProcAddressfails afterLoadLibraryExW, releasing the loaded module handle withFreeLibraryavoids leaking the extrad3d12.dllreference.@fuzeofficlal on GitHub · 2026-11-26 04:40 UTC · original · requested changes
Extracting
crates/victory-agilityand cleaning up thedred_on()if letinhost.rsare nice improvements, but several items from the previous review still remain on6170e8ee:crates/victory-gpu/src/host.rs): The branch is still behindorigin/main(842b0cb7/63bcca43) and currently reportsmergeable: dirtyaroundcreate()/depth_bounds_supported. Please rebase ontomain.factory.CreateDevicefails (crates/victory-agility/src/lib.rs:247):create_devicestill returnsfactory.CreateDevice(...)?directly without falling back toD3D12CreateDevice, so an incompatible Agility runtime or unsupported adapter path will fail device creation instead of falling back to inbox D3D12 as documented.ApplyToGlobalState()(crates/victory-agility/src/lib.rs:197): CallingApplyToGlobalState()mutates process-wide D3D12 state globally for all subsequent callers (including tests andvictory-shaderWARP/host tests).crates/victory-agility/src/lib.rs:146-155):format_sdk_pathencodes Rust UTF-8 into aCStringand passes it asPCSTRtoCreateDeviceFactory, which interprets it using the system ANSI code page rather than UTF-8 on non-UTF-8 Windows locales.crates/victory-agility/src/lib.rs:72-104,129-137):rva_to_offsetstill returnsSome(rva as usize)when no section containsrva(line 84), and line 77 only checksdelta >= section.file_sizewithout checking that all 4 bytes (delta..delta + 4) lie withinsection.file_size.resolve_dirreturns on the first parseableD3D12Core.dll(line 130); ifcreate_factorythen fails for that candidate, implicit fallback does not try remaining candidate directories.@kotekompotek on GitHub · 2026-11-26 04:42 UTC · original · approved these changes
LGTM — correct SDK mechanics: D3D12SDKVersion export validated via PE parse before activation, ApplyToGlobalState+ALLOW_RETURNING_EXISTING covers late direct D3D12CreateDevice callers, and configuration_interface goes through the factory so debug interfaces match the device's runtime. Explicit-dir failures reported not skipped; clean inbox fallback everywhere.
@Auroraooy on GitHub · 2026-11-26 11:51 UTC · original
Thanks @fuzeofficlal for the precise report — both lints fixed in
18db812(c-string literal + explicitFARPROCtransmute annotation). Verified locally:cargo clippy -p victory-agility --all-targets --locked -- -D warningsclean,cargo test -p victory-agility --lib3 passed. CI should re-run on the new head.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.