Cross-lane compute: a wave vote used as a branch is refused (16 lighting programs); needs if-conversion #527

Open
opened 2026-11-28 01:02:23 +00:00 by LakshanSivakumar · 18 comments
LakshanSivakumar commented 2026-11-28 01:02:23 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-28T01:02:23Z.


What you see

Lighting and shadow work is skipped because a family of compute shaders is refused with a cross-lane operation between host waves in divergent code. In my runs 22 compute programs are refused this way per frame.

What I know

16 of the 22 are large (4,000 to 29,000 instructions, 128 or 256 threads). They are dispatched together, next to the computes that write the screen lighting targets. All 16 refuse at one of two shapes, a vote over the whole console wave that is then used as a branch:

  • s_bcnt1 sN, vcc then s_cbranch_scc0
  • s_and vcc, exec, mask then s_cbranch_vccz

The Mac's GPU runs a 64-lane console wave as two 32-lane host waves, so each half sees only its own lanes' vote.

Why the easy fixes are wrong:

  • These sites sit under EXEC skips and after other votes, so they are not in blocks every thread runs once. The exchange through group-shared memory that #518 uses for mesh programs cannot be placed there.
  • In a group of several console waves, each wave can take a different branch. A group barrier at the vote can then hang the GPU. #438 shows this (it hangs at 128 groups by its author's own test).
  • Reading the vote per half is a guess, and it gives wrong results where the halves disagree.

The fix I believe is correct is if-conversion as in design note #393: run both arms predicated, keep loops going while any wave of the group still wants to, and exchange votes at points every thread reaches. The other route is paired lanes (one host thread does two console lanes), which needs no barriers but touches every vector lowering.

Not in this family, although they are often listed with it: the shadow traces 534b3645dd344ab2, d50c03da6d935d87 and ffd9788ba9fec033 have 32-thread groups and refuse with lane-mask join of an untracked mask (#434, #466).

What would help

  • @Ketan-Kapse said on #437 that his local tree translates 31 of 38 cross-lane programs by if-conversion. That work, even unfinished, would save days.
  • A reviewer for a narrow first step: if-conversion for only the two shapes above, everything else refused as today.
  • A GPU test that builds a two-wave group where the halves vote differently, so any lowering can be checked.

#376, #393, #302 (regresses 17 compute shaders), #438 (unsound), #512.

How to see it

Branch lit-world/base-3 (commit 9a0d811d). It is #437 with fixes on top: #518, the cross-page loads, texture fixes, the page table for described pipelines and the image null-view test. It is not main, and one upstream test fails on it by design (wave32_tests::a_branch_on_a_first_lane_read_is_not_uniform_across_the_halves).

VICTORY_CONSOLE_PIPELINES=0 VICTORY_METAL_RESIDENCY_SETS=1 VICTORY_TEXTURE_DROP_TOP_MIP=1 \
VICTORY_OUTPUT=1280x720 VICTORY_UPSCALER=6 VICTORY_STEP_OVER=pool VICTORY_PIPELINE_TIMEOUT_S=15 \
tools/macos/run-native.sh --console series-s <game folder>

Apple Silicon Mac with 48 GB, Series S profile. The world shows about 4.5 minutes after start on a cold shader cache.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6656989976 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-28T01:02:23Z. --- ### What you see Lighting and shadow work is skipped because a family of compute shaders is refused with `a cross-lane operation between host waves in divergent code`. In my runs 22 compute programs are refused this way per frame. ### What I know 16 of the 22 are large (4,000 to 29,000 instructions, 128 or 256 threads). They are dispatched together, next to the computes that write the screen lighting targets. All 16 refuse at one of two shapes, a vote over the whole console wave that is then used as a branch: - `s_bcnt1 sN, vcc` then `s_cbranch_scc0` - `s_and vcc, exec, mask` then `s_cbranch_vccz` The Mac's GPU runs a 64-lane console wave as two 32-lane host waves, so each half sees only its own lanes' vote. Why the easy fixes are wrong: - These sites sit under EXEC skips and after other votes, so they are not in blocks every thread runs once. The exchange through group-shared memory that #518 uses for mesh programs cannot be placed there. - In a group of several console waves, each wave can take a different branch. A group barrier at the vote can then hang the GPU. #438 shows this (it hangs at 128 groups by its author's own test). - Reading the vote per half is a guess, and it gives wrong results where the halves disagree. The fix I believe is correct is if-conversion as in design note #393: run both arms predicated, keep loops going while any wave of the group still wants to, and exchange votes at points every thread reaches. The other route is paired lanes (one host thread does two console lanes), which needs no barriers but touches every vector lowering. Not in this family, although they are often listed with it: the shadow traces `534b3645dd344ab2`, `d50c03da6d935d87` and `ffd9788ba9fec033` have 32-thread groups and refuse with `lane-mask join of an untracked mask` (#434, #466). ### What would help - @Ketan-Kapse said on #437 that his local tree translates 31 of 38 cross-lane programs by if-conversion. That work, even unfinished, would save days. - A reviewer for a narrow first step: if-conversion for only the two shapes above, everything else refused as today. - A GPU test that builds a two-wave group where the halves vote differently, so any lowering can be checked. ### Related #376, #393, #302 (regresses 17 compute shaders), #438 (unsound), #512. ### How to see it Branch [`lit-world/base-3`](https://github.com/LakshanSivakumar/Native-Victory-macOS/tree/lit-world/base-3) (commit `9a0d811d`). It is #437 with fixes on top: #518, the cross-page loads, texture fixes, the page table for described pipelines and the image null-view test. It is not main, and one upstream test fails on it by design (`wave32_tests::a_branch_on_a_first_lane_read_is_not_uniform_across_the_halves`). ```bash VICTORY_CONSOLE_PIPELINES=0 VICTORY_METAL_RESIDENCY_SETS=1 VICTORY_TEXTURE_DROP_TOP_MIP=1 \ VICTORY_OUTPUT=1280x720 VICTORY_UPSCALER=6 VICTORY_STEP_OVER=pool VICTORY_PIPELINE_TIMEOUT_S=15 \ tools/macos/run-native.sh --console series-s <game folder> ``` Apple Silicon Mac with 48 GB, Series S profile. The world shows about 4.5 minutes after start on a cold shader cache.
marcus-4 commented 2026-11-28 01:47:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T01:47:36Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231920175 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7231920175). Originally posted by [marcus-4](https://github.com/marcus-4) on 2026-11-28T01:47:36Z. --- /claim
github-actions[bot] commented 2026-11-28 01:47:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T01:47:54Z.


Claimed by @Sheffy007. Open a draft pull request with Refs #527 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7231923602 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7231923602). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T01:47:54Z. --- Claimed by @Sheffy007. Open a draft pull request with `Refs #527` in its description within 24 hours, or the claim expires.
marcus-4 commented 2026-11-28 02:55:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T02:55:25Z.


@Sheffy007, a question so we don't overlap. My /claim here (01:47:36 UTC) came 18 s before the bot assigned this issue to you, and I don't see a comment of yours on it, so I think the bot may have mixed up two claims that arrived at about the same time. Your /claim on #538 went in at 01:48:04.

I already have a PR for this issue, #541. It adds paired lanes behind VICTORY_PAIRED_WAVES=1, the route this issue names besides if-conversion, with GPU tests for both of the vote shapes listed above.

Are you working on #527, perhaps the if-conversion route? If not, could you /release it so the claim matches the PR? If you are, I'll keep #541 to #376 and stay off yours.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232680510 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7232680510). Originally posted by [marcus-4](https://github.com/marcus-4) on 2026-11-28T02:55:25Z. --- @Sheffy007, a question so we don't overlap. My `/claim` here (01:47:36 UTC) came 18 s before the bot assigned this issue to you, and I don't see a comment of yours on it, so I think the bot may have mixed up two claims that arrived at about the same time. Your `/claim` on #538 went in at 01:48:04. I already have a PR for this issue, #541. It adds paired lanes behind `VICTORY_PAIRED_WAVES=1`, the route this issue names besides if-conversion, with GPU tests for both of the vote shapes listed above. Are you working on #527, perhaps the if-conversion route? If not, could you `/release` it so the claim matches the PR? If you are, I'll keep #541 to #376 and stay off yours.
Sheffy007 commented 2026-11-28 03:05:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-28T03:05:54Z.


/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232792342 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7232792342). Originally posted by [Sheffy007](https://github.com/Sheffy007) on 2026-11-28T03:05:54Z. --- /release
github-actions[bot] commented 2026-11-28 03:06:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T03:06:04Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232794154 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7232794154). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T03:06:04Z. --- Released. This issue is free to claim.
marcus-4 commented 2026-11-28 03:06:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T03:06:47Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232802064 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7232802064). Originally posted by [marcus-4](https://github.com/marcus-4) on 2026-11-28T03:06:47Z. --- /claim
github-actions[bot] commented 2026-11-28 03:06:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T03:06:57Z.


Claimed by @marcus-4. Open a draft pull request with Refs #527 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7232803919 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7232803919). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T03:06:57Z. --- Claimed by @marcus-4. Open a draft pull request with `Refs #527` in its description within 24 hours, or the claim expires.
marcus-4 commented 2026-11-28 08:19:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T08:19:16Z.


/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7236506465 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7236506465). Originally posted by [marcus-4](https://github.com/marcus-4) on 2026-11-28T08:19:16Z. --- /release
marcus-4 commented 2026-11-28 08:23:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by marcus-4 on 2026-11-28T08:23:36Z.


/release

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7236553003 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7236553003). Originally posted by [marcus-4](https://github.com/marcus-4) on 2026-11-28T08:23:36Z. --- /release
github-actions[bot] commented 2026-11-28 08:23:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T08:23:48Z.


Released. This issue is free to claim.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7236555364 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7236555364). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T08:23:48Z. --- Released. This issue is free to claim.
AnastasisKon commented 2026-11-28 11:25:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T11:25:16Z.


