GPU: pool mapped upload buffers across command list resets #1894
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!1894
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1894"
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?
@n-romanovich on GitHub · 2026-11-25 00:16 UTC · original
n-romanovich:perf/gpu-upload-buffer-pool→main· +71 −7 · 1 files · 1 commits · openProblem
HostList::uploadpreviously allocated a fresh committedD3D12_HEAP_TYPE_UPLOADresource (Host::upload_buffer) for every copy and dropped it when the command list reset, causing repeatedCreateCommittedResource/Map/Releaseoverhead during texture and buffer uploads.Fix
crates/victory-gpu/src/host.rs:upload_pool: Mutex<Vec<(u64, ID3D12Resource, usize)>>toHost, bounded byMAX_POOLED_BUFFERS(64) andMAX_POOLED_BYTES(64 MiB).Host::take_upload(reuses the smallest pooled buffer in[size, 2 * size], otherwise allocates viaupload_buffer) andHost::return_upload.Deferred::pooled_uploadsinHostList::uploadand return them toHostinHostList::reset(which only runs after the list's last submission has completed).host::batch::upload_buffers_are_pooled_across_list_resetsto verify that resetting aHostListreturns its upload buffer to the pool and the nextuploadof the same size reuses the exact sameID3D12Resourceand mapped pointer.Verification
cargo test -p victory-gpu --locked -- upload_buffers_are_pooled_across_list_resetson Windows 11 (NVIDIA RTX 5060 Ti): 1 passed, 0 failed.@Marvisak on GitHub · 2026-11-25 08:21 UTC · original
Automated triage for the maintainers.
Merge candidate.
This does what main's
shortcut:note onHostList::upload(crates/victory-gpu/src/host.rs) asked for. Upload buffers handed out byuploadnow come from a host-wide pool (take_upload: the smallest pooled buffer betweensizeand2*size) and go back to it inHostList::reset. The pool is capped at 64 buffers and 64 MiB. Reuse is safe only if a list's GPU work has finished beforereset. I checked that:reset's contract on main says so, and the title-facingresetinlist.rsrelies on submissions being waited for. Buffers are returned before the allocator reset, and a list dropped without a reset just releases its buffers as before. The one caller (list.rs, footprint copies) uses onlybytesof a possibly larger buffer, which is fine. The new test checks that the same resource and mapped pointer come back after a reset.Notes:
CreateCommittedResourcecount from one session would help the maintainer judge it.Deferred::uploadsunpooled, which is fine.CI:
checkpassing.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.