Repository navigation
perf(gpu): async submission (VICTORY_ASYNC_SUBMIT=1): measure it, queue page mappings, present without a second drain, and prepare the next submission during a quiet flight (VICTORY_PREP_AHEAD=1) - #584
Conversation
…fences VICTORY_ASYNC_SUBMIT=1 (pragyaangaur#447) already lets the title's ExecuteCommandLists, Signal and Wait only queue their work for victory-submit, but its time was invisible: the frame report's "threads held by host GPU work" line counted nothing under it, so it could not be weighed against the default. - queue.rs: the title's calls count what they spend queuing; threads that wait for the worker to drain (PresentX as "presents", our read-backs, captures and page mappings as the new "our syncs") count the drain's lock and run; the Flight-1-only pump on title threads is counted too. - host/flight.rs: per flight, the worker's time waiting for the last flight to land, preparing and launching, and the host GPU's idle time before it, split into nothing to run and preparing; logged as a frame-report line. - Tests: the title's thread is back while its work is held, may reset the list at once, never runs host work, and its fence moves only after the work's bottom-of-pipe write; a queue waiting on another queue's fence completes only after that queue's fence and write show. - docs/macos.md: the switches and the lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fences VICTORY_ASYNC_SUBMIT=1 (pragyaangaur#447) already lets the title's ExecuteCommandLists, Signal and Wait only queue their work for victory-submit, but its time was invisible: the frame report's "threads held by host GPU work" line counted nothing under it, so it could not be weighed against the default. - queue.rs: the title's calls count what they spend queuing; threads that wait for the worker to drain (PresentX as "presents", our read-backs, captures and page mappings as the new "our syncs") count the drain's lock and run; the Flight-1-only pump on title threads is counted too. - host/flight.rs: per flight, the worker's time waiting for the last flight to land, preparing and launching, and the host GPU's idle time before it, split into nothing to run and preparing; logged as a frame-report line. - Tests: the title's thread is back while its work is held, may reset the list at once, never runs host work, and its fence moves only after the work's bottom-of-pipe write; a queue waiting on another queue's fence completes only after that queue's fence and write show. - docs/macos.md: the switches and the lines. (Upstream pragyaangaur#584 by Nick233x, applied onto two flights: its step enum is Phase here, as flight.rs already uses host's Step; the GPU counts as free after a landing only once no flight is left in the air; the docs row only.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mission With VICTORY_ASYNC_SUBMIT=1, CopyPageMappingsBatchX drained all queued work and the flight in the air on the title's thread: in the open world that was the "our syncs" 124-182 ms of a 428 ms frame, and the GPU then sat idle with nothing to run while the title waited (async 2.3 fps against 2.9 by default). On the console the batch is a queue operation. It now is here too, with VICTORY_ASYNC_SUBMIT=1 or VICTORY_FLIGHT1=1: while its queue holds work or a host submission is in flight, the batch becomes a hold::Item::Action and the title's thread goes on. The action ends its queue's part of a coalesced piece (other queues still join); the submit worker lands the flight, as the next preparation would anyway, maps, and only then prepares the queue's later work. With nothing held or in flight it maps at once, as before. The default (synchronous) path is unchanged. The frame report gets a line of what still drains queued work: presents, page mappings done at once or queued, and our own synchronous host work by the line that called it (#[track_caller] through Host::execute). Tests: an action runs between its queue's work in both pumps and keeps a signal before it first; take_ready_with hands it out only after its queue's work, with another queue's work still joining; under async a mapping behind held work returns at once and maps after the earlier work's fence and before the later work's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
queue::present drains the queued work, then Host::present submitted its swap-chain copy through Host::execute, whose before_sync drained a second time: behind everything other title threads queued since (the next frame's work), counted as "our syncs". With VICTORY_ASYNC_SUBMIT=1 or VICTORY_FLIGHT1=1 the copy now goes through execute_sync: behind the host submission in flight only, ahead of work queued after PresentX, as on the console. The synchronous default still calls Host::execute (before_sync is a no-op there). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t (VICTORY_PREP_AHEAD=1) With VICTORY_ASYNC_SUBMIT=1 the host GPU still sat idle ~150 ms a frame while the next submission was prepared: Wait-Before-Prep landed the flight in the air first, as host copies of title memory are refreshed in place. Opt-in VICTORY_PREP_AHEAD=1 (with Flight-1) prepares the next submission behind the one in flight and launches it behind it, at most two in flight, when the flight in the air is quiet at landing: no ranges shaders write, no write marks, no read-backs, no work after it or bottom-of-pipe writes, no uploads. Then its landing changes nothing the preparation reads, and the in-place refreshes rewrite what it reads with the same bytes: the title does not change memory submitted work reads until that work's fence moves, at its landing. The flight in the air lands first (land_ahead, on the preparing thread under Host::submitted) for what needs the GPU done with it: the frame's eviction, a view remake, the shared barrier lists, a heap fill (Host::quiet), title copies (done on the CPU while preparing), and, before launching, the new submission's write marks, as every landing takes the marks bitmaps whole. Lists now record binding those bitmaps. FlightState holds up to two flights, with title signals per flight; landing records the landed flight's own fence value (SUBMISSIONS_DONE, retirement), and an even fence value ends with a second mark so arming one never changes the other's. Native splits stay together behind a flight. The default and VICTORY_ASYNC_SUBMIT=1 without the switch keep Wait-Before-Prep; a frame-report line counts what was prepared and launched behind a flight and why the others landed it first. Tests: launched behind a quiet flight, two in flight, results and fences in order; a flight whose shaders write a host copy lands before the next refreshes it (a mutation that treats it as quiet loses the GPU's write); write marks and title copies land the flight first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mit-17244c # Conflicts: # crates/victory-gpu/src/host.rs
|
This breaks the native macOS build. CONTRIBUTING asks for
Moving the gate back fixes it. With this on top of the merge, native diff --git a/crates/victory-gpu/src/resource.rs b/crates/victory-gpu/src/resource.rs
index eb9f18d..871bb69 100644
--- a/crates/victory-gpu/src/resource.rs
+++ b/crates/victory-gpu/src/resource.rs
@@ -1894,21 +1894,23 @@ pub(crate) fn evict_heap_uav() -> bool {
*ON.get_or_init(|| std::env::var_os("VICTORY_EVICT_HEAP_UAV").is_some_and(|v| v != "0"))
}
-/// Once per presented frame, before a submission (`Host::execute`, one at a
-/// time, the last one has run): gives up host textures fed from title memory
-/// that the title has not used for [`IDLE_MS`], and past [`BUDGET_HIGH`] of
-/// the card's budget the least recently used ones until [`BUDGET_LOW`].
-/// Host copies of title memory nothing asked for in as long go too
-/// ([`crate::shadow::release_stale`]).
-#[cfg(windows)]
/// The frame [`evict_unused`] last ran in.
+#[cfg(windows)]
static EVICTED_IN: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(u64::MAX);
/// Whether [`evict_unused`] would run now (once per presented frame).
+#[cfg(windows)]
pub(crate) fn evict_due() -> bool {
EVICTED_IN.load(std::sync::atomic::Ordering::Relaxed) != crate::queue::presented()
}
+/// Once per presented frame, before a submission (`Host::execute`, one at a
+/// time, the last one has run): gives up host textures fed from title memory
+/// that the title has not used for [`IDLE_MS`], and past [`BUDGET_HIGH`] of
+/// the card's budget the least recently used ones until [`BUDGET_LOW`].
+/// Host copies of title memory nothing asked for in as long go too
+/// ([`crate::shadow::release_stale`]).
+#[cfg(windows)]
pub(crate) fn evict_unused() {
use std::sync::atomic::Ordering::Relaxed;
let frame = crate::queue::presented();I gated AI-assisted, prepared with Claude Code. |
|
Tried this on an M3 Max (48 GB, macOS 27.2.1, CrossOver 26.1, D3DMetal 4.0 beta 3, Series X): PR head A heads-up first. In the I can't pin it on prep-ahead: it never kicked in on this title here ( Median frame over the same stretch of the world (184 to 356 s after world entry). The default run had a cold shader cache, so its number is somewhat high:
Report lines from the async-only run: title submissions 710 → 0.2 ms/frame; presents 23 + 294; our syncs 0. Flight line: worker busy 344 (waiting for the last to land 60, preparing 165), host GPU idle before them 200 (nothing to run 21, preparing 179). Drains: presents 1.0, page mappings 0.1 at once and 0.1 queued, our own host work 0. I can run a longer async series on Apple Silicon if it helps, but given the desktop freeze I'd rather check with you first. |
…P_AHEAD=1 probe) Run C: with VICTORY_PREP_AHEAD=1, 6-8 of ~10 host submissions a frame were not quiet at landing, so almost nothing was prepared ahead. Before replacing the whole-flight rule with a range one, this measures its ceiling without changing what runs. With VICTORY_PREP_AHEAD=1, each landing records why its flight was not quiet (declared ranges, write marks, work after it, bottom-of-pipe writes, read-backs, table textures, uploads) and what it wrote back: declared and bottom-of-pipe ranges, and the pages its shaders marked. The preparation right after it records the host-copy ranges its refreshes rewrite (Batch::add, written copies only) and is counted against them: refreshing nothing the flight declared (known before it lands), nothing it wrote (known after), nothing any view write can reach (the copies owning mark bits, the bound a range rule can use for a flight that marks); a frame line gives the ceiling by ranges, and the same if marks were known ahead. The prep-ahead tests now retry their scenario: another test's Host::quiet lands every flight in the air, and freed test memory left its host copy registered for the next allocation at the same address. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A new line per report, "host preparing per frame by phase, ms": evicting, heap views synced, uploads, list steps, preludes, refreshes, landing early (VICTORY_PREP_AHEAD=1) and other. The preparing line only told copies and textures apart, which left 40-50 ms of the ~100 ms a frame unnamed; this names it, so the next run says which part to make faster. A lap is one clock read per phase and list (~10 lists a submission). "preparing" (SUBMISSION_US) now ends after the hang note, which it used to follow: the note's time was on the submit worker's chain but counted nowhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every submission copied the names of all pipelines its lists bind into a new set and formatted them, for a log line written only if the GPU hangs for 8 s. Under Wine that cost 0.2 ms a submission at 100 pipelines a list and 0.6 ms at 300 (benchmark waiting_on_takes_the_sets), on the submit worker's chain about 10 times a frame. A list's set is now shared (Arc): the note keeps the sets, and the hang line names them. A reset gives a list a new set if the note still holds the old one, so nothing is copied while recording either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…et (VICTORY_PREP_AHEAD=ranges) Off by default; =1 and the default path are unchanged. With =ranges a submission is also prepared behind a flight that is not quiet at landing, when what its landing writes is known before it runs (HostList:: ahead_writes): ranges its shaders declare (whole 64 KiB pages, as the trackers take pages), write marks (bound by every copy owning mark bits) and bottom-of-pipe writes outside host copies. A flight with work after it, read-backs, table textures or uploads lands first, as before. The preparation lands it first only where it would refresh those bytes (Batch::add), declare shader writes in a copy it writes (one snapshot and pending set a copy), fill from them, or run host work (Early::Overlap, Early::CpuRead). Its landing then writes title memory the preparation did not read and nothing into host copies: what its shaders wrote is in them already, and a refresh of other bytes of a copy leaves its snapshot and pending ranges alone. shortcut: a texture over memory the flight's shaders write can be brought up one submission late, as one written in the same submission already is. The prep-ahead line counts preparations behind such a flight and why they landed it. Tests: the spans (pages, bytes, whole copies), a launch behind a flight writing other memory (two in flight, write goes back, refresh reads the title's bytes), and the hazard: a refresh of what the flight writes lands it first (fails with the check removed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ode lock In the full suite another test could switch Flight-1 on while it ran: its submission then returned before it ran, and the mark check after it failed in about one run in four. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es first (VICTORY_SAME_COPIES) A new frame-report line, "host preparing copies per frame", splits the preparing copies (the ~180 MB a frame in the world) into title copies between buffers, fills of upload memory from title memory, and refreshes of host copies, with counts, MB and ms each. VICTORY_SAME_COPIES (off by default): each title copy is compared first, its source's bytes against its destination's and every host copy of the destination (host_copy::same_copy). All the same, the copy changes nothing anywhere: "probe" counts those, "skip" leaves them out, so the copy does not write title memory and its destination's host copies are not made due for a refresh again. A host copy holding other bytes (what shaders wrote and kept there) makes the copy run, as on the console it overwrites them. Comparing reads through the kernel as the copy does, so unmapped pages fail it instead of faulting; aliased, overlapping and copies over 16 MiB are not compared. Comparing costs 4-5 times a warm copy under Wine (same_copy_costs: 8.4 us against 1.9 us for 64 KiB, 1.2 ms against 0.23 ms for 8 MiB), so skip pays only where most copies are in place, plus the refreshes it saves: probe first. Tests: the switch's values; a copy in place is left out and its copy stays current, with probe it still runs; a copy changing the destination, or whose host copy holds other bytes, runs with skip (fails with the host-copy check removed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run E put "heap views synced" (41-56 ms a frame) and the refreshes of host copies (~174 MB, 37-45 ms) first. Measured offline before changing them: - An unchanged 64 KiB heap page (2,048 slots, all synced) is checked in 1.8 us, less than comparing it with its last bytes (2.2 us; bench_unchanged_page_scan_vs_compare). The sync already checks only pages the title wrote, and slots whose record is unchanged cost nothing more: skipping by page contents would not help. Where its time goes in the world is not known, so a new line says it: "heap views synced per frame": syncs, pages, slots checked, made again; ms taking the written ranges (guarding pages again), reading pages, checking slots, making them. - A refresh of a written page costs 3.0 us on tracked memory (5.9 us scattered), the same with unchanged bytes (refresh_cost_per_written_page): about the copy itself, so comparing first saves nothing, and the GPU cannot read title memory that is not aliased (D3DMetal refuses OpenExistingHeapFromAddress). What removes a refresh is zero-copy aliasing, so two new lines say which memory is refreshed and why it is not aliased: "host copies refreshed per frame" (copies, tracked and untracked MB, the five that took most, with address and size), and "title memory committed without zero-copy aliasing" (XMemVirtualAlloc commits by reason: aliasing off, protection, placeholder, not whole pages, remap failed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…AP_READ_ONCE=1) Run F: the heap sync is 48 ms a frame, 46.7 of it making ~41,000 slots again. Each slot made again re-read its 12-byte record through the kernel under the heap's lock (a title write since the page was read defers it to `mirror`): 0.46 us a read under Wine (bench_record_reads), ~19 ms a frame. With VICTORY_HEAP_READ_ONCE=1 (off by default) the records from the first slot to the last are read once, under the same lock (at most 1 MiB; a sync's slots lie in one 64 KiB page); a failed read falls back to one read a slot. A title write after the read is seen by the next sync, as one after a slot's own read was. bench_made_again_read_once (a ring of tables: every slot takes another view each pass, 256 views): 0.77 us a slot made again, 0.31 us with the switch, the same views made and kept. Test: reading once makes and keeps the same slots as reading each record, over three syncs with changes. The refreshed-copies line marks copies of memory shown at several addresses (physical pages the title maps more than once), which zero-copy aliasing does not reach. a_title_copy_of_bytes_in_place_is_left_out takes memory with no other copy or alias registered (memory another test gave back may have them, and then nothing is compared): it failed once in the full suite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lots costs Run G (VICTORY_HEAP_READ_ONCE=1, ~2,700 frames in the world, no glitch seen): heap sync 50.1 -> 33.5 ms a frame, 0.70 us a slot made again against 1.14. It reads the same bytes under the same lock, so it is on by default now; VICTORY_HEAP_READ_ONCE=0 turns it off. A new line, "heap slots made again per frame", says what the remaining ~30 ms are: slots holding that view already, views created (and their ms), copied from one created in the same sync, left null for draws, made null; then ms looking the views up and preparing them, the slots' loop, copying descriptors, keeping what they view, noting it (bindless), and the rest. VICTORY_VIEW_PROBE=1 also counts the created views whose descriptor an earlier sync created already: what a cache of views across syncs could save at most. Offline (bench_made_again_read_once, 256 views rotating through 16,384 slots), creating views is 2% of making slots again: most of it is the slots' loop and noting what they view. A content cache would only take the 2%; the probe says how much more it is in the world before one is built. The refreshed-copies line now names each top copy's memory (VirtualQuery: private or mapped, protection, allocation, region), to tell whether zero-copy aliasing (private XMemVirtualAlloc memory) could reach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ran the new head on the M3 Max:
One caveat on the number. On d1609d9 I see two steady frame levels with the same draws, about 400 ms and about 720 ms (details on #608), with or without async, and this run happened to stay on the fast one. Comparing like with like, from the host's 5-second report lines:
So async is a few percent on the fast level here. I left |
…th copies A loop of the victory-gpu lib suite under Wine (20 runs at dd434a4) found no access violation, but one failure, in a test checking right after a submission what assumes it ran: another test had switched Flight-1 on. That test and the two others known to assume synchronous submission (they failed under VICTORY_ASYNC_SUBMIT=1) now hold the mode lock, synchronous: - list: allocate_upload_survives_early_reset_and_release_while_held_on_gpu - resource: a_texture_read_back_reaches_the_title_buffer - resource: a_list_waiting_for_another_queues_write_reads_what_it_wrote shadow::loose_memory_must_be_committed failed once with VICTORY_ASYNC_SUBMIT=1: a reservation where another test's memory had been may still have a copy registered over it, which is found. It now takes a reservation with no copy over it. After: 20 runs, 10 synchronous and 10 with VICTORY_ASYNC_SUBMIT=1, all 615 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run H: the four largest refreshed copies (37.7, 25.2, 12.6 and 182.5 MB regions, ~75 MB of the 173 MB a frame) are all "mapped, protect 0x2". Mapped: section views, the title's physical pages (XMemMapPhysicalPages), which zero-copy aliasing (private XMemVirtualAlloc memory) does not reach. Protect 0x2 (read-only) is the change tracking's guard on pages a copy has taken, not the title's: their refreshes are already only of pages the title wrote since, so the 25.2 MB region refreshed whole is the title writing every page of it each frame. A refresh on some other event would not take fewer bytes. For the GPU to read them in place, those physical pages would have to be GPU memory (the VICTORY_PHYSICAL_TILES trial backs sections with a placed buffer) and a copy's pages lie in one GPU range: one run of pages in one section, or a tiled resource mapping each. So the refreshed-copies line now says, for each of the five largest, how its memory lies on physical pages (victory-hle's page table, through victory_gpu::on_physical_runs): pages, runs of pages one after another in a section, and sections. Test (victory-hle): pages mapped 0, 1, 3, 2 make three runs of one section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lock CI (run 46083986817) failed it: with another test's VICTORY_PREP_AHEAD on, even submissions are marked by the second mark list, not host.mark(). It now runs synchronous and without prep-ahead, as work_goes_on_on_a_new_queue does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's pragyaangaur#640 reads a heap sync batch's stale records once a page, always, as VICTORY_HEAP_READ_ONCE did here (on by default since dd434a4): that one is kept, and the switch, its test and its docs row go. bench_made_again times the merged path and prints the split of making slots again. In flight.rs, main's SUBMISSIONS_BEGUN store goes after the fence check here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run I: "list steps" is 16.6 ms a frame. A new line, "host list steps per frame", counts each kind of step the lists run while preparing and times the heavier ones (one clock read a step): title copies and fills, host work, shader writes declared (their snapshots and the refreshes they flush), table textures, heap scans (bindless), page tables (title memory). The many refreshes asked and table slots are counted only; their time is the rest of the phase. Test: host work is counted and timed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's pragyaangaur#592 keeps a flight's undeclared shader writes armed until it lands (InFlight.armed, disarmed at landing): kept, beside the prep-ahead probe's landing record. flight.rs imports host's list Step as ListStep, apart from its own Step of flight times. host re-exports flight's Gate (main) and probe_marked (here). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Why
In the open world (Series 1.0.2.1, M5 Pro, macOS 26.6.2, D3DMetal from GPTK 4.0 beta 3, with #570 applied), VIctory's frame report gives 431 ms/frame: 167 preparing + 218 on the GPU + ~20 copying back. The same report says
threads held by host GPU work … title submissions 0.0 + 358.6, so the title's own threads spend ~359 ms of each frame inside our host submission work. A Metal System Trace over the same stretch shows the GPU busy only 41% of the time.The title doesn't have to wait there. #447 already added
VICTORY_ASYNC_SUBMIT=1, opt-in. With it,ExecuteCommandLists,SignalandWaitonly queue their work. Thevictory-submitthread then prepares the work and submits it, joining up to 64 ready lists into one host submission, andvictory-flightlands each submission. The title's fences move only when the work has landed. But under that switch the frame report had no numbers: the unlocked pump and the drain at PresentX weren't timed, so the "threads held" line read ~0 whatever happened. That meant the switch couldn't be compared with the default. It has never been tried in these runs.What
VICTORY_ASYNC_SUBMIT=1/VICTORY_FLIGHT1=1(queue.rs). A title call now counts the time it spends queueing. A thread that waits for the worker to drain counts the drain lock it waits for and the run after it: PresentX aspresents, and our own read-backs, captures and page mappings (before_sync,CopyPageMappings) under a new bucket,our syncs. The Flight-1-only pump that runs on title threads is counted too. The line is the same as before, so it compares directly with a default run:threads held by host GPU work per frame, ms waiting for the queues' lock + running it: title submissions a + b, …, presents c + d, our syncs e + f, our timer …host/flight.rs). Each flight now records three times: waiting for the last flight to land (its remaining GPU time plus its copy-back), preparing, and launching (the hostExecuteCommandLists+Signal). It also records how long the host GPU sat idle before the flight, split into "nothing to run" (the worker came to a free GPU) and "preparing" (the work was there, but Wait-Before-Prep held it). Synchronous submissions mark the GPU free too. A new frame-report line shows this:host submissions in flight per frame: n; ms per frame: submit worker busy w (waiting for the last to land l, preparing p, launching x); host GPU idle before them i (nothing to run u, preparing q)docs/macos.md): the two switches, what they overlap and what they don't, and how to read both lines.The default doesn't change: async stays opt-in until a run shows it holds up on this title.
Expected effect (with
VICTORY_ASYNC_SUBMIT=1)title submissionsshould drop from ~359 ms to around a millisecond (queueing only). The title then waits at PresentX instead (presents), but only for whatever host work its own CPU time didn't overlap.shadow.rsassumes one submission at a time (snapshots, pending ranges, copy-back merge), so preparing N+1 during N would overwrite what N reads. From overlap alone, expect up to about the title's own CPU time per frame, ~431 → ~405 ms (≈ +6%, 2.3 → ~2.45 fps).pieces=gives the count: 13 per frame today. perf(gpu): opt-in Wait-Before-Prep Flight-1 GPU overlap and async submit worker #447 measured 2.7× on an M5 Max on an older tree, but I wouldn't count on that here.Ordering and fences
These are unchanged from #447 and now covered by tests. The title's call returns once its work is queued. The fence moves only after the work's bottom-of-pipe writes. A Signal behind running work stays behind it:
holds_workcounts running queues, and the flight is marked active beforefinish_running. Host copies of title memory are refreshed when the worker prepares the submission, not when the title calls, which is how the console's GPU reads unified memory too (at execution, not at submission).Tests
host::flight::tests::async_submit_runs_host_work_off_the_title_thread_and_signals_after_it(GPU). A list waits for a memory value.ExecuteCommandLists+Signalreturn with the fence still at 0 and nothing run, and the list can be reset at once. Once the value is written, the fence reaches 1, the BoP write is there, and the work'safterran on a thread other than the title's. The flight is counted.host::flight::tests::async_submit_queue_wait_completes_after_the_signalling_queue_work(GPU). Queue BWaits for queue A's fence, and A's work is held behind a memory value. Neither fence moves before the value is written. Whenever B's fence reads as reached, A's fence and both queues' writes are already visible. Note: the worker may join both queues into one host submission. Inside a landing, allafterhooks run before all BoP writes, so anafterhook of B can't see A's BoP write. Nothing title-visible depends on that, and the sync pump coalesces the same way.host::flight::tests::idle_time_is_split_at_when_the_work_was_there.tools/macos/test-wine.sh -p victory-gpu(Wine + D3DMetal, M5 Pro), with all three commits and the game closed: 582 passed, 0 failed (19 ignored). (With the game running, one process for the whole suite ran out of Metal memory and failed in a cascade; the base commit failed the same way.)cargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warnings, with and without--all-features: clean.cargo xtask policy: ok.It merges cleanly with #556 and #570 and doesn't depend on them.
I haven't run the game with this change.
Re-test
Same place in the open world, two runs: the default, then
VICTORY_ASYNC_SUBMIT=1. Comparems/frame, the "threads held" line (title submissions→ ~0,presentstakes what's left),pieces=in the held-work line, and the new "host submissions in flight" line. If the async run hangs or shows corruption,VICTORY_FLIGHT1=0keeps the worker but waits for each submission on it, which separates the two halves.Follow-up: the first A/B, and the drains it showed
Same build plus this PR (63f2c10), same spot in the open world. Medians over frames with more than 2,500 draws:
VICTORY_ASYNC_SUBMIT=1Flight line, async:
submit worker busy 292 (waiting for the last to land 145, preparing 103, launching 1); host GPU idle before them 261 (nothing to run 145, preparing 116).So the title's threads were freed from submitting, but two drains took the time back. While the title's thread waited in them, it submitted nothing, and the GPU sat idle with nothing to run.
The only production callers of a synchronous
Host::executeare PresentX's copy and the diagnostics captures, so the drains are these:CopyPageMappingsBatchXdrained all queued work and the flight in the air, on the title's thread. On the console the batch is a queue operation, and now it's one here too. UnderVICTORY_ASYNC_SUBMIT=1/VICTORY_FLIGHT1=1, while its queue holds work or a host submission is in flight, the batch becomes a newhold::Item::Actionand the title's thread goes on. An action ends its queue's part of a coalesced piece; other queues still join. The submit worker lands the flight (the next preparation has to wait for that anyway), maps the pages, and only then prepares that queue's later work. With nothing held or in flight, it maps at once, as before. The mapper (xmem::map_alias) uses global locks only and no thread-locals, so running it onvictory-submitis fine. It also no longer forgets host copies while a flight reads them.queue::present, then again for its own swap-chain copy (Host::execute→before_sync). The second drain waited for whatever other title threads had queued since: the next frame's work. In the queued modes the copy now goes throughexecute_sync, so it waits only for the flight in the air and runs ahead of the work queued after PresentX, as on the console. In sync mode it's stillHost::execute, and nothing changes.queued host work drained per frame: by presents p; page mappings done at once a, queued behind their queue q; by our own host work s (file:line n× t ms, …).Host::executeandexecute_with_barriersare#[track_caller], so a remaining drain names the line that called it.The default (synchronous) path doesn't change: mappings still happen at once, PresentX still calls
Host::execute, and the sync pumps run an action in place (none is queued in sync mode).Expected effect (async)
our syncsshould drop to about 0, leaving what PresentX must wait for. Waiting for the flight in the air is inherent to the copy, because its preparation can only run once that flight has landed.nothing to runshould drop by roughly the time the title spent blocked in mappings. The title keeps feeding the worker through its streaming.Preparing N+1 while N is in flight: assessed, not done
prepare_submissionwrites state that a flying submission reads or will hand back:run_deferred→Shadow::update*): CPU writes into the same system-memory host copies the GPU reads in place. It takes the one snapshot per copy that copy-back diffs against, and clearspending, assuming "one submission runs at a time".descriptor::sync_heaps: rewrites slots of the shader-visible host heaps that N's shaders read. D3D12 doesn't allow changing descriptors that in-flight work uses. Double-buffering them means a second set of million-slot heaps, whose creation needsquiet()(D3DMetal issue GPU tests that read back shader writes fail in about a third of runs on an M5 Max, never with one test thread #31).Marklist, upload staging released at landing, and texture recycling.Items 1–3 together mean versioned shadow ranges (copy-on-write of the ranges in flight, with N's written ranges excluded from N+1's refresh until landing) plus double-buffered host view heaps. That's a redesign of
shadow.rsanddescriptor/host, and it needs runs of the game to check. It isn't in this PR. The flight line'shost GPU idle … preparing(~116 ms/frame in the A/B) is the most it could win.Tests added
hold::tests::an_action_runs_between_its_queues_work: both sync pumps run the work before the action, then the action, then the work after it. A signal before the action is delivered before it.hold::tests::take_ready_hands_out_an_action_after_its_queues_work: per queue and coalesced. The action comes out only after its queue's piece was handed over, and never while that queue is running. Another queue's work still joins (coalesced) or comes out on its own (per queue). The work after the action comes next.host::flight::tests::async_submit_queues_page_mappings_in_their_queues_order(GPU): under async, a batch behind held work returns at once with nothing mapped. It's mapped once the earlier work's fence reached 1, and before the later work's fence reaches 2.Re-test
Same spot and command,
VICTORY_ASYNC_SUBMIT=1, against the default. Look at:ms/frame;our syncsandpresentsin the "threads held" line;our own host workentries name their lines;nothing to runvspreparingin the flight line.If the async run shows streaming corruption (missing or wrong texture pages), the queued mappings are the suspect.
VICTORY_FLIGHT1=1alone (without the worker) runs the same queue order on the title's thread, which narrows it down.Follow-up 2: prepare N+1 while N is in flight (
VICTORY_PREP_AHEAD=1, opt-in)Second A/B (main d1609d9 + this PR at 92f47ab): async 2.8 fps / 358 ms against the default's 2.3 fps / 432 ms.
our syncswent from 124–182 ms to 0. What's left in the flight line ishost GPU idle … preparing≈ 150 ms/frame: the next submission's work is queued, but Wait-Before-Prep lands the flight in the air before preparing it.What it does
With
VICTORY_PREP_AHEAD=1(on top of Flight-1), the submit worker prepares the next host submission while the one before is still on the GPU, and launches it behind that one. At most two submissions are in flight. This happens only when the flight in the air is quiet at landing (HostList::quiet_at_landing): none of it goes back to title memory (no ranges shaders write, no write marks, no texture read-backs, noafterwork, no bottom-of-pipe writes), and it had no uploads. Its landing then changes nothing the preparation reads.During that preparation, host copies are refreshed in place while the flight's shaders read them. This is safe for the same reason it's safe on the console: the title doesn't change memory that submitted work reads until that work's fence moves, which here is at its landing. So the refresh rewrites what the flight reads with the same bytes.
Some steps of the preparation need the GPU done with the flight first. Those land it first (
flight::land_ahead, on the preparing thread, underHost::submitted), and each one is counted:take_remake)Host::quiet)Step::Copy/Move)To make the last row reliable, lists now record when they bind the write bitmaps (
HostList::note_marksindraw.rs), instead of relying onnote_unknown_gpu_writealone.Plumbing
FlightStateholds a queue of flights (at most two), with the title's signals attached per flight and delivered in order.SUBMISSIONS_DONE, retirement), not the newest submission's.Mark, so arming one flight's mark never changes the other's. Native splits (shared split marks) stay together while behind a flight.VICTORY_ASYNC_SUBMIT=1without the switch, keep Wait-Before-Prep unchanged: one mark, the same splits, andprepare_submissiononly changes the type of its counter argument.Frame line
Expected effect
host GPU idle … preparing(~150 ms/frame) should go down by the preparation time of the submissions that are launched behind a flight (labove). How largelis depends on how many of this title's submissions are quiet at landing. Compute passes that write through views (culling, the BVH builder) aren't; render passes that only draw into render targets are. I can't predict the split without a run. Iflturns out small, the line says which reason dominates. That's the next thing to unlock:Not done, and why
VICTORY_HEAP_WORKER=1already stages heap-indexed textures on its own thread, so textures are prepared ahead without this switch. It's worth trying together with this one.Tests
prep_ahead_launches_behind_a_quiet_flight_and_lands_in_order(GPU). Landing is paused in the test, so the second submission is launched behind the first: two in flight. Both results are right, the newer flight's refresh sees the title's write, and its fence never shows before the older one's.prep_ahead_lands_a_flight_with_copy_back_before_preparing(GPU), the overwrite hazard. The flight in the air writes a host copy that goes back at landing, and the next submission refreshes that copy. It's prepared only after the flight landed, so the GPU's write reaches title memory and the refresh reads it. Mutation check: with the gate forced open, the GPU's write is lost (title memory 0 instead of0xCAFEBABE).prep_ahead_lands_before_launching_a_flight_that_marks_writes,prep_ahead_lands_before_a_title_copy: the new submission is prepared behind the flight, which then lands before the marked submission launches or before the title copy runs.tools/macos/test-wine.sh -p victory-gpu, after merging main (d1609d9): 601 passed, 0 failed.VICTORY_ASYNC_SUBMIT=1 VICTORY_PREP_AHEAD=1: the same 3 failures as underVICTORY_ASYNC_SUBMIT=1alone. They're tests that read GPU results synchronously right after submitting (list::…allocate_upload_survives_early_reset…,resource::…a_list_waiting_for_another_queues_write…,resource::…a_texture_read_back_reaches_the_title_buffer). Prep-ahead adds no failure.--workspace --all-targets, with and without--all-features, Windows target): clean.cargo xtask policy: ok.Re-test
Same spot, three runs:
VICTORY_ASYNC_SUBMIT=1(the B2 baseline);VICTORY_ASYNC_SUBMIT=1 VICTORY_PREP_AHEAD=1;VICTORY_HEAP_WORKER=1.Compare
ms/frame, the flight line'shost GPU idle … preparing, and the new "prepared while the last was in flight" line (l, and the reasons). If anything looks wrong on screen with prep-ahead but not without (flicker, stale geometry, wrong streamed textures), that points at a title write into memory a submitted pass reads, and the first suspect is the in-place refresh.Follow-up 3: a probe for a range-level rule (measurement only)
Run C (
VICTORY_ASYNC_SUBMIT=1 VICTORY_PREP_AHEAD=1) showed 2.8 fps / 360 ms, unchanged from async alone. 6–8 of ~10 submissions per frame were "not quiet at landing", so almost nothing was prepared ahead. Before replacing the whole-flight rule with a range-level one, commit 6086751 measures the ceiling. It changes nothing that runs.With
VICTORY_PREP_AHEAD=1, every landing records two things:The preparation right after that landing records the host-copy ranges its refreshes actually rewrite (
Batch::add, written copies only) and compares them against the flight's writes. New frame line:Test changes
prep_ahead_probe_counts_overlapping_and_disjoint_refreshes(GPU): behind a flight with a declared shader-written range, a refresh of another host copy is counted as able to go ahead, and a refresh of that range is not.overlaps_finds_shared_bytes_onlychecks the range sweep.Host::quiet(a heap made on its thread) lands every flight in the air, which is correct. Each attempt also keeps its title memory allocated: freed test memory left its host copy registered, so the next attempt found that copy at the same address, and the copy-back saw no change.--all-features;cargo xtask policyok.Re-test
One run as in C (
VICTORY_ASYNC_SUBMIT=1 VICTORY_PREP_AHEAD=1), then read the new "prep-ahead probe" line. Behaviour is unchanged from C, so ms/frame should match.Follow-up 4: host preparing time, and the range rule ready for A/B
None of this changes the default path or
VICTORY_PREP_AHEAD=1.4837ee3: preparing split by phase. A new frame-report line:host preparing per frame by phase, ms: evicting, heap views synced, uploads, list steps, preludes, refreshes, landing early, other.b817920: the hang note no longer copies pipeline names.host::waiting_on_tests::waiting_on_takes_the_sets, ignored by default, run with--release --include-ignored.Arc), and names are built only for the hang line.e0e0242:VICTORY_PREP_AHEAD=ranges, the range rule, off by default. It also prepares behind a flight that is not quiet, when what its landing writes is known before it runs:The preparation lands that flight first only when it would do one of these (
Early::Overlap/Early::CpuRead):A flight with work after it, read-backs, table textures or uploads lands first, as with
=1. It matches the probe's "could go ahead by ranges" (C) except that fills and host work are also checked, which the probe doesn't count.Shortcut: a texture over memory the flight's shaders write can be brought up one submission late.
Tests:
writes_keep_declared_pages_bottom_of_pipe_bytes_and_whole_copies;prep_ranges_launches_behind_a_flight_writing_other_memory(two in flight; the write goes back; the refresh reads the title's bytes);prep_ranges_lands_before_refreshing_what_the_flight_writes. This is the hazard test, and it fails with thebefore_refreshcheck removed.A/B after the probe run:
VICTORY_ASYNC_SUBMIT=1 VICTORY_PREP_AHEAD=rangesagainst=1.host GPU idle … preparingshrinks by up to C/(submissions a frame) of itself, plus the hang-note saving. If C comes out near 0,=rangeswill only show "landed it first" counts, and per-flight mark bitmaps are the next step.Suite: 604 passed, 0 failed (two runs) after the first two commits; 607 passed, 0 failed (two runs) after the range rule. One of five runs hit a race in
host::marks::work_goes_on_on_a_new_queue: another test's flight movessubmittedbetweenexecuteand the check. It passes alone and in the reruns. Clippy is clean with and without--all-features.Follow-up 5: the probe result, and the ~180 MB of preparing copies
Run D (6086751): "could go ahead by ranges 0.0 (0.1 if marks were known ahead)" out of 10.3 preparations. Almost every flight is held by write marks, BoP writes, table textures and work after it, all at once. So
VICTORY_PREP_AHEAD=ranges(e0e0242) stays off and won't be developed further. For the same reason, removing the table-textures blocker on its own would unblock nothing.d16fabf: what the copies are, andVICTORY_SAME_COPIES.host preparing copies per frame. It splits the copy MB/ms into three kinds: title copies between buffers, fills of upload memory, and refreshes of host copies (only changed 64 KiB pages, with fault tracking on). Up to now the ~180 MB had no breakdown.VICTORY_SAME_COPIES=probecompares each title copy before running it: source against destination, and against every host copy of the destination. It counts the copies whose bytes are already in place. The copies still run.=skipleaves those copies out. That saves the write and the refreshes it would make due for the destination's host copies (whole pages).host::batch::same_copy_costs): comparing takes 4–5× a copy (8.4 µs vs 1.9 µs per 64 KiB). Soskiponly pays off if most copies are already in place and the saved refreshes outweigh the extra cost. Runprobefirst.probeit still runs;skiptoo;234f010:host::marks::work_goes_on_on_a_new_queuenow runs under the mode lock and synchronously. It failed in about one full-suite run in four, because another test had switched Flight-1 on.Next run:
VICTORY_ASYNC_SUBMIT=1 VICTORY_SAME_COPIES=probe. Read the new line, plushost preparing per frame by phase:=skip.Suite: 610 passed, 0 failed, three runs. Clippy clean, policy ok.
Follow-up 6: heap sync and refreshes, measured before changing them
Run E (
VICTORY_SAME_COPIES=skip): title copies are 29 a frame (0.1 MB), so the ~174 MB is refreshes. Preparing by phase: heap views synced 41–56 ms, uploads 14–40, list steps 20–25, refreshes 18–20.c4b3402: offline benchmarks, and three new lines for what they couldn't settle. It changes no behaviour, so it needs no switch.bench_unchanged_page_scan_vs_compare).heap views synced per framesplits it into syncs, pages, slots checked and slots made again, and ms for taking the written ranges (pages re-guarded), reading, checking and making.refresh_cost_per_written_page). That is roughly the copy itself, so a hash or compare skip saves nothing.OpenExistingHeapFromAddress.mach_vm_remap,alias.rs). It is on here (24 GiB), but only forXMemVirtualAlloccommits that are read-write and whole pages.host copies refreshed per frame: copies, tracked/untracked MB, and the top 5 with address and size;title memory committed without zero-copy aliasing: by reason, which is aliasing off, protection, placeholder, not whole pages, or remap failed.Next run:
VICTORY_ASYNC_SUBMIT=1, optionally withVICTORY_HEAP_WORKER=1. That existing switch, off by default, makes heap-indexed textures on its own thread, which should shrink the "uploads" phase. Read the three new lines:Suite: 611/0 twice, victory-hle 211/0. Clippy is clean with and without
--all-features, policy ok.Follow-up 7: views made again, and the region refreshed whole
Run F: the heap sync takes 48.1 ms a frame, and 46.7 ms of that is making 40,989 slots again. Reading and checking pages takes under 2 ms.
9a036af:VICTORY_HEAP_READ_ONCE=1(off by default). Each slot made again used to re-read its 12-byte record through the kernel under the heap lock. That costs 0.46 µs under Wine (bench_record_reads), about 19 ms a frame at 41k slots. With the switch, the stale slots' records are read once, under the same lock.bench_made_again_read_once(ring-like, every slot takes another view each pass): 0.77 µs → 0.31 µs per slot made again, with the same made and kept state.read_once_makes_what_reading_each_record_makes.CopyDescriptors. A cache that lasts across syncs would have to keep resources alive past eviction, so it isn't built. The benchmark's remaining 0.31 µs per slot is the next ceiling.The 25.2 MB region refreshed whole (
0x73c8a80000). Zero-copy aliasing (mach_vm_remap) only coversXMemVirtualAlloccommits that are read-write and whole pages. A region whose every page the title rewrites each frame, and that doesn't show in the "committed without zero-copy aliasing" line, most likely lives in physical pages (XMemAllocatePhysicalPages+XMemMapPhysicalPages, file sections). The GPU can only read those directly if the pages are backed by GPU-visible memory. The diagnostics-onlyVICTORY_PHYSICAL_TILES(alias::PhysicalHeap) is that trial. The refreshed-copies line now marks copies of memory the title shows at several addresses.Next run:
VICTORY_ASYNC_SUBMIT=1 VICTORY_HEAP_READ_ONCE=1. Read "making them", and whether the top refreshed copies are marked "(shown at several addresses)". Also send the "committed without zero-copy aliasing" line, if it printed.Suite: 612/0 in three runs. Clippy clean, policy ok.
Follow-up 8: read-once by default, and what making slots costs
Run G (9a036af,
VICTORY_HEAP_READ_ONCE=1): the heap sync fell from 50.1 to 33.5 ms, which is 0.70 µs per slot made again instead of 1.14. The game ran at 2.9 fps / 342.8 ms against 2.6 fps / 386 ms in run F, and with more draws. No glitches were reported.dd434a4:VICTORY_HEAP_READ_ONCEis on by default (=0turns it off). It reads the same bytes under the same lock, and the run showed no difference except the time. Test:reading_records_once_is_on_unless_zero.heap slots made again per frame:CopyDescriptors, keeping, noting (bindless), rest.VICTORY_VIEW_PROBE=1(off) also counts created views whose descriptor an earlier sync already created. That is the ceiling of a cache across syncs.bench_made_again_read_once(256 views rotating through 16k slots), creating views is only about 2% of making slots again. Most of the cost is the slot loop and the bindless notes. So a content cache would save little unless the world creates far more views. Use the probe to decide before building one.mach_vm_remapaliasing doesn't cover those. No-copy access needs the pages backed by GPU memory (theVICTORY_PHYSICAL_TILEStrial).newBufferWithBytesNoCopypath through D3D12.OpenExistingHeapFromAddressis refused.Next run:
VICTORY_ASYNC_SUBMIT=1 VICTORY_VIEW_PROBE=1. Send the two heap lines and the refreshed-copies line.Suite: 615/0, two runs. Clippy clean, policy ok.
Follow-up 9: test flakes, and the physical pages behind the refreshes
778bfd7: four flaky tests fixed. I ran the suite 20 times under Wine: no access violation, but one failure. Three tests assume submission is synchronous and now run under the mode lock:list::…allocate_upload_survives…;resource::…a_texture_read_back…;resource::…a_list_waiting_for_another_queues_write….shadow::loose_memory_must_be_committednow takes a reservation that has no stale copy over it. Afterwards 20 of 20 runs were green (10 synchronous, 10 withVICTORY_ASYNC_SUBMIT=1), and CI is green.Run H (778bfd7): 3.0–3.1 fps, heap views synced 23.9 ms. The four largest refreshed copies, about 75 MB of the 173 MB a frame, are all
mapped, protect 0x2:XMemMapPhysicalPages). Zero-copy aliasing only remaps privateXMemVirtualAllocmemory, so it doesn't reach these.5955ee4: how those copies lie on physical pages. The GPU could only read them in place if the physical pages were GPU memory and a copy's pages fell in one GPU range: one run per section, or a tiled resource per page. The trial behindVICTORY_PHYSICAL_TILES(diagnostics builds) backs sections with a placed buffer. The refreshed-copies line now shows, for the five largest copies,physical pages P in R runs over S sections, from victory-hle's page table viavictory_gpu::on_physical_runs. Test:physical_runs_count_pages_one_after_another_in_a_section.UpdateTileMappings) under D3DMetal.The views made again: the line
heap slots made again per frameis always printed (on Windows builds), directly afterheap views synced per frame. Its part "created by an earlier sync" (the ceiling for a view cache) appears only withVICTORY_VIEW_PROBE=1.Run I:
VICTORY_ASYNC_SUBMIT=1 VICTORY_VIEW_PROBE=1. Send the two heap lines and the refreshed-copies line.Suite: victory-gpu 615/0 (twice), victory-hle 212/0. Clippy clean, policy ok.
Follow-up 10: merge with main, the view cache, the physical pages, and list steps
5b24362: mergedorigin/main. main's #640 now reads a heap sync batch's stale records once per page, always, which is whatVICTORY_HEAP_READ_ONCEdid here. I kept main's version and removed the switch, its test and its docs row. Suite after the merge: 620/0 (twice), victory-hle 216/0.(1) View cache: not built, because the measurement says it can't help. With main merged,
bench_made_again(a ring of 256 views over 16k slots) takes 0.36 µs per slot made again. Of that:viewed.set_batch(bindless range bookkeeping)A content cache would only remove the 0.3%. The real lever is the bookkeeping. In a ring of tables, each view leaves one slot and enters another, so a batch's net change to the bindless ranges is close to zero. Netting the +1/−1 per range before applying it would skip most of
set_batch, up to ~30% of the ~23 ms. In the world, the lineheap slots made again per framegives the exact split. Its "created by an earlier sync" part needsVICTORY_VIEW_PROBE=1.(2) A no-copy GPU view for the physical pages is possible. The existing hardware probe
inplace_probe_6_remap_cpu_visible_tilespasses under D3DMetal. It shows that a reserved buffer whose tilesUpdateTileMappingsmaps onto a CPU-visible L0 write-back heap works:Run I's layout (576 pages in 4 runs, 384 in 7, one section each) fits it well. One mapping call per run covers a whole title buffer. The plan, behind a switch:
mach_vm_remap. This is the existingVICTORY_PHYSICAL_TILEStrial, today diagnostics-only.XMemMapPhysicalPages,CopyPageMappingsBatchX, already queued in order by this PR).Expected gain: most of the ~175 MB / 15 ms of refreshes, plus the title threads' write faults on those pages (~35 µs a page in the tracking benchmark). Risks:
This is a multi-step change to victory-hle and victory-gpu, and it needs game runs at each step.
(3)
33475e6: list steps split. New linehost list steps per frame: each step kind counted, the heavier ones timed. The kinds are:Run J:
VICTORY_ASYNC_SUBMIT=1 VICTORY_VIEW_PROBE=1. Send the lineshost preparing per frame by phase,host list steps per frame,heap views synced per frame,heap slots made again per frameandhost copies refreshed per frame.62476de: mergedorigin/mainagain (up to 7128c74). Two adjustments:InFlight.armedis kept, disarmed at landing, beside the prep-ahead probe's landing record.flight.rsimports host's listStepasListStep, so it doesn't clash with its own flight-timeStep.Suite after the merge: victory-gpu 639/0 (three runs), victory-hle 216/0. Clippy clean, policy ok. CI green (run 46087857132), and the PR is mergeable again.
Follow-up 11: the title's physical pages read in place (
VICTORY_PHYSICAL_TILES=1)5416c68, off by default, Rosetta and D3DMetal only. The largest refreshed copies in run I sit on the title's physical pages: 576 pages in 4 runs and 384 in 7, one section each. With the switch on, those pages are GPU memory, and such buffers need no copy:alias::PhysicalHeap, until now a diagnostics-only trial. The title's views are remapped onto the heap (mach_vm_remap), so the title's CPU writes and DirectStorage's writes land in GPU memory.UpdateTileMappings, one call per run of consecutive tiles). Nothing is refreshed into it or copied back, and what shaders write the title reads at once.victory_gpu::physical_retiled) and the copy's tiles follow at once on the host queue.Tests:
Also fixed:
own_section_views_start_above_two_tibno longer checks the address floor when the whole view is the GPU heap.until_takenwas meant to do. The new test's tile updates made that more frequent.Suites under Wine before the pause in Wine tests:
shadow::marked_pages_go_back_by_the_bytes_the_gpu_changed, which also fails without this change while other sessions' GPU tests run.lifecycle::…a_title_window…, which looks unrelated. Both still need a Wine run after run K1.Run J (or K):
VICTORY_ASYNC_SUBMIT=1 VICTORY_PHYSICAL_TILES=1 VICTORY_VIEW_PROBE=1against the same withoutVICTORY_PHYSICAL_TILES. Readhost copies refreshed per frame(the physical-page copies should be gone), the refreshes phase, the startup log linefirst title buffer read on its physical pages in place, and watch for corrupt geometry or textures. Memory: the physical pages become wired GPU heaps.🤖 Generated with Claude Code