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.@upipibi on GitHub · 2026-11-26 17:51 UTC · original · edited 2026-11-26 20:13 UTC
Verified #3276 at
ddc621b904on Ampere: RTX 3070 8 GB, driver 616.56, Windows 11, rustc 1.98.1. main63bcca43as control for the shared tests (the two new tests are added by this PR, so they do not exist on main and ran on the PR head only), each tree in its own target dir,--locked,--test-threads=1. Synthetic tests only.resource::x3a_texture_refused_for_want_of_memory_is_made_laterx5a_slot_left_null_for_want_of_memory_is_read_againx5cargo test -p victory-gpu --libThe 2 failures are the same on both trees:
descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views(NVIDIA's 1,000,000-view heap cap; #3178, #1744). No nvlddmkm resets.AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 18:26 UTC · original
I checked this together with the view-address-table retry from #3175, keeping both PR heads in the history. The combined commit is
d1c8b3f.The WARP test refuses the first view-address-table allocation and the first allocation for a 64×64 D32 texture copy independently. It checks that the descriptor is still null, then retries the address table while the slot is null and reads through
make_readon the following request. The texture recovers, the GPU address of the table remains stable, and the recovered slot has the expected view-address words. The permanentE_INVALIDARGcase still takes the existing failure path.The targeted test passed 3/3 on app-local Agility 1.620.2 / WARP 1.0.22. The full GPU suite passed 252 with one ignored, and strict Clippy passed with default and all features. This was a synthetic allocation-failure test on WARP.
If the two PRs land separately, please run the combined test after the second lands. If you pick up the test, please preserve its Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>when folding it into another commit.@borosf on GitHub · 2026-11-26 19:03 UTC · original
Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head
ddc621b:Result: victory-gpu lib: 230 passed / 2 known baseline failures + the waits_end_on_ticks timing flake (passed on --exact re-run).
Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions.
Synthetic tests only; no game data used. Full log kept locally. — borosf
@lerapeurdu62280-debug on GitHub · 2026-11-26 19:22 UTC · original
Thanks @andrewpozdnakov7-jpg, good to know the two retries hold together, with the table's address stable. I won't fold your test into #3276, so it stays yours: whichever of #3175 and #3276 lands second is the natural place for it, with your authorship kept.
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.