Repository navigation
GPU: the Xbox's shared CPU/GPU memory on PC GPUs: simulated in video memory on discrete cards, title memory itself on unified ones - #3102
Conversation
Host copies of title buffers are in system memory (`Host::shared_buffer`: a custom heap, write-back, memory pool L0) so that the CPU can refresh them and read back what shaders write. Every shader read of a copy then crosses PCIe. On an RTX 5070 Ti a shader reads 256 MiB from such a copy at 22.9 GB/s, and from video memory at 713 GB/s: the console's memory is one pool, and the GPU reads it at video memory speed. A buffer the title makes without unordered access is one shaders only read: nothing reads its copy back, and the CPU only writes it (refreshes). Its copy can be in video memory the CPU writes through the PCI BAR: a GPU upload heap (`D3D12_HEAP_TYPE_GPU_UPLOAD`, `D3D12_OPTIONS16`, on hosts with resizable BAR). With `VICTORY_GPU_UPLOAD=1`: - `shadow::register_read_only` registers such buffers (`resource.rs`, from the title's `ALLOW_UNORDERED_ACCESS` flag), and `shadow::find` makes their copies with `Host::gpu_upload_buffer`; - copies past 2 GiB of video memory, and every copy on hosts without GPU upload heaps, stay in system memory, as before; - shaders that still write such a copy (through a view of the same memory under another resource) get it right, slowly: the copy-back reads video memory at ~50 MB/s; a warning names the first one. Measured on an RTX 5070 Ti (driver 621.24, Ryzen 9 7900X), 256 MiB, through `shadow::find` (`reading_copies_in_video_and_system_memory`): | copy | shader reads | refresh writes (first, every page) | |---|---|---| | writable buffer's (system memory) | 11.74 ms, 22.9 GB/s | 42.1 ms | | read-only buffer's (GPU upload heap) | 0.38 ms, 713 GB/s | 32.8 ms | Off by default: how much of a world frame's GPU time this is depends on which buffers the title makes without unordered access, which needs a run of the title to measure. `read_only_buffers_get_their_copies_in_video_memory` (in a child process with the switch on) checks that a read-only buffer's copy is in a GPU upload heap, that the GPU reads what a refresh wrote there, and that a writable buffer's copy stays in system memory. The victory-gpu tests give the same results with the switch on and off.
The 2 GiB allowance for host copies in GPU upload heaps counted every copy made over the whole run and never took any back. After enough read- only buffers came and went (64 of 32 MiB on an RTX 3050 Laptop, with only one alive at a time), every later copy went to system memory for the rest of the run. A copy's bytes now leave the count when D3D12 destroys its buffer, through the buffer's destruction notifier. That is when the last reference goes (the copy's, and the clones lists and descriptor tables hold), not when the copy drops. A host without the notifier keeps copies in system memory instead of charging them for good. Test: upload_budget_is_given_back_when_copies_go. It makes 20 copies of 128 MiB one after another (2.5 GiB, past the budget). Each one is in a GPU upload heap, stays charged while a clone of its buffer is held after the copy dropped, and is given back once the clone goes. With the callback doing nothing, it fails in the first round.
…pt-in) Copies shaders write stayed in system memory, because the CPU reads them back (copy-back compares what shaders wrote; snapshots read them before a submission) and reading a GPU upload heap from the CPU runs at ~50 MB/s. Shaders reading and writing system memory are slower still than reading it: on an RTX 5070 Ti a shader reading and writing 256 MiB of a copy takes 212 ms in system memory and 1.25 ms in video memory. With `VICTORY_GPU_UPLOAD_WRITES=1` (and `VICTORY_GPU_UPLOAD=1`) such a copy is in a GPU upload heap, which shaders use, mirrored in system memory (`Shadow::data`), where the CPU reads and writes as before: - every CPU write into the copy (refreshes, copy-back taking the title's bytes) goes on into video memory (`Shadow::push`); - before the CPU reads what shaders may have written, the GPU copies it into the mirror (`shadow::pull`, `Host::copy_now`: one list and one wait per call): the marked pages in `copy_back_marks`, the declared ranges before `copy_back`/`keep_writes` in `Host::execute`, the title memory pages in `memory`'s copy-back; - shaders' writes outside every declared range and marked page reach the copy only, as they did; the mirror has them once a later range brings them (a shortcut, noted at `pull`). Copies of loose title memory and of single views (`loose`, `exact`) stay in system memory. Tests (each in a child process with the switches on): `written_buffers_copies_are_in_video_memory_with_a_mirror` (placement; the GPU sees refreshes), `gpu_writes_to_mirrored_copies_reach_title_memory` (a GPU write into the copy in a declared range, then in a marked page, with the title writing the same page meanwhile, through `Host::execute`: title memory gets both), `withheld_writes_stay_in_the_copy_and_its_mirror`. Without `pull` the second and third fail; without `push` the first two do; without the marked pages' pull the marked case does. The victory-gpu tests give the same results with the switches off, on for read-only copies, and on for both. Benchmark: `written_copies_in_video_and_system_memory`.
A copy in video memory (VICTORY_GPU_UPLOAD_WRITES=1) took every refresh twice: into its system-memory mirror, then on into video memory. Now a refresh writes video memory only and marks the 64 KiB pages it touched as stale in the mirror. Before the CPU reads the mirror, its stale pages come back from video memory in one GPU copy (`freshen`, `bring_back`). A refresh over a page whose bytes from before the title's first write are saved writes the mirror too, so that those bytes take it (`Tracked::saves`, `Tracked::refreshed`). A submission's snapshot ranges are brought up to date up front, in one copy (`snapshots_ahead`), and refreshes there write the mirror too until the copy-backs, so no snapshot waits for the GPU. The declared-range pull now covers only those ranges: nothing reads the mirror for a marked range, whose pages `copy_back_marks` pulls. Copy-back reads the mirror only where it compares. Synthetic world frame, marked path, median ms: copies in system memory 80.7, mirror always written 114.6, now 69.0. docs/gpu-memory.md explains how copies bridge the console's unified memory and the PC's two pools, with the measurements.
…hare of the VRAM budget When the process uses more video memory than DXGI's budget, Windows' video memory manager demotes some of its allocations to system memory. VIctory set no residency priorities, so the manager chose among all of them alike, render targets and depth buffers drawn every frame included. Frames then take seconds. The host copies in GPU upload heaps also had a fixed 2 GiB allowance (`UPLOAD_BUDGET`), whatever the card and whatever the title's own textures already took. Residency priorities (`host::keep_resident`, `host::Residency`), set where the allocations are made: - `HIGH`: host textures with the render target, depth stencil or unordered access flag (`make_texture`: the GPU writes them every frame, and they hold the only copy of what it wrote), view heaps' stride, mark and address tables, the views' written-pages bitmap, list scratch chunks, and host copies in GPU upload heaps. Not `MAXIMUM`, which the system keeps even past the budget at the cost of other processes. - `NORMAL` (no call: every allocation starts there): textures uploaded from title memory (`texture::title_written`). They are streamed, each read by some frames, and sampling one from system memory is slower without stalling the frame. Not `LOW`, which would demote them before allocations with no priority set (depth twins, upload staging). - None for descriptor heaps: on an RTX 5070 Ti (driver 621.24) a priority on a shader-visible descriptor heap removed the device at the next submission (every later GPU test failed with 0x887A0005). The budget (`crate::budget`): `QueryVideoMemoryInfo` on the host device's adapter, local and non-local segment groups, read at most every 250 ms and again as soon as the system signals a change (`RegisterVideoMemoryBudgetChangeNotificationEvent`). Bytes a pool takes between readings (`Budget::charge`) count as used until the next reading. `Budget::limit` answers how many bytes a pool may hold now: its part of what the rest of the process leaves of the local budget, up to a ceiling, the ceiling alone without a reading. Copies in GPU upload heaps (`UPLOAD_POOL`) take half of what the rest of the process leaves, at most 2 GiB (the old fixed size) or a quarter of the budget where that is more. A copy that does not fit stays in system memory, as before. On an 8 GB card with 5 GB used by the rest, that is 1.25 GB instead of 2 GiB; on a 16 GB card with 4 GB used, 3.75 GB. `VICTORY_GPU_UPLOAD` and `VICTORY_GPU_UPLOAD_WRITES` are unchanged. The first time local use passes nine tenths of the budget, a warning names what VIctory knows takes it: host textures (and those lists used), host copies of title memory (and those in GPU upload heaps), and the non-local use and budget. It is checked with each frame-rate line, whether or not a pool asks. Tests: - budget: the limit shrinks as others' use rises (to nothing at the budget) and not with the pool's own bytes; the ceiling grows only on large budgets; readings are cached until old or signalled, with charges counted in between; nine tenths is logged once; the host adapter answers. - upload_copies_take_their_share_of_the_budget: the upload pool's admission under a fake budget. - textures_the_gpu_writes_are_kept_resident_first: the level chosen from texture flags. The device has no getter for priorities, so the helper records what it was asked per object in test builds, and host_textures_are_kept_resident_by_use (make_texture), list_scratch_chunks_are_kept_resident, view_heap_tables_are_kept_resident, the_written_pages_bitmap_is_kept_resident and upload_budget_is_given_back_when_copies_go check the creation paths. docs/gpu-memory.md: a section on the budget and residency; the further step "size the budget from DXGI's video memory budget" is done.
A resource placed in a heap takes its heap's residency: asked of a placed texture, SetResidencyPriority removed the device at the next submission, found merging this with host heaps shared by placed render targets (Marvisak#2226), whose heaps take the priority instead. keep_resident says so, and make_texture gives a priority to the textures it commits only: those it places in a heap of textures (`crate::placement`, fed from title memory) keep their heap's, the normal one.
…e the host has GPU upload heaps A slow host submission of a few hundred compute dispatches over title buffers spends most of its GPU time on shaders reading and writing the buffers' host copies, which were in system memory unless VICTORY_GPU_UPLOAD (and VICTORY_GPU_UPLOAD_WRITES) said otherwise: every access crossed PCI Express (~23 GB/s against ~720 GB/s for video memory on an RTX 5070 Ti). A benchmark of such a submission, through the copies' real paths (`shadow::find`, `Shadow::refresh`, `Shadow::gpu_writes`, `HostList`, `Host::execute`): `shadow::bench::compute_heavy_submissions_by_copy_placement` (ignored; run in release). 200 dispatches in 8 lists over four 64 MiB read-only buffers and two 32 MiB written ones; each dispatch reads 4 MiB, reads and writes 1 MiB and reads 256 KiB more, with write marks (as translated shaders mark their stores) or snapshots, and with the title writing 16 MiB between submissions or not. Each placement runs in a child process of its own (the switches are read once per process), and all must leave title memory the same. Medians, ms per submission (total = prepare + GPU + copy-back): | copies | writes found by | total | GPU | copy-back | |---|---|---|---|---| | system memory | marks | 59.7 | 44.0 | 15.7 | | read-only ones in video memory | marks | 31.0 | 15.7 | 15.1 | | all in video memory | marks | 31.7 | 12.0 | 19.6 | | system memory | snapshots | 73.5 | 43.4 | 17.8 | | read-only ones in video memory | snapshots | 43.3 | 12.9 | 18.3 | | all in video memory | snapshots | 35.9 | 2.1 | 21.8 | Read-only copies in video memory halve the submission; refreshes cost the same through the BAR as into system memory (2 ms for the title's 16 MiB). Written copies in video memory too add 4 ms of copy-back (bringing written pages back to their mirrors) and save as much GPU time or more: even with marks (31.7 and 32.3 ms against 31.0 and 32.9 with the title writing, within the runs' spread), 17% faster with snapshots, and a quarter (marks) to five sixths (snapshots) less GPU time. Both are now on by default where the host reports GPUUploadHeapSupported (`host::upload_placement`): VICTORY_GPU_UPLOAD=0 keeps every copy in system memory, VICTORY_GPU_UPLOAD_WRITES=0 those of written buffers (`switch::on_unless_off`). Hosts without the heaps, and copies past their share of the video memory budget, stay in system memory as before. With all copies in video memory, marking takes about 9 of the 11-12 GPU ms: the written-pages bitmap is in system memory. docs/gpu-memory.md lists that as a further step, with the switches' defaults and the measurements; the README names the opt-outs. Tests: `host::tests::copies_are_in_video_memory_by_default_where_the_host_can` (the placement from host support and the switches), `switch::tests::a_switch_on_by_default_is_off_at_zero_only`. The tests pass with the new default and with VICTORY_GPU_UPLOAD=0 or VICTORY_GPU_UPLOAD_WRITES=0 set (those that need the switches on set them in a child process already).
…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.
…e runtime changes it A GPU heap opened over title memory (OpenExistingHeapFromAddress1, as Marvisak#2112 does) locks its pages. While it lives, VirtualProtect, UnmapViewOfFile2 and VirtualFree fail with ERROR_INVALID_PARAMETER, on NVIDIA, AMD and WARP alike. The title frees and remaps such memory. victory_gpu::pinned keeps a registry of held ranges, each with how to let it go. title_memory_change(at, len, change) releases every holder overlapping the range, then runs the host call. The system sometimes unlocks released pages late (RTX 5070 Ti: 32 of 40 within 0.01 ms, the slowest 5.9 ms), so after a release a call refused with that error is tried again for up to 100 ms. The changes go through it: - the title's VirtualFree, VirtualFreeEx, VirtualProtect, VirtualProtectEx, UnmapViewOfFile, UnmapViewOfFileEx and UnmapViewOfFile2 (new HLE module memoryapi; everything else in those DLLs stays the host's); - xmem's unmapping of physical pages; - XMemFreeDefault's release of 32-bit memory. Nothing registers a pin on main yet, so the cost is one atomic load per call. Holders (Marvisak#2112, Marvisak#2734) register when they open a heap.
…o memory would save Host copies of title memory live in system memory, so every shader access crosses the bus on a discrete GPU. To choose what belongs in video memory, victory_gpu::heat counts per copy (title start, length), since the last frame-rate line: - GPU time: with per-command timing (VICTORY_GPU_TIMING and VICTORY_D3D12_DRED), each command's time split over the copies it binds, by bytes. Commands reading heap views or title memory by address are counted as rows of their own. - bytes copied in by refreshes; - bytes copied back. The line lists the copies by estimated gain: GPU time x (1 - 1/20), less moving the changed bytes at 28.7 GB/s. Both constants come from synthetic measurements on an RTX 5070 Ti (Marvisak#2912). It ranks and moves nothing. Diagnostics builds only. HostList::slowest now builds on a new command_times, which gives each command's time in order.
…waits for it Review (fuzeofficlal): the pin count dropped before the release callbacks ran. A second thread changing an overlapping range could then see nothing held, call VirtualFree or VirtualProtect while the first was still dropping the heap, and get ERROR_INVALID_PARAMETER without a retry. Released pins now stay counted, as releasing, until their callback returns. A change on another thread that overlaps one waits on a condition variable for it, then gets the late-unlock retry. A release running on the caller's own thread is not waited for, so a callback that changes memory itself does not deadlock. The docs also say never to change title memory through here from the guard handler or under watch's lock: a release may wait for a submission. Test: a change on a second thread waits for a 50 ms release running on the first.
… 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.
upload_fits adds the new copy's size to what the pool holds with saturating_add.
…VIDIA only Elsewhere their mirrors cost more CPU time than the GPU saves reading video memory, so VICTORY_GPU_UPLOAD_WRITES unset keeps them in system memory unless the adapter is NVIDIA's; 1 puts them in video memory on any GPU and 0 keeps them out on any. Read-only copies keep their default. The placement log names the adapter's vendor.
… CPU On a unified host every placement reads at the same speed, so a host copy buys no GPU time and costs its refreshes, snapshots and copy-backs. There, title buffers of 64 KiB or more get no copy: crate::in_place opens the buffer's own pages as a heap (OpenExistingHeapFromAddress1) and places one buffer at its start. Shadow gains an in-place kind whose data is title memory: refresh, snapshot and copy-back do nothing. - On by default where crate::unified::detect reports UMA and the in-place self-test (moved here from the detection change) passes; VICTORY_IN_PLACE =1 everywhere the host can open heaps, =0 off. Off in tests unless asked. - Each heap is pinned (crate::pinned): the title's frees, protections and remaps drop the buffer first. The buffer holds its heap through private data, so the pin lasts as long as anything placed in it. - Withholding (crate::memory::withholding) cannot hold back writes to title memory itself: a buffer a program using title memory writes gets a copy from then on, and that submission's declared range is kept beforehand and put back if withheld. Once a page table is made, buffers shaders may write are copied; buffers made without unordered access stay in place. - Other copies of the same pages cannot guard them under a heap, so they are refreshed at each use and see what the GPU wrote. The placement benchmark gains an in-place row and runs on another GPU of the machine with VICTORY_TEST_ADAPTER (tests only). Integrated Radeon, median of three runs: a 200-dispatch submission takes 40.5-41.1 ms in place against 58.9-71.1 ms with copies in system memory.
docs/gpu-memory.md gains a section on unified hosts: detection, the self-test, the switch, what holding title memory as a heap implies and how each part is handled, and the compute-heavy submission on the Ryzen 9 7900X's integrated Radeon and the RTX 5070 Ti. The README names the switch.
|
A data point for the Mac side, since Apple Silicon is the obvious unified host: through Apple's D3DMetal (CrossOver 26.3, D3DMetal 4.0b3, M5 Max) this path won't turn on, and it can't as written.
What does work there is the reverse direction: let D3DMetal allocate a mapped write-back buffer, then use So if |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):
cargo test -p victory-gpu shadow::tests -- --test-threads=1(RTX 5090 & WARP): 24 passed, 0 failed on both (including all new video-memory mirror and in-place tests).cargo test -p victory-gpu draw::tests -- --test-threads=1(RTX 5090): 20 passed, 0 failed.cargo test -p victory-hle memoryapi&xmem: all tests passed.cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 199 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
…ed again On a translation layer such as D3DMetal, each new buffer paid a failing call before falling back to its copy: - GPU upload buffers: a host whose resources have no destruction callback had an upload buffer made and dropped for every read-only copy. The first failure now keeps copies in system memory. - In place: a host without ID3D12Device13, or returning E_NOTIMPL, is not asked again. One that refuses 16 ranges in a row and never opened one (D3DMetal returns E_FAIL) is not asked again either. A host that opened any range keeps being asked, since single ranges can be refused for their own reasons.
|
Automated triage for the maintainers. Needs work, and needs the maintainer's decision. This merges cleanly, but it is 5,425 added lines in 20 files, folding in eight earlier PRs, and some of it is beyond what triage can pass:
CI ( Generated by Claude Code |
…pies are Copies of the 4 MiB windows of title memory no buffer holds (shadow::loose) were always in system memory, so shaders read them across the bus. They are now placed as written buffers' copies (shaders may write any of it): in video memory with a mirror where the host puts those there, else in system memory. find and loose share the placement (copy_buffer). The placement benchmark gains VICTORY_TEST_BENCH_LOOSE=1, which makes its title memory no buffer's. RTX 5070 Ti, median of three runs: a submission takes 30.6-44.4 ms with the windows in video memory against 66.3-103.1 ms in system memory, and title memory ends up the same in both.
Thanks for pulling #2120, #2130, #2222 and the rest into one PR. The lazy mirror and the in-place path for unified hosts are nice, and keeping read-only copies in a single buffer saves the RAM that #2993 spends. I read #3102 against #2993, which covers the same ground, and wrote synthetic tests for the places where the two differ. Below are only the findings those tests reproduce on #3102's own code, at How the tests run. All of them are in one file,
Command: 1. A failed bring-back loses a marked shader write on every side, and can write stale mirror bytes into title memoryWhere:
What goes wrong. When the copy that brings the shaders' writes back doesn't run:
Tests:
Each test runs one submission. Its shaders write OutputHow #2993 handles it (d2c20e2, from fuzeofficlal's review there):
You're welcome to take any of it. For a lazy mirror, the smallest change would be to clear the stale bits only after 2. An old unmarked GPU write reaches title memory late, over a title writeWhere:
What goes wrong. An earlier shader writes a byte through a view no list declares or marks, as a shader without write marks does. The byte lands in video memory only and sets no stale bit. Later, the title writes that byte while a submission declares the page unmarked and its shader writes another byte there. The snapshot comes from the mirror, which lacks the old byte. The pull after the submission brings the old byte in, so the merge takes it for this submission's write and puts it over the title's byte. On main, and on #3102 with Tests:
OutputHow #2993 handles it (477c6c6): 3. With
|
|
Follow-up: I re-ran the tests from my earlier comment on the new head, The tests are rebased onto it at
The new cases come from the loose windows: until Output at aab0007The The title was not used in these tests. AI-assisted |
Goal: give titles the Xbox Series' shared memory model on a PC whose GPU has its own video memory.
On the console, the CPU and GPU share one pool of memory. A title builds vertex data, constants and command data at an address, hands the GPU that address, and reads back what shaders wrote at that same address, with nothing copied. Titles are written around that.
A PC with a discrete GPU has two pools: system memory next to the CPU, and video memory on the card, joined by PCI Express. Each processor is fast in its own pool and slow in the other: on an RTX 5070 Ti, the GPU reads system memory at ~23 GB/s and video memory at ~720 GB/s.
This PR simulates the console's single pool on such a GPU:
Where the host really has one pool (an APU or integrated GPU), no simulation is needed: the GPU uses title memory itself, exactly as on the console.
Everything here is my own work: new code, plus my open PRs, which this replaces (#2120, #2130, #2222, #2870, #2912, #2921, #2929, #2945). It depends on no one else's PR.
How the shared pool is simulated
Why simulate instead of sharing literally on a discrete GPU? The GPU can read title memory itself across the bus (
VICTORY_IN_PLACE=1). Measured, that takes 43.7 ms per submission, against 29.7–36.7 ms for the simulated pool in video memory: shaders reading across PCI Express cost more than keeping the image coherent. So literal sharing is only the default where the pool really is shared.What each host gets by default
No environment variable is needed. The switches only override.
The startup log names the outcome:
host GPU memory: ..., plus a line when in place turns on or is refused.Overrides:
VICTORY_GPU_UPLOAD=0: every copy in system memory.VICTORY_GPU_UPLOAD_WRITES=0|1: written buffers' copies in system memory, or in video memory on any GPU.VICTORY_IN_PLACE=0|1: in place off, or on wherever the GPU can open title memory as a heap.The diagnostics ranking (from #2929) needs a
--features diagnosticsbuild plusVICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1.Results
Synthetic:
shadow::bench::compute_heavy_submissions_by_copy_placementruns one submission of 200 compute dispatches in 8 lists over 320 MiB of title buffers, through the real copy paths (shadow::find,Shadow::refresh,Shadow::gpu_writes,HostList,Host::execute). Each placement runs in its own process, and the test checks that title memory ends up byte-identical in all of them. Ryzen 9 7900X, Windows 11. Each number is the median of three runs, each the median of 5 submissions, ms per submission.VICTORY_TEST_BENCH_LOOSE=1, 5070 Ti): 30.6-44.4 ms with its 4 MiB windows' copies in video memory, against 66.3-103.1 ms in system memory (−54 to −57%). The GPU's time falls from about 50 ms to 10 (2 with snapshots).VICTORY_IN_PLACE=1: 43.6-43.8 ms. That beats copies in system memory but loses to copies in video memory, so in place stays off on discrete GPUs.docs/gpu-memory.mdhas the full tables, every placement on both GPUs.What changes
Detecting the host (from #2912)
crate::unified::detectruns at host creation:ARCHITECTURE1.UMA/CacheCoherentUMA,GPUUploadHeapSupportedand the DXGI budgets. It costs about 0.3 ms and logs one line (host GPU memory: ...), which also goes into the GPU failure text.Copies in video memory on discrete GPUs (from #2120, #2130, #2222, #2870)
VICTORY_GPU_UPLOAD=0andVICTORY_GPU_UPLOAD_WRITES=0|1override.Title memory in place on unified hosts (new,
crate::in_place)OpenExistingHeapFromAddress1), with one buffer placed at its start.Shadowgains an in-place kind whosedatais title memory itself. Refresh, snapshot and copy-back do nothing for it.unified::self_test. The self-test runs once, only on unified hosts: it has the GPU copy into and out of memory allocated like the title's pools, and checks that both sides see the other's writes. That guards against layers that have the API but hand the GPU new memory, such as vkd3d-proton withoutVK_EXT_external_memory_host.VICTORY_IN_PLACE=1turns it on wherever heaps open;=0turns it off.Freeing memory held in place (from #2921, now with its caller)
VirtualFree,VirtualProtectandUnmapViewOfFile*with error 87.title_memory_change. That releases the buffers held over the range first, then retries for up to 100 ms while lists still holding them are reset.Withholding still works with in place
memory::withholding). A buffer in place cannot withhold anything, so:Diagnostics (from #2929)
VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1). Buffers in place aren't ranked.Limits
shadow::exact, ~2 KB each, in shared buffers) stay in system memory.Tests
shadow::tests::a_title_buffer_in_place_needs_no_copiesthe_title_frees_memory_a_buffer_is_in_place_overa_buffer_in_place_holds_its_heap_and_pinpage_tables_move_written_buffers_to_copieshost::withholding::a_program_using_title_memory_moves_a_buffer_in_place_to_a_copyin_place::tests::the_switch_decides_and_unset_follows_the_hostin_place::tests::a_host_that_never_opens_heaps_is_not_asked_againshadow::tests::loose_memory_is_in_video_memory_with_a_mirrorVICTORY_IN_PLACE=1; elsewhere tests keep the copies, so the copy machinery stays tested on unified hosts.dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_viewsfail the same way on clean main on this machine.VICTORY_TEST_ADAPTER=radeon): 271 of 271.victory-gpu/diagnostics.Related