Shaders: keep literal select mask bits when lowering local half-waves #277

Open
fluffyflattershy-afk wants to merge 1 commit from upstream-pr/277 into main
fluffyflattershy-afk commented 2026-11-24 23:09:02 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by fluffyflattershy-afk on 2026-11-24T23:09:02Z.


Change

A v_cndmask_b32 using a literal 64-bit scalar mask was refused in local half-wave lowering. When console lanes are already mapped, both host waves can use the literal and select the bit at their console lane index. This select requires no group exchange. Computed mask pairs still use the existing refusal.

Verification

  • A synthetic 64-thread compute shader selects 0 in lanes 0–31 and 1 in lanes 32–63. Before the change, lowering refused the select. With the patch, DXIL validation passed and all 64 outputs matched on a Windows 11 RTX 5070 Ti Laptop GPU.
  • All six emit::wave64_tests passed. cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings and cargo xtask policy passed.
  • This covers literal mask pairs. The tiled-shadow program discussed in #190 still fails to lower in the local check.

AI-assisted with Codex. The test uses only synthetic inputs.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593254322 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/277). Originally posted by [fluffyflattershy-afk](https://github.com/fluffyflattershy-afk) on 2026-11-24T23:09:02Z. --- ## Change A `v_cndmask_b32` using a literal 64-bit scalar mask was refused in local half-wave lowering. When console lanes are already mapped, both host waves can use the literal and select the bit at their console lane index. This select requires no group exchange. Computed mask pairs still use the existing refusal. ## Verification - A synthetic 64-thread compute shader selects 0 in lanes 0–31 and 1 in lanes 32–63. Before the change, lowering refused the select. With the patch, DXIL validation passed and all 64 outputs matched on a Windows 11 RTX 5070 Ti Laptop GPU. - All six `emit::wave64_tests` passed. `cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings` and `cargo xtask policy` passed. - This covers literal mask pairs. The tiled-shadow program discussed in #190 still fails to lower in the local check. AI-assisted with Codex. The test uses only synthetic inputs.
ErRusso commented 2026-11-25 00:09:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by ErRusso on 2026-11-24T23:35:19Z.

Review: APPROVED


Reviewed at 6c835cd against 2119b0e.

Verification:

  • victory-shader --lib builds for x86_64-pc-windows-gnu.
  • The new local_waves_select_their_console_bits_from_a_constant_mask passes here (the hardware dispatch is skipped because this Wine host has no SM 6.6 device; DXIL validation and lowering still ran).
  • All six emit::wave64_tests pass under Wine.

The change is correct: a local half-wave can select bits from a literal 64-bit mask because both host waves see the same constants and lane_bit relabels each wave's lanes through console_lane(). Computed masks still take the refusal path, and the condition requires both halves to be literal, so a partially computed wave64 mask is still rejected. self.exchange.is_some() is redundant with self.local, but harmless.

Non-blocking: add a negative test that a computed mask (or a mask with only one literal half) is still refused in a local half-wave. That would lock in the boundary the new condition draws.

LGTM.

<!-- greyfinch-sync:fxceless/victory-fork:review:6049134694 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/277#pullrequestreview-6049134694). Originally posted by [ErRusso](https://github.com/ErRusso) on 2026-11-24T23:35:19Z. **Review:** APPROVED --- Reviewed at `6c835cd` against `2119b0e`. Verification: - `victory-shader --lib` builds for `x86_64-pc-windows-gnu`. - The new `local_waves_select_their_console_bits_from_a_constant_mask` passes here (the hardware dispatch is skipped because this Wine host has no SM 6.6 device; DXIL validation and lowering still ran). - All six `emit::wave64_tests` pass under Wine. The change is correct: a local half-wave can select bits from a literal 64-bit mask because both host waves see the same constants and `lane_bit` relabels each wave's lanes through `console_lane()`. Computed masks still take the refusal path, and the condition requires both halves to be literal, so a partially computed wave64 mask is still rejected. `self.exchange.is_some()` is redundant with `self.local`, but harmless. Non-blocking: add a negative test that a computed mask (or a mask with only one literal half) is still refused in a local half-wave. That would lock in the boundary the new condition draws. LGTM.
HAL9000RELOADED commented 2026-11-25 20:09:27 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HAL9000RELOADED on 2026-11-25T19:29:45Z.


RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: the new test local_waves_select_their_console_bits_from_a_constant_mask passes on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (https://github.com/fxceless/victory-fork/pull/129#issuecomment-7172358511).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7172376346 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/277#issuecomment-7172376346). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T19:29:45Z. --- RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main `d510ee4`: the new test `local_waves_select_their_console_bits_from_a_constant_mask` passes on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (https://github.com/fxceless/victory-fork/pull/129#issuecomment-7172358511).
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/277:upstream-pr/277'
git switch 'upstream-pr/277'

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/277'
git switch 'upstream-pr/277'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/277'
git switch 'upstream-pr/277'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/277'
git switch 'main'
git merge --squash 'upstream-pr/277'
git switch 'main'
git merge --ff-only 'upstream-pr/277'
git switch 'main'
git merge 'upstream-pr/277'
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!277
No description provided.