perf: reduce GPU submission, coherence, and loading overhead #38

Open
github-bot wants to merge 65 commits from github-bot/gh-38 into main AGit
Owner

@⁠vilaris on GitHub · 2026-11-27 12:20 UTC · original
vilaris:perf/radical-refactor → main · +20335 −2121 · 95 files · 65 commits · open

## Summary

This branch brings together performance work aimed at reducing GPU command submission overhead, improving coherence between title memory and GPU copies, and shortening texture and pipeline loading times. The branch history was rewritten to remove all Co-Authored-By trailers.

Main changes

GPU/CPU submission and coherence

  • Reduce contention while translating command lists with per-thread counters and shared reads, block-allocated host epochs, and partitioned locks.
  • Optimize copy refreshes by tracking dirty ranges with binary searches, 4 KiB parts, and clean-range caches; avoid repeated checks and redundant write-watch queries.
  • Track and reduce unnecessary coherence work, including sweeps that no longer drain all in-flight work, adjacent copy joining, and submission wait limits.
  • Keep constants in title memory when their pages can be read safely in place. Add raw and structured CBV view paths, 4-byte alignment where supported, and GPU-copy fallbacks when writes or in-flight data make direct reads unsafe.
  • Add counters for demand-paged fulfillment, faults, and fulfillment sources, plus optimizations for pages and dynamic streams.

Resource loading

  • Prioritize pipeline creation by first-use order and record creation and loading times.
  • Add a persistent catalog of recognized textures and a cache of converted BCPack/zlib results, with preloading tied to DirectStorage request completion.
  • Size processing slices and worker counts according to backlog and available memory.

Measurement and documentation

  • Add audit reports, baselines, experiment notes, and unified-memory architecture documentation under docs/performance.
  • Record existing measurements and proposed experiments to separate CPU, submission, and GPU costs. The reported measurements come from earlier sessions and do not validate every commit in this branch.

Validation

  • git diff --check passed for the local changes before they were committed.
  • The project was not compiled or run during this update. The branch reports mark several changes as uncompiled or unmeasured and describe the in-game/replay experiments needed.

Suggested review

  1. Build and run the applicable test/replay suite, including memory and shader comparisons.
  2. Repeat performance measurements with the same capture and configuration described in docs/performance.
  3. Pay particular attention to mapped-memory paths, write coherence, constants read while GPU work is in flight, and resource lifetimes.
