Game: short-circuit pipeline state enumeration once wanted hashes are found #2573
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2575"
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?
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T16:08:30Z.
Summary
Short-circuits pipeline state enumeration in
victory_game::pipelinesas soon as all wanted hashes are resolved, instead of always exhausting the entire search space.Changes
name_from_registers,depth_space, andraster_spaceinNamed::findwhen their correspondingwantsets are already empty.std::ops::ControlFlow<()>fromraster_space,depth_space,depth_from_registers, andblend_from_registerssoNamed::findandname_from_registersstop immediately once every wanted hash (or the current record's target hash) has been matched.raster_space_short_circuits_on_breakto verify early termination.Scope
Trimmed to only the
ControlFlowearly exits per triage feedback; candidate generation inblend_from_registersandraster_spaceis unchanged.Verification
cargo test -p victory-game --lockedcargo clippy -p victory-game --all-targets --target x86_64-pc-windows-msvc --locked -- -D warningscargo test -p xtask --lockedImported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:16:39Z.
Automated triage for the maintainers.
Needs work. Re-reviewed at
dfcfa60. Thevisited < 2_000_000assertion is gone, and the rewrite ofcrates/victory-game/src/pipelines.rsstill reads as behaviour-preserving (ControlFlowearly exits, the array forms ofper_target/twins, the reusedtargetsbuffers,basesdedup).Reply to the author: you are right, and our earlier comment was wrong:
apps/victory/src/prebuild.rscallsNamed::findduringvictory prebuild. That is still a one-off offline step, though. Your benchmark uses a pack whose wanted states are all D3D12 defaults. That is the best case for the early exits, because enumeration stops at once. With a real pack, any hash that is never named still walks the whole space. What would change the verdict: the time ofNamed::findin a realvictory prebuildrun, before and after, as a share of the whole command. Timings only, no title data. If that gain is small, a smaller change limited to the early exits would be easier to take.CI:
checkpassing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T05:56:05Z.
Updated to address the triage feedback:
visited < 2_000_000assertion fromthe_depth_space_holds_the_d3d12_default.Named::findis called byapps/victory/src/prebuild.rs:92duringvictory prebuild.cargo test --release -p victory-game, 9 runs, synthetic pack with matched D3D12 default depth-stencil and default rasterizer states,main63bcca4vs this PR):main: median 153.94 ms (min 153.66 ms, max 157.13 ms)[PR #2575] Game: skip redundant pipeline state enumeration and eliminate inner-loop blend Vec allocationsto [PR #2575] Game: short-circuit pipeline state enumeration once wanted hashes are foundImported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T10:39:34Z.
Trimmed this PR down to only the
ControlFlowearly exits (and rebased onto currentmain), dropping theblend_from_registersallocation rewrite so the change stays small and focused as suggested.Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T08:51:11Z.
I found a case where the early exit changes which pipeline states
Named::findcan recover ona894f0d. In a generated two-record pack, both records have stencil disabled. The first register image retains the inactive masks and can supply both depth hashes, while the second image omits the masks. The PR finds the first hash, stops enumerating that image, and leaves the second hash unnamed. The same test finds both on #3698.dd74dc4is a follow-up directly on your current head. It keeps the early exit once no depth or blend hashes of that kind remain, and adds the two-record regression. The test fails ona894f0dand passes with the follow-up. All 17victory-gametests, strict Clippy for that crate and the asset policy check passed. I also resolved the overlapping hunk with #3698 locally and all 17 tests passed together.@reeledMarek, could you review the follow-up for inclusion here? Please retain the Git author if you cherry-pick or rebase it, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding it into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T10:08:22Z.
I combined your current head and the two-state regression follow-up with #3698, #3700 and #3707 in 7b1113d. The branch keeps all four PR heads and the regression commit in its history. The one overlapping register hunk retains the per-record skip and stops enumerating a kind only when its wanted set is empty.
I checked full
Named::findon Windows with 25,003 generated graphics records and 25,000 effects. The state bytes and source labels matched main across separate release binaries. With all hashes named by the first effect, the two process medians were 140–160 ms on main and 2.75–3.79 ms on the combined tree. With a remaining depth hash and two register-derived states, the medians were 159–160 ms and 136–137 ms. These are generated prebuild fixtures.All 17 game tests passed, including the two-state regression, along with strict Clippy and asset policy. @reeledMarek, this branch is available for your review. Please retain the Git authors on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the changes into another commit.AI-assisted with OpenAI Codex.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.