Shaders: a deep block's reach no longer hides a waterfall's proof #1550

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

@⁠EduAzevedo on GitHub · 2026-11-24 19:03 UTC · original
EduAzevedo:fix/waterfall-meet-reach → main · +43 −1 · 2 files · 1 commits · closed without merging

Title: Shaders: a deep block's reach no longer hides a waterfall's proof

What

15 programs (12 mesh, 3 vertex) were refused with "a waterfall loop whose compares do not select the access's lanes", although their loops are the plain LLVM waterfall:

  • two v_cmp_eq_u64 (the first in the VOPC form, into VCC);
  • s_and_b64 and s_and_saveexec_b64;
  • the access, then s_xor_b64 exec and s_cbranch_execnz.

Moving those loops into the unit tests (a sampler compared per lane, the image loaded inside the loop, VCC, inside a divergent if, as Vs, Ps and Cs) doesn't reproduce the refusal: they all prove.

The cause is in Bools::meet (crates/victory-shader/src/structure.rs). It answers yes when its search exceeds MAX_MEET case splits. In these programs the loop sits deep, around block 145, so its reach is large. A local census in waterfall() showed the solver's answers:

  • without reach, meet(&[(selected, true), (matched, false)]) is false: the proof holds;
  • with reach, it is true: the search gave up.

Adding a condition can only lower what meets, so that yes is the budget running out, not a lane.

Fix

Bools::meet_beside(aside, others) asks meet(others) first. A no from meet is exact, and fewer conditions are met at least as often, so a no there settles it. Only when the others can meet does it ask again with aside. waterfall() uses it with the block's reach as aside. No other caller changes.

Tests

  • New structure::tests::a_large_condition_aside_does_not_hide_that_the_others_never_meet. It builds a condition the search gives up on (the parity of 20 atoms) and checks:
    • plain meet answers yes;
    • meet_beside answers no for conditions that never meet;
    • meet_beside still answers yes for conditions that do.
  • cargo test -p victory-shader: 121 passed, 1 ignored (as on main).
  • cargo clippy -p victory-shader --all-targets: clean.

Measured

victory translate --jobs 8 --list, offline, on my own retail dump (26,148 programs), main ffe310e vs this branch:

main this branch
refused programs 4,003 4,003
"a waterfall loop whose compares do not select the access's lanes" 15 0
no longer refused / newly refused 0 / 0
reason changed 15 (12 Ms, 3 Vs)

