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

Open
gdawid9407 wants to merge 1 commit from upstream-pr/190 into main
gdawid9407 commented 2026-11-24 22:22:00 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by gdawid9407 on 2026-11-24T22:22:00Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6592583921 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/190). Originally posted by [gdawid9407](https://github.com/gdawid9407) on 2026-11-24T22:22:00Z. --- ### 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.
ryotdev commented 2026-11-25 06:06:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by ryotdev on 2026-11-25T05:42:13Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7154056821 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7154056821). Originally posted by [ryotdev](https://github.com/ryotdev) on 2026-11-25T05:42:13Z. --- 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.
JRamos1993 commented 2026-11-25 07:06:17 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by JRamos1993 on 2026-11-25T06:46:54Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155150468 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7155150468). Originally posted by [JRamos1993](https://github.com/JRamos1993) on 2026-11-25T06:46:54Z. --- **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 commented 2026-11-25 07:06:19 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by JRamos1993 on 2026-11-25T06:58:20Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155350102 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7155350102). Originally posted by [JRamos1993](https://github.com/JRamos1993) on 2026-11-25T06:58:20Z. --- 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 commented 2026-11-25 07:06:19 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by JRamos1993 on 2026-11-25T07:00:00Z.


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.)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155378835 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/190#issuecomment-7155378835). Originally posted by [JRamos1993](https://github.com/JRamos1993) on 2026-11-25T07:00:00Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/190:upstream-pr/190'
git switch 'upstream-pr/190'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/190'
git switch 'upstream-pr/190'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/190'
git switch 'upstream-pr/190'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/190'
git switch 'main'
git merge --squash 'upstream-pr/190'
git switch 'main'
git merge --ff-only 'upstream-pr/190'
git switch 'main'
git merge 'upstream-pr/190'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!190
No description provided.