Texture guard: see writes through every view of its pages (boot video glitch) #115

Open
github-bot wants to merge 1 commit from github-bot/gh-115 into main AGit
Owner

@⁠Spexivus on GitHub · 2026-11-24 21:36 UTC · original
Spexivus:texture-guard-views → main · +354 −17 · 6 files · 1 commits · open

Before: the texture guard made the 64 KiB blocks of one view read-only and learned of writes only at that address: a fault there, watch::writing, or a mapping. Physical pages can be mapped at several addresses, though, and a write through another view of the same pages, or the runtime's own write into physical pages (write_physical, DirectStorage page destinations), never faults at the guarded address. The guard then reported the texture unwritten, so it was hashed only on its turn every eighth frame and kept showing stale contents in between.

After: a write to the pages is seen whichever way it arrives.

  • watch.rs: the guard makes every view of the guarded physical pages read-only. A fault at any of them, or writing, opens and marks all of them written. New title_memory_written(section, offset, len) lets the runtime report its own writes into physical pages, and a view newly mapped over guarded pages makes their guards check again.
  • inplace.rs: an index from (section, 64 KiB offset) to every view showing it, kept by title_memory_view / views_gone, with views_between, pages_of and views_of_section to look it up.
  • xmem.rs: write_physical reports each run it writes; PageWindow::written() reports the window. dstorage.rs calls it after filling a page destination.
  • texture.rs: with diagnostics, a one-time warning when a hash finds a change the guard did not report, naming the texture, so any write path still missed shows up.

Unchanged: HASH_EVERY, and memory that is not written costs the same as before (no faults, no hash). The hash stays as the net under the guard.

Tests: three new ones in watch.rs (a write through another view, a view mapped beside a guarded one, a runtime write into physical pages). cargo test -p victory-gpu --features diagnostics 120 passed, victory-hle 95 passed, clippy clean with and without diagnostics.

**@⁠Spexivus** on GitHub · 2026-11-24 21:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/115) `Spexivus:texture-guard-views` → `main` · +354 −17 · 6 files · 1 commits · open Before: the texture guard made the 64 KiB blocks of one view read-only and learned of writes only at that address: a fault there, `watch::writing`, or a mapping. Physical pages can be mapped at several addresses, though, and a write through another view of the same pages, or the runtime's own write into physical pages (`write_physical`, DirectStorage page destinations), never faults at the guarded address. The guard then reported the texture unwritten, so it was hashed only on its turn every eighth frame and kept showing stale contents in between. After: a write to the pages is seen whichever way it arrives. - `watch.rs`: the guard makes every view of the guarded physical pages read-only. A fault at any of them, or `writing`, opens and marks all of them written. New `title_memory_written(section, offset, len)` lets the runtime report its own writes into physical pages, and a view newly mapped over guarded pages makes their guards check again. - `inplace.rs`: an index from (section, 64 KiB offset) to every view showing it, kept by `title_memory_view` / `views_gone`, with `views_between`, `pages_of` and `views_of_section` to look it up. - `xmem.rs`: `write_physical` reports each run it writes; `PageWindow::written()` reports the window. `dstorage.rs` calls it after filling a page destination. - `texture.rs`: with `diagnostics`, a one-time warning when a hash finds a change the guard did not report, naming the texture, so any write path still missed shows up. Unchanged: `HASH_EVERY`, and memory that is not written costs the same as before (no faults, no hash). The hash stays as the net under the guard. Tests: three new ones in `watch.rs` (a write through another view, a view mapped beside a guarded one, a runtime write into physical pages). `cargo test -p victory-gpu --features diagnostics` 120 passed, `victory-hle` 95 passed, clippy clean with and without `diagnostics`.
The guard protected one view of a texture's physical pages and heard only of faults there, so a write through another view of the same pages, or the runtime's own write into them (write_physical, DirectStorage page destinations), went unseen and the texture kept stale contents until its eighth-frame hash. The guard now protects every view of its pages, and the runtime reports its own writes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:24 +00:00
Author
Owner

@⁠thiagolima0 on GitHub · 2026-11-24 22:00 UTC · original

Confirmed on AMD: this fixes the boot video stutter on an RX 6600M.

Setup: AMD Radeon RX 6600M (8 GB, 32-lane waves), driver 32.0.21045.16010, Windows 11 26200, default TDR. Own 1.0.2.1 copy, Series X profile, cargo build --profile diag -p victory --features diagnostics. Tree: 4e17478 + #24, #23, #9, #40, #25, #38, then this PR merged on top (no conflicts). Hashes and counts only, nothing from the game attached.

What it looked like before: the boot video played visibly jerky, and the present timing did not explain it. With VICTORY_LOG=victory_gpu::frame=debug, presents during the video arrive steadily (0-2 intervals over 45 ms per 5 s, nearly all 33-37 ms). The problem is the content. I saved 24 consecutive frames during the video (VICTORY_KEYS=25:Enter,27:Enter VICTORY_CAPTURE_FRAMES=760,...,783) and hashed the PNGs:

distinct frames of 24 frames equal to the one 3 before
without this PR 6 18
with this PR 24 0

Without it, the video's three frame buffers cycle: frames 761-770 show the same three images in turn (A B C A B C ...). Only one buffer gets new content every 8-9 frames (one new image at 771, another at 779). That fits the every-eighth-frame hash you describe: the picture jumps back and forth between stale frames. With the PR every frame is new, and the a texture's hash found a change its guard did not report warning did not fire in the run.

Tests: cargo test -p victory-gpu -p victory-hle --lib on this card: 115 + 95 passed, 1 ignored.

Unrelated, from the same runs, in case it helps someone else: the 1.0-1.5 s freezes on the black screen before the first logo are a title worker making about 54,000 one-page XMemMapPhysicalPages calls while the main thread polls with SleepEx. About 0.5 s of that is ours (VirtualFree placeholder split + MapViewOfFile3 ≈ 6.8 µs per call, commit ≈ 1.6 µs). The rest is the title's own page-list comparison. They happen before anything is drawn, so they are not visible as stutter.

AI-assisted (Claude Code); hashes, counts and log lines only.

**@⁠thiagolima0** on GitHub · 2026-11-24 22:00 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7145672783) Confirmed on AMD: this fixes the boot video stutter on an RX 6600M. **Setup:** AMD Radeon RX 6600M (8 GB, 32-lane waves), driver 32.0.21045.16010, Windows 11 26200, default TDR. Own 1.0.2.1 copy, Series X profile, `cargo build --profile diag -p victory --features diagnostics`. Tree: `4e17478` + #24, #23, #9, #40, #25, #38, then this PR merged on top (no conflicts). Hashes and counts only, nothing from the game attached. **What it looked like before:** the boot video played visibly jerky, and the present timing did not explain it. With `VICTORY_LOG=victory_gpu::frame=debug`, presents during the video arrive steadily (0-2 intervals over 45 ms per 5 s, nearly all 33-37 ms). The problem is the content. I saved 24 consecutive frames during the video (`VICTORY_KEYS=25:Enter,27:Enter VICTORY_CAPTURE_FRAMES=760,...,783`) and hashed the PNGs: | | distinct frames of 24 | frames equal to the one 3 before | |---|---|---| | without this PR | 6 | 18 | | with this PR | **24** | **0** | Without it, the video's three frame buffers cycle: frames 761-770 show the same three images in turn (`A B C A B C ...`). Only one buffer gets new content every 8-9 frames (one new image at 771, another at 779). That fits the every-eighth-frame hash you describe: the picture jumps back and forth between stale frames. With the PR every frame is new, and the `a texture's hash found a change its guard did not report` warning did not fire in the run. **Tests:** `cargo test -p victory-gpu -p victory-hle --lib` on this card: 115 + 95 passed, 1 ignored. Unrelated, from the same runs, in case it helps someone else: the 1.0-1.5 s freezes on the black screen before the first logo are a title worker making about 54,000 one-page `XMemMapPhysicalPages` calls while the main thread polls with `SleepEx`. About 0.5 s of that is ours (`VirtualFree` placeholder split + `MapViewOfFile3` ≈ 6.8 µs per call, commit ≈ 1.6 µs). The rest is the title's own page-list comparison. They happen before anything is drawn, so they are not visible as stutter. AI-assisted (Claude Code); hashes, counts and log lines only.
Author
Owner

@⁠ryotdev on GitHub · 2026-11-24 22:10 UTC · original · edited 2026-11-24 22:22 UTC

Confirmed the boot-video fix on an NVIDIA RTX 5070 (driver 610.88), Ryzen 7 7800X3D, Windows, native D3D12, Series X profile. I compared 4e17478 with #115 (2ef19e0, also cleanly applied to 2119b0e, whose source tree matches 4e17478). Both runs used the same saved setup, separately copied warm caches and identical inputs.

I captured three bursts of 18 consecutive frames in the animated startup video, starting at host frames 390, 470 and 555. Both sides showed the moving intro in all three bursts. I hashed the decoded RGB pixels. A return means frame N matches N−3 with at least one different image in between.

Distinct images per 18-frame burst Returns at lag 3 per 15 comparisons
Main 5, 5, 5 12, 13, 13
With #115 18, 18, 18 0, 0, 0

I also ran the Windows shared-page regressions against main as negative controls: the write-through-another-view and newly-mapped-alias tests both failed with an empty dirty-page result on main and passed with #115. All 33 focused watch, XMem and DirectStorage tests passed with the change. These captures measure frame content, so I’m reporting the reversal fix separately from frame pacing or gameplay FPS. AI-assisted testing.

World checkpoint follow-up. This revision also exited in two runs shortly after entering the prison scene on my RTX 5070. Windows exit code was 0x80000003 in both, without a reported GPU device loss. The last captured frames were 40 and 24 frames past the first 500-draw frame. One used joined rehash runs with descriptor statistics, the other the normal direct-queue play profile. I reran main with the latter profile and the same saved checkpoint and reached +150 frames. Earlier main comparisons reached +500. I haven't isolated which change accounts for the exits. The intro result above stands; I would keep later gameplay stability a separate check. The narrower patch from #63 applied to 4e17478 also gave 18 distinct frames in each of the three intro bursts and zero three-frame returns. With that patch, the same checkpoint reached +500 frames on the standard direct-queue play profile.

**@⁠ryotdev** on GitHub · 2026-11-24 22:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7145894136) · edited 2026-11-24 22:22 UTC Confirmed the boot-video fix on an NVIDIA RTX 5070 (driver 610.88), Ryzen 7 7800X3D, Windows, native D3D12, Series X profile. I compared 4e17478 with #115 (2ef19e0, also cleanly applied to 2119b0e, whose source tree matches 4e17478). Both runs used the same saved setup, separately copied warm caches and identical inputs. I captured three bursts of 18 consecutive frames in the animated startup video, starting at host frames 390, 470 and 555. Both sides showed the moving intro in all three bursts. I hashed the decoded RGB pixels. A return means frame N matches N−3 with at least one different image in between. | | Distinct images per 18-frame burst | Returns at lag 3 per 15 comparisons | | --- | --- | --- | | Main | 5, 5, 5 | 12, 13, 13 | | With #115 | 18, 18, 18 | 0, 0, 0 | I also ran the Windows shared-page regressions against main as negative controls: the write-through-another-view and newly-mapped-alias tests both failed with an empty dirty-page result on main and passed with #115. All 33 focused watch, XMem and DirectStorage tests passed with the change. These captures measure frame content, so I’m reporting the reversal fix separately from frame pacing or gameplay FPS. AI-assisted testing. **World checkpoint follow-up.** This revision also exited in two runs shortly after entering the prison scene on my RTX 5070. Windows exit code was 0x80000003 in both, without a reported GPU device loss. The last captured frames were 40 and 24 frames past the first 500-draw frame. One used joined rehash runs with descriptor statistics, the other the normal direct-queue play profile. I reran main with the latter profile and the same saved checkpoint and reached +150 frames. Earlier main comparisons reached +500. I haven't isolated which change accounts for the exits. The intro result above stands; I would keep later gameplay stability a separate check. The narrower patch from #63 applied to 4e17478 also gave 18 distinct frames in each of the three intro bursts and zero three-frame returns. With that patch, the same checkpoint reached +500 frames on the standard direct-queue play profile.
Author
Owner

@⁠joroyt on GitHub · 2026-11-24 23:53 UTC · original

A defect in this PR's protect, with a fix and a failing test: https://github.com/Spexivus/victory-fork/pull/1 (one commit on top of 2ef19e0, +49/-1 in watch.rs).

What is wrong. protect makes the other views of the pages read-only through protect_here, which also notes them clean. The host copies at those other addresses have not taken the pages, so their next check reports nothing written and they keep the bytes from before the write. It needs two host copies of one physical page to show, which the video's textures do not have and the world does: the pages I looked at were shown at five or six title addresses, each with a host copy of its own.

The fix. The other views are made read-only and noted protected, not clean; guard already reports such a block written at its view's next check.

Test. a_write_is_reported_at_every_checked_view fails on 2ef19e0 (left: Some([]) at the second view's first check) and passes with the fix; the other ten watch:: tests pass in both.

Measured on an RTX 5070 (driver 32.0.16.2124, Windows 11, diag build, 2119b0e + #156, VICTORY_BVH_BUILDER=1), with a local diagnostic that compares each range a submission declares as written with title memory right after its refresh:

tree copies that differ from title memory after their refresh
without this PR windows: 13-29 pieces of 64 KiB a second that stay different while the title's bytes do not change; title buffers: 948 pieces (44 MB)
with this PR (2ef19e0) windows: none. Title buffers: 747-870 pieces (34-40 MB) in every run, the copy all zeros and title memory all 0xff; the blocks are mapped views, PAGE_READONLY, noted copied
with this PR and the fix 0 pieces, 2 of 2 runs

So this PR also matters outside textures: without it the copies of the memory the structure builder works in go stale within a second.

It does not fix #16: the title still crashes 5-15 s after the builder starts with both changes (2 of 2 runs, +0x4f38ba5 / +0x8f92a reading 0xffffffffffffffff).

Not tested: AMD, Intel, Windows 10, the boot video with the fix on top.

AI use: Claude (Anthropic) in OpenCode, on my machine with my own copy of the title; no game data attached.

**@⁠joroyt** on GitHub · 2026-11-24 23:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7147903914) A defect in this PR's `protect`, with a fix and a failing test: https://github.com/Spexivus/victory-fork/pull/1 (one commit on top of `2ef19e0`, +49/-1 in `watch.rs`). **What is wrong.** `protect` makes the other views of the pages read-only through `protect_here`, which also notes them clean. The host copies at those other addresses have not taken the pages, so their next check reports nothing written and they keep the bytes from before the write. It needs two host copies of one physical page to show, which the video's textures do not have and the world does: the pages I looked at were shown at five or six title addresses, each with a host copy of its own. **The fix.** The other views are made read-only and noted protected, not clean; `guard` already reports such a block written at its view's next check. **Test.** `a_write_is_reported_at_every_checked_view` fails on `2ef19e0` (`left: Some([])` at the second view's first check) and passes with the fix; the other ten `watch::` tests pass in both. **Measured** on an RTX 5070 (driver 32.0.16.2124, Windows 11, diag build, `2119b0e` + #156, `VICTORY_BVH_BUILDER=1`), with a local diagnostic that compares each range a submission declares as written with title memory right after its refresh: | tree | copies that differ from title memory after their refresh | |---|---| | without this PR | windows: 13-29 pieces of 64 KiB a second that stay different while the title's bytes do not change; title buffers: 948 pieces (44 MB) | | with this PR (`2ef19e0`) | windows: none. Title buffers: 747-870 pieces (34-40 MB) in every run, the copy all zeros and title memory all `0xff`; the blocks are mapped views, `PAGE_READONLY`, noted copied | | with this PR and the fix | 0 pieces, 2 of 2 runs | So this PR also matters outside textures: without it the copies of the memory the structure builder works in go stale within a second. It does not fix #16: the title still crashes 5-15 s after the builder starts with both changes (2 of 2 runs, `+0x4f38ba5` / `+0x8f92a` reading `0xffffffffffffffff`). Not tested: AMD, Intel, Windows 10, the boot video with the fix on top. AI use: Claude (Anthropic) in OpenCode, on my machine with my own copy of the title; no game data attached.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-25 00:44 UTC · original

Measured in the title with joroyt's Spexivus/victory-fork#1 (0bcc069) on top, and one problem this PR brings that needs fixing before it can go in.

RTX 4070, 2119b0e + this PR (+ 0bcc069 where noted), default mode (no relay, no late wait, no loop limit), a save that loads into the cell, diag build, 15-minute runs. A local diagnostic compares pages the guard reports clean with title memory and counts a page as stale when it still differs at three checks in a row (details on #62).

Tree Runs First room at the window Stale clean pages Of them on pages with several views Frame
2119b0e 2 missing in both (sky beside the frame) 2,598 in one run all ~430 ms
+ this PR 1 (title stopped at 136 s) 88 in 136 s 87 preparation ~1.7 s
+ this PR + 0bcc069 3 drawn in both runs that reached it (walls, posters, chain-link) 0–6 per run 0 ~440 ms

So with 0bcc069 the copies over aliased pages stop going stale, and the room comes back.

The problem: the title stops itself in 2 of the 4 runs with this PR (one without 0bcc069 at 136 s, one with it at 176 s): int3 at +0x23d8f03. In both, the line right before is
dstorage: request failed: copying options=0x0 ... destination_size=1600 ... hr=0x800706f8
(ERROR_INVALID_USER_BUFFER: the kernel read into the destination met a read-only page), and in one also a destination's physical pages could not be written. Without this PR: no request failure and no stop in either run.

Why it happens more with this PR: kernel_will_write opens the destination (and with this PR its other views) before the read, but nothing stops a guard check on another thread from protecting those blocks again before the kernel writes them. With every view of guarded pages protected, a raw DirectStorage destination is now often one of them. A fix is to have kernel_will_write hold the blocks open until the read is done (a value whose drop lets them be guarded again, the blocks reported written meanwhile), and the same for ReadFile/fread in files.rs and the page-destination path. I'm writing that on top of 0bcc069 with a test that reproduces the failure and will post it here.

**@⁠SantannaCarlos** on GitHub · 2026-11-25 00:44 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7148820820) Measured in the title with joroyt's Spexivus/victory-fork#1 (`0bcc069`) on top, and one problem this PR brings that needs fixing before it can go in. RTX 4070, `2119b0e` + this PR (+ `0bcc069` where noted), default mode (no relay, no late wait, no loop limit), a save that loads into the cell, diag build, 15-minute runs. A local diagnostic compares pages the guard reports clean with title memory and counts a page as stale when it still differs at three checks in a row (details on #62). | Tree | Runs | First room at the window | Stale clean pages | Of them on pages with several views | Frame | |---|---|---|---|---|---| | `2119b0e` | 2 | missing in both (sky beside the frame) | 2,598 in one run | all | ~430 ms | | + this PR | 1 | (title stopped at 136 s) | 88 in 136 s | 87 | preparation ~1.7 s | | + this PR + `0bcc069` | 3 | **drawn in both runs that reached it** (walls, posters, chain-link) | 0–6 per run | **0** | ~440 ms | So with `0bcc069` the copies over aliased pages stop going stale, and the room comes back. **The problem: the title stops itself in 2 of the 4 runs with this PR** (one without `0bcc069` at 136 s, one with it at 176 s): `int3` at `+0x23d8f03`. In both, the line right before is `dstorage: request failed: copying options=0x0 ... destination_size=1600 ... hr=0x800706f8` (`ERROR_INVALID_USER_BUFFER`: the kernel read into the destination met a read-only page), and in one also `a destination's physical pages could not be written`. Without this PR: no request failure and no stop in either run. Why it happens more with this PR: `kernel_will_write` opens the destination (and with this PR its other views) before the read, but nothing stops a guard check on another thread from protecting those blocks again before the kernel writes them. With every view of guarded pages protected, a raw DirectStorage destination is now often one of them. A fix is to have `kernel_will_write` hold the blocks open until the read is done (a value whose drop lets them be guarded again, the blocks reported written meanwhile), and the same for `ReadFile`/`fread` in `files.rs` and the page-destination path. I'm writing that on top of `0bcc069` with a test that reproduces the failure and will post it here.
Author
Owner

@⁠oz-stanislav-zhukov on GitHub · 2026-11-25 00:47 UTC · original

Same stop as @⁠SantannaCarlos describes, on another setup, and it comes fast with the speed switches.

Setup: RTX 5060 Ti 16 GB (driver 621.24), i7-14700KF, Windows 10 22H2 (#22 for the Agility SDK), release build, Series X. Tree 4e17478 + #22 + #58 + this PR (2ef19e0) + #410 + #51 (one run also + #206). VICTORY_SHADER_OPT=0 VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1 VICTORY_RELAY=1 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024.

tree runs result
with this PR (+ #206) 1 0xc0000005 at +0x541f03f reading 0x2ee5028a92f at world entry (~frame 1736, ~1 min after launch)
with this PR (without #206) 1 int3 at +0x23d8f03, ~1.5 min after launch
without this PR (same tree otherwise) 1 reaches the cell, no stop, ~3 fps

Before both stops the log has dstorage: a destination's physical pages could not be written ... its request fails (several, len=12288/16384, pages=1), and before the int3 also dstorage: request failed: copying ... destination_size=17232 ... hr=0x800706f8. So the access violation looks like the same failed read, the title using the unwritten bytes as a pointer instead of stopping.

With VICTORY_LATE_WAIT=3 + VICTORY_RELAY=1 it came in the first minute or two in every run, which may help test the hold-open fix. Happy to run it here once it is posted.

AI-assisted (Claude Code, Claude Opus 5.5); numbers from local logs, no game data attached.

**@⁠oz-stanislav-zhukov** on GitHub · 2026-11-25 00:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7148875270) Same stop as @⁠SantannaCarlos describes, on another setup, and it comes fast with the speed switches. **Setup:** RTX 5060 Ti 16 GB (driver 621.24), i7-14700KF, **Windows 10 22H2** (#22 for the Agility SDK), release build, Series X. Tree `4e17478` + #22 + #58 + this PR (`2ef19e0`) + #410 + #51 (one run also + #206). `VICTORY_SHADER_OPT=0 VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1 VICTORY_RELAY=1 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`. | tree | runs | result | |---|---|---| | with this PR (+ #206) | 1 | `0xc0000005` at `+0x541f03f` reading `0x2ee5028a92f` at world entry (~frame 1736, ~1 min after launch) | | with this PR (without #206) | 1 | `int3` at `+0x23d8f03`, ~1.5 min after launch | | without this PR (same tree otherwise) | 1 | reaches the cell, no stop, ~3 fps | Before both stops the log has `dstorage: a destination's physical pages could not be written ... its request fails` (several, `len=12288`/`16384`, `pages=1`), and before the `int3` also `dstorage: request failed: copying ... destination_size=17232 ... hr=0x800706f8`. So the access violation looks like the same failed read, the title using the unwritten bytes as a pointer instead of stopping. With `VICTORY_LATE_WAIT=3` + `VICTORY_RELAY=1` it came in the first minute or two in every run, which may help test the hold-open fix. Happy to run it here once it is posted. AI-assisted (Claude Code, Claude Opus 5.5); numbers from local logs, no game data attached.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 01:37 UTC · original

Tested this PR on its own (merged onto current main 2119b0e, release build, RTX 5070, driver 32.0.16.2124, VICTORY_RELAY=2, same key script, 330 s per run, real title).

  • This PR alone: 2 runs out of 2 ended with the title's own unhandled breakpoint (exit 0x80000003) about 2-3 minutes in, right after a dstorage: request failed: copying ... hr=0x800706f8 warning. No device removed, no host ERROR before that.
  • main alone: 0 crashes in 2 runs of the same script (about 4 fps, ~5000 draws/frame in the cell scene at t=280-330 s).
  • A build with every other pending PR but not this one also crashed once (different exception, 0xC0000005), so I cannot attribute the crash to this PR with certainty; n is small and the timing is not deterministic.

Not verified: whether the boot-video glitch this PR targets is fixed (not looked at in these runs), and whether the dstorage failure is caused by the page guard or only exposed by it.

**@⁠Revens2** on GitHub · 2026-11-25 01:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7149773080) Tested this PR on its own (merged onto current main 2119b0e, release build, RTX 5070, driver 32.0.16.2124, VICTORY_RELAY=2, same key script, 330 s per run, real title). - This PR alone: 2 runs out of 2 ended with the title's own unhandled breakpoint (exit 0x80000003) about 2-3 minutes in, right after a `dstorage: request failed: copying ... hr=0x800706f8` warning. No device removed, no host ERROR before that. - main alone: 0 crashes in 2 runs of the same script (about 4 fps, ~5000 draws/frame in the cell scene at t=280-330 s). - A build with every other pending PR but not this one also crashed once (different exception, 0xC0000005), so I cannot attribute the crash to this PR with certainty; n is small and the timing is not deterministic. Not verified: whether the boot-video glitch this PR targets is fixed (not looked at in these runs), and whether the dstorage failure is caused by the page guard or only exposed by it.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-25 01:51 UTC · original

The fix for the stops above is Spexivus/victory-fork#2, on top of this branch and joroyt's #1 there: kernel_will_write now holds the destination (and the other views of its pages) open until the kernel has written. With it, 3 of 3 runs in the cell ran 15 minutes with no DirectStorage request failing and no stop, and the room was drawn in all three; numbers and tests in the PR.

**@⁠SantannaCarlos** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7150045266) The fix for the stops above is Spexivus/victory-fork#2, on top of this branch and joroyt's #1 there: `kernel_will_write` now holds the destination (and the other views of its pages) open until the kernel has written. With it, 3 of 3 runs in the cell ran 15 minutes with no DirectStorage request failing and no stop, and the room was drawn in all three; numbers and tests in the PR.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 02:05 UTC · original

Tested this PR merged onto current main (c96b4f2) against main alone: release build, RTX 5070 12 GB, driver 32.0.16.2124, VICTORY_RELAY=2, same key script, 240 s per run, 3 runs each. A main run and a PR run were always running at the same time (two sessions), so GPU/host memory pressure is a confound.

  • main alone: 1 of 3 runs reached 240 s; 2 of 3 ended around t=150-230 s with host GPU failure: a host command list did not close (0x8007000E) (out of memory), no device removed before it.
  • main + this PR: 2 of 3 ended with the same 0x8007000E failure (t=125-155 s); 1 of 3 ended with an access violation (0xC0000005) at about t=160 s.
  • No dstorage: request failed ... 0x800706f8 warning in any of the 6 runs, and no 0x80000003 breakpoint.

So I could not reproduce the earlier report (breakpoint after a dstorage failure, only with this PR): on this main both sides fail, in similar proportions, and the PR does not stand out at n=3. The 0xC0000005 run is one sample and I did not look for its cause.

Not verified: whether the boot-video glitch is fixed (not looked at), and whether the failures above also happen with one session at a time.

**@⁠Revens2** on GitHub · 2026-11-25 02:05 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7150297244) Tested this PR merged onto current main (c96b4f2) against main alone: release build, RTX 5070 12 GB, driver 32.0.16.2124, VICTORY_RELAY=2, same key script, 240 s per run, 3 runs each. A main run and a PR run were always running at the same time (two sessions), so GPU/host memory pressure is a confound. - main alone: 1 of 3 runs reached 240 s; 2 of 3 ended around t=150-230 s with `host GPU failure: a host command list did not close (0x8007000E)` (out of memory), no device removed before it. - main + this PR: 2 of 3 ended with the same 0x8007000E failure (t=125-155 s); 1 of 3 ended with an access violation (0xC0000005) at about t=160 s. - No `dstorage: request failed ... 0x800706f8` warning in any of the 6 runs, and no 0x80000003 breakpoint. So I could not reproduce the earlier report (breakpoint after a dstorage failure, only with this PR): on this main both sides fail, in similar proportions, and the PR does not stand out at n=3. The 0xC0000005 run is one sample and I did not look for its cause. Not verified: whether the boot-video glitch is fixed (not looked at), and whether the failures above also happen with one session at a time.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-25 02:40 UTC · original

@⁠UwUCammie @⁠Revens2 thanks, that's the same signature on both platforms (ERROR_NOACCESS under Wine, ERROR_INVALID_USER_BUFFER on Windows). The hold-open fix is posted as Spexivus/victory-fork#2. To test this PR with it, the branch is SantannaCarlos/victory-fork fx/kernel-write-held: this PR (2ef19e0) + joroyt's Spexivus/victory-fork#1 (0bcc069) + the fix (90697f1), on 4e17478. It merges onto 2119b0e; I haven't tried c96b4f2 yet.

git fetch https://github.com/SantannaCarlos/victory-fork fx/kernel-write-held
git merge FETCH_HEAD

On the 4070, with it, 3 of 3 runs in the cell went 15 minutes with no request failed line and no stop. A run on Wine that reaches the stop in 2–3 minutes without it would be a good check of the ERROR_NOACCESS path, which I can't run here. If a read comes back pending in ReadFile, a warning says so once (that case isn't held yet).

**@⁠SantannaCarlos** on GitHub · 2026-11-25 02:40 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7151039238) @⁠UwUCammie @⁠Revens2 thanks, that's the same signature on both platforms (`ERROR_NOACCESS` under Wine, `ERROR_INVALID_USER_BUFFER` on Windows). The hold-open fix is posted as Spexivus/victory-fork#2. To test this PR with it, the branch is `SantannaCarlos/victory-fork` `fx/kernel-write-held`: this PR (`2ef19e0`) + joroyt's Spexivus/victory-fork#1 (`0bcc069`) + the fix (`90697f1`), on `4e17478`. It merges onto `2119b0e`; I haven't tried `c96b4f2` yet. ``` git fetch https://github.com/SantannaCarlos/victory-fork fx/kernel-write-held git merge FETCH_HEAD ``` On the 4070, with it, 3 of 3 runs in the cell went 15 minutes with no `request failed` line and no stop. A run on Wine that reaches the stop in 2–3 minutes without it would be a good check of the `ERROR_NOACCESS` path, which I can't run here. If a read comes back pending in `ReadFile`, a warning says so once (that case isn't held yet).
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 05:13 UTC · original

Tested in the game, sequentially and alone on the machine (no other title session at the same time), RTX 5070 12 GB, diagnostics build, VICTORY_RELAY=2, same key script every run, 900 s per run. Base is origin/main c96b4f2 and this PR at 2ef19e0.

main main + this PR
runs reaching 900 s 3 of 3 1 of 3
title breakpoint 0x80000003 at about 130-140 s 0 2
median fps after the world loads 4.84 / 5.00 / 5.04 4.67 (the one run that survived)
dstorage request failed: copying ... hr=0x800706f8 0 2 of 3 runs

In both crashed runs the title raised the breakpoint within about 150 ms of the failed request, always an unpacked read (options=0x0, so the kernel_will_write path, not a page destination). 0x800706f8 is ERROR_INVALID_USER_BUFFER. It never appears on main (0 of 3).

Probable cause (read from the code, not proven by a trace): kernel_will_write opens the guards, then the file read starts. Since this PR protect also makes every other view of the same pages read-only, and views_mapped re-checks guards when a view is mapped, so a guard can be closed again between the open and the kernel's write.

