Repository navigation
perf(gpu): read the title's physical pages in place (VICTORY_PHYSICAL_TILES=1) - #653
Conversation
…_TILES=1) Run I: the largest refreshed copies (37.7 MB on 576 physical pages in 4 runs, 25.2 MB on 384 in 7, one section each) are title buffers on the title's physical pages, refreshed page by page as the title writes them, ~175 MB a frame with the rest. With VICTORY_PHYSICAL_TILES=1 (off by default; Rosetta and D3DMetal only) those pages are GPU memory, and such buffers need no copy: - Each section of physical pages is a CPU-visible L0 heap (alias::PhysicalHeap, the diagnostics trial made a switch), and the title's views of it are remapped onto it (mach_vm_remap): the title's CPU writes land in GPU memory, and DirectStorage writes the heap. - A title buffer whose pages all lie on such heaps when first used gets a zero-copy host copy (crate::tiled): a reserved buffer whose 64 KiB tiles are its pages in the title's order (UpdateTileMappings, one call a run of a heap's consecutive tiles). Nothing is refreshed into it or copied back; what shaders write the title reads at once. - When the title maps other pages there or unmaps them, victory-hle passes the new tiles (victory_gpu::physical_retiled, under its own lock: no call back) and the copy's tiles follow on the host queue at once. D3DMetal ignores null tile mappings (the tile keeps its old page; the inplace probe only passed as its fresh buffer held zeros anyway), so an unmapped page shows a tile of zeros of ours. - The tiles are asked of victory-hle without the buffers' lock: it holds its own while it tells the trackers of a mapping, which may read the buffers (VICTORY_SHADOW_KEEP). Tests: on a CPU-visible heap with title pages remapped onto tiles 2, 0, 3, 1, the GPU reads what the title wrote with no refresh, the title reads what the GPU wrote, a page retiled shows the new tile, an unmapped page reads zeros and the others stay (victory-gpu); a buffer with a page off GPU memory is copied; with the switch, mapped physical pages name their tiles in the title's order, the title's writes land in the heap, and unmapped they name none (victory-hle). own_section_views_start_above_two_tib skips the floor when the whole view is the GPU heap. Two prep-ahead tests asserted what another test's synchronous submission can undo (it lands the flight held in the air), and failed more often with the new test's tile updates on the queue: they now retry, as until_taken meant them to. Suites under Wine: victory-gpu 641/0 in four of five runs (the fifth: shadow::marked_pages_go_back_by_the_bytes_the_gpu_changed, which fails as often without this change while other sessions' GPU tests run). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Heads-up on the switch name: #410's view space (my One lesson from #410 that may apply here too. With the page pool read in place, tiles not shown read as zeros without counting as misses, and the title's writes can't be withheld without a copy. On my lab base that let the BVH builder write empty bounding boxes over its own data, and the title crashed at about 180 to 260 s. The builder is held back by default now (#591, |
Follow-up to #584. It got merged just before this commit was pushed to its branch, so this is the commit again, on current main.
What
VICTORY_PHYSICAL_TILES=1(off by default; Rosetta and D3DMetal only) lets title buffers on the title's physical pages be read in place, with no host copy to refresh.In the world (run I), the largest refreshed host copies are title buffers on physical pages (
XMemAllocatePhysicalPages/XMemMapPhysicalPages). The new "physical pages … runs" line shows 576 pages in 4 runs and 384 in 7, one section each. The title writes them page by page, and they are refreshed accordingly: about 75 of the 175 MB refreshed per frame.With the switch:
alias::PhysicalHeap, until now a diagnostics-only trial, now behind the switch. The title's views of a section are remapped onto its heap (mach_vm_remap), so the title's CPU writes, and DirectStorage's, land in GPU memory.crate::tiled): a reserved buffer whose 64 KiB tiles are its pages in the title's order (UpdateTileMappings, one call per run). Nothing is refreshed into it or copied back, and what shaders write the title reads at once.victory_gpu::physical_retiled) and the tiles follow at once on the host queue.Tests
own_section_views_start_above_two_tib_under_wineskips the address floor when the whole view is the GPU heap.until_takenintended.Under Wine on #584's branch: victory-gpu 641/0 in four of five runs. The fifth failed in
shadow::marked_pages_go_back_by_the_bytes_the_gpu_changed, which also fails without this change while other sessions' GPU tests run.Not run yet: Wine tests are paused while the game runs (they share 24 GB with it; run K1 hit a Metal OOM). Still open:
VICTORY_PHYSICAL_TILES=1after the floor-test fix;Clippy is clean with and without
--all-features, andcargo xtask policyis ok.Re-test
Compare
VICTORY_ASYNC_SUBMIT=1 VICTORY_PHYSICAL_TILES=1 VICTORY_VIEW_PROBE=1against the same withoutVICTORY_PHYSICAL_TILES.What to look at:
host copies refreshed per frame, the physical-page copies should be gone.first title buffer read on its physical pages in place.Memory cost: physical pages become wired GPU heaps.
🤖 Generated with Claude Code