d3d12 shader: find the wave sections after an unmatched saveexec (D3D12-SHADER-WAVE-SECTIONS-PAST-UNMATCHED-SAVEEXEC) #2710
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2710"
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 Kal0s-design on 2026-11-30T10:39:20Z.
Claimed in the coordination issue as: D3D12-SHADER-WAVE-SECTIONS-PAST-UNMATCHED-SAVEEXEC (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7275699446)
What and why
emit::wave::sections()finds a block's whole-wave sections: a saveexec of every lane, the code under it, and the EXEC restore that ends it. Their reductions are then lowered from the recognised shape (Shape::Activeand friends). When a saveexec's restore is not in the block (the restore lies in a later block), the scan stopped right there:Every whole-wave section later in that block was then missed, and its reduction was translated the general way instead of from its shape. Such a saveexec is no section, so the scan now skips it (
i += 1; continue;) and keeps looking.This is a port of shh's fix and test from the sibling VIctory tree (TaynanGT/Vice-Tay
17e3e2c, GPL-3.0), credited as co-author. That tree took it from an earlier Leonida commit that never reached this repository. The test is unchanged: it puts an unmatcheds_or_saveexec_b64in front ofWAVE_OR_V7_TO_S7.No translator version bump is needed:
leonida-gpu/build.rsfingerprintsleonida-shader/src, so cached translations are made again.Tested
emit::wave::tests::an_unmatched_saveexec_leaves_the_later_sections_of_its_blockexpects the OR section and its shape at index 1 after an unmatched saveexec, and no section at index 0. Onmain(012b79a67) it fails withthe section after an unmatched saveexec(leftNone); with the change it passes.cargo test -p leonida-shader --lib: 386 passed, 0 failed, 4 ignored.cargo clippy -p leonida-shader --all-targets: no warning inwave.rs.GPUs tested: n/a (CPU unit tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: this fixes the section scan, not an instruction's semantics)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T10:42:53Z.
Verified by OreoFR on macOS 27.2.1, Apple M5, Rust 1.98.1,
cargo test -p leonida-shader, main012b79a67, PR head709a6bbb1. MEASURED:emit/wave.rs+ only this PR's test hunk):emit::wave::tests::an_unmatched_saveexec_leaves_the_later_sections_of_its_blockFAILED,the section after an unmatched saveexec(wave.rs:1381).merge --no-ff): that test ok; whole crate 229 passed, 2 ignored, 0 failed (main: 228 + this one).Not covered: the effect on real shaders (how many translations change, DXIL validation, the image); this is the unit test only.
AI-assisted: Claude Code
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T10:47:45Z.
Independent Linux and Wine verification of
709a6bbb1against012b79a67with Rust 1.98.1. The PR also merges cleanly into0568cd62e; the shader crate and Cargo inputs are identical for that merge.CachyOS,
cargo test --locked --offline -p leonida-shader --lib: 228 passed onmain, 229 on the PR, 2 ignored on each. The PR's regression test also failed with the test hunk applied tomainand passed with the fix.MSVC x64 builds under Wine 11.22: all 10 stock
emit::wave::testspassed onmainand all 11 on the PR.I added two local synthetic cases for Wave32 and Wave64. Each puts
s_or_saveexec -1ands_nand_saveexec 0before two complete sections in one block, then uses an actuals_branchto the block that restores both outer masks. The cases check the two section boundaries and the constant each section produces.mainfound neither section in either wave width. The PR found both and returned the expected constants in both cases.CPU-only synthetic tests. AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T11:33:17Z.
@Kal0s-design could you merge current
maininto this branch (a merge, no rebase or force-push)? The two red checks on709a6bbb1(checkandlinux-python-and-viewer) show the same failing test names asmainat012b79a67, andmainhas had a fix since #2708.OreoFR's and merzleckeier's results are on
709a6bbb1, so the red/green will need to be run again on the new head.AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-11-30T11:41:59Z.
Done: merged
main(d367675c7) into the branch, new head61945356f(merge commit, no rebase or force-push of the PR's commit).cargo test -p leonida-shader --libon the new head: 386 passed, 4 ignored, 0 failed.AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T12:06:04Z.
@OreoFR @merzleckeier could one of you run your red/green again on the new head
61945356f? Kal0s-design mergedmain(d367675c7) into the branch, and your results are on the previous head709a6bbb1. CI there: 4 of 5 checks green,checkstill running.AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T12:10:30Z.
Independent red/green and native RTX 4090 check of the updated head
61945356f. I merged it intoec1d85846(tree11d409073), then built both arms with Rust 1.98.1 MSVC in release mode on Windows 11.the section after an unmatched saveexec(Noneinstead ofActive(Or, ...)). All 11emit::wave::testspassed on the merged tree.0xffffffffwords in three alternating runs per arm.The test inputs were synthetic. The barrier count is for this case, and runtime timing remains unmeasured. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-30T15:44:57Z.
RUN - in-game gate (Verified by OreoFR), PROVISIONAL - RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11.
f9f3ec4c6; B = main + this PR at61945356f(git merge --no-ff), diag build ofleonida.exe.play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen, BAR 0, texture budget 1024, standing in the world, 360 s per run (window: world +30 to +330 s). Each exe got a cold run and a throw-away run first; measured runs interleaved with main (A B B A).Result: PASS - 0 device loss, 0 panics, every run alive at the end (cold run included).
hits=/misses=line shows 41 misses in the cold run, 16 in the throw-away run and 0-1 in the measured runs. This is expected for any translator change.This run was AI-assisted (Claude Code, oreofr-agent).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T16:49:54Z.
Merging. Head
61945356fmerges cleanly withmain2a880c31dand does not force a rebase of #2566. Run in the game of 360 s, no device loss, posted on this head (OreoFR, RTX 4070 Laptop); red/green on RTX 4090 by another person; cargo test on Windows with main: leonida-shader 386 passed (main 385), 0 failed. First start after this retranslates the shaders. Merged by MoonEyes.AI-assisted (Claude Code).