GPU: back off texture heap growth after out-of-memory #3264
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3266"
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?
Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T15:05:59Z.
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.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:07:19Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
CreateHeapattempts for 500 ms afterE_OUTOFMEMORYwhile 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 (includingout_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).
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T16:10:01Z.
WARP verification report (test report only, no code changes)
87c6d35063bcca43(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. Command:cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>.placement::tests::out_of_memory_backs_off_growth_but_not_reuse(also the changedplacement::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.now/makeparameters ofHeaps::allocate, so I added only that hook to main and left out the backoff logic. The test fails on main atassert_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-gpulib 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 globalWHILE_PREPARINGhook 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).AI-assisted: verification by Claude Code (Claude Sonnet 5.5)
Imported from Marvisak/VIctory. Originally posted by shortselow-byte on 2026-11-27T01:30:19Z.
AMD hardware check at
87c6d350, on an RX 6900 XT (RDNA 2, Windows 11, noVICTORY_*variables, so the host device is the hardware adapter, not WARP):placement::tests::out_of_memory_backs_off_growth_but_not_reuse: passes, including the part that creates a real 64 MiB heap and reuses its free range during the delay.cargo test -p victory-gpu --lib --locked: 232 passed, 0 failed, 1 ignored.main63bcca4on the same card: 231 passed, 0 failed, 1 ignored. No test that passes onmainfails here.One in-game observation that may matter for the scope. On this machine (16 GB RAM, commit limit ~35 GB), GTA VI runs out of commit a few minutes into the world, so I looked at which allocations fail. In two runs (
main, andmain+ #2974, which does not touch these paths), the loggedE_OUTOFMEMORYrefusals are almost all inHost::shared_buffer:main: 100no shared bufferwarnings, thena host command list did not closeand the run aborted at 179 s.main+ #2974: 177,750no shared bufferwarnings in 168 s (170,028 of them 4 MiB, 7,710 of 64 KiB), plus 163no mapped buffer(Host::mapped_buffer, upload/readback buffers).shared_buffercallsCreateCommittedResourceagain on every request and has no backoff, so after the first refusal it keeps hitting the driver at about 1,000 calls per second. Onmaina refusedCreateHeapinplacement.rsis not logged, so I cannot tell from these logs how often this PR's path was hit in game. I'm not claiming a gain or loss for this PR in game. The point is only that, on a low-RAM machine, the refusals I can see are inshared_buffer(and a few inmapped_buffer), which this PR does not cover.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.