Shaders: lower scc_some directly and per host wave under with_local_waves_any #190

Open
github-bot wants to merge 1 commit from github-bot/gh-190 into main AGit
Owner

@⁠gdawid9407 on GitHub · 2026-11-24 22:22 UTC · original
gdawid9407:fix/wave64-local-any-scc-some → main · +70 −5 · 2 files · 1 commits · open

Problem

  1. On 32-lane hosts, when a wave64 compute shader evaluates scc_some inside a divergent branch (!all_lanes(b)), the initial pass stops with "a lane mask exchanged where not every lane runs" (e.g. compute f133e35efed2a48a in #75 and #89). emit then retries with with_local_waves_any (local && local_any), which takes every other mask-as-data and lane read per host wave, but Lower::scc_some unconditionally rejected self.local instead of self.local && !self.local_any.
  2. Direct SOP reads of Reg::Scc in st.scc_some (without an intervening Scc phi) hit Val::Missing(LANE_MASK) in Lower::get instead of lowering through scc_some, and were not counted by reads_mask_as_data.

Changes

  • Allow Lower::scc_some under self.local && self.local_any, returning the host wave's waveAnyTrue without cross-half LDS exchange (while still rejecting plain with_local_waves idiom checks).
  • Lower direct st.scc_some reads in Lower::get and recognize direct and phi-joined scc_some uses in reads_mask_as_data / console_lanes / crosses.
  • Add unit test covering both direct and scalar-skip-joined scc_some inside a divergent branch on 64-lane and 32-lane hosts.
**@⁠gdawid9407** on GitHub · 2026-11-24 22:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/190) `gdawid9407:fix/wave64-local-any-scc-some` → `main` · +70 −5 · 2 files · 1 commits · open ### Problem 1. On 32-lane hosts, when a wave64 compute shader evaluates `scc_some` inside a divergent branch (`!all_lanes(b)`), the initial pass stops with `"a lane mask exchanged where not every lane runs"` (e.g. `compute f133e35efed2a48a` in #75 and #89). `emit` then retries with `with_local_waves_any` (`local && local_any`), which takes every other mask-as-data and lane read per host wave, but `Lower::scc_some` unconditionally rejected `self.local` instead of `self.local && !self.local_any`. 2. Direct `SOP` reads of `Reg::Scc` in `st.scc_some` (without an intervening `Scc` phi) hit `Val::Missing(LANE_MASK)` in `Lower::get` instead of lowering through `scc_some`, and were not counted by `reads_mask_as_data`. ### Changes - Allow `Lower::scc_some` under `self.local && self.local_any`, returning the host wave's `waveAnyTrue` without cross-half LDS exchange (while still rejecting plain `with_local_waves` idiom checks). - Lower direct `st.scc_some` reads in `Lower::get` and recognize direct and phi-joined `scc_some` uses in `reads_mask_as_data` / `console_lanes` / `crosses`. - Add unit test covering both direct and scalar-skip-joined `scc_some` inside a divergent branch on 64-lane and 32-lane hosts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:53 +00:00
Author
Owner

@⁠ryotdev on GitHub · 2026-11-25 05:42 UTC · original

I checked be692ec against its parent 4e17478 on a 32-lane target. The tiled cascaded-shadow compute program mentioned in the PR still refuses in both builds. On the PR head, the final approximate retry now stops on a constant lane mask in a half-wave. Applying the literal-select lowering from #277 as well leaves that refusal in place. The exact wave-wide retry reports a thread group containing multiple console waves.

Separately, I ran a handwritten 64-thread version of the direct SCC/select case through the normal emitter and read back every lane on an RTX 5070. I placed the one matching lane at 1 and then at 40 and varied the active prefix through 0, 1, 16, 32, 48, and 64 lanes. All 768 output dwords matched the console-wide expectation. WARP on this machine refused the test PSO. This check covers the direct read, and I have no gameplay or joined-SCC output result to report. AI-assisted.

**@⁠ryotdev** on GitHub · 2026-11-25 05:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7154056821) I checked be692ec against its parent 4e17478 on a 32-lane target. The tiled cascaded-shadow compute program mentioned in the PR still refuses in both builds. On the PR head, the final approximate retry now stops on a constant lane mask in a half-wave. Applying the literal-select lowering from #277 as well leaves that refusal in place. The exact wave-wide retry reports a thread group containing multiple console waves. Separately, I ran a handwritten 64-thread version of the direct SCC/select case through the normal emitter and read back every lane on an RTX 5070. I placed the one matching lane at 1 and then at 40 and varied the active prefix through 0, 1, 16, 32, 48, and 64 lanes. All 768 output dwords matched the console-wide expectation. WARP on this machine refused the test PSO. This check covers the direct read, and I have no gameplay or joined-SCC output result to report. AI-assisted.
Author
Owner

@⁠JRamos1993 on GitHub · 2026-11-25 06:46 UTC · original

Offline check: with this PR, f133e35efed2a48a still stops with "a lane mask exchanged where not every lane runs". That holds at this head be692ec (on its base 4e17478) and merged onto current main 310c6eb.

Setup: RTX 5090 (32-lane waves), Windows 11. VICTORY_TRANSLATE_ONLY=f133e35efed2a48a victory translate --validate --list on the retail shader pack, with VICTORY_HOST_WAVE=32, and also with VICTORY_HOST_MAX_WAVE=32, alone and together.

