Upload fills: stop false trips of the fill-ahead latch; quiet depth U… #860

Open
github-bot wants to merge 32 commits from github-bot/gh-860 into main AGit
Owner

@⁠turbinedogbla-creator on GitHub · 2026-11-25 10:58 UTC · original
turbinedogbla-creator:claude/startup-perf-fixes → main · +1943 −145 · 17 files · 32 commits · open

…AV log

fill_ahead compared a landing's shader bytes with title memory as it is now, so a title rewrite after the fill counted as a miss and made every fill wait for the rest of the run (about 100 ms a frame on the submitting thread). Fills now keep a fingerprint of the bytes they read; a fill whose bytes the title rewrote since is not compared. A real miss holds back only the 64 KiB pieces it touched; past 8 such pieces every fill waits as before. Adds a unit test (Windows) for the three cases.

The "unordered access view of a depth texture" line is logged once per view instead of on every creation (up to 512 lines, a few a frame), and drops the four record words past the texture part of the union, which are uninitialised title stack bytes.

Fix the doc of VICTORY_CARD_ROOM_FOR_BUFFERS: it is on by default.

Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX

**@⁠turbinedogbla-creator** on GitHub · 2026-11-25 10:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/860) `turbinedogbla-creator:claude/startup-perf-fixes` → `main` · +1943 −145 · 17 files · 32 commits · open …AV log fill_ahead compared a landing's shader bytes with title memory as it is now, so a title rewrite after the fill counted as a miss and made every fill wait for the rest of the run (about 100 ms a frame on the submitting thread). Fills now keep a fingerprint of the bytes they read; a fill whose bytes the title rewrote since is not compared. A real miss holds back only the 64 KiB pieces it touched; past 8 such pieces every fill waits as before. Adds a unit test (Windows) for the three cases. The "unordered access view of a depth texture" line is logged once per view instead of on every creation (up to 512 lines, a few a frame), and drops the four record words past the texture part of the union, which are uninitialised title stack bytes. Fix the doc of VICTORY_CARD_ROOM_FOR_BUFFERS: it is on by default. Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
fill_ahead compared a landing's shader bytes with title memory as it is
now, so a title rewrite after the fill counted as a miss and made every
fill wait for the rest of the run (about 100 ms a frame on the submitting
thread). Fills now keep a fingerprint of the bytes they read; a fill whose
bytes the title rewrote since is not compared. A real miss holds back only
the 64 KiB pieces it touched; past 8 such pieces every fill waits as before.
Adds a unit test (Windows) for the three cases.

The "unordered access view of a depth texture" line is logged once per
view instead of on every creation (up to 512 lines, a few a frame), and
drops the four record words past the texture part of the union, which are
uninitialised title stack bytes.

Fix the doc of VICTORY_CARD_ROOM_FOR_BUFFERS: it is on by default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
The reasons draws and dispatches go without a host pipeline (the shader
hash that does not translate, or the pipeline the host refused) were only
counted in diagnostics builds; a release build said "dropped N" and
nothing more. They are counted in every build now and the ten that cost
the most draws are printed every five seconds ("dropped X/frame without a
host pipeline: <stage> <hash>"), forty with diagnostics.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
VICTORY_QUEUE2 bit 1 (the down lane) is on unless VICTORY_QUEUE2=0. On an
RTX 4070 with the relay the frame line's "copying back" went from 121-136
ms to 41.5 ms a frame and the copy-back thread's wait for fetches from
about 121 ms to 7; the frame from 180-192 ms to 174.5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
VICTORY_INDIRECT_WINDOW is on unless set to anything but 1, and stays off
by default with VICTORY_CARD_FETCH_INFLIGHT=1 (the one device loss after
the window fix had both). A 10.5-minute run on an RTX 4070 had no device
loss; the card's time for the title's lists went from about 85 to 37-43
ms a frame and the frame from about 174 to 144-154 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
# Conflicts:
#	crates/victory-gpu/src/draw.rs
VICTORY_WIDE_REFRESH is on unless =0. RTX 4070 / i7-14700KF: "copies"
54-56 -> 45-47 ms a frame, frame 144-154 -> 131-139 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
VICTORY_TEXTURE_NO_WAIT is on unless =0. RTX 4070 run: 327 one-second
frame lines with refreshes waiting for the remap lock (nearly all while
the world loads) without it, none with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
The flights are settled about once a frame for "title memory changed
under shader writes" (30-50 ms of the submitting thread), with 0 changed
runs merged: the run cap is not the reason. The frame line's merge line
now counts each reason merge_under_writes gives up for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
A/B on an RTX 4070: with the cap at 512 the flights were settled once a
frame over the cap and the picture had many more black textures and
overblown light than at 4,096; the frame rate was the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
When the title's changed runs under flights' shader writes exceed
VICTORY_MERGE_RUNS (gameplay: 100,000+ runs of a few bytes a frame,
over 4,096 in one submission), the flights were settled, about once a
frame, 30-50 ms of the submitting thread, and the bytes waited for it
(black textures, overblown light). Now such a page's runs become a mask
(one bit per byte, shadow::Masked): the CPU side takes the title's bytes
as before, and before the next submission CARD_MASK, one compute pass
per page, writes exactly the masked bytes into the card side and leaves
every other byte (what shaders wrote) as the card holds it. The pages
are hashed again with the ranges sent up. With the relay, a page's
masked bytes count as sent (Card::masked_sent), so the copy-back takes
the card's other bytes there as shader writes as usual.

VICTORY_CARD_MASK=0 settles as before. Without the pipeline or the mask
buffer, the masked runs go up one copy each. Tests: the mask round-trips
the changed runs; the shader on WARP takes exactly the masked bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Pieces of 64 KiB fetched from card copies and merged by the relay, per
frame: how many, how many differ at all, the bytes between their first
and last difference, and the bytes that differ. Says whether smaller
pieces would fetch much less.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
The relay's landings merged their card pieces one after the other (some
1,250 pieces of 64 KiB a frame, 96 % with bytes shaders wrote, 45-60 ms
a frame on the landing thread), and every merge of a copy took the
copy's one lock. A merge under flights and a copy-back merge now take
the locks of their own 64 KiB blocks of title memory
(shadow::side_locks), and VICTORY_WIDE_MERGE, now on by default (=0:
as before), spreads the landing's pieces over the wide threads too.
The copy-back counter no longer scans each piece for the bytes that
differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
# Conflicts:
#	crates/victory-gpu/src/host.rs
A single real miss (one in a whole run) held its 64 KiB back for good,
and a title buffer copy reading it settled the flights about every
other frame ("title memory read, by a buffer copy" 0.4-0.5 a frame).
A miss now holds the piece back for 60 frames, twice as long at each
miss of the same piece after; past 8 pieces held at once every fill
waits, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
VICTORY_BACK_OWN_VIEW, VICTORY_JOIN_PARTS and VICTORY_INDIRECT_GATHER
(fxceless/victory-fork) are on unless =0. RTX 4070 / Ryzen 5 7500F, the
three together: 125-127 ms a frame against 134-137 without.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Off by default. With N, one 4 KiB page in N of each stretch the relay's
copy-back writes into title memory gets PAGE_GUARD on top of its
protection; a vectored handler counts the CPU's first read or write of
it and lets the access go on (the system clears the bit). Our own kernel
reads and writes (ReadProcessMemory, NtWriteVirtualMemory) that meet a
marked page take the marks off the range, count it as ours and go again.
The frame line says per frame: pages marked, first touched by a CPU read,
a CPU write, our own access, and how many are still marked. Measures
whether a copy-back that merges only what the CPU reads would pay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Off by default; with it nothing is skipped or protected. Every piece the
relay's copy-back fetches is noted per 64 KiB page of title memory, and
our own reads and writes of title memory through the kernel (read_into,
copy_mapped, write_mapped) count as touches, except the copy-back's own
merge (lazyback::merging). A page fetched again and untouched for 60
frames is a card-only candidate. The frame line says how many fetched
pieces lie wholly on candidates (what step 2 would not merge) and how
often a candidate was touched (what step 2 would materialize).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Off by default. A page the copy-back fetched and nothing on the CPU's
side touched for 60 frames becomes card-only right after a normal merge:
every title view of it (crate::inplace::pages_of) is made PAGE_NOACCESS
once and the guards let it go (watch::release; they leave card-only
blocks alone from then on). Later landings keep the piece's fetched
bytes instead of merging them. The page is given back on a touch: an
access violation on it (a vectored handler), our own kernel read or
write (read_into, copy_mapped, write_mapped), or a kernel write on the
title's behalf (watch::writing). The kept bytes go into the CPU side and
title memory through our own view while the title views are still kept
from the CPU, then the views get their protection back (read-write where
the guards had it read-only). A fault on a page being given back waits
for it. Only view memory with an own view, every view of a page or none.

Not handled: a kernel read of title memory on the title's behalf (a
file write from a card-only page) fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Each view's protection is checked before anything changes; the views are
in the card-only lookup (under CARD's lock) before they are protected,
so a fault meanwhile waits and is given back; the guards let the page go
only once every view is protected. Before, a view refused half way had
been let go by the guards already, read-only, and a title write there
reached no handler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
With the lookup at every file read of the title's, VICTORY_LAZY_BACK=2
crashed the game as its first cutscene started, before any piece was
fetched (a write to 0 in the title's code, the same address each time;
none without the switch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Two faults behind the crash at the first cutscene with VICTORY_LAZY_BACK=2:
the fetch being merged was noted before its merge, so every untouched
page became card-only at its first fetch (the first world frame's pages,
all at once); and a give-back wrote the card's piece whole, over title
bytes the card had not received (the ranges the copy-back's merge skips),
putting stale bytes into title memory. A page is now a candidate only
60 frames after its first fetch, and a give-back merges as the copy-back
does: the CPU's side with the card's bytes where they differ, outside
Card::skip (now shared with card_merge_relay), for the send its kept
bytes were fetched after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
The crash with VICTORY_LAZY_BACK=2 comes in the second the first pages
become card-only, before any frame line counts them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
A gameplay profile had the submitting thread waiting 18 ms a frame for
watch::writes' journal lock, held across the guard walk of view memory
(VirtualProtect on what was written, page-table queries), and the wide
refreshes waiting on each other there too. For memory the guards hold,
writes now takes the asking's number under the lock, walks the guards
without it, and puts what it found into the journal after. What a walk
finds is noted in the guards (Guards::recent) until its asking has put
it in the journal: a walk meanwhile finds those pages clean and reports
them from there, stamped with its own asking's number. Pages keep the
highest number any asking gave them. VICTORY_WATCH_SPLIT=0: under the
lock, as before. The kernel's write watch (which resets what it reads)
stays under the lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
A gameplay profile had merge_under_writes at about 14 ms a frame of the
submitting thread: for every changed page it made a list of changed runs
(up to a million a frame), joined it, then made a mask of most of them.
Without a merge gap (the default) the page's mask and its number of runs
now come out of one pass, eight bytes at a time (Masked::of_diff); a page
over the cap goes up through the mask and the CPU's side takes the page
whole (the same bytes), one under it takes its few runs from the mask.
A test checks of_diff against of_runs(changed_runs) on 200 random cases
(passed, run on its own).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
# Conflicts:
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/shadow.rs
#	crates/victory-gpu/src/watch.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:44 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head ce304e5 into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them), also with --all-features; this PR adds none. cargo test --workspace --locked: run 1: stopped at indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields (the one that fails on main itself most runs here (PR #849 and #847 fix its assertion)); run 2: stopped at indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields (the one that fails on main itself most runs here (PR #849 and #847 fix its assertion)) (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 12:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/860#issuecomment-7162307427) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `ce304e5` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with exactly the errors `main` itself has on this machine (`placed_filler_twins`, `depth_written`, a sort; PR #841 fixes them), also with `--all-features`; this PR adds none. `cargo test --workspace --locked`: run 1: stopped at `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields` (the one that fails on `main` itself most runs here (PR #849 and #847 fix its assertion)); run 2: stopped at `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields` (the one that fails on `main` itself most runs here (PR #849 and #847 fix its assertion)) (`main` alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/shadow.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/860/head:github-bot/gh-860'
git switch 'github-bot/gh-860'

Merge

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