Reuse fenced GPU upload scratch across command lists #1525
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!1525
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1525/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?
@franticfrostin on GitHub · 2026-11-24 18:45 UTC · original
franticfrostin:gpu/upload-scratch-reuse→main· +202 −34 · 1 files · 1 commits · closed without mergingSummary
Recycle idle D3D12 upload scratch across command lists after the GPU has finished using it. The shared pool holds up to 4 MiB. If the fence wait fails, the submission stops through VIctory’s existing GPU failure reporter before the buffers can be recycled.
Testing
On an RTX 4060 Laptop GPU, two 170-second Series S runs compared pooling on and off in the same build. New scratch allocations dropped from 1,669 to 118, while peak scratch capacity rose from 27.5 to 28.5 MiB. A 150-second Series X run also reached world rendering with the pool enabled.
The earlier live runs used 256 KiB chunks and PR #431. The current patch is rebased onto
940d32fand preserves upstream’s on-demand chunk sizing from 64 KiB to 4 MiB. The shared idle pool is capped at 4 MiB in total and reuses chunks of the requested capacity.On the rebased patch, four scratch tests passed on hardware and WARP. Workspace Clippy with all features, the default-feature GPU Clippy check, and the asset-policy check also passed. Frame rate and long-session stability remain unverified.
Related work includes dedicated upload pooling in #982 and scratch chunk sizing in #1246. Codex helped write and test this patch.
@Marvisak on GitHub · 2026-11-25 01:30 UTC · original · edited 2026-11-25 06:32 UTC
Automated triage for the maintainers.
Merge candidate. It merges cleanly. In
crates/victory-gpu/src/host.rs,HostList::resetnow trims each list's scratch to the peak of its last two recordings, and hands the rest to a process-wide idle pool (IDLE_SCRATCH, at most 4 MiB, reused by exact capacity).Scratch::reservekeeps the old growth policy, and it no longer moves the cursor when an allocation fails. This is only safe if no list is reset while its work is still running. I checked that:Host::executehas the onlyExecuteCommandListsin the crate, and it waits on the fence for every group. The PR makes a failed fence wait fatal (fail(..)with the removal report) instead of a warning, which closes the one path where a chunk could be recycled while still in use. That behaviour change is deliberate and worth a maintainer's glance. The measured drop from 1,669 to 118 new scratch allocations in a 170 s run is in the description. Overlap with #982 (dedicated uploads) and #1246 (chunk sizing) is noted there.CI: passing (
check).Generated by Claude Code
@Marvisak on GitHub · 2026-11-25 22:01 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because the gain is not shown on
main. The measurement (new scratch allocations 1,669 to 118) was taken on an older base with fixed 256 KiB chunks plus another PR. Onmaineach host list already keeps its scratch chunks across resets, and since9cc37c5fhost lists themselves are recycled with their chunks, so the churn the pool removes is not known to exist; the trimming can add some, because a list whose use alternates would free chunksmainkeeps. The fatal fence-wait change is unrelated and should be its own PR.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed