GPU: back off texture heap growth after out-of-memory #3266

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

@⁠yumaste on GitHub · 2026-11-26 15:05 UTC · original
yumaste:fix/texture-heap-growth-backoff → main · +71 −15 · 1 files · 1 commits · open

When D3D12 refuses a new 64 MiB placement heap with E_OUTOFMEMORY, each subsequent small texture can otherwise repeat that driver call before trying a committed texture.

Wait 500 ms before attempting another full heap after that specific error. Free ranges in existing heaps are still considered first. A miss still returns to the existing committed-texture path, and other HRESULTs do not activate the delay. The timer starts when the failed call returns. The policy uses the same D3D12 API on all adapters.

In a synthetic burst of 64 requests following a refusal, the allocator calls the heap factory once instead of 64 times. The regression verifies that allocation is retried when the delay expires and that a free range is reused during the delay in an actual D3D12 heap. WARP GPU suite passed (247 passed, one ignored) and strict Clippy passed. The new regression also passed on a physical NVIDIA RTX 5080 Laptop GPU with both PRs applied. AMD hardware validation remains open. No title files were used.

Clean trial merges with #3259, #3265, #3230, #3228 and #2972. #3259 covers upload staging buffers, while this change covers the default heaps that hold the textures themselves.

Inspired by codec_d's pool-growth backoff in cool_fox.

**@⁠yumaste** on GitHub · 2026-11-26 15:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/3266) `yumaste:fix/texture-heap-growth-backoff` → `main` · +71 −15 · 1 files · 1 commits · open When D3D12 refuses a new 64 MiB placement heap with E_OUTOFMEMORY, each subsequent small texture can otherwise repeat that driver call before trying a committed texture. Wait 500 ms before attempting another full heap after that specific error. Free ranges in existing heaps are still considered first. A miss still returns to the existing committed-texture path, and other HRESULTs do not activate the delay. The timer starts when the failed call returns. The policy uses the same D3D12 API on all adapters. In a synthetic burst of 64 requests following a refusal, the allocator calls the heap factory once instead of 64 times. The regression verifies that allocation is retried when the delay expires and that a free range is reused during the delay in an actual D3D12 heap. WARP GPU suite passed (247 passed, one ignored) and strict Clippy passed. The new regression also passed on a physical NVIDIA RTX 5080 Laptop GPU with both PRs applied. AMD hardware validation remains open. No title files were used. Clean trial merges with #3259, #3265, #3230, #3228 and #2972. #3259 covers upload staging buffers, while this change covers the default heaps that hold the textures themselves. Inspired by [codec_d's pool-growth backoff in cool_fox](https://github.com/DoubleGhosty/cool_fox/commit/ab75ac3e02ba9fe5b45297c6254bafe5660a1a68).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:08:05 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 15:07 UTC · original · approved these changes

Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):

  • Backing off new 64 MiB CreateHeap attempts for 500 ms after E_OUTOFMEMORY while continuing to reuse freed heap ranges and letting callers fall back to committed textures avoids repeated failing heap allocations under VRAM pressure.
  • cargo test -p victory-gpu --lib placement:: -- --test-threads=1 (RTX 5090): 3 passed, 0 failed (including out_of_memory_backs_off_growth_but_not_reuse).
  • VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib placement:: -- --test-threads=1 (WARP): 3 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 15:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3266#pullrequestreview-6076465102) · **approved these changes** Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP): - Backing off new 64 MiB `CreateHeap` attempts for 500 ms after `E_OUTOFMEMORY` while continuing to reuse freed heap ranges and letting callers fall back to committed textures avoids repeated failing heap allocations under VRAM pressure. - `cargo test -p victory-gpu --lib placement:: -- --test-threads=1` (RTX 5090): 3 passed, 0 failed (including `out_of_memory_backs_off_growth_but_not_reuse`). - `VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib placement:: -- --test-threads=1` (WARP): 3 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).
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 16:10 UTC · original

WARP verification report (test report only, no code changes)

  • PR head: 87c6d350
  • main: 63bcca43 (control); WARP software adapter forced with VICTORY_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, via VICTORY_DXIL).
  • Each new/changed test run in its own process (--exact), -j 4, synthetic tests only, no game data. Command: cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>.
  • New test placement::tests::out_of_memory_backs_off_growth_but_not_reuse (also the changed placement::tests::a_range_is_reused_only_once_nothing_holds_its_texture): both pass on the PR (1 passed each). The test's WARP-device part (reuse of a free range while growth is backed off) ran.
  • Control on main: the test needs the injectable now/make parameters of Heaps::allocate, so I added only that hook to main and left out the backoff logic. The test fails on main at assert_eq!(calls.get(), 1) (left 64, right 1: 64 heap creations for 64 refused allocations instead of 1). That is a main-plus-hook control, not unmodified main.
  • victory-gpu lib suite: PR 247 passed, 0 failed, 1 ignored on 8 of 9 runs; main 246 passed, 0 failed, 1 ignored on 6 of 6. One full-suite run of the PR (the first) had 1 failure, descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record (the slot views the record written last); it passed on its own and in 8 full-suite reruns. This PR does not touch descriptors. That test sets a global WHILE_PREPARING hook that other tests share, which #3265 moves to a thread-local, so this may be a pre-existing flake; I did not reproduce it on main (6 runs).
  • Not tested: physical GPU.

AI-assisted: verification by Claude Code (Claude Sonnet 5.5)

**@⁠oni-swr** on GitHub · 2026-11-26 16:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/3266#issuecomment-7197271657) WARP verification report (test report only, no code changes) - PR head: `87c6d350` - main: `63bcca43` (control); WARP software adapter forced with `VICTORY_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, via `VICTORY_DXIL`). - Each new/changed test run in its own process (`--exact`), `-j 4`, synthetic tests only, no game data. Command: `cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>`. - New test `placement::tests::out_of_memory_backs_off_growth_but_not_reuse` (also the changed `placement::tests::a_range_is_reused_only_once_nothing_holds_its_texture`): **both pass on the PR** (1 passed each). The test's WARP-device part (reuse of a free range while growth is backed off) ran. - Control on main: the test needs the injectable `now`/`make` parameters of `Heaps::allocate`, so I added only that hook to main and left out the backoff logic. The test **fails on main** at `assert_eq!(calls.get(), 1)` (left 64, right 1: 64 heap creations for 64 refused allocations instead of 1). That is a main-plus-hook control, not unmodified main. - `victory-gpu` lib suite: PR 247 passed, 0 failed, 1 ignored on 8 of 9 runs; main 246 passed, 0 failed, 1 ignored on 6 of 6. One full-suite run of the PR (the first) had 1 failure, `descriptor::host::tests::a_slot_rewritten_while_its_view_is_prepared_views_the_new_record` (`the slot views the record written last`); it passed on its own and in 8 full-suite reruns. This PR does not touch descriptors. That test sets a global `WHILE_PREPARING` hook that other tests share, which #3265 moves to a thread-local, so this may be a pre-existing flake; I did not reproduce it on main (6 runs). - Not tested: physical GPU. AI-assisted: verification by Claude Code (Claude Sonnet 5.5)
This pull request can be merged automatically.
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/3266/head:github-bot/gh-3266'
git switch 'github-bot/gh-3266'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3266'
git switch 'github-bot/gh-3266'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3266'
git switch 'github-bot/gh-3266'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3266'
git switch 'main'
git merge --squash 'github-bot/gh-3266'
git switch 'main'
git merge --ff-only 'github-bot/gh-3266'
git switch 'main'
git merge 'github-bot/gh-3266'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3266
No description provided.