Shaders: continue scanning wave sections past an unmatched saveexec #3185
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3187"
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 reeledMarek on 2026-11-26T11:28:33Z.
Summary
crates/victory-shader/src/emit/wave.rs,sections()exited the basic-block scan loop withbreakwhenever ans_or_saveexec_* -1/s_nand_saveexec_* 0had no matchingEXECrestore in the same basic block.i += 1; continue;instead ofbreak.Testing
unmatched_saveexec_does_not_skip_later_wave_sections_in_blockincrates/victory-shader/src/emit/wave.rs(fails onmain, passes with the fix).cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warningsandcargo test -p xtask --lockedpass.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T11:49:13Z.
Review: APPROVED
Verified against
origin/main(63bcca4):cargo test -p victory-shader --lib emit::wave:: -- --test-threads=1: passed.cargo test -p victory-shader --lib emit::lower::tests:: -- --test-threads=1: 33/33 passed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly continues scanning wave sections past an unmatched
saveexec.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T11:44:25Z.
Independent local verification of head
d097c31on Windows 11, Rust 1.100.0/MSVC:cargo test --locked -p victory-shader --lib emit::wave::tests::unmatched_saveexec_does_not_skip_later_wave_sections_in_block -- --exact— 1 passed, 0 failed.git diff --check origin/main HEAD— clean.CPU-only synthetic unit test; no D3D12 device or game assets used. Worktree-local
CARGO_TARGET_DIR. AI-assisted (Hy4 flash).Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T11:47:11Z.
WARP verification of #3187 (head
d097c310a40be0364c960293390a7e643b4c2265)Environment: Windows 11 Pro 10.0.26200; WARP
D3D10Warp.dll10.0.26100.9818 (VICTORY_D3D12_WARP=1, physical GPU not used);dxil.dllanddxc.exe1.8.2502.11 from Windows SDK 10.0.26100.0 (VICTORY_DXILpoints at thatdxil.dll); rustc 1.98.1.Commands (
CARGO_TARGET_DIRon a scratch dir):cargo test -p victory-shader --lib -j 4 --locked -- --test-threads=1, on the PR head and on the merge-base withmain(63bcca43c6a00a758510398fa43096ce7e4f7df0).emit::wave::tests::unmatched_saveexec_does_not_skip_later_wave_sections_in_block)wave.rsfix reverted (i += 1; continue;back tobreak;), test keptDefects found: none. The loop still advances
ion thecontinuepath, so it can't spin, and the diff touches onlywave.rs. The test fails without the fix and passes with it.AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5). Test report only, no code changes. Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7190976040
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T22:30:02Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, oni-swr, since none of them names a GPU run. Tested exact head
d097c31(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.unmatched_saveexec_does_not_skip_later_wave_sections_in_block.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:13:29Z.
Review: CHANGES_REQUESTED
Thanks for tracking down the early
breakwhen an unmatchedsaveexecprecedes a clean reduction section. Continuing to scan past unmatched saves exposes a couple of safety gaps insections/simulatethat need to be guarded before this can land:saveexecinside later sections (crates/victory-shader/src/emit/wave.rs:158-168, 329-338, 369-374,crates/victory-shader/src/emit/lower.rs:1116-1131, 1367-1375):Because
Lower::runreplaces every instruction ini + 1..endwithsection_instwithout emitting the underlying instructions, anySectioninserted bysectionsdrops all memory/side-effecting instructions in that range. Previously, an earlier unmatchedsaveexeccausedsectionstobreakand fall back to normal lowering; continuing past it exposes any latersaveexec ... restoreblock that contains stores or an unmatched nestedsaveexec(wheresimulatereturns early at line 337 or skips non-VALU effects at line 369, yetsectionsstill recordsSection { end, shapes }at line 167).crates/victory-shader/src/emit/wave.rs:139-141, 158-161):endsearch matches any instruction that writesEXECand readssaved_code(inst) == Some(saved), so a nesteds_*_saveexec_* s2, s0afters_mov exec, 0will prematurely close the outer section instead of matching an actualEXECrestore.saved_codeonly checks the low scalar dword ofsaved(missing partials_mov_b32 exec_lo, s0or a clobbered high dword), and lines 140-141 accept_b32savers even whenp.wave64is true.Please restrict
sectionsso a candidate interval is only recorded as a whole-wave section when it ends at a real matching-widthEXECrestore (full 64-bit pair in Wave64) and contains no side-effecting instructions or unmodeledEXECmutations, and add tests covering nestedsaveexecand store preservation.Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-27T17:22:08Z.
Thanks for the thorough review @fuzeofficlal! Pushed
dffd7c6addressing every point:EXECwrites:simulatenow returnsOption<(HashMap<Value, Shape>, u64)>and returnsNoneon any unmodeledEXEC/EXEC+1write (such as nestedsaveexecorv_cmpx) or any instruction with observable side effects (has_side_effect: memory/LDS/image/buffer stores & atomics, exports, barriers,s_setreg*, control transfers, etc.), sosectionsrejects that candidate range instead of dropping it inLower::run.EXECrestore:sectionsnow matchess_or_saveexec_b64/s_nand_saveexec_b64only in Wave64 and*_b32only in Wave32, tracks the full 64-bit saved register pair in Wave64, and usesis_restoreto require a real matching-widths_mov_b32/s_mov_b64(ors_and_b32/s_and_b64withEXECequal to all lanes) targetingEXECrather than any instruction writingEXECand readingsaved_lo.section_with_store_or_side_effect_is_rejected,nested_saveexec_does_not_close_outer_or_drop_inner, andwave64_requires_matching_width_save_and_full_pair_restore.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.