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

Closed
paales wants to merge 1 commit from upstream-pr/3553 into main
paales commented 2026-11-30 00:53:59 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by paales on 2026-11-30T00:53:59Z.


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 41adb551 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

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2776 (SoftViews::write for what shaders wrote, the copy-back path; this is the DirectStorage path), #2655 (the notices after a DirectStorage write; this keeps them as they are), #3850 (VICTORY_MAP_ONCE: the page-mapping locks, the other side of the same contention). #3586 and #3607 also change dstorage.rs: each merges cleanly with this change, also on main.

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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5557054996 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3553). Originally posted by [paales](https://github.com/paales) on 2026-11-30T00:53:59Z. --- _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` 41adb551 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 - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2776 (`SoftViews::write` for what shaders wrote, the copy-back path; this is the DirectStorage path), #2655 (the notices after a DirectStorage write; this keeps them as they are), #3850 (`VICTORY_MAP_ONCE`: the page-mapping locks, the other side of the same contention). #3586 and #3607 also change `dstorage.rs`: each merges cleanly with this change, also on `main`. ## 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.
trustno1-coder commented 2026-12-01 18:51:15 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:51:15Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321677137 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3553#issuecomment-7321677137). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:51:15Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!3553
No description provided.