Turning the camera: a title write flushes and forgets only what it touches (ports #3109's scoped invalidation), and new textures can be filled beside the recording (VICTORY_FILL_AHEAD, opt-in) #4207
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!4207
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4206"
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?
@Lyrnc on GitHub · 2026-11-30 17:23 UTC · original
Lyrnc:perf/turn-texture-pass→main· +560 −13 · 3 files · 3 commits · closed without mergingProblem
Users report the frame rate falling hard just from turning the camera (#3443: 28 -> 3.6 fps). Our bench: RTX 5080 + Ryzen 7 9800X3D, 32 GB, Series X 1440p DLSS Quality, standing for 120 s, then the right stick held for 120 s. Eight spin runs (four builds of the 2026-11-29 base, two runs each), world + 30..150 s against world + 150..270 s, means of the per-second lines:
(One run of the eight, R_1, was slow in both halves: 16 and 15 fps, the submitting thread 61 and 67 ms, refreshes 35 and 37 ms. The ranges above leave it out; its flush and copy counts are in them.)
The texture pass (textures picked by index, on the threads that translate the lists), from its 5-second lines in the same windows:
Root cause
Step::Copy) and a copy at its place (Step::Placed, when free) calledBatch::title_written: every pending refresh flushed, thenBatch::ahead(what the submission refreshed in front of its steps) andBatch::textures(the textures it checked) emptied. Every refresh and texture check after such a step in the submission was queued and checked again, and each title write after that flushed them. Turning, the title makes about 4 more buffer copies and 11 more copies at their place a frame (it streams). The refresh requests the lists make hardly change (+3 %), but the flushes grow by 11-12 a frame, and the refreshes by 4-5 ms of the submitting thread, which is the frame's bottleneck (the card drops from 63-71 % to 46-56 % busy). Each texture a later list samples is checked again too (the write watch or the guards asked; hashed every eighth frame).Batch::refresh_front, which the submitting thread waits for.VICTORY_TEXSPK_PASS_MS=8, doubled on a card over 12 GiB with room: up to 16 ms a frame of a list thread), so cheaper slots there drain the queue faster but do not shorten the frame; and "for copies in the card's memory" grows mostly insend::take's time per MB (49 -> 53 MB a frame, 6 -> 9 ms), which these logs cannot tie to textures.Fix
Batch::invalidate_written(dst, len, aliases). After a title buffer copy or a copy at its place (free), only theaheadandtexturesentries whose range meets[dst, dst + len), or a 64 KiB block that shows the same physical pages (watch::elsewhere_blocks, the runtime's views), are forgotten.Batch::textureskeeps each staging buffer's title span for it. On current main the copies are joined (VICTORY_JOIN_COPIES), so a joined piece forgets its own range too. Work of ours that may write anywhere (Step::Run) still empties everything. #3109's other parts (theStep::Host/Step::Runsplit, the AVX2 digest, the lock-free texture checks, the port and prelude trims) are not taken.VICTORY_SCOPED_WRITES(on;=0restores the oldtitle_writtenat those steps exactly).Batch::title_wrote: before such a step, only the pending refreshes whose host copy's span meets the written range (or one of its alias blocks), and the textures due whose memory does, are done (Batch::flush_touching); the others stay pending for a later flush. A copy is judged by its whole span:Shadow::updatereads title memory and writes the host copy only inside it, so a copy the write misses gets the same bytes before the write as after it.title writes among the steps per frame (VICTORY_SCOPED_WRITES is on): N; before them R pending refreshes done as they read what is written, L left for a later flush; past them A copies refreshed ahead stood (F forgotten), T textures checked stood (G forgotten), D textures due left for a later flush.watch::elsewhere_blocksnames is whatwatch::wrotenotes in the journal after such a write, which is what the refreshes' no-op checks go by already. A page shown at more than 64 addresses, orVICTORY_VIEW_GUARD=0, is outside both, as before.VICTORY_FILL_AHEAD=1(off by default). When the texture pass records an upload whose staging buffer was made for that one upload (Staging::once, not uploaded yet, not a bake's, not levels on demand, not detiled on the card), the buffer is handed to two threads of ours (victory-texture-fills-N, at most 512 waiting) that fill it (Staging::refresh_now) beside the frame's recording. The staging buffer's lock orders it with the submission: the submission finds it filled (such a buffer is never read twice), waits while it is being filled, or fills it itself if no thread got to it, and the thread then finds nothing to read. The texture's memory is then read when its upload is recorded, as the copy queue ahead already reads it; a title write in between is found by the pass's looks after the upload (RECHECK_FRAMES) and uploaded again. Line:texture fills ahead per frame (VICTORY_FILL_AHEAD=1): S staging buffers sent to the threads, F filled by them, N with nothing to read (filled by their submission already, or not there), X left to their submission.Verification
Windows 11, rustc 1.98.1 (the pinned toolchain), RTX 5080 + Ryzen 7 9800X3D, own target directory, on
6a9dcecb(main84bd61e2+ the three commits):cargo check -p victory-gpu --tests --locked -j 4: passes. Its one warning (Shadow::rangednever used,shadow.rs) is main's.cargo test -p victory-gpu --lib --locked -j 4 -- host:: watch:: shadow:: texture::: 462 passed, 0 failed, 40 ignored (benchmarks, and tests that want a process or a relay of their own).cargo clippy -p victory-gpu --lib --tests --locked -j 4: two warnings, neither on a line this branch adds (main'sShadow::ranged, andseed % 3in a test ofhost.rsfrom7addcfc7e).cargo xtask policy: fails oncrates/victory-shader/src/native.rs(a 560-character hex run), a file this branch does not touch; main has it.host::batch::scoped_title_writes_invalidate_only_overlapping_entries(ported from #3109): a write evicts theaheadandtexturesentries it overlaps and those of an alias block, and keeps the others.host::refresh_tests::a_title_write_flushes_only_the_copies_it_writes: two copies with pending refreshes; a write into one has that one done first (it holds the bytes of before the write), leaves the other pending; after the write a new refresh of the first gets the new bytes, the other gets its unchanged bytes at the last flush.host::refresh_tests::a_title_write_flushes_copies_of_its_pages_at_other_addresses: one section mapped twice and told to the runtime as two views;watch::elsewhere_blocksnames the block at the other address, and a write through the first view has the second view's copy refreshed before it.host::refresh_tests::scoped_title_writes_end_as_writes_that_flush_everything: 24 rounds of random submissions (5 copies over write-watched memory, some over one another, copies standing refreshed ahead, 24 random refreshes and title writes), each run twice from the same bytes: the old way and the scoped way end with the same bytes in every copy.texture::fill_ahead_tests::only_a_fresh_one_upload_staging_buffer_is_filled_ahead: which staging buffers fill ahead takes.NOT tested
c71899d9; ARM A = this branch (scoped writes on, fill ahead off); ARM B = this branch with--set VICTORY_FILL_AHEAD=1; ARM C = this branch with--set VICTORY_SCOPED_WRITES=0(should match BASE: the switch puts the old steps back).VICTORY_REFRESH_FRONT=0/ withoutVICTORY_JOIN_PARTS(thenrefresh_aheadfillsahead; the scoping is the same code), nor withVICTORY_LIGHT_REFRESH=0.Overlap
invalidate_written(the same function). Its other changes are not here and do not conflict in intent: itsStep::Copykeeps a fullflush()before the write, which commit 2 scopes.Batchinvalidation (title_written_rangeflushes only the overlapping pending refreshes, fills and textures, and keeps sorted written ranges), with card_steps planning, write-watch scratch and async landing in one +1,619/-576 commit. Same idea as commits 1 and 2 for the Batch part; this branch is the small version on current main. It also scopes the fills, which this branch leaves as they are (all done before any title write).Batch::texturesacross a title write by their spans; the texture half of commit 1.perf/refresh-noops(queue sift inBatch::add) touchesBatch::add,flush_oneandtitle_writtenand would need a small rebase (itssametable must drop entries the write overlaps, asinvalidate_writtendropsaheadentries).claim_texture_rechecks). #2608 (nidea1), #2795, #2971, #2509, #2116: merged; this branch is on top of them.VICTORY_DUE_INDEX(in main, off: "taking the slots due" 157-221 ms per 5 s while turning here, against 35-45 standing) are the pass's own budget and queue; not changed here. #2338, #2240, #2797 (card detiling) and #1391 (staging reuse) are the detiling and staging side; fill ahead moves the PC's detiling of the pass's listed uploads, it does not change it.AI use
Claude Code (Claude Opus 5.5) read the bench's spin logs and the submission and texture paths, chose #3109's scoped invalidation to build on and ported it (qlfu as author), wrote the two other commits and their tests, ran the checks above, and wrote this note. Nothing was run in game.
🤖 Generated with Claude Code
@gabrielecabrini on GitHub · 2026-11-30 18:29 UTC · original
Tested on Linux (Proton). Standing still it helps; turning the camera it makes no difference here.
VICTORY_FILL_AHEAD=1gave more stale-texture warnings and some visible glitches.Setup: RTX 4070 SUPER 12 GB, i5-14600KF (no SSE4a), 31 GB RAM, Arch Linux, NVIDIA 620.73.04, Proton Experimental (11.0-20261123b) via umu-run,
VKD3D_CONFIG=no_descriptor_heap. Release build of this branch (6a9dcecb, on main84bd61e2),victory play --series-s --dlss off. Same save each run: loaded, stood still for about 60 s, then walked and turned the camera along the same route for about 60 s. Runs in order A, B, C, one run each.--set VICTORY_SCOPED_WRITES=0--set VICTORY_FILL_AHEAD=1Medians of the 5-second log lines (12 per phase, 10 for C moving):
title writes among the steps per frame: 27.3; ... 11.7 left for a later flush; past them 3633.8 copies refreshed ahead stood (20.3 forgotten), 704.8 textures checked stood (0.0 forgotten).VICTORY_FILL_AHEAD=1:0.6 staging buffers sent to the threads, 0.6 filled by themper frame, so almost nothing goes through it here.a texture picked by index changed after its upload with nothing to tell of itwas logged 29 times, against 13 (A) and 18 (B). The player saw a few more small texture glitches in C than in A or B (no screenshots). C's moving route had fewer draws, so its moving row is the least comparable.Not tested: Windows, more than one run per arm, DLSS or frame generation, Series X.
@mstrmoos on GitHub · 2026-11-30 20:38 UTC · original
A/B on the same hardware as yours: RTX 5080 16 GB and Ryzen 7 9800X3D on Windows 11, Series X, 1440p, DLSS Balanced, frame generation off.
The build was main at
e1251c31plus this PR, plus #4333 (VICTORY_SCRATCH_CARD=1, list scratch in card memory), which was on in every phase. I used one run withVICTORY_AB=20,VICTORY_SCOPED_WRITES,VICTORY_FILL_AHEAD, so every combination was played in the same scene. The run stood on a pier with people around it.Median frame time per 20 s phase. Phases 0–2 were still loading and are left out.
A caveat: a CPU-heavy analysis ran beside the game at high priority for the whole run, so the absolute numbers are higher than usual and drift. The alternating phases cancel most of that, but take the deltas as about ±0.5 ms. I'll rerun on an idle machine and add the result here.
Tests:
cargo test -p victory-gpu --libmatches main. It has the same two failures #4025 fixes, plushost_list_uav_pool_lifecycle_retire_trim_and_info_queue, which failed once in the full run and passed 3 of 3 alone. That test is flaky; this PR doesn't touch its file.@paales on GitHub · 2026-11-30 20:51 UTC · original
Written by 🤖:
In-game numbers for this PR, as the description asks. PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. Series X, 1440p, DLSS Performance, frame generation off. Each run: a new game (settings save, no story save), one A press, the first cutscene for 60 s from its first frame. On this PC the same build's submitting thread took 24 ms a frame in one run and 35 ms in another half an hour later, so only large differences count. 60 fps cap.
Base without this PR:
mainc71899d9with #3918, #1727, #3553 and #3043. Merging this branch also broughtmainup to84bd61e2, so the first table holds those commits too. The second table is one build, with the switch off and on.VICTORY_FILL_AHEAD=1The fill line said about 15 staging buffers a frame sent to the threads, 14 filled by them, none left to the submission. No crash and nothing wrong in the screenshots in about 20 runs. I play with it on.
@nicolasabosch on GitHub · 2026-11-30 23:19 UTC · original
Tested on an RTX 4070 Laptop 8 GB with
VICTORY_FILL_AHEAD=1: no measurable fps difference in this scene (2 runs).What was built
e1251c31with four opt-in PRs merged together and nothing else changed: #4069, #3757, #3614 and #4207. This PR's head was6a9dcecb.Setup
victory play --series-s --dlss performance --framegen 2, with no fps cap and the window minimized.host:reports, about 200 s. These are real frames, not generated ones.On this laptop, identical runs differ by about 0.5–1 fps, so only an effect of roughly 1.5 fps or more would show.
In this scene the frame (~60 ms) is longer than the submit thread's own work (~33–40 ms), so a gain on the submit thread alone may not reach the fps here. A still camera is not the case
FILL_AHEADis for. The default-on scoped writes are part of the control build. Against main, that build's refreshes were 12.5 and 13.9 ms against 14.2–15.3, and its fps was 16.45 and 16.93 against 15.9–16.4. That's a hint, not a result: the build also carries the other three PRs.Not tested: driving, camera turns, interiors, an image comparison, other GPUs.
@Lyrnc on GitHub · 2026-12-01 01:41 UTC · original
Bench result: the spin A/B from "NOT tested", run overnight. RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11. Release builds, one shared shader cache (warmed first):
84bd61e2.6a9dcecb, defaults.VICTORY_SCOPED_WRITES=0.VICTORY_FILL_AHEAD=1.The base is main
84bd61e2, notc71899d9as the description planned, since this PR now sits on it. Series X, 1440p, DLSS Quality, frame generation off, same save. Standing from world+30 to 150 s, right stick held from 150 to 270 s, 360 s runs, two runs per arm, in the order main A C B (+ #4295) twice. Ranges are the two runs.SCOPED_WRITES=0)FILL_AHEAD=1)The new line, A while turning (per frame): 41.7-42.0 title writes among the steps. Before them, 4.3-4.5 pending refreshes were done and 45.1-46.3 left for a later flush. Past them, 8,506-8,691 copies refreshed ahead stood (26.4-26.7 forgotten), and 1,014-1,259 textures checked stood (0 forgotten). While standing: 27.1-27.8 writes, 0.1-0.3 done, 17.1-18.4 left, 6,050-6,330 stood (20.5-21.7 forgotten).
B's fills line while turning: 64-68 staging buffers sent to the threads per frame, 61-62 filled by them, 3-6 with nothing to read, 0 left to their submission.
No device removed, DRED or "did not close" line in any of the 8 runs.
What this shows
VICTORY_SCOPED_WRITES=0puts back main's counts exactly: 44 and 55 flushes, 6,900-7,440 asked.What it does not show
84bd61e2, so there is no per-cause split of the slow frames.VICTORY_REFRESH_FRONT=0,VICTORY_LIGHT_REFRESH=0.AI use: Claude Code (Claude Opus 5.5) ran these on our bench queue, parsed the run logs with its own scripts (and the PR author's line parser), and wrote this comment.
@Lyrnc on GitHub · 2026-12-01 03:56 UTC · original · edited 2026-12-01 04:19 UTC
Thanks @mstrmoos, @paales and @nicolasabosch, and @gabrielecabrini above. Read together:
VICTORY_FILL_AHEAD=1is mixed, so it stays opt-in. paales: median frame 31.2 → 30.1 ms in one build, seconds with a frame over 50 ms 30 → 23, ~14 staging buffers a frame filled by the threads. mstrmoos: 0.4-1 ms slower on its own, and no better than scoped writes alone. nicolasabosch (8 GB laptop): no measurable change. There the frame (~60 ms) is longer than the submitting thread's work (~34 ms), so a saving on that thread can't show in fps. gabrielecabrini saw more "changed after its upload" texture warnings with it (29 against 13 and 18) and a few small texture glitches. That needs a look before it could be more than opt-in.c71899d9to84bd61e2. Only the second table (one build, switch off and on) measures this PR alone.AI use: Claude Code (Claude Opus 5.5) read the reports side by side and wrote this.
@mstrmoos on GitHub · 2026-12-01 04:13 UTC · original
The idle-machine rerun I owed you. It doesn't change your summary.
Setup: RTX 5080 16 GB, Ryzen 7 9800X3D, Series X, DLSS Balanced, frame generation off. The player stands still on a pier for 240 s: water fills the left of the frame, people sit at a terrace behind, foliage and a far shore are in the distance, about 8,650 draws a frame. The build is main
e1251c31+ #4333 + this PR. Nothing else ran this time; my first A/B had a static analysis running beside it.VICTORY_ABflippedVICTORY_SCOPED_WRITESin place in 40 phases.On against off in 39 neighbouring pairs: median +0.0 % frame time, on faster in 19.
The caveat matters. This build is now held by the card on this scene (100 % busy, the submitting thread worked about 24 ms of a 33 ms frame), so a saving on the submitting thread can't show in the frame here. My first run's 1.4-2.2 ms came from a build that was still partly bound by the submitting thread, with the analysis competing for the CPU. So "a small saving on the submitting thread where that thread is the limit, nothing where the card is" fits both of my runs.
6a9dcecb36to7bb8b13098@albertik322-sudo on GitHub · 2026-12-01 16:49 UTC · original
A/B on a laptop GPU, cherry-picked onto main @
5fabb46e. PC: RTX 3070 Laptop 8 GB, i7-11800H, 32 GB RAM, Windows 11. Series S, 1080p output, DLSS Performance (540p scene), frame generation x4 on.Same save point, standing still, median over ~5 min in-world:
The fixed-cost drop is the whole story here: in light scenes the ceiling went from ~15 to ~21 fps. Heavy scenes are still bounded by the per-draw cost (ms/kdraw ~9 unchanged).
One note: we're on a laptop where the write-watch/copy path dominates frame time (copies ~17-19 ms + write-watch asking ~12-16 ms of a ~67 ms frame, ~7,700 draws/frame). Anything that cuts the number of refreshes has outsized effect here, so this PR was the biggest single win we've measured so far.
@Lyrnc on GitHub · 2026-12-01 17:04 UTC · original
@albertik322-sudo thank you, that's the clearest result this PR has had. On a CPU-limited laptop (i7-11800H) the fixed cost per frame falls from ~47 to 25.5 ms, and the light-scene ceiling goes from ~15 to ~21 fps. That fits the mechanism: where the write-watch and copy path dominates the frame, every flush a title write no longer forces is time back. On our 9800X3D desktop the same change saved only ~1 ms, because there the submitting thread isn't the frame's limit, so desktop numbers undersell it. Thanks also for the batch numbers on #4295/#4340 (no wrong surfaces, clobber watch quiet) and for the
VICTORY_WC_BAR=1laptop warning.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@trustno1-coder on GitHub · 2026-12-01 18:45 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed