Repository navigation
Shaders: the lane-condition search keeps the condition sets no lane meets - #1491
rayderCode wants to merge 1 commit into
Conversation
…eets Bools::meet assigns the variables in order and searches what is left of the conditions under each assignment. Many assignments leave the same conditions (every assignment of the variables they do not tell apart), and the search tried those again each time. On large programs it ran out of its 65,536 splits and said yes, which the waterfall proof and the per-lane descriptor tracking take as a proof that failed. The search now keeps the condition sets it has finished without finding 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 as before. Translation census over the title's 26,084 programs: none lost, 61 get past resource tracking to a later refusal (a scalar memory read as data). Three refusals are empty with it: a waterfall loop whose compares do not select the access's lanes (15), a descriptor read from the first lane of computed VGPRs (38), a descriptor partly joined by control flow (8). Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
DenRakEiw
left a comment
There was a problem hiding this comment.
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 (includingconditions_with_few_distinct_remainders_are_searched_to_the_end)cargo clippy -p victory-shader --all-targets— 0 warningscargo 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
left a comment
There was a problem hiding this comment.
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).
|
I measured this offline on my own retail dump:
This and #1550 don't conflict: #1550 only adds |
Offline measurement on a retail dump, and the shader tests on AdaResult: no count change against Offline. I merged head 28c91b9 onto 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, No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
|
Automated triage for the maintainers. Closing because this change is already in Keeping the condition sets no lane meets in 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. |
Summary
Bools::meetassigns 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: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
conditions_with_few_distinct_remainders_are_searched_to_the_end: a synthetic parity case over 40 atoms. It fails onmainand 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