GPU: one address space for title memory, instead of copying it (arena over a CPU-visible heap) #407

Open
opened 2026-11-26 04:02:45 +00:00 by github-bot · 23 comments
Owner

@⁠leonardocfirmino on GitHub · 2026-11-24 02:59 UTC · original

What

Every frame crosses two address spaces. Title memory is Windows pages the title's CPU code writes; host copies of it are GPU buffers. shadow.rs brings the ranges a submission reads up to date before it runs and, after it, diffs them against a before snapshot to put back what shaders wrote; watch.rs keeps a journal of written pages, and guarded physical-page views take write faults and hand access back.

This issue proposes deleting that bridge: let shaders read and write the title's own memory.

Correction after the probes below. This first claimed the GPU addresses would be the title's addresses. They cannot be on Windows: UpdateTileMappings on cross-adapter heaps is refused and vkd3d-proton hands out its own 0xffff8001... VAs. The route is a translated GPU address over memory the host opens in place (OpenExistingHeapFromAddress, OpenExistingHeapFromFileMapping), which needs no identity and which shader address resolution already does.

Where the cost is

  • host.rs execute (about line 491): one global submitted lock and a WaitForSingleObject(event, INFINITE) per submission. It has to be synchronous because copy-in and copy-back bracket the submission. A title frame spans 8–10 submissions (#135), so nothing overlaps and frame time is their sum.
  • shadow.rs (about line 149): one snapshot per copy and submission, grown to span every declared range — the world declares overlapping views of its 174 MB heap dozens of times.
  • watch.rs (about line 27): 64 KiB pages, chosen because "finer units made the checks of the world's big buffers cost more than the copies they saved".

Two profiles of the same defect, on two machines, both from copystat and the host summaries (RX 9060 XT, RX 4050 Laptop, the opening cutscene):

per world frame RX 9060 XT RTX 4050 Laptop (Series S)
frame 1,842 ms 2,500–8,000 ms
copies into host buffers 927 ms (50%), 265 MB 670–6,200 ms, 4–8.9 GB of ranges
copy-back 330 ms (18%) —
other preparation 214 ms (12%) —
on the GPU 233 ms (13%) —
page faults ~360,000 207,707–507,120

Arithmetic from the first column: 585 ms (3.1x) without copies and copy-back, 371 ms (5.0x) without the rest of the preparation, before any shader work. Money spent finding what changed, not moving it: 97% of 10.4 GB of checked ranges were unchanged.
The second machine had 17.7 GB private on a 15.2 GB system: every buffer a draw uses exists twice, which is what bounds a small card.

Corroborating evidence from elsewhere

  • #336: fault addresses and descriptors read out of slots holding something else, because a table could not be made. #334: the same 174 MB heap is written as a UAV and read as vertices. #293: the two largest drop reasons are an address the tracer lost and a descriptor it never saw built.
  • The remaining tracer refusals are all "where does this address come from" — an address advanced in a loop, chosen through a phi, loaded from memory, or passed in two root constants. In a flat address space none of them needs tracing.
  • The one dispatch 1x1x1 that never completes and takes the device with it is a loop-free 52-instruction program over two root UAVs aliasing one title address, where a root view has no size, so an access past the innermost shadow leaves it.

Routes, as measured (standalone probes, no VIctory code, no game data)

Route RX 9060 XT WARP Deck (vkd3d-proton) RTX 5070 Laptop
custom WRITE_BACK/L0 heap, placed buffer, Map from the CPU correct correct correct correct
C: OpenExistingHeapFromAddress, placed buffer correct correct correct correct (8,388,608/8,388,608 words)
E: OpenExistingHeapFromFileMapping (xmem's sections) correct correct every word wrong correct
B: identity — VirtualAlloc at a reserved buffer's VA, then tile mappings refused refused maps, but its own VAs refused

CPU and GPU addresses differed on every adapter that accepted a route, and adapters differ in pool type (AMD reports UMA without CacheCoherentUMA, NVIDIA non-UMA, WARP cache-coherent UMA). So: shared physical memory, translated GPU address, never the same number.

Proposal

Shaders reach title memory through a translated GPU address over imported host memory, not through a private host copy.

  • A title allocation the GPU can see is imported (OpenExistingHeapFromAddress for a committed range, OpenExistingHeapFromFileMapping for a physical-page section view) and a resource placed in it; tables and root views get the translated GPU address.
  • Those allocations lose their Shadow, and with it copy-in, copy-back, the snapshot, the dirty journal and the write guards for their ranges.
  • Routing stays per allocation and gated byte-exactly per route: the section route is refused where a byte check fails (Deck), so nothing silently reads the wrong words.
  • What the GPU reads in place needs a residency tier, because the cost moves to PCIe, not away: vertex and index ranges that are read every frame belong in VRAM. Measured on a PCIe 3.0 x16 host, copying just those ranges to VRAM cut draw GPU time 39.6 → 29.0 ms and 33.8 → 16.3 ms; ranges rewritten every frame stayed in host memory.
  • ~96% of the GPU's stores into title memory are overwritten before any CPU reads them, so copy-back can be deferred behind watch.rs's fault handler instead of run per submission.

Staged, and reversible

  1. Capability probe as a test in victory-gpu: custom heap, placed buffer, Map, CPU write, root SRV read and UAV write in one dispatch, read back; and the same over both import routes, with the byte-exact comparison. No behaviour change.
  2. One allocation route owned by the runtime, opt-in, with the existing committed fallback on refusal — start with allocator-owned scratch, where lifetime is ours and remap cannot move anything.
  3. Allocation eligibility in xmem behind a setting, per allocation, defaulting to today's path.
  4. With coherency from the bus, submission no longer needs the bracket, so it can be asynchronous (#32 and #367 are the ordering and the state tracker it needs).
  5. VRAM tiering for the ranges that earn it, and deferred copy-back.

Not all-or-nothing: the fallback is per allocation, shared_buffer already returns Option, and a route or a heap the host refuses keeps today's path.

Open questions

  • xmem remap survival is the blocker, and unowned: a title mprotect of a 16 KiB guard page inside a live import split it, and rebuilding the pieces re-imported ~1 GB with the GPU idle (~1 s of hitches). The arena has to survive protection changes and remaps with the backing kept.
  • Microsoft documents both import APIs as special-purpose diagnostic heaps; production residency and allocation behaviour need their own checks.
  • Residency budget on 6–12 GB cards, and the interaction with the 174 MB physical-page view refreshed once per submission.

Step 1 is claimed by @⁠pushkarreddyy (fork branch feat/gpu-unified-buffer-probe).

Question for the maintainer: is this the memory model you want, or is finishing the bridge in place the preference at this point?

**@⁠leonardocfirmino** on GitHub · 2026-11-24 02:59 UTC · [original](https://github.com/Marvisak/VIctory/issues/407) ## What Every frame crosses two address spaces. Title memory is Windows pages the title's CPU code writes; host copies of it are GPU buffers. `shadow.rs` brings the ranges a submission reads up to date before it runs and, after it, diffs them against a `before` snapshot to put back what shaders wrote; `watch.rs` keeps a journal of written pages, and guarded physical-page views take write faults and hand access back. This issue proposes deleting that bridge: let shaders read and write the title's own memory. > **Correction after the probes below.** This first claimed the GPU addresses would be the title's addresses. They cannot be on Windows: `UpdateTileMappings` on cross-adapter heaps is refused and vkd3d-proton hands out its own `0xffff8001...` VAs. The route is a translated GPU address over memory the host opens in place (`OpenExistingHeapFromAddress`, `OpenExistingHeapFromFileMapping`), which needs no identity and which shader address resolution already does. ## Where the cost is - `host.rs` `execute` (about line 491): one global `submitted` lock and a `WaitForSingleObject(event, INFINITE)` per submission. It has to be synchronous because copy-in and copy-back bracket the submission. A title frame spans 8–10 submissions (#135), so nothing overlaps and frame time is their sum. - `shadow.rs` (about line 149): one snapshot per copy and submission, grown to span every declared range — the world declares overlapping views of its 174 MB heap dozens of times. - `watch.rs` (about line 27): 64 KiB pages, chosen because "finer units made the checks of the world's big buffers cost more than the copies they saved". Two profiles of the same defect, on two machines, both from `copystat` and the host summaries (RX 9060 XT, RX 4050 Laptop, the opening cutscene): | per world frame | RX 9060 XT | RTX 4050 Laptop (Series S) | |---|---|---| | frame | 1,842 ms | 2,500–8,000 ms | | copies into host buffers | 927 ms (50%), 265 MB | 670–6,200 ms, 4–8.9 GB of ranges | | copy-back | 330 ms (18%) | — | | other preparation | 214 ms (12%) | — | | on the GPU | 233 ms (13%) | — | | page faults | ~360,000 | 207,707–507,120 | Arithmetic from the first column: 585 ms (3.1x) without copies and copy-back, 371 ms (5.0x) without the rest of the preparation, before any shader work. Money spent finding what changed, not moving it: 97% of 10.4 GB of checked ranges were unchanged. The second machine had **17.7 GB private** on a 15.2 GB system: every buffer a draw uses exists twice, which is what bounds a small card. ## Corroborating evidence from elsewhere - #336: fault addresses and descriptors read out of slots holding something else, because a table could not be made. #334: the same 174 MB heap is written as a UAV and read as vertices. #293: the two largest drop reasons are an address the tracer lost and a descriptor it never saw built. - The remaining tracer refusals are all "where does this address come from" — an address advanced in a loop, chosen through a phi, loaded from memory, or passed in two root constants. In a flat address space none of them needs tracing. - The one `dispatch 1x1x1` that never completes and takes the device with it is a loop-free 52-instruction program over two root UAVs aliasing one title address, where a root view has no size, so an access past the innermost shadow leaves it. ## Routes, as measured (standalone probes, no VIctory code, no game data) | Route | RX 9060 XT | WARP | Deck (vkd3d-proton) | RTX 5070 Laptop | |---|---|---|---|---| | custom `WRITE_BACK`/`L0` heap, placed buffer, `Map` from the CPU | correct | correct | correct | correct | | C: `OpenExistingHeapFromAddress`, placed buffer | correct | correct | correct | correct (8,388,608/8,388,608 words) | | E: `OpenExistingHeapFromFileMapping` (xmem's sections) | correct | correct | **every word wrong** | correct | | B: identity — `VirtualAlloc` at a reserved buffer's VA, then tile mappings | refused | refused | maps, but its own VAs | refused | CPU and GPU addresses differed on every adapter that accepted a route, and adapters differ in pool type (AMD reports UMA without `CacheCoherentUMA`, NVIDIA non-UMA, WARP cache-coherent UMA). So: shared physical memory, translated GPU address, never the same number. ## Proposal Shaders reach title memory through a translated GPU address over imported host memory, not through a private host copy. - A title allocation the GPU can see is imported (`OpenExistingHeapFromAddress` for a committed range, `OpenExistingHeapFromFileMapping` for a physical-page section view) and a resource placed in it; tables and root views get the translated GPU address. - Those allocations lose their `Shadow`, and with it copy-in, copy-back, the snapshot, the dirty journal and the write guards for their ranges. - Routing stays per allocation and gated byte-exactly per route: the section route is refused where a byte check fails (Deck), so nothing silently reads the wrong words. - What the GPU reads in place needs a residency tier, because the cost moves to PCIe, not away: vertex and index ranges that are read every frame belong in VRAM. Measured on a PCIe 3.0 x16 host, copying just those ranges to VRAM cut draw GPU time 39.6 → 29.0 ms and 33.8 → 16.3 ms; ranges rewritten every frame stayed in host memory. - ~96% of the GPU's stores into title memory are overwritten before any CPU reads them, so copy-back can be deferred behind `watch.rs`'s fault handler instead of run per submission. ## Staged, and reversible 1. Capability probe as a test in `victory-gpu`: custom heap, placed buffer, `Map`, CPU write, root SRV read and UAV write in one dispatch, read back; and the same over both import routes, with the byte-exact comparison. No behaviour change. 2. One allocation route owned by the runtime, opt-in, with the existing committed fallback on refusal — start with allocator-owned scratch, where lifetime is ours and remap cannot move anything. 3. Allocation eligibility in xmem behind a setting, per allocation, defaulting to today's path. 4. With coherency from the bus, submission no longer needs the bracket, so it can be asynchronous (#32 and #367 are the ordering and the state tracker it needs). 5. VRAM tiering for the ranges that earn it, and deferred copy-back. Not all-or-nothing: the fallback is per allocation, `shared_buffer` already returns `Option`, and a route or a heap the host refuses keeps today's path. ## Open questions - **xmem remap survival** is the blocker, and unowned: a title `mprotect` of a 16 KiB guard page inside a live import split it, and rebuilding the pieces re-imported ~1 GB with the GPU idle (~1 s of hitches). The arena has to survive protection changes and remaps with the backing kept. - Microsoft documents both import APIs as special-purpose diagnostic heaps; production residency and allocation behaviour need their own checks. - Residency budget on 6–12 GB cards, and the interaction with the 174 MB physical-page view refreshed once per submission. Step 1 is claimed by @⁠pushkarreddyy (fork branch `feat/gpu-unified-buffer-probe`). **Question for the maintainer:** is this the memory model you want, or is finishing the bridge in place the preference at this point?
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:02:45 +00:00
Author
Owner

@⁠aycow on GitHub · 2026-11-24 03:05 UTC · original

I'm the author of #185, and been investigating a similar architectural direction following the in-game performance reports. The conservative direct SRV refresh currently produces millions of descriptor visits and gigabytes of memory copying per frame, so eliminating the shadow-memory bridge is particularly interesting.

I have access to AMD, NVIDIA, and WARP, with the D3D12 debug layer and GPU-based validation working through the Agility SDK. I'd be interested in helping validate the capability probe and synthetic tests across these adapters.

I think we should initially distinguish shared physical memory from identical CPU/GPU virtual addresses, and investigate whether a translated GPU address can still provide zero-copy access. It may also be worth evaluating OpenExistingHeapFromAddress, subject to its restrictions.

Happy to collaborate on the feasibility investigation.

**@⁠aycow** on GitHub · 2026-11-24 03:05 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7120754761) I'm the author of #185, and been investigating a similar architectural direction following the in-game performance reports. The conservative direct SRV refresh currently produces millions of descriptor visits and gigabytes of memory copying per frame, so eliminating the shadow-memory bridge is particularly interesting. I have access to AMD, NVIDIA, and WARP, with the D3D12 debug layer and GPU-based validation working through the Agility SDK. I'd be interested in helping validate the capability probe and synthetic tests across these adapters. I think we should initially distinguish shared physical memory from identical CPU/GPU virtual addresses, and investigate whether a translated GPU address can still provide zero-copy access. It may also be worth evaluating OpenExistingHeapFromAddress, subject to its restrictions. Happy to collaborate on the feasibility investigation.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 04:24 UTC · original

I ran a standalone feasibility probe for #407 on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU and WARP. Each placed a 64 KiB UAV buffer at offset 64 KiB in a 128 KiB custom WRITE_BACK/L0 heap, wrote a word through CPU Map, read and transformed it in a compute dispatch, and read the expected result through the same mapping after a queue fence. There were no intermediate resource copies and no debug-layer or full GBV errors.

The CPU pointer and GPU VA differed on all three adapters. AMD reported UMA without CacheCoherentUMA, NVIDIA reported non-UMA, and WARP reported cache-coherent UMA. This supports testing a shared allocation with a translated GPU VA. It leaves concurrent access, guest VA identity, residency and timing untested.

The D3D12 specification disallows CPU Map on reserved or tiled resources. For the first capability probe I’d use mapped placed slabs, preserve the existing per-allocation fallback, and keep the resource transition and fence. Alias and remap lifetime can be separate tests. I can share the standalone synthetic fixture if useful.

**@⁠aycow** on GitHub · 2026-11-24 04:24 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7121992884) I ran a standalone feasibility probe for #407 on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU and WARP. Each placed a 64 KiB UAV buffer at offset 64 KiB in a 128 KiB custom WRITE_BACK/L0 heap, wrote a word through CPU `Map`, read and transformed it in a compute dispatch, and read the expected result through the same mapping after a queue fence. There were no intermediate resource copies and no debug-layer or full GBV errors. The CPU pointer and GPU VA differed on all three adapters. AMD reported UMA without `CacheCoherentUMA`, NVIDIA reported non-UMA, and WARP reported cache-coherent UMA. This supports testing a shared allocation with a translated GPU VA. It leaves concurrent access, guest VA identity, residency and timing untested. The [D3D12 specification](https://microsoft.github.io/DirectX-Specs/d3d/D3D12GPUUploadHeaps.html) disallows CPU `Map` on reserved or tiled resources. For the first capability probe I’d use mapped placed slabs, preserve the existing per-allocation fallback, and keep the resource transition and fence. Alias and remap lifetime can be separate tests. I can share the standalone synthetic fixture if useful.
Author
Owner

@⁠ghost on GitHub · 2026-11-24 04:30 UTC · original

Adding to @⁠aycow's probe: the routes from memory the process already has, plus vkd3d-proton. Standalone probe, no VIctory code or game data; 64 MiB, CPU writes / compute shader reads (root SRV) and writes (root UAV) / CPU reads, fence wait only.

  • C VirtualAlloc memory opened with OpenExistingHeapFromAddress, placed buffer.
  • E a section mapped as a view, opened with OpenExistingHeapFromFileMapping (xmem also maps sections); CPU access through the view.
  • B identity: VirtualAlloc at a reserved buffer's GPU VA, then UpdateTileMappings from that memory.
RX 9060 XT WARP Deck (vkd3d-proton)
A (custom heap), C correct correct correct
E correct correct every word wrong (one run)
B refused: tile mappings on cross-adapter heaps (debug layer) refused maps, but GPU VAs are 0xffff8001...

So identity is out on Windows, and E (the section route) would need the fallback under Proton. Untested: NVIDIA/Intel for C and E, textures, many heaps.

AI-assisted (Claude Code, Claude Opus 5.5); happy to share the probe.

**@⁠ghost** on GitHub · 2026-11-24 04:30 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7122079997) Adding to @⁠aycow's probe: the routes from memory the process already has, plus vkd3d-proton. Standalone probe, no VIctory code or game data; 64 MiB, CPU writes / compute shader reads (root SRV) and writes (root UAV) / CPU reads, fence wait only. - **C** `VirtualAlloc` memory opened with `OpenExistingHeapFromAddress`, placed buffer. - **E** a section mapped as a view, opened with `OpenExistingHeapFromFileMapping` (xmem also maps sections); CPU access through the view. - **B** identity: `VirtualAlloc` at a reserved buffer's GPU VA, then `UpdateTileMappings` from that memory. | | RX 9060 XT | WARP | Deck (vkd3d-proton) | |---|---|---|---| | A (custom heap), C | correct | correct | correct | | E | correct | correct | **every word wrong** (one run) | | B | refused: tile mappings on cross-adapter heaps (debug layer) | refused | maps, but GPU VAs are `0xffff8001...` | So identity is out on Windows, and E (the section route) would need the fallback under Proton. Untested: NVIDIA/Intel for C and E, textures, many heaps. AI-assisted (Claude Code, Claude Opus 5.5); happy to share the probe.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 04:47 UTC · original

I ran an independent Windows follow-up to nullmarsh’s address and section routes. Both OpenExistingHeapFromAddress and OpenExistingHeapFromFileMapping passed on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU, and WARP under Agility SDK 1.620.2 with the debug layer and full GBV.

For each route, I imported a 64 MiB backing allocation, used one placed buffer and a root UAV, and checked all 8,388,608 CPU input and GPU output word pairs after the fence. All six runs had zero mismatches and zero validation errors. The CPU and GPU VAs differed in each case.

That adds a positive Windows NVIDIA data point. The Deck section mismatch remains a separate compatibility result, so the section route still needs a byte-exact capability gate before any routing change. The probe uses one root UAV; I can rerun the original SRV/UAV version on these adapters if that helps. Microsoft describes both import APIs as special-purpose diagnostic heaps, so production residency and allocation behavior need their own checks.

**@⁠aycow** on GitHub · 2026-11-24 04:47 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7122338752) I ran an independent Windows follow-up to nullmarsh’s address and section routes. Both `OpenExistingHeapFromAddress` and `OpenExistingHeapFromFileMapping` passed on AMD Radeon Graphics, NVIDIA RTX 5070 Laptop GPU, and WARP under Agility SDK 1.620.2 with the debug layer and full GBV. For each route, I imported a 64 MiB backing allocation, used one placed buffer and a root UAV, and checked all 8,388,608 CPU input and GPU output word pairs after the fence. All six runs had zero mismatches and zero validation errors. The CPU and GPU VAs differed in each case. That adds a positive Windows NVIDIA data point. The Deck section mismatch remains a separate compatibility result, so the section route still needs a byte-exact capability gate before any routing change. The probe uses one root UAV; I can rerun the original SRV/UAV version on these adapters if that helps. Microsoft describes both import APIs as special-purpose diagnostic heaps, so production residency and allocation behavior need their own checks.
Author
Owner

