Textures picked by index: after their last recheck they are watched for writes, not let go #4161

Closed
github-bot wants to merge 1 commit from github-bot/gh-4161 into main AGit
Owner

@⁠Lyrnc on GitHub · 2026-11-30 16:53 UTC · original
Lyrnc:fix/texture-recheck-stale → main · +733 −10 · 5 files · 1 commits · closed without merging

Possibly related, cause not confirmed (see "Not confirmed"): #3409, #3559, #1167, and #3829 #3676 #3288 #3526 #3554 #3882

What it changes

What was wrong. A texture picked by index that is uploaded whole gets five more looks after the upload (RECHECK_FRAMES = [4, 12, 40, 120, 400]; each look is a 48 KiB fingerprint). After the fifth, about 576 frames or 20-30 s in, the slot is Told::Done(None): it leaves the queue and is never checked again. If the title later rewrites that texture's memory and nothing reports it (no descriptor write, no remap, no page write that reaches the queue), the host copy keeps the old bytes until the slot is written again, which may be never. #3409 (a parked car solid green, at least 200 "a texture picked by index changed after its upload with nothing to tell of it" warnings) and #3559 (that counter past 1,000, wrong-colour ground patches) look like this case, but that is not proven yet.

What this does. After its last look the slot is no longer dropped. Its memory is watched by the write tracking that already exists for title memory, crate::watch::writes_since: the kernel's write watch, or the guards on view memory. That is the same path Staging::refresh_timed uses for textures read through tables. When the tracking reports a write, the slot is due again the same way texture_slots_remapped makes a slot due. Its upload compares the bytes first (texture::unchanged) and the schedule starts over.

  • descriptor/retired.rs (new): RetiredWatch, the slots that are out of the queue after their last look. Each has a record (address, bytes, last fingerprint, the tracking's asking number), and a FIFO holds the frame from which each is next asked about.
  • draw.rs: the last look takes the tracking's asking for the memory before its fingerprint (retired::retire). A write after the fingerprint is then news to the tracking, and a write before it is in the fingerprint. If the look finds the texture as uploaded, the pass tells Told::Retire(..) where it used to tell Told::Done(None). The decision is now a small pure helper (unchanged_told, last_look). If another thread is already asking about the same memory, the last look is made again 16 frames later, so the pass never waits.
  • TextureQueue::retire takes the slot out as done does and hands it to the watch. TextureQueue::put drops it from the watch when it comes back into the queue (written again or made due); it is retired again after its new looks.
  • HostHeap::texture_slots_retired_written runs once a frame next to texture_slots_remapped. It asks the tracking about at most 128 retired slots, each at most every 16 frames, within 0.5 ms, without holding the queue's lock while it asks. Slots found written are made due with TextureQueue::changed. Slots that tables read lately stay watched, because the draws bring those up to date, and become due once tables stop reading them.
  • Memory nothing tracks (writes_since returns None) falls back to the fingerprint: at most 4 a pass, and each slot at most every 400 frames (192 KiB a frame at most).
  • A new 5-second line: textures picked by index after their last look, watched for writes: N slots now; since the start: retired (untracked) / askings / found written and due again / fingerprints.
  • VICTORY_RETIRED_WATCH=0 gives the old behaviour exactly: the slot is done after its last look.

Cost. The schedule ends so that slots are not fingerprinted for ever on the thread that records the frame (#886 measured about 30 MB a frame of turn hashes on table textures, which found nothing). This change adds no fingerprint reads for tracked memory. Each watched slot costs one tracking query about every 16 frames. For guarded view memory that nothing wrote, that is the lock-free published bits and one journal lookup. For write-watched memory, it is one kernel GetWriteWatch over the range. The table path makes the same query for each staged texture at every check. A pass is bounded by count (128) and time (0.5 ms). Guarding means the title's next write to a retired texture's 64 KiB blocks faults once, which is how buffers and table textures are tracked already.

How it was tested

  • GPU and profile: RTX 5080 16 GB, Windows 11. No in-game run yet. Our bench has an A/B queued on one diagnostics build of this branch: VICTORY_RETIRED_WATCH=0 against the default, Series S 720p DLSS Quality, standing and walking. It compares the warning count, the new line, frame times, and fixed-time shots. I will post the results here.
  • Before: a slot whose memory is written after its fifth look stays out of the queue, with its old upload, for good.
  • After (unit level, synthetic): the same slot is due again within 16 frames of the write, as a new write, and its memory is not read while watched.
  • New tests:
    • descriptor::host::tests::a_slot_written_after_its_last_look_is_due_again: five looks find the slot unchanged, it leaves the queue at frame 576, a fake write tracking reports a write at frame 650, and the slot is due by frame 666. It fails if the slot is never due again or if watched memory is fingerprinted.
    • a_retired_slot_written_again_leaves_the_watch: a slot written again is queued and not watched, and a retire for an old write changes nothing.
    • draw::recheck_schedule_tests (3): the schedule is unchanged; the fifth look retires the slot with its fingerprint; with the switch off it is Done as before; a busy tracking retries; painted slots (VICTORY_PAINTED_EVERY) are never retired.
    • descriptor::retired::tests (8): order and per-pass budget; written, later and stale entries; compaction; tracked memory is asked and never read; untracked memory is fingerprinted rarely and a few a pass; memory that stops being tracked is fingerprinted at once.
  • cargo test -p victory-gpu --lib --locked on top of main 84bd61e2: 1144 passed, 2 failed, 66 ignored. All 13 new tests pass. The two failures are in files this PR does not touch, and they come from main: list::thin::tests::bindings_record_no_work ("a call is in no list", 47 vs 49) and shader_cache::tests::every_switch_of_the_translator_is_in_the_key (VICTORY_ORACLE_RUNS is no longer read by the translator).
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, and the same with --all-features: nothing in the files this PR changes. The only errors are main's own: shadow.rs ranged is never used, host.rs:5092 seed % 3 == 0 (manual_is_multiple_of), and, with all features, copystat.rs mb is never used.
  • cargo xtask policy: one violation, from main: crates/victory-shader/src/native.rs has a 560-character hex run. This PR adds no data.
  • For shader changes, the wave sizes tested: no shader changes.
  • cargo test passed for the crates it touches: the new tests yes. victory-gpu as a whole still has main's two failures listed above.

Not confirmed

  • In game, nothing yet. I don't know whether the green car or the ground patches go away. #3409 also has another theory: a buffer refresh puts the title's older bytes back over card writes. If that is the cause, this change does not fix it.
  • Not measured: how many slots end up watched in play, and what the sweep costs per frame. The bounds above come from the code, not from a measurement.
  • A write the tracking itself does not see (through a view of the page beyond what the view guard covers) is still missed after the last look. For table textures, #886 counted 0 such changes in about 30 minutes.

Checked for overlap

  • I searched the open pull requests for "recheck", "stale texture", "green", "fingerprint" and Told::Done. None keeps checking slots after the last look. Related: #2651 (open: tests for the painted schedule. It also extracts this decision into a helper, so the two would conflict trivially), #2605 (open: batches recheck claims), #3551 (open: requeues remapped slots after the table grace), #1573 and #2104 (merged: VICTORY_PAINTED_EVERY, VICTORY_FULL_FINGERPRINT).

AI use

Claude Code (Claude Opus 5.5) wrote this change, its tests and this description. No game files or game data are included.

🤖 Generated with Claude Code

**@⁠Lyrnc** on GitHub · 2026-11-30 16:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4161) `Lyrnc:fix/texture-recheck-stale` → `main` · +733 −10 · 5 files · 1 commits · closed without merging Possibly related, cause not confirmed (see "Not confirmed"): #3409, #3559, #1167, and #3829 #3676 #3288 #3526 #3554 #3882 ## What it changes **What was wrong.** A texture picked by index that is uploaded whole gets five more looks after the upload (`RECHECK_FRAMES = [4, 12, 40, 120, 400]`; each look is a 48 KiB fingerprint). After the fifth, about 576 frames or 20-30 s in, the slot is `Told::Done(None)`: it leaves the queue and is never checked again. If the title later rewrites that texture's memory and nothing reports it (no descriptor write, no remap, no page write that reaches the queue), the host copy keeps the old bytes until the slot is written again, which may be never. #3409 (a parked car solid green, at least 200 "a texture picked by index changed after its upload with nothing to tell of it" warnings) and #3559 (that counter past 1,000, wrong-colour ground patches) look like this case, but that is not proven yet. **What this does.** After its last look the slot is no longer dropped. Its memory is **watched by the write tracking that already exists for title memory**, `crate::watch::writes_since`: the kernel's write watch, or the guards on view memory. That is the same path `Staging::refresh_timed` uses for textures read through tables. When the tracking reports a write, the slot is due again the same way `texture_slots_remapped` makes a slot due. Its upload compares the bytes first (`texture::unchanged`) and the schedule starts over. - `descriptor/retired.rs` (new): `RetiredWatch`, the slots that are out of the queue after their last look. Each has a record (address, bytes, last fingerprint, the tracking's asking number), and a FIFO holds the frame from which each is next asked about. - `draw.rs`: the **last** look takes the tracking's asking for the memory before its fingerprint (`retired::retire`). A write after the fingerprint is then news to the tracking, and a write before it is in the fingerprint. If the look finds the texture as uploaded, the pass tells `Told::Retire(..)` where it used to tell `Told::Done(None)`. The decision is now a small pure helper (`unchanged_told`, `last_look`). If another thread is already asking about the same memory, the last look is made again 16 frames later, so the pass never waits. - `TextureQueue::retire` takes the slot out as `done` does and hands it to the watch. `TextureQueue::put` drops it from the watch when it comes back into the queue (written again or made due); it is retired again after its new looks. - `HostHeap::texture_slots_retired_written` runs once a frame next to `texture_slots_remapped`. It asks the tracking about at most 128 retired slots, each at most every 16 frames, within 0.5 ms, **without** holding the queue's lock while it asks. Slots found written are made due with `TextureQueue::changed`. Slots that tables read lately stay watched, because the draws bring those up to date, and become due once tables stop reading them. - Memory nothing tracks (`writes_since` returns `None`) falls back to the fingerprint: at most 4 a pass, and each slot at most every 400 frames (192 KiB a frame at most). - A new 5-second line: `textures picked by index after their last look, watched for writes: N slots now; since the start: retired (untracked) / askings / found written and due again / fingerprints`. - `VICTORY_RETIRED_WATCH=0` gives the old behaviour exactly: the slot is done after its last look. **Cost.** The schedule ends so that slots are not fingerprinted for ever on the thread that records the frame (#886 measured about 30 MB a frame of turn hashes on table textures, which found nothing). This change adds **no fingerprint reads for tracked memory**. Each watched slot costs one tracking query about every 16 frames. For guarded view memory that nothing wrote, that is the lock-free published bits and one journal lookup. For write-watched memory, it is one kernel `GetWriteWatch` over the range. The table path makes the same query for each staged texture at every check. A pass is bounded by count (128) and time (0.5 ms). Guarding means the title's next write to a retired texture's 64 KiB blocks faults once, which is how buffers and table textures are tracked already. ## How it was tested - GPU and profile: RTX 5080 16 GB, Windows 11. **No in-game run yet.** Our bench has an A/B queued on one diagnostics build of this branch: `VICTORY_RETIRED_WATCH=0` against the default, Series S 720p DLSS Quality, standing and walking. It compares the warning count, the new line, frame times, and fixed-time shots. I will post the results here. - Before: a slot whose memory is written after its fifth look stays out of the queue, with its old upload, for good. - After (unit level, synthetic): the same slot is due again within 16 frames of the write, as a new write, and its memory is not read while watched. - New tests: - `descriptor::host::tests::a_slot_written_after_its_last_look_is_due_again`: five looks find the slot unchanged, it leaves the queue at frame 576, a fake write tracking reports a write at frame 650, and the slot is due by frame 666. It fails if the slot is never due again or if watched memory is fingerprinted. - `a_retired_slot_written_again_leaves_the_watch`: a slot written again is queued and not watched, and a retire for an old write changes nothing. - `draw::recheck_schedule_tests` (3): the schedule is unchanged; the fifth look retires the slot with its fingerprint; with the switch off it is `Done` as before; a busy tracking retries; painted slots (`VICTORY_PAINTED_EVERY`) are never retired. - `descriptor::retired::tests` (8): order and per-pass budget; written, later and stale entries; compaction; tracked memory is asked and never read; untracked memory is fingerprinted rarely and a few a pass; memory that stops being tracked is fingerprinted at once. - `cargo test -p victory-gpu --lib --locked` on top of main 84bd61e2: 1144 passed, 2 failed, 66 ignored. All 13 new tests pass. The two failures are in files this PR does not touch, and they come from main: `list::thin::tests::bindings_record_no_work` ("a call is in no list", 47 vs 49) and `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` (`VICTORY_ORACLE_RUNS` is no longer read by the translator). - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`, and the same with `--all-features`: nothing in the files this PR changes. The only errors are main's own: `shadow.rs` `ranged` is never used, `host.rs:5092` `seed % 3 == 0` (manual_is_multiple_of), and, with all features, `copystat.rs` `mb` is never used. - `cargo xtask policy`: one violation, from main: `crates/victory-shader/src/native.rs` has a 560-character hex run. This PR adds no data. - For shader changes, the wave sizes tested: no shader changes. - `cargo test` passed for the crates it touches: the new tests yes. victory-gpu as a whole still has main's two failures listed above. ### Not confirmed - **In game, nothing yet.** I don't know whether the green car or the ground patches go away. #3409 also has another theory: a buffer refresh puts the title's older bytes back over card writes. If that is the cause, this change does not fix it. - Not measured: how many slots end up watched in play, and what the sweep costs per frame. The bounds above come from the code, not from a measurement. - A write the tracking itself does not see (through a view of the page beyond what the view guard covers) is still missed after the last look. For table textures, #886 counted 0 such changes in about 30 minutes. ## Checked for overlap - [x] I searched the open pull requests for "recheck", "stale texture", "green", "fingerprint" and `Told::Done`. None keeps checking slots after the last look. Related: #2651 (open: tests for the painted schedule. It also extracts this decision into a helper, so the two would conflict trivially), #2605 (open: batches recheck claims), #3551 (open: requeues remapped slots after the table grace), #1573 and #2104 (merged: `VICTORY_PAINTED_EVERY`, `VICTORY_FULL_FINGERPRINT`). ## AI use Claude Code (Claude Opus 5.5) wrote this change, its tests and this description. No game files or game data are included. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
After the fifth look again (RECHECK_FRAMES, about 576 frames after the
upload) a slot left the queue for good: a texture the title wrote again
later, with no descriptor written, nothing mapped and nothing told, kept
its old host copy for the rest of the run.

The last look now takes the write tracking's asking for the memory
(watch::writes_since: the kernel's write watch, or the guards of view
memory) before its fingerprint, and the slot is retired to a watch
(descriptor::retired) instead of done. Once a frame up to 128 retired
slots are asked about, within 0.5 ms and without the queue's lock; the
ones found written are due again as memory written under them, and their
upload compares the bytes first. Tracked memory is never fingerprinted
again; memory nothing tracks falls back to a fingerprint every 400
frames, 4 a pass. A slot back in the queue leaves the watch.
VICTORY_RETIRED_WATCH=0: done after the last look, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 16:57:56 +00:00
Author
Owner

@⁠Lyrnc on GitHub · 2026-12-01 02:47 UTC · original

Bench result for this PR: an A/B by switch in one diagnostics build of d6b7d9db (on main 84bd61e2), run overnight. RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11. Series S, 720p, DLSS Quality, frame generation off (as #3409). Same save, own shader cache, warmed first.

  • a = VICTORY_RETIRED_WATCH=0, the old behaviour.
  • b = default: watched after the last look.
  • Runs: one each standing still (420 s), one each on a 5-minute scripted walk.
run fps frame ms p50 / p90 / p99 >50 ms /1000 >100 ms /1000 draws/frame "changed after its upload with nothing to tell of it" (running total at the world / at the end) watched slots (max / at the end) retired since start (untracked) askings of the write tracking found written and due again
a, standing 30.0 31.7 / 44.4 / 59.1 47 0.8 6,263 4 / 54 - - - -
b, standing 30.2 31.8 / 44.6 / 59.2 52 1.0 6,182 200 / 3,001-3,999 27,012 / 23,024 77,128 (0) 2,422,296 35,956
a, walk 26.4 35.6 / 56.1 / 74.1 178 3.5 7,796 11 / 4,001-4,999 - - - -
b, walk 27.0 34.6 / 52.2 / 69.3 124 1.1 7,480 200 / 3,001-3,999 26,889 / 24,226 89,907 (0) 2,600,379 50,108

The warning is written for the first 200 changes and then every 1,000th, so its running total (changed=) is known only to that step. Fingerprints of untracked memory: 0 in both b runs. No device removed, DRED or "did not close" line in any run.

What this shows

  • Standing still (the clean case), b finds and re-uploads changed textures that a never looks at again. a ends with 54 changes caught in 420 s, all inside the first looks. b ends with 3,001-3,999. b had already caught 200 by the time the world appeared, against 4 for a: those are slots written after their 5th look during loading. The watch made 35,956 slots due again. Most then matched their fingerprint, and about 3,000-4,000 had really changed.
  • The cost is not visible in frame times. Standing: p50 / p90 / p99 within 0.2 ms, frames over 50 ms 47 against 52 per 1,000. Walking, b came out better (124 against 178), but the walk's scenes differ (draws ±4 %), so read that as "not worse", not as a gain. The watch held 23,000-27,000 slots and asked the write tracking ~2.4-2.6 million times per run.

What it does not show

  • The pictures. Shots at world+60 and +240 s (the 400-s shot fell after the run's end) show no flat-green or wrong-colour surface in either arm. But the camera framing differed between the a and b runs, and the parked car from #3409 is not in frame, so this is not a picture comparison.
  • On the walk, the totals are no measure of this PR: a 4,001-4,999 against b 3,001-3,999. On a walk most changes come from new textures inside their first looks, which both arms catch the same way.
  • Not run: other GPUs, Series X profiles, a session long enough for a slot to be written many times after retiring.

AI use: Claude Code (Claude Opus 5.5) ran these on our bench queue, parsed the run logs and frame files with its own scripts, looked at the shots locally, and wrote this comment.

**@⁠Lyrnc** on GitHub · 2026-12-01 02:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4161#issuecomment-7298994022) Bench result for this PR: an A/B by switch in one diagnostics build of d6b7d9db (on main 84bd61e2), run overnight. RTX 5080 16 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11. Series S, 720p, DLSS Quality, frame generation off (as #3409). Same save, own shader cache, warmed first. - **a** = `VICTORY_RETIRED_WATCH=0`, the old behaviour. - **b** = default: watched after the last look. - Runs: one each standing still (420 s), one each on a 5-minute scripted walk. | run | fps | frame ms p50 / p90 / p99 | >50 ms /1000 | >100 ms /1000 | draws/frame | "changed after its upload with nothing to tell of it" (running total at the world / at the end) | watched slots (max / at the end) | retired since start (untracked) | askings of the write tracking | found written and due again | |---|---:|---|---:|---:|---:|---|---|---:|---:|---:| | a, standing | 30.0 | 31.7 / 44.4 / 59.1 | 47 | 0.8 | 6,263 | 4 / 54 | - | - | - | - | | b, standing | 30.2 | 31.8 / 44.6 / 59.2 | 52 | 1.0 | 6,182 | 200 / 3,001-3,999 | 27,012 / 23,024 | 77,128 (0) | 2,422,296 | 35,956 | | a, walk | 26.4 | 35.6 / 56.1 / 74.1 | 178 | 3.5 | 7,796 | 11 / 4,001-4,999 | - | - | - | - | | b, walk | 27.0 | 34.6 / 52.2 / 69.3 | 124 | 1.1 | 7,480 | 200 / 3,001-3,999 | 26,889 / 24,226 | 89,907 (0) | 2,600,379 | 50,108 | The warning is written for the first 200 changes and then every 1,000th, so its running total (`changed=`) is known only to that step. Fingerprints of untracked memory: 0 in both b runs. No device removed, DRED or "did not close" line in any run. **What this shows** - **Standing still (the clean case), b finds and re-uploads changed textures that a never looks at again.** a ends with 54 changes caught in 420 s, all inside the first looks. b ends with 3,001-3,999. b had already caught 200 by the time the world appeared, against 4 for a: those are slots written after their 5th look during loading. The watch made 35,956 slots due again. Most then matched their fingerprint, and about 3,000-4,000 had really changed. - **The cost is not visible in frame times.** Standing: p50 / p90 / p99 within 0.2 ms, frames over 50 ms 47 against 52 per 1,000. Walking, b came out better (124 against 178), but the walk's scenes differ (draws ±4 %), so read that as "not worse", not as a gain. The watch held 23,000-27,000 slots and asked the write tracking ~2.4-2.6 million times per run. **What it does not show** - **The pictures.** Shots at world+60 and +240 s (the 400-s shot fell after the run's end) show no flat-green or wrong-colour surface in either arm. But the camera framing differed between the a and b runs, and the parked car from #3409 is not in frame, so this is not a picture comparison. - **On the walk, the totals are no measure of this PR:** a 4,001-4,999 against b 3,001-3,999. On a walk most changes come from new textures inside their first looks, which both arms catch the same way. - Not run: other GPUs, Series X profiles, a session long enough for a slot to be written many times after retiring. AI use: Claude Code (Claude Opus 5.5) ran these on our bench queue, parsed the run logs and frame files with its own scripts, looked at the shots locally, and wrote this comment.
github-bot force-pushed github-bot/gh-4161 from d6b7d9db1a to c695f9aa2b 2026-12-01 05:10:54 +00:00 Compare
github-bot closed this pull request 2026-12-01 18:50:39 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:46 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.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4161#issuecomment-7321515466) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4161
No description provided.