Selective texture refresh using existing dirty-page tracking #3266
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#3266
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@AwkGrep256 on GitHub · 2026-11-29 21:09 UTC · original
🚀 [Performance] Selective texture refresh using dirty-page tracking
💡 The idea
Currently, when a texture changes, VIctory can end up copying, detiling and uploading the entire texture, even if only a tiny portion of its memory was modified.
We already have dirty-page tracking in
watch.rs, so why not use that information to update only the parts that actually changed?For example:
Instead of processing all 64 MiB, ideally we should only process the affected regions.
🔍 Where this happens
Relevant files:
crates/victory-gpu/src/watch.rscrates/victory-gpu/src/texture.rscrates/victory-gpu/src/gpudetile.rsdocs/unified-memory-audit.mdIn particular,
Staging::refresh_timed()intexture.rsdetects changes, but the current refresh path can still process the entire texture.The interesting part is that
watch.rsalready has more detailed information about which memory portions were modified (parts_written).We're potentially not using all the information we already collect.
⚙️ Proposed approach
Instead of refreshing the entire texture:
Current vs proposed
📊 Potential data reduction
\boxed{
\text{Savings} =
\left(1-\frac{\text{Changed Bytes}}{\text{Total Texture Size}}\right)
\times 100%
}
This is an idealized estimate, not a guaranteed performance improvement.
⚠️ Things to investigate
This isn't as simple as copying a few dirty pages.
We need to account for:
A 4 KiB dirty memory page doesn't necessarily correspond to one contiguous rectangle in the final texture.
Unsupported or dense updates should fall back to the existing full-refresh path.
📊 Benchmark plan
Before implementing the optimization, let's establish whether it's actually worthwhile.
We should be able to benchmark most of this without launching a game.
Measure:
Also compare the resulting texture data byte-for-byte against the existing full-refresh implementation.
🎮 In-game validation
If the synthetic benchmarks look promising, compare both implementations in the same gameplay scenarios.
Track:
The biggest potential benefit is reduced CPU overhead and fewer streaming-related stutters. Average FPS gains are not guaranteed, particularly when GPU-bound.
✅ Acceptance criteria
🎯 Initial scope
Start with investigation, instrumentation and a standalone benchmark.
No need to introduce Merkle trees, replace the existing hash algorithm or redesign memory tracking.
The goal is simple:
Stop processing and uploading megabytes of texture data when only a few kilobytes actually changed.
If the measurements justify it, implement selective refresh incrementally, starting with the simplest supported texture layouts.
Are you working on a fix?
No
@github-actions[bot] on GitHub · 2026-11-29 21:09 UTC · original
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
@AJNXKJ on GitHub · 2026-11-30 05:52 UTC · original
Real-world numbers for this proposal, from a card that is not the bottleneck.
Environment: RTX 5090 Laptop 24,463 MiB, driver 621.24, Windows 11 26200, build v2026.11.29.05 (release), Series X, 2560x1440 output with DLSS Performance (1280x720 scene), frame generation 4x. Pipeline library pre-warmed, so no pipeline is built during the run.
Steady play in the city (draws/frame 9,096 median):
The card has 60 ms of idle time a frame, so this frame is CPU-side: the
submitting thread plus those copies. If a texture refresh only touched the
dirty pages instead of the whole texture,
copiesis the number that shouldmove, and it is also the number that decides whether this frame gets faster
at all on this machine.
Light scenes for contrast (on the water, draws/frame ~4,000): copies drop to
roughly half and the frame goes to about 25 fps, which matches the copies
scaling with what changed rather than with the card.
Happy to run an A/B on any build that implements this and report the same
figures (median of ten-second lines, same save, same area).
@AJNXKJ on GitHub · 2026-11-30 09:00 UTC · original
Follow-up: the same machine in a light scene, plus the scaling that seems to matter here.
Same RTX 5090 Laptop, same build (v2026.11.29.05), same save, two areas:
So
copiestracks the volume of what changed, roughly linearly, while the card keeps60 ms of idle time in the heavy scene. That is the argument for this proposal: if a
refresh only covered the dirty pages, the heavy row is where the frame would move,
and the light row would barely change.
Two more observations that may be useful:
Throughput. 73 MB in 26 ms is about 2.8 GB/s on this machine. The RTX 5080 entry
in
docs/findings.mdreports 37 MB in 10 ms, about 3.7 GB/s. Same order, so the gapbetween the two machines is the volume and the single-thread cost, not a pathological
slowdown on the laptop.
Aliasing is related but separate. Turning
VICTORY_ALIAS_TARGETS=0on this machinecosts almost nothing in fps (15.1 against 14.1 median) but raises
on the GPUfrom1.2 ms to 6.7 ms, and the run later died on a host command list (reported in #1976).
Whatever the dirty-page path does, it probably has to stay correct with alias targets
left on.
I will keep posting the same figures for any build that changes the copy path, as long as
it helps.
@AJNXKJ on GitHub · 2026-11-30 09:03 UTC · original
RTX 5090 Laptop — a measured profile, and the two defects found on the way.
Environment: RTX 5090 Laptop 24,463 MiB, driver 621.24; Core Ultra 9 290HX Plus / 128 GB;
Windows 11 26200; build v2026.11.29.05 (release); GTA VI Xbox 1.0.2.1, Series X;
2560x1440 output, DLSS Performance (1280x720 scene), frame generation 4x;
VICTORY_NAN_SCRUB=1only; pipeline library pre-warmed, nothing built during play.Light scene (on the water): about 25 fps with roughly half the copy volume.
The point: 60 ms of idle card per frame in the heavy scene.
preparingis 40-50 ms,copies20-27 ms for 65-80 MB, about 2.8 GB/s. The RTX 5080 entry indocs/findings.mdreports 37 MB in 10 ms (3.7 GB/s) on a scene of comparable shape, so the difference here is
volume plus single-thread cost, not a pathological slowdown on the laptop.
Lowering the picture or the internal resolution changes nothing measurable, as that file says.
Two defects found
VICTORY_ALIAS_TARGETS=0the run died during a jetski stunt:a host command list did not close (0x80070057 E_INVALIDARG)->host GPU failure.Two sessions without the switch, same binary and save, had no crash. Log in #1976.
Reproduce
If a build changes the copy path, I will run the same profile and post the same table.
@AwkGrep256 on GitHub · 2026-11-30 12:32 UTC · original
Thanks, this confirms the game is CPU and copy-bound in the heavy scene. Texture work is about 2–4 ms inside 20–27 ms of total copying, so selective texture refresh is a good first target but will not remove all copy time.
Could we split the remaining copy time into textures, buffers, readbacks, descriptors, staging, and waits?
For the A/B test, please keep alias targets enabled and compare total copy time, texture copy time, copied bytes, p95/p99 frame time, and 1% lows using the same save and scene.
If dirty pages are usually sparse, we can copy only changed texture regions and fall back to the existing full copy when many pages changed.
@AJNXKJ on GitHub · 2026-11-30 12:37 UTC · original
Bucket split from the same session, as far as the default log line lets me go.
preparing(whole)copies(buffers)texturesheap bufferspassescopying backFrame time over the same samples: median 70.5 ms, p95 91.3 ms, p99 133.2 ms,
1% low 7.5 fps, max 723 ms (that one is a load, not gameplay).
So of the 54.8 ms of
preparing, about 31 ms is named by the buckets above andabout 24 ms is not attributed by the default line — which is presumably the
descriptors, staging and waits you are asking about.
copying backis 0 herebecause this run used the default relay settings; I can turn the copy-back path on
if you want readbacks in the table.
Question: is
VICTORY_PROFILE=<from>,<to>,<ms>,<file>sampling the intended wayto attribute those 24 ms, or is there a diagnostics build that prints named buckets
(descriptors / staging / waits) per frame? I would rather report your buckets than
my guesses.
A/B protocol accepted exactly as you wrote it: alias targets left on, same save
and same scene, and I will report total copy time, texture copy time, copied bytes,
p95/p99 frame time and 1% low. Tell me which build to download when it exists.
@AwkGrep256 on GitHub · 2026-11-30 12:59 UTC · original
This bucket split is exactly what we needed. The 2.8 ms texture cost confirms that selective texture refresh is worthwhile, but the larger opportunity is the remaining buffer, descriptor, staging, and wait time.
VICTORY_PROFILE looks appropriate for finding the missing CPU time because it samples call stacks by phase.
Please run it during the same heavy scene with alias targets left enabled. The profile output should tell us whether the missing time is mainly descriptor setup, staging allocation, range planning, or waits.
The current main branch also has GPU detiling, copy queues, GPU upload heaps, parallel copy workers, and an opt-in prelude upload path.
I think the first A/B should test the existing prelude upload path, then selective texture detiling, while measuring total copies separately from texture copies.
The important measurements are total frame time, p95, p99, 1% low, texture milliseconds, buffer-copy milliseconds, copied bytes, and the number of upload ranges.
@AJNXKJ on GitHub · 2026-12-01 02:04 UTC · original
A/B of the prelude upload path, as you asked — same build, same save, same area.
Build v2026.11.30.03, RTX 5090 Laptop 24 GB / driver 621.24, Series X,
2560x1440 with DLSS Performance and frame generation 4x, borderless fullscreen,
pipeline library pre-warmed (14,972 pipelines), alias targets left at their default.
VICTORY_PRELUDE_UPLOADS=1Reading: the average is unchanged (17.8 against 17.5, inside the noise), the copy
volume grows a little (+12 MB a frame), and the tail collapses: p95 457 -> 90 ms,
p99 737 -> 344 ms, 1% low 1.4 -> 2.9 fps. The player's own words mid-A/B were that it
"feels good once it settles". So on this machine the prelude path is a latency fix
rather than a throughput fix, which fits your point that texture work is only 1.7-2.5 ms
of the copy time.
What I could not measure: the number of upload ranges. The default frame line does
not print it here, and I did not want to guess — which switch or counter names it, so I
can add it to the next table? (I also have not run
VICTORY_PROFILEyet; it needs theheavy scene and I wanted your answer on the buckets first.)
Caveat: A ran 7 minutes and B 10 minutes, from the same save in the same street.
I can repeat either side longer if the sample count matters to you.
@AwkGrep256 on GitHub · 2026-12-01 12:37 UTC · original
This is excellent. The prelude path clearly improves frame-time consistency even though average FPS is unchanged. The 1% low roughly doubled, and the p95/p99 spikes dropped dramatically.
Please repeat the A/B with equal sample counts and alternating order so we can confirm the result. Keep alias targets at their default.
For the next run, please also use VICTORY_PROFILE during the heavy scene.
The next target is the remaining roughly 20 ms of buffer, descriptor, staging, and wait work. The texture-only optimization is still worthwhile, but this result shows that upload scheduling and synchronization are probably the largest source of 1% lows.
Please record upload-range count if possible. That will tell us whether range merging and selective texture uploads can reduce the remaining copy overhead.
@AJNXKJ on GitHub · 2026-12-01 13:16 UTC · original
Thank you — and I have to take the A/B back: both sides had the switch on.
The README now documents
VICTORY_PRELUDE_UPLOADSas defaulting to 1 in victory.exe, and theA-side log confirms it: that run never set the variable, yet it carries nine
prelude upload left outlines. So what I compared was on against on, and the taildifference I reported (p95 457 -> 90 ms) is session variance, not the switch. The same
applies to my "copy volume +12 MB" reading.
That was my error, not yours; I should have checked the default before designing the run.
Proper A/B, ready to run
VICTORY_PRELUDE_UPLOADS=0One variable I have now removed: the pipeline library is freshly and fully built
(15,603 pipelines, 1.38 GB,
preload --all), so no pipeline is being made during eitherside, and no shader translation happens mid-run.
On
VICTORY_PROFILEI will run it on the heavy scene. One caveat from today: the profile is written at the
end of a run, and this build crashes in the dense city (issue #4733,
host command list did not close). A crash loses the whole profile. So I will keep the profilesessions to 10 minutes and exit them cleanly; if one dies, I will say so rather than
hand you an empty file.
On upload ranges
I cannot find a per-frame count of destination ranges in the default line — it gives
only
copies <ms> <MB>. Do you mean the written-memory ranges (VICTORY_AHEAD_GAP_KB,8 MB default, ranges closer than that asked about as one), or a count of the dst-copy
ranges themselves? If it is the second, tell me which counter or build names it and I
will add it to the table.
Agreed on the priority: with textures at 1.7-2.5 ms of a 22 ms copy, the remaining ~20 ms
of buffer, descriptor, staging and wait work is where the 1% low lives.