GPU: a texture that changed with no write seen is hashed at each check for a while #159

Open
NuraadGit wants to merge 1 commit from upstream-pr/159 into main
NuraadGit commented 2026-11-24 21:59:24 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by NuraadGit on 2026-11-24T21:59:24Z.


What it fixes

On the loading/intro video the picture switched between older and newer frames, so the video strobed.

The video's frames are textures that the runtime writes through another view of their pages, so write watching never sees those writes. Such textures are only hashed every eighth frame, staggered by address. With a ring of three frame textures, a slot kept showing its old picture until its turn came round.

Change (crates/victory-gpu/src/texture.rs)

  • Last gets an unseen counter. If a texture's hash changed although no write to it was seen, it is hashed at each of its next 64 checks instead of waiting for its eighth-frame turn.
  • Once it has stayed the same for that long, it goes back to the eighth-frame turn. Textures whose writes are seen, and textures that don't change, behave exactly as before.
  • A diagnostics log line for the first such textures (n <= 8 or powers of two).
  • Unit test a_texture_that_changed_unseen_is_hashed_at_each_check.

Testing

RTX 2080 (8 GB, Windows 11), on this fork, warm shader cache:

  • Without the change: a script compares each captured intro frame with frames n-1, n-2 and n-3. It found 6 frames where n-2 or n-3 matched and n-1 didn't, i.e. old frames shown again.
  • With it: 0 such frames over the same capture window.
  • By eye: the video plays smoothly, and the world loads as before.
  • cargo test -p victory-gpu --lib passes; cargo clippy adds no warnings.

Cost: only textures that changed without a seen write get hashed more often, and only for 64 checks after each change.

