GPU: scan virtual regions on copy_mapped and write_mapped fallback (#783) #1350
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1350"
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 wbkepler on 2026-11-24T17:34:52Z.
Summary
Implements #783:
VirtualQueryregion-scan copy fallback incopy_mappedandwrite_mapped(crates/victory-gpu/src/host.rs) so mapped copies spanning uncommitted or guard-page gaps copy committed sub-regions safely instead of failing the entire span.Verification
cargo clippy -p victory-gpu --all-targets— passedcargo test -p victory-gpu— passedcargo xtask policy— passedImported from Marvisak/VIctory. Originally posted by maplerouteadmin-dev on 2026-11-24T17:58:01Z.
Tested on hardware that hits the fallback path hard; it helps a lot here.
Setup: RTX 5070 12 GB (driver 32.0.16.2114), Ryzen 5 5600X, 32 GB, Windows 11; Xbox Series 1.0.2.1; diag build (
--profile diag --features diagnostics),VICTORY_GPU_TIMING=1 VICTORY_D3D12_DRED=1, warm shader cache. Base:mainatffe310eplus #966, Peppacodesexp/mesh-host-lanes(#940/#189) and a port of the #951 fix, needed to reach the world on NVIDIA. #1350 merged on top with one trivial conflict (both sides append at the end ofhost.rs; kept both).cargo test -p victory-gpupasses. No game data used.Same route both runs: boot, menus, first cutscene into the world, about 60 s there. Medians over the 5 s frame-rate lines with frames over 500 ms (world only):
The two runs do not copy the same amount per frame (the scene differs from second to second), so the per-GB figure is the fairer comparison: about 3x cheaper.
moves(the firstReadProcessMemory) stays at 65-90 ms/frame in both, so before the change almost all of the copy time was the 64 KiB / 4 KiB retry.Unchanged by the PR: draws dropped without a host pipeline are similar in both runs (hundreds to thousands per frame, untranslated shaders) and the scene is black in both. No crash, no device removal.
What dominates with the PR in: copies are still ~1.2 s/frame, and in some lines write-watch askings take up to ~1.2 s/frame (
1480 watches 1175.70 ms, 14644.6 MB checked, 10186.5 MB unchanged), with GPU time spiking to 1.2-1.4 s in a few lines.Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T18:09:04Z.
In-game A/B on AMD/Linux, since the PR has unit/WARP checks but no title numbers.
Setup: RX 9060 XT (RDNA4, RADV 26.3.1), Arch, Wine 11.22, DXVK 3.1.1
dxgi, vkd3d-proton 3.2.0,WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n"; release MSVC build, package 1.0.2.1 (build unknown (b99f876b…)); scripted Enter through the menus, 600 s per run.mainffe310e2f27ea1So the fallback does what it says on AMD/Wine too: copy time roughly halves to a third in the world, and the frame gets shorter. Directional only — two runs, not the same save/frame window.
Both runs reach the prologue (credits render; the 3D scene behind stays black, #841), then hit
RtlReleaseSRWLockExclusiveand the title's+0x2215c35null write (#774); no device removal in either. Not tested: Windows/NVIDIA, controlled same-save, long sessions.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:09:07Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests.
copy_mapped/write_mapped now walk regions with for_regions (VirtualQuery) instead of blind 64 KiB/4 KiB piece retries: the whole-range RPM/WPM prefix is preserved (done.min(len)), unreadable source pages are zeroed in one write_bytes call (zero_unmapped), and only committed readable regions go through RPM/WPM with piece fallback if a region unmaps mid-read. read/write now return (ok, bytes_done) so partial progress is not re-copied. This removes the quadratic retry behavior on sparsely-mapped title memory. Windows-only; logic is careful (wrapping_add offsets, dst bounds by construction).
Imported from Marvisak/VIctory. Originally posted by maplerouteadmin-dev on 2026-11-24T21:15:31Z.
Correction to my earlier numbers on #1350 and #1351. After posting them I found a background GPU process on the test machine (a hidden CUDA miner, since removed) holding about 2.8 GB of VRAM and using the GPU. Every build was measured under the same conditions, so the comparisons between builds hold, but the absolute frame times and some of the device removals were inflated by it. Re-measured on the clean machine:
RTX 5070 12 GB (driver 32.0.16.2114), Ryzen 5 5600X, 32 GB, Windows 11; Xbox Series 1.0.2.1; diag build; same scripted input (
VICTORY_KEYS), 240 s per run, builds alternated, one process at a time. Base =mainffe310e+ #966 + Peppacodesexp/mesh-host-lanes+ a #951 port. Medians over world frame-rate lines (frames over 500 ms). No game data used.Same conclusions as before: #1350 cuts the copy cost sharply; #1351 as is copies more per draw (the copies left unwatched after a failed gap, see my comment on #1351); with the gap fix it is the fastest of the four. The device removals are real on this card without the background process too: about one run in two, on every build, so they are not caused by either PR.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:38:04Z.
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #943. The same VirtualQuery region walk as #943 (same issue), larger (357 lines), without measurements, and its test must find a 5 MiB MEM_FREE hole in a shared test process within 16 tries (flaky).
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed