GPU: an upload buffer refused for want of memory is asked again once the spare scratch chunks are freed (#944) #953
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!953
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-953"
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?
@kibagami-nc on GitHub · 2026-11-28 09:50 UTC · original
kibagami-nc:fix/upload-oom-frees-spare-chunks→main· +123 −9 · 1 files · 1 commits · merged 2026-11-29 08:16 UTCRebuilt on main
32ecacf(force-pushed). Main now pools copy sources (UPLOAD_SPARE, up to 1 GiB of each kind, from924911f), and its sweep keeps some spares under pressure while plenty of the PC's memory is free. This change leaves that sweep alone. On anE_OUTOFMEMORYrefusal it now frees every spare no list holds, the scratch chunks and the pooled copy sources, throughfree_all_spares, then asks once more. With the pool, a refusal now has much more to free than in Exopus-0x65f7ad0's run below, where the scratch chunks were already gone.cargo test -p victory-gpu --lib --lockedon the rebuilt branch: 478 passed, 37 ignored. Clippy is clean in both builds, with main's ownmanual_is_multiple_ofallowed.What happens
An upload buffer comes out of the PC's memory the card may use: D3D12's non-local budget, about half the RAM. That budget can run out while the PC itself still has memory free.
#944 shows it: an RTX 4060 Laptop with 15.7 GB of RAM, and three runs with the same switches.
0x8007000E. That size isSCRATCH_FIRST, a list's first scratch chunk. Thena host state prelude did not record (0x8007000E), and the run ended there.Meanwhile the spare scratch chunks, the ones no list holds, are upload buffers in that same budget: up to 128 MiB of them on a PC with 32 GB or less (
SPARE_MOST). Only the once-a-second sweep frees them, and only whileresidency::pressured()holds. That is decided by the PC's free physical memory and commit, not by this budget. So they stayed kept while new ones were refused. The 368 refused buffers came to about 92 MiB.The change
crates/victory-gpu/src/host.rs:Host::upload_bufferasks once more when a buffer is refused withE_OUTOFMEMORY, aftertrim_spare_chunksfreed the spare chunks.trim_spare_chunksnow returns the bytes it freed. It frees them as the sweep does: no list holds them, and their submissions have run.make_or_free_and_retry, which can be tested without running out of memory:no upload buffer,residency::allocation_error).This keeps a run going through a spike while chunks are spare. It does not make room the title or the texture queue have already taken. #944's failing run also had its texture queue fall far behind first.
Tests
host::spare::an_out_of_memory_refusal_is_tried_again_once_memory_is_given_back:cargo test -p victory-gpu --lib --locked: 454 passed, 36 ignored.-D warnings, default and--all-features): nothing in the changed lines. It stops onmain's ownmanual_is_multiple_of(fixed in #665). With that lint allowed, both builds are clean.trim_spare_chunkstakes the spare pool's lock, and no caller ofupload_bufferholds it.take_chunklets it go before it makes a new chunk.Not run with the game. On a PC like #944's, a log with this change would show
was made once the spare scratch chunks were freedwhereno upload bufferwas before. Read-back and shared buffers fail the same way under that budget (#804 counts both), and could take the same step if a log shows them refused while chunks are spare.Seen by others (#944)
host memory pressure. There was not one0x8007000Eorno upload buffer. That fits a budget of the PC's memory running out on 15.7 GB, rather than the card's own.Tested by Exopus-0x65f7ad0 (RTX 5060 Ti 8 GB, 16 GB, Windows 11 26300)
Four starts with this change and the switches that had failed there that morning, on the same save. Three ran through with no refusal at all. One still died, about the rate seen without it (#944: 1 in 3).
7032 MB against a line of 6325 MB).a host command list did not close (0x8007000E).So on that machine the spare chunks are not what runs dry. The whole budget outside the card's memory was used up while the card's own memory was full. This change is harmless there (it only acts on
E_OUTOFMEMORY), but it does not prevent that failure. What fills the budget during world load is the lead: texture staging, and copies moved out of the card's memory. #986 and #991 work on that side.No game files, dumps or extracted data are included.
@Exopus-0x65f7ad0 on GitHub · 2026-11-28 13:12 UTC · original
Tested on a machine close to #944's: RTX 5060 Ti 8 GB (DXGI local budget ~7.0 GB), 16 GB RAM, Windows 11 26300. Base
63b902fplus this PR merged; the few extra local commits don't touchhost.rsupload or scratch code. README launcher defaults with-Dlss balanced, which is the switch set that died this morning on the same machine without the PR (2,711 ×no upload buffer0x8007000E, thena host state prelude did not record).Runs with this PR (4 starts, same switches, same save)
no upload bufferno shared buffertimes=1,2,4,8;freed_mb= 0, 3, 0, 0)So 1 of 4 still died, about the same rate as without the PR (#944 had 1 of 3).
What the failing run shows
SCRATCH_FIRST(262,144 bytes). The first two in the log are a 2,228,224-byte upload buffer and an 8,388,608-byte shared buffer, both at12:58:18. So the whole non-local budget was exhausted, not just the scratch pool.texture queue's room: 6244 MB in use ... + 1592 MB kept for render targets = 7032 MB against a line of 6325 MB (90.0 % of a budget of 7028 MB): no room.My guess is that local overflow is being demoted into the same non-local budget.
host GPU failure: a host command list did not close (0x8007000E), withhost copies in the card's memory could not be brought up to date (0x8007000E)just before it. Noprelude did not recordthis time.Take-away
The change looks correct and harmless: no regressions in the 3 good runs, and the retry rule only acts on
E_OUTOFMEMORY. On an 8 GB / 16 GB machine, though, the spare scratch chunks are not the reservoir that runs dry. Whatever demotes into the non-local budget during world load, while VRAM is at ~100 %, is the real driver. A cap on the non-local side (texture staging plus card-copy demotion), or backing off texture admission sooner onceno roomis reported, would probably matter more here. #986 (smaller staging blocks after OOM) and #991 (pooled buffers) also touch this; I'll run #991 next on the same machine and post there.Logs are available if useful (they contain only the emulator's own lines).
@kibagami-nc on GitHub · 2026-11-28 13:46 UTC · original
Thank you, that is the test this needed, and it answers it. The retry fires, but by then there is nothing spare to free (0 to 3 MB), and the refusals start with an ordinary 2.2 MB upload buffer and an 8 MB shared buffer while the card's own memory is over its line. So on an 8 GB / 16 GB PC the spare chunks are not the reservoir that runs dry, and this change does not prevent that crash. I put your runs and that conclusion in the description, so nobody takes it for the fix of #944.
I'll keep it open as a small, harmless hardening for a spike while chunks are spare, unless the maintainer prefers to drop it. I'll look at what moves into that budget while the card is full, and wait for your #991 numbers before touching the same paths.
f87534e336tod8ae70b310github-bot referenced this pull request2026-11-29 07:26:49 +00:00