Shaders: keep prior per-lane descriptor word across redundant masked moves (fixes #750) #1182

Closed
github-bot wants to merge 1 commit from gh-pr/1182/head into gh-pr/1182/base
Owner

@⁠R0D4X on GitHub · 2026-11-24 16:21 UTC · original
R0D4X:fix/issue-750-redundant-per-lane-write → main · +540 −7 · 2 files · 1 commits · closed without merging

Summary

Fixes #750.

When a per-lane descriptor joined across control flow is followed by a plain predicated v_mov_b32 that re-writes one of its VGPR words with the exact value every active lane already holds, Tracer::lane_value previously refused the program with "a per-lane descriptor written where some lanes may keep the old one".

What changed

  • crates/victory-shader/src/resource.rs:
    • Added Tracer::redundant_vmov and Tracer::equals_under: when Tracer::runs cannot prove that every lane in known executes a plain v_mov_b32, check whether the destination VGPR's prior SSA value (inst.read(Reg::V(reg))) already equals the move's source on every feasible active lane (known ∧ reach[site] ∧ guard, walking forward phis and v_cndmask_b32 joins). If proven, the move is a no-op and lane_value continues from the prior VGPR value; otherwise the conservative refusal is unchanged.
    • Added Tracer::lanes_meet (with canonical pure v_cmp*/v_cmpx* comparison keys and BDD-order backtracking meet_equiv, fast-pathing straight through Bools::meet when no two lane-compare atoms share a key) so repeated comparisons of identical SSA operands (including operand swaps and integer negations, without unsafe float NaN negations) are recognized as equivalent without mutating structure::Bools.
    • Added 4 synthetic unit tests in resource::tests covering the exact #750 repro, a negated integer compare on the else arm, and two negative cases (writing the other arm's word; writing under a wider predicate mask) that must still be refused.
  • crates/victory-shader/src/emit/waterfall_tests.rs:
    • Added lanes_sample_their_arm_after_a_redundant_masked_write to verify DXIL lowering, dxil.dll validation, and end-to-end execution on both host GPU hardware and D3D12 WARP.

Verification

  • Hardware / OS: Windows 11, NVIDIA GeForce RTX 5080 (Blackwell, Wave32), Rust 1.98.1
  • cargo xtask policy: passed (154 files ok)
  • cargo clippy --workspace --all-targets -- -D warnings and --all-features: passed
  • cargo test --workspace: 347 passed, 0 failed (including victory-shader 125/125, running the new waterfall test on RTX 5080 + WARP with dxil.dll validation)
  • Offline A/B regression check (victory translate --list over 26,096 title programs): 0 regressions (25,736 / 26,096 tracked before and after; no game data or dumps included).
**@⁠R0D4X** on GitHub · 2026-11-24 16:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1182) `R0D4X:fix/issue-750-redundant-per-lane-write` → `main` · +540 −7 · 2 files · 1 commits · closed without merging ### Summary Fixes #750. When a per-lane descriptor joined across control flow is followed by a plain predicated `v_mov_b32` that re-writes one of its VGPR words with the exact value every active lane already holds, `Tracer::lane_value` previously refused the program with `"a per-lane descriptor written where some lanes may keep the old one"`. ### What changed - **`crates/victory-shader/src/resource.rs`**: - Added `Tracer::redundant_vmov` and `Tracer::equals_under`: when `Tracer::runs` cannot prove that every lane in `known` executes a plain `v_mov_b32`, check whether the destination VGPR's prior SSA value (`inst.read(Reg::V(reg))`) already equals the move's source on every feasible active lane (`known ∧ reach[site] ∧ guard`, walking forward `phi`s and `v_cndmask_b32` joins). If proven, the move is a no-op and `lane_value` continues from the prior VGPR value; otherwise the conservative refusal is unchanged. - Added `Tracer::lanes_meet` (with canonical pure `v_cmp*`/`v_cmpx*` comparison keys and BDD-order backtracking `meet_equiv`, fast-pathing straight through `Bools::meet` when no two lane-compare atoms share a key) so repeated comparisons of identical SSA operands (including operand swaps and integer negations, without unsafe float NaN negations) are recognized as equivalent without mutating `structure::Bools`. - Added 4 synthetic unit tests in `resource::tests` covering the exact #750 repro, a negated integer compare on the `else` arm, and two negative cases (writing the other arm's word; writing under a wider predicate mask) that must still be refused. - **`crates/victory-shader/src/emit/waterfall_tests.rs`**: - Added `lanes_sample_their_arm_after_a_redundant_masked_write` to verify DXIL lowering, `dxil.dll` validation, and end-to-end execution on both host GPU hardware and D3D12 WARP. ### Verification - **Hardware / OS:** Windows 11, NVIDIA GeForce RTX 5080 (Blackwell, Wave32), Rust 1.98.1 - `cargo xtask policy`: passed (`154 files ok`) - `cargo clippy --workspace --all-targets -- -D warnings` and `--all-features`: passed - `cargo test --workspace`: **347 passed, 0 failed** (including `victory-shader` 125/125, running the new waterfall test on RTX 5080 + WARP with `dxil.dll` validation) - Offline A/B regression check (`victory translate --list` over 26,096 title programs): **0 regressions** (`25,736 / 26,096` tracked before and after; no game data or dumps included).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:22:45 +00:00
github-bot closed this pull request 2026-11-26 04:22:45 +00:00
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 17:27 UTC · original

Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main ffe310e plus #1017 (main's host build fails without it: E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).

translate valid SPIR-V RADV pipeline
base 666 / 768 656 656
your head 666 / 768 656 656

No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you handle, so this is a no-regression result only (same 10 SPIR-V validation failures as the base).

Not tested: in-game.

**@⁠pablogonz12** on GitHub · 2026-11-24 17:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1182#issuecomment-7139221851) Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main `ffe310e` plus #1017 (main's host build fails without it: `E0425 host_resource`), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped). | | translate | valid SPIR-V | RADV pipeline | |---|---|---|---| | base | 666 / 768 | 656 | 656 | | your head | 666 / 768 | 656 | 656 | No program gained or lost and the failure table is identical to the base, reason for reason: nothing in this capture reaches the class you handle, so this is a no-regression result only (same 10 SPIR-V validation failures as the base). Not tested: in-game.
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 18:00 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 8c94b5c: cargo test -p victory-shader passes, 125 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 18:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1182#issuecomment-7140025390) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 8c94b5c: `cargo test -p victory-shader` passes, 125 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:34 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Fix for #750 ('per-lane descriptor written where some lanes may keep the old one'): that refusal class is 0 in main after today's lane-condition fixes; same issue as #1229.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1182#issuecomment-7148645776) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Fix for #750 ('per-lane descriptor written where some lanes may keep the old one'): that refusal class is 0 in main after today's lane-condition fixes; same issue as #1229. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1182
No description provided.