**@⁠vilaris** on GitHub · 2026-11-27 12:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/38) `vilaris:perf/radical-refactor` → `main` · +20335 −2121 · 95 files · 65 commits · open ## Summary This branch brings together performance work aimed at reducing GPU command submission overhead, improving coherence between title memory and GPU copies, and shortening texture and pipeline loading times. The branch history was rewritten to remove all `Co-Authored-By` trailers. ## Main changes ### GPU/CPU submission and coherence - Reduce contention while translating command lists with per-thread counters and shared reads, block-allocated host epochs, and partitioned locks. - Optimize copy refreshes by tracking dirty ranges with binary searches, 4 KiB parts, and clean-range caches; avoid repeated checks and redundant write-watch queries. - Track and reduce unnecessary coherence work, including sweeps that no longer drain all in-flight work, adjacent copy joining, and submission wait limits. - Keep constants in title memory when their pages can be read safely in place. Add raw and structured CBV view paths, 4-byte alignment where supported, and GPU-copy fallbacks when writes or in-flight data make direct reads unsafe. - Add counters for demand-paged fulfillment, faults, and fulfillment sources, plus optimizations for pages and dynamic streams. ### Resource loading - Prioritize pipeline creation by first-use order and record creation and loading times. - Add a persistent catalog of recognized textures and a cache of converted BCPack/zlib results, with preloading tied to DirectStorage request completion. - Size processing slices and worker counts according to backlog and available memory. ### Measurement and documentation - Add audit reports, baselines, experiment notes, and unified-memory architecture documentation under `docs/performance`. - Record existing measurements and proposed experiments to separate CPU, submission, and GPU costs. The reported measurements come from earlier sessions and do not validate every commit in this branch. ## Validation - `git diff --check` passed for the local changes before they were committed. - The project was not compiled or run during this update. The branch reports mark several changes as uncompiled or unmeasured and describe the in-game/replay experiments needed. ## Suggested review 1. Build and run the applicable test/replay suite, including memory and shader comparisons. 2. Repeat performance measurements with the same capture and configuration described in `docs/performance`. 3. Pay particular attention to mapped-memory paths, write coherence, constants read while GPU work is in flight, and resource lifetimes.
play.rs forced VICTORY_TEXTURE_CATCHUP=0 and a 16 ms slice per frame; with
100-300 ms frames the due-slot backlog (up to ~26k slots) drained over ~3 min
(agent report 05). Catch-up is now on, with a 200 ms slice
(VICTORY_TEXTURE_BACKLOG_MS) only while >=1024 slots are due.
Unmeasured in-game: needs a run, compare time from pack open to queue < 500.
The title's 174 MB heap is declared written as a whole (root views have no
size) so its 480-byte constants ring waited for every flight once a frame:
43-59 ms of 70-84 ms frames (report 06, measured). The existing guarded
mechanism is now default; VICTORY_FILL_TITLE=0 disables it. Residual risk
(documented in fill_is_titles): a constant a flight's shader really writes
in a block the title also wrote. Not yet validated in-game.
Measurement only (report 03, E2/E4/E5), logged beside the existing
descriptor lines: rounds run and empty rounds, asks of the write watch
split by whether they found pages, ring pages (over 90% of changed
records are draws' tables) with bytes read, and CreateShaderResourceView
count/time for buffer views and raw twins (VICTORY_DESCRIPTOR_TIMING=0
counts without timing). No behaviour change.
Records the new counters and why ring-page skipping, submission gating and
coalesced write-watch asks were not done in this scope (need draw.rs,
watch.rs or the picked bitmap).
Record first-use order and per-pipeline make ms in pipeline-order.txt
(early/slow files keep their formats), queue early pipelines by that
order, raise worker priority and lift the slow cap while 32+ pipelines
wait, and log count/p50/p90/p99/total of made, loaded and static-sampler
pipelines in release builds.
# Conflicts:
#	docs/performance/EXPERIMENTS.md
The periodic sweep (every 1.5 s) forced a full settle of the flights
first. What it lets go of goes through retire(), which holds it until
every submission started so far has finished (submission numbers act as
fence values), and what a list names has a count above one while the list
is in a flight. So the drain is only kept for VICTORY_SWEEP_SETTLE=1 and
the up-check. Unmeasured in game.
Distinct 64 KiB blocks per host copy that shaders wrote (landed bytes), that
the title's CPU changed afterwards, and that the title wrote while pending
(merge_under_writes). Logged every ~10 s with the frame lines;
VICTORY_FOOTPRINT=0 disables. No behaviour change.
ask_rest walked the submission's ranges in refresh order and asked each one
the standing asking did not already hold, so a small range followed by the
big one containing it cost two kernel calls. Sorted by start, widest first,
the contained one is answered by the first. The set of pages found and the
journal are unchanged. Per-frame (rather than per-submission) asking is not
done: a title write between two submissions would be seen a frame late.
The reads of title memory into the buffer between, and the writes out of
it, are recorded as one CopyBufferRegion each. Runs that touch in both
buffers (and, for reads, are separated by the same under-256-byte padding
in source and between) now go in one command. VICTORY_JOIN_STEPS=0 gives
one command each, as before. No gather kernel: see EXPERIMENTS.md.
Unmeasured in game.
# Conflicts:
#	docs/performance/EXPERIMENTS.md
# Conflicts:
#	docs/performance/EXPERIMENTS.md
Experimental code: constants instead of VICTORY_TIGHT_WRITES/VERIFY and
VICTORY_TEXTURE_BACKLOG_MS.
- texture/ledger.rs: each finished DirectStorage request is told to the book
  (dstorage.rs `landed`); if the texture at its destination is known (a view
  named it earlier this run, or the on-disk book linked this request to a
  named, kept texture), a background thread makes the host texture and sends
  the detile+upload to the copy queue (texture/ahead.rs), so the pass adopts
  the slot with no upload. Book saved in <cache>/textures/book.bin (request
  keys -> resource words; only named and kept, evicted dropped, aged out).
- Loading gate from the request stream (+ .rpf opens, < 200 draws/frame):
  4x pass bytes, >= 120 ms slice, more upload bytes in flight.
- texture/converted.rs: write-through cache of decoded BCPack/zlib outputs
  keyed by request (file, offset, sizes, options) with a source digest; hits
  skip decode. 24 GiB LRU cap, in the cache dir only.
- Budgets: 32 GB machines no longer limited for textures; in-flight uploads
  sized from free RAM (up to 6 GiB); ahead workers cores/4; VRAM line as code
  constants (88/90 % with frame generation), launcher switch removed.
- Rechecks of uploaded textures counted in time as well as frames.

Uncompiled, unmeasured. See docs/performance/EXPERIMENTS.md.
# Conflicts:
#	docs/performance/EXPERIMENTS.md
The fills behind a copy at its place read its destination on the CPU, where the
copy is not while flights may write its bytes, so the submission waited for them
(READ_PLACED, 18.6 ms/frame in a chase). Such constants are now copied at their
place in the list out of the host copy into a buffer of ours, and the root view
or descriptor slot points there.
- watch: the submission's asked ranges are kept sorted and joined and looked up
  by halves in writes/asked/nothing_new/ask_rest (was a linear walk per question,
  thousands of ranges x 12,800 refresh spans a frame in the chase).
- shadow: pages a refresh or a merge under shader writes holds in part note each
  4 KiB part taken (parts_taken); stale_runs/stamp_taken decide and note per part,
  so pages beside declared ranges and at range ends are no longer taken again at
  every refresh once the title wrote any of them. nothing_new and stale_pages_in
  read the part notes too.
- release line: what refreshes took (never taken / taken again / mid-page ends)
  and the asked-range questions.

Not compiled or run (by instruction).
# Conflicts:
#	docs/performance/EXPERIMENTS.md
The chase scene's list calls cost 11.5 us each (70,418 in 813 ms of thread
time a frame) against 3.5-5.3 us with fewer threads busy: contention. Per
draw or look-up every translating thread wrote the same few lines:

- draw counters DRAWS/DISPATCHES (list.rs) and DRAWN/DROPPED/DISPATCHED
  (draw.rs): one place per thread (sharded::Counter), summed when read;
- the table of views' RwLock (descriptor.rs VIEWS), read per table entry
  of every draw: a reader takes its own thread's lock only, a writer all
  (sharded::ReadMostly); forget() of a resource without entries no longer
  takes the writer's lock;
- HostList epochs (host.rs next_epoch): per-thread blocks of unique
  numbers (only compared for equality);
- pipeline bound flag (pipeline.rs): load before the swap;
- tight.rs footprint state: 16 locks by key and 16 by copy, never two
  held at once.

Same counts, same exclusion, no switch. Not compiled, not measured.
# Conflicts:
#	docs/performance/EXPERIMENTS.md
Two homes per title buffer: title memory in place (port region) for
constants no shader writes, the card copy for everything else; a per-page
oracle (pages ever landed, pages bound to GPU writes at record time)
decides per access.
Renderer port 1 no longer turns whole title buffers into title memory in
place (measured slower: the 174 MB heap is mostly geometry the card reads
by the hundred MB, and skinning writes all of it through one view). The
32-bit graphics heap's stretch is opened once as a heap through a view of
ours with one buffer over all of it, and port::constants resolves a
constant buffer view to it when no shader writes any of its pages (pages
ever landed, or bound for a write on the card at record time). Every other
access keeps the card copy.

Removed: VICTORY_PORT_CONSTANTS (gpu and xmem), port::on/wanted/place_for,
the port branches in shadow lookup and windows, inplace::counted, the menu
item. xmem's arrange always runs for the 32-bit reservation.
Root CBVs and table CBVs ask crate::port::constants first: a 256-aligned
view in the title's graphics heap whose pages no shader writes is bound to
the title's own bytes (the list and the slot hold the region's buffer).
For those there is no 64 KiB refresh of the card copy per root CBV, no
scratch, no fill step, no card-step fill and no read-wait. Writes on the
card bound for title memory (copies at their place, read-backs) mark
their pages at record time so they are never read in place again.

VICTORY_FILL_TITLE is gone; its predicate (on by default) is the code.
The launcher's VICTORY_WC_NO_BACK=1 / _MIN_KB=1024 become the code: copies
of 1 MiB and more of write-combined title memory are the 'written by the
card, never read by the CPU' class, whose home is the card. Switches,
launcher lines (play.rs, play-foxhound.ps1) and the menu item removed.
With card_steps stage 2 (the launcher's) a title buffer copy into the ring
is done on the card copy and lands after the flight, so a constant view
bound in place behind it would read the old bytes. Every recorded title
copy (defer_copy, copies at their place) now stamps its pages for 8 frames;
read-backs mark theirs for good; landings count for 600 frames (the window
the shipped fill_is_titles default uses), so ring pages a copy wrote come
back to the title-memory home while skinning outputs never do.
The port opened (185 MB) but 6,185 of 6,556 constant views a frame were
"not 256-aligned" and 6,149 fills still ran on the CPU (14 fps, the
submitting thread busy 71 of 71.7 ms). The 256-byte rule is D3D12's for
CBVs; the title's constants lie on 16.

- victory-shader: every constant buffer load goes through
  Lower::constant_view/constant_dword: root ones as raw loads through a
  raw root SRV t<slot> (Shader::root_constants_handle, zeros past 64 KiB
  by the code), tables' and picked ones through the raw twin of their
  slot (sized like the CBV: zeros past it); the CBV only without raw
  twins. HostShader::root_cbvs are raw SRVs in the metadata. Changes the
  translator hash (one cold retranslation).
- pipeline/host.rs: root constant buffers are SRV root descriptors.
- draw.rs: root_view asks port::constants with 4-byte alignment and binds
  the host copy at any 4-byte address on fallback; tables ask with
  HostHeap::constant_align (16 with twins); roots set as SRVs.
- descriptor/host.rs: constant_at makes the CBV only on 256 (else null)
  and the twin as a raw view via raw_view_range; make_twinned's twin of a
  CBV slot is a raw view (was a CBV).
- port.rs: constants() takes the alignment the binding view needs.
- docs: EXPERIMENTS entry, UNIFIED_MEMORY_ARCHITECTURE section 10.

Not compiled or run (the user compiles).
# Conflicts:
#	crates/victory-gpu/src/descriptor/host.rs
#	crates/victory-gpu/src/port.rs
The first raw-constants version read tables' constants through the slots'
raw twins. NVIDIA caps view heaps at 1,000,000 descriptors and the twins
(2 x 2^21) never fit ("raw_twins=false" in play-20261127-114321-28084), so
constant_align() asked for 256 bytes: ~108 views in place a frame,
2,841-4,075 not, 2,574-3,669 fills, 13.8 fps.

- descriptor/host.rs: a constant buffer's slot (constant_at, the mirror's
  make_twinned, null_constant_at, null_for) is a structured view
  (DXGI_FORMAT_UNKNOWN, stride 4) of the CBV's bytes (constant_views):
  it begins at the title's own dword, so no twin and no residual offset
  are needed; the raw twin is still made where twins exist (picked reads).
- victory-shader lower.rs: constants loaded through tables are read as
  element byte/4 of that structured view (props 12, stride 4); picked ones
  read the raw twin where twins exist, else the same view. Translator hash
  changes again. Test harness makes table CBVs structured views.
- port.rs: one alignment (ALIGN = 4) for every binder; constants() takes
  Use::{Root, Table, Mirror}; the log splits not-in-place off 4 bytes and
  in-place counts by binder.
- draw.rs: tables ask with Use::Table; null constant slots are null
  structured views.
- docs: EXPERIMENTS revision entry, UNIFIED_MEMORY_ARCHITECTURE section 10.

Not compiled or run (the user compiles).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 12:24:16 +00:00
github-bot force-pushed github-bot/gh-38 from 03a6c1ff3a to bd7351c8ae 2026-11-27 12:33:20 +00:00 Compare
github-bot force-pushed github-bot/gh-38 from 9bf8f2d6fc to 3013ab8d16 2026-11-27 13:16:27 +00:00 Compare
Author
Owner

@⁠exotiquee on GitHub · 2026-11-27 16:15 UTC · original

A note on the write-watch asking this PR reworks (kernel_written / kernel_written_into in watch.rs). It is a problem that already exists on main, not something this branch introduces.

In watch.rs, ASKING holds back an asking only when another asking covers overlapping pages (Asking::hold). So two threads can call GetWriteWatch(WRITE_WATCH_FLAG_RESET) at the same time over disjoint ranges of the same reservation. A submission's refreshes run on several threads, so this can happen.

We found that two concurrent GetWriteWatch(RESET) calls over one reservation can make one of them miss a page written before it began, even when their ranges are disjoint. The next asking reports the page, so the write is not lost for good. It is picked up one asking late, which can mean one submission late. This is consistent with the kernel gathering and resetting write-watch state for more than the asked range.

