Skip to content

GPU: hash textures that changed lately at every check (fixes startup flicker) - #63

Closed
arminkhaleghirod wants to merge 1 commit into
fxceless:mainfrom
arminkhaleghirod:texture-guard-live
Closed

arminkhaleghirod wants to merge 1 commit into
fxceless:mainfrom
arminkhaleghirod:texture-guard-live

Conversation

@arminkhaleghirod

Copy link
Copy Markdown

Fixes #39.

The texture guard (VICTORY_TEXTURE_GUARD, on by default) skips a texture in view memory unless it saw a write, and hashes it only every eighth frame. It can't see writes made through another view, which is how the startup animation's frames get filled. So the three textures it cycles through were each refreshed only now and then, and the animation jumped back and forth between old frames.

Now a texture whose hash changed is hashed at every check for the next 30 frames. Animated textures stay current, and static ones keep the guard's savings.

Frames 550 to 1000, on an RTX 4080 with the Series X profile. A jump back is a frame where n and n+2 match but n+1 doesn't.

Moving frames Jumps back
main 25 13
main, VICTORY_TEXTURE_GUARD=0 29 0
this PR 11 0

Also confirmed by eye: no flicker. cargo test -p victory-gpu passes, and clippy is clean.

The texture guard skips a texture in view memory unless it saw a write,
hashing it only every eighth frame. It cannot see writes through another
view, so a ring of video frames filled that way was shown out of order:
the startup animation flickered back and forth. A texture whose hash
changed is now hashed at every check for 30 frames.
@rostaddotcc

Copy link
Copy Markdown

Checked this on a Linux host (CachyOS, RX 7900 XT/RDNA3, Mesa 26.3.1 RADV) at 059ab35:

  • cargo xwin build --release -p victory --target x86_64-pc-windows-msvc — clean, 19.4 s.
  • cargo xtask policy — 169 files ok.
  • cargo test -p victory-shader — 171 passed, 0 failed, 2 ignored.
  • cargo test -p victory-gpu --lib does not compile on Linux — cannot find function 'host_resource', cannot find 'host' in 'crate', cannot find 'texture' in 'crate'. That is pre-existing, not from this PR: main fails the same three errors, because the test module references items behind #[cfg(windows)]. So nobody can run the victory-gpu unit tests off Windows today, which is worth knowing before merging a victory-gpu change on the strength of "tests pass".

The change itself reads right to me: the guard misses writes made through another view, and a frame-ring texture is exactly that shape. Two things I would want in the PR before merge:

  1. The cost is now per-check for the lifetime of a changing texture. LIVE_FRAMES = 30 is a sliding window, so a texture that changes every frame (the video ring this is aimed at) has changed set on every check and therefore stays "live" forever — it is hashed on every check from then on, not for 30 frames. That may well be the right trade (a 4K texture is 33 MB to hash at ~20 GB/s of mapped reads, so ~1.5 ms), but the comment reads as if it were bounded.
  2. Say what it costs in the log. copystat's TexChanged will jump when the fix is active; quoting that number before/after on one machine would let the next person tell "fixed the flicker" from "fixed the flicker and halved the texture lane".

If it helps, this rig can run the before/after on the loading phase (where the texture lane is already 146–907 ms/frame) and quote TexChanged, the texture lane and the flicker with VICTORY_RELAY=2 VICTORY_LATE_WAIT=0 versus VICTORY_RELAY=0. Not run yet.

@adriaespii

Copy link
Copy Markdown

Independent test run on commit 059ab35 (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 496 passed, 0 failed, 7 ignored (victory-gpu: 110 passed, 0 failed, 1 ignored; victory-shader: 210 passed, 0 failed, 2 ignored)
  • Not tested: live startup animation run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

@arminkhaleghirod

Copy link
Copy Markdown
Author

Closing in favour of #58: same fix, opened first, and it also covers new textures and has an off switch. Tested it, it scores clean (numbers on #58). Thanks @rostaddotcc for the review. The cost point applies there too.

@rostaddotcc

Copy link
Copy Markdown

Correcting my earlier note: the victory-gpu suite can run against this PR on Linux, and now I have. The recipe matters — with Wine's d3d12 stub the GPU tests return early and the run is vacuous, so these results come from vkd3d-proton serving d3d12 and Microsoft's d3dcompiler_47 as the native override:

WINEDLLOVERRIDES="d3d12=n;d3d12core=n;dxgi=n;d3dcompiler_47=n" wine victory_gpu-<hash>.exe
tree result
main (4e17478) 109 passed, 1 failed, 1 ignored
this PR (059ab35) 109 passed, 1 failed, 1 ignored

The one failure is the same on both and is not yours: pipeline::library::tests::a_rejected_blob_gives_an_empty_library panics at library.rs:731 — open() returns None for a garbage blob on vkd3d-proton where native D3D12 hands back an empty library. So on this platform the change is at parity with main, which is what I can say about it; the flicker itself needs a run with VICTORY_RELAY=2 VICTORY_LATE_WAIT=0 versus VICTORY_RELAY=0, and I have not done that one.

@ezbyDev

ezbyDev commented Nov 24, 2026

Copy link
Copy Markdown

Confirmed on AMD: RX 9060 XT 16 GB (RDNA4), Adrenalin driver 32.0.32029.2010, i7-9700K, Windows 11 Pro 26300, diag build, Series X profile, default switches plus VICTORY_RELAY=2 and the RDNA4 skip list from #3.

Build Startup star animation and intro
main 4e17478 flashes and jumps back and forth, as in #39
main, VICTORY_TEXTURE_GUARD=0 smooth
main + this PR (059ab35) smooth

Judged by eye over several runs, no frame captures. I also tried an extra change on top (making the host copy at once when a live slot gets a view of a texture that has no copy yet, for VICTORY_LAZY_TEXTURES): no visible difference with this PR, so I'm not proposing it.

AI-assisted (Claude Code, Claude Opus 5.5): bisected with the switches and wrote this; runs on my own machine.

@dkdknight

Copy link
Copy Markdown

Tested on an RTX 5080 (merged with #80, #71, #81, #77 and #38 on 4e17478): the loading-screen images no longer glitch. The person at the machine had seen them misbehave on every earlier build. No other visible change in the world, no device removal. Frame time unchanged: 221 ms at the same spot, against 202 ms for the same build without #80/#63 (one run each, within this machine's run-to-run spread).

Setup: NVIDIA GeForce RTX 5080 16 GB, driver 621.14, i9-13900KF, Windows 11 26200, release build, Series X profile. cargo test --release -p victory-gpu --lib on the merged tree: 113 passed, 0 failed, 1 ignored.

AI use: Claude Code, Claude Opus 5.5 merged, built, ran the tests and the game, and wrote this comment. The visual check is the user's.

VlREX added a commit to VlREX/victory-fork that referenced this pull request Nov 25, 2026
…uploads

Credit NuraadGit (fxceless#159), ryotdev (unlocked reads), adritoyalser (fxceless#80), arminkhaleghirod (fxceless#39/fxceless#63), and brunofgmag (geometry A/B). Preserve inline placement for correctness testing. Native validation pending.
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.

Startup star animation flashes and jumps back and forth (upstream VIctory is smooth)

5 participants