Shaders: bitwise wave prefixes as WaveMultiPrefixOp #1328

Closed
paulomatias97-create wants to merge 1 commit from upstream-pr/1328 into main
paulomatias97-create commented 2026-11-24 17:28:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by paulomatias97-create on 2026-11-24T17:28:54Z.


A whole-wave section the simulation finds to be an OR, AND or XOR prefix failed the translation ("a wave prefix of an operation other than a sum"). DXIL has no plain bitwise prefix, but WaveMultiPrefixOp over one partition holding every active lane is one: exclusive, with the identity in the first lane, the lane's own value joined for an inclusive prefix. Inactive lanes already hold the identity. Minimum and maximum prefixes still fail, now under their own reason.

Claude-Session: https://claude.ai/code/session_01CL4QZxTrzfn3nkthzLyAtV

<!-- greyfinch-sync:Marvisak/VIctory:issue:6587622766 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1328). Originally posted by [paulomatias97-create](https://github.com/paulomatias97-create) on 2026-11-24T17:28:54Z. --- A whole-wave section the simulation finds to be an OR, AND or XOR prefix failed the translation ("a wave prefix of an operation other than a sum"). DXIL has no plain bitwise prefix, but WaveMultiPrefixOp over one partition holding every active lane is one: exclusive, with the identity in the first lane, the lane's own value joined for an inclusive prefix. Inactive lanes already hold the identity. Minimum and maximum prefixes still fail, now under their own reason. Claude-Session: https://claude.ai/code/session_01CL4QZxTrzfn3nkthzLyAtV
catminou4 commented 2026-11-24 21:02:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:48Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests.

Bitwise wave prefixes lower as WaveMultiPrefixOp; or_prefix_cs synthetic test verifies the multi-prefix shape.

<!-- greyfinch-sync:Marvisak/VIctory:review:6046557366 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1328#pullrequestreview-6046557366). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:09:48Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and only run on Windows; macOS covers lowering/structure/IR unit tests. Bitwise wave prefixes lower as WaveMultiPrefixOp; or_prefix_cs synthetic test verifies the multi-prefix shape.
sinan-cmyk commented 2026-11-25 03:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T02:09:30Z.


Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 9182328 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150384982 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1328#issuecomment-7150384982). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T02:09:30Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 9182328 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 121, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 03:03:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:35:51Z.


Automated triage for the maintainers.

Recommended for a maintainer's look. In Lower's wave-reduction lowering (emit/lower.rs), OR/AND/XOR prefixes now lower to WaveMultiPrefixOp (DXIL op 166) instead of failing. They use one partition mask taken from WaveActiveBallot(true) (op 116), and the lane's own value is joined for an inclusive prefix. I checked the op numbers, argument order and op kinds (And=1, Or=2, Xor=3) against the public DXIL operation list. A single all-active-lanes partition gives an exclusive prefix with the identity in the first lane, inactive lanes already hold the identity through the existing select, and mesh programs still refuse prefixes earlier in the function. The new test in emit/mod.rs checks that the simulation sees the OR prefix and that the output validates. A GPU readback test comparing against the expected prefix would make it stronger. No CI ran on this head; a contributor reports victory-shader tests passing on an RTX 4070 SUPER.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150930078 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1328#issuecomment-7150930078). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:35:51Z. --- <!-- victory-triage v1 head=91823286336dd4c108409234d43cb66c2a234837 verdict=merge-candidate at=2026-11-25T02:20:29Z --> Automated triage for the maintainers. Recommended for a maintainer's look. In `Lower`'s wave-reduction lowering (`emit/lower.rs`), OR/AND/XOR prefixes now lower to `WaveMultiPrefixOp` (DXIL op 166) instead of failing. They use one partition mask taken from `WaveActiveBallot(true)` (op 116), and the lane's own value is joined for an inclusive prefix. I checked the op numbers, argument order and op kinds (And=1, Or=2, Xor=3) against the public DXIL operation list. A single all-active-lanes partition gives an exclusive prefix with the identity in the first lane, inactive lanes already hold the identity through the existing `select`, and mesh programs still refuse prefixes earlier in the function. The new test in `emit/mod.rs` checks that the simulation sees the OR prefix and that the output validates. A GPU readback test comparing against the expected prefix would make it stronger. No CI ran on this head; a contributor reports `victory-shader` tests passing on an RTX 4070 SUPER. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:02:55 +00:00
Marvisak commented 2026-11-25 22:04:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:00:09Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because the emitted code cannot be used on the hosts tested. A GPU readback of this PR's own test program (or_prefix_cs) failed at pipeline creation both times on an RX 6700 XT with the device removed, and WARP refused it with E_INVALIDARG. A control with the three v_or_b32 turned into adds, which takes main's wavePrefixOp path, built every time and returned the right prefix sums. No title program is refused for this reason on main either.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175811232 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1328#issuecomment-7175811232). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:00:09Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because the emitted code cannot be used on the hosts tested. A GPU readback of this PR's own test program (`or_prefix_cs`) failed at pipeline creation both times on an RX 6700 XT with the device removed, and WARP refused it with `E_INVALIDARG`. A control with the three `v_or_b32` turned into adds, which takes `main`'s `wavePrefixOp` path, built every time and returned the right prefix sums. No title program is refused for this reason on `main` either. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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
Marvisak/VIctory!1328
No description provided.