Textures the card had no memory for are made again later, not refused for good (#256) #293

Open
github-bot wants to merge 1 commit from github-bot/gh-293 into main AGit
Owner

@⁠lerapeurdu62280-debug on GitHub · 2026-11-26 14:37 UTC · original
lerapeurdu62280-debug:fix/texture-retry-after-oom → main · +111 −7 · 4 files · 1 commits · open

Fixes the first three points of #256: a host texture refused with E_OUTOFMEMORY was refused for the rest of the run.

What and why

Before this change, one E_OUTOFMEMORY from CreateCommittedResource set refused, and hosted() never asked for that texture again, even once the card had room. Two other places then made it permanent for bindless slots:

  • draw.rs took host_resource() == None as "nothing to upload" and marked the slot done;
  • HostHeap::mirror noted the slot as made from that record, holding the null view, so the quick path kept returning it.

Changes:

  • resource.rs: refused: AtomicBool becomes refused_until: AtomicU64. When the card was out of memory, the texture is asked again after RETRY_MS (500 ms, the same as the upload backoff). Any other error is still refused for good (u64::MAX). A success resets it to 0. retrying(this) tells the other two places.
  • residency.rs: allocation_error also sets a thread-local flag that hosted() takes, the same pattern as STAGING_DEFERRED. A failed resident()/mapped() now calls allocation_error too.
  • draw.rs: a slot whose texture is retrying is held with texture_slot_held(.., frame + 1) instead of done.
  • descriptor/host.rs: mirror does not note such a slot as made (made and quick stay 0), so the next ask makes it again.

Tested (Windows 10, RX 6600 (RDNA 2, Adrenalin 32.0.21045), MSVC 14.51, Rust 1.98.1)

  • New test resource::tests::a_texture_refused_for_want_of_memory_is_made_later. It injects one E_OUTOFMEMORY into the real host_texture_as path (a #[cfg(test)] thread-local, and the test checks the injection was consumed). The texture is not made during the wait and is made after it. E_INVALIDARG stays refused. 5 runs out of 5.
  • cargo test -p victory-gpu --locked: 380 passed, 2 failed. --all-features --test-threads=1: 432 passed, 2 failed. Both failures (views_are_made_beside_the_heap_and_copied_in, depth_bounds_pipeline_loads_and_filters_draws) fail the same way on a clean main on this machine; the second one is what #169 fixes.
  • cargo clippy -p victory-gpu --all-targets -D warnings, default and --all-features: clean once #241's one-line fix is applied (main's own lint).
  • Not run in the game (no dump here), and no real VRAM exhaustion: the failure is injected.

Not covered

  • Point 4 of #256 (permanent vs. device-removed classification beyond OOM / other) is left as it was: anything but OOM is still refused for good.
  • If the pool path (crate::pool::texture) runs out of memory and the committed fallback then fails for another reason, the texture is treated as retryable. The worst case is one failed creation every 500 ms for that texture.

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

**@⁠lerapeurdu62280-debug** on GitHub · 2026-11-26 14:37 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/293) `lerapeurdu62280-debug:fix/texture-retry-after-oom` → `main` · +111 −7 · 4 files · 1 commits · open Fixes the first three points of #256: a host texture refused with `E_OUTOFMEMORY` was refused for the rest of the run. ### What and why Before this change, one `E_OUTOFMEMORY` from `CreateCommittedResource` set `refused`, and `hosted()` never asked for that texture again, even once the card had room. Two other places then made it permanent for bindless slots: - `draw.rs` took `host_resource() == None` as "nothing to upload" and marked the slot done; - `HostHeap::mirror` noted the slot as made from that record, holding the null view, so the quick path kept returning it. Changes: - **`resource.rs`**: `refused: AtomicBool` becomes `refused_until: AtomicU64`. When the card was out of memory, the texture is asked again after `RETRY_MS` (500 ms, the same as the upload backoff). Any other error is still refused for good (`u64::MAX`). A success resets it to 0. `retrying(this)` tells the other two places. - **`residency.rs`**: `allocation_error` also sets a thread-local flag that `hosted()` takes, the same pattern as `STAGING_DEFERRED`. A failed `resident()`/`mapped()` now calls `allocation_error` too. - **`draw.rs`**: a slot whose texture is `retrying` is held with `texture_slot_held(.., frame + 1)` instead of done. - **`descriptor/host.rs`**: `mirror` does not note such a slot as made (`made` and `quick` stay 0), so the next ask makes it again. ### Tested (Windows 10, RX 6600 (RDNA 2, Adrenalin 32.0.21045), MSVC 14.51, Rust 1.98.1) - New test `resource::tests::a_texture_refused_for_want_of_memory_is_made_later`. It injects one `E_OUTOFMEMORY` into the real `host_texture_as` path (a `#[cfg(test)]` thread-local, and the test checks the injection was consumed). The texture is not made during the wait and is made after it. `E_INVALIDARG` stays refused. 5 runs out of 5. - `cargo test -p victory-gpu --locked`: 380 passed, 2 failed. `--all-features --test-threads=1`: 432 passed, 2 failed. Both failures (`views_are_made_beside_the_heap_and_copied_in`, `depth_bounds_pipeline_loads_and_filters_draws`) fail the same way on a clean `main` on this machine; the second one is what #169 fixes. - `cargo clippy -p victory-gpu --all-targets -D warnings`, default and `--all-features`: clean once #241's one-line fix is applied (`main`'s own lint). - **Not run in the game** (no dump here), and no real VRAM exhaustion: the failure is injected. ### Not covered - Point 4 of #256 (permanent vs. device-removed classification beyond OOM / other) is left as it was: anything but OOM is still refused for good. - If the pool path (`crate::pool::texture`) runs out of memory and the committed fallback then fails for another reason, the texture is treated as retryable. The worst case is one failed creation every 500 ms for that texture. AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A host texture refused with E_OUTOFMEMORY was refused for good: the
resource kept no host copy for the rest of the run, its bindless slot was
marked done, and the descriptor cache kept the null view it got.

- The refusal now waits RETRY_MS (500 ms, as uploads do) when the card
  was out of memory, and stays for good for any other error.
- A texture slot whose texture waits so is held in the queue, not done.
- Its descriptor slot is not noted as made, so the next ask makes it.
- A host texture that could not be made resident counts as out of memory
  too (the upload backoff saw only creation failures).

Test: a_texture_refused_for_want_of_memory_is_made_later injects one
E_OUTOFMEMORY (made again after the wait) and one E_INVALIDARG (stays
refused) into the real creation path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:39:58 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/293/head:github-bot/gh-293'
git switch 'github-bot/gh-293'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-293'
git switch 'github-bot/gh-293'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-293'
git switch 'github-bot/gh-293'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-293'
git switch 'main'
git merge --squash 'github-bot/gh-293'
git switch 'main'
git merge --ff-only 'github-bot/gh-293'
git switch 'main'
git merge 'github-bot/gh-293'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.