Repository navigation
xmem: write DirectStorage page destinations one view per run - #61
Merged
Merged
Conversation
write_physical mapped, committed and unmapped a view for every 64 KiB page it wrote, and DirectStorage decoded each page-destination request into a zeroed buffer first, then copied it. Every unmap flushes every core's TLB, so with all the workers loading at once these writes were a serial cost per page. Pages are now looked up once and grouped into runs of consecutive slices of one section (how titles allocate them), and each run is written through one view. When a request's pages form a single run, DirectStorage inflates or unpacks straight into that view instead of a buffer; pages of several allocations still go through the buffer, written run by run. Synthetic release benchmark (16 MiB destinations, Ryzen 9 5900X): 8 threads 3.5 -> 7.8 GiB/s; one thread, buffered then copied 0.96 GiB/s vs in place 2.1 GiB/s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
AI-assisted (DeepSeek V4.1 Flash coding agent). |
mpDom
pushed a commit
to mpDom/VIctory
that referenced
this pull request
Nov 24, 2026
Each title resource got its own committed host texture, so resources the title places over the same memory (several objects at one heap offset or address, or the same physical pages mapped at several addresses) did not see each other's GPU writes, and a sampled-only alias of a render target uploaded the title's (stale) memory instead of what was rendered. Host textures are now keyed by memory identity (physical allocation and offset via xmem's new physical_at resolver, else the address) and shape (size, mips, samples, format family). An alias shares a GPU-written host texture when it needs no use that one lacks; title-written ones are shared by identical descriptions. Aliases of another shape still get their own and are counted. A log line reports live host textures, their MB and the aliases found. VICTORY_GPU_SHARE_ALIASES=0 turns sharing off to compare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
suirentakamura
referenced
this pull request
in suirentakamura/victory-suiren
Nov 24, 2026
xmem: write DirectStorage page destinations one view per run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The README lists loading as "limited by writes into title memory". One part of that is DirectStorage requests that write physical pages (
PAGE_DESTINATION):xmem::write_physicalmapped, committed and unmapped a separate view for every 64 KiB page. Each unmap flushes every core's TLB, so with all the DirectStorage workers writing at once, this cost was paid serially, once per page.dstorage::into_destinationfirst decoded each such request into a zeroedVec, then copied it into the pages.Change
xmem::runslooks the pages up under one lock and groups them into runs of consecutive slices of one section. That is the usual case, sinceXMemAllocatePhysicalPageshands out one section per call.XMemMapPhysicalPagesalready groups pages the same way.write_physicalwrites each run through a single view (an RAIIViewthat maps, commits, and unmaps on drop).xmem::page_window: when a request's pages form one run, DirectStorage inflates or unpacks straight into that view, with no buffer and no copy. Pages from several allocations, or out of order, still go through the buffer and are written run by run. Errors are reported the same way as before (E_INVALIDARGfor an unknown page).Behaviour is unchanged apart from cost. As before, only the bytes the decoder produced are written, and the GPU side's guards are unaffected: these writes go through our own view, as they did before (the
shortcutnote invictory-gpu/src/watch.rs).This fits with #53 (Wine: sections committed whole, so
commitreturns early):View::mapgoes through the samecommit.Numbers
Synthetic benchmark: a throwaway
--releasetest, not included. It writes 16 MiB destinations, 256 consecutive pages, 20 times each.write_physical, 1 threadwrite_physical, 8 threadsI haven't measured the effect on in-game load time. I didn't run the title for this change.
Tests
New unit tests, all synthetic (our own data):
xmem::runs_group_consecutive_pages_of_one_allocation: run grouping, offsets that reach only some pages, out-of-order pages, pages from two allocations, too few pages, unknown pages, an overflowing offsetxmem::writes_cross_runs_and_allocations: a write crossing a run boundary between two sections, with the bytes around it left untouchedxmem::page_windows_cover_one_run_in_placedstorage::zlib_into_pages_in_place_and_across_allocations: zlib into physical pages on both paths, checked through the title's view of themRun:
cargo +stable-x86_64-pc-windows-msvc test --workspace: 228 passed, 0 failed, 3 ignored (224 before this change)cargo clippy -p victory-hle --all-targets: no new warnings. The only warnings are the existingfetch_updatedeprecations on a newer stable toolchain.cargo xtask policy: 148 files OKmainitself is not rustfmt-clean yet, see CI: check the formatting with cargo fmt on all PRs #17)Machine: Windows 11 Pro, AMD Ryzen 9 5900X, AMD Radeon RX 6800. These tests are CPU-only, so no GPU tests were needed.
This PR was AI-assisted (Claude Code). I reviewed the change and the tests.
🤖 Generated with Claude Code