Design question: read title memory in place (OpenExistingHeap*) instead of host copies; copies and RAM bound a 16 GB laptop #880

Open
opened 2026-11-26 04:14:06 +00:00 by github-bot · 10 comments
Owner

@⁠anasssssssss1 on GitHub · 2026-11-24 13:17 UTC · original

Summary

On a 16 GB laptop the world is bound by host copies of title memory, in time and in RAM. D3D12 can open title memory as a heap in place (OpenExistingHeapFromAddress, OpenExistingHeapFromAddress1 for a sub-range, OpenExistingHeapFromFileMapping for the physical-page sections), and all four cases VIctory would need succeed on an RTX 4050. Placed buffers in such heaps would let draws read title memory directly: no shadow copy to keep, no refresh per submission, no write watching for those ranges.

I'm raising it as a design question before writing it, since it changes decision 0007's "Copies of title memory".

Measured (title 1.0.2.1, --console series-s, in the world)

RTX 4050 Laptop 6 GB (driver 32.0.16.2114, 32-lane waves), Ryzen 7 7735HS, 15.2 GB RAM, Windows 11 26300. diag build of main ffe310e plus #694/#704/#705/#233/#550/#581, driven with VICTORY_KEYS.

Per frame, from victory_gpu::host and copystat:

run 1 run 2
frame 2.5-3.5 s 2.5-8.0 s
of it "copies" 1.4-2.1 s 0.67-6.2 s
refreshes ~7,000 (4.0 GB of ranges) 11,700-12,500 (5.0-8.9 GB)
write-watch queries 873, 480 ms 1,124-1,518, 384-1,657 ms
copies hitting unmapped pages 654 (139 MB) 523-1,028 (161-231 MB)
page faults 207,707 255,667-507,120

One 174 MB buffer (0x257d0000, a physical-page view) is refreshed about 20 times a frame, once per submission.

Memory: the process had 17.7 GB private on the 15.2 GB machine with Series S settings, 0.64 GB free, Windows paging at ~8,000 pages/s. In run 2 the copies went from 0.67 s to 6.2 s a frame as that set in; the page faults above are mostly that. Every buffer a draw uses has a second, persistent copy in host memory, so this doubles the title's GPU-visible data.

Probe

OpenExisting* on this machine (64 MB allocations, a test in victory-gpu):

Memory Result
VirtualAlloc (MEM_RESERVE | MEM_COMMIT) heap 64 MB
the same with MEM_WRITE_WATCH (as xmem reserves title GPU memory) heap 64 MB
a 4 MB sub-range at +1 MB (ID3D12Device13::OpenExistingHeapFromAddress1) heap 4 MB
a pagefile-backed section (OpenExistingHeapFromFileMapping) heap 64 MB

I have not yet placed buffers in them or drawn from them.

Open questions

  • GPU reads over PCIe. On a discrete GPU, vertex, index and constant data read from these heaps crosses PCIe each time it is used, where the shadows are read from host memory too (upload heap), so this should be no worse than today, but I have not measured it.
  • Ranges shaders write. Today they go back to title memory after the submission (Shadow::gpu_writes). In place, they would land there directly; the CPU side would need the fences VIctory already waits on.
  • Granularity. OpenExistingHeapFromAddress1 takes any range, so the title's large pools can be opened per buffer or per region and kept while mapped (title_memory_remapped tells when views change).
  • Textures stay as they are (tiled title layouts need detiling into host textures).

Would a branch along these lines be welcome? I can start with read-only buffer ranges behind a switch, and measure frame time and memory against main on this machine.

Smaller thing in the meantime

Copies that hit unmapped title pages fall back to 64 KiB and then 4 KiB ReadProcessMemory pieces, asked again every time: on the order of 34,000 failing reads a frame in run 1 (139 MB unmapped). Run 2 has a change that remembers 64 KiB blocks found wholly unmapped and asks about them with one 4 KiB read instead of 17 (so memory committed later without a remap notification is still seen; a test commits a block after it was cached). Its first world frames spent 0.67-0.70 s on copies against 1.4-2.1 s in run 1, but run 2 then went into paging, so I don't have a clean measurement yet. I'll post a branch once it has one and passes CI.

Runs: run 1 is the tree above; run 2 is the same plus that change.

