Shaders: selects on a uniform mask (s_cselect -1, 0; constants) are refused as "a select on an untracked mask" in every stage (fix on a fork) #1115

Open
opened 2026-11-26 04:20:25 +00:00 by github-bot · 3 comments
Owner

@⁠A6thGraderFr on GitHub · 2026-11-24 15:50 UTC · original

On main (ffe310e), a v_cndmask_b32 whose mask is SCC turned into all lanes or none, the compilers' usual form of a select on a uniform condition, does not translate:

s_cmp_eq_u32 s0, s1
s_cselect_b32 s2, -1, 0          // or s_cselect_b64 s[2:3], -1, 0
v_cndmask_b32 v1, v3, v4, s2     // "a select on an untracked mask is not supported"

Constant masks (s_mov_b32 s2, -1 or 0, s_mov_b64 s[2:3], -1) fail the same way. s_cselect s2, exec, 0, or the same uniform mask ANDed with a compare, already translate.

Why

Lanes::step (crates/victory-shader/src/structure.rs) resolves the select's mask with self.mask(k). For these masks it gets the SCC value in every lane (Atom::Uniform) or a constant. But mask() files masks that derive from neither EXEC nor a VALU result in other, and finish() exports only masks. The v_cndmask_b32 lowering (emit/lower.rs) looks only in st.masks, so it refuses. These values can't simply join st.masks: reads_mask_as_data and Lower::get treat everything there as a lane mask, so data uses of an s_cselect -1, 0 would start failing.

Fix: branch shader/uniform-select-masks on A6thGraderFr/victory

One commit, 0b3bd70, on top of ffe310e (+75/−2, two files):

  • structure.rs keeps the select's mask in a new Structured::uniform_selects when it is not derived and is the same in every lane (its support holds only Atom::Uniform, or it is a constant). It is keyed by the value the select writes, so wave64 pairs are exact.
  • lower.rs: v_cndmask_b32 takes st.masks, else st.uniform_selects.

Every lane picks the same source, so no lane index or wave operation is involved. The fix therefore works in pixel, vertex, mesh and compute, wave32 and wave64, on any host. Masks whose lanes differ stay refused with the same message, and nothing else changes.

Tests

  • New emit::lower::tests::selects_on_masks_the_same_in_every_lane_need_no_lane_index. Six mask forms (wave32 and wave64) lower with wave_ops == false, and a lane-dependent mask (s_lshl_b32 s2, 1, s0) is still refused. On main the test fails with 0x850280c1: ... a select on an untracked mask is not supported.
  • Linux, Rust 1.98.1:
    • cargo test -p victory-shader: 97 passed, 1 ignored. The formats, core, pipeline, game and xtask tests also pass.
    • cargo clippy --workspace --all-targets [--all-features] --target x86_64-pc-windows-msvc -- -D warnings is clean in both CI configurations.
    • cargo xtask policy: 154 files ok.
  • Values: I ran the emitted DXIL on the CPU, using llvm-dis/lli from LLVM 18 with small stubs for the dx.op calls. I checked 16 wave32 mask forms with 8 inputs each and 4 wave64 forms with 4 inputs each against what RDNA2 computes. All pick the right source, including the compare masks that already worked. The same harness found no mismatch in about 150 other VALU/SALU instructions on main. Nothing was run on a GPU or with game data.

Scope

The census in #293 (WuDiXiaoBo, ffe310e) counts 288 programs refused with "a select on an untracked mask". I don't know how many of them select on a uniform mask rather than one whose lanes differ. Someone with the retail shaders could compare victory translate --list before and after.

#69 and #585 also change the v_cndmask_b32 lowering. They read untracked masks as numbers in compute shaders with console lanes. This change is stage-independent and needs no lane numbering, so the two compose; whichever lands second needs a small rebase. #320/#439 export the same other masks for console-flow joins.

No game data used. Made with Claude Code (AI-assisted).

