Shaders: wave32 lane masks on 64-lane host waves take their half's dword #3556
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!3556
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3556"
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?
@kilolimaVI on GitHub · 2026-11-27 17:26 UTC · original
kilolimaVI:shader/wave32-masks-64-lane-host→main· +293 −4 · 4 files · 2 commits · openOn hosts that run pixel waves of 64 lanes (AMD: RDNA pixel shaders run wave64; measured on a Radeon 780M, RDNA3), a wave32 pixel or vertex program's 32-bit lane masks were the ballot's low dword in every lane. Lanes 32-63 tested the bits of lanes 0-31, so the console compiler's loop that serves one value per pass (
s_ff1of EXEC,v_readlaneat that lane,v_cmpx_eq) never served them: those pixels kept whatever they held before the loop.NVIDIA (32-lane pixel waves) and WARP never show it, which is likely why it went unnoticed.
Fix (
emit/lower.rs)With
MaskData::Hostand a wave32 program, a 64-lane host wave is treated as two console waves:mask_dword: each lane takes its own half's dword of the ballot (Lower::host_half,waveGetLaneIndex >= 32).v_readlaneat a computed (host) lane adds the half's base (Lower::host_lane).v_mbcntcounts within the half (lane & 31).On a 32-lane host the upper half never exists, so nothing changes there; wave64 programs and compute (
MaskData::Console) are untouched (wave64 DXIL is byte-identical).Test (
emit/lane_mask_tests.rs)wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave: a hand-assembled pixel program runs that loop over a per-pixel key, drawn over a 16x16 target (no helper lanes), wave32 and wave64, on the hardware adapter and WARP. Pixels served a wrong key:0/5 failures over 5 runs.
cargo test -p victory-shaderon the 780M: 303 passed, 0 failed.cargo clippy -p victory-shader --all-targets [--all-features] -- -D warningsclean.cargo fmt --checkreports no new sites (main already has 33 inlower.rsand 2 inmod.rs).Related: helper lanes at triangle edges are a separate issue (#2373); this test draws a full-coverage triangle so it measures only the mask width.
AI-assisted (Claude).
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 17:44 UTC · original
I checked the merge order for the Wave32 mask fix alongside #3421. The exact heads of #3556 (
48f1646) and #3421 (c2698c3) merge cleanly, but the resultinglower.rsis 524,618 bytes, 330 bytes over the 512 KiB asset-policy limit.Adding the barycentric lowering split from #3335 (
e495d2d) also merges cleanly. On the combined commit,lower.rsis 508,704 bytes and the asset policy passes for all 194 files. Both merge commits preserve the original parent commits.These are local software-rendering results. The Radeon 780M measurement above is the hardware evidence for #3556. Its Windows workflow is still awaiting approval.
The next step is for the maintainers to choose a merge order that puts the split in place before both wave changes are in
main. If you reuse the integration work, please retain Git authorship, or addCo-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding it into another commit.@ColorMeBoom on GitHub · 2026-11-27 17:49 UTC · original
RDNA1 run, and an overlap with #125 / #145. RX 5700 XT (RDNA1), driver 32.0.21045.29003, Windows 11 26200, no game files. All trees are merged onto
main63bcca4.wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave(your test):main+ this test only48f1646)main(ColorMeBoom:pr145-rebase,dec8a5b) + this testSo RDNA1 shows the same 88/256 as your 780M, and this PR fixes it. Full
victory-shader --lib --features hoston this PR: 303 passed, 0 failed.Overlap: this is the bug #125 tracks: a wave32 pixel/vertex program's lane masks only use the low ballot dword on a 64-lane host wave, which I confirmed on this card earlier today. #145 (TheHoracio's) fixes it a different way: a 64-bit host ballot for mask ops (
emit/lower/host_masks.rs). Its head conflicts withmain. The rebase above merges cleanly, and its ownpixel_lane_masks_count_every_lane_of_the_host_wavefails onmainhere ("the host wave is wider than 32 lanes and its high half is lost") and passes with it. The two PRs conflict inlower.rs, and as the table shows, both pass your test on this card. So they look like two fixes for one bug, and it's worth settling which one lands.Not run: #145's test on this PR. Windows Application Control on this machine blocked that test binary on every rebuild.
AI use: Claude Code (Claude Opus 5.5).
@kilolimaVI on GitHub · 2026-11-27 17:54 UTC · original
Thanks for checking the merge order. Rather than depend on #3335 landing first, I moved the two helpers (
host_half,host_lane) intolower/lanes.rs, aslower/bvh.rsalready is. This PR now adds about 0.8 KB tolower.rsinstead of 2.2 KB, so with #3421 beside it the file is about 523.3 KB, under the 512 KiB limit in either merge order. No change in behaviour: the hardware test still gives 0 of 256 on the 780M, and clippy is clean.AI-assisted (Claude).
@kilolimaVI on GitHub · 2026-11-27 17:54 UTC · original
Thanks for the RDNA1 run and for spotting #125 / #145. That overlap is my miss: my check of open PRs didn't go back that far, and #145 was first.
The two fixes differ in shape. #145 widens a wave32 program's masks to the host's 64-bit ballot (lane numbers, counts and compares over the whole host wave). This PR treats a 64-lane host wave as two console waves: each lane reads its own half's dword, and lane numbers from masks count within the half (
mask_dword,v_readlaneat a computed lane,v_mbcnt; about 60 lines plus the test), so every 32-bit mask operation keeps its console meaning without tracking a second dword through the program. Either way your table shows the 88/256 gone on RDNA1 and RDNA3.I'm happy for the maintainers to take whichever they prefer. If it's #145, I'll close this one, and the hardware test (
emit/lane_mask_tests.rs) can go there with it.AI-assisted (Claude).
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 18:03 UTC · original
I retested the split on the exact new #3556 head
dcc8ca4with #3421c2698c3. Git reports one conflict where both branches add a module declaration. Keepingmod lanes;and#[cfg(test)] mod wave_tests;resolves it. The rest merged automatically.The combined commit keeps both exact parents.
lower.rsis 523,263 bytes, 1,025 bytes below the 512 KiB limit. The asset policy passes for 194 files. This combination passes with the split in #3556 itself.App-local WARP gave the expected keys for all 256 pixels at each guest wave width, and the DPP row-mask and quad-swizzle/first-lane readbacks passed. All nine wave lowering tests and both strict shader Clippy configurations passed. The author reported the same pixel result on the Radeon 780M after the split. The earlier RX 5700 XT result is for
48f1646. The new Windows workflow awaits approval.The merge-order question is resolved for these two changes. The maintainers can now choose between the approaches in #3556 and #145. If reusing my merge resolution, please retain Git authorship, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding it into another commit.@ColorMeBoom on GitHub · 2026-11-27 18:44 UTC · original
RX 5700 XT at the new head
dcc8ca4(merged ontomain63bcca4), and the cross-check that was blocked last time.wave32_lane_mask_loops_serve_every_lane_of_a_64_lane_host_wave: 0 of 256 pixels wrong, wave32 and wave64, hardware and WARP. Fullvictory-shader --lib --features host: 303 passed, 0 failed.pixel_lane_masks_count_every_lane_of_the_host_wave, taken from the #145 rebase): passes. What it prints shows how the two fixes differ, on the same card:mainup to 32 active lanes, lane indices up to 32up to 64 active lanes, lane indices up to 63up to 32 active lanes, lane indices up to 31So the two agree on the bug, but disagree on what a wave32 program sees on a 64-lane host wave:
s_bcnt1of EXEC up to 64,v_mbcntup to 63.A wave32 program on the console never sees a lane number above 31, so where its code depends on that (a lane number used as an index or a shift, a count compared with 32), this PR's form keeps the console's values. That could help the maintainers choose between the two.
AI use: Claude Code (Claude Opus 5.5).
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.