xmem: memory the GPU reads in place must survive protection changes and remaps (no re-import, no 1 s hitch) #1905

Open
opened 2026-11-26 04:48:11 +00:00 by github-bot · 4 comments
Owner

@⁠leonardocfirmino on GitHub · 2026-11-25 00:31 UTC · original

What

#407 (and #880) would have shaders read title memory where it already is, instead of through a host copy. That turns every title remap from a copy-problem into an import-lifetime problem, and this issue is that part: the memory the GPU reads in place has to survive the protections and remaps the title applies to it.

It has no owner yet and it decides whether #407 is workable at all, so it is worth separating from the memory model itself.

What the title does

From the same runs as #880 and the probes in #407:

  • XMemVirtualAlloc with MEM_RESERVE_PLACEHOLDER, then repeated protection changes: a 16 KiB guard page mprotect inside a live range is normal (a stack guard), and it lands inside memory a shader may be reading.
  • XMemMapPhysicalPages, XMemMapPhysicalPagesScatter and the GPU's CopyPageMappingsBatchX move pages around in place. On the world's 174 MB view one runtime refresh is once per submission, about 20 times a frame.
  • XMemFreePhysicalPages and unmaps underneath live views.

Why it breaks with an arena

xmem keeps its addresses by mapping over placeholders (MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER, then MapViewOfFile3(..., MEM_REPLACE_PLACEHOLDER)), so the guest VA survives a remap today — the address is not the problem.

With the arena the backing is imported host memory, an import covers one contiguous committed run, and the host refuses overlap. So a protection change or remap that splits a live imported run forces:

  1. splitting the import into pieces around the split point,
  2. a new OpenExistingHeapFromAddress/FromFileMapping (and a new placed resource) per piece,
  3. either a tile remap or a fresh resource at the boundary,
  4. victory_gpu::title_memory_remapped, which drops the guards, so anything per-submission repeats at that rate.

What that costs when it re-imports instead of remapping, measured on the project that already does in-place reads (AnyPS5, Astro Bot, RX 9070 XT, PCIe 3.0 x16): a single 16 KiB guard page mprotect inside a live import split it, and rebuilding the pieces re-imported ~1 GB with the GPU idle, ~1 s of hitches. At 20 refreshes of one 174 MB view per frame, a per-submission re-import is not survivable.

Also unanswered: whether an imported heap tolerates MEM_RESERVE_PLACEHOLDER/MapViewOfFile3 at all when the address is already inside one, and whether tile mappings can be moved between imports of the same memory cheaply (UpdateTileMappings from the old heap to the new one instead of recreating the resource).

What a test would look like

Synthetic, victory-gpu plus the xmem module, no title:

  1. import 64 MiB of one allocation,
  2. XMemVirtualProtect a 16 KiB guard in the middle, then back,
  3. remap a range in the middle elsewhere and back,
  4. remap a neighbouring range while the first is live,
  5. assert the guest VA is unchanged, the bytes are correct on both sides of every boundary, and a shader still reads through the imported address,
  6. count imports created and resources rebuilt (the number that must stay at 1), and time the worst step.

Skips without a host GPU; the count and the timings run on the same adapters #407's probe uses.

Proposal, roughly

  • An allocation that the GPU can see is imported once, and remaps inside it are answered with section views and tile mappings on that one import, not with a new import.
  • Splitting happens at the arena's level, not the host's: a piece keeps the parent's import and takes its own range, so title_memory_remapped invalidates only the pages it names.
  • A guard page never splits an import — the range keeps PAGE_READWRITE for the GPU and the guest-side guard is emulated by watch.rs's fault handler, which already takes the first write to a block and gives access back.
  • Where a host refuses a remap on an imported range, fall back to the copy for that allocation and say so once per allocation.

Open questions

  • Does a D3D12 import admit the MEM_REPLACE_PLACEHOLDER dance xmem relies on, or must the mapping be created before the import?
  • Is UpdateTileMappings between two imports of the same memory cheaper than recreating the placed resource, and by how much?
  • Does VRAM residency survive the remap (the pages a shader reads may move under it mid-frame)?
  • Guard pages: is the emulated guard acceptable to the title's own fault handler, which reads XMemVirtualQuery protection to decide what it can touch?