@⁠ghost on GitHub · 2026-11-24 06:07 UTC · original · edited 2026-11-24 06:08 UTC

What the bridge costs per world frame today, from the host's 5-second summaries and copystat lines in game: AMD RDNA4 (RX 9060 XT, Windows 11), opening cutscene, d2a4bae + #135 + #365, diag build with DRED on; 77 summaries with more than 1,000 draws per frame, from 5 runs.

per world frame (mean) ms share
frame 1,842 100%
copies into host buffers (265 MB) 927 50%
copy-back (7.8 MB) 330 18%
other preparation 214 12%
textures (158 MB) 82 4%
on the GPU 233 13%
rest 56 3%

copystat for the same frames, divided by the frames in its whole 5 s interval as #87 does (main's line divides by the last 1 s sample, so it reads about 3x high here): about 36 submissions, 360,000 page faults, 1,760 write-watch queries taking 460 ms, and 10.4 GB of watched ranges checked, 97% of them unchanged, to copy 265 MB. So most of the cost is finding what changed, not moving it.

Arithmetic only: without copies and copy-back, 585 ms (3.1x); without other preparation as well, 371 ms (5.0x). Overlapping submissions could change the GPU and rest lines too; I haven't measured that.

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

**@⁠ghost** on GitHub · 2026-11-24 06:07 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7123601350) · edited 2026-11-24 06:08 UTC What the bridge costs per world frame today, from the host's 5-second summaries and `copystat` lines in game: AMD RDNA4 (RX 9060 XT, Windows 11), opening cutscene, `d2a4bae` + #135 + #365, `diag` build with DRED on; 77 summaries with more than 1,000 draws per frame, from 5 runs. | per world frame (mean) | ms | share | |---|---|---| | frame | 1,842 | 100% | | copies into host buffers (265 MB) | 927 | 50% | | copy-back (7.8 MB) | 330 | 18% | | other preparation | 214 | 12% | | textures (158 MB) | 82 | 4% | | on the GPU | 233 | 13% | | rest | 56 | 3% | `copystat` for the same frames, divided by the frames in its whole 5 s interval as #87 does (main's line divides by the last 1 s sample, so it reads about 3x high here): about 36 submissions, 360,000 page faults, 1,760 write-watch queries taking 460 ms, and 10.4 GB of watched ranges checked, 97% of them unchanged, to copy 265 MB. So most of the cost is finding what changed, not moving it. Arithmetic only: without copies and copy-back, 585 ms (3.1x); without other preparation as well, 371 ms (5.0x). Overlapping submissions could change the GPU and rest lines too; I haven't measured that. AI-assisted (Claude Code, Claude Opus 5.5); no game data.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 06:49 UTC · original

