Preserve both words of a wave64 branch mask when EXEC is empty #345
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/Belobug--VIctory-Belobug-AMD!345
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-345"
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?
@ANDREANIADS on GitHub · 2026-11-26 21:22 UTC · original
ANDREANIADS:fix-wave64-branch-mask-join→a-publier· +178 −3 · 4 files · 3 commits · openOn
a-publier@cd8dfc06, the new compute shader fails during translation at byte offset0x38with “a lane mask holding lanes elsewhere read as data”. The shader updates a saved mask inside a divergent branch, then reads its low and high words after the join. This case came out of the NVIDIA investigation in #259.Compiler change
With no active lanes, the vector comparison clears both words of VCC. OR-ing those zeros into the saved mask leaves both words intact. The new check in
without_skipsproves this identity for each incoming SSA value before removing the skip. It applies to a single compare/OR block over ordinary SGPR pairs. Negative tests cover a different incoming operand and observable changes to SCC or VCC.Before and after on hardware
Tested with a GeForce RTX 3070 (8 GiB), NVIDIA driver 621.40, Windows 11 build 26300.9974, native wave32, WARP off. The original revision stopped before dispatch. With this patch, all 64 lanes returned the expected pair in each of four dispatches, for 512 matching 32-bit reads.
ffffffff007fffff0000001f007fffff0000001f007f00000000001f00000000The IR and wave64 suites passed 33 tests. Three hardware paths in pre-existing tests reported “not run” on this adapter. The non-emitter library suite passed 121 tests, with 11 tests in common across those runs. The new hardware test ran all four cases.
To reproduce the individual regression on a machine with the project toolchain and a compatible physical adapter:
Local validation used an isolated release build with rustc 1.98.0 MSVC (the repository pins 1.98.1). The offline cache supplied thiserror/thiserror-impl 2.0.19, unicode-ident 1.0.24, syn 3.0.3 and zlib-rs 0.6.3. Windows bindings matched the project. These measurements cover the synthetic shader. Game FPS, VRAM use and ray tracing still require a game run.
Implemented and tested with Codex.
@ANDREANIADS on GitHub · 2026-11-26 21:27 UTC · original
I also ran the four existing
emit::intersect_tests::cases against both the base compiler (cd8dfc06) and this PR (3dac8db9) on the same RTX 3070. Both runs passed 4/4 with no skips. The fixtures compare the emitted shader’s 32-bit and 64-bit ray/node intersection outputs against the Rust reference, using both a host buffer and emulated title memory. Each fixture ran on the hardware adapter and separately on WARP as a control.The physical-adapter run selected
VICTORY_D3D12_ADAPTER=RTX 3070withVICTORY_WARP=0. To repeat, use theemit::intersect_tests::test filter with--nocapture --test-threads=1. This adds a regression check for the underlying intersection math. In-game lighting, device removal and frame time were outside this test.@Aniseto on GitHub · 2026-11-26 22:01 UTC · original
Ran the BVH intersection fixture at
3dac8dbon an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by
rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build;VICTORY_D3D12_ADAPTER=NVIDIA.All eight
emit::intersect_testspass on the real adapter, including the native wave32 cases. The thread has a report on an RTX 3070 (driver 621.40) and a base-vs-head comparison by another user; this adds a desktop RTX 5070 Ti with driver 32.0.16.2124. The new compiler check itself is exercised by the translated fixtures, not by an injected empty-EXEC runtime case beyond what these tests cover.Not tested: a retail title, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
@MamaLeVrai on GitHub · 2026-11-26 22:22 UTC · original
On an RDNA 2 card the new test fails at translation. The patch's case is still refused when the host wave is 64 lanes.
Host: RX 6950 XT 16 GB, driver 32.0.21045.29003 (wave lanes 32 to 64), Windows 11 build 26300, Rust 1.98.1, release, at
3dac8db:It is the same refusal you describe for
cd8dfc06. The test translates withTEST_HOST_WAVEset tohost.translation_caps()'s wave, and here that is presumably 64, where on the RTX 3070 it is 32. So the 64-lane lowering does not reach the identitywithout_skipsnow proves, or refuses earlier. The rest ofcargo test --release -p victory-shader --libpasses on this card: 303 passed, 1 failed (this one), 4 ignored.If the PR only means to cover 32-lane hosts, the test could take
wave == 32as its condition. Otherwise the 64-lane path needs the same handling.AI-assisted (Claude Code); no game data.
@MamaLeVrai on GitHub · 2026-11-26 22:51 UTC · original
A follow-up on why it stays refused on a 64-lane host. I traced it on the RX 6950 XT but have no fix:
emit(), every retry (the forms without early-outs or skips, includingir::without_skips(p, true)with yourmask_or_on_empty) sits behindlower::host_max_wave() == 32. On RDNA,translation_caps()gives 64, so none of them runs.without_skipsforms on 64-lane hosts too, for aMASK_ELSEWHERErefusal of a wave64 compute program. The deep form exists for this test's program (without_skips(p, true)isSome,without_skips(p, false)isNone) and structures fine. Its emission is still refused at offset 56 with the sameMASK_ELSEWHERE.Lowering::mask_dword: a mask made outside the active set is accepted only whenwhole, which needsself.exchange.is_some(), that is two host waves exchanging. On a host that runs the console wave whole there is no exchange, andall_lanescannot tell which blocks every lane runs (it answerstruefor every block without exchange data). So the 64-lane path would need its own "this block runs every lane" information beforemask_dwordcan accept such a mask.So the PR as it stands helps 32-lane hosts only. The new test could check for
wave == 32(or skip whenrdnais true) until the 64-lane lowering learns the same thing.AI-assisted (Claude Code); no game data.
@MamaLeVrai on GitHub · 2026-11-27 00:12 UTC · original
Following up on my diagnosis above, here is a fix for 64-lane hosts, as one commit on top of
3dac8db:github.com/MamaLeVrai/VIctory-Belobug-AMD@29e7a59(branchMamaLeVrai:mask-whole-wave). It is for you to take into this PR if you want it.emit/lower.rs:Lowergetswhole_wave: Option<Vec<bool>>, which says per block whether every lane runs it (all_lane_blocks). It is set only for a console wave64 compute program that runs as one 64-lane host wave:wave_size == Some(64), noexchange, host not 32-lane.mask_dwordaccepts a mask made in such a block, as it already does for the exchange case. So it takes the ballot instead of refusing withMASK_ELSEWHERE.emit/mod.rs: on hosts with 64-lane waves, a wave64 compute program refused withMASK_ELSEWHEREis tried again aswithout_skips(p, false), thenwithout_skips(p, true), which reaches yourmask_or_on_emptyidentity. Both forms are exact and add no barrier.On the RX 6950 XT (RDNA 2, 64-lane host),
a_branch_mask_preserves_both_words_on_the_host:3dac8db:translation: Unsupported { offset: 56, what: "a lane mask holding lanes elsewhere read as data" };29e7a59: passes. It translates throughwithout skips, scalars followedwith wave 64, and both words are right in all 64 lanes for thresholds 0, 32, 48 and 64.Full
cargo test --release -p victory-shader --lib, twice: 304 passed, 0 failed, 4 ignored.Caveats: programs that used to fall back to
with_mask_ops_on_numberson 64-lane hosts may now take the ballot. They only do so in blocks every lane runs, the same rule the 32-lane exchange path uses. I have not checked this against the title's shaders. Not run on a 32-lane host either, but that path does not change: the new field is never set there.AI-assisted (Claude Code); no game data.
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.