/claim

Taking the narrow first step this issue asks for: if-conversion for only the two vote shapes (s_bcnt1 sN, vcc then s_cbranch_scc0, and s_and vcc, exec, mask then s_cbranch_vccz) used as a branch, everything else refused as today. Testable without the game via hand-assembled GFX10 in the refusal tests, plus a two-host-wave case where the halves vote differently. I'll read design note #393 and the related #376/#438/#512/#302 first and say in the PR what I took from them. Draft PR from my fork's vibe/ branch to follow.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238539441 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7238539441). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T11:25:16Z. --- /claim Taking the narrow first step this issue asks for: if-conversion for only the two vote shapes (`s_bcnt1 sN, vcc` then `s_cbranch_scc0`, and `s_and vcc, exec, mask` then `s_cbranch_vccz`) used as a branch, everything else refused as today. Testable without the game via hand-assembled GFX10 in the refusal tests, plus a two-host-wave case where the halves vote differently. I'll read design note #393 and the related #376/#438/#512/#302 first and say in the PR what I took from them. Draft PR from my fork's vibe/ branch to follow.
github-actions[bot] commented 2026-11-28 11:25:31 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T11:25:31Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #527 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7238542304 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7238542304). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T11:25:31Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #527` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 12:27:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T12:27:18Z.


Following up on my claim above, and closing it out honestly.

The narrow first step (the two vote shapes) already exists as @marcus-4's paired-lanes work in #541, which was closed as already in the private tree. It is not in the public tree, so I have carried it forward in my fork: https://github.com/AnastasisKon/Native-Victory-macOS/pull/2

  • Both commits are @marcus-4's, cherry-picked unchanged, so the authorship is kept.
  • Behind VICTORY_PAIRED_WAVES=1, off by default and part of the shader cache key.
  • Rebased onto my fork's main 69146296. On an M3 Pro: 422 shader tests, 60 Metal split_wave tests (both vote shapes included), clippy for x86_64-pc-windows-gnullvm with -D warnings, and cargo xtask policy all pass.

