Opt-in relay capture and page marks, and the fix that makes the marks pay off (RTX 3080: 18.3 → 20.0 fps, p99 113 → 87 ms) #3446
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3446
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3446"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@remijn on GitHub · 2026-11-29 23:25 UTC · original
remijn:rtx3080-capture-marks→main· +2154 −71 · 36 files · 11 commits · closed without mergingSummary
This PR adds two opt-in ways to cut the CPU cost of finding out what the GPU wrote into title memory each submission. It also fixes a bug that made one of them slower than doing nothing, and adds diagnostics used to measure the work. No defaults change: without the new switches, the layer behaves exactly as on
main.On an RTX 3080 (Series S profile, default settings, which include the relay at stage 2), both switches together took the median from 18.3 to 20.0 fps. 1 % lows went from 8.8 to 11.5 fps and the p99 frame from 113 to 87 ms. These are single short runs (see Measured).
Background: what this speeds up
After each submission, the layer has to learn which bytes the title's shaders changed in the ranges they declared written, so it can bring them back into title memory. The card-side compare does this by hashing every declared range in 64-byte pieces and comparing against the hashes from before; with the relay (on by default), a separate thread then fetches the pieces that differ and lands them. In the scene measured, that is about 8,000 pieces a frame, and with the relay on it is where most of the frame goes: about 40 ms of "preparing" a frame, against about 3 ms on the GPU.
The relay is on by default (
VICTORY_RELAYunset means stage 2; only=0turns it off; seeshadow::relayandhost::relay_exact, andef1f8ed0). That includesplay-foxhound.ps1, which doesn't set it: a launch with it logscopied back by a thread of its own, beside the submitting thread … exact=true. The launcher's comment "Left off: VICTORY_RELAY=2" is out of date;ef1f8ed0fixed the same wording inshadow.rs.The two switches attack two parts of that:
1. Relay capture:
VICTORY_LAND_CAPTURE=1(needs the relay at stage 2, the default)What it does. Without it, the relay waits for the compare's results, then records and submits a second step that fetches the pieces that differ. With it, the compare copies every piece it finds changed into a ring of slots in the same submission (
CardShared::capture, ring inCardWork). The relay then reads them from there, with no fetch and no extra wait on the card.Why it helps. On the branch this came from (same 3080), the relay's fetch waits went from 34–38 ms a frame to 0, landing from 44–50 ms to 12–15 ms, and the 90th-percentile frame from 94–139 ms to 75–82 ms. Here it took "copying back" from 15.7 to 13.9 ms, but the median fps didn't move (17.8 against 18.3, within noise).
Why it is opt-in for now:
8773ea2d,8622dc37); characters, faces included, show correctly on the 3080 with the relay and capture on. See the request for testing in the comments.card_batch), because the batched shader doesn't capture. On a card where batching saves a lot, capture could cost more than it gains. That wasn't the case on the 3080, but it hasn't been checked elsewhere.capture_slots_are_never_taken_twicecovers this), but it has run on one PC only.2. Page marks:
VICTORY_MARK_WRITES=1withVICTORY_WRITTEN_COMPARE=check|skipWhat it does. When the translator lowers a buffer store or atomic whose view has a title address it can work out, it adds a store that marks the 64 KiB page written, in a table bound as root UAV
u249(SLOT_WRITTEN). A program counts as "marks all it writes" only if every one of its stores was marked: no store through a root view, by address, or with a descriptor that varies across lanes. On the host side, ranges declared by any other program are noted as unmarked. The compare then reads the marks:check: hashes everything as before, and also counts pieces found changed in pages no shader marked ("misses"). This is the safety test, and it is no faster.skip: leaves pieces in unmarked pages unhashed, where only marking programs declared the range. That is the speed-up.Why it helps. In this scene, about 7,200 of 8,060 pieces a frame are declared only by marking programs, and skip leaves about 7,000 of them unhashed. "Preparing" fell from 40–41 ms to 38 ms, GPU time from 3.3 to 0.9 ms, and the frame-time tail improved most (see Measured).
Why it is opt-in, and should stay so for now:
0x8007000e). Anyone trying it should run-Preloadonce first.How to try it safely: preload once with the switch on, then run
checkand confirm the log linethe compare and the pages shaders mark (VICTORY_WRITTEN_COMPARE=check) ...shows0.00 pieces found changed whose page no shader marked (misses). Only after that, useskip.The fix that makes the marks work (
1d37f7e6)As first ported, the marks made things much worse: in check mode, 3.2 fps and 311 ms of preparing a frame. The cause:
Deferred::unmarkedwas never cleared. This fork reuses command lists (Deferred::clearkeeps their allocations), so each list kept the unmarked ranges of every frame it had ever recorded, and the compare looked through all of them for every range it compared. The stale ranges also blocked pages that current shaders had marked, so only 70 to 1,650 pieces a frame counted as marked instead of about 7,200.The fix:
unmarkedwhen it is cleared;unmarked_seen);UnmarkedIndex), so each compared range only visits the ranges that overlap it.A test checks the index against the old full scan. The same omission exists in the original implementation on the branch this was ported from; it probably went unnoticed there because lists weren't reused.
Diagnostics (off by default, diagnostics build)
VICTORY_PROFILE_SPINVICTORY_FENCE_STAGESVICTORY_DECLARED_BYVICTORY_QUEUE_USEVICTORY_GPU_TIMINGadditionsThese are what showed the GPU idle-but-busy pattern behind slow passes like
InstanceCulling:CS_Tree_BatchCull, where a wave64 program run as two 32-lane halves took 190 ns per thread against 0.3 to 4 ns elsewhere.Measured
RTX 3080 10 GB, 32 GB RAM. Series S profile, no DLSS, no frame generation, ray tracing off,
play-foxhound.ps1's switches (the relay at stage 2, its default). Diagnostics build, the same save each time, 40 s measured after a 20 s warm-up, one run each, so differences of about 1 fps are noise.checkskipcheckbefore the fix)For context, the relay is what makes the default fast here. With it turned off (
VICTORY_RELAY=0), Series X 1440 ran at 7 to 8 fps with 55 to 65 ms a frame on the GPU. With it on, as by default, the CPU's "preparing" is the limit, and that is what these two switches target.What would make them defaults
Tested
cargo checkwith and withoutdiagnostics, after mergingmain.victory-gputests for the marks, compare and capture: 52 pass, including the newunmarked_index_finds_the_overlapping_ranges_of_the_copy, and the marking translator test (its DXIL validates).hardware_card_compare_*tests on the RTX 3080.shader_cache::tests::every_switch_of_the_translator_is_in_the_keyalready fails onmainbecause of the staleVICTORY_SCALAR_SPLITS(#3210 removes it). The two marks settings are listed in itsELSEWHERE.Notes for review
u249becauseu252is this fork'sSLOT_MEET.mark_writtenis inemit/descriptor_data.rs. A view the translator can't place leaves the program unmarked rather than refused.marks_writesas one more word (an empty entry is 44 bytes) and keysVICTORY_MARK_WRITESandVICTORY_MARK_WHYonly while marking is on.CardTaketoo, so a plan made later by the sending thread (publish) has them.41f2923aandmain's41adb551fix the same diagnostics build errors; the merge keepsmain's version.🤖 Generated with Claude Code
Relay capture and page marks (opt-in), with a fix that makes the marks pay off on an RTX 3080to Opt-in relay capture and page marks, and the fix that makes the marks pay off (RTX 3080: 18.3 → 20.0 fps, p99 113 → 87 ms)@remijn on GitHub · 2026-11-29 23:51 UTC · original
A correction, and a request for testing
The first version of this description said
play-foxhound.ps1leaves the relay off. It doesn't. The relay runs at stage 2 wheneverVICTORY_RELAYis unset (ef1f8ed0corrected the comments inshadow.rssaying so). The launcher never sets it, and its own logs show the relay thread running withexact=true. Only the launcher's comment ("Left off: VICTORY_RELAY=2 … characters' skin missing", citing fxceless/victory-fork #89) is out of date. I've corrected the description.That changes the case for capture. Its one precondition, the relay at stage 2, is already met by default, so
VICTORY_LAND_CAPTUREcould become a default too. It's opt-in in this PR only because it has run on one PC. Before proposing that, it would help to have A/B runs on other hardware:VICTORY_LAND_CAPTURE=1(default settings otherwise). Compare the frame lines' fps, "copying back", and the p99 / 1 % lows. Cards where the batched compare is a big share of the frame are the most useful, since capture replaces it with single passes.8773ea2d,8622dc37) may be why.VICTORY_MARK_WRITES=1 VICTORY_WRITTEN_COMPARE=check, preloaded first (-Preload; the switch is in the shader cache key). Play a while in different areas and report the log linethe compare and the pages shaders mark (VICTORY_WRITTEN_COMPARE=check) ..., especially any non-zeromisses. Long check runs with 0 misses are what skip mode needs before it could become a default.Useful to include: card, driver, RAM, console profile and resolution, DLSS mode, and which build (diag or release).
If capture holds up elsewhere, I'll follow up with a change that makes it the default (
VICTORY_LAND_CAPTURE=0to turn it off) and fixes the launcher's relay comment.@Heldenkrieger01 on GitHub · 2026-11-29 23:57 UTC · original
On this RTX 3080, capture eliminated the measured relay fetch wait. Windows commit pressure dominated all four in-game runs, so the reported 18.3 → 20.0 FPS gain remains unverified on this PC. The isolated compare also showed a slowdown for
skipon one large span.Ryzen 9 5900X, RTX 3080 10 GB (driver 621.40), 32 GiB RAM, diagnostic builds
41adb551anddca5af48. Same Series S save, relay 2, DLSS/FG/RT off, and a 40 s window after 20 s of warm-up. I prewarmed the previously used pipelines formainand the marked build, used two pipeline workers, and disabled speculative prefetch.maincheckskipEach run logged eight frame times in the window and spent about 5.0 s per frame waiting on pipelines. Capture-only avoided about 4.9 MB of relay fetches per frame and brought median fetch wait from 4.8 to 0.0 ms/frame.
skipleft a median 4,652 pieces per frame unhashed.checkreported zero misses in its sampled window.In the smaller test, all modes used the PR’s single-span compare on 4,000 contiguous 64 KiB pages (250 MiB), with 27 timed submissions per mode. At 10% marked, median submit-and-wait time was 0.400 ms hashing all pages, 0.398 ms in
check, and 1.987 ms inskip. At 100% marked, all three were 0.395–0.396 ms. The ~5× slowdown applies to the single large dispatch with 90% unmarked pages. The in-game timings above include the full submission and relay workload.@remijn on GitHub · 2026-11-30 00:03 UTC · original
Split into two independent PRs: #3498
#3498 (relay capture) and #3499
#3499 (page marks, with the fix that made them pay off). Each builds on main alone.
Pull request closed