Stress test: title-writer threads, a submitting thread asking, and one more asker over a disjoint sub-range of the same reservation, repeated for about 1.5 s. Results:

  • Concurrent askings: 744 of 16,342 checked writes were reported late.
  • Every write-watch kernel call (GetWriteWatch and ResetWriteWatch) serialized behind one process-wide lock, taken after the journal lock wherever that is held: 763 of 17,168 were still late. A second, separate gap was also involved in our tree (a standing asking that didn't wait for an asking already in flight). With both fixed: 0 of 16,801.

Suggested fix: serialize the write-watch kernel calls per reservation, or with one global lock as we did. Across all threads the calls add up to only 3-8 ms per frame, so the lock costs little. A per-reservation lock would need the reservation bounds, which costs a system call per asking unless they are cached.

**@⁠exotiquee** on GitHub · 2026-11-27 16:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/38#issuecomment-7223047866) A note on the write-watch asking this PR reworks (`kernel_written` / `kernel_written_into` in `watch.rs`). It is a problem that already exists on `main`, not something this branch introduces. In `watch.rs`, `ASKING` holds back an asking only when another asking covers **overlapping** pages (`Asking::hold`). So two threads can call `GetWriteWatch(WRITE_WATCH_FLAG_RESET)` at the same time over disjoint ranges of the same reservation. A submission's refreshes run on several threads, so this can happen. We found that two concurrent `GetWriteWatch(RESET)` calls over one reservation can make one of them **miss a page written before it began**, even when their ranges are disjoint. The next asking reports the page, so the write is not lost for good. It is picked up one asking late, which can mean one submission late. This is consistent with the kernel gathering and resetting write-watch state for more than the asked range. Stress test: title-writer threads, a submitting thread asking, and one more asker over a disjoint sub-range of the same reservation, repeated for about 1.5 s. Results: - Concurrent askings: **744 of 16,342** checked writes were reported late. - Every write-watch kernel call (`GetWriteWatch` and `ResetWriteWatch`) serialized behind one process-wide lock, taken after the journal lock wherever that is held: 763 of 17,168 were still late. A second, separate gap was also involved in our tree (a standing asking that didn't wait for an asking already in flight). With both fixed: **0 of 16,801**. Suggested fix: serialize the write-watch kernel calls per reservation, or with one global lock as we did. Across all threads the calls add up to only 3-8 ms per frame, so the lock costs little. A per-reservation lock would need the reservation bounds, which costs a system call per asking unless they are cached.
github-bot force-pushed github-bot/gh-38 from 3013ab8d16 to 143781e60b 2026-11-27 17:42:23 +00:00 Compare
Author
Owner

@⁠vilaris on GitHub · 2026-11-27 17:39 UTC · original

A note on the write-watch asking this PR reworks (kernel_written / kernel_written_into in watch.rs). It is a problem that already exists on main, not something this branch introduces.

In watch.rs, ASKING holds back an asking only when another asking covers overlapping pages (Asking::hold). So two threads can call GetWriteWatch(WRITE_WATCH_FLAG_RESET) at the same time over disjoint ranges of the same reservation. A submission's refreshes run on several threads, so this can happen.

We found that two concurrent GetWriteWatch(RESET) calls over one reservation can make one of them miss a page written before it began, even when their ranges are disjoint. The next asking reports the page, so the write is not lost for good. It is picked up one asking late, which can mean one submission late. This is consistent with the kernel gathering and resetting write-watch state for more than the asked range.

Stress test: title-writer threads, a submitting thread asking, and one more asker over a disjoint sub-range of the same reservation, repeated for about 1.5 s. Results:

  • Concurrent askings: 744 of 16,342 checked writes were reported late.
  • Every write-watch kernel call (GetWriteWatch and ResetWriteWatch) serialized behind one process-wide lock, taken after the journal lock wherever that is held: 763 of 17,168 were still late. A second, separate gap was also involved in our tree (a standing asking that didn't wait for an asking already in flight). With both fixed: 0 of 16,801.

Suggested fix: serialize the write-watch kernel calls per reservation, or with one global lock as we did. Across all threads the calls add up to only 3-8 ms per frame, so the lock costs little. A per-reservation lock would need the reservation bounds, which costs a system call per asking unless they are cached.

Fixed

**@⁠vilaris** on GitHub · 2026-11-27 17:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/38#issuecomment-7224653151) > A note on the write-watch asking this PR reworks (`kernel_written` / `kernel_written_into` in `watch.rs`). It is a problem that already exists on `main`, not something this branch introduces. > > In `watch.rs`, `ASKING` holds back an asking only when another asking covers **overlapping** pages (`Asking::hold`). So two threads can call `GetWriteWatch(WRITE_WATCH_FLAG_RESET)` at the same time over disjoint ranges of the same reservation. A submission's refreshes run on several threads, so this can happen. > > We found that two concurrent `GetWriteWatch(RESET)` calls over one reservation can make one of them **miss a page written before it began**, even when their ranges are disjoint. The next asking reports the page, so the write is not lost for good. It is picked up one asking late, which can mean one submission late. This is consistent with the kernel gathering and resetting write-watch state for more than the asked range. > > Stress test: title-writer threads, a submitting thread asking, and one more asker over a disjoint sub-range of the same reservation, repeated for about 1.5 s. Results: > > * Concurrent askings: **744 of 16,342** checked writes were reported late. > * Every write-watch kernel call (`GetWriteWatch` and `ResetWriteWatch`) serialized behind one process-wide lock, taken after the journal lock wherever that is held: 763 of 17,168 were still late. A second, separate gap was also involved in our tree (a standing asking that didn't wait for an asking already in flight). With both fixed: **0 of 16,801**. > > Suggested fix: serialize the write-watch kernel calls per reservation, or with one global lock as we did. Across all threads the calls add up to only 3-8 ms per frame, so the lock costs little. A per-reservation lock would need the reservation bounds, which costs a system call per asking unless they are cached. Fixed
Replace the ring-search allocator for dynamic descriptor slots with a
range allocator whose ranges are owned by a recording and retired by
the submission fence.

- Add descriptor/host/dynamic.rs: free ranges indexed by start and by
  size, best-fit allocation, coalescing of neighbours on release.
- Recordings keep their ranges per host heap. Dropping them returns the
  slots, and submitting hands them to the heap with the fence value.
- Reclaim completed ranges on allocation, before readbacks and when
  merging, so reuse no longer depends on list reset or CPU readback.
- When a heap is short, poll the host fence for up to 250 ms instead of
  settling all in-flight submissions and recycling every landed list.
- Remove the host heap id and release path, and the FenceDrain reasons
  that only existed to free dynamic slots.
- Log dynamic descriptor pressure per frame and add a render trace
  event.
- Add a reserve_dynamic for permanent views so the memory table is not
  tied to a list's lifetime.
- Move the retired-fence queue out of the slot allocator's state mutex,
  so publishing a fence at submit no longer blocks on allocator
  operations. Reclaim takes the queue lock only while draining a batch.
- Translate recordings that were already submitted before speculative
  ones, since the latter hold descriptor slots and delay reuse.
- Release a dropped thin recording's list state so its descriptor
  tables are returned.
- With a standing write-watch answer, check known-clean shadow spans on
  the worker jobs instead of walking them on the submitter first.
- Add tests for lock-free fence publishing and submission-order
  priority.
- Plan front refresh spans and texture uploads in one pass.
- Send large contiguous runs directly and reduce shared-lock work.
- Reclaim completed slot ranges in batches while preserving availability.
- Reuse nested title buffers safely and report direct versus staged bytes.
Every save serialises the whole host pipeline library (over a gigabyte once
warm) and holds off every store while it does. Two cases made that a hitch:

- In a burst of new pipelines (a new area, a cutscene) a worker saved it
  every 20 s, exactly while the title waited on those pipelines and the
  write competed with texture streaming for the disk. Saves in a burst now
  come at most every 180 s (VICTORY_LIBRARY_SAVE_BUSY_S; 20 as before).
- Under host memory pressure the serialised library is written through the
  PC's memory and pushes the title's own pages out. On an RTX 4080 with
  32 GB the layer ran pressured for a whole session (commit headroom
  3.4 GB) and the title's threads stalled; the periodic save now waits
  600 s while pressured.

The save when the queue runs dry and the save at exit are unchanged, so
nothing made is lost unless the process ends without one.

Measured: release build, victory-gpu lib tests 414 passed; the two
indirect::tests failures are the same on main (fixed by #67).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit a162ae7f9f)
put_changed(), which writes what shaders wrote back into title memory, also computed its
runs with the scalar dword_runs(.., 0) although word_runs() is that same call with the
AVX2 implementation when it can. Same fallback, same runs, wider instruction. The
copy-back path is the one measured at 34.8 -> 17.2 ms by WC_NO_BACK, so it is worth the
wide compare too.

Tests: 423 passed, 2 failed - the two pre-existing upstream ones. Build clean.
(cherry picked from commit 260e446162)
The flat VICTORY_CARD_ROOM_FOR_TARGETS_MB (3,072 MiB) is given back only once
the targets hold half of it, which the targets of a 720p world never do. On an
8 GB RTX 4060 Laptop the SeriesS profile's targets held 390 MB, so 2,675 MB
stayed reserved for them the whole run: the texture queue weighed 6,182 MB
against a line of 6,181 MB with the card 41 % used and refused new textures,
and the skin textures of passers-by and the coffee shop's waitress were never
uploaded (black faces, the phone's screen empty).

Half as much again as the peak they have held (at least 256 MiB, never more
than the switch's amount) is kept instead: 195 MB for the same run, and a
1440p world's peak of 2.9 GB still gets what it had. The switch keeps the old
flat rule when it is set.

(cherry picked from commit 05a269d863)
XMemAllocatePhysicalPages makes one pagefile-backed section per request
(6.1 GiB at once for the title), which it then maps a 64 KiB view at a
time. Windows' large-page rebuild worker walks a section's views under
the section's lock, so every map and unmap of the title's pages waits
behind it while the camera turns. VICTORY_SECTION_MB=<n> backs a request
with sections of at most n MiB (2 measured); unset, 0 or not a number
keeps one section per request: same calls, same numbers.

- xmem/section_mb.rs (new): the switch, and allocate_physical(n, per),
  which makes the sections, reports each to the GPU side and numbers the
  pages as one request. Each section keeps its own window and is closed
  (title_memory_section_gone) when its last page goes, as before.
- xmem.rs: XMemAllocatePhysicalPages calls it; nothing else changes. A
  mapping or a write already ends a run at a section's end; DirectStorage
  destinations over a bound get no window and go through write_physical.
- inplace.rs: sections and our whole views of them by handle in maps, not
  vectors scanned per lookup; census lines group alike sections (one of a
  kind reads as before, lines now in size order).

Not combined with VICTORY_PORT_CONSTANTS=1: renderer port 1 needs the
32-bit heap in one section; with the switch set, arrange() logs that the
pages are not of one section and leaves them, so the heap stays on the
copy path.

Tests: the switch's values; 33 pages whole vs 32+1 (numbering, window and
write over the bound, one call mapping two views); 70 pages in 32/32/6
with every section closed after free; five pages in sections of two
mapped, written, partly unmapped and page-mapping-copied over the bounds;
the title call stays one section by default.

Port of voidopcode/vilocity 0f44a1706; the finding and the cure are
RyanCase94's and CuteBooty's (fxceless's fork, issue #1089, PR #1274).
Tests after KainanP (Skyfrye/anyXboxx-diffbase ee8b92e14) and Xeltax
(Xeltax/VIcky a8c223149). AI-assisted.

(cherry picked from commit 6db4a58caa)
physical_remap_bench maps a 4 GiB request a page at a time, then remaps
random single pages for 10 s while another thread makes, touches and
frees 2 GiB, for one section against 2 MiB sections (3 rounds). Test
code only: victory.exe is unchanged.

Adapted from KainanP's bench (Skyfrye/anyXboxx-diffbase ee8b92e14).
AI-assisted.

(cherry picked from commit 401adb9e7c)
The submitting thread, the frame's critical path, spent ~15 % of its samples
in the process heap (ntdll under realloc/alloc: vectors growing in
Host::submit, word_runs_avx2, merge_under_writes, watch::writes). That heap is
shared with the title and the drivers. With the `mimalloc` feature the Rust
side allocates through mimalloc instead (diagnostics builds keep counting
every block in copystat's allocator, which then forwards to mimalloc).

RTX 4090, Ryzen 9 7950X3D, Series S, half scale, play-nvidia.ps1 defaults,
same unattended route (tools/rtx4090/bench.ps1), jail scene, last 2 minutes:
  process heap: 24.7 fps (min 23.8), preparing 30.1 ms a frame
  mimalloc:     26.9 fps (min 26.0), preparing 26.9 ms a frame
No change in the picture.

(cherry picked from commit c6efc449be)
Classify UAV allocations by purpose so residency samples can identify their
usage, and expose enqueue and paging-fence timing. Gate the new residency path
behind `VICTORY_UAV_ENQUEUE_RESIDENT=1`, keeping existing allocation behavior
when it is disabled or unsupported.
This pull request has changes conflicting with the target branch.
  • apps/victory/src/play.rs
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/host/menu.rs
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/pipeline.rs
  • crates/victory-gpu/src/pipeline/make.rs
  • crates/victory-gpu/src/pipeline/samplers.rs
  • crates/victory-gpu/src/port.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-hle/src/modules/dstorage.rs
  • crates/victory-hle/src/modules/xmem.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/38/head:github-bot/gh-38'
git switch 'github-bot/gh-38'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-38'
git switch 'github-bot/gh-38'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-38'
git switch 'github-bot/gh-38'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-38'
git switch 'main'
git merge --squash 'github-bot/gh-38'
git switch 'main'
git merge --ff-only 'github-bot/gh-38'
git switch 'main'
git merge 'github-bot/gh-38'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.