Candidate fix, tested on top of this PR: in into_destination, on the unpacked path, call kernel_will_write and read again when the read fails with 0x800706f8 (at most 16 times). Three more solo runs (420 s each): 0 breakpoints, 0 failed requests, median fps 5.17 / 5.15 / 5.25. Only three runs, and the failure was 2 in 3 before, so this is encouraging, not proof. A cleaner fix would keep the guard from re-arming the pages a read is in flight on. Patch:

-    fill: impl FnOnce(&mut [u8]) -> Result<usize, HRESULT>,
+    mut fill: impl FnMut(&mut [u8]) -> Result<usize, HRESULT>,
 ...
-        victory_gpu::kernel_will_write(request.destination as usize, len);
-        let out = unsafe { std::slice::from_raw_parts_mut(request.destination.cast::<u8>(), len) };
-        return fill(out).map(drop);
+        const INVALID_USER_BUFFER: i32 = 0x8007_06f8_u32 as i32;
+        let mut tries = 0;
+        loop {
+            victory_gpu::kernel_will_write(request.destination as usize, len);
+            let out = unsafe { std::slice::from_raw_parts_mut(request.destination.cast::<u8>(), len) };
+            match fill(out) {
+                Err(INVALID_USER_BUFFER) if tries < 16 => tries += 1,
+                done => return done.map(drop),
+            }
+        }

Not verified: whether the boot video glitch this PR targets is fixed (not looked at in these runs); cargo test was not run on the patch.

**@⁠Revens2** on GitHub · 2026-11-25 05:13 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7153563063) Tested in the game, sequentially and alone on the machine (no other title session at the same time), RTX 5070 12 GB, diagnostics build, `VICTORY_RELAY=2`, same key script every run, 900 s per run. Base is origin/main c96b4f2 and this PR at 2ef19e0. | | main | main + this PR | |---|---|---| | runs reaching 900 s | 3 of 3 | 1 of 3 | | title breakpoint `0x80000003` at about 130-140 s | 0 | 2 | | median fps after the world loads | 4.84 / 5.00 / 5.04 | 4.67 (the one run that survived) | | dstorage `request failed: copying ... hr=0x800706f8` | 0 | 2 of 3 runs | In both crashed runs the title raised the breakpoint within about 150 ms of the failed request, always an unpacked read (`options=0x0`, so the `kernel_will_write` path, not a page destination). `0x800706f8` is ERROR_INVALID_USER_BUFFER. It never appears on main (0 of 3). Probable cause (read from the code, not proven by a trace): `kernel_will_write` opens the guards, then the file read starts. Since this PR `protect` also makes every other view of the same pages read-only, and `views_mapped` re-checks guards when a view is mapped, so a guard can be closed again between the open and the kernel's write. Candidate fix, tested on top of this PR: in `into_destination`, on the unpacked path, call `kernel_will_write` and read again when the read fails with `0x800706f8` (at most 16 times). Three more solo runs (420 s each): 0 breakpoints, 0 failed requests, median fps 5.17 / 5.15 / 5.25. Only three runs, and the failure was 2 in 3 before, so this is encouraging, not proof. A cleaner fix would keep the guard from re-arming the pages a read is in flight on. Patch: ```diff - fill: impl FnOnce(&mut [u8]) -> Result<usize, HRESULT>, + mut fill: impl FnMut(&mut [u8]) -> Result<usize, HRESULT>, ... - victory_gpu::kernel_will_write(request.destination as usize, len); - let out = unsafe { std::slice::from_raw_parts_mut(request.destination.cast::<u8>(), len) }; - return fill(out).map(drop); + const INVALID_USER_BUFFER: i32 = 0x8007_06f8_u32 as i32; + let mut tries = 0; + loop { + victory_gpu::kernel_will_write(request.destination as usize, len); + let out = unsafe { std::slice::from_raw_parts_mut(request.destination.cast::<u8>(), len) }; + match fill(out) { + Err(INVALID_USER_BUFFER) if tries < 16 => tries += 1, + done => return done.map(drop), + } + } ``` Not verified: whether the boot video glitch this PR targets is fixed (not looked at in these runs); `cargo test` was not run on the patch.
Author
Owner

@⁠ArturoWolff on GitHub · 2026-11-25 05:58 UTC · original

The shared-page negative control that @⁠ryotdev reported on Windows also distinguishes the two modes on Linux / GE-Proton11-14, using integrated main 8dd30ab, not the standalone PR head. I built the Windows release test binary on Linux (x86_64-pc-windows-gnullvm) and ran watch::tests::a_write_through_another_view_is_reported_at_the_guarded_one in separate processes with that same executable:

VICTORY_VIEW_GUARD After writing through the second mapping
0 The first mapping reported no dirty pages (Some([])); assertion failed at watch.rs:1314 as expected.
1 The first mapping reported just the written block; the following clean check also passed.

With defaults, all 12 watch:: tests and all 26 modules::xmem:: / modules::dstorage:: tests passed, single-threaded. This checks the actual Wine memory-mapping path without a game or GPU workload. It does not test the title-load failures reported above or establish that the black composite input in #599 came from an aliased page.

AI disclosure: Hermes Agent built and ran these tests, checked the negative control, and wrote this comment on ArturoWolff’s behalf.

**@⁠ArturoWolff** on GitHub · 2026-11-25 05:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7154316608) The shared-page negative control that @⁠ryotdev reported on Windows also distinguishes the two modes on Linux / GE-Proton11-14, using **integrated main `8dd30ab`**, not the standalone PR head. I built the Windows release test binary on Linux (`x86_64-pc-windows-gnullvm`) and ran `watch::tests::a_write_through_another_view_is_reported_at_the_guarded_one` in separate processes with that same executable: | `VICTORY_VIEW_GUARD` | After writing through the second mapping | |---|---| | `0` | The first mapping reported no dirty pages (`Some([])`); assertion failed at `watch.rs:1314` as expected. | | `1` | The first mapping reported just the written block; the following clean check also passed. | With defaults, all 12 `watch::` tests and all 26 `modules::xmem::` / `modules::dstorage::` tests passed, single-threaded. This checks the actual Wine memory-mapping path without a game or GPU workload. It does **not** test the title-load failures reported above or establish that the black composite input in #599 came from an aliased page. AI disclosure: Hermes Agent built and ran these tests, checked the negative control, and wrote this comment on ArturoWolff’s behalf.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 06:20 UTC · original

@⁠SantannaCarlos thanks for the branch and for naming the cause. Tested fx/kernel-write-held here, on our setup, one session at a time.

