Title memory by address: make a rehydration's inputs ready before it runs #87
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/ReTerryDavis--ReVIctory!87
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-86"
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?
@Mbappinho on GitHub · 2026-12-05 05:00 UTC · original
Mbappinho:sw-rehydrate-ready→main· +146 −13 · 3 files · 2 commits · openWhat this changes
With
-RayTracing(the software walk, the default), the builder's rehydration stages read each geometry's vertices, indices and transform through pointers that none of their dispatch arguments show. Title memory by address gives a page a copy on the card only after a shader has touched it without one, and that access reads 0. Draws and per-frame builds recover on the next frame. A structure is rehydrated once, though, so it kept those zeros for the rest of the run.The probe's rehydrate wrapper already reads the geometry descriptions the title passes, for its counts. It now also hands their ranges to title memory by address before it calls the DLL (
memory::ready_ahead, exported asvictory_gpu::title_memory_ready_ahead). The ranges are the vertices (with the 32 bytes before the first vertex, where the title's quantized positions keep their header), the indices and the transform.VICTORY_BVH_REHYDRATE_PREPARE=0.-RayTracingunlessVICTORY_BVH_PROBE=0; turning the probe off also turns this off.How it was found
I took memory dumps (
VICTORY_MEMORY_DUMP, diagnostics build) 110 s into the world, read the rehydrated structures back from the arenas and decoded their leaves. I first checked the reader on the structures the title's builder built itself in the same dumps.VICTORY_BVH_REHYDRATE_PREPARE=0(asmain)The first two rows come from two back-to-back runs of one exe with the switch flipped. I measured the second row again with this branch's exe and got the same figures. With the change, 1,302 of 1,701 rehydrated structures are whole, against 738 of 1,707 without it.
Before the change, 80 % of the structures with at least 70 % zero leaves had vertex or index pages missing from the card's copy at dump time, against 9 % of the structures with under 10 % zero leaves. The runtime's own warning ("shaders touched pages that had no copy (those accesses read 0 ...)") fires while the world loads.
Measured
RX 9070 XT, Ryzen 7 9800X3D, 32 GB, Windows 11. Release build of this branch. Series X,
-RayTracing -NoPcQuality, no other switch. Same save, standing still outdoors, 60 s to settle, then 150 s measured, nobody at the controls; runs alternated (on, off, off, on).VICTORY_BVH_REHYDRATE_PREPARE=0966f7e7c+ #81 + this change, software walk): GI pass output (mean red of its target) 3.90 and 3.96 with this change, 4.99 without (one run), 3.82 with #81's hardware walk. Probe hit distance 3,074 and 3,143 with this change, 4,236 without, 2,475 with hardware rays. With this change the software walk's GI pass output comes close to the hardware walk's (the light gap I reported in #81 mostly closes); the probe hit distance still differs, and I have no console reference to say which is right.Checks
cargo clippy --workspace --all-targets --locked -- -D warnings, and with--all-features: clean.cargo test --workspace --locked --no-fail-fast: everything that ran passed excepthost::stamps::tests::a_submissions_times_are_the_pcs, which fails onmainon this PC too.victory-loader's unit tests hang here when run in parallel, as noted in #81, and I stopped the run there.cargo test --workspace --all-features --locked -- --test-threads=1: the samehost::stampsfailure. In one full run,descriptor::host::tests::slots_gray_for_long_are_namedalso failed (it times slots in seconds); it then passed in 3 of 3 runs of thevictory-gputests on this branch and 2 of 2 onmain.cargo xtask policy: ok.Made with Claude Code.
@ReTerryDavis on GitHub · 2026-12-05 09:44 UTC · original
Awesome improvement for software
-RayTracing! Just a few small fixes incrates/victory-gpu/src/memory.rsbefore merging:pub fn ready_aheadwas inserted betweenpub(crate) fn ready's doc comment (/// Before a draw...) andfn ready(...), attachingready's docs toready_ahead.ready_ahead:address + len - 1can overflowu64on malformed inputs—useaddress.saturating_add(len - 1)and clamp the end page tou64::from(MEMORY_PAGES) - 1before iteratingpages.clone().filter(...).m.frame: Syncm.frametocrate::frame::current()(for compatibility with627da77'sDIRTY_WINDOW/dirty_epochtracking ifready_aheadruns beforememory::ready()on a new frame). Optional nice-to-have: mark newly mapped read-only input arena pagesheld.loose = trueto matchmemory::ready.(The
Default testsCI failure was just an unrelated pre-existingdescriptor.rsflake.) Once those small items inmemory.rsare tidied up, this is ready to merge!6f9374a257to3aa85624cb@Mbappinho on GitHub · 2026-12-05 17:57 UTC · original
Thanks for the review. All three are in
3aa85624, with the branch rebased onmainata6b5a998(it merges cleanly with today's8bff52be):ready_aheadnow comes afterready, with its own doc comment;ready's doc comment is back onready.address.saturating_add(len - 1) / PAGE, capped atMEMORY_PAGES - 1, and a range that is empty or starts past the directory is skipped.readydid inline (setm.frame, clearrefused,take_faults,look_again,report, and the diagnostics' per-frame work) is nowMemory::begin_frame, called by both. A rehydration that comes first in a frame starts that frame asreadywould, soreadydoes not skip the start and whatready_aheaddirties carries the current frame. The pages given a copy here are markedloose, as a read-only view's.Checked on this exact build: clippy with and without
--all-features(withmain's own lint failures allowed), the workspace tests butvictory-gpu, whose test target does not build onmain(overlay/shots.rs,Tab::Lighting), on one thread sincevictory-loader's hang with the default count (see #81): 1076 passed, 0 failed; and a memory dump: of the rehydrated structures' leaves, 86 of 1.65 M read zero (about half without the fix, in the earlier dumps). On8f78f14athe fix gave 30.3 / 30.2 fps against 25.4 / 26.3 without; on currentmainthe frame is bound by a slowdown that I will detail on #81 (19.5 / 19.8 against 19.9 / 20.2), so the gain on the card does not show there.Made with Claude Code.
@Saksukella on GitHub · 2026-12-05 18:01 UTC · original
Tested this independently on **AMD Radeon RX 9070 XT (
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.