**@⁠anasssssssss1** on GitHub · 2026-11-24 13:17 UTC · [original](https://github.com/Marvisak/VIctory/issues/880) ## Summary On a 16 GB laptop the world is bound by host copies of title memory, in time and in RAM. D3D12 can open title memory as a heap in place (`OpenExistingHeapFromAddress`, `OpenExistingHeapFromAddress1` for a sub-range, `OpenExistingHeapFromFileMapping` for the physical-page sections), and all four cases VIctory would need succeed on an RTX 4050. Placed buffers in such heaps would let draws read title memory directly: no shadow copy to keep, no refresh per submission, no write watching for those ranges. I'm raising it as a design question before writing it, since it changes decision 0007's "Copies of title memory". ## Measured (title 1.0.2.1, `--console series-s`, in the world) RTX 4050 Laptop 6 GB (driver 32.0.16.2114, 32-lane waves), Ryzen 7 7735HS, 15.2 GB RAM, Windows 11 26300. `diag` build of `main` `ffe310e` plus #694/#704/#705/#233/#550/#581, driven with `VICTORY_KEYS`. Per frame, from `victory_gpu::host` and `copystat`: | | run 1 | run 2 | |---|---|---| | frame | 2.5-3.5 s | 2.5-8.0 s | | of it "copies" | 1.4-2.1 s | 0.67-6.2 s | | refreshes | ~7,000 (4.0 GB of ranges) | 11,700-12,500 (5.0-8.9 GB) | | write-watch queries | 873, 480 ms | 1,124-1,518, 384-1,657 ms | | copies hitting unmapped pages | 654 (139 MB) | 523-1,028 (161-231 MB) | | page faults | 207,707 | 255,667-507,120 | One 174 MB buffer (`0x257d0000`, a physical-page view) is refreshed about 20 times a frame, once per submission. Memory: the process had **17.7 GB private** on the 15.2 GB machine with Series S settings, 0.64 GB free, Windows paging at ~8,000 pages/s. In run 2 the copies went from 0.67 s to 6.2 s a frame as that set in; the page faults above are mostly that. Every buffer a draw uses has a second, persistent copy in host memory, so this doubles the title's GPU-visible data. ## Probe `OpenExisting*` on this machine (64 MB allocations, a test in `victory-gpu`): | Memory | Result | |---|---| | `VirtualAlloc` (`MEM_RESERVE \| MEM_COMMIT`) | heap 64 MB | | the same with `MEM_WRITE_WATCH` (as xmem reserves title GPU memory) | heap 64 MB | | a 4 MB sub-range at +1 MB (`ID3D12Device13::OpenExistingHeapFromAddress1`) | heap 4 MB | | a pagefile-backed section (`OpenExistingHeapFromFileMapping`) | heap 64 MB | I have not yet placed buffers in them or drawn from them. ## Open questions - **GPU reads over PCIe.** On a discrete GPU, vertex, index and constant data read from these heaps crosses PCIe each time it is used, where the shadows are read from host memory too (upload heap), so this should be no worse than today, but I have not measured it. - **Ranges shaders write.** Today they go back to title memory after the submission (`Shadow::gpu_writes`). In place, they would land there directly; the CPU side would need the fences VIctory already waits on. - **Granularity.** `OpenExistingHeapFromAddress1` takes any range, so the title's large pools can be opened per buffer or per region and kept while mapped (`title_memory_remapped` tells when views change). - **Textures** stay as they are (tiled title layouts need detiling into host textures). Would a branch along these lines be welcome? I can start with read-only buffer ranges behind a switch, and measure frame time and memory against `main` on this machine. ## Smaller thing in the meantime Copies that hit unmapped title pages fall back to 64 KiB and then 4 KiB `ReadProcessMemory` pieces, asked again every time: on the order of 34,000 failing reads a frame in run 1 (139 MB unmapped). Run 2 has a change that remembers 64 KiB blocks found wholly unmapped and asks about them with one 4 KiB read instead of 17 (so memory committed later without a remap notification is still seen; a test commits a block after it was cached). Its first world frames spent 0.67-0.70 s on copies against 1.4-2.1 s in run 1, but run 2 then went into paging, so I don't have a clean measurement yet. I'll post a branch once it has one and passes CI. Runs: run 1 is the tree above; run 2 is the same plus that change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:06 +00:00
Author
Owner

@⁠Sunkiller-qc on GitHub · 2026-11-24 13:21 UTC · original

This is the direction proposed in #407, and some of it has already been measured there. aycow ran OpenExistingHeapFromAddress and OpenExistingHeapFromFileMapping on AMD, an RTX 5070 Laptop and WARP with Agility 1.620.2, and both passed. nullmarsh covered vkd3d-proton and measured what the copy bridge costs per world frame. qntic added RX 6600 XT bandwidth numbers. #501 (ToxicmaggotRP) is an open PR for a CPU-visible placed-buffer arena. pushkarreddyy has a step-1 probe branch.

Your RTX 4050 results, OpenExistingHeapFromAddress1 for sub-ranges in particular, and the 16 GB laptop RAM numbers would fit well on #407, so the design discussion stays in one place.

**@⁠Sunkiller-qc** on GitHub · 2026-11-24 13:21 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7132711887) This is the direction proposed in #407, and some of it has already been measured there. aycow ran `OpenExistingHeapFromAddress` and `OpenExistingHeapFromFileMapping` on AMD, an RTX 5070 Laptop and WARP with Agility 1.620.2, and both passed. nullmarsh covered vkd3d-proton and measured what the copy bridge costs per world frame. qntic added RX 6600 XT bandwidth numbers. #501 (ToxicmaggotRP) is an open PR for a CPU-visible placed-buffer arena. pushkarreddyy has a step-1 probe branch. Your RTX 4050 results, `OpenExistingHeapFromAddress1` for sub-ranges in particular, and the 16 GB laptop RAM numbers would fit well on #407, so the design discussion stays in one place.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 13:30 UTC · original