Tree: origin/main 310c6eb + git merge FETCH_HEAD of your branch (fx/kernel-write-held: this PR + Spexivus#1 + 90697f1). Merge was clean, no conflicts (auto-merge in shadow.rs, texture.rs, dstorage.rs, xmem.rs). Diagnostics build (needed for VICTORY_KEYS), cargo build --locked only; cargo test not run on the merge.

Setup: RTX 5070 12 GB, driver 32.0.16.2124, Windows 11, VICTORY_RELAY=2, same key script as in my earlier table (Enter presses, then W/A/D 0.2 s bursts every 60 s from t=600 s), 3 sequential solo runs of 900 s, nothing else started by us at the same time.

main (c96b4f2) #115 alone (2ef19e0) your branch on 310c6eb
runs reaching 900 s 3 of 3 1 of 3 3 of 3
title breakpoint 0x80000003 0 2 0
dstorage: request failed ... 0x800706f8 0 2 of 3 runs 0 of 3
0x8007000E / 0xC0000005 0 / 0 0 / 0 0 / 0
device removed 0 0 0
median fps after the world loads 4.84 / 5.00 / 5.04 4.67 3.34 / 2.76 / 2.49

So the crash I reported on #115 is gone with this branch in our setup: no failed request, no breakpoint, all three runs alive at the end of 900 s, the world (about 5,000 draws per frame in the cell scene) reached at t=126-142 s. The mechanism you describe (a guard re-closing the destination between kernel_will_write and the read) matches the 0x800706f8 line we saw right before every breakpoint.

One difference I can't explain: median fps is lower (2.5-3.3 against 4.7-5.0). I did not run main on 310c6eb, so the base differs between the columns, and a second victory process was visible in the process list once during the third run (not checked whether it was a real concurrent session), so I can't attribute the drop to the branch. I'd call it a question to check, not a finding.

Not verified: whether the boot video is fixed with this branch (not looked at); cause of the lower fps; Wine / ERROR_NOACCESS (not testable here, Windows only); the pending-ReadFile warning you mention (I did not look for it in the logs); behaviour beyond 15 min; any other GPU. n=3, and the failure rate before was 2 in 3, so this is strong evidence for the signature, not proof that every path is held. Counts only; no game data.

AI-assisted (Claude Code); numbers from local run logs.

**@⁠Revens2** on GitHub · 2026-11-25 06:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7154688890) @⁠SantannaCarlos thanks for the branch and for naming the cause. Tested `fx/kernel-write-held` here, on our setup, one session at a time. **Tree:** origin/main `310c6eb` + `git merge FETCH_HEAD` of your branch (`fx/kernel-write-held`: this PR + Spexivus#1 + `90697f1`). Merge was clean, no conflicts (auto-merge in `shadow.rs`, `texture.rs`, `dstorage.rs`, `xmem.rs`). Diagnostics build (needed for `VICTORY_KEYS`), `cargo build --locked` only; `cargo test` not run on the merge. **Setup:** RTX 5070 12 GB, driver 32.0.16.2124, Windows 11, `VICTORY_RELAY=2`, same key script as in my earlier table (Enter presses, then W/A/D 0.2 s bursts every 60 s from t=600 s), 3 sequential solo runs of 900 s, nothing else started by us at the same time. | | main (`c96b4f2`) | #115 alone (`2ef19e0`) | your branch on `310c6eb` | |---|---|---|---| | runs reaching 900 s | 3 of 3 | 1 of 3 | **3 of 3** | | title breakpoint `0x80000003` | 0 | 2 | **0** | | `dstorage: request failed ... 0x800706f8` | 0 | 2 of 3 runs | **0 of 3** | | `0x8007000E` / `0xC0000005` | 0 / 0 | 0 / 0 | **0 / 0** | | device removed | 0 | 0 | 0 | | median fps after the world loads | 4.84 / 5.00 / 5.04 | 4.67 | 3.34 / 2.76 / 2.49 | So the crash I reported on #115 is gone with this branch in our setup: no failed request, no breakpoint, all three runs alive at the end of 900 s, the world (about 5,000 draws per frame in the cell scene) reached at t=126-142 s. The mechanism you describe (a guard re-closing the destination between `kernel_will_write` and the read) matches the 0x800706f8 line we saw right before every breakpoint. **One difference I can't explain:** median fps is lower (2.5-3.3 against 4.7-5.0). I did not run main on `310c6eb`, so the base differs between the columns, and a second `victory` process was visible in the process list once during the third run (not checked whether it was a real concurrent session), so I can't attribute the drop to the branch. I'd call it a question to check, not a finding. **Not verified:** whether the boot video is fixed with this branch (not looked at); cause of the lower fps; Wine / `ERROR_NOACCESS` (not testable here, Windows only); the pending-`ReadFile` warning you mention (I did not look for it in the logs); behaviour beyond 15 min; any other GPU. n=3, and the failure rate before was 2 in 3, so this is strong evidence for the signature, not proof that every path is held. Counts only; no game data. AI-assisted (Claude Code); numbers from local run logs.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 06:28 UTC · original

Update for anyone testing this PR: main is now at 8dd30ab, which already carries the guard over every view of a page, the "read beside" fix for kernel reads and the retry of failed page-destination reads (see the commit message and README credits: myokex, Joshua Odom, adapting this PR, joroyt's correction and tightfall's part of VIctory #1122). So the two crash signatures measured here (0x80000003 after dstorage: request failed ... 0x800706f8) should be re-tested on main itself rather than on this branch.

We have a solo three-run test of SantannaCarlos's fx/kernel-write-held (3 of 3 reached 900 s, no failed request) and of this PR alone (1 of 3). We have not yet run main at 8dd30ab solo; that is the next comparison, including the lower fps (median 2.5 to 3.3 against 4.8 to 5.0 on c96b4f2) that we could not attribute. We will post the numbers here.

**@⁠Revens2** on GitHub · 2026-11-25 06:28 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7154820484) Update for anyone testing this PR: `main` is now at 8dd30ab, which already carries the guard over every view of a page, the "read beside" fix for kernel reads and the retry of failed page-destination reads (see the commit message and README credits: myokex, Joshua Odom, adapting this PR, joroyt's correction and tightfall's part of VIctory #1122). So the two crash signatures measured here (`0x80000003` after `dstorage: request failed ... 0x800706f8`) should be re-tested on `main` itself rather than on this branch. We have a solo three-run test of SantannaCarlos's `fx/kernel-write-held` (3 of 3 reached 900 s, no failed request) and of this PR alone (1 of 3). We have not yet run `main` at 8dd30ab solo; that is the next comparison, including the lower fps (median 2.5 to 3.3 against 4.8 to 5.0 on c96b4f2) that we could not attribute. We will post the numbers here.
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-25 01:38 UTC · original · edited 2026-11-25 06:36 UTC

Same stop reproduced on Linux/Wine, with the same log signature, and a clean A/B on the same tree. Counters and offsets only, no game data.

Setup: RX 7900 XT (RADV, Mesa 26.3.1), Wine 11.22 with vkd3d-proton (GE cae8353ed) + DXVK dxgi, Series X, diag build, VICTORY_PIPELINE_WAIT_MS=24 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024 VICTORY_NO_WATCHDOG=1, no relay, no late wait. Tree: myokex/victory-amd (2119b0e + 7 commits), whose c6dc4d8 carries this PR's code.

tree runs result
victory-amd without c6dc4d8 (8e6d29e and 8e6d29e + 1daf3fd) 2 (8 and 7 min) no dstorage: request failed, no stop; ~330-350 ms/frame; copies ~150 MB/frame
+ c6dc4d8 (as 070df42) 2 of 2 title stops 1.5-3 min after the world loads; copies ~280-295 MB/frame (about twice as much)

The two stops, both on a title worker thread (+0x2215eca job loop): 0xc0000005 at +0x2b8035 (read of 0x0) and 0xc0000005 at +0x43051d (write of 0x0). In the second run the line right before the stop (<1 s earlier) is

dstorage: request failed: copying options=0x0 offset=19585040 source_size=38128 destination_size=38128 intermediate_size=0 tag=0 hr=0x800703e6

0x800703e6 is ERROR_NOACCESS, which is what a read into a page that is read-only at that moment looks like on Wine; it is the same failure as the 0x800706f8 reported above on Windows (ERROR_INVALID_USER_BUFFER). The first run has 3 request failed lines before its stop; the two clean runs have none. So it reads like the failure described above: the destination of a DirectStorage read is protected again by a guard check on another thread before the read lands, and the title uses the unwritten bytes as a pointer.

That supports @⁠SantannaCarlos's diagnosis and the hold-open fix (keeping the destination's blocks open until the read is done, for kernel_will_write, ReadFile/fread and the page-destination path). Happy to run it here on Linux once it is posted; this setup reaches the crash in 2-3 minutes, so a 6-minute run is a decent test.

**@⁠UwUCammie** on GitHub · 2026-11-25 01:38 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7149774601) · edited 2026-11-25 06:36 UTC Same stop reproduced on Linux/Wine, with the same log signature, and a clean A/B on the same tree. Counters and offsets only, no game data. **Setup:** RX 7900 XT (RADV, Mesa 26.3.1), Wine 11.22 with vkd3d-proton (GE `cae8353ed`) + DXVK dxgi, Series X, diag build, `VICTORY_PIPELINE_WAIT_MS=24 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024 VICTORY_NO_WATCHDOG=1`, no relay, no late wait. Tree: `myokex/victory-amd` (`2119b0e` + 7 commits), whose `c6dc4d8` carries this PR's code. | tree | runs | result | |---|---|---| | victory-amd without `c6dc4d8` (`8e6d29e` and `8e6d29e` + `1daf3fd`) | 2 (8 and 7 min) | no `dstorage: request failed`, no stop; ~330-350 ms/frame; copies ~150 MB/frame | | + `c6dc4d8` (as `070df42`) | 2 of 2 | title stops 1.5-3 min after the world loads; copies ~280-295 MB/frame (about twice as much) | The two stops, both on a title worker thread (`+0x2215eca` job loop): `0xc0000005` at `+0x2b8035` (read of 0x0) and `0xc0000005` at `+0x43051d` (write of 0x0). In the second run the line right before the stop (<1 s earlier) is ``` dstorage: request failed: copying options=0x0 offset=19585040 source_size=38128 destination_size=38128 intermediate_size=0 tag=0 hr=0x800703e6 ``` `0x800703e6` is `ERROR_NOACCESS`, which is what a read into a page that is read-only at that moment looks like on Wine; it is the same failure as the `0x800706f8` reported above on Windows (`ERROR_INVALID_USER_BUFFER`). The first run has 3 `request failed` lines before its stop; the two clean runs have none. So it reads like the failure described above: the destination of a DirectStorage read is protected again by a guard check on another thread before the read lands, and the title uses the unwritten bytes as a pointer. That supports @⁠SantannaCarlos's diagnosis and the hold-open fix (keeping the destination's blocks open until the read is done, for `kernel_will_write`, `ReadFile`/`fread` and the page-destination path). Happy to run it here on Linux once it is posted; this setup reaches the crash in 2-3 minutes, so a 6-minute run is a decent test.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-25 07:30 UTC · original

@⁠Revens2 thanks for the runs. On the fps question, the same base on the 4070 (default settings of 310c6eb, a save at the cell, 15-minute runs, median ms per world frame after the load):

310c6eb runs median frame stale aliased pages
alone 2 423 / 495 3,548 / 2,160
+ this branch (and a follow-up cutting alias lookups) 2 542 / 523 0 / 0
+ #555 2 518 / 520 0 / 0

So most of the drop you saw is the base: 310c6eb alone runs at about 420–500 ms here, where c96b4f2 ran at about 240–440. Guarding every view of a page costs on top of that, roughly 5–15% in the median on this card, about the same for this branch and #555.

Main has since taken the view guard (8dd30ab, via myokex's port) with reading beside for DirectStorage and fread, so this branch is superseded. Not covered there: our own kernel writes into title memory (the copy-back and title buffer copies), which have the same window between kernel_will_write and the write; with direct writes on, a piece that meets a re-guarded page is dropped without a word. I'm counting whether that happens in the title on current main and will report it on its own.

**@⁠SantannaCarlos** on GitHub · 2026-11-25 07:30 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7155932565) @⁠Revens2 thanks for the runs. On the fps question, the same base on the 4070 (default settings of `310c6eb`, a save at the cell, 15-minute runs, median ms per world frame after the load): | `310c6eb` | runs | median frame | stale aliased pages | |---|---|---|---| | alone | 2 | 423 / 495 | 3,548 / 2,160 | | + this branch (and a follow-up cutting alias lookups) | 2 | 542 / 523 | 0 / 0 | | + #555 | 2 | 518 / 520 | 0 / 0 | So most of the drop you saw is the base: `310c6eb` alone runs at about 420–500 ms here, where `c96b4f2` ran at about 240–440. Guarding every view of a page costs on top of that, roughly 5–15% in the median on this card, about the same for this branch and #555. Main has since taken the view guard (`8dd30ab`, via myokex's port) with reading beside for DirectStorage and `fread`, so this branch is superseded. Not covered there: our own kernel writes into title memory (the copy-back and title buffer copies), which have the same window between `kernel_will_write` and the write; with direct writes on, a piece that meets a re-guarded page is dropped without a word. I'm counting whether that happens in the title on current main and will report it on its own.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-25 07:45 UTC · original

Follow-up on the remaining case: on current main (a26859f, RTX 4070, default settings, the cell, 15 minutes) a counter on copy-back pieces that fail on a committed read-only page found none, and the stale-page scan found no stale aliased copy; the walls were drawn. So the window for our own kernel writes stays theoretical here; nothing to change unless it shows up elsewhere.

**@⁠SantannaCarlos** on GitHub · 2026-11-25 07:45 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7156215251) Follow-up on the remaining case: on current main (`a26859f`, RTX 4070, default settings, the cell, 15 minutes) a counter on copy-back pieces that fail on a committed read-only page found none, and the stale-page scan found no stale aliased copy; the walls were drawn. So the window for our own kernel writes stays theoretical here; nothing to change unless it shows up elsewhere.
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 07:49 UTC · original

