Repository navigation
GPU: a texture the host had no memory for is made again later, not refused for the rest of the run - #3276
Conversation
Resource::host noted any failed make_texture as Some(None), "the host refused it", and nothing clears that (evict gives up only made textures): one E_OUTOFMEMORY left the title texture without a host texture for the rest of the run, even once evictions made room. When the last creation make_texture tried was refused with E_OUTOFMEMORY, the texture is not noted as refused: it is asked again after RETRY_MS (500 ms), and made then if the host has room. Any other refusal is noted as before. Draws already make a null slot again (`needs_remake`), so a slot reading such a texture picks it up once it is made. Test: a_texture_refused_for_want_of_memory_is_made_later injects one E_OUTOFMEMORY (made after the wait) and one E_INVALIDARG (stays refused) into the committed creation. It fails without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AurumCarlos
left a comment
There was a problem hiding this comment.
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 CreateCommittedResource plus a warn!("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. Doubling RETRY_MS per 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.
From review: a texture refused for want of memory was asked for every 500 ms while memory stayed short, each time a CreateCommittedResource and a "no host texture" warning, for each such texture. - The wait doubles with each refusal for want of memory in a row (500 ms, 1, 2, 4, then 8 s at most) and starts again from 500 ms once the texture is made. - The refusal is told once per texture, when its run of refusals starts; make_texture warns as before for every other refusal. - RETRY_MS is 100 ms in tests: the test takes 0.6 s instead of 1.4 s. It also checks the second wait is twice as long (it fails without the doubling). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @AurumCarlos, all three taken in 698f889:
|
|
WARP verification report (test report only, no code changes)
AI use: Claude Code (Claude Sonnet 5.5) |
Dukestar69
left a comment
There was a problem hiding this comment.
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
- Distinguishing
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).
|
I reproduced a gap in the descriptor retry path on this head (
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. |
From review (yumaste): a heap slot that shaders only read through the heap is made when its first read is marked (take_reads, make_read), and each slot's read is marked once until forget_read. If that first read came while its texture was refused for want of memory (or within the wait after), the slot was made null and its one read mark was spent: once the wait was over nothing asked for the texture again. Resource::host now notes, per thread, that it gave nothing for want of memory. HostHeap::mirror, when it leaves a texture slot null for that reason, calls forget_read for the slot, as it already does for a placed view it leaves for later: the slot's next read is marked, make_read mirrors it, and the texture is made once the wait is over. Slots left null for any other refusal are not re-armed. Test: a_slot_left_null_for_want_of_memory_is_read_again (E_OUTOFMEMORY: null, re-armed, made after the wait; E_INVALIDARG: null, not re-armed). It fails without the forget_read; it passes on the RX 6600 and on WARP, and with the D3D12 debug layer on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @yumaste, confirmed and fixed in ddc621b.
New test |
What 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