Shaders: a scalar joining a lane mask and a number lowers in pixel and vertex programs #1073

Closed
undeadhuman37 wants to merge 1 commit from upstream-pr/1073 into main
undeadhuman37 commented 2026-11-24 15:28:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by undeadhuman37 on 2026-11-24T15:28:29Z.


A register can hold a compare result's high dword on one path and a loaded number on another. The join's mask side was refused as "a lane mask read as data". A pixel or vertex program now takes the mask's ballot as that incoming value (counts and zero tests mean the same on any wave size).

Known limit: the ballot is the host wave's, so a join read some other way would differ from the console.

Measured offline over the shader corpus (26148 programs):

  • "a lane mask read as data": 250 -> 212
  • vertex/pixel programs emitted: 12243 -> 12250 (the other 31 move on to descriptor / scalar-memory refusals)

Tests: a synthetic wave64 pixel program fails to lower before the change and lowers after. cargo clippy -p victory-shader --all-targets -- -D warnings is clean. Not run on a GPU, hence draft.

No game data. AI-assisted: written with Claude Code (Claude Sonnet 5.5).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585322280 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1073). Originally posted by [undeadhuman37](https://github.com/undeadhuman37) on 2026-11-24T15:28:29Z. --- A register can hold a compare result's high dword on one path and a loaded number on another. The join's mask side was refused as "a lane mask read as data". A pixel or vertex program now takes the mask's ballot as that incoming value (counts and zero tests mean the same on any wave size). Known limit: the ballot is the host wave's, so a join read some other way would differ from the console. Measured offline over the shader corpus (26148 programs): - "a lane mask read as data": 250 -> 212 - vertex/pixel programs emitted: 12243 -> 12250 (the other 31 move on to descriptor / scalar-memory refusals) Tests: a synthetic wave64 pixel program fails to lower before the change and lowers after. `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean. Not run on a GPU, hence draft. No game data. AI-assisted: written with Claude Code (Claude Sonnet 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DenRakEiw commented 2026-11-24 16:04:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T15:32:51Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • cargo test -p victory-shader: 121 passed, 0 failed, 1 ignored (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP)
  • cargo clippy -p victory-shader --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean lowering of mixed lane-mask/number scalar joins across pixel and vertex stages. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6042295031 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1073#pullrequestreview-6042295031). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T15:32:51Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP**: - `cargo test -p victory-shader`: **121 passed, 0 failed, 1 ignored** (all hardware + WARP VALU/waterfall/diff tests green on RTX 5090 and WARP) - `cargo clippy -p victory-shader --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean lowering of mixed lane-mask/number scalar joins across pixel and vertex stages. Approving. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 16:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T15:37:32Z.

Review: COMMENTED


Draft noted — the lowering change is the same hunk as #1074 (emit/lower.rs identical, same index line), and #1074 additionally carries the structure.rs spilled-lane tracking plus a second test. If both are meant to land, #1074 subsumes this one; if this is the smaller first step, say so and I'll review it as such.

On the change itself: the ballot fallback for a mask dword joined with a number is a pragmatic approximation, and the comment is honest about its limit (a join read any other way than a zero test/count would diverge from console). Two things worth pinning before it leaves draft: (1) a host-execution test on the Windows lane showing the joined value is only ever consumed by a zero test or count in the programs this targets, since the fallback silently changes semantics otherwise; (2) the ballot_ok gate requires def_block != cur_ir — a same-block join still refuses, which is the safe direction, but worth a test so the boundary is intentional.

Verified locally: test-merge with main clean; cargo test -p victory-shader --locked (macOS arm64, rustc 1.98.1) → 97 passed / 0 failed / 1 ignored (the new emit test runs on macOS).

<!-- greyfinch-sync:Marvisak/VIctory:review:6042384111 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1073#pullrequestreview-6042384111). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T15:37:32Z. **Review:** COMMENTED --- Draft noted — the lowering change is the same hunk as #1074 (`emit/lower.rs` identical, same index line), and #1074 additionally carries the `structure.rs` spilled-lane tracking plus a second test. If both are meant to land, #1074 subsumes this one; if this is the smaller first step, say so and I'll review it as such. On the change itself: the ballot fallback for a mask dword joined with a number is a pragmatic approximation, and the comment is honest about its limit (a join read any other way than a zero test/count would diverge from console). Two things worth pinning before it leaves draft: (1) a host-execution test on the Windows lane showing the joined value is only ever consumed by a zero test or count in the programs this targets, since the fallback silently changes semantics otherwise; (2) the `ballot_ok` gate requires `def_block != cur_ir` — a same-block join still refuses, which is the safe direction, but worth a test so the boundary is intentional. Verified locally: test-merge with main clean; `cargo test -p victory-shader --locked` (macOS arm64, rustc 1.98.1) → **97 passed / 0 failed / 1 ignored** (the new emit test runs on macOS).
upstream-sync closed this pull request 2026-11-25 01:05:27 +00:00
Marvisak commented 2026-11-25 01:07:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:31:38Z.


Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Draft. A register joining a mask and a number in pixel/vertex programs: main resolves these joins by proving the mask edge dead or the join data (dead_on_edge, live_edges, joins_loaded; 0b35b7fe, a7fc47af), 250 to 4 programs, without taking a host-wave ballot as the console's number.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148598452 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1073#issuecomment-7148598452). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:31:38Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Draft. A register joining a mask and a number in pixel/vertex programs: main resolves these joins by proving the mask edge dead or the join data (dead_on_edge, live_edges, joins_loaded; 0b35b7fe, a7fc47af), 250 to 4 programs, without taking a host-wave ballot as the console's number. If this is mistaken, reply here with what was missed (or push a change and say so) 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!1073
No description provided.