Measured: GPU access to physical pages in place (SEC_COMMIT sections ≤ 4095 MB, aliases, physical page table) – no game data #1147

Open
opened 2026-11-26 04:21:07 +00:00 by github-bot · 2 comments
Owner

@⁠quzopl on GitHub · 2026-11-24 16:13 UTC · original

Measurements only, no game data and no title run. A synthetic probe on this machine, to answer one question: can the GPU read and write title memory in place (no copies, no write watch) under VIctory's physical-page model, aliases included?

Short answer: yes, if the GPU addresses physical slices through a page table. Two constraints apply. Sections must be SEC_COMMIT, not SEC_RESERVE, and each must be at most 4095 MB. Bandwidth is that of system memory.

Machine

  • Windows 11 Pro 10.0.26200, 64 GB RAM, TDR left at the Windows default (2 s).
  • RTX 5080 and RTX 4070 Ti (driver 32.0.16.1692), Intel UHD 770.
  • No AMD card.

Method

This mirrors xmem.rs: 64 KiB slices of a pagefile-backed section, mapped in runs into placeholders with MapViewOfFile3(MEM_REPLACE_PLACEHOLDER).

  1. Import the section once with ID3D12Device3::OpenExistingHeapFromFileMapping.
  2. Place raw-UAV buffers over the heap in 1 GiB pieces.
  3. Map the same slices at two aliases, A and B. Each alias is a placeholder split into runs, and the two use different run orders.
  4. The cs_6_6 shader sees only a physical page table: logical page → (descriptor index, byte offset of the slice). It reads through ResourceDescriptorHeap[NonUniformResourceIndex(..)].
  5. Access is scattered. Logical dword j is visited through an odd-multiplier bijection, so neighbouring lanes hit different slices.
  6. The shader stores Load*3 + add + j. The + j tags the logical address, so a wrong page→slice link shows up on the CPU.

Results

The RTX 5080, RTX 4070 Ti and UHD 770 gave identical results. The device was not removed in any run.

