hle(xmem): pool-back MEM_COMMIT calls inside reserved XMemVirtualAlloc ranges #507
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/507"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T22:37:35Z.
What this changes
Closes #506
Refs #15, #258
On macOS, one-step
XMemVirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, ...)backs the allocation with aPoolviaxmem_physical::back_with_poolso the native GPU backend can resolve title addresses throughPoolTable(a017f770).When a title instead reserves virtual address space first (
MEM_RESERVEor aPAGES_64Kplaceholder) and commits granules or sub-ranges later viaXMemVirtualAlloc(at, size, MEM_COMMIT, ...)orVirtualAlloc(at, size, MEM_COMMIT, ...),xmem_posix.rsandhost_posix.rspreviously called plainmem::commiton anonymous VM pages, leaving those committed ranges outsidePoolTable(title address ... is not in a mapped pool/a buffer view over title memory with a gap stays the null view).Changes:
crates/victory-hle/src/modules/xmem_physical.rs: Addunbacked_rangesto find 64 KiB granules within a reservation span that do not yet have a physical-page view.crates/victory-hle/src/modules/xmem_posix.rs&crates/victory-hle/src/host_posix.rs: Addcommit_if_reserved, serialised withforget_physical, to pool-back uncovered 64 KiB granules onMEM_COMMITinsideXMemVirtualAllocreservations while keeping uncommitted sub-granule prefixes/tailsProtect::NO_ACCESSand rejecting commits past the reservation's end.VirtualAlloc(..., MEM_COMMIT, ...)insideXMemVirtualAllocreservations.How it was tested
cargo test --target x86_64-apple-darwin -p victory-hle --libcargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtaskcargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warningscargo clippy --workspace --all-targets --all-features --target x86_64-pc-windows-gnullvm -- -D warningscargo xtask policy(399 files ok)Checklist
docs/native-host.mdVICTORY_*variable and documentedcc @Olima34
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T22:38:45Z.
Thanks @Sheffy007, this closes a gap we left open in #267. Our wrap of non-linear heap views only covers ranges the pool table maps with no gap. Anything else stays the null view, with the "a buffer view over title memory with a gap stays the null view" line you quote. Committed ranges outside
PoolTablewere exactly the case we couldn't serve. It should also cut the ~490 commands per frame that name memory "outside every mapped pool", which we counted on #258 earlier.It may matter for one more thing we're chasing. On the preview branch, indirect dispatch and draw records sometimes hold foreign data (e.g. a whole 512-record buffer overwritten with vertex-like triples during a skinning pass). In one run we also saw more than 2,048 heap views whose title pages moved in their pool while the host entry still pointed at the old ones. Memory the title commits later, inside a reservation and outside any pool, is another way for host and title to disagree on where a buffer lives.
We'll add #507 to our next runs on the preview branch, together with #459, #483 and #499, and post whether the "not in a mapped pool" lines, the gap-null views and the garbage records go down.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T22:40:51Z.
@Sheffy007 a side question: are you on the project's Discord (Native macOS-Victory)? We're pairing a lot on the same areas tonight (fences, waits, title memory), and it would be easier to compare runs and avoid overlap there. If you're not on it yet and you'd like to join, say so here and we'll send you an invite.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-28T00:02:07Z.
@Olima34, I'm not currently but yeah please send an invite! Gemini is doing the work for me but I'm happy to direct it wherever it needs to go.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T00:06:20Z.
@Sheffy007 great, here it is: https://discord.gg/xut5NhywZ. Welcome! Say hi in the channel when you're in. Pointing your agent at the open blockers is exactly what helps most: tell us what it's on, and we'll share the runs and traces we have for that area.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-28T01:33:18Z.
Review: APPROVED
Check report (helping the maintainer clear the queue):
checkandmacos-scriptsgreen onfdd8c709.MEM_COMMITinside anXMemVirtualAllocreservation (throughXMemVirtualAllocorVirtualAlloc) now backs the touched 64 KiB granules that have no physical-page view yet with a pool (unbacked_ranges+back_with_pool). It keeps the uncommitted head and tail of a granule no-access and refuses a commit past the reservation's end.COMMIT_LOCKserialises it withforget_physical. Tests cover a placeholder's partial commit, sub-granule commits sharing one pool without wiping each other, the out-of-range commit, andVirtualAllocinside an XMem reservation, each checking the pool's own mapping sees the write.226645f9) merged with #454, #499 and this PR:victory-hletests pass on x86_64-apple-darwin, Windows clippy (-D warnings) clean,cargo xtask policyok.b3c1a1b0+ #459 + #513 + #499 + #483 + this PR,VICTORY_TRACE_GPU_FAILS=1 VICTORY_PASSES_PER_BUFFER=1): 0 GPU errors, clean end, 2432 frames, the same as without it. Indirect records past the gates' limits were 15, 12 and 17 across control and the two trees, so this doesn't change those.Thanks @Sheffy007!