Skip to content

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

Open
gdawid9407 wants to merge 1 commit into
fxceless:mainfrom
gdawid9407:fix/wave64-local-any-scc-some
Open

gdawid9407 wants to merge 1 commit into
fxceless:mainfrom
gdawid9407:fix/wave64-local-any-scc-some

Conversation

@gdawid9407

Copy link
Copy Markdown

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 RTX 3070 (32-lane): after #11 (90228a7) the driver refuses ~80 more compute pipelines with E_INVALIDARG #75 and RTX 5070 Laptop (8 GB, default TDR) on 4e17478: 20 min stable, but VICTORY_RELAY=2 causes missing character skin and overlapping subtitles (clean without relay) #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

ryotdev commented Nov 25, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

JRamos1993 commented Nov 25, 2026 •

Copy link
Copy Markdown

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

MfDev0 pushed a commit to MfDev0/victory that referenced this pull request Nov 25, 2026
…aves_any

Ported from fxceless/victory-fork#190 (be692ec). Targets compute
f133e35efed2a48a, which the user's three Try 4.3 reports list as
"a lane mask exchanged where not every lane runs" on an RTX 4060.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants