Skip to content

perf(gpu): textures on time with less CPU: refresh filtering, zero-mip skip, slot checks, plus #697, #666, #661, #654, #684, #797, #614 - #814

Closed
henriazz10 wants to merge 19 commits into
trustno1-coder:mainfrom
henriazz10:perf/texture-cpu-rtx50-v2
Closed

henriazz10 wants to merge 19 commits into
trustno1-coder:mainfrom
henriazz10:perf/texture-cpu-rtx50-v2

Conversation

@henriazz10

@henriazz10 henriazz10 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

perf(gpu): textures on time with less CPU, lock contention, and lock-free refresh filtering

Summary

This branch includes this fork's open #532 (first commit); if this PR is taken, #532 can be closed.

Rebased onto origin/main (63b902f), this branch combines our texture-streaming and submitting-thread optimizations with community improvements (each credited below). Across warm-cache 130 s runs on an RTX 5080 (1440p, DLSS Quality) + AMD Ryzen 9 5950X, it cuts per-frame texture refreshes from 9.4–9.6 ms to 3.0–4.6 ms, cuts texture served late from 2.1–3.0 avg / 58–77 max frames to 0.7–1.2 avg / 23–35 max frames, eliminates New mem MakeResident stalls (26–27 logged lines → 0), cuts TextureQueue lock wait by 66% (41 ms → 14 ms per 5 s) and TELL lock acquisitions by 95.6% (19,173 → 839 per 5 s), and lowers submitting-thread preparing to 25.3–26.5 ms/frame (with refreshes down to 7.4–8.3 ms/frame):

