Shaders: the lane-condition search keeps the condition sets no lane meets #1490

Closed
rayderCode wants to merge 1 commit from upstream-pr/1491 into main
rayderCode commented 2026-11-24 18:24:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rayderCode on 2026-11-24T18:24:07Z.


Summary

Bools::meet assigns variables in order and tries each assignment's remaining conditions again, even when it has already found them to have no lane. On large programs it ran out of its 65,536 splits and answered yes, which the waterfall proof and the per-lane descriptor tracking read as a failed proof. It now keeps the condition sets it has finished without a lane, and ends at once on a node both held and not held. Only a finished search says no, so what it keeps is exact; the budget is unchanged.

Effect

Translation census over the title's 26,084 programs, against ffe310e: none lost, 61 get past resource tracking to a later refusal (a scalar memory read as data). That empties three refusals:

Refusal Before After
a waterfall loop whose compares do not select the access's lanes 15 0
a descriptor read from the first lane of computed VGPRs 38 0
a descriptor partly joined by control flow 8 0

Programs with tracked resources go from 25,724 to 25,785. DXIL emitted is unchanged, since all 61 then stop at the scalar-memory refusal. No other program changes outcome.

On one of the 15, the two queries that gave up needed 71,246 and 95,446 splits without this change and both come out as "no lane".

Verification

  • New test conditions_with_few_distinct_remainders_are_searched_to_the_end: a synthetic parity case over 40 atoms. It fails on main and passes here.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features.
  • cargo test --workspace --locked: 343 passed, 6 ignored.
  • cargo xtask policy: 154 files ok.