Daniel tested GPU visibility after placement on an RTX 4090 with Wine/vkd3d-proton 3.2. Ordinary and MEM_WRITE_WATCH 4 MiB allocations both opened successfully with heap flags 0xe1. Each accepted the same 64 KiB buffer placed at +64 KiB. The probe wrote a CPU word, copied four bytes from the placed buffer to readback on the GPU, waited for the fence, then repeated with a different word.

Allocation CPU values in order GPU readbacks in order
Ordinary committed 0x1234abcd, 0xdeadbeef 0x1234abcd, 0xdeadbeef
Write-watched 0x1234abcd, 0xdeadbeef 0, 0

Touching the watched source before import gave the same two zero readbacks. A further arm that also reset the write watch between copies gave the same result. The pagefile-backed section opened, but this probe did not read it on the GPU.

For a read-only prototype on this Wine backend, keep the existing shadow-copy path for write-watched allocations. The same two-write, two-readback check on the native RTX 4050 would establish which allocation types are candidates for your frame-time and memory comparison. We have no native result or title timing from this probe.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 13:30 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7132931456) Daniel tested GPU visibility after placement on an RTX 4090 with Wine/vkd3d-proton 3.2. Ordinary and MEM_WRITE_WATCH 4 MiB allocations both opened successfully with heap flags 0xe1. Each accepted the same 64 KiB buffer placed at +64 KiB. The probe wrote a CPU word, copied four bytes from the placed buffer to readback on the GPU, waited for the fence, then repeated with a different word. | Allocation | CPU values in order | GPU readbacks in order | | --- | --- | --- | | Ordinary committed | 0x1234abcd, 0xdeadbeef | 0x1234abcd, 0xdeadbeef | | Write-watched | 0x1234abcd, 0xdeadbeef | 0, 0 | Touching the watched source before import gave the same two zero readbacks. A further arm that also reset the write watch between copies gave the same result. The pagefile-backed section opened, but this probe did not read it on the GPU. For a read-only prototype on this Wine backend, keep the existing shadow-copy path for write-watched allocations. The same two-write, two-readback check on the native RTX 4050 would establish which allocation types are candidates for your frame-time and memory comparison. We have no native result or title timing from this probe.
Author
Owner

@⁠anasssssssss1 on GitHub · 2026-11-24 13:39 UTC · original

Follow-up probes on the same machine (RTX 4050 Laptop, driver 32.0.16.2114), aimed at the physical-page views, which are where the copy time goes. In the run above, copies of MEM_MAPPED ranges took 8,885 ms of 9,042 ms in the per-buffer copystat lines; MEM_PRIVATE took the rest.

Memory Result
OpenExistingHeapFromFileMapping on a SEC_RESERVE section committed in part (as xmem creates them) refused (E_INVALIDARG); a committed pagefile section opens
OpenExistingHeapFromAddress1 over committed pages inside one MapViewOfFile3 view of such a section ok
the same over a range spanning two views (two sections, adjacent placeholders) refused (E_INVALIDARG)

