GPU memory: separate RAM from VRAM and use the title's own backing where it can be opened #1517

Open
CwWwWwW wants to merge 1 commit from upstream-pr/1517 into main
CwWwWwW commented 2026-11-28 17:18:56 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by CwWwWwW on 2026-11-28T17:18:56Z.


What this is

This is the GPU-memory project from trustno1-coder/VIctory-NVIDIA#916, ported onto this fork's
main (368967f, the VIctory-NVIDIA 959dcaf tree plus this fork's work). One commit, 11 files,
+3605/-243.

It has two halves:

  1. RAM/VRAM separation - the explicit memory-domain model, the placement ledger, the verified
    accounting fixes, the window/texture budget audit and the verification record
    (docs/memory-separation.md, docs/memory-separation-window-budget.md).
  2. Copy bridges - the complete audit and classification of every copy
    (docs/copy-bridges.md), the backing/admission invariants, the page-pool direct-access
    prototype, the migration of the copies the policy refuses, the coherence/lifetime wiring, and
    the removal plus the record of what remains.

The title is an Xbox Series title whose GPU memory is console unified memory, so a title GPU
address is a CPU address. The layer keeps host mirrors of title memory for the host GPU and copies
between them; this change makes that boundary explicit, removes the copies that are redundant
because the GPU can reach the title's own bytes, and documents every copy that remains and why.

No default changes: every direct-access switch is off, and with them unset the product path is
exactly this fork's base behaviour.

What it does

  • Direct access instead of a copy, only where the policy already refused a device-local side
    (so a carded copy is never replaced by a memory-class downgrade): inplace::place_fallback is
    asked exactly where the device-local admission refused the copy, and opens the title's own
    memory as a host heap - our own view of one committed section run
    (OpenExistingHeapFromAddress1, one view and one heap per run, shared) or a part of the
    title's private allocation. A placed copy has no staging/mirror, no card side, no hash twin, no
    send/fetch state, no refresh, no snapshot and no copy-back; the GPU reads and writes the title's
    pages.
  • Switches (all off by default): VICTORY_INPLACE_VIEW 1/2 (page-pool windows, then title
    buffers and view bytes), VICTORY_INPLACE 3+ (the refused-copy substitution for private
    memory), VICTORY_INPLACE_MB 4096 (in-place byte cap), VICTORY_INPLACE_PROBE (census).
    Every refusal is counted with its reason in the placement ledger and falls back to the old copy
    path.
  • Coherence and lifetime: placed shader writes are declared through the existing
    HostList::defer_gpu_write path so late waits order CPU readers behind the flight; the title's
    free/decommit/release, VirtualProtect (now intercepted unconditionally) and
    XMemFreeDefault's raw VirtualFree let placed copies go before the kernel call; the
    section view is refcounted and keeps a section's pages alive after the title unmaps its view and
    closes the handle; ID3D12Device13 is probed once and a run without it refuses placements as
    HostUnavailable.
  • Required copies stay: carded VRAM copies, by-address shader memory, texture/target/depth
    copies that exist for layout/format reasons, and the D3D12 infrastructure. The audit records
    each one and why.

Port notes (this fork is based on 959dcaf, not #916's 63b902f)

The patch applied with four conflicts and three small helpers, all resolved without dropping
either side:

  • host.rs: kept this tree's fn create() -> windows::core::Result<Host> (the anyhow conversion
    is newer than this base) and kept the in-place/separation startup notes added by the change;
    added the checked device-removal wait helpers (fence_reached, wait_host_fence,
    wait_event_for_fence).
  • shadow.rs: card_allocate keeps this tree's allocation path (there is no crate::ahead
    pre-made buffer on this base).
  • Added, because the newer base has them and the ported tests/ledger line need them:
    host_made(), Host::shared_buffer_now() (a shared buffer made now) and the
    WAIT_OBJECT_0 import.
  • Left out, because this base does not have them: the crate::upload::reserve_early startup call
    and the crate::ahead::want_card() admission hint.

Validation