I am not writing a second implementation of the same fix. As with the rest of the public tree, upstream is frozen, so this lives in the fork rather than here. The one thing left, and the reason to care: with the switch on, eee76bf6 runs, and alexballvideos-netizen measured the four ray-traced passes filling in (0.0000 to 0.6958 non-zero on the 1280x720 target they all write). That needs a game run on a Mac with the title to confirm, which I have not done.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239238264 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7239238264). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T12:27:18Z. --- Following up on my claim above, and closing it out honestly. The narrow first step (the two vote shapes) already exists as @marcus-4's paired-lanes work in #541, which was closed as already in the private tree. It is not in the public tree, so I have carried it forward in my fork: https://github.com/AnastasisKon/Native-Victory-macOS/pull/2 - Both commits are @marcus-4's, cherry-picked unchanged, so the authorship is kept. - Behind `VICTORY_PAIRED_WAVES=1`, off by default and part of the shader cache key. - Rebased onto my fork's `main` `69146296`. On an M3 Pro: 422 shader tests, 60 Metal `split_wave` tests (both vote shapes included), clippy for `x86_64-pc-windows-gnullvm` with `-D warnings`, and `cargo xtask policy` all pass. I am not writing a second implementation of the same fix. As with the rest of the public tree, upstream is frozen, so this lives in the fork rather than here. The one thing left, and the reason to care: with the switch on, `eee76bf6` runs, and alexballvideos-netizen measured the four ray-traced passes filling in (0.0000 to 0.6958 non-zero on the 1280x720 target they all write). That needs a game run on a Mac with the title to confirm, which I have not done.
AnastasisKon commented 2026-11-28 13:03:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T13:03:54Z.


Pinned both shapes with synthetic programs (emit/wave32_tests.rs, in my fork's main at 20254252). Two findings, the second one changes the scope.

1. The s_bcnt1 shape reproduces as described. v_cmp / s_cbranch_execz over the body / v_cmp / s_bcnt1_i32_b64 s6, vcc / s_cbranch_scc0, plus a v_readlane_b32 of a lane in the upper half:

  • group of one console wave (64 lanes): translates, one exchange and four barriers;
  • group of two waves (128 lanes): refused, a cross-lane operation between host waves in divergent code.

One detail worth recording: s_and_saveexec_b64 masking on its own does not make a site divergent. Every thread still visits the block once, so the exchange stays legal there and the vote lowers. What makes these sites divergent is a real branch (an s_cbranch_execz region, an if/else) around the vote - which matches "these sites sit under EXEC skips" only if the skip is a branch, not a bare EXEC mask.

2. s_and vcc, exec, mask then s_cbranch_vccz is not refused at all. It translates at every group size, with no exchange and no barriers, because each half branches on its own 32 bits of vcc. Where the halves agree on vcc that is fine; where they differ it is not the console's answer - the console takes the branch for the wave as a whole, so lanes that hold EXEC but no mask bit still run the body, while here their half skips it. So this shape is a wrong answer rather than a refusal, and if the title's sites are this shape then the if-conversion has to replace the lowering, not only stop refusing it, and "16 refused programs" undercounts how much lighting is currently going wrong.

Caveat, so nobody builds on a guess: these are synthetic programs, not the title's shaders. The game files here are still downloading (no game_scarlett_master.exe yet), so I have no corpus sweep and no in-game counts. docs/metal-backend.md now records both behaviours as the boundary an if-conversion has to widen.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239663798 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7239663798). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T13:03:54Z. --- Pinned both shapes with synthetic programs (`emit/wave32_tests.rs`, in my fork's `main` at `20254252`). Two findings, the second one changes the scope. **1. The `s_bcnt1` shape reproduces as described.** `v_cmp` / `s_cbranch_execz` over the body / `v_cmp` / `s_bcnt1_i32_b64 s6, vcc` / `s_cbranch_scc0`, plus a `v_readlane_b32` of a lane in the upper half: - group of one console wave (64 lanes): translates, one exchange and four barriers; - group of two waves (128 lanes): refused, `a cross-lane operation between host waves in divergent code`. One detail worth recording: `s_and_saveexec_b64` masking on its own does **not** make a site divergent. Every thread still visits the block once, so the exchange stays legal there and the vote lowers. What makes these sites divergent is a real branch (an `s_cbranch_execz` region, an if/else) around the vote - which matches "these sites sit under EXEC skips" only if the skip is a branch, not a bare EXEC mask. **2. `s_and vcc, exec, mask` then `s_cbranch_vccz` is not refused at all.** It translates at every group size, with no exchange and no barriers, because each half branches on its own 32 bits of `vcc`. Where the halves agree on `vcc` that is fine; where they differ it is not the console's answer - the console takes the branch for the wave as a whole, so lanes that hold EXEC but no mask bit still run the body, while here their half skips it. So this shape is a wrong answer rather than a refusal, and if the title's sites are this shape then the if-conversion has to *replace* the lowering, not only stop refusing it, and "16 refused programs" undercounts how much lighting is currently going wrong. Caveat, so nobody builds on a guess: these are synthetic programs, not the title's shaders. The game files here are still downloading (no `game_scarlett_master.exe` yet), so I have no corpus sweep and no in-game counts. `docs/metal-backend.md` now records both behaviours as the boundary an if-conversion has to widen.
AnastasisKon commented 2026-11-28 13:11:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T13:11:21Z.


Update, and it may make the if-conversion unnecessary for this shape: the paired form already handles it.

a_vote_used_as_a_branch_follows_each_console_wave_in_the_paired_form (crates/victory-gpu/src/native/split_wave_tests.rs, my fork's main at 367ce23e) is the GPU test you asked for - a group of two console waves whose halves vote differently:

  • v_cmp_lt_u32 vcc, 64, v0 leaves wave 0 whole (threads 0..63) and wave 1 empty;
  • s_bcnt1_i32_b64 s6, vcc counts 64 there and 0 here;
  • s_cbranch_scc0 skips a v_mov, so the two waves take different arms. (s_bcnt1 leaves SCC set when the count is zero, so wave 0's branch is taken and wave 1's is not.)

The fast path refuses the program with a cross-lane operation between host waves in divergent code, which is the refusal this issue is about. Translated with paired_waves (VICTORY_PAIRED_WAVES=1, lower/paired.rs), it runs on Metal and the read-back values are per wave: 1 in threads 0..63, 2 in 64..127. Nothing crosses a host wave there - one host wave per console wave, two console lanes a thread - so the vote is the wave's own and the waves may differ, as on the console.

So for this shape the fix looks like running these programs in the paired form, not if-conversion: lockstep::fits already allows groups of several waves when paired_waves is set, and the switch is what decides it today (victory-gpu/src/native/shaders.rs).

What this does not settle: my program is the vote-and-branch shape only, not the body of the 16 lighting computes, so their whole bodies are still unproven in the paired form, and nothing here is measured in game - the game files on this machine are still downloading, so there is no corpus sweep and no before/after log. The useful next step is a run with VICTORY_PAIRED_WAVES=1 to count what translates and what the picture does. If that holds, #527 turns from "needs a compiler feature" into "validate the paired form and decide the default".

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239757226 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7239757226). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T13:11:21Z. --- Update, and it may make the if-conversion unnecessary for this shape: the **paired form** already handles it. `a_vote_used_as_a_branch_follows_each_console_wave_in_the_paired_form` (`crates/victory-gpu/src/native/split_wave_tests.rs`, my fork's `main` at `367ce23e`) is the GPU test you asked for - a group of two console waves whose halves vote differently: - `v_cmp_lt_u32 vcc, 64, v0` leaves wave 0 whole (threads 0..63) and wave 1 empty; - `s_bcnt1_i32_b64 s6, vcc` counts 64 there and 0 here; - `s_cbranch_scc0` skips a `v_mov`, so the two waves take different arms. (`s_bcnt1` leaves SCC set when the count is *zero*, so wave 0's branch is taken and wave 1's is not.) The fast path refuses the program with `a cross-lane operation between host waves in divergent code`, which is the refusal this issue is about. Translated with `paired_waves` (`VICTORY_PAIRED_WAVES=1`, `lower/paired.rs`), it runs on Metal and the read-back values are per wave: 1 in threads 0..63, 2 in 64..127. Nothing crosses a host wave there - one host wave per console wave, two console lanes a thread - so the vote is the wave's own and the waves may differ, as on the console. So for this shape the fix looks like *running these programs in the paired form*, not if-conversion: `lockstep::fits` already allows groups of several waves when `paired_waves` is set, and the switch is what decides it today (`victory-gpu/src/native/shaders.rs`). What this does not settle: my program is the vote-and-branch shape only, not the body of the 16 lighting computes, so their whole bodies are still unproven in the paired form, and nothing here is measured in game - the game files on this machine are still downloading, so there is no corpus sweep and no before/after log. The useful next step is a run with `VICTORY_PAIRED_WAVES=1` to count what translates and what the picture does. If that holds, #527 turns from "needs a compiler feature" into "validate the paired form and decide the default".
AnastasisKon commented 2026-11-28 13:28:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T13:28:37Z.


Second shape, measured on the GPU: it is not only refused-or-fine - the fast path answers it per lane, and that answer is wrong. Pinned by a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave (crates/victory-gpu/src/native/split_wave_tests.rs, my fork's main at e8cebe57), marked #[ignore] with the observed values until the lowering is fixed.

Program, a group of 128 threads (two console waves):

v_cmp_lt_u32_e32 vcc, 32, v0     ; 32 < lane: on from lane 33 up
s_and_b64 vcc, exec, vcc         ; the shape
s_cbranch_vccz 1                 ; skip the body when the wave's mask is zero
v_mov_b32_e32 v2, 7              ; the guarded body
global_store_dword ...           ; store v2

On the console exec & vcc is non-zero for both waves, so both run the body with EXEC as it was and every lane stores 7. On the GPU the fast path stores 0 in lanes 0..32 and 7 in lanes 33..127: the branch is testing each lane's own vcc bit, not the wave's 64-bit mask.

Why this matters beyond the refusal count: this shape does not refuse. It translates and draws the wrong lighting wherever the lanes of a wave disagree about the mask, so if the title's light-list programs take this path, part of the black/interior lighting is a wrong answer rather than a dropped draw - which the refusal counts in #527 and #526 would not show.

Confirmed not to be a harness artefact: the same store pattern reads back the lane id 0..127 in order (v_mov_b32_e32 v2, v0), so the mapping is identity and the values above are what the shader computed.

Route out, same as the first shape: the paired form answers per wave (a_vote_used_as_a_branch_follows_each_console_wave_in_the_paired_form), so running these programs with VICTORY_PAIRED_WAVES=1 should both translate them and answer correctly. Second best, if that does not hold for their bodies: refuse this shape instead of translating it, so the draw is dropped and counted rather than drawn wrong.

Still synthetic - no title shaders, no in-game numbers, no corpus sweep until the game files here finish downloading.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7239961774 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7239961774). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T13:28:37Z. --- Second shape, measured on the GPU: it is not only refused-or-fine - **the fast path answers it per lane, and that answer is wrong**. Pinned by `a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave` (`crates/victory-gpu/src/native/split_wave_tests.rs`, my fork's `main` at `e8cebe57`), marked `#[ignore]` with the observed values until the lowering is fixed. Program, a group of 128 threads (two console waves): ``` v_cmp_lt_u32_e32 vcc, 32, v0 ; 32 < lane: on from lane 33 up s_and_b64 vcc, exec, vcc ; the shape s_cbranch_vccz 1 ; skip the body when the wave's mask is zero v_mov_b32_e32 v2, 7 ; the guarded body global_store_dword ... ; store v2 ``` On the console `exec & vcc` is non-zero for both waves, so both run the body with EXEC as it was and **every** lane stores 7. On the GPU the fast path stores 0 in lanes 0..32 and 7 in lanes 33..127: the branch is testing each lane's own `vcc` bit, not the wave's 64-bit mask. Why this matters beyond the refusal count: this shape does not refuse. It translates and draws the wrong lighting wherever the lanes of a wave disagree about the mask, so if the title's light-list programs take this path, part of the black/interior lighting is a wrong answer rather than a dropped draw - which the refusal counts in #527 and #526 would not show. Confirmed not to be a harness artefact: the same store pattern reads back the lane id 0..127 in order (`v_mov_b32_e32 v2, v0`), so the mapping is identity and the values above are what the shader computed. Route out, same as the first shape: the paired form answers per wave (`a_vote_used_as_a_branch_follows_each_console_wave_in_the_paired_form`), so running these programs with `VICTORY_PAIRED_WAVES=1` should both translate them and answer correctly. Second best, if that does not hold for their bodies: refuse this shape instead of translating it, so the draw is dropped and counted rather than drawn wrong. Still synthetic - no title shaders, no in-game numbers, no corpus sweep until the game files here finish downloading.
AnastasisKon commented 2026-11-28 13:34:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T13:34:18Z.


Correction to what I said above about the second shape, now that I have measured it rather than reasoned about it: the paired form does not answer it either, and the reason is structural.

run_group translates with Options::paired_waves, but lockstep (and so the paired form) is only tried after the fast path has refused a program - it is emit's retry on Unsupported. For s_and vcc, exec, mask then s_cbranch_vccz the fast path accepts the program and answers per lane, so the retry never happens and the paired lowering is never reached. Same program, same per-lane values (0 in lanes 0..32, 7 in the rest) whether the option is set or not:

  • a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave - fast path, wrong answer, ignored;
  • a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave_in_the_paired_form - asserts the fast path refuses first, then the per-wave answer, ignored.

So the fix for this shape is not "flip the default": it is to make the fast path refuse a vccz/vccnz branch whose vcc is a per-lane mask the structuriser cannot test wave-wide - it already refuses other cross-half reads that way - so that the retry runs. Lockstep's branches then rewrites the branch to s_cmp_eq_u64 vcc, 0 and a scalar s_cbranch_scc1, which is the wave's answer, and the paired form carries it for groups of several waves. The ignored test names the answer to expect afterwards (all 128 lanes 7).

Why I have not made that change yet: it is in the structuriser's branch(), and the size of the coverage change is unknown without a corpus - some vccz branches are uniform in practice and are right today, so refusing too widely would drop draws that currently draw correctly. That number needs a run, and a run needs the game files, which are still downloading here.

(The first shape, the s_bcnt1 vote, does go through the retry and is answered per wave in the paired form - that result stands.)

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7240029974 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7240029974). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T13:34:18Z. --- Correction to what I said above about the second shape, now that I have measured it rather than reasoned about it: **the paired form does not answer it either**, and the reason is structural. `run_group` translates with `Options::paired_waves`, but lockstep (and so the paired form) is only tried after the fast path has *refused* a program - it is `emit`'s retry on `Unsupported`. For `s_and vcc, exec, mask` then `s_cbranch_vccz` the fast path **accepts** the program and answers per lane, so the retry never happens and the paired lowering is never reached. Same program, same per-lane values (0 in lanes 0..32, 7 in the rest) whether the option is set or not: - `a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave` - fast path, wrong answer, ignored; - `a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave_in_the_paired_form` - asserts the fast path refuses first, then the per-wave answer, ignored. So the fix for this shape is not "flip the default": it is to make the fast path refuse a `vccz`/`vccnz` branch whose `vcc` is a per-lane mask the structuriser cannot test wave-wide - it already refuses other cross-half reads that way - so that the retry runs. Lockstep's `branches` then rewrites the branch to `s_cmp_eq_u64 vcc, 0` and a scalar `s_cbranch_scc1`, which is the wave's answer, and the paired form carries it for groups of several waves. The ignored test names the answer to expect afterwards (all 128 lanes 7). Why I have not made that change yet: it is in the structuriser's `branch()`, and the size of the coverage change is unknown without a corpus - some `vccz` branches are uniform in practice and are right today, so refusing too widely would drop draws that currently draw correctly. That number needs a run, and a run needs the game files, which are still downloading here. (The first shape, the `s_bcnt1` vote, does go through the retry and is answered per wave in the paired form - that result stands.)
AnastasisKon commented 2026-11-28 13:42:51 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T13:42:51Z.


Second shape of this issue fixed behind a switch: VICTORY_STRICT_VCCZ_BRANCH=1 (off by default) on fork AnastasisKon/Native-Victory-macOS main, commit e26b2a9d.

What was wrong. v_cmp_lt_u32 vcc, 32, v0; s_and_b64 vcc, exec, vcc; s_cbranch_vccz asks about the whole wave's mask, but structure::branch() models vccz as vcc & exec for the lane, so the fast path answers per lane. Measured on the GPU (split_wave_tests::a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave, still #[ignore]d as a pin): lanes 0..32 store 0, 33..127 store 7, console is 7 in all 128. The structurer's Bools are per-lane booleans, so there is no correct lowering in that form — the answer has to be lockstep, where branches() rewrites the branch to s_cmp_eq_u64 vcc, 0 + s_cbranch_scc1 and it becomes the wave's.

What the switch does. structure::structure_with(program, strict) refuses a vccz/vccnz branch whose vcc is not a uniform mask ("a vccz branch on a lane mask the two halves of a console wave can see differently"), and emit::translate_native hands that refusal to lockstep::retry instead of reporting it, so the program runs in the paired form with the branch answered per wave. The flag is Options::strict_vccz_branch, filled from the environment by the native host, and added to TRANSLATION_SWITCHES — without that, a warm cache would keep serving the per-lane translations.

Measured end to end (split_wave_tests::a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave_with_the_strict_switch, 128 threads, two console waves): all 128 lanes store 7, refusals() == 0. Pins: structure::tests::a_vccz_branch_on_a_split_mask_is_refused_only_in_the_strict_form (refusal fires only in the strict form).

To measure it yourself: VICTORY_STRICT_VCCZ_BRANCH=1 VICTORY_PAIRED_WAVES=1 on a run, then compare dump translations offline (guess). Off by default, so nothing changes until the switch is set; the shapes it moves to lockstep are the ones to count before making it the default.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7240131932 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/527#issuecomment-7240131932). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T13:42:51Z. --- Second shape of this issue fixed behind a switch: **`VICTORY_STRICT_VCCZ_BRANCH=1`** (off by default) on fork `AnastasisKon/Native-Victory-macOS` `main`, commit `e26b2a9d`. **What was wrong.** `v_cmp_lt_u32 vcc, 32, v0; s_and_b64 vcc, exec, vcc; s_cbranch_vccz` asks about the whole wave's mask, but `structure::branch()` models `vccz` as `vcc & exec` for the lane, so the fast path answers per lane. Measured on the GPU (`split_wave_tests::a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave`, still `#[ignore]`d as a pin): lanes 0..32 store 0, 33..127 store 7, console is 7 in all 128. The structurer's `Bools` are per-lane booleans, so there is no correct lowering in that form — the answer has to be lockstep, where `branches()` rewrites the branch to `s_cmp_eq_u64 vcc, 0` + `s_cbranch_scc1` and it becomes the wave's. **What the switch does.** `structure::structure_with(program, strict)` refuses a `vccz`/`vccnz` branch whose `vcc` is not a uniform mask ("a vccz branch on a lane mask the two halves of a console wave can see differently"), and `emit::translate_native` hands that refusal to `lockstep::retry` instead of reporting it, so the program runs in the paired form with the branch answered per wave. The flag is `Options::strict_vccz_branch`, filled from the environment by the native host, and added to `TRANSLATION_SWITCHES` — without that, a warm cache would keep serving the per-lane translations. **Measured end to end** (`split_wave_tests::a_vccz_branch_where_the_lanes_disagree_answers_for_the_wave_with_the_strict_switch`, 128 threads, two console waves): all 128 lanes store 7, `refusals() == 0`. Pins: `structure::tests::a_vccz_branch_on_a_split_mask_is_refused_only_in_the_strict_form` (refusal fires only in the strict form). To measure it yourself: `VICTORY_STRICT_VCCZ_BRANCH=1 VICTORY_PAIRED_WAVES=1` on a run, then compare dump translations offline (`guess`). Off by default, so nothing changes until the switch is set; the shapes it moves to lockstep are the ones to count before making it the default.
Sign in to join this conversation.
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
LakshanSivakumar/Native-Victory-macOS#527
No description provided.