GPU: the host says whether its GPU shares memory with the CPU #2912

Closed
github-bot wants to merge 2 commits from github-bot/gh-2912 into main AGit
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 23:51 UTC · original
0xkn0wh3r3:gpu/host-memory-unified → main · +163 −0 · 3 files · 2 commits · closed without merging

Problem

The console's GPU reads title memory where it is. VIctory keeps host copies of title memory in system memory and refreshes them at every submission (shadow, watch). Nothing on main asks what the host's memory is like:

  • On a unified host (an APU or integrated GPU, Apple silicon under a translation layer) the GPU reaches every placement at the same speed, so the copies only cost CPU time.
  • On a discrete GPU, video memory is far faster than system memory.

The open placement PRs decide without this:

  • #2112 is a plain opt-in switch;
  • #2870 turns GPU upload copies on from GPUUploadHeapSupported alone, so a unified host would still copy.

What this adds (no behaviour change)

crate::unified::detect, at host creation:

  • D3D12_FEATURE_DATA_ARCHITECTURE1: UMA, CacheCoherentUMA;
  • D3D12_OPTIONS16.GPUUploadHeapSupported;
  • the DXGI local and non-local budgets.

That costs about 0.3 ms on an RTX 5070 Ti. The result goes on one log line (host GPU memory: ...) and into the GPU failure text. It is kept on the host (Host::memory) for the placements to gate on.

Changed after triage:

  • The in-place self-test moved to #2945, which acts on it. It now runs only there, once, on unified hosts.
  • The ignored benchmark left the repository; its results are below.

Measurements (synthetic; benchmark no longer in the tree)

Detection:

  • RTX 5070 Ti: its own, the CPU maps part of it (Resizable BAR); budgets 15227 MiB local, 47508 MiB non-local.
  • Ryzen 7900X integrated Radeon: unified with the CPU's, cache-coherent false.
  • WARP: unified with the CPU's, cache-coherent true.

The AMD APU reports CacheCoherentUMA = false, yet write-back memory was coherent both ways there. So a mode should key on UMA.

GPU access, 256 MiB buffers, GB/s (GPU timestamps):

