Shaders: bitwise wave prefixes as WaveMultiPrefixOp #1328

Closed
github-bot wants to merge 1 commit from gh-pr/1328/head into gh-pr/1328/base
Owner

@⁠paulomatias97-create on GitHub · 2026-11-24 17:28 UTC · original
paulomatias97-create:shader/bitwise-wave-prefix → main · +137 −1 · 2 files · 1 commits · closed without merging

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

**@⁠paulomatias97-create** on GitHub · 2026-11-24 17:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1328) `paulomatias97-create:shader/bitwise-wave-prefix` → `main` · +137 −1 · 2 files · 1 commits · closed without merging 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
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.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CL4QZxTrzfn3nkthzLyAtV
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:43 +00:00
github-bot closed this pull request 2026-11-26 04:27:43 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 02:09 UTC · original

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 02:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1328#issuecomment-7150384982) ### 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:35 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 02:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1328#issuecomment-7150930078) <!-- 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)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:00 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1328#issuecomment-7175811232) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1328
No description provided.