GPU: in-place guarded writes for write_mapped when VICTORY_COPY_PLAIN=1 (-20 ms copy-back) #1032
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1032
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1032"
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?
@UwUCammie on GitHub · 2026-11-25 16:49 UTC · original
UwUCammie:pr/plaincopy-write→main· +110 −11 · 2 files · 1 commits · openWhen
VICTORY_COPY_PLAIN=1is on, reads from title memory already run in place viavictory_copy_guarded, butwrite_mappedwas still sending every shader-written copy-back chunk throughNtWriteVirtualMemoryeven thoughwatch::writingjust opened the guards right before it.What changed
victory_write_guardedtwin inplaincopy.rs(rep movsbwith WRITE-fault handling in the existing vectored exception handler).host::write_mappedtriesplaincopy::writefirst whenVICTORY_COPY_PLAIN=1(opt-out withVICTORY_WRITE_PLAIN=0) and falls back to the existingNtWriteVirtualMemory/ per-page path if any destination page is unmapped or read-only.plaincopyframe line and a unit test (a_readonly_or_unmapped_destination_ends_the_write_without_a_fault) covering writable, uncommitted, and read-only pages.Tested
VICTORY_LATE_WAIT=3,VICTORY_COPY_PLAIN=1,VICTORY_QUEUE2=1,VICTORY_ASYNC_SUBMIT=1,VICTORY_JOIN_PARTS=1,VICTORY_BACK_OWN_VIEW=1).4,250–4,740writes/frame (61–64 MB/frame) completed in place with0.0fallbacks.49.4 msto29.6 ms(~20 ms/frame saved); overall frame time moved from202–207 ms(4.9–5.0 fps) to184–186 ms(5.4 fps) with zero visual regressions or faults.plaincopy::tests(5/5) pass under Wine on465b94f.@Xeltax on GitHub · 2026-11-25 17:24 UTC · original
Tested on an RTX 4080 (Windows 11, D3D12, Ryzen 9 9900X), on a branch that is fork main
465b94fplus the BVH builder work from Xeltax/VIckyrt. Same scene every run (no input), builder on,VICTORY_COPY_PLAIN=1 VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_JOIN_PARTS=1 VICTORY_BACK_OWN_VIEW=1 VICTORY_INDIRECT_GATHER=1.So about 11% on the frame here, two runs each.
AI-assisted (Claude Code ran the measurements and wrote this up).
@Ym1r1710 on GitHub · 2026-11-25 17:30 UTC · original
Tried this on Windows, RTX 5080, on top of
ca8829fwith COPY_PLAIN=1, RELAY=2, QUEUE2=1, ASYNC_SUBMIT=1 (no JOIN_PARTS / BACK_OWN_VIEW). The new counter stayed at "writes back in place: 0, 0.0 MB, 0.0 fell back" for the whole run and frame time was the same as without it (~122 ms median at world+800). Looks like with these switches the copy-back never reaches write_mapped, it goes through the exact merge in copy_back_with instead. So no gain here, but no harm either, picture unchanged.@Proudnoob4 on GitHub · 2026-11-25 17:39 UTC · original
Tested in-game on Windows 10 Pro (22H2), Intel i5-13600K (6P+8E), RTX 4080 16 GB (driver 621.01, Series X profile), 420 s run in the prison cell scene (
ca8829f+ #1014 + #1015 + #1016 + #1029 + #1032 stacked, compared against our 600 s465b94frun with the same base switches VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_COPY_PLAIN=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_JOIN_PARTS=1 VICTORY_BACK_OWN_VIEW=1 VICTORY_INDIRECT_GATHER=1 plus VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_GROUP_SYNC=2 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024).Windows 10 RTX 4080 measurement with VICTORY_COPY_PLAIN=1 (VICTORY_WRITE_PLAIN default on):
465b94f(so WriteProcessMemory wasn't the bottleneck on Windows 10 here like under Wine, though all writes stayed in place cleanly with@UwUCammie on GitHub · 2026-11-25 17:40 UTC · original
Thanks for testing on Windows everyone!
Good to see 0 fallbacks across all three setups — and interesting how much bigger the win is under Wine (~20 ms) and on Xeltax's setup (~11%) compared to Win10
RELAY=2whereNtWriteVirtualMemoryoverhead is smaller.@Ym1r1710 curious why you got 0 there — both
copy_back_withandrelay_merge/card_merge_relaystill callhost::write_mapped, and in myRELAY=2+BACK_OWN_VIEW=1run here (and Proudnoob4'sRELAY=2run above) it's still doing ~550-650 writes back in place (~23-26 MB/frame) with 0 fallbacks. Worth checking ifhost.rshad theplaincopy::writeline applied or if another switch was bypassingwrite_mapped?@Ym1r1710 on GitHub · 2026-11-25 17:48 UTC · original
Found it, my fault for not saying. My tree also has the #690 exact copy-back on top (VICTORY_EXACT_BACK, on by default there), and with that every merge path returns through putback before it gets to write_mapped. So on plain main it should behave like your runs. I'll try it again without #690 when I get a chance.
@ThomasHFWright on GitHub · 2026-11-25 18:12 UTC · original
Linux/Proton validation of an adapted
d919676c5bon CachyOS / Ryzen 7 9800X3D / RTX 5090 / NVIDIA 620.73.04 / GE-Proton 11-14.Local adaptations keep writes explicitly opt-in (both COPY_PLAIN=1 and WRITE_PLAIN=1), handle both source and destination faults, and exercise complete-range fallback after partial copies/remaps. Relevant tests pass in the GPU suite (211 passed, 4 existing runtime failures, 8 ignored).
A synthetic Windows debug-profile test under Proton compares the production helper with NtWriteVirtualMemory: 64 KiB copies, 12 ABBA cycles, 24 samples/path, same stable VirtualAlloc mappings, canaries/readback outside timing. Median guarded/kernel time: hot 64 KiB 553/14,464 ns (26.1x); rotating 16 MiB 2,258/22,972 ns (10.2x). These are cached CPU-copy measurements, not FPS gains or section-view/remap atomicity proof. The benchmark is retained as an ignored test.
The guarded-copy title trial actually exercised write_mapped, with zero reported write fallbacks across its telemetry, normal incomplete visuals and no Xid. It ended after 421.64 s at the same existing title assertion. Scene/cache differences prevent a causal FPS comparison; recent combined trials did show occasional guarded-write fallbacks. Writes remain default-off here.
Source, benchmark and limits: https://github.com/ThomasHFWright/LinVictory/blob/linux-edge/docs/linux-improvements.md
AI-assisted integration/testing with OpenAI Codex; aggregate results only.
@gmankab on GitHub · 2026-11-25 18:51 UTC · original · edited 2026-11-25 18:58 UTC
I tested this PR’s
d919676c5b775408296cea28489e786c5d5cc78dchange on an RX 6800 under Wine and RADV. Both Series S runs used the same integration executable, copies of the same prefix, the same input sequence, andVICTORY_COPY_PLAIN=1 VICTORY_RELAY=2 VICTORY_LATE_WAIT=2. OnlyVICTORY_WRITE_PLAINchanged.In the first common 34-second interval after the heavy scene started, there were two host reports per run with at least 1 MB/frame copied back. The median of their copy-back time per MB was 74.46 ms/MB with guarded writes off and 21.49 ms/MB with guarded writes on. The enabled run reported 450–608 direct writes per frame, 15.8–20.2 MB per frame, and 0.0 fallbacks in the qualifying direct-write reports. Draw and copy volumes differed between the runs, so these samples are too small for a sustained performance estimate.
The enabled run hit the title’s known watchdog. The guest deliberately writes to address zero at that site after the main thread stops advancing. Both runs used the default watchdog behavior. Earlier FX and KLBF builds hit the same site before this PR. Watchdog report · Watchdog implementation The disabled run reached the 420-second timeout. The kernel reported no GPU reset. All five
plaincopy::testspassed in the same Wine environment.Tested-on: RX 6800, Xeon E5-2670 v3, Fedora Linux 45 Silverblue, Wine and RADV 26.2.5 in the Victory Flatpak.
Assisted-by: gpt-6.2 sol xhigh
@Filip722 on GitHub · 2026-11-26 00:44 UTC · original
I tested
d919676on a local integration based on upstreamdc4c0fc, using Bazzite 44, GE-Proton11-14 and an RTX 5060 Laptop GPU. All six focusedplaincopy::tests::cases passed, including the read-only and unmapped destination test.With both
VICTORY_COPY_PLAIN=1andVICTORY_WRITE_PLAIN=1, the offline Series S transition reached DXGI Present. A recorded frame issued about 299,000 in-process writes for 2.7 MB with zero fallbacks. The frame still spent about 30 seconds in synchronous copy-back and the title hit its stall watchdog (#416). The render thread ran for 0.34 seconds and the GPU wait was 0.14 seconds for that frame. This confirms the guarded write path was exercised and points to a remaining wait in the copy-back sequence on this setup.Codex assisted with the integration and tests.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.