Shaders: a mask read as a number takes lanes 32-63 from its high dword in halves mode #108
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!108
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-108"
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?
@Caasares on GitHub · 2026-11-27 18:15 UTC · original
Caasares:fix/shader-halves-lane-bit→main· +48 −5 · 2 files · 1 commits · openBug
A console wave64 compute program that the translator runs as two host waves of 32 ("halves"; used when the host's waves hold at most 32 lanes, as NVIDIA's do) reads a 64-bit lane mask held as a number with the wrong lanes. Lanes 32-63 take bits of the low dword instead of the high one.
Impact
Per-lane results are wrong for lanes 32-63 of such a program, for example a
v_cndmask_b32whose mask is an SGPR pair the program does not track.Root cause
thread_idnumbers the lanes of a halved program throughconsole_thread().console_lane()andlane_bit()only do the same whenexchangeis set. Otherwiselane_bittakeswaveGetLaneIndex, which is 0-31 in each host wave, solane < 32is always true and the high dword is never chosen.Fix
In halves mode
console_lane()givesconsole_thread() & 63, andlane_bit()uses it, as exchange mode already does.Testing
wave64_tests::lanes_past_32_take_the_high_dword_of_a_mask_held_as_a_number. A DPP move makes the program take the console's lanes, so it runs in halves. Thenv_cndmask_b32readss[2:3]as the mask. The test checks all 64 lanes for three masks, on the hardware device when one takes waves of 32, and skips otherwise.mainat lane 32 (maska0f0123455550f0f) and passes with this change.cargo test -p victory-shader --locked: 289 passed, 0 failed, 4 ignored (already ignored onmain).cargo clippy -p victory-shader --all-targets --locked -- -D warnings, and the same with--all-features: clean.lower.rsandwave64_tests.rsalready had rustfmt differences onmainand the number is unchanged.Workspace-wide clippy and fmt already fail on
mainin code this PR does not touch (victory-formats/src/texture.rs:1346,apps/victory).Related
#52 makes a select on a mask held as a number count toward
console_lanes. This PR does not depend on it: its test reaches halves mode with a DPP move. With #52 applied, a wave64 program with such a select does reach halves mode, and this change is what numbers its lanes correctly there. I have not run #52's branch on the card.A console wave64 compute program that runs as two host waves of 32 ("halves") numbers its lanes through console_thread (thread_id does). console_lane and lane_bit still read the host lane index unless exchange is set. A 64-bit mask read as a number, such as a select on an SGPR pair, then gave lanes 32-63 the bits of the low dword: their host lane is 0-31, so the test `lane < 32` always picked the low dword. Use the console lane in both places when halves is set, as exchange already does.@cloph-dsp on GitHub · 2026-11-28 00:36 UTC · original
Independent local verification of PR #108 (lanes past 32 take the high dword of a mask held as a number).
cargo test --locked, synthetic inputs only; CPU interpreter (Host::new(false)), no GPU.245cb85145bfd083e3df6769adf68dbdbb670340, merge base29d8dbf7d9892ceb8bec378a9dbc3c4f2931b745, worktree-localCARGO_TARGET_DIR.cargo test --locked -p victory-shader --lib -- emit::wave64_tests::lanes_past_32_take_the_high_dword_of_a_mask_held_as_a_number --exact --test-threads=1 --quiet→test result: ok. 1 passed; 0 failed; 292 filtered out, exit 0.git grep -F lanes_past_32_take_the_high_dword_of_a_mask_held_as_a_number 29d8dbf7 -- crates/victory-shader/src/emit/wave64_tests.rs→ exit 1 (test absent on base).git diff --check 29d8dbf7 HEADclean; diff 2 files, +48/−5.Only the named test was replayed; full suite not run. GPU/driver N/A (CPU interpreter). AI-assisted (Hy4 flash). No game data, assets, extracted shaders, DRM or decrypt.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.