XMem: preserve overlapping source pages during GPU mapping copies #2199
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2199
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Razdva122 on GitHub · 2026-11-25 07:32 UTC · original
Razdva122:fix/gpu-copy-page-mapping-sources→main· +114 −18 · 1 files · 1 commits · openThe 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.
@MamaLeVrai on GitHub · 2026-11-25 08:52 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 13:28 UTC · original
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
@fuzeofficlal on GitHub · 2026-11-26 00:51 UTC · original
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.
@DenRakEiw on GitHub · 2026-11-25 07:42 UTC · original · approved these changes
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).
@catminou4 on GitHub · 2026-11-25 08:03 UTC · original · reviewed
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.
@fuzeofficlal on GitHub · 2026-11-26 13:18 UTC · original · approved these changes
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.