GPU: hash a guarded texture at every check while it keeps changing (#269) #343

Open
PAYS0 wants to merge 2 commits from upstream-pr/343 into main
PAYS0 commented 2026-11-24 23:41:26 +00:00 (Migrated from github.com)

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


Fixes #269.

Problem

With VICTORY_TEXTURE_GUARD on (the default), a texture in view memory that the guard saw no write to is hashed only every eighth frame (HASH_EVERY, by address so textures take turns). The code already notes that a write through another view is not seen by the guard. The startup screens and intro are evidently written that way, so they were shown up to eight frames stale: repeated frames, jumping and flicker. #269 bisected it to this switch alone, and four more people in that thread confirmed VICTORY_TEXTURE_GUARD=0 removes it.

Fix

  • Last gains changed: the frame a hash last found the texture's memory changed. A new Last::rehash sets it, and every hashing path uses it (partly mapped, through the copy, in place, and the unlocked read).
  • The guard's skip decision moves into guard_skips. For RECENTLY_CHANGED (16, two turns) frames after a change, a texture is not skipped.
  • A texture that keeps changing (a video, an animated screen) is therefore hashed at every check, as with the guard off. One that stops goes back to taking turns, so still textures, which are where the guard's ~51 ms/frame saving came from, keep it.
  • Nothing changes for textures with a write-watch, for writes the guard does see, or with VICTORY_TEXTURE_GUARD=0.

Testing

  • New unit tests guard_tests::a_still_texture_takes_its_turn and guard_tests::a_changing_texture_is_hashed_at_every_frame, including frame counter wrap-around.
  • cargo test -p victory-gpu on Windows 11 at this commit: 112 passed, 0 failed (1 ignored benchmark). No clippy warnings in texture.rs, with or without --features diagnostics.
  • Not yet checked in the game. Could someone from #269 confirm the startup screens and intro are smooth with the guard left on, and say whether the frame time in the world moves? VICTORY_TEXTURE_GUARD=0 stays the workaround until then.

Developed with Claude Code on Claude Opus 5.5.

🤖 Generated with Claude Code

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593691970 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/343). Originally posted by [PAYS0](https://github.com/PAYS0) on 2026-11-24T23:41:26Z. --- Fixes #269. ## Problem With `VICTORY_TEXTURE_GUARD` on (the default), a texture in view memory that the guard saw no write to is hashed only every eighth frame (`HASH_EVERY`, by address so textures take turns). The code already notes that a write through another view is not seen by the guard. The startup screens and intro are evidently written that way, so they were shown up to eight frames stale: repeated frames, jumping and flicker. #269 bisected it to this switch alone, and four more people in that thread confirmed `VICTORY_TEXTURE_GUARD=0` removes it. ## Fix - `Last` gains `changed`: the frame a hash last found the texture's memory changed. A new `Last::rehash` sets it, and every hashing path uses it (partly mapped, through the copy, in place, and the unlocked read). - The guard's skip decision moves into `guard_skips`. For `RECENTLY_CHANGED` (16, two turns) frames after a change, a texture is not skipped. - A texture that keeps changing (a video, an animated screen) is therefore hashed at every check, as with the guard off. One that stops goes back to taking turns, so still textures, which are where the guard's ~51 ms/frame saving came from, keep it. - Nothing changes for textures with a write-watch, for writes the guard does see, or with `VICTORY_TEXTURE_GUARD=0`. ## Testing - New unit tests `guard_tests::a_still_texture_takes_its_turn` and `guard_tests::a_changing_texture_is_hashed_at_every_frame`, including frame counter wrap-around. - `cargo test -p victory-gpu` on Windows 11 at this commit: 112 passed, 0 failed (1 ignored benchmark). No clippy warnings in `texture.rs`, with or without `--features diagnostics`. - **Not yet checked in the game.** Could someone from #269 confirm the startup screens and intro are smooth with the guard left on, and say whether the frame time in the world moves? `VICTORY_TEXTURE_GUARD=0` stays the workaround until then. Developed with Claude Code on Claude Opus 5.5. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
avt0m4t48 commented 2026-11-25 00:10:11 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-24T23:52:24Z.


I checked 366ccb7 against 2119b0e with the exact refresh functions, real BLAKE3, and one synthetic 64 KiB file mapped at two addresses. The harness passed 6/6 on main and 8/8 on this branch with the guard both enabled and disabled. Requiring the branch's cadence on main failed.

Synthetic checks with the guard enabled Main This PR
One texture changing every check from cold 35 stale / 39 7 stale / 39, all before the first changed digest
Three rotating textures after first discovery 63 stale / 72 0 stale / 72
Original contents return at every scheduled hash 21 stale / 24 21 stale / 24
A newly read static texture 4 hashes / 32 18 hashes / 32

The discovery interval depends on when that slot is checked. With a slot used every third host frame, eight checks can take 24 host frames. If the old image is present at every scheduled hash, neither version enters the hot window. This is a useful control for a follow-up capture, especially given that #115 has intro results from AMD and NVIDIA using direct alias-write tracking.

Both models returned to the normal cadence once the texture settled. The harness mocked Windows guard, remap and detile operations. Game output and frame time still need a native run. Verified with Codex assistance.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147889034 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/343#issuecomment-7147889034). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T23:52:24Z. --- I checked `366ccb7` against `2119b0e` with the exact refresh functions, real BLAKE3, and one synthetic 64 KiB file mapped at two addresses. The harness passed 6/6 on main and 8/8 on this branch with the guard both enabled and disabled. Requiring the branch's cadence on main failed. | Synthetic checks with the guard enabled | Main | This PR | |---|---:|---:| | One texture changing every check from cold | 35 stale / 39 | 7 stale / 39, all before the first changed digest | | Three rotating textures after first discovery | 63 stale / 72 | 0 stale / 72 | | Original contents return at every scheduled hash | 21 stale / 24 | 21 stale / 24 | | A newly read static texture | 4 hashes / 32 | 18 hashes / 32 | The discovery interval depends on when that slot is checked. With a slot used every third host frame, eight checks can take 24 host frames. If the old image is present at every scheduled hash, neither version enters the hot window. This is a useful control for a follow-up capture, especially given that #115 has intro results from [AMD](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7145672783) and [NVIDIA](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7145894136) using direct alias-write tracking. Both models returned to the normal cadence once the texture settled. The harness mocked Windows guard, remap and detile operations. Game output and frame time still need a native run. Verified with Codex assistance.
PAYS0 commented 2026-11-25 00:10:12 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PAYS0 on 2026-11-24T23:57:13Z.


Thanks for running this. Pushed a follow-up (c4dc17e): a texture's first hash no longer opens the every-frame window, so a newly read static texture is back to main's cadence; one that changes enters it at its first changed digest. The "original contents at every scheduled hash" case is unchanged, as you say; only seeing the writes catches it, which is what #115 does at the source. This PR is meant to complement that: the hash net under the guard reacts within a frame, instead of up to eight, for any write path the guard still misses. Happy to rebase on #115 or close this if the maintainer prefers.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7147976553 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/343#issuecomment-7147976553). Originally posted by [PAYS0](https://github.com/PAYS0) on 2026-11-24T23:57:13Z. --- Thanks for running this. Pushed a follow-up (c4dc17e): a texture's first hash no longer opens the every-frame window, so a newly read static texture is back to main's cadence; one that changes enters it at its first changed digest. The "original contents at every scheduled hash" case is unchanged, as you say; only seeing the writes catches it, which is what #115 does at the source. This PR is meant to complement that: the hash net under the guard reacts within a frame, instead of up to eight, for any write path the guard still misses. Happy to rebase on #115 or close this if the maintainer prefers.
kaayzouee commented 2026-11-25 02:10:07 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:21:40Z.


Duplicate of #159?

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149466722 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/343#issuecomment-7149466722). Originally posted by [kaayzouee](https://github.com/kaayzouee) on 2026-11-25T01:21:40Z. --- Duplicate of #159?
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/343:upstream-pr/343'
git switch 'upstream-pr/343'

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/343'
git switch 'upstream-pr/343'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/343'
git switch 'upstream-pr/343'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/343'
git switch 'main'
git merge --squash 'upstream-pr/343'
git switch 'main'
git merge --ff-only 'upstream-pr/343'
git switch 'main'
git merge 'upstream-pr/343'
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!343
No description provided.