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

Closed
0xkn0wh3r3 wants to merge 2 commits from upstream-pr/2912 into main
0xkn0wh3r3 commented 2026-11-25 23:51:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T23:51:15Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6616191352 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T23:51:15Z. --- ### 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.
kotekompotek commented 2026-11-26 00:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:52:53Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066644567 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912#pullrequestreview-6066644567). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T23:52:53Z. **Review:** COMMENTED --- 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.
fuzeofficlal commented 2026-11-26 00:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:59:22Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066691990 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912#pullrequestreview-6066691990). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:59:22Z. **Review:** COMMENTED --- 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.
upstream-sync changed title from [PR #2912] GPU: the host says whether its GPU shares memory with the CPU, and checks that title memory opens in place to [PR #2912] GPU: the host says whether its GPU shares memory with the CPU 2026-11-26 03:04:30 +00:00
Marvisak commented 2026-11-26 03:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:21:14Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180722375 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912#issuecomment-7180722375). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:21:14Z. --- <!-- 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)_
0xkn0wh3r3 commented 2026-11-26 03:05:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T02:30:10Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180862744 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912#issuecomment-7180862744). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T02:30:10Z. --- 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`.
Dukestar69 commented 2026-11-26 04:05:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:34:20Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068200532 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912#pullrequestreview-6068200532). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T03:34:20Z. **Review:** APPROVED --- 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).
upstream-sync closed this pull request 2026-11-26 09:05:25 +00:00
0xkn0wh3r3 commented 2026-11-26 09:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T08:05:40Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7186177929 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2912#issuecomment-7186177929). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T08:05:40Z. --- 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

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
Marvisak/VIctory!2910
No description provided.