Shaders/IR: give buffer_gl0_inv and buffer_gl1_inv no register effects #3262
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3264"
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 fuzeofficlal on 2026-11-26T15:00:09Z.
Summary
On GFX10/RDNA2,
buffer_gl0_inv(MUBUF0x071) andbuffer_gl1_inv(MUBUF0x072) are zero-operand cache invalidations (MUBUF_Invalidatein LLVM'sBUFInstructions.td/gfx10_mubuf.txt): hardware ignoresvdata,vaddr,srsrc,soffset,offen,idxen,lds, andEXEC.Every other pass in
victory-shaderalready handles them as operandless no-ops (gfx10/fields.rs,gfx10/sp3.rs,resource.rs, andemit/lower.rs), and the scalar cache invalidations (s_icache_inv,s_gl1_inv,s_dcache_inv,s_dcache_wb) already produce empty register effects inir.rs. However,ir::effectsstill executed the genericFields::Bufferoperand path and thevectorEXEC-read path onbuffer_gl0_invandbuffer_gl1_inv. Because their standard encodings carrysrsrc = 0andsoffset = 0,ir::buildfabricated reads ofs[0:3]andEXEC, pollutingProgram::inputsand synthesizing phantom SSA PHIs across branches and loops.Changes
crates/victory-shader/src/ir.rs(effects), skipFields::Bufferoperand reads and thevectorEXECread forbuffer_gl0_invandbuffer_gl1_inv, matching the scalar cache invalidations while keeping the instructions in the IR foremit/lower.rs.ir::testscoveringbuffer_gl0_inv,buffer_gl1_inv,s_gl1_invparity, abuffer_load_dwordnegative control, and a diamond CFG verifying no phantoms[0:3]orEXECPHIs or inputs are created in either Wave32 or Wave64.Verification
main(buffer_gl0_invfabricated reads ofS(0)..S(3)andS(126)and 5 phantom PHIs at the merge block).cargo test -p victory-shader --locked ir::tests(dev and--release): all passing.cargo clippy --workspace --all-targets --locked -- -D warningsand--all-features: clean.cargo test -p xtask --locked policy::tests::repository_passes_policy: passing.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:09:05Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64:
buffer_gl0_invandbuffer_gl1_invas operandless / EXEC-independent inir::effectsmatches the GFX10 MUBUF cache-invalidation semantics and prevents fabricating phantom register inputs and merge PHIs.cargo test -p victory-shader --lib ir:: -- --test-threads=1: 11 passed, 0 failed (includingbuffer_cache_invalidations_have_no_register_effectsandbuffer_cache_invalidations_do_not_create_phantom_phis).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 oni-swr on 2026-11-26T15:28:25Z.
WARP verification of #3264 (test report only, no code changes)
Head
6ac0afc47449ddecc90060c74e8f9768114c8862, main63bcca43c6a00a758510398fa43096ce7e4f7df0(merge base = main).Env: Windows 11, WARP only (adapter "Microsoft Basic Render Driver", d3d10warp.dll 10.0.26100.9818), VICTORY_WARP=1 and VICTORY_D3D12_WARP=1, dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0), cargo -j 4. No physical GPU used. Each test was run in its own process (
<test> --exact), so one crashing test cannot hide the others. (With the old 10.0.19041 dxil.dll the validator tests crash with an access violation, on main too; unrelated to this PR.)Commands (head, checked out detached):
cargo test -j 4 -p victory-shader --lib(features: none)ir::tests::buffer_cache_invalidations_have_no_register_effects,ir::tests::buffer_cache_invalidations_do_not_create_phantom_phisResults:
emit::lower::tests::buffer_cache_invalidations_lower_as_no_opspasses too.victory-shaderlib on head: 307 tests, 300 passed, 3 ignored, 4 failed. On main: 305 tests, 298 passed, 3 ignored, 4 failed. The same 4 fail on both:emit::synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out}. So the PR adds +2 passes and no new failures.ir.rsfix): both fail (buffer_gl0_invreads s0..s3 and exec; phantom PHIs at the merge), the lower test passes. So the tests catch the bug the fix removes.AI-assisted: verification by Claude Code (Claude Sonnet 5.5). Synthetic tests only; no game files, dumps, shader names or hashes.
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T23:16:06Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head
6ac0afc(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: 868 passed, 0 failed, 10 ignored.buffer_cache_invalidations_have_no_register_effects,buffer_cache_invalidations_do_not_create_phantom_phis.--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
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.