Files: read-only opens go through the host file cache, and a failed texture detile is retried #470

Open
github-bot wants to merge 2 commits from github-bot/gh-470 into a-publier AGit
Owner

@⁠remembering7896 on GitHub · 2026-11-27 04:12 UTC · original
remembering7896:port-filecache-and-detile-retry → a-publier · +422 −145 · 4 files · 2 commits · open

Two fixes ported from the sibling fork avatarmanz/VIctory-7900XTX (base 014d52d), where they were first written and tested. Both are separate commits, so they can be reviewed and taken separately.

1. Files: the title's read-only opens go through the host file cache

Port of avatarmanz/VIctory-7900XTX#423 by Jesper-Andersson.

The title opens its packs read-only with FILE_FLAG_NO_BUFFERING, and files::CreateFileW passed the flag to the host unchanged. On Windows that flag keeps every read of those files out of the system file cache, so every launch reads the same bytes from the drive again.

Change (crates/victory-hle/src/modules/files.rs):

  • files::host_flags is called by CreateFileW and CreateFileA before the host's open. An open whose access is exactly GENERIC_READ and which is not overlapped loses FILE_FLAG_NO_BUFFERING.
  • A buffered handle returns the same bytes for the same aligned reads, and also takes unaligned ones, which an unbuffered handle refuses. An overlapped open keeps the flag: ReadFileScatter needs a handle with both.
  • The title's unbuffered opens are logged (the first 8, then every 256th), so a log says whether the switch can change anything.

Switch: VICTORY_FILE_CACHE=0 keeps the flag, as before. On by default.

Where it does nothing: opens with any write access, overlapped opens and opens without the flag are unchanged; CreateFile2 (used by Bink) keeps its flags; DirectStorage reads open handles of their own.

2. Textures: a failed detile conversion is retried

Port of avatarmanz/VIctory-7900XTX#419 by feanorsun.

Staging recorded the source digest before detiling the first mip. If a later mip failed, the next refresh could accept the same input as a cache hit, so a half-converted texture stayed broken. The write-watch path could also advance its watermark, and a caller reading the whole texture could still pass it to the texture store.

Change:

  • crates/victory-formats/src/texture.rs, crates/victory-gpu/src/texture.rs, crates/victory-gpu/src/texture/ahead.rs: commit the digest after the last subresource succeeds. A failed attempt clears the digest and the write-watch watermark and leaves the upload pending. Every footprint is checked against the same bounds Layout::detile uses before writing or zeroing any mip.
  • The prelude and the optional ahead queue both skip a failed conversion; other ready jobs in the ahead batch proceed. A retry uses the next eligible refresh under the existing scheduling rules.
  • No second texture-sized buffer is needed.

Measured (this machine)

RX 7900 XTX 24 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11 build 26300, cargo build --locked --profile diag -p victory --features diagnostics.

2) detile retry. Two runs of the same tree, same settings, same place; the comparison window is the first 150 s after the start (the loading phase):

long frames (>120 ms) worst single frame progress at 150 s
with the fix 1 328 ms draws 5,536 (in the world)
without 10 3,256 ms draws 2,572 (still in the menu)

In the world the frame time is unchanged by the patch (median 46.4 ms, p90 51.8 ms, no frame over 120 ms, against a median 44.7 ms / p90 58.0 ms reference run of the same build without the patch), so there is no performance cost. The warning families in the two logs are the same (device, descriptor::host, draw, texback, object) - no new failure mode.

1) file cache. The switch is active on this setup: the log shows files: read-only opens go through the host file cache on=true and the title's opens (access=0x80000000, flags=0x20000000) come out cached=true. The launch time to the first rendered frame is unchanged here (6.06-6.14 s with the patch, 6.16-6.32 s without, three launches each): the game sits on an NVMe, where an unbuffered read costs nothing, so the win the original report measured on a SATA SSD (34-37 s -> 21-23 s) does not apply to this box. The change is kept because it is the same behaviour the console has (its reads are buffered) and it removes a needless read path.

