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
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#1115
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@A6thGraderFr on GitHub · 2026-11-24 15:50 UTC · original
On main (
ffe310e), av_cndmask_b32whose mask is SCC turned into all lanes or none, the compilers' usual form of a select on a uniform condition, does not translate:Constant masks (
s_mov_b32 s2, -1or0,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 withself.mask(k). For these masks it gets the SCC value in every lane (Atom::Uniform) or a constant. Butmask()files masks that derive from neither EXEC nor a VALU result inother, andfinish()exports onlymasks. Thev_cndmask_b32lowering (emit/lower.rs) looks only inst.masks, so it refuses. These values can't simply joinst.masks:reads_mask_as_dataandLower::gettreat everything there as a lane mask, so data uses of ans_cselect -1, 0would start failing.Fix: branch
shader/uniform-select-maskson A6thGraderFr/victoryOne commit, 0b3bd70, on top of
ffe310e(+75/−2, two files):Structured::uniform_selectswhen it is not derived and is the same in every lane (itssupportholds onlyAtom::Uniform, or it is a constant). It is keyed by the value the select writes, so wave64 pairs are exact.v_cndmask_b32takesst.masks, elsest.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
emit::lower::tests::selects_on_masks_the_same_in_every_lane_need_no_lane_index. Six mask forms (wave32 and wave64) lower withwave_ops == false, and a lane-dependent mask (s_lshl_b32 s2, 1, s0) is still refused. On main the test fails with0x850280c1: ... a select on an untracked mask is not supported.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 warningsis clean in both CI configurations.cargo xtask policy: 154 files ok.llvm-dis/llifrom LLVM 18 with small stubs for thedx.opcalls. 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 comparevictory translate --listbefore and after.Related
#69 and #585 also change the
v_cndmask_b32lowering. 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 sameothermasks for console-flow joins.No game data used. Made with Claude Code (AI-assisted).
@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_cselectto-1/0thenv_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 yourLanes::stepanalysis 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 forcndmaskwith constant, SCC-derived, and EXEC-ANDed masks — I can push our probe list against yourstructure.rstests 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 — thes_cselect s2, exec, 0boundary (works) vs-1/0constants (fails) is exactly the line a correct unifier must straddle.@DrDarkDK on GitHub · 2026-11-24 16:04 UTC · original
Ran
victory translate --validate --listonffe310eand0b3bd70over 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 288a select on an untracked maskrefusals. Both builds validated 21,736 programs.I also tested a synthetic compute shader that uses the same SCC-derived mask for
v_cndmask_b32and then reads it as an ordinary scalar for XOR. The parent refused it during lowering.0b3bd70returned the expected values for both SCC outcomes on the RTX 4070 Ti and WARP.No gameplay test.
AI-assisted with Codex.
@Marvisak on GitHub · 2026-11-25 10:03 UTC · original
Automated triage for the maintainers.
Fixed in
mainby PR #1221 (merged as67c4f53).Lanes::finishincrates/victory-shader/src/structure.rsnow exports theothermasks in a newStructured::other. Thev_cndmask_b32lowering incrates/victory-shader/src/emit/lower.rs(Lower) looks there when a mask is not inst.masks. So an SCC-deriveds_cselect -1, 0or an SGPR set to a constant no longer hits "a select on an untracked mask". The lowering also takes an inline-1or0mask operand directly. Your branchshader/uniform-select-masksis no longer needed for this case. If one of your mask forms is still refused on currentmain, 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
mainwould 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