MaskData::Host: the high half of a ballot is dropped, and nothing forces the host wave to 32 #131
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#131
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?
@Luislariosss on GitHub · 2026-11-24 00:48 UTC · original
In
MaskData::Host(lower.rs:226-232) a ballot is taken over the host wave, "whatever its size", and the high half of that ballot pair is dropped by the four uses that read a mask as a number. Nothing forces the host wave to be 32 lanes for a pixel or vertex shader:s.wave_sizeis only set on the compute path (lower.rs:382-386), sowave_sizestaysNoneand the driver picks the wave size at PSO creation.If a driver runs one of those shaders 64-wide, the upper 32 lanes are invisible to:
s_bcnt1_i32_b32(lower.rs:2549-2557) -WaveActiveCountBitsover a 64-lane wave counts at most 32.s_ff1_i32_b32(same block) - a first active lane of 32 or above reports 0.s_cmp_eq_u32/s_cmp_lg_u32(lower.rs:2322-2353) - a mask compared against another mask only compares the low halves.v_mbcnt_lo_u32_b32(lower.rs:4879-4927) -WavePrefixCountBitsover a 64-lane wave stops at 32.On my machine this does not bite: an AMD Radeon RX 9060 XT (RDNA4) on Windows 11 runs the pixel shaders wave32, so the high half is zero anyway. That is a property of the current driver's default, not of the code, which is why I am reporting it rather than sending a fix.
What I can show
A unit test on
main(4926f72) that lowers a synthetic wave32 pixel program throughLowerand inspects the emitted module. The program is hand-written GFX10, no game data:After
ir::build(&code, false, 8)->resource::track->io::raise->structure::structure->Lower, with a#[cfg(test)]helper that counts the operands referring to a value:cargo test -p victory-shadergives61 passed; 1 failed, and the failure is that last assertion. The low half is used three times as expected.The question
Is dropping the high half deliberate, on the grounds that a
MaskData::Hostballot only has to be exact for the uses the comment lists and the driver's default is 32 lanes? If it is deliberate, the four sites may deserve a comment saying the upper half is unreachable, and I will keep the test out. If it is not, the fix looks small: share the 64-bitcountbits/firstbitlowlogic thats_bcnt1_i32_b64(2363-2378) ands_ff1_i32_b64(2379-2397) already have, and take both halves of the ballot in those four places.I have not opened a PR because I could not measure a wrong result on this GPU with only the tools here (no game package, so no title run). The test is ready and I can send it as a draft PR if you want it.
AI-assisted.
@NolanCotter on GitHub · 2026-11-24 03:10 UTC · original
Claiming this (renderer-path, no overlapping claim or PR found — #320's console flow covers wave64 compute on wave32 hosts and documents mask reads there; the PS/VS
MaskData::Hostpath is untouched).The defect: for
MaskData::Host(Ps/Vs — noWaveSizeattribute, host wave size is driver-chosen),mask_dwordreturns the ballot's first dword for every lane mask read as a number (s_bcnt1_i32_*,s_ff1_i32_*,v_mbcnt_*,s_cmp_eq/lg_u32/u64). On a 64-lane host wave the upper 32 lanes are a second console wave whose bits land in the ballot's second dword — they get the first console wave's mask values instead of their own.Fix plan, all in
crates/victory-shader/src/emit/lower.rs:mask_dword: forMaskData::Hoston a wave32 program, pick the ballot half by host lane (lane >= 32 ? y : x). No-op on 32-lane host waves.v_mbcnt_loin that mode: count bits of the lane's own half belowlane & 31.v_mbcnt_hiin that mode: a wave32 mask has no high half, so the count issrc1.Verification: synthetic wave32 pixel-program test in
emit::lower's test module (mask fromv_cmp, read bys_bcnt1, exported viaexp) asserting the emitted DXIL takes the lane index;cargo test -p victory-shaderon Linux. No game data.Out of scope: the host-lane-vs-console-lane space for
v_readlane/v_writelanecomputed lanes — that's the lane-space problem #225/#320 handle in the console flow, not a mask read.@NolanCotter on GitHub · 2026-11-24 03:20 UTC · original
Done: #434 (branch
agent/host-wave-mask-halves, head588a0e2).mask_dwordselects the ballot half by host lane forMaskData::Hostwave32 programs;v_mbcnt_locounts within the lane's own 32-lane half;v_mbcnt_hiis src1 alone on wave32 (no high mask half). No behavior change on 32-lane host waves.cargo test -p victory-shader57/57 on Linux; new synthetic wave32-PS test fails on the unfixed lowering;cargo build+cargo fmt --checkclean. victory-gpu not built (pre-existing Linux E0425, #90). No GPU/dxil.dll run available.@Sunkiller-qc on GitHub · 2026-11-24 12:54 UTC · original
This looks like the same bug as #125 (same author, same
MaskData::Hostpath that drops the high ballot half). #145 lists both #125 and #131 as fixed, and #434 also fixes #131, so we have two PRs for one bug. I'd keep #125, since it has the repro branch and the RDNA3 GPU test, and close this one. Whichever of #145 or #434 gets merged should say "Fixes #125".@Marvisak on GitHub · 2026-11-25 01:44 UTC · original
Automated triage for the maintainers.
This is the same defect as #125, opened six minutes earlier by the same reporter: in
crates/victory-shader/src/emit/lower.rs,Lower::mask_dwordreturns only the low ballot dword for a wave32MaskData::Hostprogram, sos_bcnt1_i32_b32,s_ff1_i32_b32,s_cmp_eq/lg_u32andv_mbcnt_lo_u32_b32drop lanes 32-63 of a 64-lane host wave. It names the same four sites and asks the same semantics question. I confirmed the defect on currentmainin #125, which also has the reproduction branch and the RDNA3 measurements. Both open fixes, #145 and #434, are linked there.Proposed close as a duplicate of #125. This issue will be closed in 48 hours unless the reporter replies or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code