So a heap per section is out unless sections are committed whole (more commit charge, on machines that already hit the limit). What does work is a heap per view run, the runs XMemMapPhysicalPages already makes. A title buffer spanning several runs would then be a reserved buffer whose 64 KiB tiles (the console's page) are mapped onto those heaps with UpdateTileMappings, and remapped where map/unmap already call title_memory_remapped. The GPU's own page-mapping copies (map_alias) would go through the same path.

Not yet tried: UpdateTileMappings onto heaps from OpenExistingHeapFromAddress1 (only onto committed heaps), and how many such heaps a frame's buffers need, given views of one page each from map_alias.

**@⁠anasssssssss1** on GitHub · 2026-11-24 13:39 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7133136809) Follow-up probes on the same machine (RTX 4050 Laptop, driver 32.0.16.2114), aimed at the physical-page views, which are where the copy time goes. In the run above, copies of `MEM_MAPPED` ranges took 8,885 ms of 9,042 ms in the per-buffer `copystat` lines; `MEM_PRIVATE` took the rest. | Memory | Result | |---|---| | `OpenExistingHeapFromFileMapping` on a `SEC_RESERVE` section committed in part (as xmem creates them) | **refused** (`E_INVALIDARG`); a committed pagefile section opens | | `OpenExistingHeapFromAddress1` over committed pages inside one `MapViewOfFile3` view of such a section | ok | | the same over a range spanning two views (two sections, adjacent placeholders) | **refused** (`E_INVALIDARG`) | So a heap per section is out unless sections are committed whole (more commit charge, on machines that already hit the limit). What does work is a heap per view run, the runs `XMemMapPhysicalPages` already makes. A title buffer spanning several runs would then be a reserved buffer whose 64 KiB tiles (the console's page) are mapped onto those heaps with `UpdateTileMappings`, and remapped where `map`/`unmap` already call `title_memory_remapped`. The GPU's own page-mapping copies (`map_alias`) would go through the same path. Not yet tried: `UpdateTileMappings` onto heaps from `OpenExistingHeapFromAddress1` (only onto committed heaps), and how many such heaps a frame's buffers need, given views of one page each from `map_alias`.
Author
Owner

@⁠Xeltax on GitHub · 2026-11-24 13:48 UTC · original

Two measurements on an RTX 4080 (driver 621.01, Windows 11) that bear on the plan above. Both come from a probe test in victory-gpu and one local tree.

1. The tile route removed the device here.

  • Setup: a committed pagefile section opened with OpenExistingHeapFromFileMapping. Heap flags 0x421 (SHARED | SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS), CUSTOM, WRITE_BACK, L0.
  • A buffer placed in that heap reads and writes the section both ways, GPU ↔ CPU.
  • A reserved buffer (ALLOW_UNORDERED_ACCESS | ALLOW_CROSS_ADAPTER) is created fine. UpdateTileMappings of two of its tiles onto pages 3 and 1 of that heap is accepted. The next submission (a CopyBufferRegion from the reserved buffer) removed the device with 0x887A0005.
  • I didn't try heaps from OpenExistingHeapFromAddress1, so that case is still open. On NVIDIA, though, tiles onto a shared, cross-adapter heap look like a dead end.

2. A section opens only below 4 GiB.

  • OpenExistingHeapFromFileMapping opens a committed section of 4,095 MB and refuses one of 4,096 MB (and 4,200 or 6,236 MB) with E_INVALIDARG.
  • So xmem's single 6.1 GiB allocation would have to be cut into sections under 4 GiB. I cut it at 65,535 pages, and each part then opened.

What it bought in practice (in-place placed buffers for the title buffers that are one run of a section, world frames):

  • copy time and page faults went down (42k → 20k faults per frame), but frame time barely moved;
  • the 174 MB heap is two runs of its section: pages ~2528–2960, then 0 onward;
  • most of the remaining copies are 4 MB windows over pages remapped one at a time, with gaps and pages out of order.

So whole-buffer placement covers little of the cost. It's the scattered pages that need covering.

AI use: Claude Code (Claude Opus 5.5) wrote the probe and the local change, ran them on my machine and wrote this.

**@⁠Xeltax** on GitHub · 2026-11-24 13:48 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7133363153) Two measurements on an RTX 4080 (driver 621.01, Windows 11) that bear on the plan above. Both come from a probe test in `victory-gpu` and one local tree. **1. The tile route removed the device here.** - Setup: a committed pagefile section opened with `OpenExistingHeapFromFileMapping`. Heap flags 0x421 (`SHARED | SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS`), CUSTOM, WRITE_BACK, L0. - A buffer *placed* in that heap reads and writes the section both ways, GPU ↔ CPU. - A *reserved* buffer (`ALLOW_UNORDERED_ACCESS | ALLOW_CROSS_ADAPTER`) is created fine. `UpdateTileMappings` of two of its tiles onto pages 3 and 1 of that heap is accepted. The next submission (a `CopyBufferRegion` from the reserved buffer) removed the device with `0x887A0005`. - I didn't try heaps from `OpenExistingHeapFromAddress1`, so that case is still open. On NVIDIA, though, tiles onto a shared, cross-adapter heap look like a dead end. **2. A section opens only below 4 GiB.** - `OpenExistingHeapFromFileMapping` opens a committed section of 4,095 MB and refuses one of 4,096 MB (and 4,200 or 6,236 MB) with `E_INVALIDARG`. - So xmem's single 6.1 GiB allocation would have to be cut into sections under 4 GiB. I cut it at 65,535 pages, and each part then opened. **What it bought in practice** (in-place placed buffers for the title buffers that are one run of a section, world frames): - copy time and page faults went down (42k → 20k faults per frame), but frame time barely moved; - the 174 MB heap is two runs of its section: pages ~2528–2960, then 0 onward; - most of the remaining copies are 4 MB windows over pages remapped one at a time, with gaps and pages out of order. So whole-buffer placement covers little of the cost. It's the scattered pages that need covering. AI use: Claude Code (Claude Opus 5.5) wrote the probe and the local change, ran them on my machine and wrote this.
Author
Owner

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

Tried it on the title: a prototype behind VICTORY_ZERO_COPY (on the testers tree) that makes a title buffer a placed buffer on a heap from OpenExistingHeapFromAddress1 when one committed region (one view) holds its 64 KiB pages, with refresh, snapshot and copy-back skipped for it, and the buffer dropped on title_memory_remapped. A standalone probe of that path works on the RTX 4050: the GPU reads the view's pages through the placed buffer and sees a later CPU write with no copy.

On the title it does not hold up yet. With it on, the per-frame copystat on the loading screen showed refreshes that checked nothing (in-place buffers), but loading never finished: 12 minutes on the loading screen and then no log lines at all (the process stayed up), where the same tree without it reached the world in about 5 minutes.

My reading, not verified: a remap drops the shadow, but views already written into descriptor tables keep the old placed buffer, which still holds the pages it was opened over. A copy re-reads the current mapping at every submission; a buffer in place does not. So zero-copy for physical-page views needs the views that name a buffer to be remade when its pages are remapped, not only the shadow. Also: UpdateTileMappings onto a heap from OpenExistingHeapFromAddress1 removed the device here; those heaps come back SHARED | SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS (0x421), and tiled resources on cross-adapter heaps are not allowed, so buffers spanning several views cannot be stitched that way.

