GPU: batch page-table rebuilds by region and owner #3230
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3232"
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?
Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T13:53:33Z.
Problem
When title-memory copies change, the GPU page table is rebuilt. The builder used to recalculate the region and update ownership one 64 KiB page at a time for each copy, including large overlapping windows. It then looked up the same descriptor and base address separately for every page in a run.
Change
Allocate level-two blocks in the existing order, then fill each copy's whole pages in bulk within each 256 MiB region. Partial edge pages still claim only unowned entries. Emit runs of identical page owners with one descriptor lookup per run. Ownership, offsets, null entries and the table's block limit stay the same. The GPU mapping is only written.
Synthetic benchmark
Windows x64, Core Ultra 9 275HX, Rust 1.98.1 with
-C opt-level=3. Medians of 20 interleaved runs of both builders. Timings include construction and emission of the page table into cached CPU memory. D3D12 synchronization, descriptor creation, and title execution are outside the measurement.The last two rows deliberately use 8 to 10 GiB virtual windows to stress repeated ownership updates. The short copies span 1 to 16 pages across 64 regions. The 174 MiB rows show the smaller gain with shorter windows.
Validation
victory-gpulibrary suite with diagnostics: 247 passed, 1 ignored. Strict Clippy andcargo xtask policypassed.Coordination claim. No game files used. AI-assisted (Codex).
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T14:07:50Z.
Review: APPROVED
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-gpu --lib memory:: -- --test-threads=1 --skip lists_share_a_table_and_copies_keep_their_views: 8/8 passed on RTX 5090 and WARP (includingpage_ownership_at_region_boundaries).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly batches page-table rebuilds by region and owner.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T14:07:56Z.
Review: COMMENTED
I walked the new fill against the per-page loop on
main, and I believe it's equivalent:pwas whole whenp << 16 >= start && (p + 1) << 16 <= end, i.e.ceil(start / 64K) <= p < end >> 16. That's exactlyfirst_whole..past_whole, clamped to the region, sofill(k)takes the same pages, overriding larger copies as before.entries[0]only in the region that holdsstart, and the tail atentries[last]only in the region that holdsend. I checked the corners: two partial pages in adjacent regions with no whole page between them (2 * REGION - 7, 14), both edges in one page (head set, tail skipped sincewhole_end == past), and an aligned start with an unaligned end in the same page (head skipped, tail set). Each partial page is claimed once, and only if it's free, as before.fullpath still skips just that region.last_blockstays belowLEVEL1, sinceend <= 1 << 40.chunk_by+fillwrites the same[pair, start]/[null, 0]per entry.The new regression pins those corners nicely. One suggestion: the description mentions that the old and new builders produced identical tables in 40 randomized cases, including limit, overflow and unaligned ones. That check is the strongest evidence here, and it would be worth committing: for example, keep the old per-page loop as a test-only reference and compare
(blocks, owner)over a seeded generator. That way a future change to the bulk path gets checked against the simple definition, not just against the hand-picked rows.Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T14:22:39Z.
I added the seeded per-page reference test in
32b656e. It compares the block map, owners, and emitted dwords over 40 seeded cases, including an explicit capacity-limit case plus invalid and partial ranges. The CI Clippy job flaggedchunks_exactin the test.fd98bfausesas_chunksand checks the remainder. Both Clippy profiles and the regression pass locally.Imported from Marvisak/VIctory. Originally posted by Desamodeth on 2026-11-26T18:31:01Z.
Review: COMMENTED
CPU-only A/B of
write_tableon63bcca43vsfd98bfaf. The overlap speedup survives writing to WindowsPAGE_WRITECOMBINEmemory (confirmed withVirtualQuery). Ryzen 7 9800X3D, rustc 1.98.1 MSVC,-C opt-level=3. Median milliseconds per rebuild, 30 interleaved samples per version after warm-up:A second process with the memory modes in reverse order reproduced the two extremes (5.576 → 1.158 ms and 0.172 → 0.265 ms). An isolation run keeping the PR ownership pass but restoring the main emitter still showed both effects. I’d keep the one-owner-per-page case alongside the overlap benchmark when tuning the builder.
The block list, page owners, written length and all emitted bytes matched in all four cases with both cached and write-combined output. Timing includes an
sfenceafter the writes. Synthetic CPU memory only; no D3D12 calls, game data or frame-rate measurement. AI-assisted with Codex.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.