GPU memory: which copies are redundant, what the placement ledger measures, and where the GPU can use the title's own bytes #2540

Open
opened 2026-11-29 14:01:24 +00:00 by github-bot · 1 comment
Owner

@⁠CwWwWwW on GitHub · 2026-11-29 13:59 UTC · original

GPU memory: which copies are redundant, what the placement ledger measures, and where the GPU can use the title's own bytes

The work is in #2538 (three commits on feat/gpu-memory-copy-bridges): the rebased successor
of the old #916, re-derived on the current main. This issue is about the problems those commits
solve and the design choices - comments are welcome.

PR: #2538

Problem 1: nobody could tell where the copies went

A title buffer's or window's host copy is either given a device-local side on the card or left in
system memory. That decision was made inside the allocation (shadow::card_for /
window_card_for): a refused copy was not recorded, a single-sided copy was silent, and a
copy back into system memory was indistinguishable in the log from one on the card. The DXGI
budget, the card limits, the path's byte cap and the host's readiness all decided it, but nothing
counted the outcome.

Commit 1 splits the decision from the allocation: card_admission / window_admission run
exactly the checks card_for / window_card_for ran, before any buffer is allocated, and return
residency::Fallback as the reason for a refusal. The placement ledger then counts:

  • every host buffer made, by the heap class the API reports for it (GetHeapProperties);
  • the copies whose GPU-visible side is system memory, alive and since the start, by reason;
  • for the direct path (commit 2), the directly backed copies and the refused direct asks.

The line is printed every 5 s while a fallback copy lives, or when VICTORY_MEMORY_REPORT=1. This
is the measurement used to decide whether the direct path is worth anything: run a save with the
switches off, then on, and compare what moved.

Also in commit 1, a defect the audit found: a window's second system-memory side
(VICTORY_WINDOWS_OWN) was charged to the window device-local budget, so a fallback could
consume VRAM budget and refuse later windows their card side. A second side is system memory; it is
in the ledger now, and only a device-local side is charged and given back.

Problem 2: copies that are redundant because the GPU can reach the title's bytes

The title's memory is pagefile-backed sections mapped as views, plus private allocations. Part of it
is openable as a host heap: one contiguous run of one section (through our own view of that run) or
a committed part of a private allocation. For a copy that stays in system memory anyway (no
device-local side), giving the GPU the title's own bytes is the same memory class with strictly
fewer copies: no mirror, no refresh, no send, no compare, no copy-back. For a copy with a
device-local side it is not the same class, so the policy must not touch those.

Commit 2 adds that path, behind switches that are off by default:

  • inplace::openability classifies a range: private committed memory, one run of one section, or a
    refusal (unmapped/scattered/holes). A refcounted SectionView maps our own view of the run and
    keeps the section's pages alive after the title unmaps its view and closes its handle; one view
    and one heap are shared per run, up to 512 MiB.
  • inplace::place_fallback is asked exactly where admission refused: VICTORY_INPLACE_VIEW=1
    places page-pool windows, =2 title buffers too, VICTORY_INPLACE=3 private memory. A placed
    copy makes no staging/mirror, no card side, no hash twin, no send/fetch/compare/copy-back, and
    the mirror stays the fallback for every refusal.
  • a placed copy's shader writes are declared (defer_gpu_write) so the late waits order a CPU
    reader behind the flight; the title's VirtualFree/decommit/release, its VirtualProtect and
    XMemFreeDefault's 32-bit 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.
  • port uses the same shared SectionView, so there is one owner/lifetime for a section view.

Problem 3: the record of what remains

