XMem: preserve overlapping source pages during GPU mapping copies #2197
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2199"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by Razdva122 on 2026-11-25T07:32:50Z.
The GPU queue calls
xmem::map_aliasto copy physical page mappings. On main, it removes the destination range before looking up the source pages. On an overlapping move this can erase the source before it is read. A source range with a hole can also discard a valid destination before the copy reports failure.This addresses one existing page-mapping case from #1905. The broader lifetime of host-imported GPU memory across protection changes remains open. Coordination thread
Resolve the entire source range while the physical mapping lock is held, retaining its section references and starting page indices. Only then replace the destination page mappings. A missing source page returns before any destination change. A single source view needs no temporary vector allocation. As before, an OS refusal while installing a destination mapping can interrupt a copy.
The regression uses real Windows placeholder reservations and physical sections with synthetic contents. It checks forward and backward overlap, a self-copy, a source with a hole and repeated physical pages. A write through one address verifies that the resulting mappings still share their backing page. With the previous implementation, a one-page forward shift mapped all five addresses to the first page: reading the sentinels returned
[1, 1, 1, 1, 1]. The corrected code returned[1, 1, 2, 3, 4]on the same Windows runner. The full workspace suite and both Clippy configurations passed. Windows comparison and test log A run with the title has not been performed.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T07:42:23Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-hle --lib xmem::— 11 passed, 0 failed (includinggpu_page_copies_keep_the_source_mappings)cargo clippy -p victory-hle --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean preservation of overlapping source pages during GPU mapping copies in
xmem.rs. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:03:06Z.
Review: COMMENTED
Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.
XMem overlapping source pages preserved during GPU mapping copy — memmove-overlap fix; relates to #2213's xmem page-run coalescing.
Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T08:52:09Z.
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head
365a2a49intomain940d32fin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with--all-features: clean.cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (mainalone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
victory configpolicy check; fix example comment #2195Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:28:49Z.
Automated triage for the maintainers.
xmem::map_alias(crates/victory-hle/src/modules/xmem.rs) now resolves every source page under the physical lock before it unmaps the destination, so an overlapping copy no longer reads pages it has just erased; main'sunmap-first order really does lose the source on a forward shift, and the new test covers forward/backward overlap, self-copy, a source hole and shared backing. Two smaller behaviour changes worth a glance: a source with a hole now leaves the destination mapped instead of unmapped, and unaligned addresses or lengths are refused (the only caller,copy_page_mappingsinvictory-gpu/src/queue.rs, always passes 64 KiB multiples). CI passes, and a tester reports the full suite passing on RDNA2.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:51:32Z.
Code review and Windows 11 verification at head
365a2a491ffdmerged cleanly ontomain(63bcca43c6a0):crates/victory-hle/src/modules/xmem.rs:773-837):(Slice { index, section: Arc<Section> }, run_bytes)across[from, from + len)before mutating[to, to + len)cleanly fixes both forward/backward overlapping mapping copies and source holes (returningfalsewithout touching the destination), while self-copy (from == to) returnstrueafter source validation andtitle_memory_remapped/title_memory_aliasedkeep GPU page watches andphysical.showncoherent.map()fails partway through remapping the destination afterunmap, earlier destination runs remain mapped (only reachable under host commit exhaustion / non-placeholder target).cargo xtask policy:191 files ok;cargo clippy --locked -p victory-hle --tests -- -D warnings: 0 warningscargo test --locked -p victory-hle -- xmem: 15/15 passed (includinggpu_page_copies_keep_the_source_mappings).LGTM.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T13:18:17Z.
Review: APPROVED
Reviewed and verified
365a2a49merged locally ontoorigin/main(63bcca43) on Windows 11 x64 (Rust1.98.1MSVC; synthetic tests only, no game files).Verification
git merge-treeagainstorigin/main(63bcca43): clean.cargo xtask policy(PR head):182 files ok.cargo clippy --locked -p victory-hle --all-targets -- -D warnings(default and--all-features, PR head and merged): 0 warnings.cargo test --locked -p victory-hle --lib -- xmem::— 15 passed, 0 failed (includinggpu_page_copies_keep_the_source_mappings); fullcargo test --locked -p victory-hle --lib— 153 passed, 0 failed.cargo test --locked --release -p victory-hle --lib -- xmem::— 15 passed, 0 failed.--release): verifiedlen == 0, unalignedto/from/len,u64overflow into + lenandfrom + len, self-copy spanning an unmapped hole returningfalse, and forward overlapping copies across multiple distinct non-contiguous source views.Review Notes
(Slice { index, section: Arc<Section> }, run_bytes)across[from, from + len)underphysical()(crates/victory-hle/src/modules/xmem.rs:769-792) before unmapping[to, to + len)(:796) fixes both overlapping forward copies and source holes leaving the destination unmapped, while keeping the single-view hot path allocation-free.from == toearly return (:793-795) preserves the contract that a self-copy containing an unmapped source page returnsfalse.#1935has a trivial test-only hunk conflict incrates/victory-hle/src/modules/xmem.rs(mod tests), with no production-code overlap.Looks good to merge.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.