Related: #407, #880, #76, #167.

**@⁠leonardocfirmino** on GitHub · 2026-11-25 00:31 UTC · [original](https://github.com/Marvisak/VIctory/issues/1905) ## What #407 (and #880) would have shaders read title memory where it already is, instead of through a host copy. That turns every title remap from a copy-problem into an import-lifetime problem, and this issue is that part: the memory the GPU reads in place has to survive the protections and remaps the title applies to it. It has no owner yet and it decides whether #407 is workable at all, so it is worth separating from the memory model itself. ## What the title does From the same runs as #880 and the probes in #407: - `XMemVirtualAlloc` with `MEM_RESERVE_PLACEHOLDER`, then repeated protection changes: a 16 KiB guard page `mprotect` inside a live range is normal (a stack guard), and it lands *inside* memory a shader may be reading. - `XMemMapPhysicalPages`, `XMemMapPhysicalPagesScatter` and the GPU's `CopyPageMappingsBatchX` move pages around in place. On the world's 174 MB view one runtime refresh is once per submission, about 20 times a frame. - `XMemFreePhysicalPages` and unmaps underneath live views. ## Why it breaks with an arena `xmem` keeps its addresses by mapping over placeholders (`MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER`, then `MapViewOfFile3(..., MEM_REPLACE_PLACEHOLDER)`), so the guest VA survives a remap today — the *address* is not the problem. With the arena the backing is imported host memory, an import covers one contiguous committed run, and the host refuses overlap. So a protection change or remap that splits a live imported run forces: 1. splitting the import into pieces around the split point, 2. a new `OpenExistingHeapFromAddress`/`FromFileMapping` (and a new placed resource) per piece, 3. either a tile remap or a fresh resource at the boundary, 4. `victory_gpu::title_memory_remapped`, which drops the guards, so anything per-submission repeats at that rate. What that costs when it re-imports instead of remapping, measured on the project that already does in-place reads (AnyPS5, Astro Bot, RX 9070 XT, PCIe 3.0 x16): a single 16 KiB guard page `mprotect` inside a live import split it, and rebuilding the pieces re-imported **~1 GB with the GPU idle, ~1 s of hitches**. At 20 refreshes of one 174 MB view per frame, a per-submission re-import is not survivable. Also unanswered: whether an imported heap tolerates `MEM_RESERVE_PLACEHOLDER`/`MapViewOfFile3` at all when the address is already inside one, and whether tile mappings can be moved between imports of the same memory cheaply (`UpdateTileMappings` from the old heap to the new one instead of recreating the resource). ## What a test would look like Synthetic, `victory-gpu` plus the xmem module, no title: 1. import 64 MiB of one allocation, 2. `XMemVirtualProtect` a 16 KiB guard in the middle, then back, 3. remap a range in the middle elsewhere and back, 4. remap a neighbouring range while the first is live, 5. assert the guest VA is unchanged, the bytes are correct on both sides of every boundary, and a shader still reads through the imported address, 6. count imports created and resources rebuilt (the number that must stay at 1), and time the worst step. Skips without a host GPU; the count and the timings run on the same adapters #407's probe uses. ## Proposal, roughly - An allocation that the GPU can see is imported **once**, and remaps inside it are answered with section views and tile mappings on that one import, not with a new import. - Splitting happens at the arena's level, not the host's: a piece keeps the parent's import and takes its own range, so `title_memory_remapped` invalidates only the pages it names. - A guard page never splits an import — the range keeps `PAGE_READWRITE` for the GPU and the guest-side guard is emulated by `watch.rs`'s fault handler, which already takes the first write to a block and gives access back. - Where a host refuses a remap on an imported range, fall back to the copy for that allocation and say so once per allocation. ## Open questions - Does a D3D12 import admit the `MEM_REPLACE_PLACEHOLDER` dance `xmem` relies on, or must the mapping be created before the import? - Is `UpdateTileMappings` between two imports of the same memory cheaper than recreating the placed resource, and by how much? - Does VRAM residency survive the remap (the pages a shader reads may move under it mid-frame)? - Guard pages: is the emulated guard acceptable to the title's own fault handler, which reads `XMemVirtualQuery` protection to decide what it can touch? Related: #407, #880, #76, #167.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:48:12 +00:00
Author
Owner

@⁠fiestorra on GitHub · 2026-11-25 01:32 UTC · original

Taking one concrete part of this, and naming its limits so nobody expects the whole thing

The issue is right that this decides whether #407 is workable, and it says it has no owner. I am taking one part of it, scoped to what can be measured and tested in this repository today:

A live range that the GPU reads in place has to survive a protection change and a remap, and I want a test that says so (or says it does not) without the title.

Concretely, the first piece is a synthetic test in victory-gpu that walks the two cases the title performs, with memory the host has mapped for the GPU:

  1. a 16 KiB guard page mprotect in the middle of a live range — the stack guard the issue describes — and a read of the range on either side of it;
  2. a remap: MEM_RESERVE_PLACEHOLDER freed and re-reserved under a live view, checking what the GPU sees afterwards and whether the import still names the same memory.

What that gives, either way, is the thing the issue is missing: a number. Today the answer is "it depends on whether the copy survives", and after the test it is either "a live range survives a protection change, here is the test" or "it does not, here is the exact step that loses it" — and only then is it worth talking about import lifetimes, host copies and the 1 s hitch.

What I am not taking, and will not claim:

  • the copy → import change itself (#407's direction), which needs the answer above first;
  • the 1 s hitch, which belongs to whoever reshapes the memory model;
  • anything that needs the title to move between regions and protections over minutes rather than seconds — the test can only do the two shapes above, which is why I am scoping it that way rather than pretending to emulate the title.

If someone is already further along on the import-lifetime side, say so and I will hand this test over rather than duplicate it — the test is useful either way and does not depend on which way the memory model goes.

No game data is involved: page sizes, protections and counts.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-25 01:32 UTC · [original](https://github.com/Marvisak/VIctory/issues/1905#issuecomment-7149660402) **Taking one concrete part of this, and naming its limits so nobody expects the whole thing** The issue is right that this decides whether #407 is workable, and it says it has no owner. I am taking **one part** of it, scoped to what can be measured and tested in this repository today: > **A live range that the GPU reads in place has to survive a protection change and a remap, and I want a test that says so (or says it does not) without the title.** Concretely, the first piece is a synthetic test in `victory-gpu` that walks the two cases the title performs, with memory the host has mapped for the GPU: 1. a 16 KiB **guard page** `mprotect` in the middle of a live range — the stack guard the issue describes — and a read of the range on either side of it; 2. a **remap**: `MEM_RESERVE_PLACEHOLDER` freed and re-reserved under a live view, checking what the GPU sees afterwards and whether the import still names the same memory. What that gives, either way, is the thing the issue is missing: a number. Today the answer is "it depends on whether the copy survives", and after the test it is either "a live range survives a protection change, here is the test" or "it does not, here is the exact step that loses it" — and only then is it worth talking about import lifetimes, host copies and the 1 s hitch. What I am **not** taking, and will not claim: - the copy → import change itself (#407's direction), which needs the answer above first; - the 1 s hitch, which belongs to whoever reshapes the memory model; - anything that needs the title to move between regions and protections over minutes rather than seconds — the test can only do the two shapes above, which is why I am scoping it that way rather than pretending to emulate the title. If someone is already further along on the import-lifetime side, say so and I will hand this test over rather than duplicate it — the test is useful either way and does not depend on which way the memory model goes. No game data is involved: page sizes, protections and counts. Written with an AI assistant.
Author
Owner

@⁠fiestorra on GitHub · 2026-11-25 01:35 UTC · original

The guard page half holds; the remap half does not, and that is the finding

I wrote the test I claimed, against the model xmem.rs already keeps (physical pages, XMemVirtualAlloc reservations of 64 KiB pages, XMemMapPhysicalPages), and it answers both halves of the question rather than one.

A 16 KiB PAGE_NOACCESS change inside a live range is fine. The change is accepted on a range that physical pages are mapped into, the pages on both sides keep their bytes across it and across the change back, and the run model still sees the range as one run. So a stack guard appearing in the middle of memory the GPU is reading is not, by itself, a problem for the direction #407 wants to take.

A remap of half a live range is refused. Concretely:

MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER on half of a live range  ->  0

A range that physical pages are mapped into is no longer a placeholder, so the title's "free half of it, reserve it again, map new pages there" step fails before any GPU read happens. Nothing moves, the range still reads as one run of four pages, and the bytes on both sides are the ones that were there — which is why nothing in the runtime notices: the bytes are fine, and the remap simply did not happen.

That matters for this issue in a way I did not expect when I claimed it: if #407 has shaders read title memory in place, a refused remap is not a copy problem or an import-lifetime problem — it is the title's own address-space operation being silently dropped, and the memory it "moved" keeps reading as before. Whether that is harmless (a title that remaps and reads the same bytes) or wrong (one that expects the new pages) is the next question, and it needs the title, not a synthetic test.

What I am handing over, since I claimed only this part:

  • the test, as it stands, is in the pull request and turns green today, because it asserts what the model does rather than what it should do;
  • the half I did not do is the placeholder identity: a range that stays a placeholder while pages are mapped into it is what #407 would need, and that is a change to the memory model, not a test. Whoever reshapes it can flip the second half of this test from "refused" to "replaced in place", and the test will say so.

Verification: cargo test -p victory-hle --locked --lib xmem 11 passed; cargo clippy --workspace --all-targets with and without --all-features clean under -D warnings; rustfmt --check on the file at the same four pre-existing hunks as main, none of them mine. The full victory-hle suite has one failure, lifecycle::tests::showing_a_title_window_shows_its_stand_in, which fails the same way on main in a session with no desktop.

Pull request: #1947

No game data is involved: page sizes, protections and return values.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-11-25 01:35 UTC · [original](https://github.com/Marvisak/VIctory/issues/1905#issuecomment-7149722893) **The guard page half holds; the remap half does not, and that is the finding** I wrote the test I claimed, against the model `xmem.rs` already keeps (physical pages, `XMemVirtualAlloc` reservations of 64 KiB pages, `XMemMapPhysicalPages`), and it answers both halves of the question rather than one. **A 16 KiB `PAGE_NOACCESS` change inside a live range is fine.** The change is accepted on a range that physical pages are mapped into, the pages on both sides keep their bytes across it and across the change back, and the run model still sees the range as one run. So a stack guard appearing in the middle of memory the GPU is reading is not, by itself, a problem for the direction #407 wants to take. **A remap of half a live range is refused.** Concretely: ``` MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER on half of a live range -> 0 ``` A range that physical pages are mapped into is no longer a placeholder, so the title's "free half of it, reserve it again, map new pages there" step fails **before any GPU read happens**. Nothing moves, the range still reads as one run of four pages, and the bytes on both sides are the ones that were there — which is why nothing in the runtime notices: the bytes are fine, and the remap simply did not happen. That matters for this issue in a way I did not expect when I claimed it: if #407 has shaders read title memory in place, a refused remap is not a copy problem or an import-lifetime problem — it is the title's own address-space operation being silently dropped, and the memory it "moved" keeps reading as before. Whether that is harmless (a title that remaps and reads the same bytes) or wrong (one that expects the new pages) is the next question, and it needs the title, not a synthetic test. What I am handing over, since I claimed only this part: - the test, as it stands, is in the pull request and turns green today, because it asserts what the model does rather than what it should do; - the half **I did not do** is the placeholder identity: a range that stays a placeholder while pages are mapped into it is what #407 would need, and that is a change to the memory model, not a test. Whoever reshapes it can flip the second half of this test from "refused" to "replaced in place", and the test will say so. Verification: `cargo test -p victory-hle --locked --lib xmem` 11 passed; `cargo clippy --workspace --all-targets` with and without `--all-features` clean under `-D warnings`; `rustfmt --check` on the file at the same four pre-existing hunks as `main`, none of them mine. The full `victory-hle` suite has one failure, `lifecycle::tests::showing_a_title_window_shows_its_stand_in`, which fails the same way on `main` in a session with no desktop. Pull request: https://git.gtahub.st/github/Marvisak--VIctory/pulls/1947 No game data is involved: page sizes, protections and return values. Written with an AI assistant.
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 08:40 UTC · original

### Empirical Windows 11 / AMD RX 7600 + WARP Findings & Zero-Reimport Prototype

Tested on Windows 11 x64 (10.0.26340), AMD Radeon RX 7600 (driver 32.0.32029.2010, ID3D12Device13), VICTORY_D3D12_DEBUG=1, and VICTORY_D3D12_WARP=1 (rustc 1.98.1, prototype on fork branch proto/issue-1905-inplace-remap, commit 593f02b, based on 940d32f).

1. What Win32 + WDDM + D3D12 actually do

  • Why #1947 hit 0 (ERROR_INVALID_PARAMETER = 87): Calling VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER) directly on a mapped view fails with err=87 because mapped views are no longer placeholders. Remapping sub-ranges requires UnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER) -> split/coalesce via VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER) / MEM_COALESCE_PLACEHOLDERS -> MapViewOfFile3(MEM_REPLACE_PLACEHOLDER) (prototyped in xmem::prepare_placeholder).
  • OpenExistingHeapFromAddress locks CPU VA protections and placeholder unmaps while live: On both RX 7600 and WARP, while an OpenExistingHeapFromAddress heap is alive over either MEM_WRITE_WATCH or plain VirtualAlloc memory, VirtualProtect (PAGE_GUARD, PAGE_READONLY, PAGE_NOACCESS) and UnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER) fail with err=87 until the ID3D12Heap is dropped (ok=1 immediately after drop). ID3D12Device13::OpenExistingHeapFromAddress1 also returns E_INVALIDARG (0x80070057) across split section views ("cannot open a region that spans multiple VirtualAlloc allocations").
  • OpenExistingHeapFromFileMapping requires SEC_COMMIT: Succeeds on SEC_COMMIT sections (4 KiB..174 MiB, Type=4 CPUPage=3 Pool=1 Flags=0x421 D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER), and rejects SEC_RESERVE with 0x80070057 even when 100% committed.
  • UpdateTileMappings cannot bind imported section heaps: Because OpenExistingHeapFromFileMapping returns a SHARED_CROSS_ADAPTER heap, ID3D12CommandQueue::UpdateTileMappings triggers device removal (DXGI_ERROR_INVALID_CALL = 0x887A0001; Debug Layer: "UpdateTileMappings does not work with cross-adapter shared heaps").

2. Working Zero-Reimport Architecture (InplaceArena in victory-gpu)

  • Import each SEC_COMMIT section once via OpenExistingHeapFromFileMapping -> CreatePlacedResource(ALLOW_CROSS_ADAPTER | ALLOW_UNORDERED_ACCESS) -> one persistent raw (SRV, UAV) descriptor pair.
  • Map/remap/alias/unmap 64 KiB pages below 2^40 in a persistently mapped 2-level GPU page table matching memory.rs's views[e.x].Load(a - e.y) indirection.
  • Verified survival across VirtualProtect(PAGE_GUARD) / PAGE_NOACCESS + restore, half-range remaps, split/coalesce (MEM_COALESCE_PLACEHOLDERS), GPU UAV writes visible across aliases, and unmap->zero-read with 0 re-imports, 0 new resources, and 0 D3D12 debug errors:
    • cargo test -p victory-hle xmem: 14/14 passed
    • cargo test -p victory-gpu --lib inplace -- --test-threads=1: 5/5 passed on RX 7600, RX 7600 + VICTORY_D3D12_DEBUG=1, and VICTORY_D3D12_WARP=1 + DEBUG=1 (2 ignored: benchmark + child-process UpdateTileMappings removal probe)
    • cargo test -p victory-gpu --lib -- --test-threads=1: 148/148 passed (RX 7600)
    • cargo clippy --workspace --all-targets -- -D warnings & cargo xtask policy: clean

3. RX 7600 --release Remap Benchmark (bench_inplace_remap_vs_reimport)

Size One-time FileMapping+Placed (p50) Zero-reimport CPU PT update (p50) Zero-reimport PT + GPU read (p50) UpdateTileMappings(DEFAULT) + fence (p50) Re-import FromAddress API / +GPU read (p50)
64 KiB (1 page, w=10 N=50) 518.4 us 0.1 us 135.2 us 192.8 us 478.7 us / 740.4 us (FromAddress1: 755.7 us)
2 MiB (32 pages, w=10 N=50) 1,040.5 us 0.1 us 134.6 us 219.9 us 553.5 us / 800.1 us (FromAddress1: 939.8 us)
64 MiB (1024 pages, w=10 N=20) 14,769.5 us 0.8 us 143.0 us 666.3 us 3,252.8 us / 3,637.2 us
174 MiB (2784 pages, w=10 N=15) 38,346.8 us 2.2 us 125.8 us 1,693.9 us 8,857.2 us / 9,525.0 us

(Constraint: guest memory must use SEC_COMMIT file mappings or fall back to copy tracking when backed by SEC_RESERVE or private VirtualAlloc.)

AI-assisted; synthetic tests only, no game files, dumps, or captures used.

**@⁠nathanbzrr** on GitHub · 2026-11-25 08:40 UTC · [original](https://github.com/Marvisak/VIctory/issues/1905#issuecomment-7157331892) ### Empirical Windows 11 / AMD RX 7600 + WARP Findings & Zero-Reimport Prototype Tested on Windows 11 x64 (`10.0.26340`), AMD Radeon RX 7600 (driver `32.0.32029.2010`, `ID3D12Device13`), `VICTORY_D3D12_DEBUG=1`, and `VICTORY_D3D12_WARP=1` (`rustc 1.98.1`, prototype on fork branch [`proto/issue-1905-inplace-remap`](https://github.com/nathanbzrr/VIctory/tree/proto/issue-1905-inplace-remap), commit `593f02b`, based on `940d32f`). #### 1. What Win32 + WDDM + D3D12 actually do - **Why #1947 hit `0` (`ERROR_INVALID_PARAMETER = 87`):** Calling `VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)` directly on a mapped view fails with `err=87` because mapped views are no longer placeholders. Remapping sub-ranges requires `UnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER)` -> split/coalesce via `VirtualFree(MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER)` / `MEM_COALESCE_PLACEHOLDERS` -> `MapViewOfFile3(MEM_REPLACE_PLACEHOLDER)` (prototyped in `xmem::prepare_placeholder`). - **`OpenExistingHeapFromAddress` locks CPU VA protections and placeholder unmaps while live:** On both RX 7600 and WARP, while an `OpenExistingHeapFromAddress` heap is alive over either `MEM_WRITE_WATCH` or plain `VirtualAlloc` memory, `VirtualProtect` (`PAGE_GUARD`, `PAGE_READONLY`, `PAGE_NOACCESS`) and `UnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER)` fail with `err=87` until the `ID3D12Heap` is dropped (`ok=1` immediately after drop). `ID3D12Device13::OpenExistingHeapFromAddress1` also returns `E_INVALIDARG` (`0x80070057`) across split section views (*"cannot open a region that spans multiple VirtualAlloc allocations"*). - **`OpenExistingHeapFromFileMapping` requires `SEC_COMMIT`:** Succeeds on `SEC_COMMIT` sections (4 KiB..174 MiB, `Type=4 CPUPage=3 Pool=1 Flags=0x421` `D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER`), and rejects `SEC_RESERVE` with `0x80070057` even when 100% committed. - **`UpdateTileMappings` cannot bind imported section heaps:** Because `OpenExistingHeapFromFileMapping` returns a `SHARED_CROSS_ADAPTER` heap, `ID3D12CommandQueue::UpdateTileMappings` triggers device removal (`DXGI_ERROR_INVALID_CALL = 0x887A0001`; Debug Layer: `"UpdateTileMappings does not work with cross-adapter shared heaps"`). #### 2. Working Zero-Reimport Architecture (`InplaceArena` in `victory-gpu`) - Import each `SEC_COMMIT` section **once** via `OpenExistingHeapFromFileMapping` -> `CreatePlacedResource(ALLOW_CROSS_ADAPTER | ALLOW_UNORDERED_ACCESS)` -> one persistent raw `(SRV, UAV)` descriptor pair. - Map/remap/alias/unmap 64 KiB pages below `2^40` in a persistently mapped 2-level GPU page table matching `memory.rs`'s `views[e.x].Load(a - e.y)` indirection. - Verified survival across `VirtualProtect(PAGE_GUARD)` / `PAGE_NOACCESS` + restore, half-range remaps, split/coalesce (`MEM_COALESCE_PLACEHOLDERS`), GPU UAV writes visible across aliases, and unmap->zero-read with **0 re-imports, 0 new resources, and 0 D3D12 debug errors**: - `cargo test -p victory-hle xmem`: **14/14 passed** - `cargo test -p victory-gpu --lib inplace -- --test-threads=1`: **5/5 passed** on RX 7600, RX 7600 + `VICTORY_D3D12_DEBUG=1`, and `VICTORY_D3D12_WARP=1` + `DEBUG=1` (2 ignored: benchmark + child-process `UpdateTileMappings` removal probe) - `cargo test -p victory-gpu --lib -- --test-threads=1`: **148/148 passed** (RX 7600) - `cargo clippy --workspace --all-targets -- -D warnings` & `cargo xtask policy`: clean #### 3. RX 7600 `--release` Remap Benchmark (`bench_inplace_remap_vs_reimport`) | Size | One-time `FileMapping+Placed` (p50) | Zero-reimport CPU PT update (p50) | Zero-reimport PT + GPU read (p50) | `UpdateTileMappings(DEFAULT)` + fence (p50) | Re-import `FromAddress` API / +GPU read (p50) | |---|---:|---:|---:|---:|---:| | **64 KiB** (1 page, w=10 N=50) | 518.4 us | **0.1 us** | **135.2 us** | 192.8 us | 478.7 us / 740.4 us *(FromAddress1: 755.7 us)* | | **2 MiB** (32 pages, w=10 N=50) | 1,040.5 us | **0.1 us** | **134.6 us** | 219.9 us | 553.5 us / 800.1 us *(FromAddress1: 939.8 us)* | | **64 MiB** (1024 pages, w=10 N=20) | 14,769.5 us | **0.8 us** | **143.0 us** | 666.3 us | 3,252.8 us / 3,637.2 us | | **174 MiB** (2784 pages, w=10 N=15) | 38,346.8 us | **2.2 us** | **125.8 us** | 1,693.9 us | 8,857.2 us / 9,525.0 us | *(Constraint: guest memory must use `SEC_COMMIT` file mappings or fall back to copy tracking when backed by `SEC_RESERVE` or private `VirtualAlloc`.)* AI-assisted; synthetic tests only, no game files, dumps, or captures used.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:52 UTC · original

Automated triage for the maintainers.

A design request that fits the project's scope: it concerns how the in-place title memory reads proposed in #407/#880 would survive the title's protection changes and remaps. It is kept open as the place for that question.

Where it stands:

  • Open PR #1947 adds a synthetic xmem test. It shows a 16 KiB protection change inside a mapped range is accepted, and a MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER on half of a live mapped range is refused on the current model.
  • The last comment reports measurements on an RX 7600 and WARP: a live OpenExistingHeapFromAddress heap blocks VirtualProtect and placeholder unmaps, and UpdateTileMappings cannot bind cross-adapter shared heaps. It also has a zero-reimport prototype (one SEC_COMMIT import plus a GPU page table), on a fork branch only.

Pull requests are open to everyone. Please open the prototype as a PR with its tests, so it can be reviewed here next to #1947 and #407.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:52 UTC · [original](https://github.com/Marvisak/VIctory/issues/1905#issuecomment-7162975591) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T08:40:35Z at=2026-11-25T12:52:17Z --> Automated triage for the maintainers. A design request that fits the project's scope: it concerns how the in-place title memory reads proposed in #407/#880 would survive the title's protection changes and remaps. It is kept open as the place for that question. Where it stands: - Open PR #1947 adds a synthetic `xmem` test. It shows a 16 KiB protection change inside a mapped range is accepted, and a `MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER` on half of a live mapped range is refused on the current model. - The last comment reports measurements on an RX 7600 and WARP: a live `OpenExistingHeapFromAddress` heap blocks `VirtualProtect` and placeholder unmaps, and `UpdateTileMappings` cannot bind cross-adapter shared heaps. It also has a zero-reimport prototype (one `SEC_COMMIT` import plus a GPU page table), on a fork branch only. Pull requests are open to everyone. Please open the prototype as a PR with its tests, so it can be reviewed here next to #1947 and #407. --- _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#1905
No description provided.