Validation

  • cargo build --locked --profile diag -p victory --features diagnostics - ok (41.3 s)
  • cargo test --locked -p victory-gpu --lib detile - 5 passed, 0 failed (the four texture::detile_retry tests included)
  • cargo xtask policy - 272 files ok
  • self-check without --execute: 94 hle / 421 host / 72 title / 0 missing, exit 0

Notes

  • VICTORY_FILE_CACHE=0 turns the file-cache change off (unbuffered reads, as before).
  • No game data in the commits.
**@⁠remembering7896** on GitHub · 2026-11-27 04:12 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/470) `remembering7896:port-filecache-and-detile-retry` → `a-publier` · +422 −145 · 4 files · 2 commits · open Two fixes ported from the sibling fork [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX) (base `014d52d`), where they were first written and tested. Both are separate commits, so they can be reviewed and taken separately. ## 1. Files: the title's read-only opens go through the host file cache Port of [avatarmanz/VIctory-7900XTX#423](https://github.com/avatarmanz/VIctory-7900XTX/pull/423) by Jesper-Andersson. The title opens its packs read-only with `FILE_FLAG_NO_BUFFERING`, and `files::CreateFileW` passed the flag to the host unchanged. On Windows that flag keeps every read of those files out of the system file cache, so every launch reads the same bytes from the drive again. **Change** (`crates/victory-hle/src/modules/files.rs`): - `files::host_flags` is called by `CreateFileW` and `CreateFileA` before the host's open. An open whose access is exactly `GENERIC_READ` and which is not overlapped loses `FILE_FLAG_NO_BUFFERING`. - A buffered handle returns the same bytes for the same aligned reads, and also takes unaligned ones, which an unbuffered handle refuses. An overlapped open keeps the flag: `ReadFileScatter` needs a handle with both. - The title's unbuffered opens are logged (the first 8, then every 256th), so a log says whether the switch can change anything. **Switch:** `VICTORY_FILE_CACHE=0` keeps the flag, as before. On by default. **Where it does nothing:** opens with any write access, overlapped opens and opens without the flag are unchanged; `CreateFile2` (used by Bink) keeps its flags; DirectStorage reads open handles of their own. ## 2. Textures: a failed detile conversion is retried Port of [avatarmanz/VIctory-7900XTX#419](https://github.com/avatarmanz/VIctory-7900XTX/pull/419) by feanorsun. Staging recorded the source digest before detiling the first mip. If a later mip failed, the next refresh could accept the same input as a cache hit, so a half-converted texture stayed broken. The write-watch path could also advance its watermark, and a caller reading the whole texture could still pass it to the texture store. **Change:** - `crates/victory-formats/src/texture.rs`, `crates/victory-gpu/src/texture.rs`, `crates/victory-gpu/src/texture/ahead.rs`: commit the digest after the last subresource succeeds. A failed attempt clears the digest and the write-watch watermark and leaves the upload pending. Every footprint is checked against the same bounds `Layout::detile` uses before writing or zeroing any mip. - The prelude and the optional ahead queue both skip a failed conversion; other ready jobs in the ahead batch proceed. A retry uses the next eligible refresh under the existing scheduling rules. - No second texture-sized buffer is needed. ## Measured (this machine) RX 7900 XTX 24 GB, Ryzen 7 9800X3D, 32 GB RAM, Windows 11 build 26300, `cargo build --locked --profile diag -p victory --features diagnostics`. **2) detile retry.** Two runs of the same tree, same settings, same place; the comparison window is the first 150 s after the start (the loading phase): | | long frames (>120 ms) | worst single frame | progress at 150 s | |---|---|---|---| | with the fix | **1** | **328 ms** | draws 5,536 (in the world) | | without | **10** | **3,256 ms** | draws 2,572 (still in the menu) | In the world the frame time is unchanged by the patch (median 46.4 ms, p90 51.8 ms, no frame over 120 ms, against a median 44.7 ms / p90 58.0 ms reference run of the same build without the patch), so there is no performance cost. The warning families in the two logs are the same (device, descriptor::host, draw, texback, object) - no new failure mode. **1) file cache.** The switch is active on this setup: the log shows `files: read-only opens go through the host file cache on=true` and the title's opens (`access=0x80000000`, `flags=0x20000000`) come out `cached=true`. The launch time to the first rendered frame is **unchanged here** (6.06-6.14 s with the patch, 6.16-6.32 s without, three launches each): the game sits on an NVMe, where an unbuffered read costs nothing, so the win the original report measured on a SATA SSD (34-37 s -> 21-23 s) does not apply to this box. The change is kept because it is the same behaviour the console has (its reads are buffered) and it removes a needless read path. ## Validation - `cargo build --locked --profile diag -p victory --features diagnostics` - ok (41.3 s) - `cargo test --locked -p victory-gpu --lib detile` - **5 passed, 0 failed** (the four `texture::detile_retry` tests included) - `cargo xtask policy` - 272 files ok - self-check without `--execute`: `94 hle / 421 host / 72 title / 0 missing`, exit 0 ## Notes - `VICTORY_FILE_CACHE=0` turns the file-cache change off (unbuffered reads, as before). - No game data in the commits.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 04:17:21 +00:00
Author
Owner

