Shaders: cap BDD memo table and bail out early on overflow #288
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!288
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/288/head"
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?
@Yaekai on GitHub · 2026-11-24 02:03 UTC · original
Yaekai:fix/shader-bdd-memo-cap→main· +15 −1 · 1 files · 1 commits · merged 2026-11-25 00:19 UTCProblem
During live GTA VI world loading (with concurrent background pipeline compilation in
pipeline::make),victory_shader::structure::Bools::memo(HashMap<(Bool, Bool, Bool), Bool>) can grow unbounded and trigger a 35.6 MB (2^21buckets)HashMap::reserve_rehashallocation failure:Two issues cause this in
crates/victory-shader/src/structure.rs:Bools::nodesis capped atMAX_NODES, butBools::memohad no cap and can grow quadratically/cubically in the number of nodes.mk()setsself.overflow = true,ite()andforget()did not bail out early and continued recursing and inserting intoself.memo.Changes
MAX_MEMO = 1 << 18(~4.5 MB max) and clearself.memowhen it reachesMAX_MEMO(it is purely a cache).Bool::FALSEimmediately at the top ofBools::ite()andBools::forget()whenself.overflowis set, and skipself.memo.inserton overflow.Verification
cargo test -p victory-shader— 71/71 passed.rustfmt --edition 2024 --check crates/victory-shader/src/structure.rs— clean.victory translateonshaders.rpf(26,084 programs): all 26,084 programs structure identically with 0 regressions.@jeremygold02 on GitHub · 2026-11-24 04:17 UTC · original
Tested PR #288 at head
176c766ab1814ab4be0602709f2f80abb466fd84(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at176c766ab1814ab4be0602709f2f80abb466fd84.cargo test --locked -p victory-shader structure— passed (ok. 5 passed; 0 failed; 0 ignored; 0 measured; 64 filtered out; finished in 0.00s ); cases: structure::tests::divergent_if_becomes_a_lane_branch, structure::tests::exec_narrowed_without_a_branch_leaves_a_guard, structure::tests::divergent_loop_exits_per_lane, structure::tests::scalar_branches_stay_uniform, and 1 more.Behavior covered: Exercises shader control-flow structure analysis after bounding the BDD ite memo table; no dedicated new test was added in this PR.
Code: crates/victory-shader/src/structure.rs