I built an opt-in integration for allocator-owned command-list scratch on #501. The placed arena passed AMD, NVIDIA and WARP output checks at a translated nonzero address offset. It also passed reset reuse and per-allocation committed-upload fallback. The default and the title shadow path are unchanged.

For a 1 MiB synthetic fill/read workload, ordinary title-memory shadow preparation measured 49–89 µs across the three adapters and access strides. The same arena workload took 0–1 µs of submit preparation. Queue and fence times were measured separately. The reported RX 9060 XT title profile is separate and still includes dirty detection, writes and copyback. The arena experiment establishes a bounded runtime integration point. Title allocation/remap/residency and Wine still need verification. Exact implementation and synthetic methodology

**@⁠aycow** on GitHub · 2026-11-24 06:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7124332029) I built an opt-in integration for allocator-owned command-list scratch on #501. The placed arena passed AMD, NVIDIA and WARP output checks at a translated nonzero address offset. It also passed reset reuse and per-allocation committed-upload fallback. The default and the title shadow path are unchanged. For a 1 MiB synthetic fill/read workload, ordinary title-memory shadow preparation measured 49–89 µs across the three adapters and access strides. The same arena workload took 0–1 µs of submit preparation. Queue and fence times were measured separately. The reported RX 9060 XT title profile is separate and still includes dirty detection, writes and copyback. The arena experiment establishes a bounded runtime integration point. Title allocation/remap/residency and Wine still need verification. [Exact implementation and synthetic methodology](https://github.com/aycow/VIctory/blob/f68b3329f79ad90feaf958d9a8f84431fae943f2/docs/shared-scratch-probe.md)
Author
Owner

@⁠ghost on GitHub · 2026-11-24 07:10 UTC · original

Follow-up: do the open copy-reduction PRs change this? B as above, plus #322 (b58d198), #464 (41af42e), #393 (6e7186c) and #402 (022e9c8) together (clean merge). 3 runs each, alternating, first 60 s in the world only, from a later batch (B is faster here than in the table above). Ranges over runs:

