Shaders: a skip on EXEC on entry is left out in the deep form, so one more wave64 compute program runs on 32-lane hosts #577
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!577
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-577"
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?
@pr0vId3nce on GitHub · 2026-11-27 12:13 UTC · original
pr0vId3nce:exec-entry-skip→a-publier· +103 −2 · 2 files · 4 commits · openWhat was wrong. On a host whose waves are 32 lanes (NVIDIA), a console wave64 compute program that cannot be split into 32-lane halves keeps
WaveSize(64), which the card refuses, so its dispatch is dropped every frame. One of the three programs #346 lists as refused every frame (2da4beb386509b77) is one: it saves EXEC on entry (s_mov_b64 s[40:41], exec) and later skips a region withs_and_saveexec_b64 <saved>, s[40:41]. EXEC never holds a lane that EXEC on entry did not (the check assumes the program never sets EXEC wider, as whole-wave code would), so that skip is taken only when no lane is left, and the restore of<saved>at the join leaves no lane either. The console compiler had moved a sampler's constants into the region, and an image sample after the join reads them. The deep "without skips" form (ir::without_skips(p, true)) kept the skip, because a scalar the join reads is changed inside it, so every 32-lane form failed.The fix. The deep form now leaves such a skip out when every scalar the region changes is read after the join only by image and buffer instructions of the join block, after the block's first instruction restores EXEC from the saved mask and before EXEC changes again. With no lane left those instructions do nothing, so they cannot tell that the region was skipped. A skip on any other mask, a read by an ALU instruction, or a read after EXEC changes again keeps the skip. So does a join whose first instruction sets EXEC without reading the saved mask:
Inst::readslists only registers, sos_mov_b64 exec, -1reads nothing and would have passed a check that every register it reads is the mask's; the check now also asks for exactly two reads, the mask's two words.TRANSLATOR_VERSIONgoes from 2 to 3, since that program's translation changes. My 16-bit halves PR and #479 also take 3; if either is merged first, this becomes 4.Tests.
ir::tests::a_skip_on_exec_on_entry_is_left_out_when_only_the_join_s_memory_reads_its_scalars, in the first commit, fails without the second: the skip is left out in the deep form only, and kept for a skip on VCC, for a read byv_mov, and for a read after EXEC changes. The third commit adds a join that begins withs_mov_b64 exec, -1instead of the restore, where the skip must be kept; it fails without the fourth commit's two-read guard.cargo test --release -p victory-shader --libon the RTX 4080: 304 passed, 0 failed (303 on a-publier).A census at 32 lanes over the title's whole shader pack: exactly one program changes (
2da4beb386509b77, 256 threads), and it is now emitted for waves of 32. All 2,682 compute programs validate as before.Results on an RTX 4080 (NVIDIA, 32-lane waves; Ryzen 9 7900X, 32 GB, Windows 11; diagnostics build, the same checkpoint and scripted input, warm shader cache, Series S, 300 s runs, median of the frame lines from 200 to 295 s):
2da4beb386509b77now runs)No crash. Frame time is within run-to-run noise. This PR's run 1 was the first with the new translator version (its translations were done before the 200 s window), and a test build was running beside its run 2. The picture changes in the one place I looked: a window now shows a glass pane over what is behind it, where before the glass was missing. I have not compared it with the console.
AMD. No change in what runs. The deep form is only tried for wave64 compute programs on a host whose widest wave is 32 (
emit/mod.rs:lower::host_max_wave() == 32), so on RDNA these programs keep running as wave64, as before. The translator version bump makes every host translate its shaders once more.This touches the same check in
ir::without_skipsas #345; whichever is merged second needs a small rebase.🤖 Generated with Claude Code
@gut0to on GitHub · 2026-11-27 13:02 UTC · original · reviewed
AI-assisted review. I checked the EXEC-mask proof and left one question about the invariant the optimization relies on.
@ -864,0 +875,4 @@&& i.name() == "s_and_saveexec_b64"&& mask.len() == 2&& mask.iter().all(|m| entry.contains(m))).then(|| i.writes.iter().filter(|(r, _)| matches!(r, Reg::S(_)) && !is_exec(r)).map(|x| x.1).collect())@gut0to on GitHub · 2026-11-27 13:02 UTC · original
AI-assisted review: This optimization is sound only if EXEC cannot contain lanes outside the saved entry mask at this point. The comment states that invariant, but this predicate only checks the s_and_saveexec operand; it does not appear to rule out an earlier write that widens EXEC (for example, restoring or setting it to all ones). Could you enforce/prove the invariant over the path or add a regression with EXEC widened before this skip? If such a state is possible, the skip could be removed while lanes are still active.
@MamaLeVrai on GitHub · 2026-11-27 15:56 UTC · original
Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At
b5e1ab0:victory-shader304 passed, 0 failed, 4 ignored.AI-assisted (Claude Code); no game data.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.