Shaders: a wave32 program's mask read picks its half of a 64-lane ballot #434
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!434
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-434"
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?
@NolanCotter on GitHub · 2026-11-24 03:20 UTC · original
NolanCotter:agent/host-wave-mask-halves→main· +263 −13 · 2 files · 3 commits · openAI-assisted (Devin). Fixes #131.
Summary
For
MaskData::Host(pixel and vertex stages — noWaveSizeattribute, so the host wave size is whatever the driver picks) a host wave may have 64 lanes. Its upper half is then a second console wave whose bits land in the ballot's second dword — butmask_dwordreturned the first dword for every lane. Every lane mask read as a number (s_bcnt1_i32_*,s_ff1_i32_*,v_mbcnt_*,s_cmp_eq/lg_u32/u64) therefore gave the upper half's lanes the lower console wave's mask values: a ballot on a 64-lane host wave drops its high half.mask_dwordnow selects the ballot half by the reader's host lane (lane >= 32 ? y : x) forMaskData::Hostwave32 programs. Unchanged on 32-lane host waves (lane < 32 always selects the first dword).v_mbcnt_loin that mode counts bits of the lane's own half's mask belowlane & 31.v_mbcnt_hiin that mode issrc1alone — a wave32 mask has no high half.Out of scope (noted in #131): the host-lane vs console-lane space for
v_readlane/v_writelanecomputed lanes is the lane-space problem #225/#320 handle in the console flow; it is not a mask read.Test plan
cargo test -p victory-shader— 57/57 pass on Linux (addeda_wave32_mask_read_takes_its_ballot_half: a synthetic wave32 pixel program —v_cmpmask read bys_bcnt1, exported viaexp— asserting the emitted DXIL declaresdx.op.waveGetLaneIndex; the test fails on the unfixed lowering)cargo build -p victory-shaderclean;cargo fmt --check -p victory-shadercleancargo test -p victory-gpu— not run:victory-gpudoes not build on Linux (pre-existingE0425incrates/victory-gpu/src/resource.rs:284, tracked by #90 / PRs #112, #235). No GPU run: none available in this environment.dxil.dll— Windows-only path; not run.The synthetic test asserts the new lowering emits the lane index needed to pick the ballot half. To see the emitted module's declared functions in tests,
emit::bitcode::Modulegained a#[cfg(test)]func_namesaccessor andLowereda#[cfg(test)]op_namesfield.No game data: the fixture is a five-instruction hand-encoded program.
Generated with Devin
@DaviTostes on GitHub · 2026-11-24 03:36 UTC · original
Verified
588a0e2on Arch Linux x86_64 (rustc 1.98.1,cargo test -p victory-shader): 57 passed, 0 failed, 0 ignored.Not covered: running the new ballot/mask paths on a Windows/Wine GPU and title behaviour (no game data here).
@marquezinii on GitHub · 2026-11-24 03:44 UTC · original
Ran
588a0e2on Windows 11 with an NVIDIA RTX 5070 (driver 621.24, 32-lane waves, the only adapter), rustc 1.98.1, debug, in its own target directory:cargo test -p victory-shader: 70 passed, 0 failed, 3 runs. The validator picked up the Windows SDK'sdxil.dll(10.0.26100.0), so the suite's modules were validated here, which the Linux runs skip.a_wave32_mask_read_takes_its_ballot_halfonly checks the op list, so I also passed its lowered container throughdxil.dlllocally (a temporary three-line addition, not pushed): it validates.Not covered: a host that runs pixel shaders 64 wide, and the title (no game data here).
@NolanCotter on GitHub · 2026-11-24 04:10 UTC · original
Update (head
48f92e2): v_mbcnt_lo now reports its rank as a host lane number.Relationship to #145 — I missed it when I scoped this (it covers #125, and #131 is the same defect): both PRs read the upper ballot half, but pick different lane-space models for a wave32 program on a 64-lane host wave:
s_bcnt1(exec)counts both console waves,s_cmptests both waves' bits, andv_mbcnt_loyields a unique index per host lane. It's GPU-verified, but its mask scalars and mbcnt ranks are polluted by the other console wave's divergence (a second wave's rank varies with the first wave's active count, ands_bcnt1(exec)reports 64 where the console program's wave expects 32).mask_dwordselects the lane's own console wave's dword, sos_bcnt1/s_ff1/s_cmpkeep their own wave's value regardless of the other wave's divergence.v_mbcnt_locounts within its own half and then adds the wave's 32-lane base, sov_mbcnt_lo(-1)still reports the host lane index and the result stays a valid host lane forv_readlanecomposition — stable whether or not the other wave is fully active.Both fix the reported defect on the common all-active case; the difference is only observable when the two console waves' tracked masks diverge. The test now asserts the emitted instruction structure (half select,
lane & 31mask, wave-base add), andv_mbcnt_lo(-1)is covered in the synthetic program.@QemmHD on GitHub · 2026-11-24 05:11 UTC · original
Tested
48f92e2onmaind2a4bae, native Windows 11, RTX 4070 SUPER (32-lane waves), driver 621.24.cargo test --workspace --locked: 266 passed, 0 failed, 4 ignored (main: 264 / 0 / 4). New warning:unused variable: iatlower.rs:6767.mask_dword/v_mbcnthunks reverse-applied,a_wave32_mask_read_takes_its_ballot_halffails, so the test does cover the change;only_host_wave32_reads_take_a_ballot_halfpasses either way.lane >= 32never holds, solane & 31 == laneandlane & 32 == 0). Both tests are structural, so the 64-lane case still needs an RDNA run. It conflicts with #145 (same defect, GPU-checked on RDNA) and #233 inlower.rs.No game data used.
AI-assisted (Claude Code, Claude Opus 5.5).
Discord: bigpeppa.
@Marvisak on GitHub · 2026-11-25 00:17 UTC · original
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.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.