@⁠SantannaCarlos thanks for the base-vs-branch table and for the follow-up on a26859f: that answers the fps question we left open. Here are the solo numbers on current main, as promised.

Tree: main at a26859f, no extra patch, diagnostics build (needed for VICTORY_KEYS). RTX 5070 12 GB, driver 32.0.16.2124, Windows 11, VICTORY_RELAY=2, same key script as in my earlier tables (Enter presses, then W/A/D 0.2 s bursts every 60 s from t=600 s). Three sequential solo runs of 900 s, one game session at a time.

c96b4f2 (earlier) 310c6eb + fx/kernel-write-held (earlier) main a26859f r1 / r2 / r3
runs reaching 900 s 3 of 3 3 of 3 3 of 3
0x80000003 / 0xC0000005 / 0x8007000E 0 / 0 / 0 0 / 0 / 0 0 / 0 / 0
dstorage: request failed 0 0 0
device removed 0 0 0
median fps after the world loads 4.84 / 5.00 / 5.04 3.34 / 2.76 / 2.49 4.00 / 4.23 / 4.21
world reached at not recorded here t=126-142 s t=175 / 110 / 126 s

The cell scene draws about 5,000 draws per frame in all three runs (max 7,300-9,600 in transitions). A late capture of run 1 shows the cell and a guard in the doorway, rendered normally.

Fps attribution: the 2.5-3.3 we measured on 310c6eb (with the branch) is not what main gives now: a26859f is at 4.0-4.2. Compared with c96b4f2 (4.8-5.0), main is still about 15-20% slower. That is the same order as the 5-15% you measured for guarding every view of a page, so your explanation (most of the drop is the 310c6eb base, the rest the view guard) fits our numbers. What we did not run: 310c6eb alone, so we cannot split base cost from branch cost ourselves, and a different GPU than yours, so absolute ms differ. One caveat: a cargo test of another agent was running on this machine during part of these runs (not a game session); its effect on fps is not verified.

Not verified: the boot video glitch (not looked at); Wine / ERROR_NOACCESS; behaviour beyond 15 min; any GPU other than the 5070. n=3.

So on main the 0x80000003 after 0x800706f8 signature we reported on this PR did not show up in 3 of 3 solo runs, consistent with the guard now being in main. Counts and medians only; no game data.

AI-assisted (Claude Code); numbers from local run logs.

