GPU: use smaller staging chunks after allocation failure #3259
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!3259
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3259"
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?
@yumaste on GitHub · 2026-11-26 14:48 UTC · original
yumaste:fix/texture-staging-smaller-chunks→main· +186 −21 · 2 files · 2 commits · openD3D12 texture staging currently requests a 32 MiB upload buffer whenever the current chunk fills. Under memory pressure, the driver can reject that allocation even though a smaller buffer could still hold the pending upload.
Try progressively smaller chunks down to the size required by the upload, rounded to 64 KiB. Reuse any space in existing chunks first, keep the successful smaller growth size for the current submission, and retry the default size after recycling. If smaller chunks would crowd out larger ones, recycling keeps the 16 largest so full-size capacity can return after memory pressure subsides. If all sizes fail, the allocator still returns
None, which preserves the interface used by the retry path proposed in #3174. The fallback uses the same D3D12 upload heap and has no adapter-vendor condition.Validation
Inspired by codec_d's staging growth backoff in cool_fox. Coordination comment.
@AurumCarlos on GitHub · 2026-11-26 14:50 UTC · original · reviewed
The backoff in
takelooks right: it always ends (at the latest oncebytes == minimumfails), and both tests trace correctly. One concern:Small chunks stick around after the pressure is gone.
recyclestill doesall.truncate(CHUNKS_KEPT), which keeps the first 16 chunks in creation order, so chunks created small during a refusal stay at the front for good. After that:recycle. That's the per-submission allocation churn the chunks exist to avoid.Dropping kept chunks smaller than
CHUNKinrecycle(or keeping the 16 largest) would fix both. A test that doesrecycleafter a refusal and checks the next submission doesn't reallocate would cover it.@yumaste on GitHub · 2026-11-26 15:08 UTC · original
Addressed in
f034d89. Recycling now retains the 16 largest chunks if smaller entries would otherwise displace them, and can still reuse small chunks while they are the only ones available. The regression starts with 16 small chunks, lets 16 full-size allocations succeed after recovery, then verifies that the next submission reuses all 16 without allocating. The WARP GPU suite passed (250 passed, one ignored).@Dukestar69 on GitHub · 2026-11-26 15:30 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
minimumon failure, resettinggrowthonrecycle(), and retaining the largestCHUNKS_KEPTchunks viaselect_nth_unstable_by_keyonce larger allocations recover is clean and well-tested.cargo test -p victory-gpu --lib texture:: -- --test-threads=1(RTX 5090): 6 passed, 0 failed (including all 4staging_tests).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.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.