Shaders: allow redundant masked v_mov_b32 writes after per-lane descriptor joins (fixes #750) #3298
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!3298
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3298"
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?
@pushkarreddyy on GitHub · 2026-11-26 16:22 UTC · original
pushkarreddyy:fix/shader-redundant-masked-write→main· +193 −12 · 1 files · 1 commits · openSummary
Allows redundant masked
v_mov_b32writes after a per-lane descriptor join when every active lane writes the exact value its register already held (fixes #750).Root Cause
In
crates/victory-shader/src/resource.rs,Tracer::lane_valuecalledTracer::runs(site, known)?on every VGPR copy and rejected any masked write where some lanes inknowncould skipsite, even when the active lanes wrote back the same value they already held from the prior SSA definition (such as aphiarm).Changes
crates/victory-shader/src/resource.rs:Tracer::redundant_mov_priorandTracer::same_under: whenruns(site, known)fails on av_mov_b32, checks whether the prior SSA value of that VGPR in the block agrees with the written value on all active lanes (known + reach + guard). If so,lane_valuecontinues tracing through the prior value so both active and skipping lanes remain consistent.joined_descriptor_redundant_partial_write(from #750) and negative testjoined_descriptor_non_redundant_partial_write_fails.Testing & Verification
joined_descriptor_redundant_partial_writeandjoined_descriptor_non_redundant_partial_write_failsincrates/victory-shader/src/resource.rs.No game files used.
AI-assisted: yes (Gemini 4 Neon)
e8f85261dctoe95add4b2f@Dukestar69 on GitHub · 2026-11-26 16:50 UTC · original · reviewed
Ran local verification on Windows 11 x64 (
origin/main63bcca4merged with this PR):cargo test -p victory-shader --lib resource::tests:: -- --test-threads=1: 36 passed, 1 failed — the newly added testresource::tests::joined_descriptor_redundant_partial_writefails: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 18:24 UTC · original
WARP verification of #3298 (synthetic tests only, no game files, no physical GPU).
Result: the PR's new positive test
joined_descriptor_redundant_partial_writefails on the PR head.Commits
e95add4b2f6129935f6b2e4fda0d54292ccb0c1563bcca43c6a00a758510398fa43096ce7e4f7df0Environment
d3d10warp.dll10.0.26100.9818,dxil.dll1.8.2502.11 (Windows SDK 10.0.26100.0 x64)VICTORY_WARP=1,VICTORY_D3D12_WARP=1New tests, head vs control
Control =
63bcca43with only the PR's two tests applied.resource::tests::joined_descriptor_redundant_partial_writeresource::tests::joined_descriptor_non_redundant_partial_write_failsBoth sides fail with the same error at
waterfall(&words, false).unwrap():Unsupported { offset: 264, what: "a per-lane descriptor written where some lanes may keep the old one" }.It is deterministic: it failed on a parallel run and on
--test-threads=1. These tests are pure shader tracing and do not touch the GPU, so WARP is not a factor. As the tests are written here, the PR's change does not make the redundant masked write accepted. The negative test passes both before and after, so it does not show the change.Full
cargo test -p victory-shader --libon head: 299 passed, 5 failed, 3 ignored (307 total, 1955 s).emit::synthetic_tests::*failures that also fail on unmodified63bcca43. They arepermutes_read_the_lane_named_and_zero_from_lanes_left_out,permutes_mask_high_address_bits_and_divergent_branches,gathers_at_a_level_match_the_hardwareanda_mask_joined_with_data_at_a_uniform_loop_is_its_number.Not tested
xtask policy.AI use: Claude Code (Claude Sonnet 5.5)
@pushkarreddyy on GitHub · 2026-11-26 18:46 UTC · original
@Marvisak Please review and merge this PR. Testers, kindly run on untested GPU models. AI‑assisted ✅ Gemini‑4 Neon
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 18:59 UTC · original
I reproduced the positive test failure on
e95add4before any DXIL or GPU work.8b404f4is a follow-up on that exact head.The redundancy proof needs the incoming branch condition as well as the predecessor’s reach condition. With that condition, the two copies of the integer comparison also need to be recognized as the same per-lane predicate. Their explicit operands agree, while the implicit EXEC SSA value was redefined when EXEC was restored. The follow-up reuses the existing edge conditions, keeps explicit inputs in the comparison, and uses the existing join depth limit for nested proofs.
With the follow-up, the positive fixture traces both original table offsets (
0and0x20). The real write in the negative fixture is still refused. All 37 resource tests passed. In three app-local WARP runs with DXIL validation, all five waterfall tests passed, including the extended test that reads red 1.0 from the first texture in lanes 0–15 and red 2.0 from the second in lanes 16–31, with and without the redundant write. Both all-target Clippy configurations passed. The full WARP run was 300 passed, 4 failed, 3 ignored, with the same four failures already reproduced onmain.pushkarreddyy, please consider applying the follow-up and rerunning CI on the PR branch. If you fold it into another commit, please preserve its Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@fuzeofficlal on GitHub · 2026-11-26 20:24 UTC · original · requested changes
Requesting changes on
e95add4b: the new positive regression test currently fails on the PR head, and there are two soundness gaps in the equivalence proof.Blocking issues
joined_descriptor_redundant_partial_writefails one95add4b:Running
cargo test --locked -p victory-shader --lib resource::tests:: -- --test-threads=1gives 36 passed, 1 failed (crates/victory-shader/src/resource.rs:4012:34panics withUnsupported { offset: 264, what: "a per-lane descriptor written where some lanes may keep the old one" }). As noted in earlier comments, two independent issues break the proof:same_compare(resource.rs:1640-1648) checksia.reads == ib.reads, which fails when two identicalv_cmp_*instructions read distinct implicitReg::S(EXEC)SSA values (e.g., entryEXECvs. restoredEXEC).check_phi(resource.rs:1667-1679) only pushes(lanes.reach[pred], true)and drops thepred -> pbbranch edge condition, so it traverses unmatching predecessor edges back to the pre-join register input.vstepignoresclampandomodonv_mov_b32:vstep(resource.rs:1689-1702) only guardsabs == 0 && neg == 0 && sdwa.is_none() && dpp.is_none(), omitting!f.clamp && f.omod == 0. However,emit/lower.rs:6230-6236andwrite_f(emit/lower.rs:2811-2831) treatv_mov_b32withclampor nonzeroomodas a float transform rather than a bitwise copy. A maskedv_mov_b32_e64 v4, s24withomod != 0orclampwould be misclassified bysame_underas an identity write.check_phitraverses loop-header backedges:Unlike
lane_phi(resource.rs:1951),check_phi(resource.rs:1673) does not reject loop headers (rpo[pred] >= rpo[pb]). Becausestructure.rs:1400-1402forgets loop-redefined atoms across backedges, mixing exit-iteration facts inknownwith a backedge check can makeconsistent(&edge)returnfalseand silently discard a live loop-carried value.Additional notes
resource.rs:1587-1598): scanning only earlier instructions in the same block and local phis misses reaching definitions from dominators; in IR, the prior value of the overwritten VGPR is already carried oninst.read(reg).resource.rs:1651-1684): expandingvaandvbsequentially rather than pairing matching predecessors allows cross-edge comparisons when both operands are phis from the same block.joined_descriptor_redundant_partial_writeshould also assert the traced descriptors/waterfall counts (andjoined_descriptor_non_redundant_partial_write_failswill start genuinely exercising thes28 != s24mismatch instead of failing at the pre-join input).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.