Local (Windows, Rust 1.98.1 x86_64-pc-windows-gnu, this port's tree):

Check Result
cargo check --workspace --all-targets --locked PASS (169 s, cold target)

GitHub Actions on this fork (Windows windows-latest, WARP), from temporary ci/** validation
branches (the workflow file is the only extra file; it is not part of this branch). The fork's
own main was run through the same workflow
so the port is compared against its real base:

Fork main 368967f (baseline) This branch
Build check (workspace, all targets, all features) PASS PASS
Tests 413 passed, 3 failed, 35 ignored 432 passed, 3 failed, 35 ignored

The 3 failures are identical at the fork's base and with this change (same tests, same panic
sites): indirect::tests::host_list_budget_starts_empty_at_each_submission,
indirect::tests::warp_batch_charges_every_execution and
pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws (the last is the WARP
depth-bounds limitation). The port adds 19 passing tests and introduces no new failure.

The fork's own CI gate is already red at this base. The PR's check run
(46169810785) fails in its Clippy step on pre-existing lints in files this change does not touch
(clippy::precedence in victory-formats/src/texture.rs:1346; the same base also fails
manual_is_multiple_of in victory-shader/src/emit/water_tile_slots.rs:87 and the
transmute annotations in victory-loader/src/write_sites.rs:349,425, identical on the
baseline tree). The diagnostics build and Tests steps are therefore skipped on the PR, as they are
on the fork's base; the full-test evidence above comes from the temporary workflow run.

What is not claimed (needs real NVIDIA hardware)

WARP and GetHeapProperties prove the creation heap class the API reports, not physical
residency. Not established here: that OpenExistingHeapFromAddress1 is accepted by the target
NVIDIA driver on private allocations and section views (and what it pins), the openable share of
the real title memory, coherency of GPU access to title system memory under the real relay, PCIe
cost against the copies replaced, WDDM residency/paging, and device-removal/TDR behaviour.

How to proceed after this PR

  1. Review together with trustno1-coder/VIctory-NVIDIA#916 - same change, authoritative upstream
    submission; this fork's PR exists because this fork's base (959dcaf-based) needs its own port
    and validation. Keep the two in sync.
  2. Safe to merge off-by-default: no policy, threshold, budget, launcher default or rendering
    behaviour changes with the switches off; the 3 test failures are inherited from this fork's
    base.
  3. Then validate on the target NVIDIA hardware: VICTORY_MEMORY_REPORT=1 baseline ledger ->
    VICTORY_INPLACE_PROBE=1 census -> same save with VICTORY_INPLACE_VIEW=2 /
    VICTORY_INPLACE=3 -> coherency under the real relay -> PCIe A/B with GPUView/ETW -> title
    free/decommit/protect and a device-removal/TDR run. If a defect shows, keep the switches off
    and report it.
  4. Then the remaining removals, in order: port-region bookkeeping unified with the shared
    registry (no hardware needed); legacy in-place levels 1/2 and the write-combined/second-side
    experiments (after the hardware A/B); per-class default enablement (then the mirror branches
    for those classes become unreachable); multi-run composition for scattered memory; the
    texture/target/depth subset after a layout census. Carded copies stay - replacing them is a
    memory-class downgrade.

The full audit, per-phase implementation records, remaining-copy record and the hardware checklist
are in docs/copy-bridges.md (§10, §11, §16, §17) and docs/memory-separation.md.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5542716594 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1517). Originally posted by [CwWwWwW](https://github.com/CwWwWwW) on 2026-11-28T17:18:56Z. --- ## What this is This is the GPU-memory project from **trustno1-coder/VIctory-NVIDIA#916**, ported onto this fork's `main` (368967f, the VIctory-NVIDIA 959dcaf tree plus this fork's work). One commit, 11 files, **+3605/-243**. It has two halves: 1. **RAM/VRAM separation** - the explicit memory-domain model, the placement ledger, the verified accounting fixes, the window/texture budget audit and the verification record (`docs/memory-separation.md`, `docs/memory-separation-window-budget.md`). 2. **Copy bridges** - the complete audit and classification of every copy (`docs/copy-bridges.md`), the backing/admission invariants, the page-pool direct-access prototype, the migration of the copies the policy refuses, the coherence/lifetime wiring, and the removal plus the record of what remains. The title is an Xbox Series title whose GPU memory is console unified memory, so a title GPU address is a CPU address. The layer keeps host mirrors of title memory for the host GPU and copies between them; this change makes that boundary explicit, removes the copies that are redundant because the GPU can reach the title's own bytes, and documents every copy that remains and why. **No default changes**: every direct-access switch is off, and with them unset the product path is exactly this fork's base behaviour. ## What it does - **Direct access instead of a copy, only where the policy already refused a device-local side** (so a carded copy is never replaced by a memory-class downgrade): `inplace::place_fallback` is asked exactly where the device-local admission refused the copy, and opens the title's own memory as a host heap - our own view of one committed section run (`OpenExistingHeapFromAddress1`, one view and one heap per run, shared) or a part of the title's private allocation. A placed copy has no staging/mirror, no card side, no hash twin, no send/fetch state, no refresh, no snapshot and no copy-back; the GPU reads and writes the title's pages. - **Switches (all off by default)**: `VICTORY_INPLACE_VIEW` 1/2 (page-pool windows, then title buffers and view bytes), `VICTORY_INPLACE` 3+ (the refused-copy substitution for private memory), `VICTORY_INPLACE_MB` 4096 (in-place byte cap), `VICTORY_INPLACE_PROBE` (census). Every refusal is counted with its reason in the placement ledger and falls back to the old copy path. - **Coherence and lifetime**: placed shader writes are declared through the existing `HostList::defer_gpu_write` path so late waits order CPU readers behind the flight; the title's free/decommit/release, `VirtualProtect` (now intercepted unconditionally) and `XMemFreeDefault`'s raw `VirtualFree` let placed copies go before the kernel call; the section view is refcounted and keeps a section's pages alive after the title unmaps its view and closes the handle; `ID3D12Device13` is probed once and a run without it refuses placements as `HostUnavailable`. - **Required copies stay**: carded VRAM copies, by-address shader memory, texture/target/depth copies that exist for layout/format reasons, and the D3D12 infrastructure. The audit records each one and why. ## Port notes (this fork is based on 959dcaf, not #916's 63b902f) The patch applied with four conflicts and three small helpers, all resolved without dropping either side: - `host.rs`: kept this tree's `fn create() -> windows::core::Result<Host>` (the anyhow conversion is newer than this base) and kept the in-place/separation startup notes added by the change; added the checked device-removal wait helpers (`fence_reached`, `wait_host_fence`, `wait_event_for_fence`). - `shadow.rs`: `card_allocate` keeps this tree's allocation path (there is no `crate::ahead` pre-made buffer on this base). - Added, because the newer base has them and the ported tests/ledger line need them: `host_made()`, `Host::shared_buffer_now()` (a shared buffer made now) and the `WAIT_OBJECT_0` import. - Left out, because this base does not have them: the `crate::upload::reserve_early` startup call and the `crate::ahead::want_card()` admission hint. ## Validation Local (Windows, Rust 1.98.1 x86_64-pc-windows-gnu, this port's tree): | Check | Result | |---|---| | `cargo check --workspace --all-targets --locked` | **PASS** (169 s, cold target) | GitHub Actions on this fork (Windows `windows-latest`, WARP), from temporary `ci/**` validation branches (the workflow file is the only extra file; it is not part of this branch). The **fork's own main was run through the same workflow** so the port is compared against its real base: | | Fork main `368967f` (baseline) | This branch | |---|---|---| | Build check (workspace, all targets, all features) | PASS | PASS | | Tests | **413 passed, 3 failed, 35 ignored** | **432 passed, 3 failed, 35 ignored** | - Baseline run: https://github.com/CwWwWwW/victory-fork/actions/runs/46169188648 - Ported branch run: https://github.com/CwWwWwW/victory-fork/actions/runs/46169184289 The 3 failures are **identical at the fork's base and with this change** (same tests, same panic sites): `indirect::tests::host_list_budget_starts_empty_at_each_submission`, `indirect::tests::warp_batch_charges_every_execution` and `pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws` (the last is the WARP depth-bounds limitation). The port adds 19 passing tests and introduces no new failure. **The fork's own CI gate is already red at this base.** The PR's `check` run (46169810785) fails in its Clippy step on pre-existing lints in files this change does not touch (`clippy::precedence` in `victory-formats/src/texture.rs:1346`; the same base also fails `manual_is_multiple_of` in `victory-shader/src/emit/water_tile_slots.rs:87` and the `transmute` annotations in `victory-loader/src/write_sites.rs:349,425`, identical on the baseline tree). The diagnostics build and Tests steps are therefore skipped on the PR, as they are on the fork's base; the full-test evidence above comes from the temporary workflow run. ## What is not claimed (needs real NVIDIA hardware) WARP and `GetHeapProperties` prove the creation heap class the API reports, not physical residency. Not established here: that `OpenExistingHeapFromAddress1` is accepted by the target NVIDIA driver on private allocations and section views (and what it pins), the openable share of the real title memory, coherency of GPU access to title system memory under the real relay, PCIe cost against the copies replaced, WDDM residency/paging, and device-removal/TDR behaviour. ## How to proceed after this PR 1. **Review together with trustno1-coder/VIctory-NVIDIA#916** - same change, authoritative upstream submission; this fork's PR exists because this fork's base (959dcaf-based) needs its own port and validation. Keep the two in sync. 2. **Safe to merge off-by-default**: no policy, threshold, budget, launcher default or rendering behaviour changes with the switches off; the 3 test failures are inherited from this fork's base. 3. **Then validate on the target NVIDIA hardware**: `VICTORY_MEMORY_REPORT=1` baseline ledger -> `VICTORY_INPLACE_PROBE=1` census -> same save with `VICTORY_INPLACE_VIEW=2` / `VICTORY_INPLACE=3` -> coherency under the real relay -> PCIe A/B with GPUView/ETW -> title free/decommit/protect and a device-removal/TDR run. If a defect shows, keep the switches off and report it. 4. **Then the remaining removals, in order**: port-region bookkeeping unified with the shared registry (no hardware needed); legacy in-place levels 1/2 and the write-combined/second-side experiments (after the hardware A/B); per-class default enablement (then the mirror branches for those classes become unreachable); multi-run composition for scattered memory; the texture/target/depth subset after a layout census. Carded copies stay - replacing them is a memory-class downgrade. The full audit, per-phase implementation records, remaining-copy record and the hardware checklist are in `docs/copy-bridges.md` (§10, §11, §16, §17) and `docs/memory-separation.md`.
Filip722 commented 2026-11-28 19:06:49 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-28T19:06:49Z.


Tested 791c8582 on a physical RTX 5060 Laptop GPU (8 GB) under Bazzite 44.20261011.0, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton cae8353ed7959c4+. The locked MSVC release and seven focused tests passed.

I reran the existing placement fixtures with a local test-only change to select the physical adapter and require ID3D12Device13. The page-pool fixture passed in both directions across two views of an anonymous section, including protection changes and cleanup. The private-placement fixture passed readback and GPU-copy writes at the requested offset.

The broader probe passed committed-section reads, writes and remapping with Wine's built-in compiler. Its private-buffer UAV shader step returned 0x80004005. With the same fixture binary and the native SDK compiler 10.0.28000.2705 it passed all three fixtures, including the UAV write. I also verified three green physical fixtures using Wine's built-in compiler with the existing DXC fallback from #1489 applied to this probe.

I also tested the page-pool switch on a private integration of this branch and the already validated Proton compatibility fixes. Both replays used the same binary, Series S settings, checkpoint and initial caches. Only VICTORY_INPLACE_VIEW changed from 0 to 1, with the private-placement switch unset. The enabled run created 9 direct placements totaling 44 MiB during startup and had zero live placements by the boat checkpoint. The stable control view was 5.70 rendered FPS (170.1 ms median). The enabled run ended at the desktop-response cutoff during the checkpoint retry, before the equivalent rendered sample. Both scopes cleaned up. This confirms that the page-pool placement can be exercised in the title under Proton. A frame-time improvement remains unverified.

Assisted by Codex (GPT-6.2-Sol High).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7244298639 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1517#issuecomment-7244298639). Originally posted by [Filip722](https://github.com/Filip722) on 2026-11-28T19:06:49Z. --- Tested `791c8582` on a physical RTX 5060 Laptop GPU (8 GB) under Bazzite 44.20261011.0, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton `cae8353ed7959c4+`. The locked MSVC release and seven focused tests passed. I reran the existing placement fixtures with a local test-only change to select the physical adapter and require `ID3D12Device13`. The page-pool fixture passed in both directions across two views of an anonymous section, including protection changes and cleanup. The private-placement fixture passed readback and GPU-copy writes at the requested offset. The broader probe passed committed-section reads, writes and remapping with Wine's built-in compiler. Its private-buffer UAV shader step returned `0x80004005`. With the same fixture binary and the native SDK compiler 10.0.28000.2705 it passed all three fixtures, including the UAV write. I also verified three green physical fixtures using Wine's built-in compiler with the existing DXC fallback from [#1489](https://github.com/fxceless/victory-fork/pull/1489) applied to this probe. I also tested the page-pool switch on a private integration of this branch and the already validated Proton compatibility fixes. Both replays used the same binary, Series S settings, checkpoint and initial caches. Only `VICTORY_INPLACE_VIEW` changed from 0 to 1, with the private-placement switch unset. The enabled run created 9 direct placements totaling 44 MiB during startup and had zero live placements by the boat checkpoint. The stable control view was 5.70 rendered FPS (170.1 ms median). The enabled run ended at the desktop-response cutoff during the checkpoint retry, before the equivalent rendered sample. Both scopes cleaned up. This confirms that the page-pool placement can be exercised in the title under Proton. A frame-time improvement remains unverified. Assisted by Codex (GPT-6.2-Sol High).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1517:upstream-pr/1517'
git switch 'upstream-pr/1517'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1517'
git switch 'upstream-pr/1517'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1517'
git switch 'upstream-pr/1517'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1517'
git switch 'main'
git merge --squash 'upstream-pr/1517'
git switch 'main'
git merge --ff-only 'upstream-pr/1517'
git switch 'main'
git merge 'upstream-pr/1517'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!1517
No description provided.