Skip to content

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

Open
yumaste wants to merge 1 commit into
Marvisak:mainfrom
yumaste:fix/texture-heap-growth-backoff
Open

yumaste wants to merge 1 commit into
Marvisak:mainfrom
yumaste:fix/texture-heap-growth-backoff

Conversation

@yumaste

@yumaste yumaste commented Nov 26, 2026 •

Copy link
Copy Markdown

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.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@oni-swr

oni-swr commented Nov 26, 2026 •

Copy link
Copy Markdown

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 GPU: batch host mirroring for contiguous descriptor copies #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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants