GPU/HLE: import committed physical-page sections in place for title memory (#1905) #2494
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!2494
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2494"
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?
@nathanbzrr on GitHub · 2026-11-25 14:48 UTC · original
nathanbzrr:proto/issue-1905-inplace-remap→main· +707 −38 · 4 files · 1 commits · openAddresses #1905.
Summary
Wires zero-reimport in-place physical-page section views directly into the runtime GPU title-memory page table (
crates/victory-gpu/src/memory.rs) andxmemphysical-page mappings (crates/victory-hle/src/modules/xmem.rs):crates/victory-hle/src/modules/xmem.rs:SEC_COMMITon Windows as on Wine (falling back toSEC_RESERVEfor multi-gigabyte reservations or ifSEC_COMMITfails).victory_gpu::title_memory_mapped) inxmem::mapand section closure (victory_gpu::title_memory_section_freed) inSection::drop, while leavingxmem::map's placeholder splitting unchanged (avoiding overlap with #76 / #1224 / #2425).crates/victory-gpu/src/memory.rs&crates/victory-gpu/src/watch.rs:ID3D12Device3::OpenExistingHeapFromFileMapping+CreatePlacedResource(ALLOW_UNORDERED_ACCESS | ALLOW_CROSS_ADAPTER) and keeps one persistent raw(SRV, UAV)descriptor pair per view heap (Shared::rewrite).write_tableto[pair_slot, (page_va as u32).wrapping_sub(sec_offset as u32)](IN_PLACEowner), and trims/clears mappings onwatch::title_memory_remapped.VirtualProtectguard pages (PAGE_GUARD/PAGE_NOACCESS) update only the two-level GPU page table with 0 heap re-imports and 0 new resources.Empirical D3D12/Win32 notes and remap benchmarks remain in #1905.
Verification
cargo run -p xtask -- policy:191 files okcargo clippy --workspace --all-targets --locked -- -D warnings: 0 warningscargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warningscargo test -p victory-gpu --lib memory --locked: 22/22 passed (includingsection_views_resolve_offsets_and_aliases_in_placeandsection_views_survive_guards_and_remaps_with_one_import)VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib memory --locked: 22/22 passed (0 D3D12 debug errors)cargo test -p victory-hle --lib xmem --locked: 15/15 passed (includinga_live_range_survives_a_guard_page_and_subrange_remaps)AI-assisted; synthetic tests only, no game files used.
593f02b38dtoe34b586eb8GPU/HLE: zero-reimport in-place memory remap prototype over SEC_COMMIT sections (#1905)to GPU/HLE: import committed physical-page sections in place for title memory (#1905)e34b586eb8to1a20686621@Marvisak on GitHub · 2026-11-26 06:15 UTC · original
Automated triage for the maintainers.
Thanks for the detailed write-up of the Win32/D3D12 findings. As it stands the PR is not mergeable, for these reasons:
crates/victory-gpu/src/inplace.rs(about 2,900 lines) addsInplaceArena/InplaceContext, capability probes and a benchmark. Nothing in the GPU path calls it, and the newxmem::mapped_runsandxmem::allocate_committed_physical_pageshave no callers outside tests. Merging it would add a large unused module, plus public API invictory-hlethat exists only for it.xmem::mapnow goes through the newprepare_placeholdersplit/coalesce path, which every physical-page mapping the title makes will use. That is a real behaviour change, and a 3,800-line prototype hides it. The PR also notes it overlaps #76, #1224 and #2425.What would change the verdict: split the work. First, a small PR with only the
prepare_placeholderfix toxmem::map, its unit tests, and evidence that it fixes a failure the title hits (for example, theVirtualFreeerror 87 from #1947 reproduced on an actual mapping sequence). Second, the arena itself, once it is wired into the GPU memory path, with the probes and benchmark left out or kept much smaller.Generated by Claude Code
@nathanbzrr on GitHub · 2026-11-26 07:20 UTC · original
Addressed the triage items at head
1a20686(rebased onorigin/main63bcca4):crates/victory-gpu/src/memory.rs,crates/victory-gpu/src/watch.rs,crates/victory-hle/src/modules/xmem.rs) and removed unused code/APIs:crates/victory-gpu/src/inplace.rsmodule (includingInplaceArena,InplaceContext, capability probes, and benchmark) and removed the test-only public items inxmem.rs(PhysicalSection,MappedRun,mapped_runs,allocate_committed_physical_pages).xmem::mapandSection::dropnow notifyvictory_gpu::title_memory_mappedandvictory_gpu::title_memory_section_freed, andwatch::title_memory_remappedupdatesmemory::unmapped.memory::Shared::rewriteimports each committed physical-page section once viaOpenExistingHeapFromFileMapping+CreatePlacedResource(ALLOW_UNORDERED_ACCESS | ALLOW_CROSS_ADAPTER), allocates one persistent raw(SRV, UAV)pair per view heap, and populateswrite_tablewith[pair_slot, (page_va as u32).wrapping_sub(sec_offset as u32)](IN_PLACEowner).prepare_placeholderchange inxmem::map:xmem::map's placeholder coalescing back tomain's implementation so it does not overlap #76, #1224, or #2425.memory.rsandxmem.rsand the PR body concise (referencing #1905 for the empirical D3D12 findings and benchmarks).Verified on Windows MSVC (
1a20686):cargo run -p xtask -- policy:191 files okcargo clippy --workspace --all-targets --locked -- -D warnings&--all-features: 0 warningscargo test -p victory-gpu --lib memory --locked: 22/22 passedVICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib memory --locked: 22/22 passedcargo test -p victory-hle --lib xmem --locked: 15/15 passed@potatoe0100 on GitHub · 2026-11-26 14:48 UTC · original
First run on NVIDIA hardware, as far as I can see (the description and comments only mention WARP): RTX 4060 8 GB, driver 621.14, Windows 11 Pro 26300. Head
1a20686merged ontomain63bcca4,cargo test -p victory-gpu --lib --locked -- --test-threads=1. Synthetic only, no game files.section_views_resolve_offsets_and_aliases_in_place: passes.section_views_survive_guards_and_remaps_with_one_import: fails, but only on the test's heap-layout assumption. It stops atassert!(initial_pair >= 1 << 18)(memory.rs:1614). Before that, the GPU reads through the imported section (OpenExistingHeapFromFileMapping+ placed buffer) return the right markers for all six pages, so the import works on this driver. NVIDIA caps the view heap at 1,000,000, soHostHeap::newtakes the capped layout andpair()comes from the dynamic slots. Here the section's pair was slot 2. With that assert replaced by a print, the whole test passes (guard page,PAGE_NOACCESS, the remap into three pieces, one import).mainon this card: the 2 known capped-heap failures (#1835).Suggestion: assert that the pair is a valid slot of
heap()(for exampleinitial_pair < views.count + views.dynamicand not the null pair) rather than>= 1 << 18, so the test holds on capped hosts.AI-assisted (Claude)
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.