GPU: refresh view-memory textures that host-side writers changed #438

Open
sennecools wants to merge 1 commit from upstream-pr/438 into main
sennecools commented 2026-11-25 00:49:27 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by sennecools on 2026-11-25T00:49:27Z.


A texture in view memory is guarded (read-only, a write faults once) and otherwise hashed only every eighth frame, so writes the guard does not see leave it up to eight frames stale. Two such writers were unseen: the title filling physical pages through its pool while the same pages are sampled through its tiled heap, and the runtime writing physical pages through views of its own (DirectStorage page destinations, xmem write_physical).

Changes

  • Blocks of another view showing a guarded block's pages are made read-only too; a write there marks the guarded block written (VICTORY_GUARD_ALIASES=0 turns this off).
  • The runtime's physical-page writes are reported with physical_written.
  • kernel_will_write returns a hold: the blocks are not guarded again (through either view) until the kernel write is done; write_mapped takes it itself.
  • A kept old view stands in for a new one only when they differ in mips; another array slice, plane or format shows an older picture.

Why: with VICTORY_TEXTURE_GUARD=0 (hash every check) or VICTORY_KEEP_VIEWS=0, flickering tiles in the intro went from 317 to 2 of 480, so stale content was the cause.

Testing

  • New unit tests for the other-view links, held kernel writes, runtime physical writes and the mip-only view match; victory-gpu and victory-hle tests pass on WARP with and without diagnostics; clippy clean.
  • Not yet confirmed in a game run with this fix.

Known limits: a runtime writer that neither faults nor reports (possibly the media code) stays unseen; an overlapped ReadFile is held only until it is started.

AI-assisted (Claude Code)

Draft: it is in our combined build and ran in the game without problems, but its effect on the flicker has not been measured yet.

