GPU memory: split the copy admission from its allocation, and use the title's own backing where it can be opened #2538
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2538"
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 CwWwWwW on 2026-11-29T13:59:19Z.
GPU memory: split the copy admission from its allocation, and use the title's own backing where it can be opened
This is the rebased successor of the closed #916, split into three commits as its closing comment
asked. The code was re-derived on the current main (
829188e), not applied as the old diff: main hadalready evolved the same memory code through other forks, and the parts this branch would have
duplicated (the by-address cap, the checked device-removal waits, the window/arena budget
separation) are kept from main and recorded as such in the docs.
What it fixes
in system memory was decided inside the allocation, and a refused copy left no trace. The first
commit makes that decision explicit (
card_admission/window_admission), counts every hostbuffer by the heap class the API reports, and counts the copies that stay in system memory by the
reason they did. It also fixes an accounting defect: a window's second system-memory side was
charged to the window device-local budget.
a device-local side, the copy stays in system memory either way; opening the title's own backing
(private allocation, or one run of one section through our own view) and placing the buffer
there removes the mirror and all its machinery. This is the second commit, behind switches that
are off by default, with the existing copy path as the fallback for every refusal. It never
replaces a copy that would have been device-local (that would be a memory-class downgrade).
late waits order CPU readers behind the flight; the title's free/decommit/protect and the raw
32-bit free path let placed copies go before the kernel call; a mapping change lets go of
exactly the copies over the range through an exact registry; a section view keeps the section's
pages alive after the title unmaps its own view.
classification, what this work removed, the copies that are required and why, the unresolved
classes, and what only a real NVIDIA run can establish.
The three commits
c9887c4bGPU memory: split the copy admission from its allocation and add the placementledger — 3 files, +526/-7.
shadow::card_admission/window_admission; the placement ledgerin
residency(HeapClass/class_offromGetHeapProperties,Fallbackreasons,fallback_add/fallback_freed,placement_lineevery 5 s or withVICTORY_MEMORY_REPORT);host.rscounts every buffer made; the window second-side budgetfix;
say_separation_switches; tests for the decisions, the heap classes and the counterbalance.
53094ebaGPU memory: use the title's own backing where it can be opened — 6 files,+973/-83.
inplace::openability, refcountedSectionView, shared regions per section run(
REGION_MOST512 MiB),place_view_part,place_fallbackwithVICTORY_INPLACE_VIEW=1/2and
VICTORY_INPLACE=3;shadowplaces only where admission refused, keeps placed copies inthe exact registry, declares their shader writes, and gives no placed copy a staging/mirror/card
side/refresh/snapshot/compare/copy-back;
xmeminterceptsVirtualProtectunconditionally andthe raw 32-bit
XMemFreeDefaultpath lets placed copies go first;portuses the sharedSectionView; the ledger counts directly backed copies and refused direct asks; WARP tests forthe placement mechanics, the section lifetime, the shared region, the exact invalidation and the
counters.
56dd8d81GPU memory: record the audit of the memory split and the copy bridges — the threedocs: the platform model, the heap classes, ownership, admission, the ledger and how to read it,
the window budget and the exception matrix, the copy inventory and classification, the
implementation records, the copies that remain, the follow-ups and the verification record.
What does not change
VICTORY_INPLACE,VICTORY_INPLACE_VIEW,VICTORY_INPLACE_MB,VICTORY_INPLACE_PROBE); with them unset the product path behaves as at829188e- no policy, threshold, budget, launcher default or rendering change.layout/format/depth reasons, read-backs and the D3D12 infrastructure.
Validation
Local (Windows, Rust 1.98.1 x86_64-pc-windows-gnu):
cargo check --workspace --all-targets --lockedcargo check --workspace --all-targets --all-features --locked829188e(diagnostics feature:copystat'smb, atiminglocal shadowing the function) - inherited, not caused by this branchGitHub Actions (Windows/WARP), from a temporary
ci/**branch of the fork (test workflow only,not part of this branch; the branch itself is
feat/gpu-memory-rebased):829188etoo (inherited)victory-gpulib (914 passed on the baseline); the focused in-place tests 15/15 PASS; every other test target passes; the only failures are the nine the baseline has too829188ebaselinebcpack::oracle_parity_*, fiveemittests,xtask's asset-policyrepository_passes_policy);victory-gpulib 914 passed, 1 failed (a flaky card-steps test)The branch adds ten passing tests to the
victory-gpulib (924 against 914) and introduces nofailure: the nine failures are identical on plain
829188ewith the same workflow, in files thischange does not touch. The tested source tip is
53094eba; the third commit (docs only) was amendedafter the run, so the source is unchanged after it.
What must be established on real NVIDIA hardware
Nothing here claims the direct path is ready to be a default: WARP proves the mechanics, not the
driver or the hardware. Before any switch becomes a default:
OpenExistingHeapFromAddress1is accepted by the target driver for private allocations andfor our section views, what it pins and at what working-set cost;
VICTORY_INPLACE_PROBE=1);residency/WDDM paging and device-removal/TDR behaviour.
Note on #916
This is the rebased successor of the closed #916: the same memory work, re-derived on the current
main and split into three commits as its closing comment asked, so it can be reviewed commit by
commit.
Follow-ups
shadow::exact) over openable backing: needs the exact pool to hold a placedform.
the memory is openable.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by futurepro62 on 2026-11-29T20:07:27Z.
The placement line never prints: its 5-second timer is reset on every check.
READ IN CODE (PR head
56dd8d81,host.rsaround line 13888):Meter::framereaches the placement block about once a second (afterframe_times_line). The block doesso
nowis stored on every call and the gap is never more than about 1,000 ms. The first check doesn't print either:now_ms()starts its clock at its first call, sonowis near 0 there. The result is nomemory placementline, withVICTORY_MEMORY_REPORT=1or without it.A fix that prints at the first check and then every 5 s:
MEASURED: with
VICTORY_MEMORY_REPORT=1, a 6.4-min session printed 0memory placementlines (the startupmemory separation: placement switches set: ... VICTORY_MEMORY_REPORT=1line shows the switch was seen). With the fix, a 7.0-min session printed 86 lines, a 17-min one 194.What the ledger then showed (MEASURED, one run each, not the same route, so read it as direction, not effect size):
no card copy for a title buffer), and there are none in the first two runs. The 2048 MB run has 21, totalling 6 MB, all near the end with the card at 14,405 of 14,826 MB.a buffer's host copy is in the card's memorylines).Method
c9887c4bby hand onto an older tree: fork main9300875plus local picks (#339, #348, #638, #1074/#1145, #1551, main's25b3b5c) and a 3619 port. The port takes residency's ledger verbatim, plusplaced(), the meter block,say_separation_switches, andcard_admission/window_admissionwritten against that tree'scard_room_for/window_room_for. It leaves out theVICTORY_WINDOWS_OWNbudget change and commits 2–3. The timer code above is the same in the port and at the PR head. The 80 %/89 % line is a local switch (VICTORY_CARD_WINDOWS_PERCENT), and the cap is the existingVICTORY_CARD_WINDOWS_MB.memory placementlines (last line, and peaks per minute), thetexture queue's roomlines (count ofno room), andframe_timeswindows with a median over 20 ms (in the world; frames are the game's before frame generation, with a 71.4 ms pacing cap). Hitches are the windows'over 100 mscounts per minute in the world.Written with Claude Code (Claude Opus 5.5) from our own runs; I checked it before posting.
Pull request closed