Shaders: O(|known|) BDD forced() sweep, read-only implies(), per-block reuse in finish(), and FxHash in meet_in() #2662
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!2662
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2662"
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?
@RVZO6 on GitHub · 2026-11-25 17:43 UTC · original
RVZO6:rvzo/structure-bdd-fast→main· +225 −60 · 1 files · 1 commits · openClaimed in #1633: #1633
Summary
Eliminates quadratic BDD node creation and repeated scans during CFG structurisation (
crates/victory-shader/src/structure.rs,+225/-60), with identical reduced OBDD output:Bools::forced()sweep: replacesBools::given()'sO(|b| * |vars(b)|)mutatingimpliesloop with a single bottom-up pass over reachable edges of the reduced OBDD.Bools::implies(): checks entailment directly without allocating temporary BDD nodes or evicting memo entries.finish(): computesforced(cond[n])once per block and reuses it across guards and exits.meet_in(): switches the refuted set from default SipHash to the existingFxhasher.Measured (
--release structure::tests::bench_bools)main)given()(n = 8)20.43 µs0.22 µsgiven()(n = 13)655.25 µs0.54 µsNot a duplicate of
Structured::activereachability rather thanBools::given/implies/forced/meet_in). No open PR or #1633 claim overlapsBoolsBDD evaluation.Verification
windows-latestMSVC + WARP SM 6.6 CI (both clippy-D warningsprofiles,xtaskpolicy 6/6,victory-shader281/281 including equivalence tests comparingforced()/implies()against the previous BDD implementations): https://github.com/RVZO6/VIctory/actions/runs/45666985023AI-assisted: T3 Code (Antigravity, gemini-4-neon)
@kotekompotek on GitHub · 2026-11-25 17:54 UTC · original
Reviewed: the read-only
implies/implies_in(localprovedset, no memo or node allocation) is sound — BDD implication is decidable by simultaneous top-variable descent.overflowreturning true preserves the conservative direction. FxHash swap in the hot BDD maps is a straight win. CI green.@oni-swr on GitHub · 2026-11-25 18:21 UTC · original
Independent verification of #2662 (BDD
forced()sweep, read-onlyimplies(),given_with)PR head
95f56a53f8ff90f700d74d102ad79538bad68771, merges cleanly ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca(git merge-tree).Environment: Windows 11 Pro 10.0.26200, rustc 1.98.1,
VICTORY_WARP=1+VICTORY_D3D12_WARP=1on every run (WARP adapter only, no physical GPU created), DXC/dxil 1.8.2502.11 (Windows SDK 10.0.26100.0, viaVICTORY_DXIL),cargo ... -j 4 --locked.Tests/clippy vs baseline.
origin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca:cargo test -p victory-shader --lib --locked -- --test-threads=1= 267 passed, 3 failed, 3 ignored. The 3 failures are WARP limits and are the same 3 in every variant below:a_mask_joined_with_data_at_a_uniform_loop_is_its_numberandpermutes_read_the_lane_named_and_zero_from_lanes_left_out("no pipeline for a wave of 32"), andgathers_at_a_level_match_the_hardware(WARP gather result differs). Clippy:cargo clippy -p victory-shader --all-targets --locked= 0 warnings.With #2662: 269 passed, 3 failed (same 3), 3 ignored (+2 new tests:
forced_matches_implies_across_disjunctive_skips_and_random_bdds,read_only_implies_matches_and_not_without_allocating_nodes). Clippy: 0 warnings.Equivalence. I read the full diff.
forced()(variable v is forced iff no reachable non-FALSE edge skips v and every reachable node testing v takes one polarity) is correct for reduced OBDDs; theTERMINALfar-edge correctly stops forcing past an edge into TRUE.implies()returns true on overflow like the oldite-based form (which yielded FALSE on overflow).given_with(known = FALSE)followshiedges, matching the old "every atom implied true". Output check: a throwaway, uncommitted patch hashed every containerShader::finishemits during the lib test run: 650 containers (476 distinct), byte-identical toorigin/main.Perf (release,
bench_bools, synthetic BDDs).givenat n=8/10/12/13 on base: 15 / 55 / 240 / 465 us (its own fast path); with the three shader PRs combined: 0.25 / 0.44 / 0.44 / 0.45 us. Small n (2, 4) unchanged within noise. Caveat: this isolatesgiven; the benchmark'sknownis cheap to walk, and the effect on real shaders was not measured.Findings: no bugs. Observation: since
implies/forcedno longer allocate BDD nodes, theMAX_NODESoverflow (TOO_LARGE) should be hit less often than before; that can only turn aTOO_LARGEinto a success, not the reverse. Not measured on real shaders.Limits: no physical GPU (WARP only), no game files; the 3 WARP-limited tests above are therefore not verified on hardware. Benchmarks are synthetic, release mode, one machine, two back-to-back rounds each for base and combined; they say nothing about real-title shaders.
AI-assisted: independent verification by Claude Code / Claude Sonnet 5.5, run on behalf of oni-swr. Claims for #1633.
@oni-swr on GitHub · 2026-11-25 18:23 UTC · original
Composition check: #2662 + #2664 + #2665 together
Heads: #2662
95f56a53f8ff90f700d74d102ad79538bad68771, #2664e6ab345e7b73be37a0741a54767e061aad35239c, #26658105fdcfb68ac99d79ea728847a0f555b7a41521, merged in that order ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbcaas a local merge commit (31ed3543e4c18b978f7b0a699a71f8d18e52a81b, not pushed). No conflicts: the three touch disjoint files (structure.rs;gfx10/fields.rs+ir.rs;emit/bitcode.rs+emit/shader.rs).Environment: Windows 11 Pro 10.0.26200, rustc 1.98.1,
VICTORY_WARP=1+VICTORY_D3D12_WARP=1(WARP only), dxil 1.8.2502.11 (SDK 10.0.26100.0),-j 4 --locked.cargo test -p victory-shader --lib --locked -- --test-threads=1: 276 passed, 3 failed, 5 ignored. That is exactly baseline 267 + 2 + 4 + 3 new tests; the 3 failures are the same WARP-limited ones as onorigin/main(wave-of-32 x2, WARP gather).cargo clippy -p victory-shader --all-targets --locked: 0 warnings.origin/main, plus one extra from #2665's new test (throwaway hashing patch, not committed).shader::op4096 calls 2.84-2.94 ms -> 0.53-0.56 ms;ir::build2048 insts 2.24-2.29 ms -> 1.80-1.84 ms; 64movrelinsts 426-456 us -> 88-103 us; bitcode writer, 256x512 synthetic module, 8.9-9.8 ms -> 7.0-7.1 ms; BDDgivenn=13 ~465 us -> ~0.45 us (synthetic).Limits: no physical GPU, no game files; synthetic benchmarks only.
AI-assisted: independent verification by Claude Code / Claude Sonnet 5.5, run on behalf of oni-swr. Claims for #1633.
@fuzeofficlal on GitHub · 2026-11-25 19:27 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP +
dxil.dllverification, code review, and same-machine--releasebenchmark comparison of95f56a53(on13f91ca):Verification (
rustc 1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll)cargo xtask policy: 184 files ok.cargo clippy --locked -p victory-shader --all-targets -- -D warningsand--features host: 0 warnings.victory-shader(structure,ir,gfx10,emit::tests,emit::lower,emit::waterfall_testson RTX 5090 + WARP +dxil.dll,emit::bitcodewith unchanged FNV-1a): 99 passed, 0 failed, 2 ignored.git merge-treeacross all three PRs (disjoint compiler stages: frontend#2664, mid-end#2662, backend#2665).Same-Machine
--releaseBenchmark (structure::tests::bench_bools)13f91ca95f56a53n=2, nodes=90.37 µs0.12 µsn=4, nodes=451.05 µs0.13 µsn=8, nodes=7658.91 µs0.14 µsn=10, nodes=306929.49 µs0.24 µsn=12, nodes=12285142.57 µs0.25 µsn=13, nodes=24573335.56 µs0.26 µsCode Review Notes
implies_in(noBools::nodesgrowth ormemochurn),O(|known|)forced()sweep (TRUE/FALSEedge handling,TERMINAL = u32::MAXordering, append-onlygiven_withsafety withcached_forced), and boundedFxHashrefutedset inmeet_inare strictly equivalent with zerounsafe. Clean and ready to merge.@Marvisak on GitHub · 2026-11-25 22:21 UTC · original
Automated triage for the maintainers.
Merge candidate (performance, same output). In
crates/victory-shader/src/structure.rs:Bools::impliesbecomes a read-only simultaneous descent with no node allocation.Bools::forcedfinds the variablesknowndecides in one walk ofknown.Lanes::finishcomputes that once per block and reuses it for guards and exits (given_with).meet_inuses the existing Fx hasher.I checked
forcedagainst the reduced-OBDD argument: a variable is forced only if no reachable non-FALSE edge skips it and all its nodes take one polarity, with an edge into TRUE skipping everything below it. Restricting by forced variables thatbdoes not contain is a no-op, so the result equals the old per-variable loop. Theknown == FALSEpath followshiedges like before, and the memo inimplies_inis sound because afalseresult short-circuits the whole walk. The new tests compareforced/implieswith the old formulations on random BDDs, and a tester reports byte-identical DXIL for all lib-test shaders. It merges cleanly; CIcheck: passing.Generated by Claude Code
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.