AI-assisted.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6594545694 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/438). Originally posted by [sennecools](https://github.com/sennecools) on 2026-11-25T00:49:27Z. --- A texture in view memory is guarded (read-only, a write faults once) and otherwise hashed only every eighth frame, so writes the guard does not see leave it up to eight frames stale. Two such writers were unseen: the title filling physical pages through its pool while the same pages are sampled through its tiled heap, and the runtime writing physical pages through views of its own (DirectStorage page destinations, xmem `write_physical`). Changes - Blocks of another view showing a guarded block's pages are made read-only too; a write there marks the guarded block written (`VICTORY_GUARD_ALIASES=0` turns this off). - The runtime's physical-page writes are reported with `physical_written`. - `kernel_will_write` returns a hold: the blocks are not guarded again (through either view) until the kernel write is done; `write_mapped` takes it itself. - A kept old view stands in for a new one only when they differ in mips; another array slice, plane or format shows an older picture. Why: with `VICTORY_TEXTURE_GUARD=0` (hash every check) or `VICTORY_KEEP_VIEWS=0`, flickering tiles in the intro went from 317 to 2 of 480, so stale content was the cause. Testing - New unit tests for the other-view links, held kernel writes, runtime physical writes and the mip-only view match; victory-gpu and victory-hle tests pass on WARP with and without `diagnostics`; clippy clean. - Not yet confirmed in a game run with this fix. Known limits: a runtime writer that neither faults nor reports (possibly the media code) stays unseen; an overlapped `ReadFile` is held only until it is started. AI-assisted (Claude Code) Draft: it is in our combined build and ran in the game without problems, but its effect on the flicker has not been measured yet. AI-assisted.
Fimpos commented 2026-11-25 02:10:12 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Fimpos on 2026-11-25T01:54:58Z.


Tested on RTX 5070 12 GB (Windows 11 25H2, driver 621.24) on top of c96b4f2 with VICTORY_RELAY=2 (plus #206, #410, #451, #457, #460, #462, #481, #139):

  • Cell shell / walls (#62): Immediately before adding #438, two back-to-back runs on the same build with dstorage-notify alone (one VICTORY_RELAY=1, one VICTORY_RELAY=2) both missed the first room's walls around the window. Replacing dstorage-notify with #438 (VICTORY_GUARD_ALIASES=1) drew the complete cell interior on the first run (cinderblock walls on both sides of the window, photo pinned on the right wall, bunk bed, window frame & sunlight).
  • Watch / frame cost: Steady-state in the cell (diag build capturing a PNG every 8 frames): 214.2 ms/frame (4.7 fps, 4876 draws/frame), 2717 watches 25.97 ms, 331 guard faults — vs 201.7 ms/frame (2756 watches 21.61 ms, 229 guard faults) immediately before #438. Only ~+4.4 ms watch overhead, no filler-page storm, no crashes or device removals.
  • All ictory-gpu (127) and ictory-hle (96) unit tests pass.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7150107629 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/438#issuecomment-7150107629). Originally posted by [Fimpos](https://github.com/Fimpos) on 2026-11-25T01:54:58Z. --- Tested on RTX 5070 12 GB (Windows 11 25H2, driver 621.24) on top of c96b4f2 with VICTORY_RELAY=2 (plus #206, #410, #451, #457, #460, #462, #481, #139): - **Cell shell / walls (#62):** Immediately before adding #438, two back-to-back runs on the same build with dstorage-notify alone (one VICTORY_RELAY=1, one VICTORY_RELAY=2) both missed the first room's walls around the window. Replacing dstorage-notify with #438 (VICTORY_GUARD_ALIASES=1) drew the complete cell interior on the first run (cinderblock walls on both sides of the window, photo pinned on the right wall, bunk bed, window frame & sunlight). - **Watch / frame cost:** Steady-state in the cell (diag build capturing a PNG every 8 frames): 214.2 ms/frame (4.7 fps, 4876 draws/frame), 2717 watches 25.97 ms, 331 guard faults — vs 201.7 ms/frame (2756 watches 21.61 ms, 229 guard faults) immediately before #438. Only ~+4.4 ms watch overhead, no filler-page storm, no crashes or device removals. - All ictory-gpu (127) and ictory-hle (96) unit tests pass.
Pin0d1 commented 2026-11-25 09:08:51 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Pin0d1 on 2026-11-25T09:03:24Z.


@sennecools, @Revens2 pointed me here from #555. Both PRs have the same head, 5af49b5. I reran the three tests on the test-only commit, whose parent is that exact head.

A write through a sibling mapping produced 0x11223344 in both independent GPU readbacks. Both journal consumers saw the same write, and the synchronous four-byte file read returned TEST while another holder covered part of its destination. All three passed in two fresh processes per adapter setting on Windows. The command is cargo test --locked -p victory-gpu --lib watch:: -- --test-threads=1.

Prepared with the help of Codex 6.2 Astra Max.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7157814627 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/438#issuecomment-7157814627). Originally posted by [Pin0d1](https://github.com/Pin0d1) on 2026-11-25T09:03:24Z. --- @sennecools, @Revens2 pointed me here from #555. Both PRs have the same head, 5af49b5. I reran the three tests on the [test-only commit](https://github.com/Pin0d1/victory-fork/commit/b63010881edd8d98e2eef0754bf38e474b0ce35b), whose parent is that exact head. A write through a sibling mapping produced 0x11223344 in both independent GPU readbacks. Both journal consumers saw the same write, and the synchronous four-byte file read returned TEST while another holder covered part of its destination. All three passed in two fresh processes per adapter setting on Windows. The command is `cargo test --locked -p victory-gpu --lib watch:: -- --test-threads=1`. Prepared with the help of Codex 6.2 Astra Max.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/438:upstream-pr/438'
git switch 'upstream-pr/438'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/438'
git switch 'upstream-pr/438'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/438'
git switch 'upstream-pr/438'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/438'
git switch 'main'
git merge --squash 'upstream-pr/438'
git switch 'main'
git merge --ff-only 'upstream-pr/438'
git switch 'main'
git merge 'upstream-pr/438'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!438
No description provided.