Repository navigation
GPU: use VEH-guarded in-process copy for copy_mapped and write_mapped (#118) - #154
BitWuehler wants to merge 1 commit into
Conversation
|
In-world follow-up on CachyOS Linux (
Caveat on isolating (AI-assisted analysis from session logs; numbers directly extracted from the two runs.) |
|
We merged this PR into our test branch and measured it on an RTX 4070, paired within one run ( One of the runs also ended at boot (~52 s, before the world) with an unhandled
A possible fix: in AI-assisted. |
|
On an RTX 3080 Ti this PR changes the picture: two alpha/decal textures in the prologue's first room never arrive. Details, in case it helps. Setup — Windows 11, RTX 3080 Ti 12 GB, 64 GB RAM, Result, 3 runs each
So the walls are A guess at the cause, not verified: the handler is installed first (
The speed side is real here too (this PR was in the stack whose frame time I reported on #175); I am only flagging the picture. (Runs and screenshots by me on the hardware above; comparison and this note written with Claude Code.) |
|
Measurements of the same idea on Windows, with the read side alone, in case they help with the two open questions here (no gain on Windows, and the window mesh / shirt print that go missing). Setup. RTX 5080 16 GB (driver 610.88), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 22631, diag build, rustc 1.98.1. Each run loads the autosaved checkpoint at the cell window and nobody touches the pad. Frame time is the spacing of the The variant differs from this PR in three ways (branch: https://github.com/larelgit/victory-fork/tree/perf/user-copies, two commits on 310c6eb):
Reads only, on 310c6eb with its defaults (no switches;
(A first run of the new binary, translating its shaders, is left out: 179 ms with plain loads.) The copies get about 9.5 ms a frame cheaper, and the submitting thread then waits for the card about as much longer: the card is about 80 % busy and sets the frame, so on this machine with these defaults the frame time does not move (2 ms, inside the spread). 8-10 copies a frame fault and go to the kernel, the same count as the kernel path's own fallbacks. Picture. The chain-link mesh in the window and the print on the back of the shirt are there in all 11 runs, the 6 with plain loads included (the first one too). The cell walls were drawn in 2 of the 6 runs with plain loads and 1 of the 5 with the kernel ( Why the write side is left out of the variant. Title memory is write-watched, and each asking resets the watch, after which the first store to every page faults. The kernel takes those faults for less than user mode does: a 64 KiB piece into freshly reset write-watched pages took 11.4 µs through (Runs, measurements and this note by Claude Code with Claude Opus 5.5 on the hardware above, at the account owner's request.) |
…process copy for copy_mapped and write_mapped (by BitWuehler)
|
I measured this pull request on native Windows. The processor and the card are the same as in your Proton test. Setup
Result Each number is the median of the frame lines of one run in that scene.
The kernel time of the submitting thread decreases by half, and preparing decreases by about 10 ms a frame. The log shows 0 errors and no device loss in the two runs. The frame rate does not change on Two notes
I made the measurements with an AI assistant (Claude Code), on my own machine. This comment has no game data. |
|
Measured this pull request on Linux/Proton, where the submitting thread (not the card) sets the frame, so the saving in preparing shows up as frame rate. Setup: RTX 4070 Ti, Linux, Proton Experimental with vkd3d-proton, Series X files. Our tree is the fork at 2119b0e plus a few open pull requests (this one included). Relay stage 1,
Preparing goes down by about 15-20 ms a frame. Here the card waits on the submitting thread, so the frame rate goes up by about 8-15%. The off and on runs were interleaved (off, on, off, on). The sampled screenshots look the same in both settings: intro art, cutscene faces, the first room. No device loss, no new errors. This fits @advxrsary's native Windows numbers: preparing goes down the same way there, but the frame does not change because the card is the limit on that machine. Measured and written with AI assistance (Claude Code, Claude Opus 5.5). |
|
The case @advxrsary described above does happen, on The faulting stack, symbolized with the build's PDB, is the same in all four (the last frames differ only between a dispatch and a mesh dispatch): So a texture's bytes in title memory include a page the title asked for with A fix along the lines of the local variant @advxrsary mentions would cover it: treat Machine: RTX 5080, Ryzen 7 7800X3D, 32 GB, Windows 11; diagnostics build. (Runs and this note by Claude Code with Claude Opus 5.5, at the account owner's request.) |
08e3d30 to
82dbea5
Compare
|
Rebased and updated PR #154 (
Verification on
AI-assisted (prepared and unit-tested locally; no application/asset data referenced). |
Summary
Rebased onto
fxceless/victory-forkmain(c36971b), extendingcrates/victory-gpu/src/plaincopy.rsfor:PAGE_GUARD(STATUS_GUARD_PAGE_VIOLATION/0x80000001) handling & re-arming (rearm_guard) on both reads and writes, preventing unhandled guard-page exceptions and restoringPAGE_GUARDviaVirtualQuery+VirtualProtect(..., info.Protect | PAGE_GUARD)before failing back to the kernel path.VICTORY_COPY_PLAIN_WRITES=1orVICTORY_DIRECT_COPY=1, off by default) forhost::copy_mapped(title_dst) andhost::write_mappedviavictory_write_guarded+ sharedwatch::handle_write_fault(at).Why this shape on top of
c36971bmain(c36971b) already landedplaincopy.rs(VICTORY_COPY_PLAIN=1) for reads (copy_mappednon-title_dst&read_into) while leaving< 256-byte probes and writes on the kernel path. Keepingmain's read design andLEAST = 256leaves native Windows defaults and picture behavior untouched.VICTORY_COPY_PLAIN_WRITES=1, off by default) avoids changing Windows write behavior (where @larelgit measuredNtWriteVirtualMemorywinning on freshly resetMEM_WRITE_WATCHpages) while still allowing Wine/Proton users to bypassNtWriteVirtualMemorywineserverIPC when desired.EXCEPTION_GUARD_PAGE(0x80000001) inplaincopy::on_faultand callingrearm_guardbefore exiting viavictory_copy_guarded_faultfixes the crash mode identified by @iurysf, @advxrsary, and @larelgit whenever a copied source/target page carriesPAGE_GUARD.Changed files
crates/victory-gpu/src/watch.rs: extractedpub(crate) fn handle_write_fault(at: usize) -> boolfromon_writesowatch::on_writeandplaincopy::on_faultshare the same write-watch guard-opening path.crates/victory-gpu/src/plaincopy.rs: addedvictory_write_guarded(rep movsbwith Win64 SEH unwind directives),writes_on(),rearm_guard(at),WRITE == 1write-fault handling inon_fault,write(to, from, len), write counters inline(frames), and unit testsguard_page_fails_copy_and_stays_guardedandguarded_write_skips_unmapped_and_readonly_and_marks_write_watch.crates/victory-gpu/src/host.rs: routedcopy_mapped(title_dst) andwrite_mapped(direct_writes() && crate::plaincopy::writes_on()) throughcrate::plaincopy::write.Verification (
82dbea5onc36971b)cargo xtask policy:185 files okcargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc:0warnings in modified files (plaincopy.rs,watch.rs,host.rs; 7/8 pre-existing upstream warnings in untouched modules).GE-Proton11-14(vkd3d-proton,VICTORY_COPY_PLAIN=1 VICTORY_COPY_PLAIN_WRITES=1):plaincopy::tests:::6 passed; 0 failed(includingguard_page_fails_copy_and_stays_guardedandguarded_write_skips_unmapped_and_readonly_and_marks_write_watch)watch::tests:: --skip drvwatch --test-threads=1:11 passed; 0 failed(drvwatch::tests::the_system_takes_the_subscriptionskipped due to WineEvtSubscribestub)host::tests:: --test-threads=1:22 passed; 0 failedshadow:::30 passed; 0 failedtexture:::2 passed; 0 failed(Prepared and verified with AI assistance.)