GPU: hash a view-memory texture once more at its next check, and every check while it keeps changing #460
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!460
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/460/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@xunbreakablex on GitHub · 2026-11-25 01:12 UTC · original
xunbreakablex:texture-hot-pr→main· +100 −1 · 1 files · 1 commits · closed without mergingNeeds human attention: this overlaps #115, #159, #343, #438 and #456 (and the closed #58 and #63), which all try to fix the same intro flicker (textures written through another view of their pages are seen only by the hash every 8th frame). I could not tell from the threads which one you prefer to keep, so this is not a request to pick mine; it is the variant for which I have measured the cost, so that the choice can use numbers. If one of the others is merged, this can be closed.
The problem
On
maina texture in view memory is checked by its write guard, which does not see writes made through another view of the same physical pages (the Bink video planes are written that way), so the only thing that notices a change is a hash taken every 8th frame (HASH_EVERY). The planes are sampled in a ring of three, each checked every third frame, so the three host copies refresh on different frames and the picture jumps between three older frames.What this changes
After the hash finds a texture changed, it is hashed once more at its next check (not the next frame: a ring texture is checked every third frame, so a "next frame" check never sees the second change). Only if that second hash also finds a change is the texture "hot" and hashed at every check while it keeps changing, until 24 frames after the last change. A texture that streams in changes once and is not hashed any more. State per texture:
Last { hot_until, changed_at, verify }, withchanged,unchangedandhash_due. Onlycrates/victory-gpu/src/texture.rschanges (+100/-1).Measured
All on a diag build of
7b0f736plus this change (the commit here is the same change ona803c87; I have not run the game ona803c87), RTX 4070 12 GB, Ryzen 5 5600, driver 621.01, Windows 11 26300.VICTORY_CAPTUREframes, mean difference of consecutive frames divided by the mean difference of frames three apart: smooth scene 0.36; with the bug 7.5 (15 runs, 6.5-7.9); with this change 0.57 (2 runs). Counting the moving frame triples where frame n+1 looks more like n-1 than like n: 47-62% in 15 runs with the bug, 0.0% (95% interval 0.0-3.4%, 108 triples) in 2 runs with this change.cargo test -p victory-gpu --lib -- hot_texture_tests, no GPU).cargo check -p victory-gpu(also--features diagnostics) andcargo clippy -p victory-gpu --all-targets -- -D warnings(also--all-features): clean.Not measured
#58, #159, #343, #438, #456 and #115 themselves: I do not know their cost in the world, only the cost of my first variant. Other GPUs. The Linux/Proton reports in #39 mention a remaining jump of about one frame in 16 to 20 that this does not address.
AI-assisted (Claude); the runs were done on my machine.
@xunbreakablex on GitHub · 2026-11-25 07:27 UTC · original
Closing this one.
mainnow has8dd30ab("A write through one view of a page is seen at its other views"), which removes the cause this change worked around: the guard did not see writes made through another view of a texture's pages, so only the hash every 8th frame noticed them. I have not re-run the intro on the newmain, so I cannot say whether the flicker is gone there; if it comes back, the cost numbers in the description (hashing every changed texture for 120 frames cost 13 → 160 ms a frame in the world, hash-once-more-then-hot cost 13-21 ms) may still be useful to whoever looks at it.I cannot follow this PR further, so closing it is cleaner than leaving it open.
Pull request closed