**@⁠Revens2** on GitHub · 2026-11-25 07:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7156287097) @⁠SantannaCarlos thanks for the base-vs-branch table and for the follow-up on `a26859f`: that answers the fps question we left open. Here are the solo numbers on current `main`, as promised. **Tree:** `main` at `a26859f`, no extra patch, diagnostics build (needed for `VICTORY_KEYS`). RTX 5070 12 GB, driver 32.0.16.2124, Windows 11, `VICTORY_RELAY=2`, same key script as in my earlier tables (Enter presses, then W/A/D 0.2 s bursts every 60 s from t=600 s). Three sequential solo runs of 900 s, one game session at a time. | | `c96b4f2` (earlier) | `310c6eb` + `fx/kernel-write-held` (earlier) | `main` `a26859f` r1 / r2 / r3 | |---|---|---|---| | runs reaching 900 s | 3 of 3 | 3 of 3 | **3 of 3** | | `0x80000003` / `0xC0000005` / `0x8007000E` | 0 / 0 / 0 | 0 / 0 / 0 | **0 / 0 / 0** | | `dstorage: request failed` | 0 | 0 | **0** | | device removed | 0 | 0 | **0** | | median fps after the world loads | 4.84 / 5.00 / 5.04 | 3.34 / 2.76 / 2.49 | **4.00 / 4.23 / 4.21** | | world reached at | not recorded here | t=126-142 s | t=175 / 110 / 126 s | The cell scene draws about 5,000 draws per frame in all three runs (max 7,300-9,600 in transitions). A late capture of run 1 shows the cell and a guard in the doorway, rendered normally. **Fps attribution:** the 2.5-3.3 we measured on `310c6eb` (with the branch) is not what `main` gives now: `a26859f` is at 4.0-4.2. Compared with `c96b4f2` (4.8-5.0), `main` is still about 15-20% slower. That is the same order as the 5-15% you measured for guarding every view of a page, so your explanation (most of the drop is the `310c6eb` base, the rest the view guard) fits our numbers. What we did not run: `310c6eb` alone, so we cannot split base cost from branch cost ourselves, and a different GPU than yours, so absolute ms differ. One caveat: a `cargo test` of another agent was running on this machine during part of these runs (not a game session); its effect on fps is not verified. **Not verified:** the boot video glitch (not looked at); Wine / `ERROR_NOACCESS`; behaviour beyond 15 min; any GPU other than the 5070. n=3. So on `main` the `0x80000003` after `0x800706f8` signature we reported on this PR did not show up in 3 of 3 solo runs, consistent with the guard now being in `main`. Counts and medians only; no game data. AI-assisted (Claude Code); numbers from local run logs.
Author
Owner

@⁠Cuebert on GitHub · 2026-11-26 13:48 UTC · original

Could re-arming one view preserve the other view’s pending dirty observation? At 2ef19e0, a write clears both views’ clean bits. On the next refresh of A, protect_here also marks B clean, but that refresh only journals pages in A’s range. B’s next refresh can therefore miss the write.

Could the regression prime two independent texture consumers on separate views of the same registered section page, write once, and check that both consumers observe the change in either refresh order?

**@⁠Cuebert** on GitHub · 2026-11-26 13:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7193867352) Could re-arming one view preserve the other view’s pending dirty observation? At `2ef19e0`, a write clears both views’ clean bits. On the next refresh of A, `protect_here` also marks B clean, but that refresh only journals pages in A’s range. B’s next refresh can therefore miss the write. Could the regression prime two independent texture consumers on separate views of the same registered section page, write once, and check that both consumers observe the change in either refresh order?
Author
Owner

@⁠ArturoWolff on GitHub · 2026-11-26 14:52 UTC · original

Two independent texture consumers on integrated main — RTX 4060 / Proton

Follow-up to Cuebert's two-consumer request: I checked the current implementation on 58de9bf4c367d4e27f6dd5da523ca2f68951bc77. This includes the integrated view-guard work at 8dd30ab472697c47b141c273c2a00f8ce1c00520 discussed above. I tested main, not the standalone 2ef19e0 PR head, with only an added test module and its registration.

The same Windows-target victory-gpu diagnostics test executable was used in two fresh, matching game-free Wine prefixes (hash-every-check first, default guard second). Linux, RTX 4060 8 GB, NVIDIA 620.73.04, GE-Proton 11-14 / Wine 11.0 Staging, vkd3d-proton 71cae091b06571e; Rust 1.98.1, x86_64-pc-windows-gnullvm, locked dependencies, diag profile. Each run started with an empty per-run driver cache.

The fixture uses one fully mapped, ordinary 64 KiB linear RGBA8 texture's source bytes with two independent views and two separate staging buffers and D3D12 textures. It exercises the real Staging::refresh_now with normal announced CPU updates. After the initial fill, it covers both writer choices crossed with both refresh orders, with an unchanged control after each fill/update. All checks are outside both consumers' periodic hash turns. Fenced D3D12 copies through the two separate textures then return the entire image for comparison with independently generated expected bytes.

Measurement Hash every check (VICTORY_TEXTURE_GUARD=0) Default guard (unset)
Complete texture readbacks matching every expected byte and BLAKE3 hash 20/20 20/20
Source bytes read, summed from refresh_now 1,310,720 655,360
Source bytes read on the five unchanged phases 655,360 0
Focused test result 1 passed, 0 failed 1 passed, 0 failed
Windows child exit 0 0

The build also exited zero. No device loss, external memory guard stop, host OOM kill or kernel GPU fault was observed in the completed scope. The default path refreshed both consumers on every update and preserved both on every unchanged check. For this ordinary two-consumer case, the current integrated implementation already gives the requested result; I would not revive the historical patch just to address it.

This is byte-level correctness evidence for the stated fixture, not a title performance benchmark: the 50% change in source bytes read is for this chosen sequence, not a measured frame-time gain. It does not qualify simultaneous refreshes, partial/streaming textures, asynchronous kernel writes or DirectStorage, the original boot video, or gameplay stability. No title executable, game data, screenshots or controller input were used. Applying the same correctness oracle to the separate parallel-refresh work would be a useful follow-up.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol Max).

**@⁠ArturoWolff** on GitHub · 2026-11-26 14:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/115#issuecomment-7195458898) ### Two independent texture consumers on integrated main — RTX 4060 / Proton Follow-up to [Cuebert's two-consumer request](https://git.gtahub.st/github/fxceless--victory-fork/pulls/115): I checked the current implementation on `58de9bf4c367d4e27f6dd5da523ca2f68951bc77`. This includes the integrated view-guard work at `8dd30ab472697c47b141c273c2a00f8ce1c00520` discussed above. I tested main, not the standalone `2ef19e0` PR head, with only an added test module and its registration. The same Windows-target `victory-gpu` diagnostics test executable was used in two fresh, matching game-free Wine prefixes (hash-every-check first, default guard second). Linux, RTX 4060 8 GB, NVIDIA 620.73.04, GE-Proton 11-14 / Wine 11.0 Staging, vkd3d-proton `71cae091b06571e`; Rust 1.98.1, `x86_64-pc-windows-gnullvm`, locked dependencies, `diag` profile. Each run started with an empty per-run driver cache. The fixture uses one fully mapped, ordinary 64 KiB linear RGBA8 texture's source bytes with two independent views and two separate staging buffers and D3D12 textures. It exercises the real `Staging::refresh_now` with normal announced CPU updates. After the initial fill, it covers both writer choices crossed with both refresh orders, with an unchanged control after each fill/update. All checks are outside both consumers' periodic hash turns. Fenced D3D12 copies through the two separate textures then return the entire image for comparison with independently generated expected bytes. | Measurement | Hash every check (`VICTORY_TEXTURE_GUARD=0`) | Default guard (unset) | |---|---:|---:| | Complete texture readbacks matching every expected byte and BLAKE3 hash | 20/20 | 20/20 | | Source bytes read, summed from `refresh_now` | 1,310,720 | 655,360 | | Source bytes read on the five unchanged phases | 655,360 | 0 | | Focused test result | 1 passed, 0 failed | 1 passed, 0 failed | | Windows child exit | 0 | 0 | The build also exited zero. No device loss, external memory guard stop, host OOM kill or kernel GPU fault was observed in the completed scope. The default path refreshed both consumers on every update and preserved both on every unchanged check. For this ordinary two-consumer case, the current integrated implementation already gives the requested result; I would not revive the historical patch just to address it. This is byte-level correctness evidence for the stated fixture, not a title performance benchmark: the 50% change in source bytes read is for this chosen sequence, not a measured frame-time gain. It does not qualify simultaneous refreshes, partial/streaming textures, asynchronous kernel writes or DirectStorage, the original boot video, or gameplay stability. No title executable, game data, screenshots or controller input were used. Applying the same correctness oracle to the separate parallel-refresh work would be a useful follow-up. AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol Max).
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/inplace.rs
  • crates/victory-gpu/src/lib.rs
  • crates/victory-gpu/src/texture.rs
  • crates/victory-gpu/src/watch.rs
  • crates/victory-hle/src/modules/dstorage.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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