pattern system memory (today's copies) title memory in place GPU upload heap video memory
5070 Ti linear read 16 B 26.8 26.5 858 859
5070 Ti scattered 64 B lines 2.2 2.2 689 691
5070 Ti scattered writes 0.9 0.9 11.4 10.5
5070 Ti hot 1 MiB, random 4 B 1.8 1.3 231 233
integrated Radeon, every pattern same within noise same same same
  • GPU copies between video memory and system or in-place memory (5070 Ti): 28.7 GB/s, the same for 512 separate 64 KiB pages.
  • CPU reads of upload and GPU upload heaps: 0.04 GB/s (5070 Ti) and 0.22 GB/s (iGPU).

The benchmark's source, as it was, is at cdc50faf: uma_bench.rs.

Tests

  • unified::tests::warp_is_unified.
  • unified::tests::the_host_device_is_described.
  • Clippy (both configurations) is clean.
  • cargo test -p victory-gpu --release --lib: two failures, descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views. They fail the same way on clean main on this machine.
  • #2945 (draft): title memory in place by default on unified hosts, using this and the self-test.
  • #2921: release of title memory held in place.
  • #2929: ranks host copies by what video memory would save.
  • #2494: probes similar capabilities inside an RFC prototype.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 23:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912) `0xkn0wh3r3:gpu/host-memory-unified` → `main` · +163 −0 · 3 files · 2 commits · closed without merging ### Problem The console's GPU reads title memory where it is. VIctory keeps host copies of title memory in system memory and refreshes them at every submission (`shadow`, `watch`). Nothing on main asks what the host's memory is like: - On a unified host (an APU or integrated GPU, Apple silicon under a translation layer) the GPU reaches every placement at the same speed, so the copies only cost CPU time. - On a discrete GPU, video memory is far faster than system memory. The open placement PRs decide without this: - #2112 is a plain opt-in switch; - #2870 turns GPU upload copies on from `GPUUploadHeapSupported` alone, so a unified host would still copy. ### What this adds (no behaviour change) `crate::unified::detect`, at host creation: - `D3D12_FEATURE_DATA_ARCHITECTURE1`: `UMA`, `CacheCoherentUMA`; - `D3D12_OPTIONS16.GPUUploadHeapSupported`; - the DXGI local and non-local budgets. That costs about 0.3 ms on an RTX 5070 Ti. The result goes on one log line (`host GPU memory: ...`) and into the GPU failure text. It is kept on the host (`Host::memory`) for the placements to gate on. **Changed after triage:** - The in-place self-test moved to #2945, which acts on it. It now runs only there, once, on unified hosts. - The ignored benchmark left the repository; its results are below. ### Measurements (synthetic; benchmark no longer in the tree) Detection: - RTX 5070 Ti: `its own, the CPU maps part of it (Resizable BAR); budgets 15227 MiB local, 47508 MiB non-local`. - Ryzen 7900X integrated Radeon: `unified with the CPU's, cache-coherent false`. - WARP: `unified with the CPU's, cache-coherent true`. The AMD APU reports `CacheCoherentUMA = false`, yet write-back memory was coherent both ways there. So a mode should key on `UMA`. GPU access, 256 MiB buffers, GB/s (GPU timestamps): | pattern | system memory (today's copies) | title memory in place | GPU upload heap | video memory | |---|---|---|---|---| | 5070 Ti linear read 16 B | 26.8 | 26.5 | 858 | 859 | | 5070 Ti scattered 64 B lines | 2.2 | 2.2 | 689 | 691 | | 5070 Ti scattered writes | 0.9 | 0.9 | 11.4 | 10.5 | | 5070 Ti hot 1 MiB, random 4 B | 1.8 | 1.3 | 231 | 233 | | integrated Radeon, every pattern | same within noise | same | same | same | - GPU copies between video memory and system or in-place memory (5070 Ti): 28.7 GB/s, the same for 512 separate 64 KiB pages. - CPU reads of upload and GPU upload heaps: 0.04 GB/s (5070 Ti) and 0.22 GB/s (iGPU). The benchmark's source, as it was, is at [cdc50faf: uma_bench.rs](https://github.com/0xkn0wh3r3/VIctory/blob/cdc50faf/crates/victory-gpu/src/uma_bench.rs). ### Tests - `unified::tests::warp_is_unified`. - `unified::tests::the_host_device_is_described`. - Clippy (both configurations) is clean. - `cargo test -p victory-gpu --release --lib`: two failures, `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`. They fail the same way on clean main on this machine. ### Related - #2945 (draft): title memory in place by default on unified hosts, using this and the self-test. - #2921: release of title memory held in place. - #2929: ranks host copies by what video memory would save. - #2494: probes similar capabilities inside an RFC prototype.
At host creation, `unified::detect` reads ARCHITECTURE1 (UMA, cache-coherent
UMA), OPTIONS16 (GPU upload heaps) and the DXGI budgets. It also runs a
self-test: a write-watched block, allocated as the title's pools are, is
opened with OpenExistingHeapFromAddress1, and a copy queue copies its first
half out and other bytes into its second half. The answer is what the GPU
did: a layer can report the method and still not share the memory.

The result goes on one log line and into the GPU failure text. Nothing
changes behaviour on it yet; later placements (in place on unified hosts,
video memory for hot buffers on discrete ones) can gate on it.

`uma_bench` (ignored) probes every adapter and WARP: what opening title
memory implies (protect, unmap and decommit fail with error 87 while a heap
lives; a read-only page fails the open; write watch sees CPU writes, not the
GPU's). It times GPU access per placement and pattern, and GPU copies
between video memory and the rest.
Triage: detection ran a self-test (a heap opened over a write-watched block,
copies on a queue of its own: 3-20 ms) at every host creation, only to log
its answer.

What stays here, for the log line and the GPU failure text:
- ARCHITECTURE1 (UMA, cache-coherent UMA);
- OPTIONS16 (GPU upload heaps);
- the DXGI budgets.
That is about 0.3 ms on an RTX 5070 Ti.

The self-test moves to the change that acts on it (#2945). The ignored
benchmark (uma_bench.rs) leaves the repository; its results are in the PRs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:20 +00:00
github-bot closed this pull request 2026-11-26 08:07:35 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 23:52 UTC · original · reviewed

Scoped review: detection reports what the GPU did (self_test opens title memory as a heap and checks both-direction visibility) rather than trusting reported feature bits — exactly right for translation layers that claim UMA without external-memory-host. Behaviour-neutral (logged once at creation + crash text), and the captured implications (no protect/unmap while the heap lives, write-watch can't see GPU writes, ~0.2-0.75 ms/MiB open cost) are the constraints any future in-place design has to respect. The uma_bench patterns are synthetic shaders, no game data. LGTM.

**@⁠kotekompotek** on GitHub · 2026-11-25 23:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912#pullrequestreview-6066644567) · **reviewed** Scoped review: detection reports what the GPU *did* (self_test opens title memory as a heap and checks both-direction visibility) rather than trusting reported feature bits — exactly right for translation layers that claim UMA without external-memory-host. Behaviour-neutral (logged once at creation + crash text), and the captured implications (no protect/unmap while the heap lives, write-watch can't see GPU writes, ~0.2-0.75 ms/MiB open cost) are the constraints any future in-place design has to respect. The uma_bench patterns are synthetic shaders, no game data. LGTM.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 23:59 UTC · original · reviewed

Verified head cdc50faf cleanly merged onto origin/main (63bcca43) on Windows 11 x64 across three adapters (discrete NVIDIA GeForce RTX 5090, integrated AMD Radeon RDNA2 iGPU, and D3D12 WARP) with VICTORY_D3D12_DEBUG=1.

Triple-Adapter uma_probe Results (--ignored --nocapture, zero debug-layer errors)

  • NVIDIA GeForce RTX 5090: its own, the CPU maps part of it (Resizable BAR); title memory opens in place; budgets 31419 MiB local, 45969 MiB non-local (asked and tested in 29.48 ms)
  • AMD Radeon(TM) Graphics (iGPU): unified with the CPU's, cache-coherent false; title memory opens in place; budgets 47991 MiB local, 0 MiB non-local (asked and tested in 5.24 ms)
  • Microsoft Basic Render Driver (WARP): unified with the CPU's, cache-coherent true; title memory opens in place; budgets 45969 MiB local, 0 MiB non-local (asked and tested in 1.91 ms)

Code & Lifetime Review

  • D3D12_FEATURE_ARCHITECTURE1 (UMA / CacheCoherentUMA), D3D12_FEATURE_D3D12_OPTIONS16 (GPUUploadHeapSupported), and the OpenExistingHeapFromAddress1 bidirectional visibility self-test are logging/diagnostic-only and preserve all existing paths.
  • Resource lifetime order in self_test drops opened and heap before Block::drop frees the MEM_WRITE_WATCH allocation.

Local Verification (--features diagnostics, VICTORY_D3D12_DEBUG=1)

  • RTX 5090 & WARP: unified::tests + host::tests + shadow::tests + draw::tests (skipping pre-existing 1M descriptor cap baseline on RTX 5090) 48/48 passed on both adapters.
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --features diagnostics) & cargo xtask policy (193 files ok): clean.

Looks clean and ready to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 23:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912#pullrequestreview-6066691990) · **reviewed** Verified head `cdc50faf` cleanly merged onto `origin/main` (`63bcca43`) on Windows 11 x64 across **three adapters** (discrete NVIDIA GeForce RTX 5090, integrated AMD Radeon RDNA2 iGPU, and D3D12 WARP) with `VICTORY_D3D12_DEBUG=1`. ### Triple-Adapter `uma_probe` Results (`--ignored --nocapture`, zero debug-layer errors) - **NVIDIA GeForce RTX 5090**: `its own, the CPU maps part of it (Resizable BAR); title memory opens in place; budgets 31419 MiB local, 45969 MiB non-local (asked and tested in 29.48 ms)` - **AMD Radeon(TM) Graphics (iGPU)**: `unified with the CPU's, cache-coherent false; title memory opens in place; budgets 47991 MiB local, 0 MiB non-local (asked and tested in 5.24 ms)` - **Microsoft Basic Render Driver (WARP)**: `unified with the CPU's, cache-coherent true; title memory opens in place; budgets 45969 MiB local, 0 MiB non-local (asked and tested in 1.91 ms)` ### Code & Lifetime Review - `D3D12_FEATURE_ARCHITECTURE1` (`UMA` / `CacheCoherentUMA`), `D3D12_FEATURE_D3D12_OPTIONS16` (`GPUUploadHeapSupported`), and the `OpenExistingHeapFromAddress1` bidirectional visibility self-test are logging/diagnostic-only and preserve all existing paths. - Resource lifetime order in `self_test` drops `opened` and `heap` before `Block::drop` frees the `MEM_WRITE_WATCH` allocation. ### Local Verification (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`) - **RTX 5090 & WARP**: `unified::tests` + `host::tests` + `shadow::tests` + `draw::tests` (skipping pre-existing 1M descriptor cap baseline on RTX 5090) **48/48 passed** on both adapters. - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--features diagnostics`) & `cargo xtask policy` (`193 files ok`): clean. Looks clean and ready to merge.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 02:21 UTC · original · edited 2026-11-26 03:24 UTC

Automated triage for the maintainers.

Verdict: merge candidate. Thanks, this is what the last review asked for. At cdf12e9, unified::detect makes two CheckFeatureSupport queries (ARCHITECTURE1, OPTIONS16) and the DXGI budget query, and nothing more. The result goes on one log line at host.rs create and into the fail text. self_test and uma_bench.rs are gone (the self-test now lives in #2945), and no behaviour depends on the result.

Two small nits:

  • The doc on Host::memory still says "and whether title memory opens in place", which this PR no longer does.
  • The second paragraph of the unified.rs module doc is rationale that belongs in #2945 rather than the code.

CI: passing (check). Merges cleanly.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 02:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912#issuecomment-7180722375) · edited 2026-11-26 03:24 UTC <!-- victory-triage v1 head=cdf12e9ebb53c2958a58746ce1f889f46e0d7b35 verdict=merge-candidate at=2026-11-26T03:24:47Z --> Automated triage for the maintainers. **Verdict: merge candidate.** Thanks, this is what the last review asked for. At `cdf12e9`, `unified::detect` makes two `CheckFeatureSupport` queries (`ARCHITECTURE1`, `OPTIONS16`) and the DXGI budget query, and nothing more. The result goes on one log line at `host.rs` `create` and into the `fail` text. `self_test` and `uma_bench.rs` are gone (the self-test now lives in #2945), and no behaviour depends on the result. Two small nits: - The doc on `Host::memory` still says "and whether title memory opens in place", which this PR no longer does. - The second paragraph of the `unified.rs` module doc is rationale that belongs in #2945 rather than the code. CI: passing (`check`). Merges cleanly. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 02:30 UTC · original

Thanks. Addressed in cdf12e9e:

  • What runs at host creation: this PR now keeps only the feature and budget queries (about 0.3 ms on an RTX 5070 Ti), for the log and the GPU failure text. Nothing else runs there.
  • self_test: moved to draft #2945, where it decides the in-place default. There it runs once, lazily, and only on hosts that report UMA.
  • uma_bench.rs: removed from the tree. The description summarises its results and links its source at cdc50faf.

Tests: on the 5070 Ti, only the two heap-cap failures that also happen on main. On WARP, which reports unified memory, 268 of 269 pass; the one failure is the flaky frame-timing test. victory-hle passes 154, and clippy is clean with and without diagnostics.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 02:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912#issuecomment-7180862744) Thanks. Addressed in cdf12e9e: - **What runs at host creation:** this PR now keeps only the feature and budget queries (about 0.3 ms on an RTX 5070 Ti), for the log and the GPU failure text. Nothing else runs there. - **`self_test`:** moved to draft #2945, where it decides the in-place default. There it runs once, lazily, and only on hosts that report UMA. - **`uma_bench.rs`:** removed from the tree. The description summarises its results and links its source at cdc50faf. Tests: on the 5070 Ti, only the two heap-cap failures that also happen on `main`. On WARP, which reports unified memory, 268 of 269 pass; the one failure is the flaky frame-timing test. `victory-hle` passes 154, and clippy is clean with and without `diagnostics`.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 03:34 UTC · original · approved these changes

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • cargo test -p victory-gpu --lib unified::tests: 2 passed, 0 failed (warp_is_unified and the_host_device_is_described on RTX 5090 + WARP).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 03:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912#pullrequestreview-6068200532) · **approved these changes** Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP): - `cargo test -p victory-gpu --lib unified::tests`: **2 passed, 0 failed** (`warp_is_unified` and `the_host_device_is_described` on RTX 5090 + WARP). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 08:05 UTC · original

Replaced by #3102, which combines this with the rest of the host-memory placement work in one PR, with measurements on a discrete and an integrated GPU. Closing here.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 08:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2912#issuecomment-7186177929) Replaced by #3102, which combines this with the rest of the host-memory placement work in one PR, with measurements on a discrete and an integrated GPU. Closing here.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/Marvisak--VIctory!2912
No description provided.