Shaders/IR: give buffer_gl0_inv and buffer_gl1_inv no register effects #3264
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!3264
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-26 15:00 UTC · original
fuzeofficlal:fix/ir-buffer-inv-no-register-effects→main· +96 −1 · 1 files · 1 commits · openSummary
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.@Dukestar69 on GitHub · 2026-11-26 15:09 UTC · original · approved these changes
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).
@oni-swr on GitHub · 2026-11-26 15:28 UTC · original
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.
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.