host: keep 512 MB of the card's budget free of texture copies #4005
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4005"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by maozhongmao on 2026-11-30T14:19:13Z.
Fixes #
Summary
On an 8 GiB card the run still ends with the driver refusing a command list
(
0x8007000E) or removing the device (0x887A0007) while the card's ownmemory is over its budget. The texture room line does not prevent that,
because render targets, buffer copies and scratch are made with no room test
of their own; only the host texture copies are weighed against a line, and
they can be pushed over it by everything else.
This adds
VICTORY_TEXTURE_KEEP_FREE_MB(512 MB by default; 0 restores theold behaviour): that many bytes of the card's budget are kept free of host
texture copies. The cap is recomputed from the DXGI budget, the current use
and the bytes that are not host copies, so it follows the scene instead of
being a fixed number; and the once-a-second sweep takes idle copies down to
the same line, so the reserve comes back after a scene grew past it. An
explicit
VICTORY_TEXTURE_BUDGET_MBis now checked before the normal roomline as well.
What it changes, by function
crates/victory-gpu/src/resource.rskeep_free_bytes(): the reserve, fromVICTORY_TEXTURE_KEEP_FREE_MB(default 512 MB; clamped to 8192 MB; 0 = off).
dynamic_texture_cap(memory): the bytes host copies may hold:The bracket is what the title holds on the card that is not a host copy of
a texture: render targets (aliased or committed), the buffers of
VICTORY_CARD_BUFFERS_MB, scratch, staging. Those are the bytes that usedto take the card past its budget unnoticed.
room_for_first_upload(): checksdynamic_texture_cap()before theordinary room line, and counts a refusal in
FirstUpload::ExplicitBudgetso the existing per-reason counters stay meaningful. The check is on
HOST_TEXTURES[1](every host texture alive), not onKINDS[1](only thecopies the title fills), which is what the memory line reports.
an explicit
VICTORY_TEXTURE_BUDGET_MBis now also checked before theroom line: before this it was only consulted once the card had no room
anyway, so a card with room took textures past it (0
ExplicitBudgetrefusals in a full run with 4096 set).
let_go_idle(): the sweep's soft budget is nowsoft_budget().or_else(dynamic_texture_cap), so idle copies are taken downto the same line (idle 5 s when over it), not only down to a fixed
VICTORY_TEXTURE_SOFT_MB.breakdown()and thememory nowline:VICTORY_CARD_BREAKDOWN=1appends the host-texture count and bytes, the aliased-target bytes and the
free texture blocks to the once-a-second line. Every number in this PR came
from it.
Reproduction
D3D12 Agility 1.618 beside
victory.exe.Walk around the city and enter a fight; the crash comes after a few minutes.
What the log showed
Before (room line at 80 %, no reserve):
and, earlier in the same configuration, the command-list variant:
After (reserve 512 MB):
The card's own use then stays at 6.4-6.9 GiB of a 7.0-7.2 GiB budget (about
500-600 MiB free) across the sessions tested, with the world fully rendered,
and the run no longer ends.
A/B
VICTORY_TEXTURE_ROOM_PERCENT=80only0x887A0007)a host command list did not reset (0x8007000E)VICTORY_TEXTURE_KEEP_FREE_MB=512Risks and limits
0) by default on cards where nothing else changed:behaviour is exactly as before.
black until copies are let go; with 512 MB on this card that did not show
in play. A lower reserve (e.g. 1024 or 1536) trades texture churn for
headroom, a higher one goes back towards the old failure.
CurrentUsagefrom DXGI, which includes the driver's ownallocations as well as ours; on cards whose budget moves under us
(the log records moves of 256 MB and more) the cap moves with it.
expected to be the same below their budget, but is untested here.
Tests
cargo test -p victory-gpu: the suite passes exceptambient::tests::the_passes_build, which aborts the test process (exit 3)on this machine before any of this change runs; it is an ambient shader
test and touches none of the code here.
cargo clippy -p victory-gpu --all-targets -- -D warningsfails only invictory-shader(while_immutable_condition, 3 sites), which thisbranch does not touch.
Checked for overlap
history: bug-journal
923e38c/ #1520 (16 GiB host reaching the 8 GiBshared-memory cap in ~95 s,
0x8007000Eon a host command list) and theVICTORY_TEXTURE_ROOM_PERCENTknob, which the A/B above shows does notcover this case. #3994 (send spares under host memory pressure) and #4004
(frame-log holdback reporting) touch other paths.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by maozhongmao on 2026-11-30T16:04:59Z.
Update after v2026.11.30.01: on the machine this was reported from (16 GiB host, 8 GiB card) the release's
playpath already keeps the run stable - memory stays around 12 GB and it no longer ends. So this change is no longer the only way past the failure; what it still covers is the plainvictory.exe run ...path and setups that do not start through the launcher's defaults, where the same0x8007000E/0x887A0007remains reachable.The A/B numbers above were taken before that release. Whether this belongs in the tree is up to you; I can re-run the numbers against
c71899dif that helps.