d3d12: skip the lane-parking scan for programs with no lane save or restore, walk register sets by word #2780
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2780"
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 bobcatchris on 2026-11-30T18:39:41Z.
Claim: D3D12-SHADER-IR-BUILD-CHEAP-PASSES in #2570.
What
Two cheap cuts in
ir::build(d3d12/crates/leonida-shader/src/ir.rs), which every shader goes through:unspilldecodes the fields and the effects of every instruction to find scalars parked in VGPR lanes, though most programs have nov_writelane_b32orv_readlane_b32. It now returns at once for a list without one; the scan is unchanged (unspill_scan) for the rest.members(the register setsrenamewalks for every block) tested one bit of each of 513 registers; it now takes the set bits a word at a time.renamealso sizes each block's live-out list once.Measured
Full-archive
leonida translateon the user's own shader archive, mimalloc build (--features diagnostics,mimalloc), 16 threads, Ryzen 7 7800X3D, four interleaved pairs against main (08e42a516, DXIL-hash build), values read from each run after the final edit:It is a small gain: wall time is the same within the noise of the runs (48 to 55 s), and the profile put
ir::buildat about 12 % of the translator's samples before this and about 8 % after (different sample windows, so only an indication). Nothing is traded for it.Equivalence
The DXIL of all 25 689 programs is identical to main's: blake3 and length of each, compared as multisets for five full runs (a scratch patch to
translate.rswrites the hashes; not part of this PR). No game data in the PR or in this text.Tests
unspill_looks_only_where_the_code_has_a_save_or_a_restore_of_a_lane: hand-encoded lists (no lane at all, a pair parked and taken back, a save alone, a restore alone, a pair parked across a branch), both wave sizes.unspillandunspill_scanmust give the same moves and the same instructions; the list without a lane must give none (negative control) and the others must give some. I broke each of three things on purpose (early-out checking only saves, checking only restores, skipping always) and the test failed each time.cargo test -p leonida-shader --release: 387 passed, 0 failed, 5 ignored (before merging main);ir::tests pass after the merge.cargo clippy -p leonida-shader --release --all-targets: nothing inir.rs.python -I scripts/check_no_game_data.py d3d12/crates/leonida-shader/src/ir.rs: clean.AI-assisted: Claude Sonnet 5.5. Tested on an AMD RX 7900 XTX host (no GPU work here: translator only).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T18:42:04Z.
Checked by OreoFR on macOS 27.2.1, Apple M5, Rust (rustup),
main8f41d7d01merged with head6c4474cfd.cargo test --release -p leonida-shader:main232 passed, 0 failed, 2 ignored;main+ this PR 233 passed, 0 failed, 2 ignored. The extra one is the newunspill_looks_only_where_the_code_has_a_save_or_a_restore_of_a_lane.ir.rsnext to the change, so it was not run againstmain'sir.rshere.AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T20:11:44Z.
RUN · VERIFY-2780-RTX4060 · by MoonEyes (another person than the author) on head
6c4474cfd, with #2745 (88d0dbf9c), #2773 (6bbaeed11), #2726 (986771506) and #2780 (6c4474cfd) merged intomain51dbc5b58. Windows 11 Pro 26300, RTX 4060 8 GB,-SeriesS -FrameGen 2, diag build.cargo test -p leonida-shader --locked: 400 passed;-p leonida-gpu: 580 passed; 0 failed.main8f41d7d01with two other pull requests: n=1 on each side and not the same tree, so no speed-up is claimed. The four pull requests were in one build.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T20:13:29Z.
Merging. Head
6c4474cfdmerges cleanly withmain643cad411and does not force a rebase of #2566. Two runs in the game (RTX 4060, about 500 s steady each, no device loss) with #2745, #2773, #2726 and #2780 together on this head; cargo test green; checked by other people. The shaders are translated again at the first start. Merged by MoonEyes.AI-assisted (Claude Code).