Textures: staging buffers come from a pool instead of being made per texture #781
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!781
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-781"
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?
@marquezinii on GitHub · 2026-11-25 07:27 UTC · original
marquezinii:perf/staging-pool→main· +224 −1 · 2 files · 1 commits · openThe pass over the heap's textures (
draw.rsheap_textures) runs on the thread that records the frame, with a budget of 250 ms and 192 MB a pass, three times that while 1,024 or more slots are due. On a Ryzen 5 5600X + RTX 5070 the queue held about 5,000 due slots for minutes, so frames sat at that budget (0.7-1.4 s) whenever it ran full.I split the pass with local counters. In the 111 heaviest lines of a run, staging was 257 ms of the median 392 ms of the texture part. Most of it was
staging()making an upload buffer for each texture (Host::upload_buffer, a committed resource and a map) and releasing it when the texture was let go a frame later. A small benchmark of 1,000 buffers / 350 MB on the 5070:D3D12_HEAP_FLAG_CREATE_NOT_ZEROEDThis change keeps those buffers in a pool:
Stagingthat is dropped gives its buffer back. The lists that recorded a copy from it hold theArcuntil they are reset, so the card is done with it by then.detilewrites every subresource (including the zeros for levels on demand), and if the first refresh does not detile at all (memory all zero, or not there yet) the buffer is zeroed, as a new one would be.VICTORY_STAGING_POOL_MB(512) caps it; 0 makes and releases every buffer as before. The diagnostics memory line counts buffers made, taken, given back and released.Measured on
310c6ebplus #95 and #665 (the remap and fetch waits hid this otherwise), diag build, Series X, 480 s runs with the same scripted input, one exe with the switch on and off:VICTORY_STAGING_POOL_MB=0The queue drained a few minutes into the world in the runs with the pool. After that the pass costs 15-40 ms a frame. Frames in the steady door scene of the prologue are bound by the card either way (about 2 fps there with these two runs), so this shows up while textures stream in, not in the steady frame. I compared the captured frames (
VICTORY_CAPTURE) of both runs at the same offsets and saw no texture with stale texels.Tests: two new unit tests (size classes; a buffer given back is taken again for its class and not for another).
cargo test --release -p victory-gpupasses, exceptinplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset. That test also fails ona26859fwithout this change when the whole suite runs (3 of 3 runs here) and passes alone. Clippy shows no warnings in the changed files, in both CI configurations. Rebased ona26859f; levels on demand were not enabled in the measured runs.@marquezinii on GitHub · 2026-11-25 07:31 UTC · original
The red check is the Clippy step failing on three lints that
mainhas as well (its run fora26859ffails on the same ones):placed_filler_twinsnever used (resource.rs:2553),sort_unstable_by_key(draw.rs:2387),depth_writtennever read (indirect.rs:1335). This PR only changes texture.rs and copystat.rs.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.