@⁠gw1337x on GitHub · 2026-11-27 04:59 UTC · original

Ran in the title on RDNA 3: RX 7800 XT 16 GB (driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds of e77f5dd and its base 4eb6cfd, same boot.

Settings: scripts/play.ps1 settings plus VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1, Series X profile, ray tracing off, VICTORY_FILE_CACHE unset (on). Method: 270 s hands-off from a Chapter I boat save with the same scripted presses each run; the window title's 1 s fps and draw count sampled every second. "World" is the first second with 1,000+ draws a frame.

The switch is active: the log has files: read-only opens go through the host file cache (VICTORY_FILE_CACHE) on=true and 8 the title opened a file unbuffered ... cached=true lines per run.

Run Build world at steady fps (205 s on) seconds < 15 fps in 60-190 s
1 e77f5dd 36.5 s 29.0 4
2 4eb6cfd 44.2 s 29.0 24
3 e77f5dd 36.0 s 28.0 14
4 4eb6cfd 41.1 s 29.0 14

For a wider base: 10 other runs of builds without this PR in the same boot (the base and other PRs, same test) reached the world at 40.7-44.2 s (7 of them at 41.1-41.2 s).

So the world comes up about 5 s sooner with the PR, from the file cache presumably (the runs were back to back, so the packs were in the cache from earlier runs; a first launch after a reboot was not measured). Seconds under 15 fps in the cutscenes vary too much between runs to say anything (4 and 14 against 24 and 14). No device loss, peak commit 33.8-34.3 GB for both. The detile half: no detile failures are logged in the base runs here, so it probably did not come into play.

**@⁠gw1337x** on GitHub · 2026-11-27 04:59 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/470#issuecomment-7210255391) Ran in the title on RDNA 3: RX 7800 XT 16 GB (driver 32.0.32015.7029), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200 (Memory Integrity off). Diagnostics builds of `e77f5dd` and its base `4eb6cfd`, same boot. Settings: `scripts/play.ps1` settings plus `VICTORY_PORT_CONSTANTS/DESCRIPTORS/CBV/GUARD/JOURNAL=1`, Series X profile, ray tracing off, `VICTORY_FILE_CACHE` unset (on). Method: 270 s hands-off from a Chapter I boat save with the same scripted presses each run; the window title's 1 s fps and draw count sampled every second. "World" is the first second with 1,000+ draws a frame. The switch is active: the log has `files: read-only opens go through the host file cache (VICTORY_FILE_CACHE) on=true` and 8 `the title opened a file unbuffered ... cached=true` lines per run. | Run | Build | world at | steady fps (205 s on) | seconds < 15 fps in 60-190 s | |---|---|---|---|---| | 1 | `e77f5dd` | 36.5 s | 29.0 | 4 | | 2 | `4eb6cfd` | 44.2 s | 29.0 | 24 | | 3 | `e77f5dd` | 36.0 s | 28.0 | 14 | | 4 | `4eb6cfd` | 41.1 s | 29.0 | 14 | For a wider base: 10 other runs of builds without this PR in the same boot (the base and other PRs, same test) reached the world at 40.7-44.2 s (7 of them at 41.1-41.2 s). So the world comes up about 5 s sooner with the PR, from the file cache presumably (the runs were back to back, so the packs were in the cache from earlier runs; a first launch after a reboot was not measured). Seconds under 15 fps in the cutscenes vary too much between runs to say anything (4 and 14 against 24 and 14). No device loss, peak commit 33.8-34.3 GB for both. The detile half: no detile failures are logged in the base runs here, so it probably did not come into play.
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 05:38 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At e77f5dd: victory-gpu 400 passed, 0 failed, 34 ignored; victory-hle 163 passed, 0 failed, 2 ignored; victory-formats 42 passed, 0 failed, 5 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 05:38 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/470#issuecomment-7210806658) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `e77f5dd`: `victory-gpu` 400 passed, 0 failed, 34 ignored; `victory-hle` 163 passed, 0 failed, 2 ignored; `victory-formats` 42 passed, 0 failed, 5 ignored. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠gw1337x on GitHub · 2026-11-27 12:07 UTC · original

#477 and #470 stack, measured together. Memory Integrity was off.

PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, Belobug launcher settings plus the 5 port switches. I made a local build of #477 (0834177) with #470's two commits cherry-picked on top (no conflicts) and ran it with VICTORY_WC_NO_BACK=1. Compared against 4eb6cfd, 3 runs each, interleaved.

#477 + #470 base 4eb6cfd
steady fps (last minute, layer log) 30.0 / 30.0 / 30.0 28.4 / 28.3 / 28.6
world on screen (first 1,000+ draws a frame), s after start 39.9 / 36.2 / 36.5 42.9 / 44.0 / 44.3
seconds under 15 fps (window title, 45-265 s, seconds with 1,000+ draws) 7 / 6 / 8 13 / 15 / 14
peak commit, GB 33.5 / 33.8 / 33.7 33.8 / 34.2 / 33.9
device loss lines 0 0
  • Both halves were active in every combo run: 8 file-cache opens per run, and NO_BACK lines in the log.
  • Pictures at 241 s look normal in all three.

Each PR keeps its own gain when they're combined: #477's steady fps and #470's faster load.

**@⁠gw1337x** on GitHub · 2026-11-27 12:07 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/470#issuecomment-7217875600) #477 and #470 stack, measured together. Memory Integrity was off. PC: Ryzen 7 9800X3D, RX 7800 XT, 32 GB. Test: 270 s hands-off boat scene, RT off, Belobug launcher settings plus the 5 port switches. I made a local build of #477 (`0834177`) with #470's two commits cherry-picked on top (no conflicts) and ran it with `VICTORY_WC_NO_BACK=1`. Compared against `4eb6cfd`, 3 runs each, interleaved. | | #477 + #470 | base `4eb6cfd` | |---|---|---| | steady fps (last minute, layer log) | 30.0 / 30.0 / 30.0 | 28.4 / 28.3 / 28.6 | | world on screen (first 1,000+ draws a frame), s after start | 39.9 / 36.2 / 36.5 | 42.9 / 44.0 / 44.3 | | seconds under 15 fps (window title, 45-265 s, seconds with 1,000+ draws) | 7 / 6 / 8 | 13 / 15 / 14 | | peak commit, GB | 33.5 / 33.8 / 33.7 | 33.8 / 34.2 / 33.9 | | device loss lines | 0 | 0 | - Both halves were active in every combo run: 8 file-cache opens per run, and NO_BACK lines in the log. - Pictures at 241 s look normal in all three. Each PR keeps its own gain when they're combined: #477's steady fps and #470's faster load.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/470/head:github-bot/gh-470'
git switch 'github-bot/gh-470'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-470'
git switch 'github-bot/gh-470'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-470'
git switch 'github-bot/gh-470'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-470'
git switch 'a-publier'
git merge --squash 'github-bot/gh-470'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-470'
git switch 'a-publier'
git merge 'github-bot/gh-470'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.