Skip to content

Textures picked by index: the recheck's fingerprint reads every mip of every slice - #559

Open
NickJBc wants to merge 1 commit into
fxceless:mainfrom
NickJBc:recheck-every-mip
Open

NickJBc wants to merge 1 commit into
fxceless:mainfrom
NickJBc:recheck-every-mip

Conversation

@NickJBc

@NickJBc NickJBc commented Nov 25, 2026

Copy link
Copy Markdown

Follow-up to the known gap in a803c87 ("the fingerprint samples the start, middle and end of the memory, so a texture whose other parts arrive later is still missed").

The gap

The recheck compares a fingerprint of 16 KiB at the start, middle and end of a texture's memory. Each slice stores its mips smallest first, with mip 0 last, so:

  • For a plain 2D texture the three windows land on the tail and mip 0 only. Mips 1 and 2 (about a quarter of the bytes) and the mips between them are never read.
  • For an array or cube map the windows see two slices of six or more.

A mip or slice that arrives after the upload in one of those places is still missed.

The change

  • Layout::sample_ranges (victory-formats): one range at the start of each mip of each slice, with tail mips at their places in the tail block. Each range is 1 KiB, at most 64 per texture, spread evenly over slices and mips when there are more. Adjacent ranges are joined into one read.
  • victory-gpu: the ranges are worked out from the staging buffer's layout at upload and kept with the slot (Waiting::mips). They're read on top of the three existing windows, so the new fingerprint sees every change the old one saw.
  • Cost per look: a 4096² texture with all its mips takes 10 extra reads (12 KiB); a 512 cube map with 10 mips takes 40 reads (52 KiB).
  • Switch: VICTORY_HEAP_RECHECK_MIPS=0 reads the three windows alone, and the fingerprint is then identical to before.

Windows go at a mip's start, not its centre, because a tail mip may fill only the first part of its place in the tail block. A centred window missed mip 5 of a 2048² BC texture in the test below.

Checked

  • victory-formats tests on Linux, 27 passing, 3 of them new:
    • Every mip of every slice, tail mips included, has a range over bytes its elements are stored at. The bytes are found through Layout::offset, not through the mip offsets sample_ranges uses. The cases cover 2D BC and RGBA, cube, array, linear and a 4096×64 texture.
    • Ranges are ordered, apart, bounded and capped for every swizzle mode, XOR modes included.
    • Capped ranges spread over the slices of a 64-slice array.
  • The Windows target builds and passes clippy with and without diagnostics.

Not checked

Not run in the game yet, so it is unknown how many more stale textures this catches. The changed after its upload warning count, with and without VICTORY_HEAP_RECHECK_MIPS=0, would show it.

#555 also touches descriptor/host.rs and texture.rs (view-memory guards, a different path); they may need a small rebase against each other.

…f every slice

The recheck added in a803c87 compares a fingerprint of 16 KiB at the
start, middle and end of a texture's memory. Each slice stores its mips
smallest first with mip 0 last, so for a plain 2D texture those windows
land on the tail and mip 0 only: mips 1 and 2 (about a quarter of the
bytes) and every mip in between are never read. In an array or cube map
they see two slices of six or more. A mip or slice that arrived after the
upload there was still missed (the commit's own "known gap").

Layout::sample_ranges (victory-formats) gives one range at the start of
each mip of each slice, tail mips at their places in the tail block: 1 KiB
each, at most 64 per texture, spread evenly over slices and mips when
there are more, adjacent ranges joined into one read. The ranges are
worked out from the staging buffer's layout at upload, kept with the slot,
and read on top of the three windows, so the new fingerprint sees every
change the old one saw. A 4096-square texture with all its mips: 10 reads,
12 KiB more per look; a 512 cube map with 10 mips: 40 reads, 52 KiB.

VICTORY_HEAP_RECHECK_MIPS=0 keeps the three windows alone (the
fingerprint is then the same as before).

Checked: victory-formats tests on Linux, including a test that every mip
of every slice (tail mips too) has a range over bytes its elements are
stored at, found through Layout::offset rather than the mip offsets; the
Windows target builds and passes clippy with and without diagnostics.
Not yet run in the game.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYNyBknqrxMVw1v7HYK6J4
@Victorywillbeours222

Copy link
Copy Markdown

A count of the gap this PR describes, from the game.

RTX 5080 16 GB, Ryzen 7 5800X, diag build of f85101b with its frame-rate switches, Series S profile. Two 10-minute runs through the prologue (the diner, the title card, the cell).

We read the textures picked by index whole as well (up to 8 MiB) at each recheck. We counted a change as "only between the windows" when the three 16 KiB windows matched but the whole did not:

run changes found at a recheck only between the three windows
f85101b + the switches 34,457 9,714 (28 %)
same, with #868's VICTORY_SKIP_WC_COMPARE=1 28,590 9,005 (31 %)
  • More than a quarter of what the title changes in these textures is invisible to the current fingerprint.
  • The case we saw on screen is the HUD's glyph cache. The cell's button prompts showed only a few of their letters until the whole texture was read.

The change we measured with is #956: a whole read up to a set size, and rechecks that go on past the fifth. It is meant to sit beside this PR, not replace it: your per-mip ranges for big textures, a whole read for small atlases. We're happy to rebase it onto this one if it goes in first.

Numbers only; no captures.

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.

2 participants