feat(gpu,hle): share SectionWindow whole-section view and skip redundant remaps #328

Merged
Androtim merged 1 commit from upstream-pr/328 into main 2026-12-02 12:48:58 +00:00
Androtim commented 2026-12-02 12:18:08 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T12:18:08Z.


Summary

Shares one refcounted whole-section VA mapping between victory-hle::xmem and victory-gpu::inplace, skips unnecessary alias guard scans for non-aliased views, and avoids redundant unmap/remap churn on identical xmem mappings:

  • Shared SectionWindow / Arc<WholeView> (crates/victory-gpu/src/{inplace.rs,lib.rs,land.rs,watch.rs}, crates/victory-hle/src/modules/xmem.rs):
    • Replaces separate whole-section MapViewOfFile mappings in xmem::Section::window and inplace::beside / beside_page with one refcounted SectionWindow(Arc<WholeView>) mapping created via title_memory_section_window.
    • Prevents duplicate multi-GiB address-space mappings and prevents title_memory_section_gone from unmapping out from under an active SectionWindow or beside reader (dropping/unmapping happens cleanly outside the VIEWS lock once all holders finish).
  • Non-aliased views_mapped skip (inplace.rs): title_memory_view only invokes watch::views_mapped when shown.len() >= 2, eliminating redundant shard/protected-bitmap checks for single-view physical pages.
  • Granularity-preserving same-page remap no-op fast path (xmem.rs): Adds Physical::shows_run / Physical::shows_slices to skip unmap/remap/GPU-notification churn in map_pages (!lazy) and alias_as (!lazy) when the destination already maps the exact same physical pages with matching view granularity (while still coalescing fragmented single-page views when
    uns_in_one = true).

Verification

  • Static & Unit Tests: cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (322 files ok), cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu inplace (11 passed), victory-hle xmem -- --test-threads=1 (35 passed, 0 failed, 1 ignored benchmark), victory-gpu land & watch, dual workspace clippy --all-targets --locked -- -D warnings (default & --features diagnostics), objdump -p (standard Windows DLLs only).
  • Paired Same-Path Plain---release A/B vs main (e1130bf, Series X + DLSS quality, RTX 4060 Ti 8 GB, 0 crashes/DRED, no_view_warns=0):
    • 1440p (90s, 20 windows): Median FPS 14.2 -> 14.9 fps (+0.7 fps), Mean FPS 12.39 -> 15.73 fps (+3.34 fps), working_set_mb max 19,669 -> 19,169 MB (-500 MB), private_commit_mb max 21,062 -> 20,784 MB (-278 MB), thin_ms avg 461.1 -> 446.8 ms (-14.4 ms), final_waiting 3,636 -> 2,456.
    • 4K DLSS quality (90s, 18 windows): Median FPS 6.3 -> 6.3 fps, working_set_mb avg 16,888 -> 16,477 MB (-411 MB; max 20,545 -> 20,387 MB), private_commit_mb avg 19,236 -> 18,976 MB (-260 MB), shared_mb avg 4,663 -> 4,481 MB (-182 MB), thin_ms avg 533.0 -> 510.9 ms (-22.1 ms), preparing_core_ms med 31.80 -> 29.60 ms (-2.20 ms).
  • 1440p 90s --features diagnostics Visual Gate (diag-pr-secwin-1440p-90s): PASS (6/6 gates) — world_windows=21, max_draws=13961, crashes=0, used_max=6258 MB / budget_min=6690 MB, final_waiting=1793, mapped_rate=0.8 ms/s, pngs=24 lit=20/24 luma=101.22 near_black=0.07% edge_energy=7.74 magenta=0.0%. Inspected frame-2376.png, frame-2384.png, frame-2390.png — spotless rendering.
