Skip to content

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

Closed
0xkn0wh3r3 wants to merge 2 commits into
Marvisak:mainfrom
0xkn0wh3r3:gpu/host-memory-unified
Closed

0xkn0wh3r3 wants to merge 2 commits into
Marvisak:mainfrom
0xkn0wh3r3:gpu/host-memory-unified

Conversation

@0xkn0wh3r3

@0xkn0wh3r3 0xkn0wh3r3 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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:

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:

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.

Related

…ecks that title memory opens in place

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.

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Marvisak commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

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:

CI: passing (check). Merges cleanly.


Generated by Claude Code

… the benchmark go

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 (Marvisak#2945). The ignored
benchmark (uma_bench.rs) leaves the repository; its results are in the PRs.
0xkn0wh3r3 added a commit to 0xkn0wh3r3/VIctory that referenced this pull request Nov 26, 2026
…t decides the default

Marvisak#2912's triage moved the self-test here, to the change that acts on it.
crate::unified::self_test is unchanged: a write-watched block opened with
OpenExistingHeapFromAddress1, a copy queue's round trip, both directions
checked.

It no longer runs at host creation. VICTORY_IN_PLACE unset asks it the
first time, and only where the host reports unified memory. A failure keeps
the copies and is logged with its reason. Discrete hosts never run it.
@0xkn0wh3r3 0xkn0wh3r3 changed the title GPU: the host says whether its GPU shares memory with the CPU, and checks that title memory opens in place GPU: the host says whether its GPU shares memory with the CPU Nov 26, 2026
@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks. Addressed in cdf12e9:

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 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

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 0xkn0wh3r3 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants