GPU: give buffer-to-texture copies slices of the lists' scratch chunks #135
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/135"
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 DexNom/VIctory. Originally posted by SamuelHaleDev on 2026-11-27T15:43:25Z.
Hardware
--rt, no FSR). The shader cache was warmed first withvictory-warm.exe.Problem statement
CommandList::upload(host.rs, marked "shortcut: one buffer per copy") makes, zeroes and frees a committed upload buffer for every copy from title memory into a texture (CopyTextureRegionwith a buffer footprint as the source,list.rs), so every such copy pays the driver's allocation cost.Solution
Buffer-to-texture copies now take a slice of the list's existing scratch chunks instead of a buffer of their own. The scratch chunks already come from the shared spare pool (
SPARE) and go back to it when the list is reset after its submissions have run. So the slices inherit the existing fence-based reuse and the existing 128 MiB cap on spare chunks, and need no new lifetime logic. Copies larger than a chunk keep the old path.What changed
crates/victory-gpu/src/host.rsCommandList::uploadfirst tries the newupload_slice, then falls back to a buffer of its own. It now returns(buffer, offset, pointer)instead of(buffer, pointer).CommandList::upload_slicehands out slices of the list's scratch chunks, starting at multiples of 512 bytes (D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT). Afterwards it leavesusedon a 256-byte boundary forscratch.upload_slices():VICTORY_UPLOAD_SLICES=0restores one buffer per copy.UPLOAD_SLICES: slices and own buffers, with their bytes.crates/victory-gpu/src/list.rs: the buffer-to-texture copy uses the returned offset as the source footprint's offset, and in diagnostics builds adds it to the read address.crates/victory-gpu/src/copystat.rs: the memory line printscopy upload sources since startup: N slices of scratch chunks, M buffers of their own.Design decisions
usedback up to a multiple of 256 after a slice.scratchhands out fromusedon, and its constant-buffer data needs 256-byte alignment.VICTORY_UPLOAD_SLICES=0.mapped_upload, not only this path, so it can't tell what this change saved.Baseline (
64bd58f5, one buffer per copy)Same save on every run. The camera was still for minute 3–4 of the run, looking out of a window in the opening interior. The numbers are the runtime's own 5-second frame lines and memory lines over that minute.
After change (
d8b27659)Same save, profile and camera.
Correctness:
VICTORY_UPLOAD_SLICES=0) and slices on again.VICTORY_CAPTURE,VICTORY_CAPTURE_HEAVY_FRAMES), compared side by side.cargo test -p victory-gpupassed (239 passed, 4 ignored).Not checked:
--rt/ FSR Quality 4K profile.Notes
cargo xtask policypasses.cargo fmt --checkreports many existing differences across these files; the new code follows the style around it.🤖 Generated with 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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.