Commit 3 is the write-up: the copy-bridge inventory and classification (title buffers,
windows, view-byte copies, by-address arenas, textures, targets/depth/read-backs, D3D12
infrastructure, the title's own CPU steps, the experiment switches), what this work removed, what
remains and why, what only a real NVIDIA run can establish, and the verification record.

What is deliberately not done

  • Carded copies stay: replacing a device-local side with system-memory access is a memory-class
    downgrade; only a measured PCIe-vs-VRAM study could justify it, and nothing here does it.
  • View-byte copies (shadow::exact) would need the new exact pool to hold a placed form; they stay
    on the copy path for now.
  • Scattered/holed memory (multi-run composition), a layout-equal texture subset (needs a layout
    census + driver probe), a device-local by-address arena, and overlapping placed resources are
    listed as unresolved.
  • Legacy VICTORY_INPLACE=1/2 and VICTORY_PORT_CONSTANTS behaviour is unchanged.

Evidence so far

  • cargo check --workspace --all-targets --locked PASS after each commit (local and CI).
  • The all-features build already fails at 829188e (diagnostics feature: copystat's mb and a
    timing local shadowing the function) - inherited, reported in the PR, not caused here.
  • Full cargo test --workspace in CI on Windows/WARP, compared against a baseline run of plain
    829188e with the same workflow: the branch adds ten passing tests to the victory-gpu lib (924
    against 914) and introduces no failure; the nine failures are identical on the baseline, in files
    this work does not touch (three bcpack::oracle_parity_* in victory-formats, five emit tests
    in victory-shader, and xtask's asset-policy repository_passes_policy). The build check with
    default features passes; the all-features build fails identically at 829188e (diagnostics
    feature, untouched here).
  • No NVIDIA hardware here: nothing is claimed about driver acceptance, pinning, coherency, PCIe cost
    or physical residency.

Questions for discussion

  1. Is the "only the copies the admission refused" rule the right boundary for direct access, or
    should some device-local copies be offered a direct option too (a measurement question)?
  2. The placement ledger line: is every 5 s and VICTORY_MEMORY_REPORT the right place, or should it
    be diagnostics-build only?
  3. Which unresolved class should come next after a hardware census: view-byte copies, scattered
    views (multi-run), or the layout-equal texture subset?
  4. For the windows' late card-side policy (card_late): should a window that is late be offered the
    direct path in the meantime, or is copying it for its first frames the cheaper choice?
**@⁠CwWwWwW** on GitHub · 2026-11-29 13:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2540) # GPU memory: which copies are redundant, what the placement ledger measures, and where the GPU can use the title's own bytes The work is in **#2538** (three commits on `feat/gpu-memory-copy-bridges`): the rebased successor of the old #916, re-derived on the current main. This issue is about the problems those commits solve and the design choices - comments are welcome. PR: https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/2538 ## Problem 1: nobody could tell where the copies went A title buffer's or window's host copy is either given a device-local side on the card or left in system memory. That decision was made *inside the allocation* (`shadow::card_for` / `window_card_for`): a refused copy was not recorded, a single-sided copy was silent, and a copy back into system memory was indistinguishable in the log from one on the card. The DXGI budget, the card limits, the path's byte cap and the host's readiness all decided it, but nothing counted the outcome. **Commit 1** splits the decision from the allocation: `card_admission` / `window_admission` run exactly the checks `card_for` / `window_card_for` ran, before any buffer is allocated, and return `residency::Fallback` as the reason for a refusal. The placement ledger then counts: - every host buffer made, by the heap class the API reports for it (`GetHeapProperties`); - the copies whose GPU-visible side is system memory, alive and since the start, by reason; - for the direct path (commit 2), the directly backed copies and the refused direct asks. The line is printed every 5 s while a fallback copy lives, or when `VICTORY_MEMORY_REPORT=1`. This is the measurement used to decide whether the direct path is worth anything: run a save with the switches off, then on, and compare what moved. Also in commit 1, a defect the audit found: a window's second system-memory side (`VICTORY_WINDOWS_OWN`) was charged to the window *device-local* budget, so a fallback could consume VRAM budget and refuse later windows their card side. A second side is system memory; it is in the ledger now, and only a device-local side is charged and given back. ## Problem 2: copies that are redundant because the GPU can reach the title's bytes The title's memory is pagefile-backed sections mapped as views, plus private allocations. Part of it is openable as a host heap: one contiguous run of one section (through our own view of that run) or a committed part of a private allocation. For a copy that stays in *system memory* anyway (no device-local side), giving the GPU the title's own bytes is the same memory class with strictly fewer copies: no mirror, no refresh, no send, no compare, no copy-back. For a copy with a device-local side it is not the same class, so the policy must not touch those. **Commit 2** adds that path, behind switches that are off by default: - `inplace::openability` classifies a range: private committed memory, one run of one section, or a refusal (unmapped/scattered/holes). A refcounted `SectionView` maps our own view of the run and keeps the section's pages alive after the title unmaps its view and closes its handle; one view and one heap are shared per run, up to 512 MiB. - `inplace::place_fallback` is asked exactly where admission refused: `VICTORY_INPLACE_VIEW=1` places page-pool windows, `=2` title buffers too, `VICTORY_INPLACE=3` private memory. A placed copy makes no staging/mirror, no card side, no hash twin, no send/fetch/compare/copy-back, and the mirror stays the fallback for every refusal. - a placed copy's shader writes are declared (`defer_gpu_write`) so the late waits order a CPU reader behind the flight; the title's `VirtualFree`/decommit/release, its `VirtualProtect` and `XMemFreeDefault`'s 32-bit 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. - `port` uses the same shared `SectionView`, so there is one owner/lifetime for a section view. ## Problem 3: the record of what remains **Commit 3** is the write-up: the copy-bridge inventory and classification (title buffers, windows, view-byte copies, by-address arenas, textures, targets/depth/read-backs, D3D12 infrastructure, the title's own CPU steps, the experiment switches), what this work removed, what remains and why, what only a real NVIDIA run can establish, and the verification record. ## What is deliberately not done - Carded copies stay: replacing a device-local side with system-memory access is a memory-class downgrade; only a measured PCIe-vs-VRAM study could justify it, and nothing here does it. - View-byte copies (`shadow::exact`) would need the new exact pool to hold a placed form; they stay on the copy path for now. - Scattered/holed memory (multi-run composition), a layout-equal texture subset (needs a layout census + driver probe), a device-local by-address arena, and overlapping placed resources are listed as unresolved. - Legacy `VICTORY_INPLACE=1/2` and `VICTORY_PORT_CONSTANTS` behaviour is unchanged. ## Evidence so far - `cargo check --workspace --all-targets --locked` PASS after each commit (local and CI). - The all-features build already fails at `829188e` (diagnostics feature: `copystat`'s `mb` and a `timing` local shadowing the function) - inherited, reported in the PR, not caused here. - Full `cargo test --workspace` in CI on Windows/WARP, compared against a baseline run of plain `829188e` with the same workflow: the branch adds ten passing tests to the `victory-gpu` lib (924 against 914) and introduces no failure; the nine failures are identical on the baseline, in files this work does not touch (three `bcpack::oracle_parity_*` in victory-formats, five `emit` tests in victory-shader, and `xtask`'s asset-policy `repository_passes_policy`). The build check with default features passes; the all-features build fails identically at `829188e` (diagnostics feature, untouched here). - branch run: https://github.com/CwWwWwW/VIctory-NVIDIA/actions/runs/46269247875 - baseline run: https://github.com/CwWwWwW/VIctory-NVIDIA/actions/runs/46267700603 - No NVIDIA hardware here: nothing is claimed about driver acceptance, pinning, coherency, PCIe cost or physical residency. ## Questions for discussion 1. Is the "only the copies the admission refused" rule the right boundary for direct access, or should some device-local copies be offered a direct option too (a measurement question)? 2. The placement ledger line: is every 5 s and `VICTORY_MEMORY_REPORT` the right place, or should it be diagnostics-build only? 3. Which unresolved class should come next after a hardware census: view-byte copies, scattered views (multi-run), or the layout-equal texture subset? 4. For the windows' late card-side policy (`card_late`): should a window that is late be offered the direct path in the meantime, or is copying it for its first frames the cheaper choice?
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 14:01:24 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-29 13:59 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-29 13:59 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/2540#issuecomment-7256956611) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA#2540
No description provided.