All 15 now pass resource tracking and stop at "a scalar memory read as data" (the #979 area), so DXIL emitted counts don't move on main alone.

With #979. I cherry-picked Machad3x's bc2b1b5 on main, with and without this branch:

#979 only #979 + this branch
VS/PS emitted 12,321 12,323 (+2)
mesh emitted 8,380 8,386 (+6)
refused programs 3,749 3,741
newly refused 0
  • 8 of the 15 are emitted.
  • The other 7 stop at "a descriptor read only as data" (the #180 / #329 area).

No shader names, disassembly or game data are included here, only counts.

AI-assisted. The measurement is offline, so no GPU was needed. Built and tested on Windows 11 (Ryzen 7 5700G, RTX 2070 SUPER, driver 610.88).

**@⁠EduAzevedo** on GitHub · 2026-11-24 19:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1550) `EduAzevedo:fix/waterfall-meet-reach` → `main` · +43 −1 · 2 files · 1 commits · closed without merging **Title:** Shaders: a deep block's reach no longer hides a waterfall's proof ## What 15 programs (12 mesh, 3 vertex) were refused with "a waterfall loop whose compares do not select the access's lanes", although their loops are the plain LLVM waterfall: - two `v_cmp_eq_u64` (the first in the VOPC form, into VCC); - `s_and_b64` and `s_and_saveexec_b64`; - the access, then `s_xor_b64 exec` and `s_cbranch_execnz`. Moving those loops into the unit tests (a sampler compared per lane, the image loaded inside the loop, VCC, inside a divergent `if`, as Vs, Ps and Cs) doesn't reproduce the refusal: they all prove. The cause is in `Bools::meet` (`crates/victory-shader/src/structure.rs`). It answers **yes** when its search exceeds `MAX_MEET` case splits. In these programs the loop sits deep, around block 145, so its `reach` is large. A local census in `waterfall()` showed the solver's answers: - without `reach`, `meet(&[(selected, true), (matched, false)])` is **false**: the proof holds; - with `reach`, it is **true**: the search gave up. Adding a condition can only lower what meets, so that yes is the budget running out, not a lane. ## Fix `Bools::meet_beside(aside, others)` asks `meet(others)` first. A no from `meet` is exact, and fewer conditions are met at least as often, so a no there settles it. Only when the others can meet does it ask again with `aside`. `waterfall()` uses it with the block's reach as `aside`. No other caller changes. ## Tests - New `structure::tests::a_large_condition_aside_does_not_hide_that_the_others_never_meet`. It builds a condition the search gives up on (the parity of 20 atoms) and checks: - plain `meet` answers yes; - `meet_beside` answers no for conditions that never meet; - `meet_beside` still answers yes for conditions that do. - `cargo test -p victory-shader`: 121 passed, 1 ignored (as on main). - `cargo clippy -p victory-shader --all-targets`: clean. ## Measured `victory translate --jobs 8 --list`, offline, on my own retail dump (26,148 programs), main `ffe310e` vs this branch: | | main | this branch | |---|---|---| | refused programs | 4,003 | 4,003 | | "a waterfall loop whose compares do not select the access's lanes" | 15 | 0 | | no longer refused / newly refused | | 0 / 0 | | reason changed | | 15 (12 Ms, 3 Vs) | All 15 now pass resource tracking and stop at "a scalar memory read as data" (the #979 area), so DXIL emitted counts don't move on main alone. **With #979.** I cherry-picked Machad3x's `bc2b1b5` on main, with and without this branch: | | #979 only | #979 + this branch | |---|---|---| | VS/PS emitted | 12,321 | 12,323 (+2) | | mesh emitted | 8,380 | 8,386 (+6) | | refused programs | 3,749 | 3,741 | | newly refused | | 0 | - 8 of the 15 are emitted. - The other 7 stop at "a descriptor read only as data" (the #180 / #329 area). No shader names, disassembly or game data are included here, only counts. AI-assisted. The measurement is offline, so no GPU was needed. Built and tested on Windows 11 (Ryzen 7 5700G, RTX 2070 SUPER, driver 610.88).
Bools::meet answers yes when its search grows too large. In a waterfall
deep in a program, the loop block's reach made the search give up, so
the proof that the access's lanes are the compares' matches failed with
"a waterfall loop whose compares do not select the access's lanes".

A no from meet is exact, and fewer conditions are met at least as often:
Bools::meet_beside asks first without the reach, and only asks with it
when the other conditions can meet.

Offline over a retail dump (26,148 programs): 15 programs (12 mesh, 3
vertex) pass resource tracking and now stop at "a scalar memory read as
data"; no other program changes reason.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:36:02 +00:00
github-bot closed this pull request 2026-11-26 04:36:02 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 19:33 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: no count changes against main, and the tests pass on Ada.

Offline. I merged head 6c9e0ec onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost. 15 programs that already fail move from "resources: a waterfall loop whose compares do not select the access's lanes" to "emit: a scalar memory read as data". So this PR gets them through resource tracking, and they now stop at the later scalar-read gap that #953, #1103 and #1319 address.

This is the expected result for a correctness fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests. With the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 19:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1550#issuecomment-7142273774) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count changes against `main`, and the tests pass on Ada.** **Offline.** I merged head 6c9e0ec onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on both, 0 gained, 0 lost. 15 programs that already fail move from "resources: a waterfall loop whose compares do not select the access's lanes" to "emit: a scalar memory read as data". So this PR gets them through resource tracking, and they now stop at the later scalar-read gap that #953, #1103 and #1319 address. This is the expected result for a correctness fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests.** With the same merge, `cargo test --locked -p victory-shader --lib` passed 121, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

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

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

Waterfall proofs hidden by a deep block's reach exhausting Bools::meet: main fixed this in resource.rs meet (small conditions first) and the refuted memo; that refusal class is 0.

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:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1550#issuecomment-7148790067) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Waterfall proofs hidden by a deep block's reach exhausting `Bools::meet`: main fixed this in resource.rs `meet` (small conditions first) and the refuted memo; that refusal class is 0. 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!1550
No description provided.