GPU: route upload buffers to GPU_UPLOAD VRAM under budget and move indirect arguments to DEFAULT #3228
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!3228
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3228"
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?
@0xKaji on GitHub · 2026-11-26 13:47 UTC · original
0xKaji:perf/upload-buffers-vram→main· +212 −17 · 3 files · 1 commits · openSummary
Routes CPU-write-only / GPU-read-only upload buffers (
Host::upload_buffer: texture staging chunks/buffers, command-list scratch, descriptorstrides/marks/addresses, title-memory page tables) toD3D12_HEAP_TYPE_GPU_UPLOAD(VRAM via Resizable BAR) while local VRAM stays below 80% of its DXGI budget, and moves GPU-only indirect argument buffers (HostList::arguments) toD3D12_HEAP_TYPE_DEFAULT.Changes
GPU_UPLOADrouting (host.rs): ChecksD3D12_FEATURE_D3D12_OPTIONS16.GPUUploadHeapSupportedonce at device creation and routesHost::upload_buffertoD3D12_HEAP_TYPE_GPU_UPLOAD(D3D12_RESOURCE_STATE_COMMON) when local VRAM usage + allocation fits within 80% of DXGI local budget (refreshed every 250 ms or on >= 4 MiB allocations), falling back cleanly toD3D12_HEAP_TYPE_UPLOADin system RAM. Toggleable viaVICTORY_UPLOAD_VRAM=0.host.rs,indirect.rs): AllocatesHostList::argumentsviaHost::default_uav_buffer(D3D12_HEAP_TYPE_DEFAULT+ALLOW_UNORDERED_ACCESS) instead of CPU-mappedshared_buffer; updatesindirect.rstests to read back via aREADBACKbuffer.host.rs,list.rs): AddsHostList::release_idle_buffers()called fromlist::recycle()so command lists parked inSPAREdrop oversizedargumentsand trimscratchchunks.Measured A/B (Linux Wine 11.22 + vkd3d-proton, RTX 3060 8 GiB ReBAR, 16 GiB RAM, Series S + #2112)
VICTORY_UPLOAD_VRAM=0→VICTORY_UPLOAD_VRAM=1:4,180 MB→3,697 MB(-483 MB)3,337 MB→3,046 MB(-291 MB)14,510 MB/13,959 MiB→13,357 MB/12,847 MiB(-1,112 MiB RSS)0 MB VRAM / 177 MB RAM→59 MB VRAM / 0 MB RAM6.0 ms→4.9 ms, median FPS:28.9→30.0(no regression).Verification
cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warningscargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warningscargo test -p xtask --locked(6/6 passed)upload_vram_fits_checks_80_percent_headroom,list_scratch_grows_to_fit_and_reuses_fenced_chunks(2/2 passed)Partial Overlaps / Related PRs
#3102,#2993, and#2875, which moveshared_buffershadow copies of title memory to VRAM; this PR targetsupload_bufferandHostList::argumentsinstead.#2972onHostList::scratchtrimming (release_idle_buffershere only runs when a list is parked inSPARE, and does not alterHostList::resetorScratch).@potatoe0100 on GitHub · 2026-11-26 14:03 UTC · original
Tested
ef8d719merged ontomain63bcca4on an RTX 4060 8 GB (Ada, PCIe 4.0 x8, driver 621.14, Windows 11 Pro 26300, Resizable BAR on). No game files, so synthetic tests only.Tests:
cargo test -p victory-gpu -p victory-shader --lib --locked -- --test-threads=1(skippingheap_direct_texture_reads_mark_their_heap_index, #2571). Same result asmainon this card: the newupload_vram_fits_checks_80_percent_headroom,list_scratch_grows_to_fit_and_reuses_fenced_chunksand allindirect::testspass. The only failures are the 5 known capped-heap ones (#1835), which fail onmaintoo.OPTIONS16.GPUUploadHeapSupportedis true here, so the GPU_UPLOAD path really ran.Costs measured on this card (a throwaway
--releaseprobe, not part of the PR):default_uav_buffer)Two things this suggests, for whoever reviews:
release_idle_buffers()runs on everylist::recycle(). It drops the indirectargumentsbuffer and trims scratch to at most one chunk.list.rsnotes the title resets up to 21 lists a frame, so a recycled list that does indirect work makes a new DEFAULT buffer each time (about 0.25 ms here). A list that needs a few MiB of scratch also regrows it 64 KiB → 4 MiB, about 7 allocations. Before this PR both were kept across reuse. Would it be enough to trim only lists that have sat inSPAREfor a while, or only when the buffer is well above what was used?list.uploadcopies. That's fine when the GPU copy saved is the bottleneck, but on a card with a narrow link it may move time into "preparing", which is already the largest part of a frame in the forks' measurements. A per-caller choice (VRAM for small, often-rewritten tables; system memory for large staging writes) might be worth measuring.AI-assisted (Claude)
@Dukestar69 on GitHub · 2026-11-26 14:09 UTC · original · approved these changes
Verified on RTX 5090 (Resizable BAR /
GPU_UPLOADcapable) againstorigin/main(63bcca4):cargo test -p victory-gpu --lib host::tests -- --test-threads=1 --skip dynamic_slots_are_held_until_released: passed.cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed;indirect::: 6/6 passed;shadow::: 10/10 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly routes upload buffers to
GPU_UPLOADVRAM within budget and moves indirect arguments accordingly.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.