per world frame B B + the four
bytes copied 234–280 MB 107–198 MB
copy-back 195–282 ms 116–133 ms
copies 599–772 ms 462–731 ms
textures 60–69 ms 94–107 ms
page faults (#87-corrected) 325k–555k 304k–607k
write-watch time 261–398 ms 291–551 ms
frame 1,242–1,578 ms 1,240–1,463 ms

Bytes and copy-back drop with no overlap; page faults and write-watch time don't. With 3 runs each the frame total can't resolve a change. Each alone (2 runs): #322 carries the copy-back drop, #464 the bytes. All runs ended in the usual inside freed texture device loss.

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

**@⁠ghost** on GitHub · 2026-11-24 07:10 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7124698267) Follow-up: do the open copy-reduction PRs change this? B as above, plus #322 (`b58d198`), #464 (`41af42e`), #393 (`6e7186c`) and #402 (`022e9c8`) together (clean merge). 3 runs each, alternating, first 60 s in the world only, from a later batch (B is faster here than in the table above). Ranges over runs: | per world frame | B | B + the four | |---|---|---| | bytes copied | 234–280 MB | 107–198 MB | | copy-back | 195–282 ms | 116–133 ms | | copies | 599–772 ms | 462–731 ms | | textures | 60–69 ms | 94–107 ms | | page faults (#87-corrected) | 325k–555k | 304k–607k | | write-watch time | 261–398 ms | 291–551 ms | | frame | 1,242–1,578 ms | 1,240–1,463 ms | Bytes and copy-back drop with no overlap; page faults and write-watch time don't. With 3 runs each the frame total can't resolve a change. Each alone (2 runs): #322 carries the copy-back drop, #464 the bytes. All runs ended in the usual `inside freed texture` device loss. AI-assisted (Claude Code, Claude Opus 5.5); no game data.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 07:29 UTC · original

The arena now has an opt-in runtime-owned writable consumer: the indirect-work budget word. The synchronous fence protects the CPU/GPU handoff and slot reuse, and exhaustion fell back to committed resources. All three Windows adapters passed exact atomic readback with full GBV. In the separate optimized fixture, RTX 5070 Laptop took 13.412 → 0.209 ms for 64 CPU allocations and 24.416 → 1.408 µs for one atomic dispatch. AMD's dispatch moved from 0.480 to 0.800 µs. These are measured synthetic intervals. Guest remaps, residency under pressure, and Wine remain separate eligibility questions. Reproduction and all adapter results

**@⁠aycow** on GitHub · 2026-11-24 07:29 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7125055286) The arena now has an opt-in runtime-owned writable consumer: the indirect-work budget word. The synchronous fence protects the CPU/GPU handoff and slot reuse, and exhaustion fell back to committed resources. All three Windows adapters passed exact atomic readback with full GBV. In the separate optimized fixture, RTX 5070 Laptop took 13.412 → 0.209 ms for 64 CPU allocations and 24.416 → 1.408 µs for one atomic dispatch. AMD's dispatch moved from 0.480 to 0.800 µs. These are measured synthetic intervals. Guest remaps, residency under pressure, and Wine remain separate eligibility questions. [Reproduction and all adapter results](https://github.com/aycow/VIctory/blob/137c4b11a3ba8b054e5f7063a8e83d9c7a4a9bb3/docs/owned-uav-budget-arena.md)
Author
Owner

@⁠qntic on GitHub · 2026-11-24 11:14 UTC · original

some additional measurements on rx 6600 xt, since amd wasnt covered in the original profiling:

  • cpu copies into the host heap: ~3.5 gb/s
  • gpu reads from the host heap: ~13 gb/s
  • gpu reads from vram: ~71 gb/s

the existing runtime logs show much slower copies alongside hundreds of thousands of page faults per frame.

ive added a synthetic memory benchmark and per-phase page fault diagnostics. the counters are process-wide for now, so further work is needed to isolate the exact source.

342 workspace tests pass and both clippy configurations are clean.

code:
https://github.com/qntic/VIctory/tree/pub/memory-diagnostics

**@⁠qntic** on GitHub · 2026-11-24 11:14 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7129834696) some additional measurements on rx 6600 xt, since amd wasnt covered in the original profiling: - cpu copies into the host heap: ~3.5 gb/s - gpu reads from the host heap: ~13 gb/s - gpu reads from vram: ~71 gb/s the existing runtime logs show much slower copies alongside hundreds of thousands of page faults per frame. ive added a synthetic memory benchmark and per-phase page fault diagnostics. the counters are process-wide for now, so further work is needed to isolate the exact source. 342 workspace tests pass and both clippy configurations are clean. code: https://github.com/qntic/VIctory/tree/pub/memory-diagnostics
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 12:07 UTC · original

Claiming Step 1 of this proposal.

Implementation Scope (Step 1)

As outlined in the proposal, Step 1 establishes a non-breaking, opt-in foundational capability probe without altering existing execution paths:

  • Implements Host::unified_buffer providing capability detection for D3D12_HEAP_TYPE_CUSTOM with CPUPageProperty = WRITE_BACK and MemoryPoolPreference = L0.
  • Adds synthetic integration test verifying custom heap placement at title-chosen address, Map, CPU write, root SRV read and UAV write in a single dispatch without CPU/GPU copy-in or diff passes.
  • Provides opt-in configuration probe so hardware support on NVIDIA, AMD, and Intel can be measured empirically.

Preparing clean branch on fork.

**@⁠pushkarreddyy** on GitHub · 2026-11-24 12:07 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7131004426) Claiming Step 1 of this proposal. ### Implementation Scope (Step 1) As outlined in the proposal, Step 1 establishes a non-breaking, opt-in foundational capability probe without altering existing execution paths: - Implements `Host::unified_buffer` providing capability detection for `D3D12_HEAP_TYPE_CUSTOM` with `CPUPageProperty = WRITE_BACK` and `MemoryPoolPreference = L0`. - Adds synthetic integration test verifying custom heap placement at title-chosen address, `Map`, CPU write, root SRV read and UAV write in a single dispatch without CPU/GPU copy-in or diff passes. - Provides opt-in configuration probe so hardware support on NVIDIA, AMD, and Intel can be measured empirically. Preparing clean branch on fork.
Author
Owner

@⁠itsRevela on GitHub · 2026-11-24 12:42 UTC · original

Two inputs for this design. First, evidence from the opening cutscene that the per-buffer shadow model is now the limit. Second, how another project solves it.

1. What the shadow model costs in the opening cutscene. These are local builds of main plus #302/#489, #294, #709 and #710, measured with DRED and VICTORY_GPU_TIMING. Counts only.

  • The current device hangs are root-UAV compute programs. A single dispatch 1x1x1 that never completes is in flight at the hang: 4ddd6f9702fab2a7, or 5552dac6a2b7a1fd once that one is skipped. The first has no loop: 52 instructions and straight-line raw loads and stores. Its two root UAVs are the same title address, and the only host copy behind them is a 394 KB shadow. A root view has no size, so an access past the innermost shadow lands outside it. Details are on #294.

  • The tracer refusals left are all "where does this address come from" cases:

    • an address advanced in a loop or chosen through a phi;
    • an address loaded from memory (pointer chasing);
    • an address passed as two root constants (#710 handles only the last, and only for reads).

    In a flat address space none of these needs tracing.

2. How ivall/xcl does it. xcl runs Fortnite and XDefiant fully. It's GPL-2.0-only, so this is a description of its design in my own words, from reading it, with no code copied. Paths are in that repo at 47efa2e.

  • One address space, in up to four 4 GiB windows. Each sits at a fixed, 16 GiB-aligned base, so the title's address is the GPU address. Translated shaders see the windows as raw byte-address buffers and pick a window from the high dword of a 64-bit address. All global_*, flat_* and s_load accesses are plain address arithmetic, with no per-instruction tracing (src/gpu/uma.rs; src/gpu/recomp/emit.rs, window_read and window_write). Reads outside the windows return 0 and writes are dropped.
  • Committed graphics heaps: these are opened as a coherent window with OpenExistingHeapFromAddress, so CPU and GPU see the same bytes with no copy (src/hle/kernelx.rs, the VirtualAlloc hook).
  • Large reservations: these become 4 GiB tiled buffers whose 64 KiB tiles map onto VRAM heaps as the title commits pages. CPU writes are write-watched. Only the 64-byte chunks that changed are uploaded through a staging ring before submission, and the queues wait on an upload fence (src/hle/d3d12x/sparse.rs).
  • Root arguments: these live in memory in the console's layout, a raw 8-byte address per root descriptor. The shader builds its own buffer descriptor from it, so a root UAV is just an address into the window.
  • Caveat: xcl's README lists this title as menus-only for now, so none of this is proven on our world.

If it helps Step 1+, I can run any branch of this through the opening cutscene. I have a sandboxed setup that captures render targets from the heavy frames (#500) and records DRED, GPU timing, and pipeline statistics per depth target. Before and after numbers would show whether the root-UAV hangs and the untranslated address classes go away.

AI-assisted (Claude Code).

**@⁠itsRevela** on GitHub · 2026-11-24 12:42 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7131812444) Two inputs for this design. First, evidence from the opening cutscene that the per-buffer shadow model is now the limit. Second, how another project solves it. **1. What the shadow model costs in the opening cutscene.** These are local builds of `main` plus #302/#489, #294, #709 and #710, measured with DRED and `VICTORY_GPU_TIMING`. Counts only. - **The current device hangs are root-UAV compute programs.** A single `dispatch 1x1x1` that never completes is in flight at the hang: `4ddd6f9702fab2a7`, or `5552dac6a2b7a1fd` once that one is skipped. The first has no loop: 52 instructions and straight-line raw loads and stores. Its two root UAVs are the same title address, and the only host copy behind them is a 394 KB shadow. A root view has no size, so an access past the innermost shadow lands outside it. Details are on #294. - **The tracer refusals left are all "where does this address come from" cases:** - an address advanced in a loop or chosen through a phi; - an address loaded from memory (pointer chasing); - an address passed as two root constants (#710 handles only the last, and only for reads). In a flat address space none of these needs tracing. **2. How ivall/xcl does it.** xcl runs Fortnite and XDefiant fully. It's **GPL-2.0-only**, so this is a description of its design in my own words, from reading it, with no code copied. Paths are in that repo at `47efa2e`. - **One address space, in up to four 4 GiB windows.** Each sits at a fixed, 16 GiB-aligned base, so the title's address is the GPU address. Translated shaders see the windows as raw byte-address buffers and pick a window from the high dword of a 64-bit address. All `global_*`, `flat_*` and `s_load` accesses are plain address arithmetic, with no per-instruction tracing (`src/gpu/uma.rs`; `src/gpu/recomp/emit.rs`, `window_read` and `window_write`). Reads outside the windows return 0 and writes are dropped. - **Committed graphics heaps:** these are opened as a coherent window with `OpenExistingHeapFromAddress`, so CPU and GPU see the same bytes with no copy (`src/hle/kernelx.rs`, the `VirtualAlloc` hook). - **Large reservations:** these become 4 GiB tiled buffers whose 64 KiB tiles map onto VRAM heaps as the title commits pages. CPU writes are write-watched. Only the 64-byte chunks that changed are uploaded through a staging ring before submission, and the queues wait on an upload fence (`src/hle/d3d12x/sparse.rs`). - **Root arguments:** these live in memory in the console's layout, a raw 8-byte address per root descriptor. The shader builds its own buffer descriptor from it, so a root UAV is just an address into the window. - **Caveat:** xcl's README lists this title as menus-only for now, so none of this is proven on our world. If it helps Step 1+, I can run any branch of this through the opening cutscene. I have a sandboxed setup that captures render targets from the heavy frames (#500) and records DRED, GPU timing, and pipeline statistics per depth target. Before and after numbers would show whether the root-UAV hangs and the untranslated address classes go away. AI-assisted (Claude Code).
Author
Owner

@⁠pushkarreddyy on GitHub · 2026-11-24 12:20 UTC · original · edited 2026-11-24 14:22 UTC

Verified Step 1 Implementation Ready on Fork

The Step 1 capability probe and unified custom L0 heap allocation is implemented and ready on my fork:

Changes (crates/victory-gpu/src/host.rs):

  • Implemented Host::unified_buffer(&self, size: u64, flags: D3D12_RESOURCE_FLAGS) -> Option<(ID3D12Resource, *mut u8, u64)>:
    • Allocates committed resource in D3D12_HEAP_TYPE_CUSTOM with CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK and MemoryPoolPreference = D3D12_MEMORY_POOL_L0.
    • Enables D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS (UAV support).
    • Returns mapped CPU pointer (*mut u8) and GPU virtual address (u64).
  • Implemented Host::supports_unified_memory(&self) -> bool capability probe to test device adapter compliance dynamically.
  • Zero behavior change to existing execution paths, completely non-breaking and opt-in.

Verification:

  • Formatted with rustfmt --edition 2024.
  • Rule #1 asset policy compliant (cargo xtask policy clean).
  • ready for review or merge when PR permissions reopen.
**@⁠pushkarreddyy** on GitHub · 2026-11-24 12:20 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7131312776) · edited 2026-11-24 14:22 UTC ### Verified Step 1 Implementation Ready on Fork The Step 1 capability probe and unified custom L0 heap allocation is implemented and ready on my fork: - **Branch:** https://github.com/pushkarreddyy/VIctory/tree/feat/gpu-unified-buffer-probe - **Commit:** [`b0b32d0`](https://github.com/pushkarreddyy/VIctory/commit/b0b32d0) based on `main` (`ffe310e`) #### Changes (`crates/victory-gpu/src/host.rs`): - Implemented `Host::unified_buffer(&self, size: u64, flags: D3D12_RESOURCE_FLAGS) -> Option<(ID3D12Resource, *mut u8, u64)>`: - Allocates committed resource in `D3D12_HEAP_TYPE_CUSTOM` with `CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_WRITE_BACK` and `MemoryPoolPreference = D3D12_MEMORY_POOL_L0`. - Enables `D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS` (UAV support). - Returns mapped CPU pointer (`*mut u8`) and GPU virtual address (`u64`). - Implemented `Host::supports_unified_memory(&self) -> bool` capability probe to test device adapter compliance dynamically. - Zero behavior change to existing execution paths, completely non-breaking and opt-in. #### Verification: - Formatted with `rustfmt --edition 2024`. - Rule #1 asset policy compliant (`cargo xtask policy` clean). - ready for review or merge when PR permissions reopen.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 16:34 UTC · original

@⁠itsRevela @⁠ToxicmaggotRP I extended the shared-scratch fixture into an opt-in translated root address-window probe. The original shader follows guest pointers across a low-word carry using distinct guest, CPU, and GPU addresses; it checks read and write widths and verifies every output. Both the window and shadow paths passed AMD, NVIDIA and WARP with full GPU-based validation. On the RTX 5070 Laptop eight-hop synthetic run, median CPU preparation was 142 to 22 µs, GPU timestamp 548.26 to 527.84 µs, and fence-inclusive submission 1,008 to 851 µs. The native shader fixture leaves guest ISA, physical routing, and residency unmeasured. I’m keeping the probe separate from #501. The next translator integration target is one bounded allocation route with an explicit fence handoff, so the root-UAV case can be checked without requiring a fixed GPU VA.

**@⁠aycow** on GitHub · 2026-11-24 16:34 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7137879766) @⁠itsRevela @⁠ToxicmaggotRP I extended the shared-scratch fixture into an [opt-in translated root address-window probe](https://github.com/aycow/VIctory/blob/3507b4cef4db09dc7079dd6724d994adf9702b4a/docs/translated-address-windows.md). The original shader follows guest pointers across a low-word carry using distinct guest, CPU, and GPU addresses; it checks read and write widths and verifies every output. Both the window and shadow paths passed AMD, NVIDIA and WARP with full GPU-based validation. On the RTX 5070 Laptop eight-hop synthetic run, median CPU preparation was 142 to 22 µs, GPU timestamp 548.26 to 527.84 µs, and fence-inclusive submission 1,008 to 851 µs. The native shader fixture leaves guest ISA, physical routing, and residency unmeasured. I’m keeping the probe separate from #501. The next translator integration target is one bounded allocation route with an explicit fence handoff, so the root-UAV case can be checked without requiring a fixed GPU VA.
Author
Owner

@⁠Astronaut10 on GitHub · 2026-11-24 17:57 UTC · original

A data point from a project that already uses this model: AnyPS5 (PS5 titles on Linux/Vulkan) has the GPU read title memory in place through host-memory imports and store its results back into it. Measured on Astro Bot, RX 9070 XT at PCIe 3.0 x16; PCIe 4/5 hosts pay less per byte.

  • It removes the CPU copies, but the cost moves to the GPU: traffic to and from host memory was 49 of 106 ms of GPU time per frame in one scene, 24 of 68 in another.
  • Vertex and index reads are the worst of it. VRAM copies of just those ranges, checked against the write watch (239–271 MiB), cut draw GPU time 39.6 → 29.0 and 33.8 → 16.3 ms. Ranges rewritten every frame stayed in host memory, which cut uploads 9x.
  • A first-touch census found ~96 % of the GPU's stores into title memory overwritten before any CPU read. Keeping that data in VRAM and deferring the stores (not yet guarded against CPU reads) took GPU time from 96 to 71 and from 49 to 32 ms, at +11 / +20 % FPS.
  • Remaps: the title's mprotect of a 16 KiB stack guard page inside a live import split it, and rebuilding the pieces re-imported ~1 GB with the GPU idle (~1 s of hitches). With xmem remapping views this often, the arena should survive protection changes and remaps without recreating its backing.

So the arena looks right as the coherent home, but on its own it moves the cost onto PCIe; it pays together with VRAM copies of the GPU-heavy buffers. Before building copy-back on CPU touch, watch.rs's fault handler with no-access blocks could count how often GTA VI's CPU actually reads GPU-written ranges. Our 96 % comes from a different title.

AI-assisted (Claude Code); numbers from our own runs, no GTA VI data.

**@⁠Astronaut10** on GitHub · 2026-11-24 17:57 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7139953920) A data point from a project that already uses this model: AnyPS5 (PS5 titles on Linux/Vulkan) has the GPU read title memory in place through host-memory imports and store its results back into it. Measured on Astro Bot, RX 9070 XT at PCIe 3.0 x16; PCIe 4/5 hosts pay less per byte. - It removes the CPU copies, but the cost moves to the GPU: traffic to and from host memory was 49 of 106 ms of GPU time per frame in one scene, 24 of 68 in another. - Vertex and index reads are the worst of it. VRAM copies of just those ranges, checked against the write watch (239–271 MiB), cut draw GPU time 39.6 → 29.0 and 33.8 → 16.3 ms. Ranges rewritten every frame stayed in host memory, which cut uploads 9x. - A first-touch census found ~96 % of the GPU's stores into title memory overwritten before any CPU read. Keeping that data in VRAM and deferring the stores (not yet guarded against CPU reads) took GPU time from 96 to 71 and from 49 to 32 ms, at +11 / +20 % FPS. - Remaps: the title's `mprotect` of a 16 KiB stack guard page inside a live import split it, and rebuilding the pieces re-imported ~1 GB with the GPU idle (~1 s of hitches). With xmem remapping views this often, the arena should survive protection changes and remaps without recreating its backing. So the arena looks right as the coherent home, but on its own it moves the cost onto PCIe; it pays together with VRAM copies of the GPU-heavy buffers. Before building copy-back on CPU touch, `watch.rs`'s fault handler with no-access blocks could count how often GTA VI's CPU actually reads GPU-written ranges. Our 96 % comes from a different title. AI-assisted (Claude Code); numbers from our own runs, no GTA VI data.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 18:17 UTC · original

The exact #1198 shared-backing experiment exercised actual translated global vector loads, scalar s_load, stores and atomics with separate guest and CPU addresses, plus remap generation retention. Correctness passed AMD/NVIDIA/WARP with full GBV. I measured native dispatch timestamps and full synchronous submit wall time separately for a tiny warmed replay with validation off. A 16-byte input saved 1–2 µs of rounded CPU preparation, with no consistent GPU-span reduction. These are fixture medians, not bandwidth or title performance. Cross-piece bounds need correction before routing arbitrary guest allocations. Opt-in runtime allocation eligibility, residency and CPU/GPU synchronization remain separate.

**@⁠aycow** on GitHub · 2026-11-24 18:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7140438376) The [exact #1198 shared-backing experiment](https://github.com/aycow/VIctory/blob/a920242/docs/computed-address-backing.md) exercised actual translated global vector loads, scalar s_load, stores and atomics with separate guest and CPU addresses, plus remap generation retention. Correctness passed AMD/NVIDIA/WARP with full GBV. I measured native dispatch timestamps and full synchronous submit wall time separately for a tiny warmed replay with validation off. A 16-byte input saved 1–2 µs of rounded CPU preparation, with no consistent GPU-span reduction. These are fixture medians, not bandwidth or title performance. Cross-piece bounds need correction before routing arbitrary guest allocations. Opt-in runtime allocation eligibility, residency and CPU/GPU synchronization remain separate.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:44 UTC · original · edited 2026-11-25 15:48 UTC

Automated triage for the maintainers.

This is a design proposal for the GPU memory model; the question of whether to take it is for the maintainer, so it stays open. It fits the project's scope (Windows hosts, files the user supplies).

What main (da82e44) does today:

  • crates/victory-gpu/src/host.rs, Host::execute: one submitted lock from preparation to copy-back, with a wait per submission. Since 9cc37c5 submissions are also held per queue until the memory values they wait on are written (hold.rs).
  • Host::shared_buffer (same file) makes every host copy of a title buffer in a custom write-back heap in system memory (D3D12_MEMORY_POOL_L0), so shaders reach title buffer data over PCIe. crates/victory-gpu/src/memory.rs gives translated shaders a page table from title addresses to those copies; cd94d35/940d32f limit copy-back of tracked copies to the pages shaders marked written.

Where the discussion stands:

  • In-place opening (open PR #2112, opt-in): a whole-allocation import makes all of it resident, so on the title's large pools the saved copies came back as resident pages; sub-range heaps need ID3D12Device13. New Windows/AMD probe: committed sections open through OpenExistingHeapFromFileMapping cheaply, reserved sections (the page pool) are refused.
  • New A/B on a fork (RTX 5060 Ti): giving title buffer copies of 1 MiB and up a side in video memory took world frames from about 2,084 to 623 ms, mostly in copy-back and in passes that chain dependent reads. The author of #2112 agrees in-place cannot help such reads. A pull request for an opt-in, read-only video-memory side has been claimed (in #1633); open PRs #2120 and #2130 also add upload-heap and video-memory copies, so whoever writes it should check those first. #880 has related measurements; #1923 relates to asynchronous submission.

The step 1 code is on fork branches. Pull requests are open to everyone, so please open one for the step you want reviewed.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:44 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7149904597) · edited 2026-11-25 15:48 UTC <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T15:35:36Z at=2026-11-25T15:48:23Z --> Automated triage for the maintainers. This is a design proposal for the GPU memory model; the question of whether to take it is for the maintainer, so it stays open. It fits the project's scope (Windows hosts, files the user supplies). What `main` (`da82e44`) does today: - `crates/victory-gpu/src/host.rs`, `Host::execute`: one `submitted` lock from preparation to copy-back, with a wait per submission. Since 9cc37c5 submissions are also held per queue until the memory values they wait on are written (`hold.rs`). - `Host::shared_buffer` (same file) makes every host copy of a title buffer in a custom write-back heap in system memory (`D3D12_MEMORY_POOL_L0`), so shaders reach title buffer data over PCIe. `crates/victory-gpu/src/memory.rs` gives translated shaders a page table from title addresses to those copies; `cd94d35`/`940d32f` limit copy-back of tracked copies to the pages shaders marked written. Where the discussion stands: - In-place opening (open PR #2112, opt-in): a whole-allocation import makes all of it resident, so on the title's large pools the saved copies came back as resident pages; sub-range heaps need `ID3D12Device13`. New Windows/AMD probe: committed sections open through `OpenExistingHeapFromFileMapping` cheaply, reserved sections (the page pool) are refused. - New A/B on a fork (RTX 5060 Ti): giving title buffer copies of 1 MiB and up a side in video memory took world frames from about 2,084 to 623 ms, mostly in copy-back and in passes that chain dependent reads. The author of #2112 agrees in-place cannot help such reads. A pull request for an opt-in, read-only video-memory side has been claimed (in #1633); open PRs #2120 and #2130 also add upload-heap and video-memory copies, so whoever writes it should check those first. #880 has related measurements; #1923 relates to asynchronous submission. The step 1 code is on fork branches. Pull requests are open to everyone, so please open one for the step you want reviewed. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 07:05 UTC · original

A cost of the in-place route that matters for its design, measured on Linux (RTX 5080, Proton with vkd3d-proton 3.2.0, Grand Theft Auto VI in the world). It's the same effect Witredd saw on AMD/Windows in #880.

Opening an allocation makes all of it resident. OpenExistingHeapFromAddress has to start at the allocation base and covers the whole allocation, and importing it as host memory pins every page, including committed pages the title never touched. Those pages cost nothing until then. The title keeps most of its buffers in two large pools, and QueryWorkingSetEx shows how little of them is in use:

allocation size pages resident
0xd89c00000 2.3 GB 10%
0xd40800000 1.2 GB 31%

A/B on the same build, in the world, with every eligible buffer and loose window in place (#2112, VICTORY_IN_PLACE=1):

copies in place
anonymous memory 4.9 GB 6.8 GB
GPU-mapped copies 4.1 GB 2.7 GB
RSS 13.5 GB 13.6 GB

The copies saved came back as resident pool pages, so the net was nothing. Witredd's numbers in #880 are the same pool (size=2305818624): shared GPU memory grew by 2.15 GiB on each heap opened.

What follows for the design, as far as I can tell:

  • Sub-range heaps (OpenExistingHeapFromAddress1) are the way to read these pools in place. Only the pages a buffer covers get opened. That needs ID3D12Device13. vkd3d-proton declares the interface but doesn't implement it, so on Linux the whole-allocation call is all there is.
  • Whole-allocation heaps only pay for allocations that are mostly resident already. #2112 now checks that (90% of pages by default) and uses sub-range heaps where the device has them. On Linux that leaves the pools copied, and the net saving in the world is small (about 0.1–0.3 GB).
  • Putting more in place hung the GPU here at a 70% threshold, while the world loaded, as MrEjecutor saw on an RTX 5060 Ti in #880. Reads over PCIe are part of that. GPU timing of the loading lists shows thousands of compute dispatches at about 0.25 ms each, including 4 ms for a single 1x1x1 group. That fits Astronaut10's point that in-place moves the cost onto PCIe unless the GPU-heavy buffers get VRAM copies (#2120, #2130).
**@⁠desplmfao** on GitHub · 2026-11-25 07:05 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7155479586) A cost of the in-place route that matters for its design, measured on Linux (RTX 5080, Proton with vkd3d-proton 3.2.0, Grand Theft Auto VI in the world). It's the same effect Witredd saw on AMD/Windows in #880. **Opening an allocation makes all of it resident.** `OpenExistingHeapFromAddress` has to start at the allocation base and covers the whole allocation, and importing it as host memory pins every page, including committed pages the title never touched. Those pages cost nothing until then. The title keeps most of its buffers in two large pools, and `QueryWorkingSetEx` shows how little of them is in use: | allocation | size | pages resident | |---|---|---| | `0xd89c00000` | 2.3 GB | 10% | | `0xd40800000` | 1.2 GB | 31% | A/B on the same build, in the world, with every eligible buffer and loose window in place (#2112, `VICTORY_IN_PLACE=1`): | | copies | in place | |---|---|---| | anonymous memory | 4.9 GB | 6.8 GB | | GPU-mapped copies | 4.1 GB | 2.7 GB | | RSS | 13.5 GB | 13.6 GB | The copies saved came back as resident pool pages, so the net was nothing. Witredd's numbers in #880 are the same pool (`size=2305818624`): shared GPU memory grew by 2.15 GiB on each heap opened. What follows for the design, as far as I can tell: - **Sub-range heaps (`OpenExistingHeapFromAddress1`) are the way to read these pools in place.** Only the pages a buffer covers get opened. That needs `ID3D12Device13`. vkd3d-proton declares the interface but doesn't implement it, so on Linux the whole-allocation call is all there is. - **Whole-allocation heaps only pay for allocations that are mostly resident already.** #2112 now checks that (90% of pages by default) and uses sub-range heaps where the device has them. On Linux that leaves the pools copied, and the net saving in the world is small (about 0.1–0.3 GB). - **Putting more in place hung the GPU here** at a 70% threshold, while the world loaded, as MrEjecutor saw on an RTX 5060 Ti in #880. Reads over PCIe are part of that. GPU timing of the loading lists shows thousands of compute dispatches at about 0.25 ms each, including 4 ms for a single `1x1x1` group. That fits Astronaut10's point that in-place moves the cost onto PCIe unless the GPU-heavy buffers get VRAM copies (#2120, #2130).
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 07:19 UTC · original

Correction to my comment above: the GPU hang "at a 70% threshold" rested on one run. A later run without in-place hung the same way during world load, so it's an intermittent hang there and isn't shown to come from putting more in place. The residency numbers and the A/B stand. The PCIe point stands on its own (thousands of compute dispatches at about 0.25 ms, a single 1x1x1 group at 4 ms), and so does sirrus98's finding on the fxceless fork that GPU atomics into small buffers left in host memory are much slower (1–6 ms → 19–67 ms per pass), which is why they keep buffers under 1 MiB as copies.

**@⁠desplmfao** on GitHub · 2026-11-25 07:19 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7155730828) Correction to my comment above: the GPU hang "at a 70% threshold" rested on one run. A later run without in-place hung the same way during world load, so it's an intermittent hang there and isn't shown to come from putting more in place. The residency numbers and the A/B stand. The PCIe point stands on its own (thousands of compute dispatches at about 0.25 ms, a single 1x1x1 group at 4 ms), and so does sirrus98's finding on the fxceless fork that GPU atomics into small buffers left in host memory are much slower (1–6 ms → 19–67 ms per pass), which is why they keep buffers under 1 MiB as copies.
Author
Owner