tree f133e35efed2a48a
4e17478 (this PR's base) emit: a lane mask exchanged where not every lane runs
this PR be692ec the same, at the same place in the program
main 310c6eb the same
main + this PR the same
  • Whole pack, merged onto main with VICTORY_HOST_MAX_WAVE=32: 25,383 validated in both, nothing gained or lost.
  • In game: on this GPU, a main 310c6eb run logs this shader with the same message.

So the stop this PR removes may no longer be the first one this program hits. Or the batch path does not take the with_local_waves_any retry the way a run does. I have not traced which.

AI use: Claude Code with Claude Opus 5.5 built the trees, ran them and wrote this. Nothing from the title is in it beyond the shader hash already named in this PR.

**@⁠JRamos1993** on GitHub · 2026-11-25 06:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7155150468) **Offline check: with this PR, `f133e35efed2a48a` still stops with "a lane mask exchanged where not every lane runs".** That holds at this head `be692ec` (on its base `4e17478`) and merged onto current `main` `310c6eb`. **Setup:** RTX 5090 (32-lane waves), Windows 11. `VICTORY_TRANSLATE_ONLY=f133e35efed2a48a victory translate --validate --list` on the retail shader pack, with `VICTORY_HOST_WAVE=32`, and also with `VICTORY_HOST_MAX_WAVE=32`, alone and together. | tree | `f133e35efed2a48a` | |---|---| | `4e17478` (this PR's base) | `emit: a lane mask exchanged where not every lane runs` | | this PR `be692ec` | the same, at the same place in the program | | `main` `310c6eb` | the same | | `main` + this PR | the same | - **Whole pack**, merged onto `main` with `VICTORY_HOST_MAX_WAVE=32`: 25,383 validated in both, nothing gained or lost. - **In game:** on this GPU, a `main` `310c6eb` run logs this shader with the same message. So the stop this PR removes may no longer be the first one this program hits. Or the batch path does not take the `with_local_waves_any` retry the way a run does. I have not traced which. AI use: Claude Code with Claude Opus 5.5 built the trees, ran them and wrote this. Nothing from the title is in it beyond the shader hash already named in this PR.
Author
Owner

@⁠JRamos1993 on GitHub · 2026-11-25 06:58 UTC · original

Follow-up: why f133e35efed2a48a doesn't reach this PR's change. VICTORY_WAVE_WHY=1 VICTORY_HOST_WAVE=32 on main 310c6eb lists every form emit tries for it, with a local tag on the two "exchanged" refusals to show which site fires. Its thread groups are 8×16, two console waves.

form tried where it stops
as is (two host waves exchange) mask_dword: "a lane mask exchanged where not every lane runs" (not scc_some)
without skips, and with scalars followed the same, at the same instruction
local waves (allocation idiom) "not the allocation idiom: a count or sum over the wave used as data"
wave-wide branches (VICTORY_WAVE_WIDE=1) not tried: "wave-wide branches in a thread group of several console waves"
local waves, approximate "a lane mask read as data in a half-wave"
local waves, approximate, any mask "a constant lane mask in a half-wave"

What this means for this PR:

  • The refusal is the ballot exchange in mask_dword, not scc_some.
  • The local && local_any path this PR opens stops first on a constant lane mask, before any scc_some.

What would get further: for this program, the any-mask half-wave form would need constant 64-bit masks taken per half (the host wave's 32 bits of the constant). After that there may be more stops; I didn't try it.

AI use: Claude Code with Claude Opus 5.5 ran the retries with a local diagnostic tag and wrote this. Nothing from the title is in it beyond the hash this PR names.

**@⁠JRamos1993** on GitHub · 2026-11-25 06:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7155350102) Follow-up: **why `f133e35efed2a48a` doesn't reach this PR's change.** `VICTORY_WAVE_WHY=1 VICTORY_HOST_WAVE=32` on `main` `310c6eb` lists every form `emit` tries for it, with a local tag on the two "exchanged" refusals to show which site fires. Its thread groups are 8×16, two console waves. | form tried | where it stops | |---|---| | as is (two host waves exchange) | `mask_dword`: "a lane mask exchanged where not every lane runs" (not `scc_some`) | | without skips, and with scalars followed | the same, at the same instruction | | local waves (allocation idiom) | "not the allocation idiom: a count or sum over the wave used as data" | | wave-wide branches (`VICTORY_WAVE_WIDE=1`) | not tried: "wave-wide branches in a thread group of several console waves" | | local waves, approximate | "a lane mask read as data in a half-wave" | | local waves, approximate, any mask | **"a constant lane mask in a half-wave"** | **What this means for this PR:** - The refusal is the ballot exchange in `mask_dword`, not `scc_some`. - The `local && local_any` path this PR opens stops first on a constant lane mask, before any `scc_some`. **What would get further:** for this program, the any-mask half-wave form would need constant 64-bit masks taken per half (the host wave's 32 bits of the constant). After that there may be more stops; I didn't try it. AI use: Claude Code with Claude Opus 5.5 ran the retries with a local diagnostic tag and wrote this. Nothing from the title is in it beyond the hash this PR names.
Author
Owner

@⁠JRamos1993 on GitHub · 2026-11-25 07:00 UTC · original

Also checked #277 (literal masks in half-waves), alone and merged with this PR on 310c6eb: f133e35efed2a48a still stops on "a constant lane mask in a half-wave" in both any-mask forms. #277's exception needs both self.exchange and literal low and high dwords. At least one of those doesn't hold for this program in that mode; I didn't check which. (AI use: Claude Code with Claude Opus 5.5 ran the builds and wrote this.)

**@⁠JRamos1993** on GitHub · 2026-11-25 07:00 UTC · [original](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7155378835) Also checked #277 (literal masks in half-waves), alone and merged with this PR on `310c6eb`: `f133e35efed2a48a` still stops on "a constant lane mask in a half-wave" in both any-mask forms. #277's exception needs both `self.exchange` and literal low and high dwords. At least one of those doesn't hold for this program in that mode; I didn't check which. (AI use: Claude Code with Claude Opus 5.5 ran the builds and wrote this.)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/190/head:github-bot/gh-190'
git switch 'github-bot/gh-190'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-190'
git switch 'github-bot/gh-190'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-190'
git switch 'github-bot/gh-190'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-190'
git switch 'main'
git merge --squash 'github-bot/gh-190'
git switch 'main'
git merge --ff-only 'github-bot/gh-190'
git switch 'main'
git merge 'github-bot/gh-190'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.