Case Result
SEC_RESERVE section, every page committed through a view → OpenExistingHeapFromFileMapping E_INVALIDARG (matches what XCL's HANDOFF reports)
SEC_COMMIT section → OpenExistingHeapFromFileMapping OK
SEC_COMMIT → OpenExistingHeapFromAddress on a plain view, and on a view that replaced a placeholder OK, OK
SEC_COMMIT size limit for a heap 4095 MB OK; 4096, 4097, 5120 and 6400 MB E_INVALIDARG
256 MB section, 64 KB views: CPU writes via A → GPU → CPU reads via B 0 wrong of 16 777 216 dwords
Same, reversed (CPU rewrites via B → GPU → CPU reads via A) 0 wrong
4095 MB section, data ~4 GB in (slice 64 432), 2 MB views, both directions 0 wrong
Negative control: table shifted by one page every dword wrong, as expected

Costs:

  • Heap plus four placed buffers over 4095 MB: 0.46–0.67 s.
  • 2 048 views of 64 KB mapped in ~2 ms.
  • SEC_COMMIT charges the whole section at creation.

Bandwidth

This is the part that limits the idea. These figures come from a companion run: private placeholder chunks, each imported with OpenExistingHeapFromAddress, same scattered shader.

RTX 5080 RTX 4070 Ti
imported system memory, scattered access 0.3–0.4 GB/s 0.4 GB/s
video-memory buffers, same shader (control) 22–24 GB/s –
imported system memory, sequential access ~10 GB/s ~10 GB/s

A scattered 2 GB pass took 3.1 s on the 4070 Ti, and the device was removed (0x887A0006, past TDR). The same pass over 128 MB was correct. The cause is dispatch length, not the import.

Other facts from that run:

  • 65 536 chunks of 64 KB imported (0.1–0.2 ms each).
  • A chunk must be committed whole. Only an allocation base imports.
  • MEM_WRITE_WATCH chunks import.

What it suggests for VIctory

  • Aliasing stops mattering once the GPU addresses physical slices: one table entry per logical page, and no copy of title memory for what the GPU reads or writes there. That is what watch.rs handles today with write watch and guarded blocks.
  • It needs two changes to XMemAllocatePhysicalPages:
    • SEC_COMMIT sections, with full commit at allocation. xmem.rs avoids this on purpose because of error 1450 on busy hosts.
    • At most 4095 MB per section. A 6.1 GiB request becomes two sections, which slices hide from the title.
  • It does not replace video memory for hot data. At ~0.3 GB/s scattered, it suits making memory visible, not render targets or frequently read buffers.
  • ResourceDescriptorHeap[] indexing in large real shaders is a known NVIDIA risk: XCL #680 reports the driver's compiler ending the process. The probe's shader is small.

Not tested

  • Unmapping a view or closing a section while the GPU uses its heap.
  • Many sections at once.
  • Wine.
  • AMD.
  • Textures, vertex and index buffers, graphics pipelines.
  • Any title run.

The probe is ~800 lines of Rust and two small shaders, written for this test, and I can share it if it's useful.

AI-assisted: the probe and this write-up were done with Claude Code. The numbers are from runs on the hardware above.

**@⁠quzopl** on GitHub · 2026-11-24 16:13 UTC · [original](https://github.com/Marvisak/VIctory/issues/1147) Measurements only, no game data and no title run. A synthetic probe on this machine, to answer one question: can the GPU read and write title memory **in place** (no copies, no write watch) under VIctory's physical-page model, aliases included? **Short answer:** yes, if the GPU addresses physical slices through a page table. Two constraints apply. Sections must be `SEC_COMMIT`, not `SEC_RESERVE`, and each must be at most 4095 MB. Bandwidth is that of system memory. ### Machine - Windows 11 Pro 10.0.26200, 64 GB RAM, TDR left at the Windows default (2 s). - RTX 5080 and RTX 4070 Ti (driver 32.0.16.1692), Intel UHD 770. - No AMD card. ### Method This mirrors `xmem.rs`: 64 KiB slices of a pagefile-backed section, mapped in runs into placeholders with `MapViewOfFile3(MEM_REPLACE_PLACEHOLDER)`. 1. Import the section once with `ID3D12Device3::OpenExistingHeapFromFileMapping`. 2. Place raw-UAV buffers over the heap in 1 GiB pieces. 3. Map the same slices at two aliases, A and B. Each alias is a placeholder split into runs, and the two use different run orders. 4. The cs_6_6 shader sees only a **physical page table**: logical page → (descriptor index, byte offset of the slice). It reads through `ResourceDescriptorHeap[NonUniformResourceIndex(..)]`. 5. Access is scattered. Logical dword `j` is visited through an odd-multiplier bijection, so neighbouring lanes hit different slices. 6. The shader stores `Load*3 + add + j`. The `+ j` tags the logical address, so a wrong page→slice link shows up on the CPU. ### Results The RTX 5080, RTX 4070 Ti and UHD 770 gave identical results. The device was not removed in any run. | Case | Result | |---|---| | `SEC_RESERVE` section, every page committed through a view → `OpenExistingHeapFromFileMapping` | **E_INVALIDARG** (matches what XCL's HANDOFF reports) | | `SEC_COMMIT` section → `OpenExistingHeapFromFileMapping` | OK | | `SEC_COMMIT` → `OpenExistingHeapFromAddress` on a plain view, and on a view that replaced a placeholder | OK, OK | | `SEC_COMMIT` size limit for a heap | **4095 MB OK; 4096, 4097, 5120 and 6400 MB E_INVALIDARG** | | 256 MB section, 64 KB views: CPU writes via A → GPU → CPU reads via B | 0 wrong of 16 777 216 dwords | | Same, reversed (CPU rewrites via B → GPU → CPU reads via A) | 0 wrong | | 4095 MB section, data ~4 GB in (slice 64 432), 2 MB views, both directions | 0 wrong | | Negative control: table shifted by one page | every dword wrong, as expected | Costs: - Heap plus four placed buffers over 4095 MB: 0.46–0.67 s. - 2 048 views of 64 KB mapped in ~2 ms. - `SEC_COMMIT` charges the whole section at creation. ### Bandwidth This is the part that limits the idea. These figures come from a companion run: private placeholder chunks, each imported with `OpenExistingHeapFromAddress`, same scattered shader. | | RTX 5080 | RTX 4070 Ti | |---|---|---| | imported system memory, scattered access | 0.3–0.4 GB/s | 0.4 GB/s | | video-memory buffers, same shader (control) | 22–24 GB/s | – | | imported system memory, sequential access | ~10 GB/s | ~10 GB/s | A scattered 2 GB pass took 3.1 s on the 4070 Ti, and the device was removed (`0x887A0006`, past TDR). The same pass over 128 MB was correct. The cause is dispatch length, not the import. Other facts from that run: - 65 536 chunks of 64 KB imported (0.1–0.2 ms each). - A chunk must be committed whole. Only an allocation base imports. - `MEM_WRITE_WATCH` chunks import. ### What it suggests for VIctory - Aliasing stops mattering once the GPU addresses physical slices: one table entry per logical page, and no copy of title memory for what the GPU reads or writes there. That is what `watch.rs` handles today with write watch and guarded blocks. - It needs two changes to `XMemAllocatePhysicalPages`: - `SEC_COMMIT` sections, with full commit at allocation. `xmem.rs` avoids this on purpose because of error 1450 on busy hosts. - At most 4095 MB per section. A 6.1 GiB request becomes two sections, which slices hide from the title. - It does not replace video memory for hot data. At ~0.3 GB/s scattered, it suits making memory *visible*, not render targets or frequently read buffers. - `ResourceDescriptorHeap[]` indexing in large real shaders is a known NVIDIA risk: XCL #680 reports the driver's compiler ending the process. The probe's shader is small. ### Not tested - Unmapping a view or closing a section while the GPU uses its heap. - Many sections at once. - Wine. - AMD. - Textures, vertex and index buffers, graphics pipelines. - Any title run. The probe is ~800 lines of Rust and two small shaders, written for this test, and I can share it if it's useful. AI-assisted: the probe and this write-up were done with Claude Code. The numbers are from runs on the hardware above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:21:07 +00:00
Author
Owner

@⁠pickles976 on GitHub · 2026-11-24 16:15 UTC · original

Second-machine confirmation, three years of prior art, and one design question.

  • Constraints confirmed independently. ivall/xcl runs the same physical-in-place model at scale (gpu/uma.rs — the title's console addresses are kept in regions D3D12 opens as heaps via OpenExistingHeapFromAddress, GPU works on them directly, no copies). Our measured constraint table from 2026-11-20 on Windows 11 + RX 9070 matches yours on both axes: fully committed sections only (a reservation with partial commit is rejected — the SEC_RESERVE vs SEC_COMMIT finding, reproduced) and 4095 MiB opens, exactly 4 GiB is rejected — hard enough that our constant is literally (4096 << 20) - 64 KiB (MAX_SIZE), with the side note that the rejected 4 GiB open still costs ~0.5 s to fail, so probing upward is expensive to get wrong. Two vendors (AMD/RDNA3 + your NVIDIA), two machines: treat the 4095 MiB ceiling and the commit requirement as platform facts, not driver quirks — no runtime should build a model that assumes they might not apply.
  • The design consequence you'll recognize: a 4 GiB heap ceiling does not mean a 4 GiB address-space ceiling — we get around it with windowed aliasing: base 16 GiB-aligned, window k at base + k·4 GiB, window index = (address >> 32) & 3, allocations never straddle (4 windows, so 16 GiB of console GPU addresses per run; the recompiler emits per-window mem/mem1… buffers). Your page-table result says the same problem solved one level down: with a real GPU-side page table the ceiling moves from heap-per-region to section-per-slice, and straddling becomes free. Worth being explicit in your issue which API your probe used for GPU visibility (OpenExistingHeapFromAddress-class vs an actual page-table path) — the ceiling you measured may be a property of the visibility API, not of the page table: our 4095 MiB is exactly the former's limit, so if your ≤4095 MB finding came through a section-open path, the page-table conclusion ("straddle freely") is supported by your alias rows more than by your size rows.
  • One transferable gotcha either way: OpenExistingHeapFromAddress needs the whole window committed up front — lazy commit is a rejected-state risk, not a perf option. If your physical-page model starts from SEC_RESERVE for sparse title memory, that transition (reserve → commit before GPU visibility) is where runs will die in debug builds and mysteriously pass in ones that pre-commit everything.
**@⁠pickles976** on GitHub · 2026-11-24 16:15 UTC · [original](https://github.com/Marvisak/VIctory/issues/1147#issuecomment-7137382161) **Second-machine confirmation, three years of prior art, and one design question.** - **Constraints confirmed independently.** ivall/xcl runs the same physical-in-place model at scale (`gpu/uma.rs` — the title's console addresses are kept in regions D3D12 opens as heaps via `OpenExistingHeapFromAddress`, GPU works on them directly, no copies). Our measured constraint table from 2026-11-20 on Windows 11 + RX 9070 matches yours on both axes: **fully committed sections only** (a reservation with partial commit is **rejected** — the SEC_RESERVE vs SEC_COMMIT finding, reproduced) and **4095 MiB opens, exactly 4 GiB is rejected** — hard enough that our constant is literally `(4096 << 20) - 64 KiB` (`MAX_SIZE`), with the side note that the rejected 4 GiB open still costs ~0.5 s to fail, so probing upward is expensive to get wrong. Two vendors (AMD/RDNA3 + your NVIDIA), two machines: treat the 4095 MiB ceiling and the commit requirement as **platform facts**, not driver quirks — no runtime should build a model that assumes they might not apply. - **The design consequence you'll recognize:** a 4 GiB heap ceiling does not mean a 4 GiB address-space ceiling — we get around it with **windowed aliasing**: base 16 GiB-aligned, window *k* at `base + k·4 GiB`, window index = `(address >> 32) & 3`, allocations never straddle (4 windows, so 16 GiB of console GPU addresses per run; the recompiler emits per-window `mem`/`mem1`… buffers). Your page-table result says the same problem solved one level down: with a real GPU-side page table the ceiling moves from *heap-per-region* to *section-per-slice*, and straddling becomes free. Worth being explicit in your issue which API your probe used for GPU visibility (`OpenExistingHeapFromAddress`-class vs an actual page-table path) — the ceiling you measured may be a property of the **visibility API**, not of the page table: our 4095 MiB is exactly the former's limit, so if your ≤4095 MB finding came through a section-open path, the page-table conclusion ("straddle freely") is supported by your alias rows more than by your size rows. - One transferable gotcha either way: `OpenExistingHeapFromAddress` needs the **whole window committed up front** — lazy commit is a rejected-state risk, not a perf option. If your physical-page model starts from SEC_RESERVE for sparse title memory, that transition (reserve → commit before GPU visibility) is where runs will die in debug builds and mysteriously pass in ones that pre-commit everything.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:08 UTC · original

Automated triage for the maintainers.

Thanks for the synthetic measurements (no title run, no game data). They fit the project's scope as design input for how the GPU sees title memory.

One check against main: XMemAllocatePhysicalPages in crates/victory-hle/src/modules/xmem.rs creates its section with SEC_RESERVE on Windows and SEC_COMMIT only under Wine, because committing 6.1 GiB at once often fails with error 1450 on busy hosts. So the two preconditions you found (SEC_COMMIT and at most 4095 MB per section) would both need changes there. Today main still works with copies: since cd94d35, shaders mark the 64 KiB pages they write through views and copy-backs compare only those pages (crate::shadow::copy_back_marks). Open PR #2088 also changes how loose title memory is copied.

Your bandwidth numbers (about 0.3-0.4 GB/s for scattered access to imported system memory) are the main open question for in-place access. This stays open for the maintainers as tracked design input.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:08 UTC · [original](https://github.com/Marvisak/VIctory/issues/1147#issuecomment-7159271600) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T16:15:58Z at=2026-11-25T09:50:38Z --> Automated triage for the maintainers. Thanks for the synthetic measurements (no title run, no game data). They fit the project's scope as design input for how the GPU sees title memory. One check against `main`: `XMemAllocatePhysicalPages` in `crates/victory-hle/src/modules/xmem.rs` creates its section with `SEC_RESERVE` on Windows and `SEC_COMMIT` only under Wine, because committing 6.1 GiB at once often fails with error 1450 on busy hosts. So the two preconditions you found (`SEC_COMMIT` and at most 4095 MB per section) would both need changes there. Today `main` still works with copies: since cd94d35, shaders mark the 64 KiB pages they write through views and copy-backs compare only those pages (`crate::shadow::copy_back_marks`). Open PR #2088 also changes how loose title memory is copied. Your bandwidth numbers (about 0.3-0.4 GB/s for scattered access to imported system memory) are the main open question for in-place access. This stays open for the maintainers as tracked design input. --- _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#1147
No description provided.