AI-assisted (Claude Code). I reviewed and tested it.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6592246857 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/159). Originally posted by [NuraadGit](https://github.com/NuraadGit) on 2026-11-24T21:59:24Z. --- ## What it fixes On the loading/intro video the picture switched between older and newer frames, so the video strobed. The video's frames are textures that the runtime writes through another view of their pages, so write watching never sees those writes. Such textures are only hashed every eighth frame, staggered by address. With a ring of three frame textures, a slot kept showing its old picture until its turn came round. ## Change (`crates/victory-gpu/src/texture.rs`) - `Last` gets an `unseen` counter. If a texture's hash changed although no write to it was seen, it is hashed at each of its next 64 checks instead of waiting for its eighth-frame turn. - Once it has stayed the same for that long, it goes back to the eighth-frame turn. Textures whose writes are seen, and textures that don't change, behave exactly as before. - A diagnostics log line for the first such textures (`n <= 8` or powers of two). - Unit test `a_texture_that_changed_unseen_is_hashed_at_each_check`. ## Testing RTX 2080 (8 GB, Windows 11), on this fork, warm shader cache: - **Without the change:** a script compares each captured intro frame with frames n-1, n-2 and n-3. It found 6 frames where n-2 or n-3 matched and n-1 didn't, i.e. old frames shown again. - **With it:** 0 such frames over the same capture window. - **By eye:** the video plays smoothly, and the world loads as before. - `cargo test -p victory-gpu --lib` passes; `cargo clippy` adds no warnings. Cost: only textures that changed without a seen write get hashed more often, and only for 64 checks after each change. *AI-assisted (Claude Code). I reviewed and tested it.*
chatgpt-codex-connector[bot commented 2026-11-24 22:07:40 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T21:59:36Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:01:45.961513Z 6109393 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7145658736 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/159#issuecomment-7145658736). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T21:59:36Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6109393264af764ee99445b39bf30c2b88d29f99","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T22:01:45.961513Z">2026-11-24T22:01:45.961513Z</relative-time> | `6109393` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
BitWuehler commented 2026-11-24 23:09:37 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by BitWuehler on 2026-11-24T22:40:01Z.


Tested on CachyOS Linux (Ryzen 7 9800X3D, RTX 5080 620.73.04, GE-Proton11-14, release build, Series X files) bundled on 4e17478 with #454, #127, #154, #95, #108, and #92:

  • victory-gpu (114/115 non-ignored pass under GE-Proton11-14; only the known vkd3d-proton CreatePipelineLibrary stub fails).
  • In a 353 s world run (41 world intervals, 0 crashes/device removals), the user visually noted the opening scene showed noticeably more cleanly compared to before #159 (alongside #95/#92/#108).
  • Together with #95 + #108 + #92, preparing: textures median dropped from 596.55 ms (892.66 ms mean) to 91.30 ms (122.55 ms mean; 10.5 ms in the final 5,426-draw frame), showing #159 did not introduce texture-path slowdowns in this Proton stack.

(AI-assisted build/log analysis.)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7146501516 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/159#issuecomment-7146501516). Originally posted by [BitWuehler](https://github.com/BitWuehler) on 2026-11-24T22:40:01Z. --- Tested on CachyOS Linux (`Ryzen 7 9800X3D`, `RTX 5080` `620.73.04`, `GE-Proton11-14`, release build, Series X files) bundled on `4e17478` with `#454`, `#127`, `#154`, `#95`, `#108`, and `#92`: - `victory-gpu` (`114/115` non-ignored pass under `GE-Proton11-14`; only the known vkd3d-proton `CreatePipelineLibrary` stub fails). - In a 353 s world run (`41` world intervals, 0 crashes/device removals), the user visually noted the opening scene showed noticeably more cleanly compared to before `#159` (alongside `#95`/`#92`/`#108`). - Together with `#95` + `#108` + `#92`, `preparing: textures` median dropped from `596.55 ms` (`892.66 ms` mean) to `91.30 ms` (`122.55 ms` mean; `10.5 ms` in the final 5,426-draw frame), showing `#159` did not introduce texture-path slowdowns in this Proton stack. *(AI-assisted build/log analysis.)*
Asenje commented 2026-11-24 23:09:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Asenje on 2026-11-24T23:04:26Z.


Independent confirmation on RTX 3060 12 GB / i7-7700K, fork 4e17478 + an equivalent patch (hash a texture at every check for 60 frames after a change its guard did not see).

Capture of the intro (OBS, 60 fps, mean luma per frame; counting frames where n matches n-6 but not n-2/n-4, i.e. a 3-texture cycle):

  • without the change: 141 and 207 such frames in two runs (eagle/stars artwork cycling between pictures seconds apart)
  • with it: 0 in two runs; the zoom plays in order

The log names the ring: three textures changed unseen in the same frame (0xb4a800000, 0xb4ac00000, 0xb4b000000), then two more triples a few frames later, and three more (0xc90…) during the opening cutscene. No new warnings, no visible cost in the intro (6 draws/frame, 30 fps).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7146981647 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/159#issuecomment-7146981647). Originally posted by [Asenje](https://github.com/Asenje) on 2026-11-24T23:04:26Z. --- Independent confirmation on RTX 3060 12 GB / i7-7700K, fork 4e17478 + an equivalent patch (hash a texture at every check for 60 frames after a change its guard did not see). Capture of the intro (OBS, 60 fps, mean luma per frame; counting frames where n matches n-6 but not n-2/n-4, i.e. a 3-texture cycle): - without the change: 141 and 207 such frames in two runs (eagle/stars artwork cycling between pictures seconds apart) - with it: 0 in two runs; the zoom plays in order The log names the ring: three textures changed unseen in the same frame (0xb4a800000, 0xb4ac00000, 0xb4b000000), then two more triples a few frames later, and three more (0xc90…) during the opening cutscene. No new warnings, no visible cost in the intro (6 draws/frame, 30 fps).
clypeal6 commented 2026-11-24 23:09:41 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by clypeal6 on 2026-11-24T23:05:28Z.


Tested on an RTX 4070 Laptop GPU (8 GB, driver 621.14, default TDR), i9-14900HX, Windows 11, Series X profile, diag build with --features diagnostics. #159 applied on top of 2119b0e (it applies cleanly; texture.rs is unchanged since its base 4e17478). Warm shader cache, debug layer off.

Jump-backs in the intro. Every presented frame from 300 to 850 was saved (VICTORY_CAPTURE_FRAMES), which covers the loading-screen transitions. A frame counts as a jump-back when it differs from frame n-1 but matches one of frames n-2…n-8, and that older frame itself differs from n-1 (mean absolute difference on a 64×36 grey thumbnail: ≤ 0.6 is a match, > 2 is a change).

Build Frames compared Picture changes Jump-backs
2119b0e (texture guard on) 551 321 246 (almost all n-3: the three-texture ring)
2119b0e + VICTORY_TEXTURE_GUARD=0 551 264 0
2119b0e + #159 551 227 0

The PR's log line fired as expected (a texture changed though no write to it was seen for 1920×1080 and 3840×2160 2D textures). By eye on the unpatched build, each loading-screen transition flickers between the old, a half-faded and the new picture for about half a second.

Cost, from runs without per-frame saving (saving every frame drops the intro to 5–7 fps, so those runs are not used here). The intro holds its 30 fps cap in all three, and reaches frames 512 and 1024 equally fast (about 18 s apart).

Build preparing: textures during the loading screens after them
guard on ~0.5 ms/frame ~0.5 ms
guard off ~3.5 ms ~3–4 ms (stays)
#159 ~6 ms ~0.5 ms

So #159 costs more than turning the guard off while the video plays (it hashes the 3840×2160 target each check), but drops back to the guarded cost once the video stops.

cargo test -p victory-gpu --lib (texture tests, including a_texture_that_changed_unseen_is_hashed_at_each_check): pass. No device removals or GPU errors in any run.

Not checked: whether it changes anything in the world; runs were 75–120 s.

AI-assisted (Claude Code): the runs, frame comparison and numbers were produced by Claude Code and checked against the logs.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147001962 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/159#issuecomment-7147001962). Originally posted by [clypeal6](https://github.com/clypeal6) on 2026-11-24T23:05:28Z. --- **Tested on an RTX 4070 Laptop GPU (8 GB, driver 621.14, default TDR), i9-14900HX, Windows 11, Series X profile, diag build with `--features diagnostics`.** #159 applied on top of `2119b0e` (it applies cleanly; `texture.rs` is unchanged since its base `4e17478`). Warm shader cache, debug layer off. **Jump-backs in the intro.** Every presented frame from 300 to 850 was saved (`VICTORY_CAPTURE_FRAMES`), which covers the loading-screen transitions. A frame counts as a jump-back when it differs from frame n-1 but matches one of frames n-2…n-8, and that older frame itself differs from n-1 (mean absolute difference on a 64×36 grey thumbnail: ≤ 0.6 is a match, > 2 is a change). | Build | Frames compared | Picture changes | Jump-backs | |---|---:|---:|---:| | `2119b0e` (texture guard on) | 551 | 321 | **246** (almost all n-3: the three-texture ring) | | `2119b0e` + `VICTORY_TEXTURE_GUARD=0` | 551 | 264 | 0 | | `2119b0e` + #159 | 551 | 227 | **0** | The PR's log line fired as expected (`a texture changed though no write to it was seen` for 1920×1080 and 3840×2160 2D textures). By eye on the unpatched build, each loading-screen transition flickers between the old, a half-faded and the new picture for about half a second. **Cost**, from runs without per-frame saving (saving every frame drops the intro to 5–7 fps, so those runs are not used here). The intro holds its 30 fps cap in all three, and reaches frames 512 and 1024 equally fast (about 18 s apart). | Build | `preparing: textures` during the loading screens | after them | |---|---:|---:| | guard on | ~0.5 ms/frame | ~0.5 ms | | guard off | ~3.5 ms | ~3–4 ms (stays) | | #159 | ~6 ms | ~0.5 ms | So #159 costs more than turning the guard off while the video plays (it hashes the 3840×2160 target each check), but drops back to the guarded cost once the video stops. `cargo test -p victory-gpu --lib` (texture tests, including `a_texture_that_changed_unseen_is_hashed_at_each_check`): pass. No device removals or GPU errors in any run. Not checked: whether it changes anything in the world; runs were 75–120 s. *AI-assisted (Claude Code): the runs, frame comparison and numbers were produced by Claude Code and checked against the logs.*
ryotdev commented 2026-11-25 00:10:09 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by ryotdev on 2026-11-24T23:39:09Z.


I found one path that misses this PR’s unseen-write tracking on 6109393. When a remap is in progress and VICTORY_TEXTURE_NO_WAIT=1, refresh_unlocked stores the new hash directly. If the texture changed through an alias, the next check can still take the every-eighth-frame shortcut. #270 makes this path the default.

I put a one-file fix and synthetic regression directly on top of your head. The unlocked read now passes the same unwritten flag to Last::hashed as the ordinary path. The first snapshot and a reported write leave the counter at zero, a change without a reported write arms all 64 checks, and an unsuccessful kernel read preserves the last good state. Cherry-pickable commit

I reproduced the zero-counter failure on native Windows x64 and reran the same test after the fix. All four texture tests and the mapping synchronization test passed. The regression uses a synthetic 16-byte texture. AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147643592 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/159#issuecomment-7147643592). Originally posted by [ryotdev](https://github.com/ryotdev) on 2026-11-24T23:39:09Z. --- I found one path that misses this PR’s unseen-write tracking on 6109393. When a remap is in progress and `VICTORY_TEXTURE_NO_WAIT=1`, `refresh_unlocked` stores the new hash directly. If the texture changed through an alias, the next check can still take the every-eighth-frame shortcut. #270 makes this path the default. I put a one-file fix and synthetic regression directly on top of your head. The unlocked read now passes the same `unwritten` flag to `Last::hashed` as the ordinary path. The first snapshot and a reported write leave the counter at zero, a change without a reported write arms all 64 checks, and an unsuccessful kernel read preserves the last good state. [Cherry-pickable commit](https://github.com/ryotdev/VIctory/commit/680c2f60629a7724befec1ee9bb72734cf675e7f) I reproduced the zero-counter failure on native Windows x64 and reran the same test after the fix. All four texture tests and the mapping synchronization test passed. The regression uses a synthetic 16-byte texture. AI-assisted.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/159:upstream-pr/159'
git switch 'upstream-pr/159'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/159'
git switch 'upstream-pr/159'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/159'
git switch 'upstream-pr/159'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/159'
git switch 'main'
git merge --squash 'upstream-pr/159'
git switch 'main'
git merge --ff-only 'upstream-pr/159'
git switch 'main'
git merge 'upstream-pr/159'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
fxceless/victory-fork!159
No description provided.