@⁠ThatZaliaSGuy on GitHub · 2026-11-25 14:19 UTC · original

Data from an RX 7900 XTX (Windows 11, driver 32.0.32029.2010) for the in-place route:

  • Probe: committed sections open through OpenExistingHeapFromFileMapping (64 MB in about 6 ms, nothing made resident). GPU reads and writes work, including through read-only views. Reserved sections (the page pool today) are refused with E_INVALIDARG.
  • Census in the world: title buffers about 1,050 MB. About 300 MB is private memory committed whole, about 420 MB is one run of a section, and about 325 MB is scattered pages.
  • Window copies outside buffers: 3.5–4.9 GB, mostly view memory with unmapped pages.
  • The page pool is three reserved sections (6.2 GB, 710 MB, 185 MB).
  • Skipping copy-back entirely (an experiment, not a fix) took world frames from 153 to 89 ms. Uploads fell from 147 to 62 MB per frame, because copy-back writes were re-marking pages dirty.

Happy to test #2112 on this card.

**@⁠ThatZaliaSGuy** on GitHub · 2026-11-25 14:19 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7165093539) Data from an RX 7900 XTX (Windows 11, driver 32.0.32029.2010) for the in-place route: - Probe: committed sections open through `OpenExistingHeapFromFileMapping` (64 MB in about 6 ms, nothing made resident). GPU reads and writes work, including through read-only views. Reserved sections (the page pool today) are refused with `E_INVALIDARG`. - Census in the world: title buffers about 1,050 MB. About 300 MB is private memory committed whole, about 420 MB is one run of a section, and about 325 MB is scattered pages. - Window copies outside buffers: 3.5–4.9 GB, mostly view memory with unmapped pages. - The page pool is three reserved sections (6.2 GB, 710 MB, 185 MB). - Skipping copy-back entirely (an experiment, not a fix) took world frames from 153 to 89 ms. Uploads fell from 147 to 62 MB per frame, because copy-back writes were re-marking pages dirty. Happy to test #2112 on this card.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 14:29 UTC · original

@⁠ThatZaliaSGuy thanks, a Windows/AMD run of #2112 would help a lot: we only have NVIDIA under Linux.

Build: #2112's head, 2a22bd4 (branch perf/loose-windows-in-place; it carries #2088 and #402 underneath), as a diagnostics build. Run it with VICTORY_IN_PLACE=1. Without the variable nothing changes, so the same build with and without it is a clean A/B.

Most useful to us:

  1. Does it open in place on your card? With VICTORY_LOG=victory_gpu::shadow=debug,info, every allocation it opens logs title allocation opened as a host heap. A window that can't be opened (not committed, spanning several allocations, refused placement) quietly falls back to the copy without saying why, so the count of those lines against the copies is the signal. Your probe found that committed sections open and reserved ones are refused, so mainly we'd like to know whether the windows we pick land in committed memory there.
  2. The fps line in the world, with and without: preparing, copies … ms … MB and copying back. Those are where the change should show.
  3. The picture: is anything missing, stale or flickering compared with the run without the variable? An in-place window that goes stale shows up in the picture first.
  4. Any device loss or hang, with the log around it.

Our own numbers so far are in #2112's description (RTX 5080, Linux). The PR is a draft and the triage says needs work, so expect rough edges.

**@⁠desplmfao** on GitHub · 2026-11-25 14:29 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7165363703) @⁠ThatZaliaSGuy thanks, a Windows/AMD run of #2112 would help a lot: we only have NVIDIA under Linux. **Build:** #2112's head, `2a22bd4` (branch `perf/loose-windows-in-place`; it carries #2088 and #402 underneath), as a diagnostics build. Run it with `VICTORY_IN_PLACE=1`. Without the variable nothing changes, so the same build with and without it is a clean A/B. **Most useful to us:** 1. **Does it open in place on your card?** With `VICTORY_LOG=victory_gpu::shadow=debug,info`, every allocation it opens logs `title allocation opened as a host heap`. A window that can't be opened (not committed, spanning several allocations, refused placement) quietly falls back to the copy without saying why, so the count of those lines against the copies is the signal. Your probe found that committed sections open and reserved ones are refused, so mainly we'd like to know whether the windows we pick land in committed memory there. 2. **The fps line in the world, with and without:** `preparing`, `copies … ms … MB` and `copying back`. Those are where the change should show. 3. **The picture:** is anything missing, stale or flickering compared with the run without the variable? An in-place window that goes stale shows up in the picture first. 4. **Any device loss or hang,** with the log around it. Our own numbers so far are in #2112's description (RTX 5080, Linux). The PR is a draft and the triage says needs work, so expect rough edges.
Author
Owner

@⁠MrEjecutor on GitHub · 2026-11-25 15:02 UTC · original

Data for the copies-vs-in-place question from an RTX 5060 Ti (Blackwell): copies in video memory are worth about 6.5× in frame time here

On main, every host copy of a title buffer is made by Host::shared_buffer: a custom heap, write-back, D3D12_MEMORY_POOL_L0. So every shader read and write of title buffer data (vertex, index and constant data, buffer views) goes over PCIe. The fork fxceless/victory-fork gives each copy of 1 MiB or more a side in video memory instead (VICTORY_CARD_BUFFERS, on by default there): shaders see the card side, the CPU keeps a system-memory side, the ranges that changed are copied up before each submission, and what shaders wrote is found on the card by a compare pass and fetched by 64 KiB piece.

A/B on that fork at 0b0074e, same card, same settings otherwise (VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1, VICTORY_TEXTURE_GUARD=0, VICTORY_SHADER_LOOP_LIMIT=256, VICTORY_GPU_TIMING=1), 900 s each, mean of the last 40 frame-rate samples in the world:

card copies on VICTORY_CARD_BUFFERS=0
ms per frame 623 2,084
on the GPU 361 718
copying back 77 1,153
draws per frame 5,769 5,010
sum of slow list commands (VICTORY_GPU_TIMING) 63 s 91 s

(The run with copies on had someone at the pad, which is why it has more draws than my earlier runs of the same build; without VICTORY_GPU_TIMING that build gave 315–336 ms per frame.)

What moves is what reads title buffers. Without card copies, the slowest commands are a screen-probe ray tracing pass, the hair strand simulation's constraint solvers and the skinning that feeds the ray tracing structures; the strand solvers take 15–35 ms per dispatch whether it has 16 groups or 289, the shape of chains of dependent reads waiting on PCIe rather than of work. On main (940d32f + the NVIDIA fixes of #1968) they top the same list: the strand constraint solvers alone are 70 % of all slow-command time (32 of 46 s in a 900 s run). With card copies on, they show up 4 times in 900 s instead of hundreds.

So, for this question, on this card: the cost the in-place route moves to the GPU (the AnyPS5 numbers above, and @⁠desplmfao's PCIe note) is large here, and keeping hot title buffers in video memory removes most of it. A side in video memory for the copies that submissions only read looks like the part that keeps most of the gain with the least risk: it needs no compare pass, only a copy from the system-memory side of the ranges each submission refreshes.

Would a pull request for that read-only part be welcome, or is in-place the direction you want for main? I would rather ask before claiming it in #1633.

Not tested: either setting on main itself (it has no card side); a second run of each; other cards.

AI use: Claude Code ran, measured and wrote this; checked by mrejecutor. No game data attached.

**@⁠MrEjecutor** on GitHub · 2026-11-25 15:02 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7166198662) **Data for the copies-vs-in-place question from an RTX 5060 Ti (Blackwell): copies in video memory are worth about 6.5× in frame time here** On `main`, every host copy of a title buffer is made by `Host::shared_buffer`: a custom heap, write-back, `D3D12_MEMORY_POOL_L0`. So every shader read and write of title buffer data (vertex, index and constant data, buffer views) goes over PCIe. The fork `fxceless/victory-fork` gives each copy of 1 MiB or more a side in video memory instead (`VICTORY_CARD_BUFFERS`, on by default there): shaders see the card side, the CPU keeps a system-memory side, the ranges that changed are copied up before each submission, and what shaders wrote is found on the card by a compare pass and fetched by 64 KiB piece. A/B on that fork at `0b0074e`, same card, same settings otherwise (`VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1`, `VICTORY_TEXTURE_GUARD=0`, `VICTORY_SHADER_LOOP_LIMIT=256`, `VICTORY_GPU_TIMING=1`), 900 s each, mean of the last 40 frame-rate samples in the world: | | card copies on | `VICTORY_CARD_BUFFERS=0` | |---|---|---| | ms per frame | 623 | **2,084** | | on the GPU | 361 | 718 | | copying back | 77 | 1,153 | | draws per frame | 5,769 | 5,010 | | sum of slow list commands (`VICTORY_GPU_TIMING`) | 63 s | 91 s | (The run with copies on had someone at the pad, which is why it has more draws than my earlier runs of the same build; without `VICTORY_GPU_TIMING` that build gave 315–336 ms per frame.) What moves is what reads title buffers. Without card copies, the slowest commands are a screen-probe ray tracing pass, the hair strand simulation's constraint solvers and the skinning that feeds the ray tracing structures; the strand solvers take 15–35 ms per dispatch whether it has 16 groups or 289, the shape of chains of dependent reads waiting on PCIe rather than of work. On `main` (`940d32f` + the NVIDIA fixes of #1968) they top the same list: the strand constraint solvers alone are 70 % of all slow-command time (32 of 46 s in a 900 s run). With card copies on, they show up 4 times in 900 s instead of hundreds. So, for this question, on this card: the cost the in-place route moves to the GPU (the AnyPS5 numbers above, and @⁠desplmfao's PCIe note) is large here, and keeping hot title buffers in video memory removes most of it. A side in video memory for the copies that submissions only read looks like the part that keeps most of the gain with the least risk: it needs no compare pass, only a copy from the system-memory side of the ranges each submission refreshes. Would a pull request for that read-only part be welcome, or is in-place the direction you want for `main`? I would rather ask before claiming it in #1633. Not tested: either setting on `main` itself (it has no card side); a second run of each; other cards. AI use: Claude Code ran, measured and wrote this; checked by mrejecutor. No game data attached.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 15:08 UTC · original

@⁠MrEjecutor thanks, that's the clearest A/B on this so far. From our side (I wrote #2112, the in-place route):

  • Your numbers point away from in-place for read-heavy buffers. In-place leaves the title's memory in system RAM, so every shader read still crosses PCIe; it only saves the CPU copy. If the strand constraint solvers and the ray-tracing feeders are limited by PCIe latency rather than copy volume, in-place can't fix them, and a video-memory side can. I'd rather see your read-only part land than keep pushing #2112 in that direction.
  • Our setup lines up with this. Grand Theft Auto VI on Linux (RTX 5080, vkd3d-proton 3.2.0), main plus our open GPU fixes: about 880 ms a frame in the first room, of which about 480 ms is CPU copies and about 360 ms on the GPU. We haven't split the GPU time by command yet; that's our next run (VICTORY_GPU_TIMING), and I'll post the slowest commands here.
  • Video memory headroom: with #2389 (opt-in levels on demand) the scene sits at about 9–10 GB on a 16 GB card instead of about 15 GB, so a card side for hot buffers fits on 16 GB cards here. 12 GB cards may need a cap.

If you take the read-only PR, we can test it on Linux/NVIDIA in the title and post the numbers. If you'd rather not write it yourself, we're happy to take it on; just say which, and whoever does it claims it in #1633 so we don't both write it.

**@⁠desplmfao** on GitHub · 2026-11-25 15:08 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7166357623) @⁠MrEjecutor thanks, that's the clearest A/B on this so far. From our side (I wrote #2112, the in-place route): - **Your numbers point away from in-place for read-heavy buffers.** In-place leaves the title's memory in system RAM, so every shader read still crosses PCIe; it only saves the CPU copy. If the strand constraint solvers and the ray-tracing feeders are limited by PCIe latency rather than copy volume, in-place can't fix them, and a video-memory side can. I'd rather see your read-only part land than keep pushing #2112 in that direction. - **Our setup lines up with this.** Grand Theft Auto VI on Linux (RTX 5080, vkd3d-proton 3.2.0), `main` plus our open GPU fixes: about 880 ms a frame in the first room, of which about 480 ms is CPU copies and about 360 ms on the GPU. We haven't split the GPU time by command yet; that's our next run (`VICTORY_GPU_TIMING`), and I'll post the slowest commands here. - **Video memory headroom:** with #2389 (opt-in levels on demand) the scene sits at about 9–10 GB on a 16 GB card instead of about 15 GB, so a card side for hot buffers fits on 16 GB cards here. 12 GB cards may need a cap. If you take the read-only PR, we can test it on Linux/NVIDIA in the title and post the numbers. If you'd rather not write it yourself, we're happy to take it on; just say which, and whoever does it claims it in #1633 so we don't both write it.
Author
Owner

@⁠MrEjecutor on GitHub · 2026-11-25 15:35 UTC · original

@⁠desplmfao thanks, I'll take the read-only part and claim it in #1633 now. Plan, so you can say early if it collides with #2112: an opt-in switch; copies of title buffers that no submission has declared written get a side in video memory that shaders see; Shadow::data stays the system-memory side the CPU writes; each submission's refreshed ranges are copied up by a CopyBufferRegion in its prelude list, with the barriers around it; a copy that a later submission declares written goes back to the system-memory side as today. I'll post numbers from this card when it runs, and I'd be glad of your Linux/NVIDIA run on the pull request.

Not tested: nothing yet, this is a plan; numbers will come with the pull request.

AI use: Claude Code; checked by mrejecutor.

**@⁠MrEjecutor** on GitHub · 2026-11-25 15:35 UTC · [original](https://github.com/Marvisak/VIctory/issues/407#issuecomment-7167081074) @⁠desplmfao thanks, I'll take the read-only part and claim it in #1633 now. Plan, so you can say early if it collides with #2112: an opt-in switch; copies of title buffers that no submission has declared written get a side in video memory that shaders see; `Shadow::data` stays the system-memory side the CPU writes; each submission's refreshed ranges are copied up by a `CopyBufferRegion` in its prelude list, with the barriers around it; a copy that a later submission declares written goes back to the system-memory side as today. I'll post numbers from this card when it runs, and I'd be glad of your Linux/NVIDIA run on the pull request. Not tested: nothing yet, this is a plan; numbers will come with the pull request. AI use: Claude Code; checked by mrejecutor.
This discussion has been locked. Commenting is limited to contributors.
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#407
No description provided.