victory-shader: resolve Structured::other and constant masks in v_cndmask_b32 #1221
No reviewers
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!1221
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1221/head"
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?
@bartikele on GitHub · 2026-11-24 16:30 UTC · original
bartikele:shader-cndmask-other-masks→main· +53 −7 · 2 files · 1 commits · merged 2026-11-25 00:21 UTCExpose
Structured::other(masks resolved bystructurethat do not derive fromEXECorVALU, such ass_cselect, constants, and opaque scalar masks) without adding them toStructured::masks(soLower::sopdoes not treat ordinary scalar data as lane masks).In
Lower::valuforv_cndmask_b32:self.x.st.otherwhensrc[2]is not inself.x.st.masks.Operand::Constinline constants (0,-1, and console-lane bitmasks).Adds unit test
emit::lower::tests::v_cndmask_accepts_uniform_and_constant_masks.Tested with:
cargo clippy -p victory-shader --all-targets --locked -- -D warningscargo test -p victory-shader --locked@MichaelSmithAI on GitHub · 2026-11-24 16:38 UTC · original
Independent GPU check on
67c4f53, with an RTX 4090 under Wine and Microsoft DXIL validation. We assembledv_cndmask_b32_e64 v0, 7, 11, s6for gfx1030 and ran it with one active lane for each of four scalar inputs (0, 1, 2, 3).s_cselect_b32to select −1 or 0Both results also matched on our comparison build containing #385. On
ffe310eboth shaders stopped before emission with “a select on an untracked mask”. The four values above are separate input cases. This fixture exercises bit zero only.The direct-inline case has a separate coverage boundary. LLVM’s gfx1030 assembler rejected 0, −1 and 1 in the mask operand position, so our live tests used the scalar-register encoding. For #1119, the reported hash and refusal text leave the mask source unknown.
@fuzeofficlal on GitHub · 2026-11-24 17:02 UTC · original
One correctness caveat with exposing all of
Structured::otherdirectly tov_cndmask_b32:Lanesalso recordsAtom::Opaque/ arbitrary non-uniform bitmasks (for examples_lshl_b32 s2, 1, s0ors_mov_b32 s2, 0x0000ffff, wherev_cndmask_b32selects bit(s2 >> lane_id) & 1per lane) inother. Lowering those throughself.boolean(m, c)treats the whole wave as taking the same scalar branch instead of refusing an untracked per-lane bitmask. Filteringself.b.support(m)toAtom::Uniform(_)atoms only (as in #1270) acceptss_cselect-1/0and all-zero/all-ones constants while keeping per-lane bitmasks rejected.@bartikele on GitHub · 2026-11-24 17:15 UTC · original
Thanks for checking @fuzeofficlal! Note that
Lower::booleanalready differentiates the two cases:!self.console_lanes, i.e., VS/PS/MS),Atom::Opaque(_)still fails withErr("an opaque lane mask")— it never collapses the wave to a single scalar branch.self.console_lanes),Atom::Opaque(v)lowers viaself.lane_bit(at, lo, hi), which extracts bit(v >> lane_id) & 1per lane (matching the console's 32/64-bit per-lane bitmask semantics, as also verified by @MichaelSmithAI'ss6numeric bitmask test above).So arbitrary non-uniform bitmasks in
otherare only accepted in compute wherelane_bitis exact per lane, and rejected in graphics stages.@pablogonz12 on GitHub · 2026-11-24 17:27 UTC · original
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you handle, so this is a no-regression result only (same 10 SPIR-V validation failures as the base).
Not tested: in-game.
@Zipettte on GitHub · 2026-11-24 17:59 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
67c4f53:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: +2 programs over
main, 0 lost.Offline. I merged head
67c4f53ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,726 with this PR.mainBoth are among the programs that #1319 gains. Another 205 programs move from "a select on an untracked mask" on to "a descriptor read only as data", the reason #1067 handles. So this PR may gain more stacked on #1402, and I'm measuring that.
Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@sinan-cmyk on GitHub · 2026-11-24 20:31 UTC · original
Stacked on #1402: no change
Result: 0 gained, 0 lost, and no failure reason changes on top of #1402. On
mainthis PR gained 2 programs and moved 205 from "a select on an untracked mask" to "a descriptor read only as data" (earlier comment). #1402 already gains those programs through #1319, so nothing is left for this PR on this data.The merge. The merge with #1402 conflicts in the
v_cndmask_b32arm ofemit/lower.rs. #1402 moved that arm into amask_condhelper. This PR rewrites the same arm: it falls back toStructured::othermasks and accepts general constant masks. I kept themask_condcall and added this PR's two cases in front of it at this call site, together with theWAVE_OPSflag thatmask_condsets beforelane_bit. Thestructure.rschange merges cleanly. Tests: 138 passed, 0 failed, includingv_cndmask_accepts_uniform_and_constant_masks.Together with #1423 on #1402. One program that validates with #1423 alone fails again at "a lane-mask join of an untracked mask" (+213 instead of +214). On this data, this PR adds no gain on top of #1402 and costs that one program when stacked with #1423.
Method:
victory translate --validate --listonshaders.rpf(1.0.2.1), dxil.dll 1.8.2502.11, compared program by program (25,889 programs). No shader names or data are included, per the asset policy. AI-assisted (Claude Code).