Skip to content

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

Draft
sennecools wants to merge 1 commit into
fxceless:mainfrom
sennecools:contrib/view-memory-refresh
Draft

sennecools wants to merge 1 commit into
fxceless:mainfrom
sennecools:contrib/view-memory-refresh

Conversation

@sennecools

Copy link
Copy Markdown

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.

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

- Blocks of another view that show a guarded block's pages are made
  read-only as well, and 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 now returns a hold. Until it is dropped the blocks
  are not guarded again through either view, so the kernel write
  cannot fail on them. write_mapped takes the hold itself.
- An old view is kept in place of a new one only when the two differ
  in their mips. A view of another array slice, plane or format (a
  video's ring of pictures) would show an older picture.

The intro flicker had this cause: with every view-memory texture
hashed at each check (VICTORY_TEXTURE_GUARD=0), or with no views kept
(VICTORY_KEEP_VIEWS=0), the flickering tiles went from 317 to 2 of 480.
The fix itself is tested on WARP only and has not been confirmed in a
game run yet. A runtime writer that neither faults nor reports its
writes (its media code may be one) is still unseen.

AI-assisted (Claude Code)
@Fimpos

Fimpos commented Nov 25, 2026

Copy link
Copy Markdown

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):

@Pin0d1

Pin0d1 commented Nov 25, 2026

Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants