Skip to content

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

Open
turbinedogbla-creator wants to merge 32 commits into
fxceless:mainfrom
turbinedogbla-creator:claude/startup-perf-fixes
Open

turbinedogbla-creator wants to merge 32 commits into
fxceless:mainfrom
turbinedogbla-creator:claude/startup-perf-fixes

Conversation

@turbinedogbla-creator

Copy link
Copy Markdown

…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

…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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
…r, driver watch, self-copy fix)

# 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
@MamaLeVrai

Copy link
Copy Markdown

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.

…by default

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
e4glevlr added a commit to e4glevlr/victory-fork that referenced this pull request Nov 25, 2026
- fxceless#860 (a544813): fingerprint fill_ahead reads so title rewrites do not permanently trip global fill waits, hold back only affected 64 KiB pieces (up to 8), log depth UAVs once per view, and fix VICTORY_CARD_ROOM_FOR_BUFFERS doc
- fxceless#462: add opt-in VICTORY_FILL_ON_CARD=1 (off by default) HostList::card_constants path in draw.rs/host.rs when aligned direct shadow bind (fxceless#144) does not apply
…iew, indirect gather, frame shot)

# Conflicts:
#	crates/victory-gpu/src/host.rs
…while

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
…cords on by default

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
…AD_PROBE=N)

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
…LAZY_BACK=1)

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
… it was

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
…only while there are some

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
…tch; give-back merges

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
… it happens

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01McYwNpi6MZ72qHprqeeyRX
PiloteCode added a commit to PiloteCode/victory-fork that referenced this pull request Nov 25, 2026
…celess#24/fxceless#104), null CBVs (fxceless#304), tables at list cuts (fxceless#742), heap entries (fxceless#589), barriers (fxceless#787), depth-stencil UAV barriers (fxceless#214), windows ending at recorded writes (fxceless#663), sRGB views (fxceless#644), wide accesses across pages (fxceless#846), view-guard costs (fxceless#812/fxceless#853), the fill latch (fxceless#860), pipeline waits (fxceless#709), robustness; opt-in fxceless#868/fxceless#845
…light refresh, step index, fills in place)

# Conflicts:
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/shadow.rs
#	crates/victory-gpu/src/watch.rs
e4glevlr added a commit to e4glevlr/victory-fork that referenced this pull request Nov 26, 2026
…xceless#1206, fxceless#1210, fxceless#1241, fxceless#1214, fxceless#1044, fxceless#1227)

- fxceless#1205: make upload fills wait for flights by default (VICTORY_FILL_WAIT=0 opt-in, fixes fxceless#1025 blurred oval while keeping fxceless#860 per-piece hold)
- fxceless#1147: guard only mapped view memory, never committed private or free memory (fixes structure-builder freeze)
- fxceless#1206 (a183ea2): cap CBV size at 64 KiB before 256-byte rounding
- fxceless#1210 (41f9857): preserve ResourceMinLODClamp in tiles::show_from
- fxceless#1241 (19a45d1): copy aliased GPU-written texture view even if list already uploaded view from title memory
- fxceless#1214 (f9fdf19): log ID3D12DeviceRemovedExtendedData2 device state in removal_data
- fxceless#1044: size DirectStorage worker pool to physical cores (VICTORY_DSTORAGE_WORKERS override)
- fxceless#1227: batch send-and-hash into copies -> 1 barrier -> hash dispatches (VICTORY_CARD_SYNC_BATCH=0 fallback)
ljm-233 pushed a commit to ljm-233/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants