d3d12 shader: find the wave sections after an unmatched saveexec (D3D12-SHADER-WAVE-SECTIONS-PAST-UNMATCHED-SAVEEXEC) #2710
No reviewers
Labels
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2710
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Kal0s-design on GitHub · 2026-11-30 10:39 UTC · original
Kal0s-design:fix/wave-sections-unmatched-saveexec→main· +30 −1 · 1 files · 2 commits · merged 2026-11-30 16:49 UTCClaimed in the coordination issue as: D3D12-SHADER-WAVE-SECTIONS-PAST-UNMATCHED-SAVEEXEC (#2570)
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
wave::sections() looks in a block for whole-wave sections: a saveexec of every lane, the code under it, and the EXEC restore that ends it. When a saveexec's restore was not in the block (it lies in a later one), the scan stopped there (`let Some(end) = end else { break; }`), so every whole-wave section later in the same block was missed and its reduction translated the general way instead of as the section's shape. Such a saveexec is no section; the scan now goes on past it. Test: an_unmatched_saveexec_leaves_the_later_sections_of_its_block puts an unmatched s_or_saveexec_b64 before the wave64 OR reduction the other tests use and expects that section and its shape at index 1. On main it fails ("the section after an unmatched saveexec", left None). Port of shh's fix and test in the sibling VIctory tree (TaynanGT/Vice-Tay 17e3e2c, GPL-3.0). The shader cache key covers leonida-shader/src, so cached translations are made again. Co-Authored-By: shh <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>@OreoFR on GitHub · 2026-11-30 10:42 UTC · original
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
@merzleckeier on GitHub · 2026-11-30 10:47 UTC · original
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.
@MoonEyes on GitHub · 2026-11-30 11:33 UTC · original
@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
d367675c7) into fix/wave-sections-unmatched-saveexec 61945356f4@Kal0s-design on GitHub · 2026-11-30 11:41 UTC · original
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
@MoonEyes on GitHub · 2026-11-30 12:06 UTC · original
@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
@ecox982745 on GitHub · 2026-11-30 12:10 UTC · original
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).
@OreoFR on GitHub · 2026-11-30 15:44 UTC · original
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).
@MoonEyes on GitHub · 2026-11-30 16:49 UTC · original
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).