Shaders: a select or carry-in on an untracked mask tests this lane's bit #1084

Open
undeadhuman37 wants to merge 1 commit from upstream-pr/1084 into main
undeadhuman37 commented 2026-11-24 15:36:50 +00:00 (Migrated from github.com)

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


v_cndmask_b32 and v_*_co_ci_u32 were refused when their scalar mask was not one that structure follows (a plain SGPR number). In compute with console lanes, the lane now tests its own bit of the register (the pair in wave64); inline 0 and -1 masks are constants.

Credit: this is taken from #585 (the mask part only). Its descriptor-dimension hunk is left out; that belongs with the resource work. It overlaps #585, so whichever merges first, the other should drop this hunk.

Measured offline over the shader corpus (26148 programs):

  • "a select on an untracked mask": 288 -> 0, with no new refusal text.
  • Those programs now stop at later refusals (descriptor read as data +205, unknown stride +32, descriptor address/format +33), so compute programs emitted only go 1441 -> 1443.

Tests: a synthetic hardware test fails before the change and passes after (run earlier on a GPU, not re-run for this PR). WARP cannot pin a wave size, so the test skips it. cargo clippy -p victory-shader --all-targets -- -D warnings is clean on this rebase.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585498133 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084). Originally posted by [undeadhuman37](https://github.com/undeadhuman37) on 2026-11-24T15:36:50Z. --- `v_cndmask_b32` and `v_*_co_ci_u32` were refused when their scalar mask was not one that `structure` follows (a plain SGPR number). In compute with console lanes, the lane now tests its own bit of the register (the pair in wave64); inline 0 and -1 masks are constants. **Credit:** this is taken from #585 (the mask part only). Its descriptor-dimension hunk is left out; that belongs with the resource work. It overlaps #585, so whichever merges first, the other should drop this hunk. Measured offline over the shader corpus (26148 programs): - "a select on an untracked mask": 288 -> 0, with no new refusal text. - Those programs now stop at later refusals (descriptor read as data +205, unknown stride +32, descriptor address/format +33), so compute programs emitted only go 1441 -> 1443. Tests: a synthetic hardware test fails before the change and passes after (run earlier on a GPU, not re-run for this PR). WARP cannot pin a wave size, so the test skips it. `cargo clippy -p victory-shader --all-targets -- -D warnings` is clean on this rebase. No game data. AI-assisted: written with Claude Code (Claude Sonnet 5.5). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
catminou4 commented 2026-11-24 17:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:29:02Z.

Review: APPROVED


v_cndmask_b32 and *_ci_u32 no longer hard-fail on untracked scalar masks: inline 0/-1 constants fold to bools, tracked masks keep the structure path, and plain SGPR masks fall back to per-lane bit tests (with wave64 hi dword and WAVE_OPS flag). The added guard extends cross-lane detection to these ops when the mask is untracked. The execution test is Windows-gated; lowering suite green here. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are #[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed.

<!-- greyfinch-sync:Marvisak/VIctory:review:6043263588 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#pullrequestreview-6043263588). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T16:29:02Z. **Review:** APPROVED --- v_cndmask_b32 and *_ci_u32 no longer hard-fail on untracked scalar masks: inline 0/-1 constants fold to bools, tracked masks keep the structure path, and plain SGPR masks fall back to per-lane bit tests (with wave64 hi dword and WAVE_OPS flag). The added guard extends cross-lane detection to these ops when the mask is untracked. The execution test is Windows-gated; lowering suite green here. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main ffe310e, `cargo test -p <crate> --locked`. Shader execution tests (valu_tests/host) are `#[cfg(all(test, windows))]`, so macOS covers lowering/decode/unit tests only. victory-shader: 96 passed, 0 failed.
jeremygold02 commented 2026-11-24 17:04:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T16:28:35Z.


I replayed 105 distinct compute shaders that VIctory had refused during one local RTX 5070 mission-loading trace, after a fence-confirmed texture readback. I matched the local inputs to the logged identifiers and compared the same inputs on ffe310e and 48a41fb. The replay ran the translator offline on Windows.

On main, 47 of the 105 stopped at the untracked-mask select. All 47 advanced on this PR. Their next reported reasons were:

Next translator refusal Distinct shaders
Descriptor read only as data 29
Structured buffer of unknown stride 7
Descriptor address or format read as data 6
Scalar memory read as data 4
Lane mask holding lanes elsewhere read as data 1

Both builds still refused all 105 inputs before producing DXIL. This confirms the specific lowering change reaches this mission’s shaders and identifies which refusal appears next. The replay did not execute any of these shaders or measure frame time. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137724648 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#issuecomment-7137724648). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T16:28:35Z. --- I replayed 105 distinct compute shaders that VIctory had refused during one local RTX 5070 mission-loading trace, after a fence-confirmed texture readback. I matched the local inputs to the logged identifiers and compared the same inputs on `ffe310e` and `48a41fb`. The replay ran the translator offline on Windows. On main, 47 of the 105 stopped at the untracked-mask select. All 47 advanced on this PR. Their next reported reasons were: | Next translator refusal | Distinct shaders | | --- | ---: | | Descriptor read only as data | 29 | | Structured buffer of unknown stride | 7 | | Descriptor address or format read as data | 6 | | Scalar memory read as data | 4 | | Lane mask holding lanes elsewhere read as data | 1 | Both builds still refused all 105 inputs before producing DXIL. This confirms the specific lowering change reaches this mission’s shaders and identifies which refusal appears next. The replay did not execute any of these shaders or measure frame time. AI-assisted.
Zipettte commented 2026-11-24 17:04:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:29:47Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 48a41fb: cargo test -p victory-shader passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137755226 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#issuecomment-7137755226). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T16:29:47Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 48a41fb: `cargo test -p victory-shader` passes, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
jtrudeau1530 commented 2026-11-24 18:05:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jtrudeau1530 on 2026-11-24T17:14:26Z.


Tested a local adaptation of 48a41fb together with #660 on an RX 7900 XT under Wine/vkd3d-proton. The adaptation reads the wave64 high word from the consuming instruction, requires it before the tracked-mask shortcut, and uses the exact low/high pair for that shortcut. Missing high-word metadata remains refused rather than becoming zero.

Synthetic GPU readbacks pass for all 128 threads with native wave32 and wave64 for v_cndmask_b32, v_add_co_ci_u32, v_sub_co_ci_u32, and v_subrev_co_ci_u32. The tests use unequal low/high words, rewrite only the high word between two uses, and cover inline 0/-1, root-driven uniform s_cselect, and tracked compares. Numeric masks alone must enable WAVE_OPS and pin the native wave size; no indexing instruction accidentally enables that path. Microsoft DXIL validation is mandatory. The same all-lane fixture on the unchanged parent fails at the original untracked-mask refusal.

Missing-high, rewritten-mask and divergent-carry negatives also remain refused. The latter now propagates the existing lane-mask-as-data refusal at the consuming store; its assertion checks the exact Unsupported location and reason. Hardware tests are explicitly invoked and fail if the physical adapter or validator is unavailable. This is compute-path validation of the adaptation, not a game-rendering or frame-time result, and does not resolve the later refusal groups reported above.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138896787 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#issuecomment-7138896787). Originally posted by [jtrudeau1530](https://github.com/jtrudeau1530) on 2026-11-24T17:14:26Z. --- Tested a local adaptation of `48a41fb` together with #660 on an RX 7900 XT under Wine/vkd3d-proton. The adaptation reads the wave64 high word from the consuming instruction, requires it before the tracked-mask shortcut, and uses the exact low/high pair for that shortcut. Missing high-word metadata remains refused rather than becoming zero. Synthetic GPU readbacks pass for all 128 threads with native wave32 and wave64 for `v_cndmask_b32`, `v_add_co_ci_u32`, `v_sub_co_ci_u32`, and `v_subrev_co_ci_u32`. The tests use unequal low/high words, rewrite only the high word between two uses, and cover inline 0/-1, root-driven uniform `s_cselect`, and tracked compares. Numeric masks alone must enable WAVE_OPS and pin the native wave size; no indexing instruction accidentally enables that path. Microsoft DXIL validation is mandatory. The same all-lane fixture on the unchanged parent fails at the original untracked-mask refusal. Missing-high, rewritten-mask and divergent-carry negatives also remain refused. The latter now propagates the existing lane-mask-as-data refusal at the consuming store; its assertion checks the exact Unsupported location and reason. Hardware tests are explicitly invoked and fail if the physical adapter or validator is unavailable. This is compute-path validation of the adaptation, not a game-rendering or frame-time result, and does not resolve the later refusal groups reported above.
justlovett0 commented 2026-11-24 19:04:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by justlovett0 on 2026-11-24T18:48:28Z.


Verified + integrated, with a runtime caveat. Stack: main ffe310e + #175/#994/#747/#302/#193/#704/#309/#953/#1067/#986/#1260/#1267/#1254/#1276/#189 (wave64 emulation), RTX 3080 10 GB / Win10 21H2 (19044.7846) / driver 621.24 (32.0.16.2124). Re-census of captured runtime containers; world stable ~9 min, 0 device removals.

Merged cleanly. Note: the offline untracked-mask gain did not transfer to our captured runtime containers — the "a lane mask read as data" (7) and "a lane mask holding lanes elsewhere read as data" (6) classes persist on the runtime "Wrapped" containers. The fix works on the offline archive; our runtime masks differ (likely loaded from memory rather than the spill/select patterns). Flagging so the offline count isn't read as a runtime guarantee.

AI use: Qwen Code; local measurements. No game data posted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141179241 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#issuecomment-7141179241). Originally posted by [justlovett0](https://github.com/justlovett0) on 2026-11-24T18:48:28Z. --- **Verified + integrated**, with a runtime caveat. Stack: main `ffe310e` + #175/#994/#747/#302/#193/#704/#309/#953/#1067/#986/#1260/#1267/#1254/#1276/#189 (wave64 emulation), RTX 3080 10 GB / Win10 21H2 (19044.7846) / driver 621.24 (32.0.16.2124). Re-census of captured runtime containers; world stable ~9 min, 0 device removals. Merged cleanly. Note: the offline untracked-mask gain did **not** transfer to our captured *runtime* containers — the "a lane mask read as data" (7) and "a lane mask holding lanes elsewhere read as data" (6) classes persist on the runtime "Wrapped" containers. The fix works on the offline archive; our runtime masks differ (likely loaded from memory rather than the spill/select patterns). Flagging so the offline count isn't read as a runtime guarantee. AI use: Qwen Code; local measurements. No game data posted.
Marvisak commented 2026-11-25 01:08:04 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148650635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#issuecomment-7148650635). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:34:20Z. --- <!-- victory-triage v1 head=48a41fb850ac37e4cdabfd94524fa11c595c0dcc verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/valu_tests.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
kais7654 commented 2026-11-25 16:09:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T15:30:52Z.


Picking this up: rebased your commit 48a41fb onto current main (940d32f),
authorship preserved — https://github.com/Marvisak/VIctory/compare/main...kais7654:VIctory:shader/untracked-mask-lane-bit

The merge conflicts were with the stride-heap and lane-detection work
that landed since; I resolved them along the lines discussed above
(lane_bit sets WAVE_OPS itself, so the mask path needs no separate
flag), and the test now runs through main's single-threaded GPU harness.
Clippy clean with -D warnings; the mask test passes on hardware.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166960124 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1084#issuecomment-7166960124). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T15:30:52Z. --- Picking this up: rebased your commit 48a41fb onto current main (940d32f), authorship preserved — https://github.com/Marvisak/VIctory/compare/main...kais7654:VIctory:shader/untracked-mask-lane-bit The merge conflicts were with the stride-heap and lane-detection work that landed since; I resolved them along the lines discussed above (`lane_bit` sets `WAVE_OPS` itself, so the mask path needs no separate flag), and the test now runs through main's single-threaded GPU harness. Clippy clean with -D warnings; the mask test passes on hardware.
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/1084:upstream-pr/1084'
git switch 'upstream-pr/1084'

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