victory-gpu: small device-local buffers placed together (about 1.2 GB of the card on AMD) #331
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/readmet3xt-lab--foxhound!331
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-331"
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?
@Bushyon on GitHub · 2026-12-01 13:57 UTC · original
Bushyon:small-buffers-placed-together→main· +304 −6 · 5 files · 72 commits · closed without mergingSmall device-local buffers placed together (about 1.2 GB of the card on AMD)
What was wrong
Every buffer
Host::uav_buffermakes is a committed resource. The AMD driver gives each committed resource in local video memory 256 KiB of the card, however small it is. Several kinds of buffers foxhound makes by the thousands are far smaller:shadow::card_room_for,ahead)HostList::batch_place)HostList::make_card_budget)card_make_before), window card copiesAn RMV memory trace (RX 7800 XT 16 GB, driver 32.0.32029.2010, Series X profile at 1440p, standing in the world 2.3 minutes after loading, launcher's default switches) had 8,622 allocations of 256 KiB: 2,156 MB of the card holding 463 MB of buffers (21% used). The 4 MiB blocks next to them were 90% full.
What this changes
New
crates/victory-gpu/src/card_pool.rs: buffers of 256 KiB or less are placed in shared 4 MiBALLOW_ONLY_BUFFERSheaps at 64 KiB multiples (a buffer's placement alignment) instead of being committed one by one. The six makers above ask the pool first and fall back touav_bufferif it can't place one.Reuse is safe without changing any owner: the pool keeps its own reference to every buffer it placed, and a slot is taken again only once that reference is the last one (
host::references), i.e. no copy, host list or heap slot holds the buffer, so no recorded or in-flight work can read it. Owners drop their buffers exactly as they dropped committed ones. Reclaiming runs when the pool has no room, and at most once a second otherwise.VICTORY_CARD_POOL=0turns it off (every buffer committed, as before).Measured (same switches and scene, RMV traces, 2.3 minutes in)
Texture heaps varied 5.5–6.3 GB between runs, so the comparison leaves them out. Every run rendered normally (38–42 FPS log lines a run), with no device removal.
Tests
cargo clippy --workspace-equivalent forvictory-gpu, with and without--all-features,-D warnings: clean.cargo test --workspace --locked: all pass, apart fromwatch::tests::faults_that_take_no_lock_tell_the_same. That test fails about 1 run in 3 on unmodifiedmaintoo (it passes alone), so it is timing-sensitive under the parallel run, not this change.card_pool: slot masks, finding runs of free slots, and a slot not being given out again while its buffer is still held.cargo xtask policy --staged: 5 files ok.Related open PRs
#327 and #276 tune texture eviction and reserves in
pool.rs/resource.rs. This PR doesn't touch those files, and its saving stacks with theirs. #290 changes the sameahead.rsline (host.uav_buffer(SIZE)); whichever merges second needs a one-line merge.Not in this PR, but seen while measuring
shadow::by_addresskeeps its card-memory total in a function-local counter that only grows. It is never lowered when a copy goes, and is raised even whenuav_bufferfails. After 4 GiB has passed through it in a session, every later copy goes to PC memory even with room on the card. Only ray-tracing runs use it.victory-image-…dll+0x2215c35). This was before and after this change, so it isn't related to it.🤖 Generated with Claude Code
@Aniseto on GitHub · 2026-12-01 14:00 UTC · original
Ran the
card_pool::testsgroup at542e329on an NVIDIA Blackwell desktop part with 16 GB of VRAM. The PR's measured 1.2 GB saving is on AMD, where committed small buffers cost 256 KiB each; this NVIDIA adapter runs the same synthetic tests but does not reproduce that driver behaviour.Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own
CARGO_TARGET_DIR, no local patches.All three new tests pass here: slot masks, finding runs of free slots, and not reusing a slot while its buffer is still held. The description's full workspace run and the AMD RMV trace were not repeated.
Not tested: the full workspace suite, a retail title, VRAM-savings on this adapter, AMD adapters, Wine, release profile, game data.
AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Pull request closed