GPU: a list's state prelude is made the first time it has work to do #3236
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!3236
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3236"
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?
@Luislariosss on GitHub · 2026-11-26 14:07 UTC · original
Luislariosss:perf/lazy-prelude→main· +28 −13 · 1 files · 1 commits · openProblem
Every
HostListmade aD3D12CommandAllocatorand a direct command list for its state prelude when the list was created. The prelude only runs when a list has a depth twin or a state transition to record before its work, and most lists never do: the pair was made and closed for nothing, for every list the title creates.Change
crates/victory-gpu/src/host.rs: the prelude is aOnceLock, made byHostList::preludethe first time it has work to do. Same allocator and list type, same thread (the submitting one), same error path (fail) if creation fails. No API or behaviour change.Measurement
Ryzen 5 9600X, RX 9060 XT 16 GB, 15.2 GB RAM, Windows. Same branch and runner, cold cache; only this commit differs between the two runs (r39 before, r42 after).
Free RAM at the end: 1,084 MB before, 1,269 MB after. Loose windows still go idle (642 windows, 3.0 GB reclaimed in r42 against 720 windows, 3.4 GB in r39), so the eviction keeps working with the prelude made later. Zero allocation errors, exceptions or device removals in either run.
Free RAM is noisy because of standby; commit is the number that matters for the pagefile.
Tests
cargo test -p victory-gpu: 231 passed, 1 ignored (232). With--all-features: 246 passed, 1 ignored (247). Clippy clean with--all-targetsin both.cargo build -p victory --lockedclean.Risk
prelude()is also touched by #3162 (a pool per use) and #2908 (parallel recording). This change is orthogonal — the first pair is still made on demand — but whichever lands second will need a small rebase.@AurumCarlos on GitHub · 2026-11-26 14:18 UTC · original · reviewed
Nice, small change, and the commit numbers are a good way to show it. The
OnceLockis only touched fromprelude()on the submitting thread,host()must exist for aHostListto exist, and spare lists keep their prelude once made, so reuse throughSPAREstill benefits. I agree with the note about #3162 needing a rebase.One behaviour change worth stating, because "no behaviour change" isn't quite true for the failure path. On
main, a failedCreateCommandAllocator/CreateCommandListfor the prelude happens insidenew_list()and comes back as anErr. Its callers degrade:next_segmentreturnsNone,restartskips the replacement (_ => continue), and list creation fails back to the title. With this change, the same failure happens at submission insideget_or_initand goes tofail(..), which aborts the process unlessON_FAILUREis set.The PR targets exactly the near-full-commit situation where that creation is most likely to fail, so it moves an out-of-memory from a point the title can survive to one it can't. Recording the prelude already calls
failon error, so this may well be acceptable (a list that needs a prelude can't run without one). But the description should say so, and thefailmessage could name memory pressure as the likely cause, so a report from a low-RAM machine is easy to read.@oni-swr on GitHub · 2026-11-26 15:03 UTC · original
WARP verification at head
432b0069(main63bcca43as control).OnceLock).Software adapter (WARP, Microsoft Basic Render Driver), not a physical GPU. Synthetic tests only, no game files. Run with
VICTORY_WARP=1 VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --features diagnostics -j 4and dxil.dll available. Test report only, no code changes.AI-assisted: verification by Claude Code (Claude Sonnet 5.5).
@Dukestar69 on GitHub · 2026-11-26 16:11 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
HostList::preludeviaOnceLockon first prelude work avoids allocating a D3D12 command allocator and command list for lists that never need state transitions or depth-twin preludes.cargo test -p victory-gpu --lib host::tests:: -- --test-threads=1(RTX 5090): 12 passed, 0 failed.cargo test -p victory-gpu --lib draw:: -- --test-threads=1(RTX 5090): 20 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.