GPU: a texture the host had no memory for is made again later, not refused for the rest of the run #3276
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!3276
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3276"
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?
@lerapeurdu62280-debug on GitHub · 2026-11-26 15:27 UTC · original
lerapeurdu62280-debug:fix/texture-retry-after-oom→main· +204 −1 · 3 files · 3 commits · openWhat and why
Resource::hoststores any failedmake_textureasSome(None)("the host refused it"), and nothing ever clears that:evictonly resetsSome(Some(t)). So a single transientE_OUTOFMEMORYfromCreateCommittedResource(VRAM full while the world streams, mostly on 8-12 GB cards) leaves that title texture without a host texture for the rest of the run, even after evictions have made room.Change (
resource.rs, plus a few lines indescriptor/host.rsandshadow.rs):make_texturenotes, in a thread-local, whether its last way (the committed creation) was refused withE_OUTOFMEMORY. Earlier ways (placed, castable) fall through to it, so only the final outcome counts.Resource::hostdoes not storeSome(None)for such a refusal. It sets a per-resourcerefused_untiland returnsNone. Within the wait it returnsNoneat once, with no driver call; the next ask after it tries again.Some(None)exactly as before.HostHeap::mirroralready makes a draw-read texture slot again when it holds nothing (needs_remake). A slot that shaders only read through the heap is made when its read is marked, and each read is marked once: whenmirrorleaves a texture slot null for want of memory, it now callsshadow::forget_read, so the next read after the wait is marked and the slot is made (review by @yumaste). Slots left null for other refusals are not re-armed.This is the same defect a contributor reported on the avatarmanz fork (avatarmanz/VIctory-7900XTX#256, fixed there in avatarmanz/VIctory-7900XTX#293). Here the fix is smaller, thanks to
needs_remake. It complements #3266 (backoff on placement-heap growth after OOM): that PR avoids repeating the heap call, this one gives the texture itself a second chance. #1272 (mip-drop on OOM) takes a different, larger route and conflicts withmain.Tested (Windows 10, RX 6600 (RDNA 2, Adrenalin 32.0.21045), Rust 1.98.1)
resource::tests::a_texture_refused_for_want_of_memory_is_made_later:E_OUTOFMEMORYinjected into the committed creation (a#[cfg(test)]thread-local; whether the injection was consumed tells whether the host was asked). No driver call within a wait, the second wait twice as long, the texture made after it;E_INVALIDARGstays refused with no further call.RETRY_MSis 100 ms in tests (0.6 s for the test). 5/5 runs. It fails with the retry disabled, and with the doubling disabled.cargo test -p victory-gpu --locked: 229 passed, 3 failed. The 3 (compute_view_marks_rebind_after_depth_twin_conversion,a_texture_written_in_one_format_reads_in_another_through_a_placed_view,depth_bounds_control_a_title_draw) fail the same way onmain(63bcca4) on this card.cargo clippy -p victory-gpu --all-targets -D warnings, default and--all-features: clean.AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
@AurumCarlos on GitHub · 2026-11-26 15:33 UTC · original · reviewed
Good fix: an OOM refusal no longer poisons the resource, and other refusals stay
Some(None). The flag is cleared before each attempt, so it can't leak between calls.One thing to bound: a texture that keeps failing is retried every 500 ms for as long as VRAM stays full, and each retry is a
CreateCommittedResourceplus awarn!("no host texture"). With a few hundred such textures while the world streams, that's a lot of driver calls and log lines per second, exactly when the card is already struggling. DoublingRETRY_MSper consecutive OOM (capped at a few seconds), and/or logging the OOM case once per resource, would keep the second chance without the churn.Nit: the test sleeps 2 × 600 ms; injecting the clock (or a test-only
RETRY_MS) would keep the suite fast.@lerapeurdu62280-debug on GitHub · 2026-11-26 15:41 UTC · original
Thanks @AurumCarlos, all three taken in
698f889:make_textureno longer warns for OOM itself; every other refusal warns as before.RETRY_MSis 100 ms undercfg(test), so the test takes 0.6 s instead of 1.4 s. It now also checks that the second wait is twice as long; it fails with the doubling disabled.@oni-swr on GitHub · 2026-11-26 15:44 UTC · original
WARP verification report (test report only, no code changes)
34fb1dc863bcca43(control); WARP software adapter forced withVICTORY_WARP=1 VICTORY_D3D12_WARP=1,--features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, viaVICTORY_DXIL).--exact),-j 4, synthetic tests only, no game data.resource::tests::a_texture_refused_for_want_of_memory_is_made_later: passes on the PR (1 passed, 1.25 s).FAIL_NEXT/RETRY_MS) from this PR, so I added only that hook to main and left out the retry logic. The test fails on main at the first "made later" assertion (E_OUTOFMEMORY: the texture stays refused after the wait). That is a main-plus-hook control, not unmodified main.victory-gpulib suite: PR 247 passed, 0 failed, 1 ignored; main 246 passed, 0 failed, 1 ignored. No failures on either, so none shared with main.AI use: Claude Code (Claude Sonnet 5.5)
@lerapeurdu62280-debug on GitHub · 2026-11-26 15:50 UTC · original
Thanks @oni-swr. Note that the report is on the first commit (
34fb1dc). The review follow-up,698f889(the doubling wait, one warning per texture,RETRY_MS= 100 ms undercfg(test)), came after it; the test there takes about 0.6 s, and the CI check passes on it.@Dukestar69 on GitHub · 2026-11-26 15:52 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
E_OUTOFMEMORYinmake_texturesoResource::hostretries with capped exponential backoff (500 msup to8 s) instead of permanently cachingSome(None)— while still permanently caching non-OOM refusals likeE_INVALIDARG— is clean and well-tested.cargo test -p victory-gpu --lib resource:: -- --test-threads=1(RTX 5090): 19 passed, 0 failed (includinga_texture_refused_for_want_of_memory_is_made_later).VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib resource::tests::a_texture_refused_for_want_of_memory_is_made_later -- --test-threads=1(WARP): 1 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@yumaste on GitHub · 2026-11-26 16:00 UTC · original
I reproduced a gap in the descriptor retry path on this head (
698f889), using WARP and the PR's existingFAIL_NEXThook. If a slot is only read bindlessly, the first read can consume its only notification while the texture is still in backoff.E_OUTOFMEMORY. The slot is null.shadow::take_readsfollowed bydescriptor::make_readduring the cooldown. The first read is seen, but the slot still has no resource.refused_until, then post another read mark for the same slot.take_readsreturns[]; the slot stays null. Callinghost_heap.mirror(slot, handle, true)explicitly at that point does create the resource and populate the slot.reads_sinceclears the mapped marks but intentionally keeps the deduplication state. The null-slot path callsforget_readfor a deferred placed view, but not for this already-attempted SRV. Could the failed bindless slots be rearmed or queued for a retry when the OOM wait ends? Keeping this tied to the transient OOM state would preserve the permanent-refusal behavior for other HRESULTs. The regression above does not require a game or real VRAM exhaustion.I then re-ran the synthetic test with an explicit forget_read(slot) and one collection pass to clear the mark, before simulating the next GPU read. That read was reported and the slot recovered through make_read, without the explicit table read.
@lerapeurdu62280-debug on GitHub · 2026-11-26 16:15 UTC · original
Thanks @yumaste, confirmed and fixed in
ddc621b.Resource::hostnow notes, per thread, when it gives nothing for want of memory: either refused now, or within the wait that follows. WhenHostHeap::mirrorleaves a texture slot null for that reason, it callscrate::shadow::forget_read(index), as it already does for a placed view it leaves for later. The slot's next read is then marked again,make_readmirrors it (needs_remakesees nothing held), and the texture is made once the wait is over. Slots left null for any other refusal are not re-armed, so the permanent-refusal path is unchanged.New test
a_slot_left_null_for_want_of_memory_is_read_again: an SRV of a committed D32 texture is mirrored withE_OUTOFMEMORYinjected. The slot is null and re-armed (shadow::forgotten, acfg(test)accessor), and after the wait a mirror makes it. WithE_INVALIDARGthe slot is null and not re-armed. The test fails without theforget_read, and passes on an RX 6600 and on WARP, with the D3D12 debug layer on.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.