Repository navigation
Shaders: a wave32 program's mask read picks its half of a 64-lane ballot - #434
NolanCotter wants to merge 3 commits into
Conversation
For MaskData::Host (pixel and vertex stages, whose programs declare no WaveSize) a host wave may have 64 lanes; its upper half is a second console wave whose bits land in the ballot's second dword. mask_dword returned the first dword for every lane, so mask reads as data (s_bcnt1_i32_*, s_ff1_i32_*, v_mbcnt_*, s_cmp_eq/lg_u32/u64) gave the upper half's lanes the lower console wave's mask values. mask_dword now selects the ballot half by the reader's host lane. v_mbcnt_lo counts bits of the lane's own half below its lane in it, and v_mbcnt_hi is src1 alone on wave32, whose mask has no high half. Both are unchanged when the host wave is 32 lanes. Fixes Marvisak#131. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Verified Not covered: running the new ballot/mask paths on a Windows/Wine GPU and title behaviour (no game data here). |
|
Ran
Not covered: a host that runs pixel shaders 64 wide, and the title (no game data here). |
…names The wave32 mask-read test now asserts the pick's shape: an unsigned `lane >= 32` compare selecting the ballot's second dword over the first, `lane & 31` for v_mbcnt_lo, and a bit count of a constant zero for v_mbcnt_hi. A second test covers the paths that must not pick: wave64 programs (own dwords) and compute (the whole host wave is the console's). emit::bitcode::Module gains a test-only inst_lines dump to support that. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Under MaskData::Host a wave32 program's lane numbers stay host lanes, so a v_mbcnt_lo rank of the upper half's console wave takes its 32-lane base: v_mbcnt_lo(-1) still reports the lane index, and the value composes with host-lane reads like v_readlane. The mask itself stays per console wave, so s_bcnt1, s_ff1 and s_cmp keep their own wave's count and the first wave's divergence never feeds a second wave's scalars. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
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:
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, |
|
Tested
No game data used. AI-assisted (Claude Code, Claude Opus 5.5). |
catminou4
left a comment
There was a problem hiding this comment.
Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
AI-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 Linux: main does not build (E0425 in victory-gpu); with #39 the workspace builds and 156 tests pass #90 / PRs Build: Linux workspace, contributor setup and CI #112, Build: gate Windows-only paths so the workspace builds and tests on Linux #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