**@⁠anasssssssss1** on GitHub · 2026-11-24 14:02 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7133727533) Tried it on the title: a prototype behind `VICTORY_ZERO_COPY` (on the testers tree) that makes a title buffer a placed buffer on a heap from `OpenExistingHeapFromAddress1` when one committed region (one view) holds its 64 KiB pages, with refresh, snapshot and copy-back skipped for it, and the buffer dropped on `title_memory_remapped`. A standalone probe of that path works on the RTX 4050: the GPU reads the view's pages through the placed buffer and sees a later CPU write with no copy. On the title it does not hold up yet. With it on, the per-frame `copystat` on the loading screen showed refreshes that checked nothing (in-place buffers), but **loading never finished**: 12 minutes on the loading screen and then no log lines at all (the process stayed up), where the same tree without it reached the world in about 5 minutes. My reading, not verified: a remap drops the shadow, but views already written into descriptor tables keep the old placed buffer, which still holds the pages it was opened over. A copy re-reads the current mapping at every submission; a buffer in place does not. So zero-copy for physical-page views needs the views that name a buffer to be remade when its pages are remapped, not only the shadow. Also: `UpdateTileMappings` onto a heap from `OpenExistingHeapFromAddress1` removed the device here; those heaps come back `SHARED | SHARED_CROSS_ADAPTER | ALLOW_SHADER_ATOMICS` (`0x421`), and tiled resources on cross-adapter heaps are not allowed, so buffers spanning several views cannot be stitched that way.
Author
Owner

@⁠MrEjecutor on GitHub · 2026-11-24 19:07 UTC · original

A measurement of reading title memory in place on NVIDIA (RTX 5060 Ti): the heap opens, but in this form it is slower than the copies, and with every eligible buffer it hangs the GPU

A data point for this design question, from a prototype on a fork (not for merging): https://github.com/MrEjecutor/VIctory/tree/inplace-prototype. It sits on ffe310e + #578 + MIN_DYNAMIC = 1 << 18 + #322 (no hang without it, see #747). Behind VICTORY_INPLACE=1, a title buffer inside one committed MEM_PRIVATE allocation gets a UAV-capable buffer placed in a heap opened over the title's own memory (ID3D12Device3::OpenExistingHeapFromAddress at the allocation base), and its refresh, write watch, snapshot and copy-back are skipped; everything else keeps the copied path. Physical-page views (MEM_MAPPED) are not covered.

Setup: RTX 5060 Ti 16 GB, driver 621.24; Intel Core Ultra 5 225F; 32 GB; Windows 11 26200; diag build, Rust 1.100.0; --console series-x; Enter every 10 s; 200–240 s runs.

What I found

  1. The heap opens, and placed buffers need D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER. The opened heap reports flags 0x621, type CUSTOM, WRITE_BACK, pool L0. Without the cross-adapter flag every CreatePlacedResource returned E_INVALIDARG (0x80070057). Placement also has to start on a 64 KiB boundary of the allocation, below the title buffer.
  2. With every eligible buffer in place (153–179 buffers), the GPU hangs. In 2 of 2 runs a submission took over 2 s (slow host submission ms=2570) and the device was removed with DXGI_ERROR_DEVICE_HUNG at ~62 s, still loading; DRED breadcrumbs all done.
  3. With only buffers of 16 MiB or more in place (2 buffers, 90 MB and 24 MB), it is stable, but slower. About 190–230 MB per frame are no longer refreshed, and the 90 MB MEM_PRIVATE range (the costliest private one, ~100 ms of copies in the top ranges) drops out of the copy statistics. But the world runs at 0.7 fps against 1.9–2.1 fps with the switch off in the same build, and preparing: copies is 600–970 ms against 60–150 ms. The remaining big copies (MEM_MAPPED) take about as long as before; I have not found where the extra time goes.

So on this NVIDIA card, opening title memory with OpenExistingHeapFromAddress and reading it in place is slower than VIctory's copies, at least for MEM_PRIVATE buffers placed this way. In-place reads may still win in another form; this only measures this one.

