Repository navigation
Conversation
…obe`; HLE: count the title's frees and protects of graphics memory
The tier-3 design (title memory as the GPU's own, one opened heap per
region) rests on driver limits nobody had measured on the card. This adds
the design's probes (inplace_probes.rs), run on a queue and memory of
their own, and a way to run them without the title:
victory inplace-probe [--small] [--tiles] [--debug-layer] [--mb N]
and `cargo test -p victory-gpu -- --ignored probe_on_hardware`. In game,
VICTORY_INPLACE_PROBE=1 adds the small ones (P2-P6, R9) to the first probe,
now on a thread of its own; =3 also the ones that lock or commit gigabytes
(P1, P2's 4 GiB part, P7).
Measured on the RTX 4090 (debug layer on, no errors except where said):
- P1: 40 bits of GPU VA per resource and per process. Parts of 2 GiB,
4095 MiB and 4 GiB - 64 KiB open (343/684/672 ms) with a buffer over
all of it, written at its far end by copy and shader. 4 GiB and 6 GiB
are refused by the runtime ("must point to a memory region that is 4GiB
or less"). Committed sections of 2 GiB and 4095 MiB open (89/177 ms);
6 GiB is refused ("hFileMapping must be 4GiB or less").
- P2: opening private memory locks it: 1 GiB 173 ms +1,024 MB working set,
4095 MiB 695 ms +4,096 MB; no commit added; the heap goes in 16/68 ms. A
committed section's pages count in the working set when opened (no
more when the GPU reads them).
- P3: InterlockedOr/And from a compute shader into a part and a section
are exact, a byte replaced by And+Or keeps the dword's other bytes, and
a CPU writing byte 0 of the same dwords all along keeps its last byte
(32 of 32) while the GPU's bits all land.
- P4: with a part opened, write watching still reports CPU writes
exactly ([1, 5, 9] -> [1, 5, 9]) and reports none of the GPU's (copy and
shader: []).
- P5: 512 parts of 64 KiB with a buffer each: 93 ms, none refused, gone in
41 ms. Two overlapping parts: written through one, UAV barrier, read
through the other in one list: right, and the CPU sees it.
- P6: a buffer in an opened heap works as vertex and index views, root
CBV, typed SRV and raw UAV in a table, ExecuteIndirect arguments and
count, CopyTextureRegion both ways, ResolveQueryData. One buffer used as
copy source then destination in one list needs an explicit transition
(implicit promotion is once per list: risk R8).
- P7: commit headroom 63,990 MB; a 6 GiB SEC_RESERVE section adds 0 MB,
SEC_COMMIT adds 6,156 MB (whole or as six 1 GiB sections, both made at
once); a 6 GiB section cannot be opened as one heap.
- R9: on pages of an opened part VirtualProtect read-only, MEM_DECOMMIT and
MEM_RELEASE fail with error 87, also while only a buffer placed in the
heap is alive; MEM_RESET and an unchanged protection succeed.
- tiles (--tiles, a device of its own): a reserved buffer's tile mapped
onto a heap in the card's memory works; mapped into an opened heap the
runtime removes the device (0x887a0001), as on the software adapter.
R9 (count only): with VICTORY_INPLACE_PROBE, VICTORY_INPLACE or
VICTORY_MEMORY_CALLS=1 the title's kernel32 VirtualFree, VirtualProtect
and VirtualAlloc(MEM_RESET) go through wrappers in xmem.rs that call the
host's functions unchanged and count (and log, first 16 and every power
of two) the calls that touch memory XMemVirtualAlloc reserved. Without the
switches the imports go to the host as before.
Tests: victory-gpu 111 passed, 2 ignored (probe_on_hardware, and the one
ignored before); victory-hle 96 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…in place are declared to the flights The two bugs of the tier-3 design (§11), both only with VICTORY_INPLACE. 1. memory.rs (raw-address directory of the BVH builder) wrote each page's offset from the title memory's first byte and gave each numbered copy a view of `len` bytes from the buffer's start. A copy in place is a buffer that begins on the 64 KiB line below the title memory (or, with arenas, at the arena's base): every raw access was `bias` bytes off and the last `bias` bytes were cut off. The offset is now `Shadow::offset(page)` and the view `offset(start) + len` bytes (entry_offset, view_bytes). 2. Shader writes to memory in place were not declared at all (`Shadow::gpu_writes` returned early), so late wait and the relay could let a CPU read of that memory (a title buffer copy, a fill, a texture, a step of ours, a value wait) run before the flight that writes it. The range is now declared like a copy's; `declared_writes` leaves it out of the copy-back (nothing to copy back), and the new `in_place_writes` puts it in the flight (`Sent`/`Flight::in_place`) and in the line's `written`, which `late_blocked`, `relay_wait`'s `blocked_by` and `late_met` read, and which a landing recomputes from the flights still in the air. With this VICTORY_INPLACE=2 (and the coming 3) may be combined with VICTORY_LATE_WAIT / VICTORY_RELAY: they hold back reads of in-place writes exactly as of copies' declared ranges, under the same assumption (shaders write only what is declared) and the same shortcut (another host copy of the same bytes is not told). The doc's "do not combine" is replaced by that. Behaviour without VICTORY_INPLACE is unchanged (no copy is in place, so no range takes the new path). Tests (software adapter): memory::tests:: warp_raw_addresses_into_memory_in_place_take_the_bias (the directory offset reads the page's own bytes, the view reaches the last byte); host::in_place_tests::warp_in_place_writes_reach_the_flights (in-place ranges come out of a submission's steps joined, a copy's do not). victory-gpu: 113 passed, 2 ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…, VICTORY_INPLACE_POOL=1 committed pool sections Stage 1 of the tier-3 design. Levels 1 and 2 open a heap of their own per window or title buffer (`place_part`); level 3 opens one heap per region the GPU reaches, an arena, with one buffer placed over all of it, and every title buffer and window in it is that buffer at an offset (`inplace::place_for` now returns a view: bias = start - arena base). arena.rs: - Parts of private title memory: only memory XMemVirtualAlloc committed (xmem reports it, `title_memory_committed`; nothing else, the Rust heap included, is ever opened). The runtime refuses a part of 4 GiB or more on the card (probe P1), so parts are at most 4 GiB - 64 KiB and a bigger region has overlapping parts every 2 GiB (P5: overlap works); a range takes the lowest part that holds it whole. Opened on first GPU use: at once up to VICTORY_ARENA_SYNC_MB (64, ~11 ms), else on a thread of its own (P2: 1 GiB locks in 173 ms), copies until then; a title buffer copied before its arena opened is let go at the next sweep when nothing holds it (`in_place_upgrade`), so the next ask finds it in place. - Sections of the physical page pool made committed: view memory that is one run of one section is in place in the section's arena (the heap is the section; views come and go under it). Windows over view memory are the run around the ask (`inplace::run_window`): the census found 1,948 MB of 4 MiB windows over views with unmapped pages, and the GPU never reads a view through a tile mapping (into an opened heap that removes the device: probe "tiles", on the card too). - `resolve(addr, len)` gives resource, offset, GPU address, bytes left and kind (InPlace, Section). Budget: VICTORY_INPLACE_MB, by default a quarter of the PC's memory (opening locks pages: on this 96 GB PC 24 GiB), scaled from the queried RAM. - Free/protect (R9): the runtime's wrappers of the title's VirtualFree, VirtualProtect (other than read-write) and xmem's own release of 32-bit memory call `title_memory_released` first: the parts over the range are retired and what is in place in all of them let go, so the pages are no longer locked unless a list still holds the arena's buffer. - Big buffers keep their copies in the card's memory (VICTORY_CARD_BUFFERS_*), as at level 2. xmem.rs, VICTORY_INPLACE_POOL=1: the page pool is made of SEC_COMMIT sections of VICTORY_POOL_SECTION_MB (1024; at most 4095: P1/P7 refuse a 6 GiB section as a heap) while the commit has room for the pool and 4 GiB more (else reserved, as before, with a warning); `commit` does nothing for a committed section; pages are slices of their chunk's section (`runs` and mapping already break at sections). A closed section retires its arena. Off, one reserved section as before. The in-place line every ten seconds gains an arenas line: parts and sections open, GiB locked against the budget, opened/refused/retired, ranges resolved, MB of private and view memory placed in them. Tests: arena::tests (parts of a region and the lowest that holds a range; on the software adapter two title buffers resolve into one arena and the GPU reads and writes their bytes there, retiring unlocks the pages; a run of a committed section resolves at its section offset and the GPU's write shows through the view), inplace::tests:: a_window_over_views_is_the_run_around_the_ask, and arena_on_hardware (ignored; passes on the RTX 4090). victory-gpu 117 passed, 3 ignored; victory-hle 96 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…nts across same-page remaps, say why ranges are turned down
In run inplace3-t3 (VICTORY_INPLACE=3) no part ever opened: the title
commits its 3.4 GB private region at 0xd00000000 in steps, with holes and
pages of other protections, and the arena asked for one part over the
whole region ("not private memory committed whole and read-write"); that
one refusal then turned down every range of the region. The pool run
(inplace3-pool-t3) worked: 8 sections open, 6.78 GiB locked, 6,011
windows (575 MB) and 80 title buffers in place, 2,018 MB of view memory
placed, median frame 233.8 ms against 285.5 ms for its control (-18%).
Parts come from runs of committed pages. `runs_of` asks Windows for the
runs of committed read-write private pages of a reported region, one
VirtualQuery per run. The runs are asked when first needed, and again
when the region changes or an opening finds the pages changed. A range is
in place when it lies in one run. Its part is the lowest of the run's
parts on the 2 GiB grid from the run's start (`grid_part`, at most
4 GiB - 64 KiB). An open part that holds the range is always taken
first. So when the title commits more and two runs join, ranges over the
join open a new, longer part beside the older ones, which stay for what
was placed in them until it is let go. A refusal is kept per part, not
per region, and a part refused because its pages changed is not kept at
all. The title's own kernel32 VirtualAlloc(MEM_COMMIT) in memory that
XMemVirtualAlloc reserved is reported too (xmem's wrapper).
Remaps. The pool run let 9,755 in-place windows go in three minutes
because the title remapped their pages. A placement in a section's arena
is now only marked when its pages are remapped. When it is next asked
for, it stays if its range is still the same run of the same section at
the same offset (`still_good`, `inplace::still_run`); otherwise it is let
go and placed again. Both outcomes are counted on the arenas line
(REMAPS: kept / placed again). Placements in private parts, and the
title's own frees and protects, still let go at once.
Why a range is turned down is now counted by kind (arena::Why):
- view memory not one run of a committed section;
- not memory the runtime reported committed;
- spans pages not committed;
- spans another protection;
- longer than a part of its run;
- over the budget;
- refused by the host;
- its arena still being opened.
The counts are given on the arenas line, so the census can be checked
against what placement does.
Off path: `host::in_place_writes` returns before any pass when
VICTORY_INPLACE is off, a closed section tells the arenas nothing below
level 3, and xmem's release of 32-bit memory asks nothing (no lock, no
VirtualQuery) unless the wrappers' switches are on. Everything else was
already behind a switch read once.
Tests:
- arena::tests::a_range_takes_the_lowest_part_of_its_run_that_holds_it
(the grid; regions joined and cut).
- arena::tests::warp_runs_of_committed_pages_are_parts_of_their_own. A
reservation is committed in two runs with a hole: a buffer in either run
is placed in its run's part, and one over the hole is turned down. After
the hole is committed and reported, a range over it gets a part of the
joined run beside the older two. A range over a read-only page is turned
down as another protection. The GPU reads the title's bytes through
each part.
- shadow::remap_tests::warp_a_placement_in_a_section_outlives_a_remapping_
to_the_same_pages.
- arena_on_hardware passes on the RTX 4090.
victory-gpu 119 passed, 3 ignored; victory-hle 96 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…s a part; checked ends of committed ranges A part or section bigger than VICTORY_ARENA_SYNC_MB is opened on the arenas' thread. That thread read the bytes locked, opened the heap outside the arenas' lock, and added the bytes only once it was open. So while a 4 GiB part was opening (695 ms on the card, probe P2), a second ask could pass the same budget test, and both could be opened: VICTORY_INPLACE_MB was not a bound. The same check-then-act class is open in fork PR fxceless#358's place_for; it must not exist here. Now the bytes are taken from the budget when the thread is asked (Arenas::reserve, under the arenas' lock), and the slot remembers them (Slot::Opening(bytes)): - opened: they stay with the open part; - refused by the host, or no host: given back when the thread lands it; - retired (title_memory_released) or the section closed while it opens: given back then, and what the thread opens afterwards stays closed; - over the budget at the ask: refused at once, and the refusal is kept, as a refusal by the thread was before. Openings on the asking thread take the budget the same way, under the same lock as before. The open functions no longer test the budget; their callers do. Arenas::committed now uses checked ends: a range reported at the top of the address space is ignored instead of wrapping. Tests: victory-gpu 120 passed, 3 ignored (was 119); victory-hle 96 + 1 passed. - arena::tests::warp_a_part_asked_of_the_thread_holds_its_budget (new). A second ask while the first part opens is refused for the budget. The thread's refusal gives the bytes back. A part retired while opening gives them back, and its late result stays closed. A part the thread opened keeps them, and resolves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…e arenas' thread as the runtime reports it
In run inplace3-pool the private arenas opened (2 parts, 3.29 GiB
locked, 287 MB placed), but 1,320 placements were turned down "its arena
still being opened": a part is opened at its first GPU use, and a part of
2.2 GB takes about 365 ms to open on the arenas' thread. Meanwhile every
buffer in it gets a copy, and keeps it.
With the switch (off by default; with arenas, VICTORY_INPLACE=3 or more),
a commit of graphics memory the runtime reports (title_memory_committed)
is asked of the arenas' thread at once (Arenas::ask_early), so its part is
usually open before the GPU first uses it:
- the parts are cut from the commit itself, every 2 GiB from its start
and up to 4 GiB - 64 KiB each, as a run is cut (grid_part), so commits
made in steps never open parts over each other; a range over two
commits gets the part of its run at its first use, as before;
- commits of VICTORY_ARENA_SYNC_MB (64) or less are left to their first
use, which opens them on the asking thread (about 11 ms);
- the budget (VICTORY_INPLACE_MB) is held from the ask on; over it,
nothing is asked and the first use decides, as before;
- commits reported before the host is up wait for the first range
resolved (the host is not made for them);
- a range in a part asked early that is still opening is turned down as
opening, and residents wait for it (resolve_waiting), instead of asking
for a second, overlapping part of the same run;
- title_memory_released waits (five seconds at most) for a part asked
early over the range that is still opening: while it opens its pages
are locked, and the title's decommit or protect would fail (R9).
Without the switch nothing is asked early, the set of parts asked early
stays empty, and resolving and releasing are as before.
Each ask is logged:
"arena: committed graphics memory asked of the arenas' thread as the
runtime reported it (VICTORY_ARENA_EARLY=1)" start=.. mb=..
followed by the opening line as before. The effect shows in the existing
turned-down counts ("its arena still being opened").
Tests: victory-gpu 130 passed, 4 ignored (was 129); victory-hle 96 + 1.
- arena::tests::a_commit_asked_early_is_opened_in_parts_of_its_own (new):
a 5 GiB commit is asked as two parts (0, 4 GiB - 64 KiB) and (2 GiB,
3 GiB) with their bytes held; a range held already, a small commit and
one over the budget are not asked; a range in an opening part is turned
down as opening without a new ask; a release over it sees it; landed or
released, it is no longer waited for and its bytes are given back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…s; never by its handle On the card's driver a section opened as a heap by its handle (OpenExistingHeapFromFileMapping) keeps its commit until the PC restarts, whether it is released in order or not: 256 MB kept in every case in inplace::tests::section_heap_commit_comes_back (ignored; it runs on the card). Opened through the address of a view of it (OpenExistingHeapFromAddress1), none is kept. Every run with VICTORY_INPLACE_POOL=1 left the pool's commit behind; after a few runs the system's commit limit was reached. An arena over a section now maps a view of the whole section of its own (arena::SectionView) and opens the heap on it: an offset in the heap is the offset in the section, and the title's views come and go over the same pages as before. The view stays mapped while anything holds the heap (arena::Heap holds both), and is unmapped 10 s after the last holder lets go: a submission still in the air may hold the arena's buffer alone. Opening by the handle stays possible for the probes with VICTORY_ALLOW_SECTION_HEAPS=1; the probe line says why it is refused otherwise. Measured: the system's shared commit stays flat across runs (21.3 -> 21.4 GB after several runs with the pool), where it grew by the pool's size every run before. Tests: arena::tests::section_arena_on_hardware (ignored, on the card: the commit comes back), warp_a_run_of_a_committed_section_is_in_place through the same path.
…LACE_MIN_KB)
With VICTORY_INPLACE=4 three compute passes that run once a frame took
1-6 ms of card time in the control and 19-67 ms with Tier 3 (timing runs
with VICTORY_GPU_TIMING; 5cf00dc3 3.3 -> 67 ms, cb6adcc6 5.6 -> 41.6 ms,
0a5ecfee 1.2 -> 19 ms). Their code is the same; what changed is where
they write: their buffer atomics go to tiny buffers (52 B, 480 B, 56 KB)
that were copies in system memory in the control and in place, in the
title's memory, with Tier 3. Shaders reach memory in place across the bus.
Title buffers smaller than VICTORY_INPLACE_MIN_KB (1024 by default, 0 for
no floor) now stay copies, as without VICTORY_INPLACE. Windows are not
affected. Such buffers are 42 MB in all (3,376 of them, 3,242 under
64 KiB), so copying them costs little.
Measured (RTX 4090, release, the same exe, the switches equal but this
one; inplace4 with VICTORY_CARD_TIME=1, 120 s after the world):
floor off floor 1024 KiB control (Tier 3 off)
frame median 495.0 ms 234.6 ms 240.1 ms
average fps 1.69 4.30 4.33
title lists, card time 222-244 ms 100-129 ms ~111-115 ms
The frame-rate line gets a placement census: title buffers and windows
apart, count and MB in a resident, in place (and of those under 64 KiB),
card copy and system copy; and the buffers the floor kept as copies.
Tests: inplace::min_tests (the default, 0 and bad settings).
…n the card's memory, fed from the arena and merged back by the card Stage 1's pool run (VICTORY_INPLACE=3 VICTORY_INPLACE_POOL=1, per layer, against its control) took the median frame from 285.5 to 233.8 ms. The largest layers left are the copies of the big title buffers in the card's memory (VICTORY_CARD_BUFFERS_MIN_MB=1, _MB=4096): - the relay's copy-back, 115-127 ms a frame; - 136-150 MB a frame still going up through staging in the PC's memory; - 70 MB a frame fetched back; - the copy engine at 0%. Reading those buffers in place over the bus instead raised the GPU wait from 81 to 103 ms: hot data belongs in the card's memory. New crate::resident (design section 4). A title buffer that would get a card copy, whose 64 KiB pages lie in an arena (a private part, or a run of a committed section), becomes a resident: - R, a buffer in the card's memory that shaders read and write; - B, its twin. The Shadow is R at a bias, as a placement is the arena's buffer at a bias, so every binding path works unchanged. Per submission, on the one host queue, each in an ExecuteCommandLists of its own: 1. Upload. The pages the title wrote since they last went up (write watching or the guards, at the submission's refreshes: Resident::refresh) are copied arena -> R, then R -> B, whole pages. There is no CPU copy, no staging and no hash. A page the title wrote always goes up: no range is held back because a flight may write it (the #1322 class). Whole pages are safe: every earlier submission's merge has run on the queue when the copy runs. 2. The title's lists, and the card compare for copies that remain. 3. Merge (resident::MERGE), over the joined ranges the submission declared written. It compares R with B per dword. A dword that differs goes into the arena and into B: a plain store if all four bytes differ, else InterlockedAnd + InterlockedOr on the changed bytes, so the CPU's bytes of the same dword survive (probe P3). Then the host fence is signalled as before. Title fences, events and bottom-of-pipe writes still go out when the relay lands the flight; for a resident it has nothing to fetch, compare or merge. Removed for residents: the relay's fetch, card_merge(_relay), card_back, snapshots and CARD_COMPARE hashing. They are not carded, and are left out of declared_writes. Their shader writes are still declared to the flights (in_place_writes -> Line::written). So late wait and the relay hold back a CPU read of them (a title buffer copy, a fill, a texture, a value wait) until the flight has run. In-place memory and residents work with VICTORY_LATE_WAIT / VICTORY_RELAY for that reason: their writes are declared, as copies' are (f5725f4), instead of being kept away from late waits. Ordering (risk R8): no resource is a copy source and destination in one list without an explicit transition. R goes COMMON -> COPY_DEST -> COPY_SOURCE in the upload. The arena's buffer is only a copy source there, and only unordered access in the merge. Separate ExecuteCommandLists make buffers decay to common and flush the title's UAV writes to R before the merge reads it. Sharing. A buffer of any size inside a resident's pages is that resident at its offset. Where two copies of the same memory still differ (a buffer placed in the arena before the resident existed, or two residents over the same pages), what one writes reaches the arena by the end of the submission. Those pages are then marked to go up to the others before the next submission (cross_mark), never to the writer. Budget: VICTORY_RESIDENT_MB, R and B counted; by default 60% of the adapter's local budget at the first ask, and each resident only while the card's use stays under 80% of it, as card_for. The twin is made with R. The first use of a big buffer opens its arena on that thread, or waits up to 5 s for the arenas' thread (arena::resolve_waiting). Otherwise it would keep a card copy for the run. A buffer not in an arena, an arena that cannot be opened, or a spent budget keeps today's card copy. Off path (VICTORY_INPLACE < 4): resident::on() is a OnceLock read. find returns at once, submit records and runs nothing, sent and line return. Behaviour is today's. New line, with the frame-rate line: residents (VICTORY_INPLACE=4): N alive, X MB in the card's memory and Y MB of twins (budget Z MB); per frame: a MB uploaded from arenas in b ranges, c MB compared in d merge passes, e MB merged into arenas (f partial dwords), g MB marked to go up again after writes through other copies, h submissions with work for residents Tests: victory-gpu 126 passed, 4 ignored (was 120 and 3); victory-hle 96 + 1 passed. All new, in resident::tests: - a_dword_takes_only_the_bytes_the_card_changed, pages_go_up_in_runs: the shader's byte mask and And/Or arithmetic, page runs, joins. - warp_the_pages_the_title_wrote_go_up_from_the_arena (test a): write watching names exactly the pages the CPU wrote, and the upload brings them into R and B. - warp_the_merge_stores_only_what_the_card_changed (test b), and merge_on_hardware (ignored; passes on the RTX 4090). Whole dwords are stored and partial dwords keep the title's other bytes. The CPU's byte 0, written all along by another thread, survives. A byte only the CPU wrote stays. B takes R. Counts are 80 dwords, 64 of them partial. - warp_a_merge_lands_before_the_next_upload_of_its_page (test c): submission 1's GPU dword is merged, the CPU writes a byte of the same page, and submission 2's upload carries both into R and B; its merge finds nothing. - warp_a_buffer_outside_arenas_keeps_its_copy_and_nested_ones_share (test d): memory not reported committed gets no resident. One in an arena does, and a buffer in its pages shares it. Cross-marking marks the others and not the writer. forget unregisters. The tests' title memory stays reserved to the end of the run. The write-watch journal remembers pages, and a later test given the same addresses failed (watch::tests::written_pages_are_reported_to_every_asker, single-threaded). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…places are let go and find it next time
A title buffer shares a resident whose pages hold it (the previous commit).
But when an inner big buffer is used before the one around it, the outer
one got a resident of its own beside the inner one. Their bytes stayed in
step only between submissions (cross_mark), and the card's memory held
the overlap twice.
Now a big buffer whose pages no resident holds, but which overlaps
residents, gets one resident over all of them (resident::make_over), if
that lies in one arena within the budget; else one over its own pages, as
before. The new resident takes their places in the registry, and lookup
lets go of the title buffers whose shadows are in a replaced resident, so
their next ask finds the new one. A replaced resident stays alive for the
lists and descriptor slots that still hold it, and keeps receiving the
title's pages and the other copies' writes until they let go.
resident::find now returns Found { resident, bias, replaced }.
Tests: victory-gpu 127 passed, 4 ignored (was 126); victory-hle 96 + 1.
- resident::tests::warp_overlapping_residents_become_one (new). Residents
over pages 1 and 5 are made first. A buffer over pages 0..3 replaces the
one over page 1, and its pages find the new resident. One over 2..6
joins the two remaining into 0..6. A write through the new one marks
the replaced one's page.
Thirteen runs of the whole victory-gpu suite in a row passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…he title as soon as the card has run them This is the fence part of the design's Stage 3. It is behind its own switch and works only with VICTORY_INPLACE=4 and the relay. With residents and memory in place, a flight's shader writes are in the title's memory when the host fence reaches it. The card put them there in the submission, and its writes to an arena's write-back pages are seen by the CPU once the fence completes. Such a flight has nothing for the relay to fetch, compare or merge (Flight::covered: no ranges of copies in the PC's memory, no pieces of copies in the card's memory). But relay_land lands every flight the card has run in one go, the copy-back of all of them first. So a covered flight's fence signals, events and bottom-of-pipe writes waited for the copy-back of the flights after it. With the switch, a landing first tells the title about the flights ahead of the first one that still has a copy-back, with what follows each of them: read-backs, bottom-of-pipe writes, fence signals (told_ahead). The rest is landed as before. The line's order is kept: nothing behind a flight with a copy-back is told before that copy-back, a covered flight behind it included. Flights that still carry copy-back keep today's behaviour. The telling is one method for both parts (Host::relay_tell). Measured with the relay, switch on or off, in a new line after the relay line: title fence signals set by the relay per frame: N, X ms on average after it took their flights from the card (the longest Y ms); M flights told before the copy-back of later ones (VICTORY_EARLY_SIGNAL=1: now on|off) The time is from the relay taking the landed flights, which is when it saw the host fence reach them, to each fence signal. Not done here (the rest of Stage 3): the present still settles, settle points are as they were, the submission lock is not narrowed, and CBVs are not bound as SRVs. Tests: victory-gpu 128 passed, 4 ignored (was 127); victory-hle 96 + 1. - host::relay_tests::covered_flights_are_told_before_the_copy_back_of_later_ones (new). With landable: a covered flight and what follows it go as soon as the card has run it. In a landing of three, the flight with a copy-back and the covered one behind it wait. A landing that starts with a copy-back tells nothing ahead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…Y_RESIDENT_HOT_FRAMES) In-game Stage 1 (release, VICTORY_INPLACE=3 with and without VICTORY_INPLACE_POOL=1, against controls first and last) moved the CPU side as designed: - preparing: 89.5 -> 79.9 / 75.2 ms; - buffer copies: 41.6 -> 36.9 / 28.6 ms; - snapshots compared: 23.7 -> 17.7 / 8.8 MB. The card pays. With the pool, its waits went 79.5 -> 106.2 ms, the bus 3.5 -> 4.8 GB/s, and the card's shared memory 5.7 -> 14.3 GB: shaders read the windows in place, sections of the pool above all, over the bus every frame. So at level 4, a window outside buffers that is in place, of the size of a buffer that would get a copy in the card's memory (VICTORY_CARD_BUFFERS_MIN_MB) or more, becomes a resident once it is asked for in VICTORY_RESIDENT_HOT_FRAMES frames running (3 by default; frames more than 8 apart start the count anew). This holds for private windows and for runs of committed sections alike. The window table hands out the resident from then on. The window in place stays for the lists and slots that hold it; cross-marking keeps the two in step. A resident's pages go up as any resident's do, and a remap that changes a section run lets it go, as a placement is let go. Windows that only ever get a single ask stay in place, and a resident is attempted once per window. The heat is two counters on the shadow, read and written only on the level-4 path. Below it, hot_window returns at once. Tests: victory-gpu 129 passed, 4 ignored (was 128); victory-hle 96 + 1. - shadow::heat_tests::a_window_is_hot_in_the_third_frame_running (new): asks in one frame count once; a window becomes hot once; a gap of more than 8 frames starts anew. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
… that made none Stage 2 is measured by layers, and two of them had no number: how many windows in place became residents for being hot (ff5832c), and how many big buffers asked for a resident and got none, so kept a copy in the card's memory (or stayed in place) and with it the relay's copy-back. The second says directly whether the copy-back can go away: a covered flight (Flight::covered) has nothing to fetch, compare or merge, and only buffers that are not residents still bring a copy-back. Checked on the way (no change needed): a resident has no card plan, no snapshot, nothing pending and no back ranges (Shadow::in_place is true for it: declared_writes leaves it out, writing returns before snapshots, update only notes pages for the upload), so a flight whose writes are all in residents or in place is covered, and the relay neither fetches nor merges anything on the CPU for it. The residents' line (new in this branch, VICTORY_INPLACE=4 only) ends with two counts since the start: "...; since the start N hot windows in place handed residents and M asks for a new resident turned down (not in an arena, or over a budget)" No other line changes. Tests: victory-gpu 129 passed, 4 ignored; victory-hle 96 + 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…side by side Stage 2 measured in game (RTX 4090, release @a7aff1a, VICTORY_INPLACE=4, run 20261125-011526-inplace4-s2) ran 3x slower than the control: median 753 ms (control 267, Stage 1 247), the card 94% busy, 686 ms a frame on the GPU against 100 in the control. Residents line: "574.1 MB compared in 82 merge passes, 38.59 MB merged into arenas (3093758 partial dwords)", i.e. some 10 million dwords merged a frame. nvidia-smi showed the card at 87-100% SM with the bus nearly idle (0.5 MB/s .. 4.7 GB/s) and less power than the control: the card was waiting on the bus, not working. The cause is the merge's layout. A thread took 16 bytes, so each store of a group of 64 threads was 64 dwords 16 bytes apart, and every store and atomic into the arena (the title's memory, over the bus) went as a scattered partial write. On the card, 16 MB changed in every dword took 167 ms to merge whole and 327 ms in part (about 100 and 50 MB/s). Now a group covers 1 KiB as four rows of 64 dwords side by side (the same 1 KiB per group, so dispatches are unchanged): 0.7 and 1.6 ms. The partial-dword atomics turn out cheap once they are in rows, so they stay (they keep the CPU's bytes of a dword written while the merge runs, probe P3). Checked on the way (no change): the 3.1 M partial dwords a frame are not a stale twin. B is R as the submission's shaders found it (B <- R after every upload, B <- R for each merged dword), so a partial mask is a dword the shaders stored whole with some bytes unchanged (small integers, floats whose high bytes stay). Their merge must not overwrite the other bytes, as the CPU may have written them; at bus speed that costs 1.6 ms per 4 M. The compare (574 MB a frame) reads R and B in the card's memory only: about 1 GB of reads a frame, a millisecond or so; the control's card hashes read 17,388 pieces of 64 KiB a frame (1.1 GB). Not a cost worth narrowing. Expected in game: the card's time back near the control's, the residents line unchanged in its counts (same bytes compared, merged and partial). Tests: victory-gpu 130 passed, 5 ignored (was 130 / 4); victory-hle 96 + 1. - resident::tests::merge_on_hardware_runs_at_bus_speed (new, ignored: opens the card): 16 MB changed whole and in one byte per dword, merged with the right counts and the title's memory equal to R, each under 20 ms (0.7 and 1.6 ms here; the old layout fails it at 167 and 327 ms). - merge_on_hardware, warp_the_merge_stores_only_what_the_card_changed and warp_a_merge_lands_before_the_next_upload_of_its_page pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…en, not by their pages Stage 2 in game (RTX 4090, release @a7aff1a, run 20261125-011526-inplace4-s2): "202.1 MB uploaded from arenas in 187 ranges ... 196.2 MB marked to go up again after writes through other copies" per frame. Almost all that went up from the arenas over the bus was cross-marking, not the title's writes. Cross-marking (resident::cross_mark) sends up to a resident what another copy of the same memory wrote in the submission: a buffer or window in place in the arena (written by shaders directly), or another resident whose merge wrote the arena (one replaced by a union and still held). It rounded every declared range out to whole 64 KiB pages. But the title wrote none of those bytes (its writes go up by write watching, whole pages, in Resident::refresh, unchanged), so only the bytes the other copy's shaders may have written can differ from the resident; the rest of each page went up again for nothing. They now go up on 256 bytes: the declared range widened to 256, cut at the resident's end. A whole page held by the arena is no fresher than these bytes of it: the arena holds the other copy's writes and the title's alike. Which of the other copies does the writing could not be told from the line, so it says it at the end (new fields only, the line's other words unchanged): "...; of the bytes marked per frame, X MB after writes in place and Y MB after merges of other residents over the same memory" X is buffers and windows in place in an arena over a resident's pages (windows outside buffers looked up by other keys than the hot one that became the resident, and buffers placed before a resident took their pages: the tables keep handing those out); Y is residents a union replaced that something still holds. Expected in game: "marked" and "uploaded" fall by what the declared ranges leave of their pages (unknown: 196 MB if they were all whole pages of 4 MiB windows, much less for small ranges); compared, merged and partial unchanged. Tests: victory-gpu 130 passed, 5 ignored; victory-hle 96 + 1. - warp_a_buffer_outside_arenas_keeps_its_copy_and_nested_ones_share: a merged write of 8 bytes goes up to the other resident as 256 bytes, not its page; a write in place across a 256-byte line takes both units in both residents; one at a resident's end stops there; the two kinds are counted apart. - warp_overlapping_residents_become_one: a write through the union goes up to the replaced resident as 256 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZC5U8SHMXUK5wS4AS2KxT
…-time and draw-time probes Stage 2 (VICTORY_INPLACE=4) latency work, behind the same switch; nothing changes without it. Card time (VICTORY_CARD_TIME=1, new cardtime.rs): timestamps around our uploads to residents, the title's lists and the merge, read back each submission. The frame-rate line says per frame: "upload to residents X ms, title lists Y ms, merge Z ms, between our calls ..., from one submission's end to the next one's start ...". Measurement switches that take one part of the residents' work away, to time it: VICTORY_RESIDENT_PLAIN_STORES, VICTORY_RESIDENT_NO_CROSS, VICTORY_RESIDENT_NO_MERGE. Merge by store width (B5). The translator now tells, per pipeline, the narrowest store its shaders make (pipeline::StoreWidth); it goes with each declared write (shadow::writer, Step::GpuWrite, resident::Declared). Where only whole-dword stores write a resident, the merge stores whole dwords; elsewhere it keeps the atomics that leave the CPU's bytes of a dword alone. VICTORY_RESIDENT_PARTIAL = flag (default) | atomics | cas | load | plain picks the way for partial dwords. Merge card time: 165 -> ~10 ms a frame. One owner per title range (B1; VICTORY_RESIDENT_ONE_OWNER=0 turns it off). Residents that overlap were made into a union, but buffers still holding the old ones kept them alive, taking uploads and merges every submission. Now: - make_over fails closed; - resident::retargeted keeps the set of replaced residents and a generation; - shadow::retarget_tables lets both tables' copies of unregistered residents go before an ask; - HostHeap::mirror remakes descriptor slots that show a replaced buffer; - the heap-pass cache and memory.rs's numbering follow; - prepare releases what finished lists held first. In game: zombies 0, overlap 0, re-uploads 199 -> 24 MB a frame. Draw-time probes: - VICTORY_PROBE_PIPELINES=<hashes> logs each probed pipeline's views (where each copy lives, Shadow::describe) and its store and atomic counts (Translated::store_counts); - diagnostic timing runs tag commands +R/+W/+S; - VICTORY_GPU_TIMING_TOP sets how many pipelines are listed; - the slot-mismatch counter is split by kind. Tests: victory-gpu 137 passed, 8 ignored (serially): merge with the CPU writing for each partial way, overlap and retargeting.
…S=1, or VICTORY_PROBE_PIPELINES) With residents on, every bound slot was checked against its view's copy (HostHeap::shows takes the heap's lock, once per view of every draw), and every view set the +R/+W/+S tag bits, in every build and run. These are measuring tools; they now run only with VICTORY_DRAW_PROBES=1 or when VICTORY_PROBE_PIPELINES names pipelines. Off, the residents' line counts no mismatched slots (0).
…lter Co-Authored-By: Gemini 4 Neon <gemini-code-assist@google.com>
Co-Authored-By: Gemini 4 Neon <gemini-code-assist@google.com>
…hadow windows Co-Authored-By: Gemini 4 Neon <gemini-code-assist@google.com>
…sync Co-Authored-By: Gemini 4 Neon <gemini-code-assist@google.com>
Conflicts resolved toward main for the indirect draw path: indirect.rs is main's (pull request fxceless#220 windows, off by default), and HostList::budget / indirect_scratch are main's, so fxceless#814's sub-allocated scratch and barrier skipping are not in. Everything else of fxceless#814 is: ray-tracing and wave32 translation, view addresses, SLOT_MEMORY dirty pages, gpu_copy_from_shadow, lazy physical pages, texture drop-mips, Series S overlay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xceless#814 + main fxceless#772 by sirrus98: arenas over title memory (VICTORY_INPLACE=3), residents in video memory with a GPU merge (VICTORY_INPLACE=4). Conflicts with fxceless#814: - shadow.rs loose(): fxceless#814's writable windows kept; with INPLACE>=3 windows go to their arena run (also for writable asks) and hot ones to residents. - memory.rs (SLOT_MEMORY directory): copies become Option, retarget to residents (fxceless#772) also renumbers fxceless#814's dirty pages; offsets take the bias of memory in place (entry_offset). - inplace.rs place_for: arenas at level >= 3 ahead of fxceless#814's late() guard. - xmem.rs: fxceless#814's lazy SEC_COMMIT chunks kept (already committed, so VICTORY_INPLACE_POOL is not needed); both section_gone hooks called. - host.rs: flights carry both memory_dirty and in_place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion test ignored (fxceless#772 refuses it) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…anch Conflicts: copystat/watch take main's new lines and keep is_write_watched (fxceless#814); lib.rs keeps both cardtime (fxceless#772) and cardmeter (main); VICTORY_CARD_REHASH_RUNS follows main (off by default, 1 or alt); the relay's parallel merge (fxceless#814) reports through main's copy_back(); present keeps fxceless#814's overlay plane and main's frame log (a present held behind a queue passes no overlay). descriptor/host.rs gets main's record_print, sync_tables and COPIED_TABLED, which its mirror_copied_page needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current main (a253706, 0b0074e) into the branch; conflicts in copystat, watch, lib and host resolved (main's VICTORY_CARD_REHASH_RUNS default, copy_back() and frame log taken; #814's overlay plane kept, but a present held behind a queue passes no overlay). descriptor/host.rs needed main's record_print, sync_tables and COPIED_TABLED. Workspace tests pass. Rerun in the game with the same switches and VICTORY_INPLACE=4: cell lit, 260 to 290 ms a frame, 0 draws dropped, no device loss. |
|
Tested this branch as published ( With both parts on ( Each part alone does not crash:
So the crash needs the resident/in-place memory and live ray tracing together, at least on an 8 GB card. It may be memory: the title's own null write often follows a failed allocation, and 8 GB with For reference, the same machine runs at ~188-220 ms/frame in steady play with the BVH off, using #917's (AI-assisted, Claude Code. No game data.) |
|
Tested 1. Shader / BVH pipeline check (
|
|
Tested Machine: RTX 3060 12 GB (driver 610.88, 32-lane), Ryzen 7 5700X, 16 GB RAM, system-managed pagefile (commit limit ~32 GB), Windows 11 26300, Series X profile, warm shader cache ( 1. The head does not build with diagnostics
The merge kept main's two reads of these counters but dropped their declarations, along with the 2. In the game (diag build, same scene: opening cutscene, measured from world +60 s)
So on this machine the limit is host commit, not VRAM. The card kept 3+ GB free in both runs, and the first failure is a 4 MB shared (system-memory) buffer. That fits npanu420's "needs both parts together" on 8 GB: ray tracing adds ~2.6 GB of host copies, and the in-place/resident part adds its own. I did not prove that the failed buffer is what the driver tripped on. The callers handle For reference, on the same machine Not tested: |
|
Follow-up, a correction of my comment above: host commit was a symptom, not the cause. I raised the pagefile to 32 GB (commit limit ~32 → 48 GB, same 16 GB of RAM) and reran the same
So the traversal reads memory from near-null pointers (0x10000 up), and the copies made for those reads are what fill memory, here as in the earlier run. That matches what #994 describes: dispatches by thread counts that over-run, and the builder then reading pointers out of garbage. #980 converts Same machine as above (RTX 3060 12 GB, Ryzen 7 5700X, 16 GB RAM, Windows 11 26300, Series X, diag build with the |
…marked copies are taken for written; 8,191 copies Port of fxceless PR fxceless#346 (c3db707, Gargalindis) onto the fork's directory: stores and atomics through title memory by address set a per-copy mark after the fault notes (MEMORY_MARKS); the host reads the marks once a frame, and a list that can store declares written only the copies marked in the last 8 frames, the copies its dispatches name and the copies numbered while it is recorded. Before, every list declared every numbered copy written: with the structure builder on, 3.9 GB of snapshots and compares a frame (run 3 at 266cd04, 584 ms/frame). fxceless measured 3.3 s -> 0.55 s a frame. VICTORY_MEMORY_MARKS=0 takes every copy for written, as before. The copy table grows from 4,095 to 8,191 (as fxceless fxceless#980): run 3 filled 4,095 a minute in, after which pages without a number read zeros (missing walls). The marks are clamped to the table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017V7WBCi8h4eymnRhdth77t
|
RTX 5070 12 GB (32-lane), Setup: RTX 5070 12 GB (driver 32.0.16.1742), Ryzen 7 7800X3D, 32 GB DDR5 + 64 GB page file, Windows 11 Pro 26300. Diag build of the head as published, plus Zayfway's two
Not tested: AI-assisted (Claude Code) |
|
Follow-up to my RTX 5070 report above: without The same build (
AI-assisted (Claude Code) |
|
Last one from me on this card: Series X without Same build, cache and save as my two comments above, All four launches on this card side by side. Each held 300 s with the builder running, with 0 exceptions, 0 device losses, 0 programs refused or untranslated, and 0 draws dropped:
Series X without in-place, by eye:
So on this card I'd separate two things: Not tested: more than one launch per cell; AI-assisted (Claude Code) |
What
Pull request #772 by @sirrus98 (title memory in place, hot memory kept in VRAM) merged on top of #905 (#814 live ray tracing on current
main). With ray tracing on, the processor-side copy of title memory was most of the frame; withVICTORY_INPLACE=4it drops by about a third.This branch contains #905's merge commit, so it should go in after #905 (or instead of both). All credit for the in-place and resident work is @sirrus98's, for the ray tracing @staronthehorizon's; this resolves the merge and measures it with ray tracing.
How the conflicts were resolved
shadow.rsloose(): Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814's version (writable windows, read-only windows in place) is kept. WithVICTORY_INPLACE>=3a window goes to its arena run first, as in GPU: stop copying game memory to the card and back every frame (opt-in): 75% less copy-back, half the buffer uploads #772, and writable asks take it too (the card writes the title's own bytes). Hot windows become residents (hot_window).retarget_tablesruns before both tables are read.memory.rs(SLOT_MEMORYdirectory): copies areOption, with GPU: stop copying game memory to the card and back every frame (opt-in): 75% less copy-back, half the buffer uploads #772'sretargetto residents; renumbering also moves Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814's dirty-page records to the new number. Directory offsets useentry_offset(the bias of memory in place), including the pages a new copy fills in.inplace.rsplace_for: the arena path (level 3 and up) comes before Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814'slate()guard, which stays for the older levels.placekeeps Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814'swritableargument; GPU: stop copying game memory to the card and back every frame (opt-in): 75% less copy-back, half the buffer uploads #772's callers passtrue.xmem.rs: Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814's lazySEC_COMMITchunks are kept. They are already committed sections, soVICTORY_INPLACE_POOLis not needed here. The section-gone hooks of both sides run (arena::title_memory_section_gonecalls the in-place census one).host.rs: flights carry both Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814'smemory_dirtyand GPU: stop copying game memory to the card and back every frame (opt-in): 75% less copy-back, half the buffer uploads #772'sin_place; the early-signal landing passes Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814's newrelay_card_backarguments.pipeline.rs/draw.rs:threadsand the store widths both kept; typed-store write-back by width plusmark_uav_dirty.warp_committed_section_places_read_only_and_writable_and_promotesopens a section by its handle, which GPU: stop copying game memory to the card and back every frame (opt-in): 75% less copy-back, half the buffer uploads #772 refuses on purpose (commit kept until restart on NVIDIA).VICTORY_ALLOW_SECTION_HEAPS=1still allows it.Testing
Hardware: RTX 3080 10 GB, driver 621.01, no Resizable BAR, i9-12900K, 32 GB RAM, Windows 11.
cargo build --release: clean (2 dead-code warnings, as before).cargo test --release --workspace -- --test-threads=1: everything passes exceptxtaskrepository_passes_policy, which flagsemit/lower.rsover 512 KiB (from Preliminary live ray tracing, Series S overlay/upscaler, and 8 GB VRAM stability #814) and a local build directory, nothing from this merge.--console series-s,VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=0 VICTORY_CARD_FETCH_INFLIGHT=1 VICTORY_TEXTURE_DROP_MIPS=1 VICTORY_TEXTURE_ROOM_PERCENT=82, same scene (the first cell):VICTORY_INPLACE=4Known
VICTORY_CARD_TIME).🤖 Generated with Claude Code