Skip to content

Soft views: DirectStorage reads into memory the title mapped write through the section's view - #3553

Open
paales wants to merge 1 commit into
trustno1-coder:mainfrom
paales:soft-views-dstorage-writes
Open

paales wants to merge 1 commit into
trustno1-coder:mainfrom
paales:soft-views-dstorage-writes

Conversation

@paales

@paales paales commented Nov 30, 2026 •

Copy link
Copy Markdown

Written by 🤖:

What it changes

With VICTORY_SOFT_VIEWS=1 (or pool), the title's XMemMapPhysicalPages views stay in the runtime's books, with no view of the host's. But a DirectStorage request with a memory destination (not a page list) opened its destination with victory_gpu::kernel_writing before the kernel wrote the file's bytes there, and that made every soft view in the range a mapping of the host's first (watch::materialize). Then the view cost a map now and an unmap later, as without the switch.

A call-site count in watch::materialize (a local diagnostic, not in this change) showed where the views that the GPU side made real came from: in a 3.5-minute run of the intro cutscene, 35,182 of 35,183 came from kernel_writing, for 11.5 GB of DirectStorage reads.

Now into_destination checks the destination first (xmem::soft_in). If views in the books show any of it, the request fills a buffer, and xmem::soft_write puts the bytes of each soft view into its pages through the section's view (Section::window, as soft_read reads them and as page-list destinations are written). The rest of the range gets a plain copy, which faults into the GPU side's guard as the title's own writes do. The notices after the write are the same as before. The views stay in the books. Without soft views in the range, nothing changes.

How it was tested

  • GPU and profile: RTX 5070 Ti 16 GB, 32 GB RAM, Windows 11; Series X 2560x1440, DLSS Performance, DLSS frame generation 2X, ray tracing off; VICTORY_SAMPLED_EVICT=1, VICTORY_TEXSPK_PASS_MS=24. Each run: the intro cutscene with replayed input, 170 s from its first scene frame, saves restored first.

  • Views the GPU side made real, per run: 35,183 before (VICTORY_SOFT_VIEWS=1), 73 after. The soft-view line every 10 s: before, about 23,000 "asked for by the GPU side"; after, 140, of them 139 by a fault of the title's code.

  • The title's mapping calls over the 45 s after the cut to the boat (VICTORY_DSTORAGE_LOG, M lines):

    time in the title's mapping calls longest call unmap / map system calls
    soft views off 20,677 ms 340 ms 87,740 / 87,021
    VICTORY_SOFT_VIEWS=1, before 13,403 ms 672 ms 89,980 / 87,688
    VICTORY_SOFT_VIEWS=1, after 4,702 ms 124 ms 30,316 / 31,177
  • Textures picked by index that wait for the title to fill their memory, the most at the cut: 3,884 and 4,568 with soft views off (2 runs); 287 and 375 with VICTORY_SOFT_VIEWS=1 and this change (2 runs). Textures that show the neutral texture (due plus waiting for their memory) in the 40 s after the cut: 82,735 and 90,370 slot-seconds before; 43,730 and 47,710 after.

  • fps median / 10th percentile: soft views off 25.0 / 15.4 and 25.2 / 17.9; VICTORY_SOFT_VIEWS=1 before 23.4 / 13.5; after 26.8 / 17.5 and 25.0 / 17.5.

  • Build of these runs: v2026.11.29.04 with this change (xmem.rs and dstorage.rs are the same as on main 41adb55 apart from this change).

  • For shader changes, the wave sizes tested: no shader change.

  • cargo test passed for the crates it touches: cargo test -p victory-hle --lib: 423 passed. A new test, soft_writes_go_into_the_pages_and_leave_the_view_in_the_books. a_read_by_range_waits_only_for_a_remapping_that_meets_it fails in the full parallel run, on main without this change too, and passes alone.

Checked for overlap

The crash in the same runs

Some runs of the intro ended with a host command list did not close (0x80070057) at the cut into the montage, with and without this change. A run with VICTORY_D3D12_DEBUG=1 named the command: CopyTextureRegion from a BC3_TYPELESS texture into a BC7_TYPELESS texture. The console copies the blocks as they are. Direct3D 12 refuses a copy between two block-compressed families. The title makes this copy in some runs only, so the crash came in some runs only.

#3043 sends such copies through a buffer. With this change and #3043 on v2026.11.29.04, a run hit the same copy at the cut (format 78 into 99), #3043 sent it through a buffer, and the run went on. This change does not touch texture copies.

… it reads into: DirectStorage reads into views kept in the runtime's books (VICTORY_SOFT_VIEWS) put their bytes into the pages through the section's view, and the views stay in the books.
@github-actions github-actions Bot added the pr-performance Pull request: makes it faster or use less memory label Nov 30, 2026
@github-actions github-actions Bot changed the title [pr-performance] Soft views: DirectStorage reads into memory the title mapped write through the section's view Soft views: DirectStorage reads into memory the title mapped write through the section's view Nov 30, 2026
@paales
paales marked this pull request as draft November 30, 2026 01:49
@paales
paales marked this pull request as ready for review November 30, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request: makes it faster or use less memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant