Texture hash turn every 64th frame: 3 ms a frame less in the texture pass #4494

Closed
github-bot wants to merge 16 commits from github-bot/gh-4493 into main AGit
Owner

@⁠paales on GitHub · 2026-11-30 21:13 UTC · original
paales:texture-hash-64 → main · +14 −12 · 1 files · 16 commits · closed without merging

Written by 🤖:

What it changes

The texture pass hashes a guarded texture that the guard saw no write to on its turn, to find writes through another view. The turn came every eighth frame. In the first cutscene that hash work was about 3 ms a frame of all threads. The turn now comes every 64th frame.

A change that the hash finds makes the texture hot (hot_textures) as before, so a texture that is written through another view every frame is late only once. That first time it is up to 64 frames late: about 2 s at 30 fps.

How it was tested

  • PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11.
  • Profile: Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap.
  • Base: main 84bd61e2 with #3918, #1727, #3553, #3043, #4207, #4138 and #720 (branch heap-worker on paales/VIctory-NVIDIA). The interval was a switch in that build for the test (branch hash-every).
  • Each run: a new game (settings save, no story save), one A press, the first cutscene. The runs were back to back on an idle PC. The numbers are the means of the log lines from 15 s to 60 s after the first scene frame. Before 15 s each run has the world's load (a frame of 3.6 to 4.7 s) and about 4 s of texture pass at 50 to 64 ms a frame, with every interval.
every 8th frame (main) every 64th frame (this PR) never
texture refreshes, all threads, per frame 5.6 ms 2.6 ms 3.1 ms
the submitting thread, per frame 29.2 ms 29.2 ms 29.0 ms
textures picked by index, frames late on average 0.60 0.50 0.50

A fourth run with every 64th frame and two other switches had 2.7 ms of texture refreshes a frame. In this build #720 does the texture pass for textures picked by index on a thread of its own, so the time saved is on that thread, not on the submitting thread. Without #720 that pass runs on the thread that records the frame.

Captures every 250 ms of the runs with every 64th frame and with never show no old textures at the cuts at 40 s and 45 s.

The commit message says that every eighth frame held the scene's start at frames of up to 1.3 s. That is wrong: the slow start is in every run, with every interval. Please drop that part of the message when you merge.

  • cargo test: not run. The change is the constant and its comments.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #720 and #4207 change the same turn check. This PR adds no merge conflict to either of them.
**@⁠paales** on GitHub · 2026-11-30 21:13 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4493) `paales:texture-hash-64` → `main` · +14 −12 · 1 files · 16 commits · closed without merging _Written by 🤖:_ ## What it changes The texture pass hashes a guarded texture that the guard saw no write to on its turn, to find writes through another view. The turn came every eighth frame. In the first cutscene that hash work was about 3 ms a frame of all threads. The turn now comes every 64th frame. A change that the hash finds makes the texture hot ([`hot_textures`](crates/victory-gpu/src/texture.rs)) as before, so a texture that is written through another view every frame is late only once. That first time it is up to 64 frames late: about 2 s at 30 fps. ## How it was tested - PC: RTX 5070 Ti 16 GB, Ryzen 9 5900X, 32 GB, Windows 11. - Profile: Series X, 1440p, DLSS Performance, frame generation off, 30 fps cap. - Base: `main` 84bd61e2 with #3918, #1727, #3553, #3043, #4207, #4138 and #720 (branch `heap-worker` on paales/VIctory-NVIDIA). The interval was a switch in that build for the test (branch `hash-every`). - Each run: a new game (settings save, no story save), one A press, the first cutscene. The runs were back to back on an idle PC. The numbers are the means of the log lines from 15 s to 60 s after the first scene frame. Before 15 s each run has the world's load (a frame of 3.6 to 4.7 s) and about 4 s of texture pass at 50 to 64 ms a frame, with every interval. | | every 8th frame (`main`) | every 64th frame (this PR) | never | | --- | --- | --- | --- | | texture refreshes, all threads, per frame | 5.6 ms | 2.6 ms | 3.1 ms | | the submitting thread, per frame | 29.2 ms | 29.2 ms | 29.0 ms | | textures picked by index, frames late on average | 0.60 | 0.50 | 0.50 | A fourth run with every 64th frame and two other switches had 2.7 ms of texture refreshes a frame. In this build #720 does the texture pass for textures picked by index on a thread of its own, so the time saved is on that thread, not on the submitting thread. Without #720 that pass runs on the thread that records the frame. Captures every 250 ms of the runs with every 64th frame and with never show no old textures at the cuts at 40 s and 45 s. The commit message says that every eighth frame held the scene's start at frames of up to 1.3 s. That is wrong: the slow start is in every run, with every interval. Please drop that part of the message when you merge. - `cargo test`: not run. The change is the constant and its comments. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #720 and #4207 change the same turn check. This PR adds no merge conflict to either of them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 21:16:45 +00:00
github-bot changed title from Texture hash turn every 64th frame: 3.5 ms a frame less in the texture pass to Texture hash turn every 64th frame: 3 ms a frame less in the texture pass 2026-11-30 21:22:22 +00:00
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:38 UTC · original

Two things with 64:

  1. The turns bunch more. Without VICTORY_TEXTURE_TURN_SPREAD=1, turn_phase (texture.rs:305) is the texture's 64 KiB block number, so every texture at a multiple of 4 MiB now shares one turn, where with 8 it was a multiple of 512 KiB. Big textures are the ones at such addresses, so most of the bytes hashed fall on one frame in 64 rather than spread out: a spike every ~3 s at 20 fps instead of a small cost every frame. #4531 measured 64 on a 5800X and found the spread mattered (longest frame of a second 64 vs 71 ms with TURN_SPREAD=1; without it, fps unchanged). Making the spread the default together with 64 would avoid that.
  2. The doc of hot_textures now reads "VICTORY_TEXTURE_HOT=0: every 64th frame only, as before" (texture.rs:293-294); "as before" no longer holds.

Overlap: #4531 makes the same constant a switch (VICTORY_TEXTURE_HASH_EVERY, default 8) and #4510 edits the same doc comment and the hot start; all three touch the same lines. #4531's switch with 64 as its default, plus the spread, would be one change that each PC can still set back.

Why it matters on a small CPU: without #720 this pass runs on the thread that records the frame. On a Ryzen 5 5600X with an RTX 3060 our submitting thread is busy 44-54 ms of a 55-58 ms frame, so #4531's ~6 ms less "preparing" would show almost one for one in the frame there.

**@⁠IRennie74** on GitHub · 2026-11-30 22:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4493#issuecomment-7294123856) Two things with 64: 1. **The turns bunch more.** Without `VICTORY_TEXTURE_TURN_SPREAD=1`, `turn_phase` (`texture.rs:305`) is the texture's 64 KiB block number, so every texture at a multiple of 4 MiB now shares one turn, where with 8 it was a multiple of 512 KiB. Big textures are the ones at such addresses, so most of the bytes hashed fall on one frame in 64 rather than spread out: a spike every ~3 s at 20 fps instead of a small cost every frame. #4531 measured 64 on a 5800X and found the spread mattered (longest frame of a second 64 vs 71 ms with `TURN_SPREAD=1`; without it, fps unchanged). Making the spread the default together with 64 would avoid that. 2. The doc of `hot_textures` now reads "`VICTORY_TEXTURE_HOT=0`: every 64th frame only, as before" (`texture.rs:293-294`); "as before" no longer holds. Overlap: #4531 makes the same constant a switch (`VICTORY_TEXTURE_HASH_EVERY`, default 8) and #4510 edits the same doc comment and the hot start; all three touch the same lines. #4531's switch with 64 as its default, plus the spread, would be one change that each PC can still set back. Why it matters on a small CPU: without #720 this pass runs on the thread that records the frame. On a Ryzen 5 5600X with an RTX 3060 our submitting thread is busy 44-54 ms of a 55-58 ms frame, so #4531's ~6 ms less "preparing" would show almost one for one in the frame there.
Author
Owner

@⁠paales on GitHub · 2026-11-30 22:42 UTC · original

Written by 🤖:

Thank you, both points are right.

  1. Pushed 160b6cb8: the turn is the mixed page number by default now (VICTORY_TEXTURE_TURN_SPREAD=0 gives the block number as before). I did not measure the spread myself; #4531's numbers (the longest frame of a second 64 against 71 ms) are the reason.
  2. The hot_textures doc now ends "VICTORY_TEXTURE_HOT=0: every 64th frame only."

On the overlap: what I measured is the value 64 (texture refreshes 5.6 against 2.6 ms a frame of all threads). In my build #720 runs this pass on its own thread, so the submitting thread did not change there; without #720 the saving falls on the thread that records the frame, as you say. If #4531's switch with 64 and the spread as defaults is the preferred form, I close this PR in its favour. #4510 touches the same doc comment; I rebase whichever goes second.

**@⁠paales** on GitHub · 2026-11-30 22:42 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4493#issuecomment-7294206926) _Written by 🤖:_ Thank you, both points are right. 1. Pushed 160b6cb8: the turn is the mixed page number by default now (`VICTORY_TEXTURE_TURN_SPREAD=0` gives the block number as before). I did not measure the spread myself; #4531's numbers (the longest frame of a second 64 against 71 ms) are the reason. 2. The `hot_textures` doc now ends "`VICTORY_TEXTURE_HOT=0`: every 64th frame only." On the overlap: what I measured is the value 64 (texture refreshes 5.6 against 2.6 ms a frame of all threads). In my build #720 runs this pass on its own thread, so the submitting thread did not change there; without #720 the saving falls on the thread that records the frame, as you say. If #4531's switch with 64 and the spread as defaults is the preferred form, I close this PR in its favour. #4510 touches the same doc comment; I rebase whichever goes second.
The branch's base was main before its history was rewritten; this merge takes today's main for every file and keeps the two changes of this pull request in texture.rs.
Author
Owner

@⁠DoubleD17 on GitHub · 2026-12-01 14:04 UTC · original

We measured this interval (64 against 8) through #4531's switch, on an RTX 5070 12 GB and a Ryzen 7 5800X: texture refreshes on all threads went from 17.9-19.8 ms to 9.6-11.6 ms a frame in four runs out of four (about -8 ms), and the submitting thread about -3.5 ms in the runs with no one at the PC. Details and caveats: #4531

The late-by-up-to-64-frames case was not covered (idle camera only).

AI Assisted

**@⁠DoubleD17** on GitHub · 2026-12-01 14:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4493#issuecomment-7313657453) We measured this interval (64 against 8) through #4531's switch, on an RTX 5070 12 GB and a Ryzen 7 5800X: texture refreshes on all threads went from 17.9-19.8 ms to 9.6-11.6 ms a frame in four runs out of four (about -8 ms), and the submitting thread about -3.5 ms in the runs with no one at the PC. Details and caveats: https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/4531 The late-by-up-to-64-frames case was not covered (idle camera only). AI Assisted
Author
Owner

@⁠albertik322-sudo on GitHub · 2026-12-01 17:00 UTC · original

Positive on a laptop, as part of a batch cherry-picked onto main @ 5fabb46e (this one together with #4295, #4341, #4877, #4207). PC: RTX 3070 Laptop 8 GB, i7-11800H, 32 GB RAM, Windows 11. Series S, 1080p output, DLSS Performance, FG x4.

The texture line in the per-frame breakdown went from ~4 ms to ~0.5 ms after the batch, and this PR is the obvious candidate for that specific line. Frame hash hitches in the first minutes are still there but visibly shorter.

For honesty: I did not isolate it, the other PRs in the batch target different lines (copies/refresh), so the texture-line drop is very likely yours.

**@⁠albertik322-sudo** on GitHub · 2026-12-01 17:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4493#issuecomment-7318593850) Positive on a laptop, as part of a batch cherry-picked onto main @ 5fabb46e (this one together with #4295, #4341, #4877, #4207). PC: RTX 3070 Laptop 8 GB, i7-11800H, 32 GB RAM, Windows 11. Series S, 1080p output, DLSS Performance, FG x4. The texture line in the per-frame breakdown went from **~4 ms to ~0.5 ms** after the batch, and this PR is the obvious candidate for that specific line. Frame hash hitches in the first minutes are still there but visibly shorter. For honesty: I did not isolate it, the other PRs in the batch target different lines (copies/refresh), so the texture-line drop is very likely yours.
github-bot closed this pull request 2026-12-01 18:43:24 +00:00
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:39 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:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4493#issuecomment-7321300693) 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!4494
No description provided.