Shaders: one lane of a whole-wave section's value, read after the section #3402
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-26T22:25:19Z.
What 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
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:27:19Z.
Review: APPROVED
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).
Imported from Marvisak/VIctory. Originally posted by Aniseto on 2026-11-26T22:39:58Z.
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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:47:15Z.
Review: CHANGES_REQUESTED
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.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T00:20:09Z.
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.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T06:57:11Z.
@Lyrnc f9e2015 is directly on
d1158c9. It materializes only the statically requested lane values while lowering the whole-wave section, then reuses them at the later read.I reproduced the review case on app-local WARP. An all-lane OR followed by a read inside an even-lane branch returned
0x55555555in 16 lanes. On the follow-up all 16 readers return0xFFFFFFFFand the other 16 retain the old destination. The original branched case and the Wave64 lane-63 test also passed. Strict shader Clippy passed in both configurations.If you take the patch, please retain Git authorship when cherry-picking or rebasing. If folded into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.AI-assisted with Codex. Synthetic shaders only.
I also resolved the test-file overlap and the shader file-size limit in c75cc68, which combines the two reviewed follow-ups. Both SCC regressions and both section-lane tests passed in the combined app-local WARP build.
Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-27T13:33:25Z.
AMD run: RX 5700 XT (RDNA1, 32–64 lanes, so the 64-lane cases run instead of being "lowered and validated only"), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Each tree was merged onto
main63bcca4and run on the native adapter (VICTORY_WARPunset), no game files.wave64_section_read_at_lane_63_after_itwhole_wave_section_read_at_one_lane_after_it_on_gpucrosslaned1158c9f9e2015ff81029(#3401 atd9ed313+ this PR)ds_swizzle_b326/6 in every tree. "Full suite" iscargo test -p victory-shader --lib --features host, 3 ignored in each.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.