Repository navigation
host: keep 512 MB of the card's budget free of texture copies - #4005
Open
maozhongmao wants to merge 1 commit into
Open
maozhongmao wants to merge 1 commit into
maozhongmao wants to merge 1 commit into
Conversation
A card that runs out of its budget mid-frame has the driver refuse a command list or remove the device (0x8007000E / 0x887A0007). With VICTORY_TEXTURE_ROOM_PERCENT=80 alone, an 8 GiB card still ended at DXGI local 7845/7092 MiB (host texture copies 5807 MiB): render targets, buffer copies and scratch are made with no room test of their own. VICTORY_TEXTURE_KEEP_FREE_MB (512 MB by default, 0: off as before) keeps that much of the budget free: a first upload is admitted only while the host copies fit what the budget leaves after the other card bytes and the reserve, and the idle sweep takes idle copies down to the same line. An explicit VICTORY_TEXTURE_BUDGET_MB is now checked before the normal room line. VICTORY_CARD_BREAKDOWN=1 adds the host-texture, aliased-target and free-block breakdown to the memory line.
Author
|
Update after v2026.11.30.01: on the machine this was reported from (16 GiB host, 8 GiB card) the release's 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 c71899d if that helps. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 / 16 GB RAM regression on 923e38c: 8 GiB WDDM L0 Shared GPU Memory exhausted in ~95s (CommandList::Close 0x8007000E) + VICTORY_WINDOWS_BAR_MB auto-config dropped #1520 (16 GiB host reaching the 8 GiB
shared-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. Sends: under host memory pressure the spares the frames use stay, memory past 256 MiB is never kept, and releases leave the submitting thread (a 32 GB PC made them again every second) #3994 (send spares under host memory pressure) and report texture upload holdbacks in frame log summaries #4004
(frame-log holdback reporting) touch other paths.