<!-- greyfinch-sync:Androtim/MiniVI:issue:5606222151 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/328). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T12:18:08Z. --- ### Summary Shares one refcounted whole-section VA mapping between `victory-hle::xmem` and `victory-gpu::inplace`, skips unnecessary alias guard scans for non-aliased views, and avoids redundant unmap/remap churn on identical `xmem` mappings: - **Shared `SectionWindow` / `Arc<WholeView>` (`crates/victory-gpu/src/{inplace.rs,lib.rs,land.rs,watch.rs}`, `crates/victory-hle/src/modules/xmem.rs`):** - Replaces separate whole-section `MapViewOfFile` mappings in `xmem::Section::window` and `inplace::beside` / `beside_page` with one refcounted `SectionWindow(Arc<WholeView>)` mapping created via `title_memory_section_window`. - Prevents duplicate multi-GiB address-space mappings and prevents `title_memory_section_gone` from unmapping out from under an active `SectionWindow` or `beside` reader (dropping/unmapping happens cleanly outside the `VIEWS` lock once all holders finish). - **Non-aliased `views_mapped` skip (`inplace.rs`):** `title_memory_view` only invokes `watch::views_mapped` when `shown.len() >= 2`, eliminating redundant shard/protected-bitmap checks for single-view physical pages. - **Granularity-preserving same-page remap no-op fast path (`xmem.rs`):** Adds `Physical::shows_run` / `Physical::shows_slices` to skip unmap/remap/GPU-notification churn in `map_pages` (!lazy) and `alias_as` (!lazy) when the destination already maps the exact same physical pages with matching view granularity (while still coalescing fragmented single-page views when uns_in_one = true). ### Verification - **Static & Unit Tests:** `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`322 files ok`), `cargo +1.98.1-x86_64-pc-windows-gnu test --locked -p victory-gpu inplace` (`11 passed`), `victory-hle xmem -- --test-threads=1` (`35 passed, 0 failed, 1 ignored` benchmark), `victory-gpu land` & `watch`, dual workspace `clippy --all-targets --locked -- -D warnings` (default & `--features diagnostics`), `objdump -p` (standard Windows DLLs only). - **Paired Same-Path Plain-`--release` A/B vs `main` (`e1130bf`, Series X + DLSS quality, RTX 4060 Ti 8 GB, 0 crashes/DRED, `no_view_warns=0`):** - **1440p (90s, 20 windows):** Median FPS `14.2 -> 14.9 fps` (`+0.7 fps`), Mean FPS `12.39 -> 15.73 fps` (`+3.34 fps`), `working_set_mb max` `19,669 -> 19,169 MB` (`-500 MB`), `private_commit_mb max` `21,062 -> 20,784 MB` (`-278 MB`), `thin_ms avg` `461.1 -> 446.8 ms` (`-14.4 ms`), `final_waiting` `3,636 -> 2,456`. - **4K DLSS quality (90s, 18 windows):** Median FPS `6.3 -> 6.3 fps`, `working_set_mb avg` `16,888 -> 16,477 MB` (`-411 MB`; max `20,545 -> 20,387 MB`), `private_commit_mb avg` `19,236 -> 18,976 MB` (`-260 MB`), `shared_mb avg` `4,663 -> 4,481 MB` (`-182 MB`), `thin_ms avg` `533.0 -> 510.9 ms` (`-22.1 ms`), `preparing_core_ms med` `31.80 -> 29.60 ms` (`-2.20 ms`). - **1440p 90s `--features diagnostics` Visual Gate (`diag-pr-secwin-1440p-90s`):** **PASS (6/6 gates)** — `world_windows=21, max_draws=13961, crashes=0, used_max=6258 MB / budget_min=6690 MB, final_waiting=1793, mapped_rate=0.8 ms/s, pngs=24 lit=20/24 luma=101.22 near_black=0.07% edge_energy=7.74 magenta=0.0%`. Inspected `frame-2376.png`, `frame-2384.png`, `frame-2390.png` — spotless rendering.
Androtim commented 2026-12-02 12:48:55 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T12:48:55Z.


Autonomous architectural audit PASSED on 1daa6a2f (CI GREEN, allowlisted author Androtim):

  • Code review: Clean refcounted SectionWindow(Arc<WholeView>) sharing one whole-section VA mapping between xmem::Section::window and inplace::beside/beside_page (safe off-lock unmap on drop), non-aliased views_mapped skip (shown.len() >= 2), and granularity-preserving shows_run/shows_slices remap no-op fast path (zero new opt-in switches).
  • Plain --release A/B (0 crashes / 0 DRED):
    • 1440p 90s: 14.2 -> 14.9 fps (+0.7 med / +3.34 mean), working_set max -500 MB, private_commit max -278 MB, thin_ms -14.4 ms, final_waiting 3,636 -> 2,456.
    • 4K 90s: 6.3 -> 6.3 fps, working_set avg -411 MB, private_commit avg -260 MB, shared avg -182 MB, preparing_core med -2.20 ms, thin_ms -22.1 ms.
  • Diagnostics (1440p 90s): All 6 gates PASS (final_waiting=1,793, luma=101.22, near_black=0.07%, edge_energy=7.74, magenta=0.0%); frame-2376.png and frame-2384.png inspected directly — crisp lighting, reflections, and zero visual regressions.

Squash-merging into main.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7345923227 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/328#issuecomment-7345923227). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T12:48:55Z. --- Autonomous architectural audit **PASSED** on `1daa6a2f` (CI GREEN, allowlisted author `Androtim`): - **Code review:** Clean refcounted `SectionWindow(Arc<WholeView>)` sharing one whole-section VA mapping between `xmem::Section::window` and `inplace::beside`/`beside_page` (safe off-lock unmap on drop), non-aliased `views_mapped` skip (`shown.len() >= 2`), and granularity-preserving `shows_run`/`shows_slices` remap no-op fast path (zero new opt-in switches). - **Plain `--release` A/B (`0` crashes / `0` DRED):** - **1440p 90s:** `14.2 -> 14.9 fps` (`+0.7` med / `+3.34` mean), `working_set max -500 MB`, `private_commit max -278 MB`, `thin_ms -14.4 ms`, `final_waiting 3,636 -> 2,456`. - **4K 90s:** `6.3 -> 6.3 fps`, `working_set avg -411 MB`, `private_commit avg -260 MB`, `shared avg -182 MB`, `preparing_core med -2.20 ms`, `thin_ms -22.1 ms`. - **Diagnostics (`1440p` 90s):** All 6 gates PASS (`final_waiting=1,793`, `luma=101.22`, `near_black=0.07%`, `edge_energy=7.74`, `magenta=0.0%`); `frame-2376.png` and `frame-2384.png` inspected directly — crisp lighting, reflections, and zero visual regressions. Squash-merging into `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
Androtim/MiniVI!328
No description provided.