**@⁠A6thGraderFr** on GitHub · 2026-11-24 15:50 UTC · [original](https://github.com/Marvisak/VIctory/issues/1115) On main (ffe310e), a `v_cndmask_b32` whose mask is SCC turned into all lanes or none, the compilers' usual form of a select on a uniform condition, does not translate: ``` s_cmp_eq_u32 s0, s1 s_cselect_b32 s2, -1, 0 // or s_cselect_b64 s[2:3], -1, 0 v_cndmask_b32 v1, v3, v4, s2 // "a select on an untracked mask is not supported" ``` Constant masks (`s_mov_b32 s2, -1` or `0`, `s_mov_b64 s[2:3], -1`) fail the same way. `s_cselect s2, exec, 0`, or the same uniform mask ANDed with a compare, already translate. ### Why `Lanes::step` (crates/victory-shader/src/structure.rs) resolves the select's mask with `self.mask(k)`. For these masks it gets the SCC value in every lane (`Atom::Uniform`) or a constant. But `mask()` files masks that derive from neither EXEC nor a VALU result in `other`, and `finish()` exports only `masks`. The `v_cndmask_b32` lowering (emit/lower.rs) looks only in `st.masks`, so it refuses. These values can't simply join `st.masks`: `reads_mask_as_data` and `Lower::get` treat everything there as a lane mask, so data uses of an `s_cselect -1, 0` would start failing. ### Fix: branch [`shader/uniform-select-masks`](https://github.com/A6thGraderFr/victory/tree/shader/uniform-select-masks) on A6thGraderFr/victory One commit, [0b3bd70](https://github.com/A6thGraderFr/victory/commit/0b3bd70), on top of ffe310e (+75/−2, two files): - structure.rs keeps the select's mask in a new `Structured::uniform_selects` when it is not derived and is the same in every lane (its `support` holds only `Atom::Uniform`, or it is a constant). It is keyed by the value the select writes, so wave64 pairs are exact. - lower.rs: `v_cndmask_b32` takes `st.masks`, else `st.uniform_selects`. Every lane picks the same source, so no lane index or wave operation is involved. The fix therefore works in pixel, vertex, mesh and compute, wave32 and wave64, on any host. Masks whose lanes differ stay refused with the same message, and nothing else changes. ### Tests - New `emit::lower::tests::selects_on_masks_the_same_in_every_lane_need_no_lane_index`. Six mask forms (wave32 and wave64) lower with `wave_ops == false`, and a lane-dependent mask (`s_lshl_b32 s2, 1, s0`) is still refused. On main the test fails with `0x850280c1: ... a select on an untracked mask is not supported`. - Linux, Rust 1.98.1: - `cargo test -p victory-shader`: 97 passed, 1 ignored. The formats, core, pipeline, game and xtask tests also pass. - `cargo clippy --workspace --all-targets [--all-features] --target x86_64-pc-windows-msvc -- -D warnings` is clean in both CI configurations. - `cargo xtask policy`: 154 files ok. - Values: I ran the emitted DXIL on the CPU, using `llvm-dis`/`lli` from LLVM 18 with small stubs for the `dx.op` calls. I checked 16 wave32 mask forms with 8 inputs each and 4 wave64 forms with 4 inputs each against what RDNA2 computes. All pick the right source, including the compare masks that already worked. The same harness found no mismatch in about 150 other VALU/SALU instructions on main. Nothing was run on a GPU or with game data. ### Scope The census in #293 (WuDiXiaoBo, ffe310e) counts 288 programs refused with "a select on an untracked mask". I don't know how many of them select on a uniform mask rather than one whose lanes differ. Someone with the retail shaders could compare `victory translate --list` before and after. ### Related #69 and #585 also change the `v_cndmask_b32` lowering. They read untracked masks as numbers in compute shaders with console lanes. This change is stage-independent and needs no lane numbering, so the two compose; whichever lands second needs a small rebase. #320/#439 export the same `other` masks for console-flow joins. No game data used. Made with Claude Code (AI-assisted).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:20:25 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-24 15:55 UTC · original

Sibling-runtime note (ivall/xcl translates the same RDNA2 ISA): the pattern class in this issue — s_cselect to -1/0 then v_cndmask — is fully supported on our side as an ordinary scalar select: an SGPR mask that is provably uniform lowers to a scalar ternary and does not enter vector lane-mask tracking at all, which is exactly the structural fix your Lanes::step analysis points at (uniform-mask ⇒ no mask tracking needed, by construction, not by a widening allowlist). Worth a differential when your fix lands: we carry lowering probes for cndmask with constant, SCC-derived, and EXEC-ANDed masks — I can push our probe list against your structure.rs tests so the two projects converge on one corpus for this class instead of two. No ask otherwise; the repro table at the top is ideal — the s_cselect s2, exec, 0 boundary (works) vs -1/0 constants (fails) is exactly the line a correct unifier must straddle.

**@⁠pickles976** on GitHub · 2026-11-24 15:55 UTC · [original](https://github.com/Marvisak/VIctory/issues/1115#issuecomment-7136850720) Sibling-runtime note (ivall/xcl translates the same RDNA2 ISA): the pattern class in this issue — `s_cselect` to `-1`/`0` then `v_cndmask` — is **fully supported on our side as an ordinary scalar select**: an SGPR mask that is provably uniform lowers to a scalar ternary and does not enter vector lane-mask tracking at all, which is exactly the structural fix your `Lanes::step` analysis points at (uniform-mask ⇒ no mask tracking needed, by construction, not by a widening allowlist). Worth a differential when your fix lands: we carry lowering probes for `cndmask` with constant, SCC-derived, and EXEC-ANDed masks — I can push our probe list against your `structure.rs` tests so the two projects converge on one corpus for this class instead of two. No ask otherwise; the repro table at the top is ideal — the `s_cselect s2, exec, 0` boundary (works) vs `-1/0` constants (fails) is exactly the line a correct unifier must straddle.
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-24 16:04 UTC · original

Ran victory translate --validate --list on ffe310e and 0b3bd70 over the same local 1.0.2.1 executable and shader archive, using DXIL validator 1.9.2602.17. Both scans covered 26,096 programs. All 25,901 matched per-program outcomes were identical, including the same 288 a select on an untracked mask refusals. Both builds validated 21,736 programs.

I also tested a synthetic compute shader that uses the same SCC-derived mask for v_cndmask_b32 and then reads it as an ordinary scalar for XOR. The parent refused it during lowering. 0b3bd70 returned the expected values for both SCC outcomes on the RTX 4070 Ti and WARP.

No gameplay test.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-24 16:04 UTC · [original](https://github.com/Marvisak/VIctory/issues/1115#issuecomment-7137089550) Ran `victory translate --validate --list` on `ffe310e` and `0b3bd70` over the same local 1.0.2.1 executable and shader archive, using DXIL validator 1.9.2602.17. Both scans covered 26,096 programs. All 25,901 matched per-program outcomes were identical, including the same 288 `a select on an untracked mask` refusals. Both builds validated 21,736 programs. I also tested a synthetic compute shader that uses the same SCC-derived mask for `v_cndmask_b32` and then reads it as an ordinary scalar for XOR. The parent refused it during lowering. `0b3bd70` returned the expected values for both SCC outcomes on the RTX 4070 Ti and WARP. No gameplay test. *AI-assisted with Codex.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:03 UTC · original

Automated triage for the maintainers.

Fixed in main by PR #1221 (merged as 67c4f53). Lanes::finish in crates/victory-shader/src/structure.rs now exports the other masks in a new Structured::other. The v_cndmask_b32 lowering in crates/victory-shader/src/emit/lower.rs (Lower) looks there when a mask is not in st.masks. So an SCC-derived s_cselect -1, 0 or an SGPR set to a constant no longer hits "a select on an untracked mask". The lowering also takes an inline -1 or 0 mask operand directly. Your branch shader/uniform-select-masks is no longer needed for this case. If one of your mask forms is still refused on current main, please reply with that form, and your test can go into a pull request (pull requests are open to everyone).

The comment above found the same 288 retail refusals with and without the fork commit. A count on current main would show what #1221 changed there.

Proposed close (fixed in main): this issue will be closed in 48 hours unless the reporter replies or a maintainer removes the label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:03 UTC · [original](https://github.com/Marvisak/VIctory/issues/1115#issuecomment-7159162078) <!-- victory-issue-triage v1 verdict=proposed-close seen=2026-11-24T16:04:59Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. Fixed in `main` by PR #1221 (merged as `67c4f53`). `Lanes::finish` in `crates/victory-shader/src/structure.rs` now exports the `other` masks in a new `Structured::other`. The `v_cndmask_b32` lowering in `crates/victory-shader/src/emit/lower.rs` (`Lower`) looks there when a mask is not in `st.masks`. So an SCC-derived `s_cselect -1, 0` or an SGPR set to a constant no longer hits "a select on an untracked mask". The lowering also takes an inline `-1` or `0` mask operand directly. Your branch `shader/uniform-select-masks` is no longer needed for this case. If one of your mask forms is still refused on current `main`, please reply with that form, and your test can go into a pull request (pull requests are open to everyone). The comment above found the same 288 retail refusals with and without the fork commit. A count on current `main` would show what #1221 changed there. Proposed close (fixed in `main`): this issue will be closed in 48 hours unless the reporter replies or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#1115
No description provided.