Not tested: MEM_MAPPED physical pages (78 % of the copied bytes here), OpenExistingHeapFromAddress1 or file-mapping heaps, other GPUs and AMD, why the copies got slower (my guess, unchecked: the driver handling the opened allocation's 4 KiB pages), more than 1–2 runs per configuration.

AI use: Claude Code (Claude Opus 5.5) and Codex (gpt-6-sol for the design, gpt-6-luna for the first version of the code), with Claude Code reviewing, fixing, building and running; checked by mrejecutor.

**@⁠MrEjecutor** on GitHub · 2026-11-24 19:07 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7141635935) **A measurement of reading title memory in place on NVIDIA (RTX 5060 Ti): the heap opens, but in this form it is slower than the copies, and with every eligible buffer it hangs the GPU** A data point for this design question, from a prototype on a fork (not for merging): https://github.com/MrEjecutor/VIctory/tree/inplace-prototype. It sits on `ffe310e` + #578 + `MIN_DYNAMIC = 1 << 18` + #322 (no hang without it, see #747). Behind `VICTORY_INPLACE=1`, a title buffer inside one committed `MEM_PRIVATE` allocation gets a UAV-capable buffer placed in a heap opened over the title's own memory (`ID3D12Device3::OpenExistingHeapFromAddress` at the allocation base), and its refresh, write watch, snapshot and copy-back are skipped; everything else keeps the copied path. Physical-page views (`MEM_MAPPED`) are not covered. **Setup:** RTX 5060 Ti 16 GB, driver 621.24; Intel Core Ultra 5 225F; 32 GB; Windows 11 26200; diag build, Rust 1.100.0; `--console series-x`; Enter every 10 s; 200–240 s runs. **What I found** 1. **The heap opens, and placed buffers need `D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER`.** The opened heap reports flags `0x621`, type CUSTOM, `WRITE_BACK`, pool L0. Without the cross-adapter flag every `CreatePlacedResource` returned `E_INVALIDARG` (`0x80070057`). Placement also has to start on a 64 KiB boundary of the allocation, below the title buffer. 2. **With every eligible buffer in place (153–179 buffers), the GPU hangs.** In 2 of 2 runs a submission took over 2 s (`slow host submission ms=2570`) and the device was removed with `DXGI_ERROR_DEVICE_HUNG` at ~62 s, still loading; DRED breadcrumbs all done. 3. **With only buffers of 16 MiB or more in place (2 buffers, 90 MB and 24 MB), it is stable, but slower.** About 190–230 MB per frame are no longer refreshed, and the 90 MB `MEM_PRIVATE` range (the costliest private one, ~100 ms of copies in the top ranges) drops out of the copy statistics. But the world runs at 0.7 fps against 1.9–2.1 fps with the switch off in the same build, and `preparing: copies` is 600–970 ms against 60–150 ms. The remaining big copies (`MEM_MAPPED`) take about as long as before; I have not found where the extra time goes. So on this NVIDIA card, opening title memory with `OpenExistingHeapFromAddress` and reading it in place is slower than VIctory's copies, at least for `MEM_PRIVATE` buffers placed this way. In-place reads may still win in another form; this only measures this one. **Not tested:** `MEM_MAPPED` physical pages (78 % of the copied bytes here), `OpenExistingHeapFromAddress1` or file-mapping heaps, other GPUs and AMD, why the copies got slower (my guess, unchecked: the driver handling the opened allocation's 4 KiB pages), more than 1–2 runs per configuration. **AI use:** Claude Code (Claude Opus 5.5) and Codex (gpt-6-sol for the design, gpt-6-luna for the first version of the code), with Claude Code reviewing, fixing, building and running; checked by mrejecutor.
Author
Owner

@⁠anasssssssss1 on GitHub · 2026-11-24 19:25 UTC · original

Measurements on a 6 GB / 16 GB laptop, to show where the memory goes. They support doing this in place rather than with copies.

Machine: RTX 4050 Laptop 6 GB, 15.2 GB RAM, Windows 11 26300.
Build: diag build of r4tedx integration/testers update 9 (94e0ea5) plus #1010, #1277 and #1433, --console series-s, first-mission world.

The process. Private bytes 20–22 GB, of which the working set is 2 GB. Free RAM is 0.3 GB, with about 37,000 page-ins/s and 190,000 page faults/s. Most of each 8–14 s world frame is spent waiting on the disk; the GPU is busy 0.4–0.9 s of it.

Where it goes. By VirtualQueryEx, grouped by type, protection and allocation size, plus the per-process GPU counters:

What Size
Title memory: physical-page views (mapped) 10.3 GB
Title memory: private 2.9 GB
Host side: write-combined allocations, mostly 31–32 MB blocks (~200) 9.2 GB
Host side: plain read-write (buffer copies of 1023 / 1004 / 766 / 339 / 2×174 MB, 4 MB chunks, heap) 8.9 GB
GPU counters: dedicated usage (card full) 5.2 GB
GPU counters: shared usage (system memory used by GPU resources) 6.3 GB

A diagnostic on Host::upload_buffer logged no allocation of 16 MB or more in 19 minutes. So the 31–32 MB write-combined blocks are not VIctory's own upload buffers. They are the title's resources that the driver moved out of the full card into system memory.

Copies per world frame (copystat):

  • 8,000 refreshes requesting 12.2 GB, of which 11.9 GB were unchanged.
  • 1,700 write-watch queries taking 0.4–0.5 s.
  • 0.7–1.2 million page faults.

Textures per world frame: 112 MB hashed, 0 changed. Staging buffers were kept per texture, and every list copied them into the card. Dropping the staging of textures that stay the same, and skipping their per-list copy, took texture preparation from 180–320 ms to under 2 ms per frame. That change is on a local branch and needs a longer run before a PR.

Prior art for in place. XCL (ivall/xcl, crates/xcl/src/gpu/uma.rs) keeps the title's graphics memory in up to four fully committed windows of up to 4095 MB each, opened with OpenExistingHeapFromAddress. Shaders reach memory by window (address >> 32 & 3) and 32-bit offset, with no per-buffer copies. Its notes say a heap must cover a fully committed allocation; a reservation with partial commit is rejected, which matches what I measured here. fxceless/victory-gta6 has a first stage of this behind VICTORY_INPLACE.

On a machine like this one the copies and the overflow out of the card are the whole frame, so I think this is the change that matters most for small machines.

No game data attached.

**@⁠anasssssssss1** on GitHub · 2026-11-24 19:25 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7142069725) Measurements on a 6 GB / 16 GB laptop, to show where the memory goes. They support doing this in place rather than with copies. **Machine:** RTX 4050 Laptop 6 GB, 15.2 GB RAM, Windows 11 26300. **Build:** diag build of r4tedx `integration/testers` update 9 (`94e0ea5`) plus #1010, #1277 and #1433, `--console series-s`, first-mission world. **The process.** Private bytes 20–22 GB, of which the working set is 2 GB. Free RAM is 0.3 GB, with about 37,000 page-ins/s and 190,000 page faults/s. Most of each 8–14 s world frame is spent waiting on the disk; the GPU is busy 0.4–0.9 s of it. **Where it goes.** By `VirtualQueryEx`, grouped by type, protection and allocation size, plus the per-process GPU counters: | What | Size | |---|---:| | Title memory: physical-page views (mapped) | 10.3 GB | | Title memory: private | 2.9 GB | | Host side: write-combined allocations, mostly 31–32 MB blocks (~200) | 9.2 GB | | Host side: plain read-write (buffer copies of 1023 / 1004 / 766 / 339 / 2×174 MB, 4 MB chunks, heap) | 8.9 GB | | GPU counters: dedicated usage (card full) | 5.2 GB | | GPU counters: shared usage (system memory used by GPU resources) | 6.3 GB | A diagnostic on `Host::upload_buffer` logged no allocation of 16 MB or more in 19 minutes. So the 31–32 MB write-combined blocks are not VIctory's own upload buffers. They are the title's resources that the driver moved out of the full card into system memory. **Copies per world frame** (copystat): - 8,000 refreshes requesting 12.2 GB, of which 11.9 GB were unchanged. - 1,700 write-watch queries taking 0.4–0.5 s. - 0.7–1.2 million page faults. **Textures per world frame:** 112 MB hashed, 0 changed. Staging buffers were kept per texture, and every list copied them into the card. Dropping the staging of textures that stay the same, and skipping their per-list copy, took texture preparation from 180–320 ms to under 2 ms per frame. That change is on a local branch and needs a longer run before a PR. **Prior art for in place.** XCL (`ivall/xcl`, `crates/xcl/src/gpu/uma.rs`) keeps the title's graphics memory in up to four fully committed windows of up to 4095 MB each, opened with `OpenExistingHeapFromAddress`. Shaders reach memory by window (`address >> 32 & 3`) and 32-bit offset, with no per-buffer copies. Its notes say a heap must cover a fully committed allocation; a reservation with partial commit is rejected, which matches what I measured here. `fxceless/victory-gta6` has a first stage of this behind `VICTORY_INPLACE`. On a machine like this one the copies and the overflow out of the card are the whole frame, so I think this is the change that matters most for small machines. No game data attached.
Author
Owner

@⁠Witredd on GitHub · 2026-11-25 00:05 UTC · original

An AMD data point for the in-place route, from @⁠MrEjecutor's inplace-prototype (aec1b40) run as is with VICTORY_INPLACE=1 (default 16 MiB minimum).

RX 5600 XT 6 GB (RDNA1, driver 32.0.21045.16010), Ryzen 7 5700X, 16 GB RAM, Windows 11. The card has no mesh shaders, so the branch is merged locally with #961, plus #1296 at VICTORY_TEXTURE_MIP_DROP=2 (all on ffe310e; the conflicts were only imports and struct fields). Memory is the process's GPU Process Memory counters, sampled every 2 s.

  • The heap opens on AMD: in-place heap opened size=2305818624 flags=0x621 kind=4 cpu_page=3 pool=1, and two title buffers (90 MiB and 24 MiB) went in place. Five others were refused with reason=Mapped, as the prototype intends.
  • But each heap covers the whole 2.15 GiB allocation, and the process's shared GPU usage grew by about that much each time: 2.1 → 4.7 GB within 3 s of the first heap opened line, then → 7.4 GB within 3 s of the second. With 16 GB RAM the shared limit is about 8 GB, so the next allocations failed (no shared buffer, then a host command list did not close (0x8007000E)).
  • What it did save: without in-place the same build fails on dedicated memory (thousands of no shader-writable buffer, dedicated at 5.8 of 6 GB); with it there were 2 of those and dedicated peaked at 5.6 GB.

So on a 16 GB host, opening the whole allocation costs more shared memory than it saves in copies. Opening only the buffer's range (OpenExistingHeapFromAddress1 with a sub-range, as this issue mentions) looks needed for it to help low-memory machines.

**@⁠Witredd** on GitHub · 2026-11-25 00:05 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7148130980) An AMD data point for the in-place route, from @⁠MrEjecutor's `inplace-prototype` (`aec1b40`) run as is with `VICTORY_INPLACE=1` (default 16 MiB minimum). RX 5600 XT 6 GB (RDNA1, driver 32.0.21045.16010), Ryzen 7 5700X, 16 GB RAM, Windows 11. The card has no mesh shaders, so the branch is merged locally with #961, plus #1296 at `VICTORY_TEXTURE_MIP_DROP=2` (all on `ffe310e`; the conflicts were only imports and struct fields). Memory is the process's `GPU Process Memory` counters, sampled every 2 s. - **The heap opens on AMD:** `in-place heap opened size=2305818624 flags=0x621 kind=4 cpu_page=3 pool=1`, and two title buffers (90 MiB and 24 MiB) went in place. Five others were refused with `reason=Mapped`, as the prototype intends. - **But each heap covers the whole 2.15 GiB allocation, and the process's shared GPU usage grew by about that much each time:** 2.1 → 4.7 GB within 3 s of the first `heap opened` line, then → 7.4 GB within 3 s of the second. With 16 GB RAM the shared limit is about 8 GB, so the next allocations failed (`no shared buffer`, then `a host command list did not close (0x8007000E)`). - What it did save: without in-place the same build fails on dedicated memory (thousands of `no shader-writable buffer`, dedicated at 5.8 of 6 GB); with it there were 2 of those and dedicated peaked at 5.6 GB. So on a 16 GB host, opening the whole allocation costs more shared memory than it saves in copies. Opening only the buffer's range (`OpenExistingHeapFromAddress1` with a sub-range, as this issue mentions) looks needed for it to help low-memory machines.
Author
Owner

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

A data point for this design: OpenExistingHeapFromAddress works under Wine with vkd3d-proton on NVIDIA (RTX 5080, proton-cachyos 11.0, vkd3d-proton 3.2.0). It worked on all three kinds of memory VIctory gives the title: a plain VirtualAlloc, a write-watched VirtualAlloc, and a view of a section (also a second view of the same section). The GPU wrote to a buffer placed in such a heap, and the CPU read the result right away at the right offset. The address has to be the allocation's base; a buffer is then placed at its offset.

#2112 uses it, opt-in (VICTORY_IN_PLACE=1), for loose windows only. While Grand Theft Auto VI loads its world, their host memory goes from about 3.4 GB (main) to 79 MB: 1,448 windows in place, none refused, no device errors. Title buffer objects (about 1.2 GB here) are still copied.

**@⁠desplmfao** on GitHub · 2026-11-25 05:12 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7153546995) A data point for this design: `OpenExistingHeapFromAddress` works under Wine with vkd3d-proton on NVIDIA (RTX 5080, proton-cachyos 11.0, vkd3d-proton 3.2.0). It worked on all three kinds of memory VIctory gives the title: a plain `VirtualAlloc`, a write-watched `VirtualAlloc`, and a view of a section (also a second view of the same section). The GPU wrote to a buffer placed in such a heap, and the CPU read the result right away at the right offset. The address has to be the allocation's base; a buffer is then placed at its offset. #2112 uses it, opt-in (`VICTORY_IN_PLACE=1`), for loose windows only. While Grand Theft Auto VI loads its world, their host memory goes from about 3.4 GB (`main`) to 79 MB: 1,448 windows in place, none refused, no device errors. Title buffer objects (about 1.2 GB here) are still copied.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:53 UTC · original

Automated triage for the maintainers.

This is a design question for the maintainer about the GPU memory model (reading title memory in place instead of the host copies kept in crates/victory-gpu), so it stays open for that decision. The same direction is being discussed in #407, which is where the design discussion should be kept together; the measurements in this thread (sub-range heaps, the refusal of partly committed sections and of sections of 4 GiB or more, the NVIDIA tile-mapping device removal, the shared-memory growth on AMD, and the slower in-place reads on an RTX 5060 Ti) are useful there too. Open pull request #2112 already uses OpenExistingHeapFromAddress opt-in (VICTORY_IN_PLACE=1) for loose windows. It fits the project's scope.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:53 UTC · [original](https://github.com/Marvisak/VIctory/issues/880#issuecomment-7155260210) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T05:12:21Z at=2026-11-25T06:53:08Z --> Automated triage for the maintainers. This is a design question for the maintainer about the GPU memory model (reading title memory in place instead of the host copies kept in `crates/victory-gpu`), so it stays open for that decision. The same direction is being discussed in #407, which is where the design discussion should be kept together; the measurements in this thread (sub-range heaps, the refusal of partly committed sections and of sections of 4 GiB or more, the NVIDIA tile-mapping device removal, the shared-memory growth on AMD, and the slower in-place reads on an RTX 5060 Ti) are useful there too. Open pull request #2112 already uses `OpenExistingHeapFromAddress` opt-in (`VICTORY_IN_PLACE=1`) for loose windows. It fits the project's scope. --- _Generated by [Claude Code](https://claude.ai/code)_
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#880
No description provided.