GPU: copy title memory into host memory without a system call #1010
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!1010
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1010"
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?
@TG0000 on GitHub · 2026-11-24 14:57 UTC · original
TG0000:perf/user-mode-title-copies→main· +693 −17 · 3 files · 4 commits · openSummary
Every constant buffer fill of a submission is one
ReadProcessMemorycall, about 0.8 us for a few hundred bytes, and a world frame makes many of them. A leaf routine now copies in user mode. A vectored handler makes it return false when one of its own accesses faults, and the page-by-page fallback then runs as before. Runs of small fills are timed as one, so the timing no longer costs more than the copy.Measured
title_copy_bench(included, ignored by default), release build, Ryzen 9 5900X, Windows 11. Other builds were running, so treat the numbers as approximate. Time per copy:A copy that fails: 4.1 us before, 2.8 us now. 4096 fills of 256 B: 2.94 ms before, 0.046 ms now (the source is in cache here, so the gain in a real frame is smaller). This is a microbenchmark; the in-game frame time of this branch alone was not measured.
Verification
Rust 1.98.1 MSVC, base
ffe310e:cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo test --workspace --locked --no-fail-fast: 347 passed, 1 failed. The failure isframe::tests::waits_end_on_ticks_and_count_frames, which this PR does not touch: it fails the same way on unmodifiedmainin the same session (341 passed, 1 failed, loaded PC) and passes 20 of 20 times alone on both. #174 and #689 are about that kind of wait.Overlap
Conflicts textually with #943, which changes how the fallback of the same functions finds regions, not the copy itself; I will rebase on whichever lands first. #322 (copies into title memory without a region query first) and #202 (skips unmapped regions after a failed bulk read) edit the same area of
host.rs.AI-assisted: written, benchmarked and checked with Claude Opus 5.5. No game data.
🤖 Generated with Claude Code
@TG0000 on GitHub · 2026-11-24 15:07 UTC · original
Thanks for testing on the RTX 5090 and WARP.
@Zipettte on GitHub · 2026-11-24 15:12 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
e99253e:cargo test -p victory-gpupasses, 56 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@DaviTostes on GitHub · 2026-11-24 15:54 UTC · original
In-game A/B on AMD/Linux, since the description only has the microbenchmark:
mainffe310e, release MSVC, real title 1.0.2.1 (build unknown (b99f876b…)).dxgi, vkd3d-proton 3.2.0,WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n", scripted Enter through the menus, 600 s run.mainin the same setup:mainNo measurable difference here: the copies in this workload are dominated by large watched ranges and page holes (the #783 path), not by the many small fills the microbenchmark targets, or the user-mode path falls back on this setup. Not a controlled same-save A/B, so treat it as directional.
Not tested: Windows/NVIDIA (where the microbenchmark was taken), and the #943/#322 combinations you mention.
@TG0000 on GitHub · 2026-11-24 16:00 UTC · original
Thanks for the in-game A/B. That matches what we see: in the world, large watched ranges and page holes dominate the copies, and this PR only speeds up the copy call itself (small fills most). Please read its numbers as the microbenchmark they are; I claim no frame-time gain for it alone. A run of ours on an RX 6800 was too noisy to add a number.
@TG0000 on GitHub · 2026-11-24 16:26 UTC · original
Pushed
79c9b93(fast-forward): when a copy meets a guard page, the read spends the guard, which the kernel's copy on main does not. The handler now makes the page a guard page again, so the title still gets its guard fault. Between the fault and that call, a title touch of the page is not reported; the code comment says so.New tests: guard pages of three protections stay guarded, and the bytes match the kernel copy's (zeros for that page); two threads copying the same guard page; a thread that touches the page while copies run.
title_copytests 8 passed andhosttests 12 passed on this commit (Windows 11, RX 6800), clippy clean with and without--all-features. The full workspace tests ran on the same code before a rustfmt rewrap; onlyframe::tests::waits_end_on_ticks_and_count_framesfailed, which also fails at times on main here.AI-assisted (Claude Code).
@465d6a0eac on GitHub · 2026-11-24 17:49 UTC · original
Thank you for this, @TG0000! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/36. You're credited as the author there. This stays the original.
Test results
cargo clippy(both variants) andcargo test --workspacepass (429 passed, 0 failed).@adnanoos on GitHub · 2026-11-24 20:47 UTC · original
RTX 5060 Laptop GPU: in the world this PR takes frames from ~3.0 s to ~1.7 s (0.36 → 0.64 fps), and the run outlasts the title-pool stop at
+0x5149aecSetup. NVIDIA GeForce RTX 5060 Laptop GPU, driver 32.0.16.2124, Intel Core 7 240H, 32 GB, Windows 11 Pro 26200, title 1.0.2.1, Series X mode. Release build with
--features diagnostics,VICTORY_D3D12_DRED=1, Enter every 5 s for 4 min, 12-minute cap. The base is the stack that gets this laptop through the world without a GPU hang: #1520 (2190efe) + theresync_title_writesbound from #994's thread + #452. This PR at79c9b93was merged onto it cleanly. One run each.World frames only, from the
fps, ms/framelines (5-s samples):0x80000003at+0x5149aecafter 7m45s in the worldThe run without this PR ends at the title's empty-pool assert that #1232 reads as a frame-rate symptom; with this PR it does not come within the run, which fits that reading.
Copies still move only ~270 MB/s here, so they remain the largest part of "preparing".
Tests.
cargo test --release -p victory-gpu --libon this PR alone: 59 passed, 0 failed, 3 ignored (all 8title_copytests pass, the bench ignored).@TG0000 on GitHub · 2026-11-24 23:00 UTC · original
Merged main in (fast-forward); both the per-step timer of main and the run of fills timed as one are kept.
victory-gpu 87 and victory-shader 209 tests pass on Windows (RX 6800), clippy clean with and without all features. The microbenchmark was not run again and I still claim no frame-time gain.
Thanks @adnanoos for the run in the world. AI-assisted (Claude Code).
139 perf/shader-address-sums : PUSH
local ref: prready/139 (
90cf2f6), GitHub head697c4bcgit push fork prready/139:perf/shader-address-sums
Resolved: took main's tracer whole; the cache sits in a RefCell so its &self stays, and is emptied after the spilled parameters change the origins. One test expected a refusal that main turned into title memory: expectation changed, and the same test file passes on main without the cache.
Checks: Mac lint 0, Mac tests formats 23, shader 118 + 3. Windows tests gpu 78, shader 209 + 3, 0 failed. Benchmark and census not run again.
Draft comment:
Merged main in (fast-forward). Main's tracer is unchanged; the sums are cached behind a RefCell and dropped when the spilled parameters change the origins.
One test follows main's rule that an address from no root parameter is title memory; the same file passes on main without the cache.
victory-shader 209 + 3 tests pass on Windows (RX 6800). The benchmark was not run again. AI-assisted (Claude Code).
999 perf/shader-lane-condition-search : MERGED, CENSUS BEFORE THE PUSH
local ref: prready/999 (255377d), GitHub head
3ca9456git push fork prready/999:perf/shader-lane-condition-search
Resolved: main now remembers refuted states in Bools::meet too; kept this PR's search, tables and implies, added main's
decideson the new node table. The pass that finds all missing phis was REWRITTEN: it looks at main's live edges only and skips edges main calls never taken or dead.Checks: Mac lint 0, Mac tests formats 23, shader 120. Windows tests gpu 78, shader 211, 0 failed.
Not done: the census against main. "None goes from translating to refused", the byte-for-byte check and all timings in the body are from
ffe310eand the old phi pass. Do not repeat them for this head.Draft comment (if pushed without the census):
Merged main in (fast-forward). Main's search now remembers failed states as well, so item 1 gains less than the table says.
The pass that finds every missing phi was rewritten: it follows main's live edges and skips the edges main calls never taken or dead.
victory-shader 211 tests pass on Windows (RX 6800), clippy clean. The corpus comparison and the timings in the description are from
ffe310eand were not run again on this head.AI-assisted (Claude Code).
No push needed (mergeable, no failing check, no open question)
prready/1000, 993, 188, 172, 153, 126 = head + main, only to prove that they merge and build: do not push.
All six: clean merge, Mac lint 0, Mac tests pass (formats 23 to 25, shader 118 to 121). Their Windows-only tests (1000 and 153 gpu, 188 loader) were not run on the merge.
#1000: the two nits promised for its next change (a message when the test is skipped, one line on the order) are still open.
#124 is closed on GitHub: nothing done.
Worktree: C:\Users\theo_\victory-prs (detached at origin/main).
@Marvisak on GitHub · 2026-11-25 01:17 UTC · original · edited 2026-11-25 13:27 UTC
Automated triage for the maintainers.
Merge candidate (worth a look). Rebased onto current
mainand merges cleanly. It replacesReadProcessMemorywith a small user-mode copy routine (title_copy.rs,copy) for title-to-host copies only (copy_mappedwithtitle_dst == false), with a vectored handler that only redirects faults whose RIP lies inside the routine's ownbegin..endrange, and re-arms spent guard pages (guard_again);run_deferredtimes runs of fills as one. I read the assembly's length/tail handling and the handler's scope and found no issue; tests compare against the kernel copy at inaccessible, guard and concurrently unmapped pages. CIcheckpasses. The inline assembly and the extra exception handler deserve the maintainer's own read; the author claims only a microbenchmark gain, and a tester reports an in-world improvement on an RTX 5060.Generated by Claude Code
@TG0000 on GitHub · 2026-11-25 12:28 UTC · original
Merged main
940d32fin (fast-forward). The only conflict was the comment oncopy_mapped; it now says both things.Windows (RX 6800 and WARP, one thread): victory-gpu 152 and victory-shader 247 passed; clippy
-D warningsclean for the Windows target, with and without all features. The microbenchmark was not run again and I still claim no frame-time gain. AI-assisted (Claude Code).@HLVM04 on GitHub · 2026-11-25 15:29 UTC · original
A Windows/NVIDIA data point for the in-game side of this idea, from a different tree: our own local change on a fxceless/victory-fork base, not this PR's code. It reads title memory with a
rep movsbcopy, and a vectored handler turns a fault at that instruction into a failed copy, in place ofReadProcessMemory.That is the thread's time in the reads, on one machine, with scene variance. It is not a frame-time A/B, so it supports the per-call cost on native Windows but is not a measured fps gain for this PR.
@kais7654 on GitHub · 2026-11-25 17:15 UTC · original
Verified on the branch head (
6e3c516, Windows 11, RTX 5070 Laptop GPU,driver 616.87, hardware + WARP, rustc 1.98.1, --locked): clippy -D
warnings clean with and without --all-features; victory-gpu lib 150
passed / 2 failed — the two failures are the known heap-cap pair (#1943),
and the branch's own title_copy tests pass on hardware; victory-shader
lib 244 passed / 3 failed (the NVIDIA machine trio, #2317). Merge into
current main (
67e8ae1) is clean.@fuzeofficlal on GitHub · 2026-11-26 01:27 UTC · original
Code review (VEH /
watch.rs/PAGE_GUARDaudit) and RTX 5090 + WARP + release benchmark verification at head6e3c516074aemerged cleanly ontomain(63bcca43c6a0):title_copy.rs,host.rs:2500-2556):!title_dst(title -> host staging/upload); title-destination writes retainwatch::writing+ReadProcessMemory. ReadingPAGE_READONLYpages watched bywatch.rsdoes not fault or tripwatch::on_write.AddVectoredExceptionHandler(1, Some(on_fault))restricts interception strictly toAV/IN_PAGE_ERROR/GUARD_PAGEwithRipinside[victory_title_copy_begin .. victory_title_copy_end)and redirects tovictory_title_copy_failedwithout clobbering stack/non-volatile registers;guard_again(va)restoresPAGE_GUARDbeforecopy_mappedfalls back 64 KiB -> 4 KiB and zero-fills unreadable pages.VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:192 files ok;cargo clippy -p victory-gpu --all-targets -- -D warnings(default +--features diagnostics): 0 warningstitle_copy:: shadow:: watch:: host::skippingdescriptor::host/pipeline::host): 50/50 passed (2 ignored); WARP (--features diagnostics, skippingpresent_plane_tests): 69/69 passed (2 ignored)--releasetitle_copy_bench:514.9 -> 6.1 ns), 30.1x at 256 B, 13.0x at 1 KiB, 2.4x at 4 MiB538.3 -> 5.1 ns), 40.3x at 256 B, 12.2x at 1 KiB, 1.7x at 4 MiB4096constant fills: 2.8 / 8.4 / 16.3 ns each (64 / 256 / 512 B).Rock-solid safety boundaries and huge speedup; LGTM.
@MeMako on GitHub · 2026-11-26 03:51 UTC · original
Independent verification of
6e3c516on AMD Ryzen 9 7950X + AMD Radeon RX 9070 XT (adapter 0, driver32.0.32029.2010, Windows 1110.0.26200x64).CI checks & microbenchmark:
cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings(and--all-features): passcargo test -p victory-gpu --locked: 252 passed, 0 failed (including all newtitle_copytests)title_copy_bench(release build, Ryzen 9 7950X):64 B: heap362.8 → 7.6 ns(48x), upload399.9 → 3.5 ns(115x)256 B: heap357.0 → 17.8 ns(20x), upload442.6 → 10.0 ns(44x)4 KiB: heap789.6 → 220.4 ns(3.6x), upload857.5 → 238.4 ns(3.6x)64 KiB: heap3.88 → 1.99 µs(1.9x), upload4.42 → 2.42 µs(1.8x)4 MiB: heap195.8 → 114.7 µs(1.7x), upload234.2 → 147.6 µs(1.6x)1437 → 1118 nsLive title run (release build, warm shader & pipeline cache):
(Note: merged cleanly onto a local RX 9070 XT branch on
842b0cbcarrying a separate-handle workaround equivalent to #2122,DYNAMIC = 1 << 19, #2051, #2472, and #2918; compared against the same branch without #1010.)draws >= 500)n=116)n=82)copiestime / volume (median)89.5 ms(155 MB)71.2 ms(154 MB)505.4 ms(2.00 fps)455.8 ms(2.20 fps)copy_back_marks(median)81.2 ms(32.1 µs/page)72.3 ms(31.0 µs/page)00#1010+#2918VEH handlers coexist cleanly)No game data, shader names, or screenshots are included, per
docs/asset-policy.md. Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.@DenRakEiw on GitHub · 2026-11-24 15:02 UTC · original · approved these changes
Tested head
e99253e(fast-forward onmainffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):cargo test -p victory-gpu(RTX 5090): 56 passed, 0 failed, 3 ignored (including all newtitle_copy::tests::*andhost::fills::steps_run_in_order_and_unmapped_pages_read_as_zeros)VICTORY_D3D12_WARP=1 cargo test -p victory-gpu(WARP): 56 passed, 0 failed, 3 ignoredcargo clippy -p victory-gpu --all-targets: 0 warningscargo xtask policy: ok (156 files ok)Clean SEH-guarded title-memory copy avoiding per-copy syscalls, with strong fault/protection/unmap test coverage. Approving.
AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 14:39 UTC · original · approved these changes
Reviewed
6e3c516074aef3dbcf04ba6ffee8598ac9d66bd5merged cleanly ontomain(63bcca43c6a0) and verified on Windows 11 x64 (Ryzen 9 9950X, NVIDIA GeForce RTX 5090, Microsoft WARP,VICTORY_D3D12_DEBUG=1, Rust1.98.1, debug and--release).Code Review
crates/victory-gpu/src/title_copy.rs:28-105):victory_title_copyis a pure leaf routine that leavesrspand all non-volatile registers untouched (onlyrax,rcx,rdx,r8–r10, andxmm0–xmm3), so redirectingRiptovictory_title_copy_failed(xor eax, eax; ret) is safe under--releaseoptimization without stack unwinding. All length tiers (0,1..=15,16..=63,64+, overlapping 16 B tail) handle exact boundaries cleanly in ascending order for write-combined upload destinations.PAGE_GUARD(crates/victory-gpu/src/title_copy.rs:107-176,crates/victory-gpu/src/host.rs:2026):!title_dst(title → host) copies; title-destination writes continue usingwatch::writing+ReadProcessMemory, and any failed bulk read falls back to the existing 64 KiB → 4 KiB page-by-page zero-fill path.on_faultintercepts onlyEXCEPTION_ACCESS_VIOLATION,EXCEPTION_IN_PAGE_ERROR, andEXCEPTION_GUARD_PAGEwithRipinside[victory_title_copy_begin .. victory_title_copy_end)and holds no shared mutable state, making concurrent multi-threaded faults safe. It coexists cleanly withwatch::on_writein either handler order (read faults onsrcare ignored bywatch::on_write, and write faults outside[begin..end)are ignored byon_fault).guard_againre-arms spentPAGE_GUARDpages viaVirtualQuery/VirtualProtectand restoresoldif another thread changed the base protection in between.crates/victory-gpu/src/host.rs:1799,1842): Batching consecutiveStep::Fillentries under one timer preserves ordering relative toStep::Copy,Step::Refresh,Step::Run, andStep::GpuWrite.Verification (9950X + RTX 5090 + WARP +
VICTORY_D3D12_DEBUG=1, Rust1.98.1)cargo run --locked -p xtask -- policy:192 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features): 0 warnings.victory-gpu(title_copy:: host::fills:: host::title_copies:: watch:: shadow::): 36/36 passed (2 benchmarks ignored) on RTX 5090 + Debug Layer, WARP (--features diagnostics) + Debug Layer, and--releaseRTX 5090.--releaseVEH coexistence stress probe (6 reader threads callingtitle_copy::copyconcurrently across valid RW,PAGE_NOACCESS,MEM_DECOMMIT,PAGE_GUARD, andwatch::track-guarded pages while 2 writer threads concurrently fault intowatch::on_write): passed (ok_reads=960,faults_caught=1440, both watched pages marked dirty,PAGE_GUARDpreserved as0x104).--releasebenchmarks on Ryzen 9 9950X + RTX 5090:title_copy_bench(to heap): 64 B484.4 -> 5.8 ns(83.3x), 256 B438.3 -> 15.1 ns(29.1x), 1 KiB903.8 -> 60.4 ns(15.0x), 4 KiB1162.8 -> 248.3 ns(4.7x), 64 KiB4312.8 -> 1617.4 ns(2.7x), 4 MiB217.2 -> 92.1 µs(2.4x).title_copy_bench(to RTX 5090 upload buffer): 64 B517.9 -> 11.0 ns(46.9x), 256 B532.1 -> 11.3 ns(47.2x), 1 KiB986.2 -> 64.4 ns(15.3x), 4 KiB1244.6 -> 255.3 ns(4.9x), 64 KiB5547.6 -> 2835.8 ns(2.0x), 4 MiB291.6 -> 169.0 µs(1.7x).1698 -> 1311 ns.constant_fills_per_list(4,096 fills):64 B: 11.7 µs (2.9 ns/fill),256 B: 32.9 µs (8.0 ns/fill),512 B: 68.6 µs (16.7 ns/fill).LGTM.
@tumbubu on GitHub · 2026-11-26 18:21 UTC · original
6e3c516merged onto currentmain63bcca4, measured in the world on an RX 7900 XT (Windows): refresh copies run at 4.6–5.0 GB/s against 3.8–3.9 onmain. In the stack samples the refresh'sZwReadVirtualMemorybecomesvictory_title_copy. Tests: 240 passed.This adds a Windows/AMD data point next to the RTX 5060 Laptop and Linux runs above.
--profile diag --features diagnostics) of63bcca4, and of63bcca4with this PR merged (clean,17c95b0). The translator is the same, so one cache warmed withtranslate --cache --pipelinesserved both, and no shader was translated during the runs.VICTORY_LOG=info. Two runs per build; the second of each was sampled withVICTORY_STACKS.mainmain, sampledStack samples (a dump every 0.25 s from 105 s to 175 s; 80 dumps on
main, 84 with this PR;victory.exesymbolised from the build's PDB):mainZwReadVirtualMemory←copy_mapped←Shadow::update←Batch::flushvictory_title_copy_begin←copy_mapped←Shadow::updateZwReadVirtualMemoryelsewhere:copy_back_marks,write_mapped,copy_back_or_not,watch::mark_changedTests.
cargo test --locked -p victory-gpu --lib -- --test-threads=1on the merge: 240 passed, 0 failed, 3 ignored.AI-assisted (Claude Code); every run was on this machine. Only timings, counts and VIctory's own function names are posted, no game files.
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.