Frame rate in these cutscenes stays about the same as main (main 23.1–25.1 fps; this branch 21.8–26.1 fps over its runs, within this setup's ±3 fps noise): there the card and the rest of the frame set the pace. The gain is in how soon textures arrive and how little CPU they take; the open world, where textures weigh more, was not reachable unattended. @nick0451's warm three-round test on an RTX 3090 (balcony by the water, card ~95 % busy) agrees: 25.6 fps against main's 25.1, within noise. Where the card is the limit, this PR does not change fps.

  1. Scale texture pass time cap with VRAM and catch-up backlog (59db7fa) — apps/victory/src/play.rs, crates/victory-gpu/src/draw.rs (from trustno1-coder/VIctory-NVIDIA#532).
  2. Pre-filter nothing_new refreshes before ask_ahead and wide_each (e8f7d02) — crates/victory-gpu/src/host.rs: filters out unchanged refreshes in parallel before watch::ask_ahead and worker dispatch.
  3. Skip detiling zeroed non-tail mips and expose hash cadence switches (a6c9174) — crates/victory-gpu/src/texture.rs: fills linear staging with zero instead of detiling unmapped/zeroed mips, and adds VICTORY_TEXTURE_HASH_EVERY and VICTORY_TEXTURE_HOT_FRAMES.
  4. Cache heap.handle per slot and add VICTORY_DUE_FRESH_FIRST (f642186) — crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/descriptor/host.rs.
  5. Combine Batch::copy_spans and Batch::refresh_front step walks (8653fc3) — crates/victory-gpu/src/host.rs.
  6. Verify descriptor record key before host descriptor writes (90f051d) — crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs.
  7. Prioritize fresh textures over rechecks and parallelize ahead staging refresh (5b463d7) — crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/texture/ahead.rs.
  8. Hold only asked pages during submission write-watch askings (bcb4e1f) — crates/victory-gpu/src/host.rs, crates/victory-gpu/src/watch.rs. Adapted from trustno1-coder/VIctory-NVIDIA#697 by @0xkn0wh3r3.
  9. Split VIEW_SHAPES lock, O(1) FxHashMap, and forget() read-check (74223a5, f88e7d5) — crates/victory-gpu/src/descriptor.rs. Adapted from trustno1-coder/VIctory-NVIDIA#666 by @Capt-Speed.
  10. Make texture and staging pool blocks with the pool lock released (9ace3a4) — crates/victory-gpu/src/pool.rs. Adapted from trustno1-coder/VIctory-NVIDIA#661 by @0xkn0wh3r3 (already covers Texture blocks made with the pool's lock let go #683/Staging blocks made with the pool's lock let go #685/Texture and staging blocks made with the pool's lock let go #816).
  11. Add VICTORY_WAIT_RESIDENT=textures to wait for texture residency only (9f3d869) — crates/victory-gpu/src/host.rs. Adapted from trustno1-coder/VIctory-NVIDIA#654 by @bakdakonusuruz.
  12. Compact AtomicU64 bitmask and in-place retain in filter_nothing_new (87694c9) — crates/victory-gpu/src/host.rs: replaces per-element AtomicBool + Arc<Vec<...>> allocation with an AtomicU64 bitmask and in-place retain.
  13. Enable texture residency wait, fresh-first due, and guard-driven hashing in victory play (9af8068) — apps/victory/src/play.rs: sets VICTORY_WAIT_RESIDENT=textures, VICTORY_DUE_FRESH_FIRST=1, VICTORY_TEXTURE_HASH_EVERY=0, VICTORY_TEXTURE_HOT_FRAMES=0.
  14. Make one empty texture block ahead when none is left (2f1dc9c) — crates/victory-gpu/src/pool.rs: spawns victory-block-ahead when VICTORY_RIPE_BLOCKS=0 and no empty texture block remains (VICTORY_BLOCK_AHEAD=0 disables). Adapted from trustno1-coder/VIctory-NVIDIA#684 by @0xkn0wh3r3.
  15. Reduce TextureQueue lock hold time, TELL fallbacks, and zero-work locks (d80e7c7) — crates/victory-gpu/src/descriptor.rs, crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs: dense 32-byte Entry + FastMap, O(N) select_nth_unstable_by_key in Due::ordered_with, QueueMarks atomic writes/has_held, QueueBatch / QueueFlusher, mirror_range, and Tells::BATCH = 64. Adapted from trustno1-coder/VIctory-NVIDIA#797 by @Capt-Speed.
  16. Lock-free no-op refreshes, thin-worker refresh coalescing, and AVX2 copy diff (3f6ca47) — crates/victory-gpu/src/host.rs, crates/victory-gpu/src/shadow.rs, crates/victory-gpu/src/watch.rs: Shadow::copied AtomicU64 array + JournalRead::nothing_new_atomic inside filter_nothing_new, JOURNAL_KEPT atomic fast-path, and HostList::refresh span coalescing. Adapted from trustno1-coder/VIctory-NVIDIA#614 by @wike1701.

Credits

(Also re-tested in warm A/B and left out: trustno1-coder/VIctory-NVIDIA#682 by @0xkn0wh3r3 — alternating VICTORY_AHEAD_BATCH=1 vs =16 gave 26.1 / 23.7 fps off vs 23.5 / 24.0 fps on, texrf 3.0 / 3.4 ms vs 4.3 / 3.8 ms; trustno1-coder/VIctory-NVIDIA#674 by @mint17 — 22.9 / 25.4 fps on vs 26.1 / 23.7 fps off, texrf 3.7 / 3.8 ms vs 3.0 / 3.4 ms; and trustno1-coder/VIctory-NVIDIA#801 by @mint17 — 21.9 / 21.6 fps with vs 23.3 fps without in our opening-cutscene runs.)

Measurements (130 s unattended, --res 1440 --dlss quality, VICTORY_WARMUP_RESTART=0, Enter keys, 0 being made on all 3D ticks)

Environment: Windows 11 (build 26300), RTX 5080, driver 616.92, AMD Ryzen 9 5950X (16 cores, 32 threads).

Configuration 3D ticks 3D FPS med (last 3) Frame ms med preparing med texrf med Served late (avg / max) New mem lines
f88e7d5 (#682 off, BATCH=1) Run 1 12/23 26.1 (33.7, 31.7, 33.1) 38.5 ms 29.6 ms 3.0 ms 0.8 / 29.0 0
f88e7d5 (#682 off, BATCH=1) Run 3 12/23 23.7 (34.6, 34.3, 31.5) 42.3 ms 34.8 ms 3.4 ms 0.9 / 27.0 0
f88e7d5 + #682 (BATCH=16) Run 2 12/23 23.5 (32.8, 34.2, 32.8) 42.6 ms 33.7 ms 4.3 ms 0.9 / 23.0 0
f88e7d5 + #682 (BATCH=16) Run 4 12/23 24.0 (32.8, 33.2, 29.5) 41.8 ms 33.9 ms 3.8 ms 0.8 / 23.0 0
f88e7d5 + #674 Run 5 11/23 22.9 (32.8, 30.5, 34.3) 43.6 ms 34.8 ms 3.7 ms 0.9 / 28.0 0
f88e7d5 + #674 Run 6 12/23 25.4 (31.4, 36.4, 26.8) 39.5 ms 31.5 ms 3.8 ms 0.9 / 23.0 0
3f6ca47 (#684+#797+#614) Run 10 12/23 24.1 (31.1, 35.4, 25.8) 41.5 ms 32.0 ms 4.0 ms 0.8 / 24.0 0
3f6ca47 (#684+#797+#614) Run 11 11/23 21.8 (33.7, 31.3, 32.4) 45.8 ms 35.6 ms 4.6 ms 1.1 / 27.0 0

Submitting-thread preparing per frame steady-state: 28.2–33.0 ms (f88e7d5) → 25.3–26.5 ms (3f6ca47, with refreshes 8.4–10.7 ms → 7.4–8.3 ms).
TextureQueue lock per 5 s: 64,302 takes (19,173 TELL/ask, 41 ms waited) → 36,163 takes (839 TELL/ask, 14 ms waited).

Verification

  • cargo test --workspace --locked → exit 0 (all workspace crates passed, including victory-gpu 470 passed / 0 failed / 37 ignored, victory-shader 293 passed / 0 failed, victory-formats 49 passed / 0 failed / 2 ignored, victory 26+2 passed, victory-core 16 passed, xtask 6 passed / 0 failed).
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings -A clippy::manual_is_multiple_of (and --all-features) → exit 0 (0 warnings). Workspace-wide clippy hits only the 2 pre-existing origin/main lints (crates/victory-gpu/src/shadow.rs:1718 manual_is_multiple_of and crates/victory-shader/src/emit/mod.rs:2768 let_and_return).
  • cargo fmt --all -- --check → exit 1 on pre-existing formatting differences.
  • git diff --check → exit 0.

What Was Not Tested

  • Open-world boat scene: Unattended 130 s runs cover the opening cutscenes; interactive open-world gameplay will be verified by the user using the test/for-user build.

Later additions

AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.

🤖 Generated with Claude Code

465d6a0eac added a commit to 465d6a0eac/VIctory-NVIDIA-Experiment that referenced this pull request Nov 28, 2026
…HADER_OPT=127 measured in the open world; about 13 fps is the 3070 Ti's spot today

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SGw6DM2fQu3WKmCUhFxrrM
@henriazz10 henriazz10 changed the title perf(gpu): textures on time with less CPU: refresh filtering, zero-mip skip, slot checks, plus #697, #666, #661, #654 perf(gpu): textures on time with less CPU: refresh filtering, zero-mip skip, slot checks, plus #697, #666, #661, #654, #684, #797, #614 Nov 28, 2026
@nick0451

nick0451 commented Nov 28, 2026 •

Copy link
Copy Markdown

Tested in the game: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. Release builds, each of #797, #801, #814 and #816 merged on its own onto main at 63b902f.

How: the same frozen save, outdoors on a balcony by the water, about 5,900-6,100 draws a frame (corrected: I first wrote "an interior"). Series S, DLSS Performance, frame generation off, standing still. Each build is started once first as a warm-up (a new build's first start is slow), then the five builds are run in turn, three rounds. Each run is 40 s to settle, then 60 s measured, and the figures are medians of the frame lines. An A/A run of main against itself the same way differed by 2-3%, so smaller differences are noise.

Build fps, 3 runs median frame preparing card busy
main 63b902f 25.5, 24.7, 25.1 25.1 39.8 ms 25.6 ms 95%
#814 25.3, 25.6, 26.4 25.6 39.1 ms 25.1 ms 97%
#801 25.4, 25.8, 25.2 25.4 39.5 ms 25.8 ms 95%
#797 25.3, 25.2, 23.9 25.2 39.7 ms 26.8 ms 95%
#816 24.0, 25.4, 24.2 24.2 41.3 ms 25.0 ms 94%

For this PR: no regression, and +2% fps here, which is within noise. Preparing is 0.5 ms lower, also within noise. The texture-refresh gains you measured are CPU-side, and this card-bound scene cannot show them.

In this scene the card is about 95% busy, so the frame is the card's. Work saved on the CPU side would show in "preparing" more than in fps.

No crashes, device losses or ERROR lines in any build: about 7 minutes in the world each, warm-up included.

Tested with an AI assistant (Claude Code); results are from this PC.

@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the victory-gpu library suite at 3f6ca47 on an NVIDIA Blackwell desktop part:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5 (shared env), debug build.

cargo test -p victory-gpu --lib -- --test-threads=1
470 passed; 0 failed; 37 ignored; 0 measured; 0 filtered out      (exit 0)

All 470 tests pass with 37 ignored, matching the author's victory-gpu count. These are CPU-side tests; the frame-time and texture-latency numbers from the description need a title run and were not reproduced. The thread has runs on RTX 5080 and RTX 3090, but no 5070 Ti.

Not tested: an unattended title run, the open-world boat scene, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

xorpix added a commit to xorpix/VIctory-NVIDIA that referenced this pull request Nov 28, 2026
Reuse upload scratch and filter unchanged graphics copies, reduce descriptor
lock contention, and let safe constant-buffer transfers stay on the GPU.
Keep the optional direct constant-buffer path behind F1. Stabilize static
sampler order for reuse of the driver's shader pipelines. Expose DLSS
Ultra Performance for Series X with the same ultrawide output and HUD.

Ports selected changes from trustno1-coder#548, trustno1-coder#700,
trustno1-coder#814, trustno1-coder#740, trustno1-coder#958 and fxceless/victory-fork@9e90746. The source bundle
preserves the individual commits and credit.
xorpix added a commit to xorpix/VIctory-NVIDIA that referenced this pull request Nov 28, 2026
Return the renderer to the proven ultrawide reflection tree before the
submission optimization batch. Add render-only launch tests with the
frame-generation proxy absent, and show the DLSS sizes in F3.

Prioritize pending and new textures over rechecks, revalidate deferred
uploads after GPU writes, and expose an optional larger indirect budget.
Based on trustno1-coder#33, trustno1-coder#814, and trustno1-coder#72. The source bundle
keeps the individual commits and credit.
@henriazz10

Copy link
Copy Markdown
Contributor Author

Thanks @nick0451 for the careful five-way comparison (warm-up, three rounds, an A/A control), and @Aniseto for the test run on a 5070 Ti.

nick0451's result matches what we saw in the cutscenes: with the card about 95 % busy, the frame belongs to the card, and the texture work saved on the CPU can't show up as fps. Where it should help is scenes bound by the submitting thread, like the open world on 6-8 core CPUs, and how soon textures arrive (served late and new-memory waits in the description), not the frame rate of a card-bound scene. I'll add a line to the description saying that fps is unchanged where the card is the limit.

🤖 Generated with Claude Code

xorpix added a commit to xorpix/VIctory-NVIDIA that referenced this pull request Nov 28, 2026
Carry the descriptor record used in staging through the list and upload-ahead completion paths. Ignore superseded queue work, alternate new writes with missing-mip retries, and keep complete-upload rechecks moving under the existing budgets.

The record validation builds on the work in trustno1-coder#814.
@bakdakonusuruz

Copy link
Copy Markdown
Contributor

Tested on an RTX 4090 24 GB (driver 621.40), i7-13700K, 32 GB RAM, Windows 11 26200. Release builds: main at 63b902f and this PR at 3f6ca47, each in its own worktree with its own cache folder. Series X at 2560x1440, DLSS balanced, frame generation on. Route: a new game, the first 4 minutes of gameplay, stopped by a script.

The four new defaults reach victory play only, not the script launcher

9af8068 adds VICTORY_WAIT_RESIDENT=textures, VICTORY_DUE_FRESH_FIRST=1, VICTORY_TEXTURE_HASH_EVERY=0 and VICTORY_TEXTURE_HOT_FRAMES=0 to SETTINGS in apps/victory/src/play.rs. scripts\play-foxhound.ps1 clears the VICTORY_* switches left in the window and sets its own table, and that table does not get the four (no hit for any of them in scripts\ or the .cmd files). So a start through the script runs this PR's code with its new switches off. The comment over SETTINGS says the script "has the same"; after this PR it does not.

I start through play-foxhound.ps1, and the run shows it. The launcher's log lists 63 switches and none of the four, and the new-memory waits stay where main has them:

main 63b902f this PR, started by the script
new-memory waits 53,000, 17.3 s, longest 1,029 ms 56,000, 16.5 s, longest 1,275 ms
mapping waits 39,800, 4.1 s 40,600, 4.1 s

With VICTORY_WAIT_RESIDENT=textures set, the same route on this PC gives 1,000 to 1,999 waits and 0.7 s (the #654 A/B). Adding the four lines to play-foxhound.ps1 would close the gap.

What the run shows otherwise

Switches off, so this is the unconditional part of the PR only:

  • Uploads ahead get through more often: 0.92 turned down per upload on main, 0.49 here. The longest asking-to-there goes from 46 ms to 14 ms, and about 13 % more textures are uploaded in the same 4 minutes.
  • No errors and no device loss in either run. I saw no artifacts in the PR run; main had some wall textures missing.
  • Frame time: no claim yet. Both builds had cold pipeline caches after a 1-minute warm-up, and both show 200 to 300 ms windows while pipelines were being made. The medians were 44 ms (main) and 39 ms (PR).

I will repeat with warm caches, once as the script starts it and once with the four switches set by hand, and post the numbers here.

VICTORY_WAIT_RESIDENT=textures, VICTORY_DUE_FRESH_FIRST=1,
VICTORY_TEXTURE_HASH_EVERY=0 and VICTORY_TEXTURE_HOT_FRAMES=0 were added to
SETTINGS in apps/victory/src/play.rs only; the script clears VICTORY_* and
sets its own table, so a start through it ran with them off. Reported by
@bakdakonusuruz.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@henriazz10

Copy link
Copy Markdown
Contributor Author

Thanks @bakdakonusuruz, you're right, and the table makes it clear. play-foxhound.ps1 clears the VICTORY_* switches and sets its own table, so a start through the script ran this PR with the four new defaults off.

Fixed in 1b1de3d: the script's table now has VICTORY_WAIT_RESIDENT=textures, VICTORY_DUE_FRESH_FIRST=1, VICTORY_TEXTURE_HASH_EVERY=0 and VICTORY_TEXTURE_HOT_FRAMES=0, the same values as SETTINGS in play.rs. The script still parses, and nothing else in it changed.

Your switches-off run is still useful: it isolates what the PR does unconditionally (0.92 to 0.49 turned down per upload, longest asking-to-there 46 to 14 ms, about 13 % more textures in the same 4 minutes). I'm looking forward to the warm-cache numbers with the script as it is now.

🤖 Generated with Claude Code

An AtomicBool beside HostHeap::away, set and cleared under its lock, lets
texture_slot_here return at once in the usual case of an empty map.

Based on trustno1-coder#1242 by @qlfu (its other two parts,
the dense texture queue and Tells batches of 64, are already in this branch
through trustno1-coder#797).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trustno1-coder

Copy link
Copy Markdown
Owner

Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

@henriazz10

Copy link
Copy Markdown
Contributor Author

Understood, thanks @trustno1-coder. With about 100 pull requests merged today a rebase here would be most of the work anyway. I'll rebase the texture changes onto the current main, run the checks again, and open a new pull request that links back to this one and keeps the credits.

🤖 Generated with Claude Code

krolyxon added a commit to krolyxon/VIctory-NVIDIA-proton that referenced this pull request Nov 28, 2026
…VERY=0 / HOT_FRAMES=0)

Under Proton, skin looked plastic with them off: textures the title rewrites
without a guard noticing were never hashed again. No frame-rate difference
was measured from them here. Back to the texture.rs defaults (8 and 64).
krolyxon added a commit to krolyxon/VIctory-NVIDIA-proton that referenced this pull request Nov 28, 2026
Conflicts:
- watch.rs: trustno1-coder#933's protect_here/protect_run split kept, upstream's soft
  views parameter passed through both.
- shadow.rs: upstream's has_pending and PageMerge landing loop taken (on
  trustno1-coder#1298's copied tuple); trustno1-coder#1184's lazy landing applied to upstream's
  outside_sorted_into parts.
- pool.rs: trustno1-coder#814's take_from_with (one empty block made ahead) kept; its
  base is the same trustno1-coder#661 change upstream merged.
- card_steps.rs: upstream's taken whole (VICTORY_PLACED_FILLS, trustno1-coder#740);
  trustno1-coder#1298's card_steps part dropped.
- draw.rs: upstream's trustno1-coder#532 values; trustno1-coder#814's cached slot handle kept inside
  upstream's rest() timing.
- descriptor/host.rs: upstream's TextureQueue ordering taken whole; trustno1-coder#814's
  VICTORY_DUE_FRESH_FIRST and its play.rs default dropped. A test module
  both sides added was kept once.
- emit/mod.rs, send.rs: both sides kept.
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.

5 participants