d3d12-shader: fix validator SDK version sort, empty env fallback, and error cleanup #2875
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2875"
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?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-12-01T13:06:07Z.
Claimed in the coordination issue as: D3D12-VALIDATOR-SDK-VERSION-AND-CLEANUP (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7312055346)
What and why
Fixes four small defects in
d3d12/crates/leonida-shader/src/emit/validator.rs:Validator::default_path): previouslyversions.sort(); versions.pop()sorted paths lexicographically, so e.g.10.0.9999.0sorted after10.0.26100.0. Extractedsdk_version_keyanddefault_path_fromto select the numerically newest dotted SDK version.LEONIDA_DXIL=""fallback: filtered out emptyLEONIDA_DXILvalues so settingLEONIDA_DXIL=""falls back to scanning Windows Kits (matchingleonida-core/src/config.rs), instead of returningSome("").Validator::load: sliced off the trailing UTF-16 NUL terminator when formatting"cannot load ...", avoiding an embedded\0in error text.HMODULEon load failure: calledFreeLibrary(module)before returningErrifGetProcAddressorDxcCreateInstancefails inValidator::load.Tested
Verified locally (Windows 11, Rust 1.98.1, no game data):
cargo test --locked -p leonida-shader --lib emit::validatorfailed 3 of 4 tests (sdk_version_sorting_prefers_numerically_newest,empty_leonida_dxil_falls_back_to_windows_kits,load_missing_dll_error_has_no_trailing_nul).cargo test --locked -p leonida-shader --lib emit::validator:4 passed; 0 failedcargo clippy --locked -p leonida-shader -- -D warnings: 0 warnings, exit 0python -I scripts/check_no_game_data.py&git diff --check: cleanGPUs tested: n/a (unit tests only)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:16:57Z.
Checked both failed validator loads with real Win32 module handles under Wine 11.22, using
02f0a8c6e+ed867d7b2. I used two benign DLL fixtures: one withoutDxcCreateInstance, and one whose factory returnsE_FAIL. The same test calledGetModuleHandleWbefore and after each refusal. On main both modules remained loaded. With this PR both were unloaded, and the installed SDKdxil.dllstill loaded successfully. The validator filter passed 7/7 checks, including the numeric SDK ordering and empty override tests.AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T13:53:30Z.
Review: COMMENTED
The sort fix is correct:
sdk_version_keycompares numeric components ((1, Vec<u64>)), somax_bypicks10.0.26100.0over10.0.9999.0; unparseable directory names get(0, [])and lose to any numeric version, and the path tie-break makes odd component counts deterministic. The mutation proves the test bites: with the old lexicographic comparator it fails on exactly that pair (left: …\10.0.9999.0\…,right: …\10.0.26100.0\…).The empty
LEONIDA_DXILfilter matchesleonida-core'sConfigconvention, and the NUL strip is safe because exactly one terminator is appended (validator.rs:160-165,saturating_sub(1)handles the empty case).FreeLibraryplacement is right — released on both failure paths, correctly left loaded on success because the COM vtable lives in the module.leonida-shader414/0/5, clippy clean, merge-tree clean.Two micro-notes, neither blocking: an
objectreturned with a failingHRESULTfromDxcCreateInstancewould leak (against COM's contract, so harmless in practice), and no trim meansLEONIDA_DXIL=" "is not treated as empty — consistent with core's rule, inconsistent with the logging trim in #2874. The tests do not cover mixed-length version names; the sort is still deterministic there, so it is coverage rather than behaviour.Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T15:03:25Z.
Review: APPROVED
Second-maintainer review: looks clean and safe to merge.
dxil.dllsearch paths; keepsLEONIDA_DXILoverride (now falling back cleanly toC:\Program Files (x86)\Windows Kits\10\binwhenLEONIDA_DXIL=""), fixes lexicographic vs numeric SDK version sorting (10.0.26100.0>10.0.9999.0), strips the trailing UTF-16 NUL from load error strings, and properly callsFreeLibraryon bothGetProcAddressandDxcCreateInstancefailure paths.