D3D12-SHADER-IR-BUILD-ANALYSE-ONCE: decode instruction fields and effects once #2835
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2835
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/d3d12-shader-ir-analyse-once"
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?
Pull request successfully merged and closed
Claim:
D3D12-SHADER-IR-BUILD-ANALYSE-ONCE(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7298302658).What and why
ir::buildwalks every machine instruction, decodingfields(wave64)and computingeffects(...). When a program hasv_writelane_b32/v_readlane_b32,unspill_scanhas to walk every instruction first to find parked scalars, decodingfieldsand computingeffectsfor each, and thenbuilddoes both again. A sampling profile putir::buildat 16.3% of samples underspill::build; this halves the decoding for spilling programs.unspillnow returns a cache indexed by instruction:Decoded { name, fields, effects }. The cache is sound:unspill_scanonly borrowsfields/effectsduring its scan and rewriteslistin place after scanning everything;listis never resized or reordered, and everyputrewrite clears that entry's cache slot.None); programs whereunspill_scanbails (name() == None,effectserror, no parked scalars, no pair) get no cache and decode exactly as before.buildrecomputeseffectsafter its own parked-scalar substitution (which mutatesFields::Sopscalar codes) and for rewritten instructions.Same values, same errors, same order; the emitted DXIL is unchanged. No rendering or translation-rule change.
Verification (offline, no game files)
The existing
ir::tests::unspill_looks_only_where_the_code_has_a_save_or_a_restore_of_a_lanestill comparesunspillwithunspill_scanon synthetic streams and now reads the moved return type.The DXIL-identity-over-full-archive check the claim mentions needs game shader data, which is not used here; the semantic corpus is hand-written.
AI-assisted: yes. Design direction from Gemini 4 Neon (one call, no game data).
Verified on Windows: the crate is green with it, and the suite does not distinguish it from
main- which is the honest finding for a change that decodes an instruction once instead of twice.main10bed9ff2, cherry-picked (one commit,merge-base86c30fcea),cargo 1.98.1:So nothing is broken and nothing is added.
ir.rsgains 51 lines and loses 26, and the same 404 tests pass in both trees.What that means, and I would rather say it than dress it up: the suite proves the answers did not change, which is the property a refactor must have; it does not prove the instruction is decoded once. Only a count of decodes would, and there is no such counter in
leonida-shader. If the pull request's description has a measurement, that is what to check.And one thing worth noting from the shape: a change that only touches
ir.rsand adds no test is the kind this repository has no workflow to run at all -cargo test -p leonida-shadertakes six minutes and nothing runs it in CI. That is #2816's argument, and this pull request is the case it does not cover: a refactor with no new test is exactly what a suite catches by accident or not at all.AI-assisted: yes - DeepSeek v4.1 (flash), two six-minute runs.
Written with an AI assistant.
RUN - VERIFY-2835-RTX4060 - by MoonEyes (another person than the author) on head
12ff308a8, with #2836, #2835, #2695, #2696, #2689, #2699 and #2705 merged together intomain9372a4d4f(clean).main9372a4d4fand thenmain+ the seven, one run each, same save: 0 device lost, 0 panics, 0 exceptions in both, about 490 s in the world each, alive at the time limit. Frame rate median 17.8 with the seven and 15.0 onmain, not a comparison: other work ran on the PC during themainrun.main9372a4d4f+ the seven (Windows): leonida-hle 243, leonida-gpu 602, leonida-formats 47, leonida 47, leonida-shader 403 of 405: twosource_hash_testsfailed on a stale build script of mine (a target folder shared with an older branch) and pass after a rebuild of it (3 of 3).Limits: one card, one run per arm, two arms only, the seven together. Values only, no game data.
AI-assisted (Claude Code).
Merging. Head
12ff308a8merges cleanly withmain76746d35band does not force a rebase of #2566. CI green on this head and on main. In-game run on the RTX 4060 posted above (this head, with the six others, about 490 s in the world, 0 device lost, pictures compared with main). Tests on main + the seven: leonida-hle, leonida-gpu, leonida-formats, leonida, leonida-shader, 0 failed. Verified on it by fiestorra and KelboLive (800 random builds, same IR). Merged by MoonEyes.AI-assisted (Claude Code).