Textures the card had no memory for are made again later, not refused for good (port of avatarmanz#293) #287

Open
github-bot wants to merge 1 commit from github-bot/gh-287 into a-publier AGit
Owner

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

Port of avatarmanz/VIctory-7900XTX#293 onto a-publier (that tree has the same code). Fixes the first three points of avatarmanz/VIctory-7900XTX#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 avatarmanz/VIctory-7900XTX#169 fixes.
  • cargo clippy -p victory-gpu --all-targets -D warnings, default and --all-features: clean once avatarmanz/VIctory-7900XTX#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 avatarmanz/VIctory-7900XTX#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

On a-publier (cd8dfc0)

Cherry-picked without conflict; the only change is that #256 in the code comments now reads avatarmanz/VIctory-7900XTX#256, since #256 here is another PR. Windows 10 Pro 19045, AMD RX 6600 (RDNA 2, Adrenalin 32.0.21045):

  • cargo test -p victory-gpu --locked: 386 passed, 2 failed. The two (depth_bounds_pipeline_loads_and_filters_draws, which fails on WARP-less hosts too and avatarmanz/VIctory-7900XTX#169 fixes, and the flaky watch::tests::a_block_just_written_rests) fail on a-publier alone as well.
  • The new test passes.
  • Clippy reports the same warnings with and without this PR, none in its files. a-publier itself fails -D warnings on host/panel.rs:386 and texture.rs:46 (and watch.rs:3626, which avatarmanz/VIctory-7900XTX#241 fixes).
**@⁠lerapeurdu62280-debug** on GitHub · 2026-11-26 19:11 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/287) `lerapeurdu62280-debug:fix/texture-retry-after-oom` → `a-publier` · +111 −7 · 4 files · 1 commits · open Port of avatarmanz/VIctory-7900XTX#293 onto `a-publier` (that tree has the same code). Fixes the first three points of avatarmanz/VIctory-7900XTX#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 avatarmanz/VIctory-7900XTX#169 fixes. - `cargo clippy -p victory-gpu --all-targets -D warnings`, default and `--all-features`: clean once avatarmanz/VIctory-7900XTX#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 avatarmanz/VIctory-7900XTX#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) ### On `a-publier` (cd8dfc0) Cherry-picked without conflict; the only change is that `#256` in the code comments now reads `avatarmanz/VIctory-7900XTX#256`, since #256 here is another PR. Windows 10 Pro 19045, AMD RX 6600 (RDNA 2, Adrenalin 32.0.21045): - `cargo test -p victory-gpu --locked`: 386 passed, 2 failed. The two (`depth_bounds_pipeline_loads_and_filters_draws`, which fails on WARP-less hosts too and avatarmanz/VIctory-7900XTX#169 fixes, and the flaky `watch::tests::a_block_just_written_rests`) fail on `a-publier` alone as well. - The new test passes. - Clippy reports the same warnings with and without this PR, none in its files. `a-publier` itself fails `-D warnings` on `host/panel.rs:386` and `texture.rs:46` (and `watch.rs:3626`, which avatarmanz/VIctory-7900XTX#241 fixes).
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]>
(cherry picked from commit d8d5d20cb013f29381d9f42dd837d866965841da)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:22:31 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 20:45 UTC · original

Tested on an RX 6950 XT 16 GB (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release, at 4e95a78: cargo test --release -p victory-gpu --lib 387 passed, 1 failed, 34 ignored. The new a_texture_refused_for_want_of_memory_is_made_later passes. The one failure is views_are_made_beside_the_heap_and_copied_in, which fails the same way on cd8dfc0 on this card (fixed by #288).

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 20:45 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/287#issuecomment-7203045907) Tested on an RX 6950 XT 16 GB (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release, at `4e95a78`: `cargo test --release -p victory-gpu --lib` 387 passed, 1 failed, 34 ignored. The new `a_texture_refused_for_want_of_memory_is_made_later` passes. The one failure is `views_are_made_beside_the_heap_and_copied_in`, which fails the same way on `cd8dfc0` on this card (fixed by #288). AI-assisted (Claude Code); no game data.
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/287/head:github-bot/gh-287'
git switch 'github-bot/gh-287'

Merge

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