Shaders: with pair meetings, a lane mask joined with a number is exchanged where the mask is written (on #3683) #3823

Open
redNSF wants to merge 86 commits from upstream-pr/3823 into main
redNSF commented 2026-11-29 06:45:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by redNSF on 2026-11-29T06:45:30Z.


Stacked on #3683 (pair meetings, itself on #439); the last commit is this change. It does not depend on #3759 (also on #3683); the two merge without conflicts.

Problem. A register that holds a lane mask on one way and a number on another is a number after the join, and the join takes the mask's number along its edge (fill_phis, "a lane mask joined with data at a join every lane enters along one edge"). The joins are filled in when no block is being lowered any more. With pair meetings the two halves of a console wave meet only in the block being lowered, so the exchange of the mask's two words was made behind the last block lowered, the program's end, after the join that reads it. defs_dominate_uses then refuses the program: "a value used before the meeting of the halves that makes it".

Change. Such a mask is exchanged in the block that writes it, right after the instruction (at the top of the block for a mask that is itself a join). The exchanged words are then made on every way to the join and kept for the whole program, as when an instruction of that block reads the mask as a number. The lowering finds these masks where it did, when it fills the joins, and lowers the program once more with them (Stop::Exchange, beside Stop::Retry); a program without such a join is lowered exactly as before. Both halves run the block that writes the mask, so they meet in step.

Effect. Grand Theft Auto VI, translate --list --host-lanes 32-32: compute programs that translate go from 2,619 (#3683) to 2,621 of 2,682; none are lost. The two gained are the two refused for this reason: cascadeshadows_rendering:CS_ShadowRenderTiledCascadesAlphaCBPPPC and CS_ShadowRenderTiledMiscAlphaPPPC. With #3759 merged in as well: 2,626.

Tests (RTX 3060, 32-lane waves only):

  • New a_mask_joined_with_a_number_translates_with_pair_meetings: a group of four console waves in which s[12:13] holds a number in the odd console waves and a 64-bit lane mask in the even ones (a compare the odd waves branch around), joined and read as a number. It translates; without this change it is refused with the reason above. Runs anywhere.
  • New a_mask_joined_with_a_number_is_the_console_waves_mask: that program on a 32-lane hardware adapter (skipped elsewhere): every thread of an even console wave stores its wave's mask, both dwords (one mask has lanes of both halves), every thread of an odd one the number.
  • cargo test -p victory-shader --lib on WARP: the same 4 synthetic_tests fail here as on #3683 alone. The pair meeting tests pass on the card.

Not run in the title yet: this PR claims that the two programs translate and that the join behaves as the test checks on this card.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5548369665 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3823). Originally posted by [redNSF](https://github.com/redNSF) on 2026-11-29T06:45:30Z. --- Stacked on #3683 (pair meetings, itself on #439); the last commit is this change. It does not depend on #3759 (also on #3683); the two merge without conflicts. **Problem.** A register that holds a lane mask on one way and a number on another is a number after the join, and the join takes the mask's number along its edge (`fill_phis`, "a lane mask joined with data at a join every lane enters along one edge"). The joins are filled in when no block is being lowered any more. With pair meetings the two halves of a console wave meet only in the block being lowered, so the exchange of the mask's two words was made behind the last block lowered, the program's end, after the join that reads it. `defs_dominate_uses` then refuses the program: "a value used before the meeting of the halves that makes it". **Change.** Such a mask is exchanged in the block that writes it, right after the instruction (at the top of the block for a mask that is itself a join). The exchanged words are then made on every way to the join and kept for the whole program, as when an instruction of that block reads the mask as a number. The lowering finds these masks where it did, when it fills the joins, and lowers the program once more with them (`Stop::Exchange`, beside `Stop::Retry`); a program without such a join is lowered exactly as before. Both halves run the block that writes the mask, so they meet in step. **Effect.** Grand Theft Auto VI, `translate --list --host-lanes 32-32`: compute programs that translate go from 2,619 (#3683) to 2,621 of 2,682; none are lost. The two gained are the two refused for this reason: `cascadeshadows_rendering:CS_ShadowRenderTiledCascadesAlphaCBPPPC` and `CS_ShadowRenderTiledMiscAlphaPPPC`. With #3759 merged in as well: 2,626. **Tests** (RTX 3060, 32-lane waves only): - New `a_mask_joined_with_a_number_translates_with_pair_meetings`: a group of four console waves in which s[12:13] holds a number in the odd console waves and a 64-bit lane mask in the even ones (a compare the odd waves branch around), joined and read as a number. It translates; without this change it is refused with the reason above. Runs anywhere. - New `a_mask_joined_with_a_number_is_the_console_waves_mask`: that program on a 32-lane hardware adapter (skipped elsewhere): every thread of an even console wave stores its wave's mask, both dwords (one mask has lanes of both halves), every thread of an odd one the number. - `cargo test -p victory-shader --lib` on WARP: the same 4 `synthetic_tests` fail here as on #3683 alone. The pair meeting tests pass on the card. Not run in the title yet: this PR claims that the two programs translate and that the join behaves as the test checks on this card. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
kilolimaVI commented 2026-11-29 17:17:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-29T17:17:11Z.


AMD run on a Radeon 780M (RDNA3, wave32 and wave64), #3823 + #3824 + #3830 merged together (they merge clean) onto main 63bcca4, cargo test --profile diag -p <crate> --locked --lib:

victory-shader victory-gpu
main 302 passed, 0 failed 231 passed, 0 failed
#3823 + #3824 + #3830 356 passed, 0 failed 232 passed, 0 failed

No regressions on AMD, and the pair-meeting tests pass on a card that can also run the console's wave64 natively. #3822 takes the other approach to the same problem and also passes everything here (340 / 232); the two conflict, so this is just data for choosing.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7259570019 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3823#issuecomment-7259570019). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-29T17:17:11Z. --- AMD run on a Radeon 780M (RDNA3, wave32 and wave64), #3823 + #3824 + #3830 merged together (they merge clean) onto main 63bcca4, `cargo test --profile diag -p <crate> --locked --lib`: | | victory-shader | victory-gpu | |---|---|---| | main | 302 passed, 0 failed | 231 passed, 0 failed | | #3823 + #3824 + #3830 | 356 passed, 0 failed | 232 passed, 0 failed | No regressions on AMD, and the pair-meeting tests pass on a card that can also run the console's wave64 natively. #3822 takes the other approach to the same problem and also passes everything here (340 / 232); the two conflict, so this is just data for choosing. AI-assisted (Claude).
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/3823:upstream-pr/3823'
git switch 'upstream-pr/3823'

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