Shaders: one lane of a whole-wave section's value, read after the section #3402
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!3402
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3402"
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?
@Lyrnc on GitHub · 2026-11-26 22:25 UTC · original
Lyrnc:fix/wave-section-lane-read→main· +312 −11 · 3 files · 1 commits · openWhat was refused
Three wave64 compute programs of the title's FidelityFX upscaler DLL (
amd_fidelityfx_upscaler_xbox.dll):17af85f170e66f30,477b52e73ddeb6f2,8b437ab61d8008fe. On main they stop earlier, ata lane mask read as data(fixed by #3401); past that, each stops ata whole-wave section step the simulation does not follow, at its final store.Each ends with a wave OR reduction of the form the console compiler writes for wave64 (as this PR's test
writes it):
The section simulation lowers a value that leaves the section only where every lane agrees on one shape.
Here the low half holds its own lanes' OR and the high half the whole wave's, so
v7had no shape, and theread at lane 63 after the section was refused.
What changed
emit/wave.rs:Section::laneskeeps, for a value whose lanes differ, what each lane holds where that does notdepend on the lane reading it: a reduction over all lanes, a constant, a uniform value (never a lane's own value
of a VGPR). Values with one shape are unchanged.
emit/lower.rs: av_readlane_b32at a constant lane, outside the section, of such a value is lowered by thatlane's shape (
shape(), the same lowering as a section value with one shape). A lane without one (here lane 0,which holds only the low half's OR) is still refused.
Tests
wave::tests::a_wave64_reduction_finished_in_the_high_half_is_known_per_lane(no GPU): the sequence above;lanes 32-63 are the reduction over the wave, lanes 0-31 have no lane-independent shape, the value no shape.
crosslane_tests::whole_wave_section_read_at_one_lane_after_it_on_gpu(wave32, 32 lanes, hardware adapter):the same idea within one wave32: rows reduced with DPP, row 0's result (lane 0) ORed in, so only row 1 holds the
whole wave's, read at lane 31 after EXEC is restored; under a branch on three of four lanes, on
1 << lane, sothe answer (0x77777777) differs from a dropped row (half of it) and from counting inactive lanes (0xFFFFFFFF).
crosslane_tests::wave64_section_read_at_lane_63_after_it: the wave64 sequence above under a branch on the laneswith
lane & 2 == 0, on1 << (lane >> 1): 0x55555555 (a dropped half gives 0x5555 or 0x55550000, inactivelanes counted 0xFFFFFFFF). Lowered and validated everywhere, run where the host has 64-lane waves.
Results:
NVIDIA).
the wave64 program dispatched on 64-lane waves.
wave.rsandlower.rsthe two GPU tests fail at lowering witha whole-wave section step the simulation does not follow.sequences run natively give 0x77777777 (wave32, read at lane 31) and 0x55555555 (wave64, read at lane 63) in
every running lane: 0 differences from the tests' expected values.
cargo clippy -p victory-shader --lib --tests -- -D warnings: clean.cargo xtask policy: 191 files ok.cargo test -p victory-shader --lib -- --test-threads=1on the RTX 5080, skippingheap_direct_texture_reads_mark_their_heap_index(it kills the test process here, as #2571 reports): 301 passed,3 failed, 3 ignored; the three (
stride_tests::a_heap_buffer_read_*twice,synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on main63bcca4here.Census (offline, the title's shader pack, exe and DLLs)
translate --list --validateovershaders.rpf, the executable,XboxBvhBuilder.dllandamd_fidelityfx_upscaler_xbox.dll, validator dxc 1.9.2609dxil.dll, compared program by program:63bcca4hash): the three programs stop at the earlier refusal first.
8e614708143ef917,17af85f170e66f30,477b52e73ddeb6f2,8b437ab61d8008fe); against #3401 alone, exactly thethree wave64 ones change, from
a whole-wave section step the simulation does not followto validated, and noother program changes outcome or DXIL. The five new tests of both branches pass together on the RTX 5080.
Both this and #3401 append tests at the end of
emit/crosslane_tests.rs; whichever mergessecond has a trivial conflict there (keep both blocks; git takes the closing brace as shared, so check it).
Not tested
VICTORY_FIDELITYFX_DIR; the game wasnot started).
AI use: Claude Code (Claude Opus 5.5) found the refusal in the offline census, wrote the change, the tests and
this text, and ran the checks on our machine; Lyrnc reviews what goes out. No game data is included (hashes,
counts and error text only; the sequence above is the test's, written by hand).
🤖 Generated with Claude Code
A whole-wave section's value leaves it lowered only where every lane agrees on one shape. The wave64 OR (and the like) reductions the console compiler writes reduce each half with DPP and v_permlanex16_b32, then read lane 0 and combine it into every lane, so that only the high half holds the whole wave's result; the program restores EXEC and reads lane 63 with v_readlane_b32. The lanes of that value differ, so it had no shape and the read was refused ("a whole-wave section step the simulation does not follow"). Three compute passes of the title's FidelityFX upscaler end so. The simulation now also keeps, for a value whose lanes differ, what each lane holds where that does not depend on the lane reading it (a reduction over all lanes, a constant, a uniform value; never a lane's own value). A v_readlane_b32 of such a value at a constant lane, outside the section, is lowered by that lane's shape. Co-Authored-By: Claude Opus 5.5 <[email protected]>@Dukestar69 on GitHub · 2026-11-26 22:27 UTC · original · approved these changes
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).cargo test -p victory-shader --lib emit::wave:: -- --test-threads=1: 8 passed, 0 failed (a_wave64_reduction_finished_in_the_high_half_is_known_per_lane).cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1: 7 passed, 0 failed on RTX 5090 and 7 passed, 0 failed onVICTORY_WARP=1(whole_wave_section_read_at_one_lane_after_it_on_gpu,wave64_section_read_at_lane_63_after_it).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Aniseto on GitHub · 2026-11-26 22:39 UTC · original
Ran the whole-wave-section tests at
d1158c9on 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.Both pass: the wave32 fixture ran a dispatch on the real 32-lane adapter, and the wave64 reduction test passed at translation level. I did not run
wave64_section_read_at_lane_63_after_it, which needs a 64-lane host. The PR has no comments yet; the author tested on an RTX 5080, so this adds a second NVIDIA datapoint on driver 32.0.16.2124.Not tested: the wave64 GPU dispatch, the title's FidelityFX shaders, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, 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.
@fuzeofficlal on GitHub · 2026-11-26 22:47 UTC · original · requested changes
Tracking per-lane
ShapeinSection::lanesfor whole-wave Wave64 split-half reductions is a very clean idea, and both new tests pass validation (with Wave32 GPU readback passing on RTX 5090, 48/48 tests green).However, there is one P1 regression in how
section_lanematerializes the read shape:shapes— which callsself.shape(sh)immediately atsection_inst(crates/victory-shader/src/emit/lower.rs:1162) whileself.curis still in the section's block —section_lanesdefers callingself.shape(shape)until thev_readlane_b32consumer (lower.rs:6682-6686).v_readlane_b32(for example, the section computes an all-laneOp::Orreduction0xFFFFFFFFbefore an even-lane branch, andv_readlane_b32 s15, v7, 31executes inside that even-lane branch),self.shape(shape)emitswaveActiveBitat the divergent branch block (self.cur), which only sees the even lanes and silently returns0x55555555instead of0xFFFFFFFF.Materializing (and caching) the needed
section_lanesshapes eagerly atsection_inst(just likeshapes) — or rejecting deferred reads across divergent control flow — would close this cleanly.Non-blocking notes:
v_readfirstlane_b32(lower.rs:6715) does not consultsection_lanesand can pick host lane 0 when restoredEXECexcludes lane 0.>= wave_size), and values flowing through a non-trivial VGPR phi beforev_readlane_b32misssection_lanesand fall back toVal::Missing.@andrewpozdnakov7-jpg on GitHub · 2026-11-27 00:20 UTC · original
Following up on the Wave64 runtime check, I combined this exact head
d1158c9with #3401 atd9ed313. The tested merge resolves the shared test-file conflict and adds a regression for the ordered pair.The regression runs the two patterns in a single synthetic shader. The first true comparison is in lane 63 on iteration 2 of a bounded poll. The shader then performs the whole-wave OR and reads lane 63 after restoring EXEC. Readback must contain
0x55555557in the 32 participating lanes and the original sentinel 7 in the other 32.With the identical fixture, #3402 alone stops at
a lane mask read as dataand #3401 alone stops ata whole-wave section step the simulation does not follow. The combined branch validated and dispatched the Wave64 shader in three fresh WARP 1.0.22 processes, with all 64 words matching each time. The cross-lane and wave suites reported 18 passed. This WARP runtime skipped Wave32 dispatches. Strict clippy with default and all features and the 192-file asset-policy check passed.The merge retains both parent commits and both sets of tests. It moves the mask-SCC helpers to keep
lower.rsbelow the size limit. Maintainers can use the composition when ordering the two PRs. If folding the new regression into another commit, please retain the Git author or addCo-authored-by: andrewpozdnakov7-jpg.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.