Offline translation only: no title run, no DXIL validation or pipelines, and no shader contents included. AI-assisted (Claude).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588592616 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1491). Originally posted by [rayderCode](https://github.com/rayderCode) on 2026-11-24T18:24:07Z. --- ## Summary `Bools::meet` assigns variables in order and tries each assignment's remaining conditions again, even when it has already found them to have no lane. On large programs it ran out of its 65,536 splits and answered yes, which the waterfall proof and the per-lane descriptor tracking read as a failed proof. It now keeps the condition sets it has finished without a lane, and ends at once on a node both held and not held. Only a finished search says no, so what it keeps is exact; the budget is unchanged. ## Effect Translation census over the title's 26,084 programs, against `ffe310e`: none lost, 61 get past resource tracking to a later refusal (`a scalar memory read as data`). That empties three refusals: | Refusal | Before | After | |---|---|---| | a waterfall loop whose compares do not select the access's lanes | 15 | 0 | | a descriptor read from the first lane of computed VGPRs | 38 | 0 | | a descriptor partly joined by control flow | 8 | 0 | Programs with tracked resources go from 25,724 to 25,785. DXIL emitted is unchanged, since all 61 then stop at the scalar-memory refusal. No other program changes outcome. On one of the 15, the two queries that gave up needed 71,246 and 95,446 splits without this change and both come out as "no lane". ## Verification - New test `conditions_with_few_distinct_remainders_are_searched_to_the_end`: a synthetic parity case over 40 atoms. It fails on `main` and passes here. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`. - `cargo test --workspace --locked`: 343 passed, 6 ignored. - `cargo xtask policy`: 154 files ok. Offline translation only: no title run, no DXIL validation or pipelines, and no shader contents included. AI-assisted (Claude). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DenRakEiw commented 2026-11-24 19:03:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T18:27:58Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib structure:: — 6 passed, 0 failed (including conditions_with_few_distinct_remainders_are_searched_to_the_end)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean memoization of unsatisfiable condition sets in Bools::meet_in with canonicalized/sorted keys and immediate contradiction check (w[0].0 == w[1].0). Looks great.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045042565 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1491#pullrequestreview-6045042565). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T18:27:58Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib structure::` — 6 passed, 0 failed (including `conditions_with_few_distinct_remainders_are_searched_to_the_end`) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean memoization of unsatisfiable condition sets in `Bools::meet_in` with canonicalized/sorted keys and immediate contradiction check (`w[0].0 == w[1].0`). Looks great. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 19:03:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T18:42:07Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Execution/valu tests are #[cfg(all(test, windows))] and were not run here; lowering/structure coverage only.

Bools::meet dead-set caching fixes a real soundness bug: condition sets with few distinct remainders (the parity example) exhausted MAX_MEET and returned a wrong "yes". The new code only caches exact false results (out-of-budget still returns true), sorts/dedups the condition set, and short-circuits a node held and not held. The 40-bit parity regression test is exactly the shape that used to blow the budget. Structure tests pass on macOS (+1).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045232590 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1491#pullrequestreview-6045232590). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T18:42:07Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), `cargo test -p victory-shader --locked` → 97 passed, 0 failed. Execution/valu tests are `#[cfg(all(test, windows))]` and were not run here; lowering/structure coverage only. `Bools::meet` dead-set caching fixes a real soundness bug: condition sets with few distinct remainders (the parity example) exhausted `MAX_MEET` and returned a wrong "yes". The new code only caches exact `false` results (out-of-budget still returns true), sorts/dedups the condition set, and short-circuits a node held and not held. The 40-bit parity regression test is exactly the shape that used to blow the budget. Structure tests pass on macOS (+1).
EduAzevedo commented 2026-11-24 20:03:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by EduAzevedo on 2026-11-24T19:56:32Z.


I measured this offline on my own retail dump: victory translate --jobs 8 --list over 26,148 programs, 28c91b9 vs main ffe310e. Windows 11, Ryzen 7 5700G.

  • Matches your numbers. 61 programs change reason, all now stopping at "a scalar memory read as data":
    • 38 "a descriptor read from the first lane of computed VGPRs"
    • 15 "a waterfall loop whose compares do not select the access's lanes"
    • 8 "a descriptor partly joined by control flow"
  • Nothing else moves. Refused programs stay 4,003 → 4,003, with 0 no longer refused and 0 newly refused. Emitted DXIL is unchanged.
  • meet never gives up with this branch. A local, uncommitted counter on the *budget == 0 path fired in 823 refused programs on main. On this branch it fired in 0 programs, across the whole corpus. The census took 156 s, about the same as main.
  • That doesn't free the lane-mask refusals. On main, most programs refused with "a select on an untracked mask" (283 of 288) or "a lane mask holding lanes elsewhere read as data" (257 of 272) also had meet give up. With this branch, those refusals are exactly the same. So the give-ups only came along with them, and they come from missing rules, not from the budget.
  • Raising MAX_MEET isn't an alternative. At 1 << 22 the same census was still running after 36 minutes, so caching the dead sets as you do is the right approach.

This and #1550 don't conflict: #1550 only adds Bools::meet_beside and uses it in waterfall(). Counts only here, no game data. AI-assisted measurement.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142814978 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1491#issuecomment-7142814978). Originally posted by [EduAzevedo](https://github.com/EduAzevedo) on 2026-11-24T19:56:32Z. --- I measured this offline on my own retail dump: `victory translate --jobs 8 --list` over 26,148 programs, `28c91b9` vs main `ffe310e`. Windows 11, Ryzen 7 5700G. - **Matches your numbers.** 61 programs change reason, all now stopping at "a scalar memory read as data": - 38 "a descriptor read from the first lane of computed VGPRs" - 15 "a waterfall loop whose compares do not select the access's lanes" - 8 "a descriptor partly joined by control flow" - **Nothing else moves.** Refused programs stay 4,003 → 4,003, with 0 no longer refused and 0 newly refused. Emitted DXIL is unchanged. - **`meet` never gives up with this branch.** A local, uncommitted counter on the `*budget == 0` path fired in 823 refused programs on main. On this branch it fired in 0 programs, across the whole corpus. The census took 156 s, about the same as main. - **That doesn't free the lane-mask refusals.** On main, most programs refused with "a select on an untracked mask" (283 of 288) or "a lane mask holding lanes elsewhere read as data" (257 of 272) also had `meet` give up. With this branch, those refusals are exactly the same. So the give-ups only came along with them, and they come from missing rules, not from the budget. - **Raising `MAX_MEET` isn't an alternative.** At 1 << 22 the same census was still running after 36 minutes, so caching the dead sets as you do is the right approach. This and #1550 don't conflict: #1550 only adds `Bools::meet_beside` and uses it in `waterfall()`. Counts only here, no game data. AI-assisted measurement.
sinan-cmyk commented 2026-11-24 21:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:13:14Z.


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

Result: no count change against main.

Offline. I merged head 28c91b9 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 main, 21,724 with this PR.

61 programs get through resource tracking and now stop at "a scalar memory read as data", the gap that #953, #1103 and #1319 address: 38 from "a descriptor read from the first lane of computed VGPRs", 15 from "a waterfall loop whose compares do not select the access's lanes" and 8 from "a descriptor partly joined by control flow". So this PR may gain programs stacked on #1319 or #1402.

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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143208874 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1491#issuecomment-7143208874). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T20:13:14Z. --- ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 28c91b9 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 `main`, 21,724 with this PR. 61 programs get through resource tracking and now stop at "a scalar memory read as data", the gap that #953, #1103 and #1319 address: 38 from "a descriptor read from the first lane of computed VGPRs", 15 from "a waterfall loop whose compares do not select the access's lanes" and 8 from "a descriptor partly joined by control flow". So this PR may gain programs stacked on #1319 or #1402. **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).
upstream-sync closed this pull request 2026-11-25 01:06:42 +00:00
Marvisak commented 2026-11-25 01:08:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:41:20Z.


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

Keeping the condition sets no lane meets in Bools::meet: main's meet_in has the same refuted set (structure.rs 245-281).

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148773137 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1491#issuecomment-7148773137). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:41:20Z. --- Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Keeping the condition sets no lane meets in `Bools::meet`: main's `meet_in` has the same `refuted` set (structure.rs 245-281). 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1490
No description provided.