VICTORY_WC_NO_BACK=1: shaders' writes into write-combined title memory stay on the card (with a read census) #477
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/Belobug--VIctory-Belobug-AMD!477
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-477"
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?
@icecreammule277-dot on GitHub · 2026-11-27 05:19 UTC · original
icecreammule277-dot:wc-no-back→a-publier· +939 −2 · 8 files · 7 commits · openAI-assisted (Claude Code). Numbers and log lines only.
Builds on #476: its first two commits are that PR. Adds
VICTORY_WC_NO_BACK=1(off by default). Shaders' writes into title memory the title asked for as write-combined stay on the card. They aren't declared as written, so there's no snapshot, no compare and no copy-back. A census switch checks that the title doesn't read them.Why
#476 showed that all of the copy-back in a heavy scene goes into write-combined memory. On the console the CPU writes such memory but doesn't read it back. This follows the console's own model: what the GPU wrote stays where the GPU wrote it. It's the same idea as fxceless/victory-fork issue #1169 and PR #1178 (lazy copy-back), but much narrower: no fault handler, and it's chosen by the protection the title asked for.
What it does
VICTORY_WC_NO_BACK_MIN_KB) that lies wholly in write-combined title memory. Its copy must also be in the card's memory and known to be write-watched.Shadow::card_owns).VICTORY_WC_KEEP_STORES=1(off): copies holding such ranges send up only the dwords the title changed, through the existingkeep_storespath. A part the CPU writes only in part otherwise goes up whole, with older title bytes next to the CPU's. The trade-off is that exact sending misses a value written over the same value. It's separate because neither side has evidence yet.VICTORY_WC_CENSUS=1(diagnostics, needsVICTORY_WC_NO_BACK=1), after #1169's read census:PAGE_GUARD. This is done holding the write guards' lock exclusively, and never on a block the guards keep read-only or one the kernel is writing for the title (kernel_writingtakes the census's guards off).VICTORY_WC_STATSline.Results (diagnostics build, 7900 XTX, plus the
PORT_*switches andVICTORY_WINDOWS_BAR_MB=1024)Matched A/B: same save loaded, standing still, a 62-second window each, with the unwatched and host-memory copies copied back as above.
The remaining copy-back time is mostly copies in host memory, which are still copied back.
Census: about 13 minutes of play with
VICTORY_WC_CENSUS=1.vmovups; the rest are similar packing loops. None of them load from their destination.Visual check: no difference seen. A foliage flicker that turned up shows with the switch off too, at the same spot.
Tests
cargo test -p victory-gpu --lib -- census:: wc:: shadow::: 40 passed. They cover the range set (join, cut, cover) and a census test on real guarded pages: a read, a write and a tagged touch are each counted once and go on. Built with--profile diag --features diagnostics.🤖 Generated with Claude Code
@MamaLeVrai on GitHub · 2026-11-27 07:01 UTC · original
Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At
0834177:victory-gpu401 passed, 0 failed, 34 ignored;victory-hle162 passed, 0 failed, 2 ignored.AI-assisted (Claude Code); no game data.
@gw1337x on GitHub · 2026-11-27 09:39 UTC · original
Tested in the title on RDNA 3: RX 7800 XT 16 GB, driver 32.0.32015.7029, Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds (
--profile diag --features diagnostics) of0834177and its base4eb6cfd, same boot.Settings:
scripts/play.ps1settings plusVICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, Series X profile, ray tracing off; the PR's runs addVICTORY_WC_NO_BACK=1. Method: 270 s hands-off from a Chapter I boat save; fps is the layer's 1 s figure from the window title, sampled every second, 45-265 s with 1000+ draws ("steady" from 205 s); per-frame figures fromVICTORY_TIMELINEwindows of 30 frames at 200 s and 240 s; screenshots every 5 s.0834177NO_BACK4eb6cfd0834177NO_BACK4eb6cfd0834177NO_BACK0834177NO_BACK +VICTORY_WC_CENSUS=1What showed:
VICTORY_WC_NO_BACK=1the steady figure is 30.0 in all five runs against 28.6 in the two base runs here; frames are about 1-1.5 ms shorter.wcline reports 800-1,300 declarations a frame left on the card in the boat scene; 5-12 MB a frame of small ones still copied back.Five runs of the PR with the switch, one scene, ray tracing off.
@gw1337x on GitHub · 2026-11-27 12:07 UTC · original
#477 and #470 stack, measured together. Memory Integrity was off.
PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, Belobug launcher settings plus the 5 port switches. I made a local build of #477 (
0834177) with #470's two commits cherry-picked on top (no conflicts) and ran it withVICTORY_WC_NO_BACK=1. Compared against4eb6cfd, 3 runs each, interleaved.4eb6cfdEach PR keeps its own gain when they're combined: #477's steady fps and #470's faster load.
@gw1337x on GitHub · 2026-11-27 13:35 UTC · original
Follow-up: #477 with
VICTORY_WC_NO_BACK=1while driving, not just sitting in the boat. Memory Integrity was off.PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. RT off, Belobug launcher settings plus the 5 port switches, warm caches. #477 (
0834177) on4eb6cfdvs4eb6cfd, interleaved (PR, base, PR, base, PR, base). Same boat scene; scripted full throttle from 190 s with no steering, run ends at 220 s.Routes split after about 205 s even on base (same input, different heading), so the main window is 190-205 s, and the frame-time numbers come from the timelines taken at 190 s and 200 s (30 frames each, 60 per run).
The #477 + #470 stack gave the same result in this test (190-205 s: 29.0-30.0 fps, 0-2 frames over 40 ms of 60), so the gain while driving comes from #477, as it does sitting still.
AI-assisted (Claude Code); numbers from the run logs and timelines.
@luisaugustz on GitHub · 2026-11-27 14:59 UTC · original
Confirming on RX 9070 XT + Ryzen 7 5800X (a-publier
4eb6cfd+ this PR, Series X, RT off, same save and spot):VICTORY_WC_NO_BACK=1Copy back fell from about 21 MB to 2.6 MB a frame. We have played with it on for several sessions since and have not noticed anything it breaks, though we did not do a careful visual A/B.
@gut0to on GitHub · 2026-11-27 15:10 UTC · original · reviewed
AI-assisted static review; I traced the page-arm failure path and the vectored exception handler. I did not run the test suite.
@ -0,0 +265,4 @@let pages = (region_end - at) / PAGE;// The bits before the guard: a hit at once is then the census's.for page in at / PAGE..region_end / PAGE {ours()[page / 64].fetch_or(1u64 << (page % 64), Relaxed);@gut0to on GitHub · 2026-11-27 15:10 UTC · original
AI-assisted review: these
oursbits are set beforeVirtualProtectso an immediate census fault is recognized, but they are not rolled back whenVirtualProtectfails. If the address is later reused and another owner installsPAGE_GUARD,on_guardwill treat that unrelated exception as ours and returnCONTINUE_EXECUTION, consuming the other guard. Could the arm state be rolled back safely on failure while preserving the immediate-fault case, with a test for a failed arm followed by a foreign guard?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.