GPU: scan virtual regions on copy_mapped and write_mapped fallback (#783) #1350

Closed
github-bot wants to merge 1 commit from gh-pr/1350/head into gh-pr/1350/base
Owner

@⁠wbkepler on GitHub · 2026-11-24 17:34 UTC · original
wbkepler:gpu/region-scan-copy-fallback → main · +357 −29 · 1 files · 1 commits · closed without merging

Summary

Implements #783:

  • Adds VirtualQuery region-scan copy fallback in copy_mapped and write_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.
  • Adds unit/WARP regression tests covering partial/gapped virtual region copies.

Verification

  • cargo clippy -p victory-gpu --all-targets — passed
  • cargo test -p victory-gpu — passed
  • cargo xtask policy — passed
**@⁠wbkepler** on GitHub · 2026-11-24 17:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1350) `wbkepler:gpu/region-scan-copy-fallback` → `main` · +357 −29 · 1 files · 1 commits · closed without merging ## Summary Implements #783: - Adds `VirtualQuery` region-scan copy fallback in `copy_mapped` and `write_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. - Adds unit/WARP regression tests covering partial/gapped virtual region copies. ## Verification - `cargo clippy -p victory-gpu --all-targets` — passed - `cargo test -p victory-gpu` — passed - `cargo xtask policy` — passed
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:28:23 +00:00
github-bot closed this pull request 2026-11-26 04:28:23 +00:00
Author
Owner

@⁠maplerouteadmin-dev on GitHub · 2026-11-24 17:58 UTC · original

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: main at ffe310e plus #966, Peppacodes exp/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 of host.rs; kept both). cargo test -p victory-gpu passes. 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):

before with #1350
ms/frame 6 134 2 200
copies, ms/frame 5 382 1 223
copies, MB/frame 3 244 1 220
copy cost, s per GB (median per line) ~1.53 ~0.50
fallbacks/frame (copystat) 5 744 ~3 000
on the GPU, ms/frame 345 376
copying back, ms/frame 184 273

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 first ReadProcessMemory) 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.

**@⁠maplerouteadmin-dev** on GitHub · 2026-11-24 17:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1350#issuecomment-7139962863) 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: `main` at `ffe310e` plus #966, Peppacodes `exp/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 of `host.rs`; kept both). `cargo test -p victory-gpu` passes. 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): | | before | with #1350 | |---|---|---| | ms/frame | 6 134 | 2 200 | | copies, ms/frame | 5 382 | 1 223 | | copies, MB/frame | 3 244 | 1 220 | | **copy cost, s per GB** (median per line) | **~1.53** | **~0.50** | | fallbacks/frame (copystat) | 5 744 | ~3 000 | | on the GPU, ms/frame | 345 | 376 | | copying back, ms/frame | 184 | 273 | 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 first `ReadProcessMemory`) 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.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 18:09 UTC · original

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.

main ffe310e this head 2f27ea1
world lines 33 35
fps 0.30 0.50
frame 4027 ms 2942 ms
copies 2627 ms / 56.7 MB 1127 ms / 35.8 MB
textures 421 ms 535 ms

So 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 RtlReleaseSRWLockExclusive and the title's +0x2215c35 null write (#774); no device removal in either. Not tested: Windows/NVIDIA, controlled same-save, long sessions.

**@⁠DaviTostes** on GitHub · 2026-11-24 18:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1350#issuecomment-7140230937) 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. | | `main` `ffe310e` | this head `2f27ea1` | |---|---:|---:| | world lines | 33 | 35 | | fps | 0.30 | **0.50** | | frame | 4027 ms | **2942 ms** | | copies | 2627 ms / 56.7 MB | **1127 ms / 35.8 MB** | | textures | 421 ms | 535 ms | So 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 `RtlReleaseSRWLockExclusive` and the title's `+0x2215c35` null write (#774); no device removal in either. **Not tested:** Windows/NVIDIA, controlled same-save, long sessions.
Author
Owner

@⁠maplerouteadmin-dev on GitHub · 2026-11-24 21:15 UTC · original

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 = main ffe310e + #966 + Peppacodes exp/mesh-host-lanes + a #951 port. Medians over world frame-rate lines (frames over 500 ms). No game data used.

base + #1350 + #1350 + #1351 + #1350 + #1351 + gap fix
runs 2 2 2 3
ms/frame 4 667 2 434 2 000 1 633
copies, ms/frame 4 240 1 222 1 347 635
copied per draw, MB 2.69 3.20 4.13 2.54
write-watch, ms/frame 271 479 456 238
runs ending in device removal 1 1 1 1

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.

**@⁠maplerouteadmin-dev** on GitHub · 2026-11-24 21:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1350#issuecomment-7144689244) **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 = `main` `ffe310e` + #966 + Peppacodes `exp/mesh-host-lanes` + a #951 port. Medians over world frame-rate lines (frames over 500 ms). No game data used. | | base | + #1350 | + #1350 + #1351 | + #1350 + #1351 + gap fix | |---|---|---|---|---| | runs | 2 | 2 | 2 | 3 | | ms/frame | 4 667 | 2 434 | 2 000 | **1 633** | | copies, ms/frame | 4 240 | 1 222 | 1 347 | **635** | | copied per draw, MB | 2.69 | 3.20 | 4.13 | **2.54** | | write-watch, ms/frame | 271 | 479 | 456 | **238** | | runs ending in device removal | 1 | 1 | 1 | 1 | 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:38 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 00:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1350#issuecomment-7148717206) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1350
No description provided.