Memory: cover overflow MEM_GRAPHICS reservations in trailing view windows #3653

Open
Kalmarv wants to merge 2 commits from upstream-pr/3653 into main
Kalmarv commented 2026-12-02 03:51:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T03:51:40Z.


Stacked on #3517 (carries @CharlyRien's 4-sparse-window 16-window layout commit from #3517, rebased onto origin/main 5eaadb54c; will rebase onto main once #3517 merges).

In the 16-window UMA layout (4 sparse + 1..2 coherent + 6 primary GPU-view = 11..12 windows), the trailing 4..5 windows (windows 12..16 = 16 GiB with 2 coherent windows, or windows 11..16 = 20 GiB with 1 coherent window) remained unused WindowKind::None while overflow MEM_GRAPHICS and GPU-visible fallback reservations fell out to plain Windows memory outside UMA. Translated shaders drop reads and writes past xcl_w >= 16, leaving GPU-side buffers in those overflow reservations unreadable.

Notes on scope and trade-offs:

  • Visual scope (#3517 vs #3653): @KDenKC's RTX 5090 split runs on #3662 established that #3517 alone (keeping 4 runtime sparse windows in the 16-window layout) is sufficient to fix the translucent ("glass") characters in that scene; this PR specifically covers overflow MEM_GRAPHICS / GPU-visible fallback reservations that spill past the sparse and coherent windows.
  • Shared XCL_MIRROR_MB budget: Self-backed tiles mapped in trailing view windows (including uncommitted GPU-only tiles, h == 0xFFFF, charged full PAGES_PER_TILE against fill_later's per-submit page budget) draw video memory from the same XCL_MIRROR_MB (default 4096 MiB) pool shared with the 24 GiB GPU view. Large whole-range asks against a multi-GiB overflow reservation can still compete with GPU-view tiles across submits until XCL_MIRROR_MB is raised or budgeted separately.
  • Inherited #3517 switch-fallback window-4 cutoff: Moving 16-window coherent memory from window 3 to window 4 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4 in #3517) leaves #156 with_switch_fallback (MAX_WINDOWS = 4, root UAVs 0..3) unable to address coherent memory in window 4 if a pipeline falls back to switch form on the 16-window layout; this belongs to #3517's 4-sparse-window layout and is unchanged here.

What is in it

  • crates/xcl/src/gpu/uma.rs: Reserve the trailing 16-window view windows past the 6 primary GPU-view windows as MEM_RESERVE | MEM_WRITE_WATCH (PAGE_READWRITE) and add Uma::view_reserve_graphics and Uma::graphics_view_windows. Keep the 6 primary GPU-view windows (VIEW_WINDOWS) isolated for 24 GiB GPU views and reject any single reservation of at least the full trailing pool ((hi - lo) * WINDOW, e.g. 16 GiB with 2 coherent windows or 20 GiB with 1).
  • crates/xcl/src/hle/kernelx.rs: Route overflow MEM_GRAPHICS and non-GPU-view, non-CPU-view gpu_visible_fallback reservations into the trailing write-watched view windows via reserve_in_view_graphics without registering MEM_GRAPHICS reservations as unpaired CPU views in mirrors; add mirrors::is_cpu_view_reservation so pure MEM_64K_PAGES reserve-only CPU views (both 16 GiB Series S / Lockhart and 24 GiB Series X, without MEM_GRAPHICS or PAGE_GRAPHICS_* GPU-accessible protection) stay in reserve_watched plain memory instead of filling the trailing view windows; bound view-window VirtualAlloc(MEM_COMMIT) ranges against u.view_reservation(a) (failing out-of-bounds or released ranges with ERROR_INVALID_ADDRESS); notify sparse::source_committed on self-backed graphics commits (commit_in_view_graphics); and on VirtualFree(MEM_RELEASE) of a self-backed graphics reservation (free_in_view), run sparse::source_release (removing GRAPHICS_RESERVATIONS and unpairing mirrors inside its freeing span before forget_mirrors) and clean up title mappings before u.view_release(a).
  • crates/xcl/src/hle/d3d12x/sparse.rs, title_textures.rs, bind.rs, real.rs: Keep self-backed graphics reservations in trailing view windows in title_textures write-watch tracking (recording Table::coarse membership per resource at link_src time so unlink_src stays balanced if the reservation is released first); resolve tile_shows to the tile's own CPU address when in_graphics_reservation is true; allow State::fill_later to map uncommitted/lazy GPU-only tiles (h == 0xFFFF when self-backed) while charging full PAGES_PER_TILE against the per-submit page budget; forget asks on self-backed tile decommit (source_decommitted_in); and re-queue linked unmapped self-backed tiles on re-ask (take_asks) or VirtualAlloc(MEM_COMMIT) (source_committed_in).
  • Unit tests (CPU and WARP-only): 4-sparse 16-window layout and trailing graphics view windows (VirtualAlloc commit + GetWriteWatch, rejecting full-pool and 24 GiB reservations), kernelx reserve_in_view_graphics (rejecting 16 GiB Series S, 24 GiB Series X, and smaller pure CPU views while keeping MEM_GRAPHICS and PAGE_GRAPHICS_* large-page fallbacks in trailing view windows, and verifying MEM_GRAPHICS | MEM_64K_PAGES is not registered in mirrors), view_graphics_free_decommit_release_and_reuse (bounds/post-release ERROR_INVALID_ADDRESS, MEM_DECOMMIT / re-commit / MEM_RELEASE / AWAY.title cleanup / address reuse), title_textures coarse_refcount_stays_balanced_after_graphics_reservation_release, and WARP self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp covering committed/uncommitted mapping, post-decommit remapping, and PAGES_PER_TILE fill_later budget charging.

Tested

  • Hardware / toolchain: AMD Ryzen 9 9950X 16-Core, Windows 11 10.0.26200.0, NVIDIA GeForce RTX 5070 Ti (driver 610.74 / 32.0.16.1074), rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5.
  • cargo build --release -p xcl: succeeded with 39 warnings (0 new vs origin/main 5eaadb54c).
  • Targeted unit tests (reserve_in_view_graphics_places_and_tracks_fallback_reservations, view_graphics_free_decommit_release_and_reuse, graphics_view_windows_cover_reservations_and_support_commit_and_write_watch): 3 passed, 0 failed, 0 ignored, 0 skipped.
  • .\scripts\test.ps1 (workspace build, bench --test, and cargo test --workspace -- --test-threads=4 with DXC 1.9): 2982 passed, 0 failed, 52 ignored, 24 SKIPPED GPU tests (22 no wave64 on RTX 5070 Ti, 2 no heap windows).

Regression run

Base (origin/main):

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1688 (PresentX 1688)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16676 MB

PR (ebef2ce9df61b39a70f479b486870e60c45bdd2b):

xcl-smoke v1
commit: ebef2ce9df61b39a70f479b486870e60c45bdd2b
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1701 (PresentX 1701)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 16860 MB

Not tested

  • Default 4-window smoke does not run the 16-window branches: scripts/smoke.ps1 runs with default XCL_UMA_WINDOWS=4 (XCL_HEAP_WINDOWS unset), so the regression run above verifies no regression on the default layout and does not execute the 16-window trailing view-window paths. No live 16-window title run (Series X or Series S) was re-run on ebef2ce9d; coverage of the updated commit comes from the CPU and WARP unit tests.
  • Wave64-native GPU adapters / AMD hardware (22 wave64 GPU tests skipped on RTX 5070 Ti).
  • Default scripts/test.ps1 runs without XCL_HEAP_WINDOWS=1 (2 heap-window GPU tests skipped in the full suite).
  • Multi-minute 16-window gameplay under heavy XCL_MIRROR_MB pressure or concurrent decommit/release churn on trailing graphics view reservations.

AI use

  • Stacked on @CharlyRien's commit from #3517 (authorship preserved).
  • Antigravity (Gemini 4 Neon): rebased onto origin/main (5eaadb54c), addressed the @Decodere, @Foniass, @bmjask, and @jsalzy review findings, added unit tests, ran the release build, test suite, and 60 s smoke runs, and updated this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5599470309 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T03:51:40Z. --- > **Stacked on #3517** (carries @CharlyRien's 4-sparse-window 16-window layout commit from #3517, rebased onto `origin/main` `5eaadb54c`; will rebase onto `main` once #3517 merges). In the 16-window UMA layout (4 sparse + 1..2 coherent + 6 primary GPU-view = 11..12 windows), the trailing 4..5 windows (windows `12..16` = 16 GiB with 2 coherent windows, or windows `11..16` = 20 GiB with 1 coherent window) remained unused `WindowKind::None` while overflow `MEM_GRAPHICS` and GPU-visible fallback reservations fell out to plain Windows memory outside UMA. Translated shaders drop reads and writes past `xcl_w >= 16`, leaving GPU-side buffers in those overflow reservations unreadable. Notes on scope and trade-offs: - **Visual scope (#3517 vs #3653):** @KDenKC's RTX 5090 split runs on #3662 established that #3517 alone (keeping 4 runtime sparse windows in the 16-window layout) is sufficient to fix the translucent ("glass") characters in that scene; this PR specifically covers overflow `MEM_GRAPHICS` / GPU-visible fallback reservations that spill past the sparse and coherent windows. - **Shared `XCL_MIRROR_MB` budget:** Self-backed tiles mapped in trailing view windows (including uncommitted GPU-only tiles, `h == 0xFFFF`, charged full `PAGES_PER_TILE` against `fill_later`'s per-submit page budget) draw video memory from the same `XCL_MIRROR_MB` (default 4096 MiB) pool shared with the 24 GiB GPU view. Large whole-range asks against a multi-GiB overflow reservation can still compete with GPU-view tiles across submits until `XCL_MIRROR_MB` is raised or budgeted separately. - **Inherited `#3517` switch-fallback window-4 cutoff:** Moving 16-window coherent memory from window 3 to window 4 (`SIXTEEN_WINDOW_SPARSE_WINDOWS = 4` in #3517) leaves `#156` `with_switch_fallback` (`MAX_WINDOWS = 4`, root UAVs `0..3`) unable to address coherent memory in window 4 if a pipeline falls back to switch form on the 16-window layout; this belongs to #3517's 4-sparse-window layout and is unchanged here. **What is in it** - `crates/xcl/src/gpu/uma.rs`: Reserve the trailing 16-window view windows past the 6 primary GPU-view windows as `MEM_RESERVE | MEM_WRITE_WATCH` (`PAGE_READWRITE`) and add `Uma::view_reserve_graphics` and `Uma::graphics_view_windows`. Keep the 6 primary GPU-view windows (`VIEW_WINDOWS`) isolated for 24 GiB GPU views and reject any single reservation of at least the full trailing pool (`(hi - lo) * WINDOW`, e.g. 16 GiB with 2 coherent windows or 20 GiB with 1). - `crates/xcl/src/hle/kernelx.rs`: Route overflow `MEM_GRAPHICS` and non-GPU-view, non-CPU-view `gpu_visible_fallback` reservations into the trailing write-watched view windows via `reserve_in_view_graphics` without registering `MEM_GRAPHICS` reservations as unpaired CPU views in `mirrors`; add `mirrors::is_cpu_view_reservation` so pure `MEM_64K_PAGES` reserve-only CPU views (both 16 GiB Series S / Lockhart and 24 GiB Series X, without `MEM_GRAPHICS` or `PAGE_GRAPHICS_*` GPU-accessible protection) stay in `reserve_watched` plain memory instead of filling the trailing view windows; bound view-window `VirtualAlloc(MEM_COMMIT)` ranges against `u.view_reservation(a)` (failing out-of-bounds or released ranges with `ERROR_INVALID_ADDRESS`); notify `sparse::source_committed` on self-backed graphics commits (`commit_in_view_graphics`); and on `VirtualFree(MEM_RELEASE)` of a self-backed graphics reservation (`free_in_view`), run `sparse::source_release` (removing `GRAPHICS_RESERVATIONS` and unpairing `mirrors` inside its freeing span before `forget_mirrors`) and clean up title mappings before `u.view_release(a)`. - `crates/xcl/src/hle/d3d12x/sparse.rs`, `title_textures.rs`, `bind.rs`, `real.rs`: Keep self-backed graphics reservations in trailing view windows in `title_textures` write-watch tracking (recording `Table::coarse` membership per resource at `link_src` time so `unlink_src` stays balanced if the reservation is released first); resolve `tile_shows` to the tile's own CPU address when `in_graphics_reservation` is true; allow `State::fill_later` to map uncommitted/lazy GPU-only tiles (`h == 0xFFFF` when self-backed) while charging full `PAGES_PER_TILE` against the per-submit page budget; forget asks on self-backed tile decommit (`source_decommitted_in`); and re-queue linked unmapped self-backed tiles on re-ask (`take_asks`) or `VirtualAlloc(MEM_COMMIT)` (`source_committed_in`). - Unit tests (CPU and WARP-only): 4-sparse 16-window layout and trailing graphics view windows (`VirtualAlloc` commit + `GetWriteWatch`, rejecting full-pool and 24 GiB reservations), `kernelx` `reserve_in_view_graphics` (rejecting 16 GiB Series S, 24 GiB Series X, and smaller pure CPU views while keeping `MEM_GRAPHICS` and `PAGE_GRAPHICS_*` large-page fallbacks in trailing view windows, and verifying `MEM_GRAPHICS | MEM_64K_PAGES` is not registered in `mirrors`), `view_graphics_free_decommit_release_and_reuse` (bounds/post-release `ERROR_INVALID_ADDRESS`, `MEM_DECOMMIT` / re-commit / `MEM_RELEASE` / `AWAY.title` cleanup / address reuse), `title_textures` `coarse_refcount_stays_balanced_after_graphics_reservation_release`, and WARP `self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp` covering committed/uncommitted mapping, post-decommit remapping, and `PAGES_PER_TILE` `fill_later` budget charging. **Tested** - Hardware / toolchain: AMD Ryzen 9 9950X 16-Core, Windows 11 10.0.26200.0, NVIDIA GeForce RTX 5070 Ti (driver 610.74 / 32.0.16.1074), `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC 1.9.2609.5. - `cargo build --release -p xcl`: succeeded with 39 warnings (0 new vs `origin/main` `5eaadb54c`). - Targeted unit tests (`reserve_in_view_graphics_places_and_tracks_fallback_reservations`, `view_graphics_free_decommit_release_and_reuse`, `graphics_view_windows_cover_reservations_and_support_commit_and_write_watch`): 3 passed, 0 failed, 0 ignored, 0 skipped. - `.\scripts\test.ps1` (workspace build, bench `--test`, and `cargo test --workspace -- --test-threads=4` with DXC 1.9): 2982 passed, 0 failed, 52 ignored, 24 SKIPPED GPU tests (22 `no wave64` on RTX 5070 Ti, 2 `no heap windows`). **Regression run** Base (`origin/main`): ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1688 (PresentX 1688) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16676 MB ``` PR (`ebef2ce9df61b39a70f479b486870e60c45bdd2b`): ``` xcl-smoke v1 commit: ebef2ce9df61b39a70f479b486870e60c45bdd2b gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1701 (PresentX 1701) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 16860 MB ``` **Not tested** - **Default 4-window smoke does not run the 16-window branches:** `scripts/smoke.ps1` runs with default `XCL_UMA_WINDOWS=4` (`XCL_HEAP_WINDOWS` unset), so the regression run above verifies no regression on the default layout and does not execute the 16-window trailing view-window paths. No live 16-window title run (Series X or Series S) was re-run on `ebef2ce9d`; coverage of the updated commit comes from the CPU and WARP unit tests. - Wave64-native GPU adapters / AMD hardware (22 wave64 GPU tests skipped on RTX 5070 Ti). - Default `scripts/test.ps1` runs without `XCL_HEAP_WINDOWS=1` (2 heap-window GPU tests skipped in the full suite). - Multi-minute 16-window gameplay under heavy `XCL_MIRROR_MB` pressure or concurrent decommit/release churn on trailing graphics view reservations. **AI use** - Stacked on @CharlyRien's commit from #3517 (authorship preserved). - Antigravity (Gemini 4 Neon): rebased onto `origin/main` (`5eaadb54c`), addressed the @Decodere, @Foniass, @bmjask, and @jsalzy review findings, added unit tests, ran the release build, test suite, and 60 s smoke runs, and updated this PR description.
Decodere commented 2026-12-02 08:43:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T08:43:07Z.


Diff review (head a74a58b98, read-only code review — not a #3041 merge-check):

Nice design on the trailing MEM_WRITE_WATCH view windows for overflow MEM_GRAPHICS reservations (and good attention to excluding in_graphics_reservation(src) in title_textures.rs:175-176 so write-watch tracking stays active). Two concrete issues turned up in the full diff:

  1. [HIGH] Inherits #3517's with_switch_fallback window-4 cutoff (crates/xcl/src/gpu/uma.rs:48, :59, :1562, :1611):
    Moving 16-window coherent UMA memory from window 3 to window 4 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) leaves #156 with_switch_fallback (real.rs:5178 -> pso::in_switch_form -> windows_for_mode) capped at MAX_WINDOWS = 4 (root UAVs 0..3 only in bind.rs:3108, :5317). Any shader taking switch fallback on the 16-window layout can no longer address coherent memory in window 4. Either keeping coherent memory reachable by switch-form shaders or ensuring switch fallback binds/switches across window 4 resolves this.

  2. [MEDIUM] Unrelated dead code leaked into crates/xcl/src/hle/d3d12x/title_list.rs:292-298, :1135-1161:
    The diff adds pub fn active_backing(list: *mut c_void) -> Option<*mut c_void> and its unit test (+36 lines) that are unrelated to UMA/sparse memory and never called anywhere in this PR or main. Dropping that hunk keeps the PR cleanly scoped.

Testing note: the default 4-window scripts/smoke.ps1 configuration does not execute the 16-window runtime paths; verifying this PR end-to-end requires running with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16.

AI use: Antigravity (Gemini 4 Neon) audited the full diff against main and drafted this review.

<!-- greyfinch-sync:ivall/xcl:comment:7339832579 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7339832579). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T08:43:07Z. --- Diff review (head `a74a58b98`, read-only code review — not a `#3041` merge-check): Nice design on the trailing `MEM_WRITE_WATCH` view windows for overflow `MEM_GRAPHICS` reservations (and good attention to excluding `in_graphics_reservation(src)` in `title_textures.rs:175-176` so write-watch tracking stays active). Two concrete issues turned up in the full diff: 1. **[HIGH] Inherits `#3517`'s `with_switch_fallback` window-4 cutoff** (`crates/xcl/src/gpu/uma.rs:48`, `:59`, `:1562`, `:1611`): Moving 16-window coherent UMA memory from window `3` to window `4` (`SIXTEEN_WINDOW_SPARSE_WINDOWS = 4`) leaves `#156` `with_switch_fallback` (`real.rs:5178` -> `pso::in_switch_form` -> `windows_for_mode`) capped at `MAX_WINDOWS = 4` (root UAVs `0..3` only in `bind.rs:3108`, `:5317`). Any shader taking switch fallback on the 16-window layout can no longer address coherent memory in window 4. Either keeping coherent memory reachable by switch-form shaders or ensuring switch fallback binds/switches across window 4 resolves this. 2. **[MEDIUM] Unrelated dead code leaked into `crates/xcl/src/hle/d3d12x/title_list.rs:292-298`, `:1135-1161`**: The diff adds `pub fn active_backing(list: *mut c_void) -> Option<*mut c_void>` and its unit test (+36 lines) that are unrelated to UMA/sparse memory and never called anywhere in this PR or `main`. Dropping that hunk keeps the PR cleanly scoped. Testing note: the default 4-window `scripts/smoke.ps1` configuration does not execute the 16-window runtime paths; verifying this PR end-to-end requires running with `XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16`. AI use: Antigravity (Gemini 4 Neon) audited the full diff against `main` and drafted this review.
Foniass commented 2026-12-02 09:07:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:07:48Z.


Review (head a74a58b9, diff read, not a merge-check):

  • GPU-only tiles now come out of the GPU view's video-memory budget. sparse.rs ~6734 (h == 0xFFFF && w != c) gives video memory to a self-backed tile with no committed page. That memory comes from mirror_cap (XCL_MIRROR_MB, 4096 MB by default, sparse.rs ~2708), which the 24 GiB GPU view's tiles also use. If a 6 GiB overflow reservation is asked for whole (BVH scratch, or #3662's whole-range asks), it can use up the cap. After that, GPU-view tiles are refused and read zeros (sparse.rs ~6638). The 30 s run in the description does not report mirror counts or refusals.
  • A GPU-only tile does not get its memory back after a decommit. A decommit over a self-backed tile parks its video memory (source_decommitted_in, called from kernelx.rs ~1303). When the title commits the range again, the commit goes to plain VirtualAlloc, and nothing tells sparse. mirror_writes remaps a tile only after a CPU write. The tile also stays in MIRROR_ASKED, so map_mirror does not queue it again. Scratch that only the GPU writes stays unmapped (zeros, writes dropped). The w == c exception exists only in fill_later.
  • The new free and allocation paths have no tests. The view-window branch of VirtualFree (kernelx.rs ~1296-1325: source_decommit, the GRAPHICS_RESERVATIONS removal, forget_mirrors/remapped, view_release) is never called. The kernelx test cleans up by hand "without relying on global uma::get()" (~5613), and the sparse test calls source_decommitted_in directly. The routing inside VirtualAlloc (~1012, ~1076) is tested only through reserve_in_view_graphics. A test that decommits, releases and reuses the address through the hooks would cover the release path this PR adds.
  • Address given back before the title's mappings are forgotten. In the view branch, u.view_release(a) (kernelx.rs ~1321) runs before forget_title_mappings(a, n) (~1322). Another thread can reserve that range and map pages there in between, and those mappings are then dropped. The sparse branch does it the other way round (~1281 before ~1283). Main had the same order for GPU views, but this PR now expects map_pages to be used in these reservations (~2568).
  • Unrelated code. title_list::active_backing (title_list.rs ~293) and its test (+36 lines) are not called in this PR, on main, or in #3662. They belong in a separate PR.
  • Stack and regression run. The PR carries #3517's commit unchanged, and #3517 is still open. #3662 carries both commits. scripts/smoke.ps1 does not set XCL_UMA_WINDOWS and the blocks do not record the layout. With the default 4 windows the new branches never run, and the only run of the 16-window layout (30 s) has no comparison with main. Not tested should say this.

Fine: on the default 4-window layout this is a no-op by reading. There are no View windows, so view_reserve_graphics returns None, and every other new check sits behind is_view or w == c. The only cost is one extra GRAPHICS_RESERVATIONS lookup per NoView tile in tile_shows. The window arithmetic is correct: primary views limited to lo..lo+VIEW_WINDOWS, trailing windows as lo+VIEW_WINDOWS..hi, take_sparse_in bounds and alignment, the 24 GiB rejection, and nothing to place when 8 sparse + 2 coherent windows leave no trailing window. The trailing reservation is MEM_WRITE_WATCH, which src_runs scanning needs. tile_shows takes GRAPHICS_RESERVATIONS under STATE, and no lock-order inversion was found. No overlap with #3651 (committed windows only) or #3665 (placements/vram only).

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7340420279 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7340420279). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:07:48Z. --- Review (head a74a58b9, diff read, not a merge-check): - **GPU-only tiles now come out of the GPU view's video-memory budget.** `sparse.rs ~6734` (`h == 0xFFFF && w != c`) gives video memory to a self-backed tile with no committed page. That memory comes from `mirror_cap` (`XCL_MIRROR_MB`, 4096 MB by default, `sparse.rs ~2708`), which the 24 GiB GPU view's tiles also use. If a 6 GiB overflow reservation is asked for whole (BVH scratch, or #3662's whole-range asks), it can use up the cap. After that, GPU-view tiles are refused and read zeros (`sparse.rs ~6638`). The 30 s run in the description does not report mirror counts or refusals. - **A GPU-only tile does not get its memory back after a decommit.** A decommit over a self-backed tile parks its video memory (`source_decommitted_in`, called from `kernelx.rs ~1303`). When the title commits the range again, the commit goes to plain `VirtualAlloc`, and nothing tells sparse. `mirror_writes` remaps a tile only after a CPU write. The tile also stays in `MIRROR_ASKED`, so `map_mirror` does not queue it again. Scratch that only the GPU writes stays unmapped (zeros, writes dropped). The `w == c` exception exists only in `fill_later`. - **The new free and allocation paths have no tests.** The view-window branch of `VirtualFree` (`kernelx.rs ~1296-1325`: `source_decommit`, the `GRAPHICS_RESERVATIONS` removal, `forget_mirrors`/`remapped`, `view_release`) is never called. The kernelx test cleans up by hand "without relying on global `uma::get()`" (`~5613`), and the sparse test calls `source_decommitted_in` directly. The routing inside `VirtualAlloc` (`~1012`, `~1076`) is tested only through `reserve_in_view_graphics`. A test that decommits, releases and reuses the address through the hooks would cover the release path this PR adds. - **Address given back before the title's mappings are forgotten.** In the view branch, `u.view_release(a)` (`kernelx.rs ~1321`) runs before `forget_title_mappings(a, n)` (`~1322`). Another thread can reserve that range and map pages there in between, and those mappings are then dropped. The sparse branch does it the other way round (`~1281` before `~1283`). Main had the same order for GPU views, but this PR now expects `map_pages` to be used in these reservations (`~2568`). - **Unrelated code.** `title_list::active_backing` (`title_list.rs ~293`) and its test (+36 lines) are not called in this PR, on main, or in #3662. They belong in a separate PR. - **Stack and regression run.** The PR carries #3517's commit unchanged, and #3517 is still open. #3662 carries both commits. `scripts/smoke.ps1` does not set `XCL_UMA_WINDOWS` and the blocks do not record the layout. With the default 4 windows the new branches never run, and the only run of the 16-window layout (30 s) has no comparison with main. **Not tested** should say this. Fine: on the default 4-window layout this is a no-op by reading. There are no View windows, so `view_reserve_graphics` returns None, and every other new check sits behind `is_view` or `w == c`. The only cost is one extra `GRAPHICS_RESERVATIONS` lookup per NoView tile in `tile_shows`. The window arithmetic is correct: primary views limited to `lo..lo+VIEW_WINDOWS`, trailing windows as `lo+VIEW_WINDOWS..hi`, `take_sparse_in` bounds and alignment, the 24 GiB rejection, and nothing to place when 8 sparse + 2 coherent windows leave no trailing window. The trailing reservation is `MEM_WRITE_WATCH`, which `src_runs` scanning needs. `tile_shows` takes `GRAPHICS_RESERVATIONS` under `STATE`, and no lock-order inversion was found. No overlap with #3651 (committed windows only) or #3665 (placements/vram only). AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-02 10:12:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T10:12:43Z.


merge-check
base: 1c8b551475
head: a74a58b983
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2916 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7340420279 and its findings stand. Most serious: GPU-only tiles in the trailing windows use the same 4 GiB budget as the GPU view, and the new free path is untested.
performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (a74a58b9): 1652 -> 1688 frames shown (102 %; last presents per 2 s: 61 60 60), peak commit 18228 -> 17424 MB, 0 device removals, 0 crashes.
verdict: safe to merge (it carries open #3517's commits, which land with it): no blocking finding in the review (the points there are minor), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7342131118 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7342131118). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T10:12:43Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: a74a58b9836b304315c7168b562f58d960406da0 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2916 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7340420279 and its findings stand. Most serious: GPU-only tiles in the trailing windows use the same 4 GiB budget as the GPU view, and the new free path is untested. performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (a74a58b9): 1652 -> 1688 frames shown (102 %; last presents per 2 s: 61 60 60), peak commit 18228 -> 17424 MB, 0 device removals, 0 crashes. verdict: safe to merge (it carries open #3517's commits, which land with it): no blocking finding in the review (the points there are minor), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Kalmarv commented 2026-12-02 15:00:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:00:02Z.


Thanks @Decodere and @Foniass for the thorough reviews — rebased onto origin/main (5eaadb54c, keeping @CharlyRien's still-open #3517 commit intact) and updated head to 1de2334d6:

  • Dropped unrelated title_list.rs hunk (@Decodere, @Foniass): removed title_list::active_backing and its unit test (-36 lines).
  • Fixed VirtualFree address-reuse ordering in kernelx.rs (@Foniass): factored the view-window branch into free_in_view and moved forget_title_mappings(a, n) (along with GRAPHICS_RESERVATIONS removal, mirrors::released, mirrors::place_gone, and sparse::forget_mirrors / remapped) before u.view_release(a), matching the sparse branch order so another thread cannot reuse the VA before old mappings are cleared.
  • Fixed post-decommit remapping of self-backed GPU-only tiles in sparse.rs + kernelx.rs (@Foniass):
    • State::source_decommitted_in now calls forget_ask(w) when a self-backed tile (w == t) is unmapped (clearing MIRROR_ASKED and bumping MIRROR_FORGOTTEN for view_want).
    • State::take_asks re-queues linked unmapped self-backed tiles (g == c && !self.mapped.contains_key(&g)) into self.later so a subsequent GPU ask (map_mirror) remaps them even with h == 0xFFFF.
    • VirtualAlloc(MEM_COMMIT) inside a view graphics reservation (commit_in_view_graphics) calls sparse::source_committed -> State::source_committed_in so re-committing a decommitted self-backed tile also regains video memory without needing a CPU write or fresh ask.
  • Added unit tests covering the new free/release/reuse and post-decommit remapping paths (@Foniass):
    • kernelx::tests::view_graphics_free_decommit_release_and_reuse: exercises reserve_in_view_graphics, commit_in_view_graphics, partial MEM_DECOMMIT, re-commit zeroing, MEM_RELEASE clearing GRAPHICS_RESERVATIONS and AWAY.title, double-release rejection, and immediate address reuse.
    • sparse::tests::self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp: now asks through map_mirror, verifies source_decommitted_in clears MIRROR_ASKED and increments MIRROR_FORGOTTEN, and checks all three post-decommit recovery paths (map_mirror GPU-only re-ask, source_committed_in re-commit, and mirror_writes CPU write) on WARP.
  • Updated PR description (@Decodere, @Foniass): noted @KDenKC's RTX 5090 finding (that #3517 alone fixes the glass characters), documented the shared XCL_MIRROR_MB (4096 MiB) pool budget and the #3517 with_switch_fallback window-4 cutoff (unchanged here since #3517 owns the 4-sparse-window layout), and explicitly disclosed in Not tested that the default 4-window smoke does not exercise the 16-window branches.

Verified on 1de2334d6: cargo build --release -p xcl (39 warnings, matching 5eaadb54c), .\scripts\test.ps1 with DXC 1.9 (2981 passed, 0 failed, 52 ignored, 24 SKIPPED), fresh 60 s smoke pair (5eaadb54c 1688 frames / 16676 MB vs 1de2334d6 1683 frames / 16728 MB, 0 device removals, 0 crashes), and scripts/pr_check.py --local (description ok).

AI use: Antigravity (Gemini 4 Neon) implemented these fixes, ran the checks, and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7349522295 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7349522295). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:00:02Z. --- Thanks @Decodere and @Foniass for the thorough reviews — rebased onto `origin/main` (`5eaadb54c`, keeping @CharlyRien's still-open #3517 commit intact) and updated head to `1de2334d6`: - **Dropped unrelated `title_list.rs` hunk** (@Decodere, @Foniass): removed `title_list::active_backing` and its unit test (-36 lines). - **Fixed `VirtualFree` address-reuse ordering in `kernelx.rs`** (@Foniass): factored the view-window branch into `free_in_view` and moved `forget_title_mappings(a, n)` (along with `GRAPHICS_RESERVATIONS` removal, `mirrors::released`, `mirrors::place_gone`, and `sparse::forget_mirrors` / `remapped`) **before** `u.view_release(a)`, matching the sparse branch order so another thread cannot reuse the VA before old mappings are cleared. - **Fixed post-decommit remapping of self-backed GPU-only tiles in `sparse.rs` + `kernelx.rs`** (@Foniass): - `State::source_decommitted_in` now calls `forget_ask(w)` when a self-backed tile (`w == t`) is unmapped (clearing `MIRROR_ASKED` and bumping `MIRROR_FORGOTTEN` for `view_want`). - `State::take_asks` re-queues linked unmapped self-backed tiles (`g == c && !self.mapped.contains_key(&g)`) into `self.later` so a subsequent GPU ask (`map_mirror`) remaps them even with `h == 0xFFFF`. - `VirtualAlloc(MEM_COMMIT)` inside a view graphics reservation (`commit_in_view_graphics`) calls `sparse::source_committed` -> `State::source_committed_in` so re-committing a decommitted self-backed tile also regains video memory without needing a CPU write or fresh ask. - **Added unit tests covering the new free/release/reuse and post-decommit remapping paths** (@Foniass): - `kernelx::tests::view_graphics_free_decommit_release_and_reuse`: exercises `reserve_in_view_graphics`, `commit_in_view_graphics`, partial `MEM_DECOMMIT`, re-commit zeroing, `MEM_RELEASE` clearing `GRAPHICS_RESERVATIONS` and `AWAY.title`, double-release rejection, and immediate address reuse. - `sparse::tests::self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp`: now asks through `map_mirror`, verifies `source_decommitted_in` clears `MIRROR_ASKED` and increments `MIRROR_FORGOTTEN`, and checks all three post-decommit recovery paths (`map_mirror` GPU-only re-ask, `source_committed_in` re-commit, and `mirror_writes` CPU write) on WARP. - **Updated PR description** (@Decodere, @Foniass): noted @KDenKC's RTX 5090 finding (that #3517 alone fixes the glass characters), documented the shared `XCL_MIRROR_MB` (4096 MiB) pool budget and the `#3517` `with_switch_fallback` window-4 cutoff (unchanged here since #3517 owns the 4-sparse-window layout), and explicitly disclosed in **Not tested** that the default 4-window smoke does not exercise the 16-window branches. Verified on `1de2334d6`: `cargo build --release -p xcl` (39 warnings, matching `5eaadb54c`), `.\scripts\test.ps1` with DXC 1.9 (`2981 passed, 0 failed, 52 ignored, 24 SKIPPED`), fresh 60 s smoke pair (`5eaadb54c` 1688 frames / 16676 MB vs `1de2334d6` 1683 frames / 16728 MB, 0 device removals, 0 crashes), and `scripts/pr_check.py --local` (`description ok`). AI use: Antigravity (Gemini 4 Neon) implemented these fixes, ran the checks, and drafted this reply.
pvfreis commented 2026-12-02 15:27:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pvfreis on 2026-12-02T15:27:34Z.


One integration note for whichever of this PR and #3696 lands second. Both use the slots immediately after the six primary GPU views. When dedicated heaps occupy some of that tail, the overflow allocator’s free list and graphics_view_windows() need to cover only the slots actually reserved as write-watched views. See #3696 for the proposed layout check.

AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source and drafted this note. Claude Code (Claude Fable 5.2) independently checked it.

<!-- greyfinch-sync:ivall/xcl:comment:7350359390 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7350359390). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-12-02T15:27:34Z. --- One integration note for whichever of this PR and #3696 lands second. Both use the slots immediately after the six primary GPU views. When dedicated heaps occupy some of that tail, the overflow allocator’s free list and `graphics_view_windows()` need to cover only the slots actually reserved as write-watched views. See #3696 for the proposed layout check. AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source and drafted this note. Claude Code (Claude Fable 5.2) independently checked it.
Kalmarv commented 2026-12-02 15:32:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:32:41Z.


Thanks @pvfreis — good catch, noted. Right now reserve_runtime takes all slots after views_at + VIEW_WINDOWS as write-watched WindowKind::View since they are WindowKind::None on main. If #3696 lands first, we will narrow total_view_wins, views.0, and graphics_view_windows() during the rebase so they cover only the trailing slots actually reserved as write-watched views (leaving dedicated heap windows untouched).

AI use: Antigravity (Gemini 4 Neon) checked gpu/uma.rs against #3696 and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7350505194 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7350505194). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:32:41Z. --- Thanks @pvfreis — good catch, noted. Right now `reserve_runtime` takes all slots after `views_at + VIEW_WINDOWS` as write-watched `WindowKind::View` since they are `WindowKind::None` on `main`. If #3696 lands first, we will narrow `total_view_wins`, `views.0`, and `graphics_view_windows()` during the rebase so they cover only the trailing slots actually reserved as write-watched views (leaving dedicated heap windows untouched). AI use: Antigravity (Gemini 4 Neon) checked `gpu/uma.rs` against #3696 and drafted this reply.
ClosetPie107 commented 2026-12-02 17:13:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-12-02T17:13:26Z.


Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on 1de2334

Merged onto main 5eaadb54 (clean merge) and compared with main run twice on the same machine.

Setup

  • AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, 30 GiB RAM, CachyOS (kernel 7.3.7)
  • Wine 11.23 (system), stock vkd3d-proton v3.1-83-gcae8353ed and DXVK dxgi.dll from GE-Proton11-16, DXC 1.9.2609.5
  • Debug build, cross-compiled for x86_64-pc-windows-msvc with cargo-xwin; test binaries run under Wine

Tested: cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-fail-fast -- --test-threads=4 --skip <31 tests>

passed failed ignored
main 5eaadb54 2769 177 52
this PR merged 2775 178 52
  • Tests that fail with this PR and pass on main: none.
  • Tests this PR adds: 6 of 7 pass (sparse_windows_setting_parses_clamps_and_fits_the_layout, sixteen_windows_keep_four_sparse_windows, a_bvh_scratch_reservation_lands_in_the_fourth_sparse_window, graphics_view_windows_cover_reservations_and_support_commit_and_write_watch, reserve_in_view_graphics_places_and_tracks_fallback_reservations, view_graphics_free_decommit_release_and_reuse).
    • self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp: fails with Invalid parameter (0x80070057), the #175 failure above, as main's tests of the same kind do here.
About the failures on main and the 31 skipped tests (same for every PR in this batch)
  • Most of main's 177 failures under Wine come from #175: once a test has set up the real device, vkd3d-proton refuses the command allocators XCL adopts (d3d12_command_list_Reset: Invalid command allocator), and later tests get E_INVALIDARG (0x80070057). Running vkd3d-proton master with its vtable check taken out, hle::d3d12x::sparse::tests goes from 106 passed / 38 failed to 144 / 0.
  • The 31 skipped tests make vkd3d-proton's dxil-spirv call std::terminate() (Cannot reliably convert LLVM pointer type, we cannot differentiate between Function and Private), which kills the whole test binary. They are the split-wave64, dispatch-chain and bridged-mask GPU tests, gpu_compute_mode_dispatch_abi, gpu_compute_thread_limits_leave_the_lanes_past_them_out, the two gpu_mesh_mode_* tests, and console_wave64_compute_through_the_pso_hook_dispatch_and_read_back, plus serialize_root_signature_strips_console_flags_and_preserves_pc_flags, whose null descriptor vkd3d-proton dereferences. The dxil-spirv ones crash the same way with vkd3d-proton master (f8c1cae8, dxil-spirv 93ab44c5).
  • main was run twice: same counts, same failure set. SKIPPED lines (same as main): no heap windows (2), no D3D12 debug layer (2-3), driver cache control not implemented in vkd3d-proton (1).

Not tested: Windows, NVIDIA, a retail title / scripts/smoke.ps1, a review of the diff. This is a test report, not a merge-check.

AI use: omp (Claude Opus 5.5) merged, built and ran the suites on this machine, compared the results with main, and drafted this report. The user asked for it to be posted.

<!-- greyfinch-sync:ivall/xcl:comment:7353068684 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7353068684). Originally posted by [ClosetPie107](https://github.com/ClosetPie107) on 2026-12-02T17:13:26Z. --- **Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on `1de2334`** Merged onto `main` `5eaadb54` (clean merge) and compared with `main` run twice on the same machine. **Setup** - AMD Radeon RX 9070 16 GB (RDNA4, RADV GFX1201, Mesa 26.3.1), Ryzen 5 9600X, 30 GiB RAM, CachyOS (kernel 7.3.7) - Wine 11.23 (system), stock vkd3d-proton `v3.1-83-gcae8353ed` and DXVK `dxgi.dll` from GE-Proton11-16, DXC 1.9.2609.5 - Debug build, cross-compiled for `x86_64-pc-windows-msvc` with `cargo-xwin`; test binaries run under Wine **Tested:** `cargo xwin test --workspace --target x86_64-pc-windows-msvc --no-fail-fast -- --test-threads=4 --skip <31 tests>` | | passed | failed | ignored | |---|---|---|---| | `main` `5eaadb54` | 2769 | 177 | 52 | | this PR merged | 2775 | 178 | 52 | - **Tests that fail with this PR and pass on `main`:** none. - **Tests this PR adds:** 6 of 7 pass (`sparse_windows_setting_parses_clamps_and_fits_the_layout`, `sixteen_windows_keep_four_sparse_windows`, `a_bvh_scratch_reservation_lands_in_the_fourth_sparse_window`, `graphics_view_windows_cover_reservations_and_support_commit_and_write_watch`, `reserve_in_view_graphics_places_and_tracks_fallback_reservations`, `view_graphics_free_decommit_release_and_reuse`). - `self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp`: fails with `Invalid parameter (0x80070057)`, the #175 failure above, as `main`'s tests of the same kind do here. <details><summary>About the failures on <code>main</code> and the 31 skipped tests (same for every PR in this batch)</summary> - Most of `main`'s 177 failures under Wine come from #175: once a test has set up the real device, vkd3d-proton refuses the command allocators XCL adopts (`d3d12_command_list_Reset: Invalid command allocator`), and later tests get `E_INVALIDARG` (`0x80070057`). Running vkd3d-proton master with its vtable check taken out, `hle::d3d12x::sparse::tests` goes from 106 passed / 38 failed to 144 / 0. - The 31 skipped tests make vkd3d-proton's dxil-spirv call `std::terminate()` (`Cannot reliably convert LLVM pointer type, we cannot differentiate between Function and Private`), which kills the whole test binary. They are the split-wave64, dispatch-chain and bridged-mask GPU tests, `gpu_compute_mode_dispatch_abi`, `gpu_compute_thread_limits_leave_the_lanes_past_them_out`, the two `gpu_mesh_mode_*` tests, and `console_wave64_compute_through_the_pso_hook_dispatch_and_read_back`, plus `serialize_root_signature_strips_console_flags_and_preserves_pc_flags`, whose null descriptor vkd3d-proton dereferences. The dxil-spirv ones crash the same way with vkd3d-proton master (`f8c1cae8`, dxil-spirv `93ab44c5`). - `main` was run twice: same counts, same failure set. `SKIPPED` lines (same as `main`): no heap windows (2), no D3D12 debug layer (2-3), driver cache control not implemented in vkd3d-proton (1). </details> **Not tested:** Windows, NVIDIA, a retail title / `scripts/smoke.ps1`, a review of the diff. This is a test report, not a `merge-check`. **AI use:** omp (Claude Opus 5.5) merged, built and ran the suites on this machine, compared the results with `main`, and drafted this report. The user asked for it to be posted.
Foniass commented 2026-12-02 18:02:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:02:38Z.


merge-check
base: 5eaadb54c1
head: 1de2334d6a
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2981 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: follow-up on 1de2334d (reworked and rebased from a74a58b9, my last review's head). Rebased onto main 5eaadb54; the carried commit 0de987866 has the same patch as #3517's current head 0b4283d1 (still open). The top commit is now +553/-73, about 330 lines of tests: it drops title_list::active_backing, moves the view-window VirtualFree branch into free_in_view (kernelx.rs ~1279) and adds commit_in_view_graphics (~1266), which the VirtualAlloc commit branch (~944) uses to call the new sparse::source_committed / source_committed_in (sparse.rs ~6475, ~7046); a decommit of a self-backed tile now calls forget_ask (~7033), and a re-ask of a linked, unmapped self-backed tile goes back into later (~6786). Earlier findings: (1) GPU-only tiles drawing on XCL_MIRROR_MB: still open; fill_later ~6756 only charges at least one page per tile now, and the description states the trade-off but gives no mirror or refusal counts from a 16-window run. (2) no video memory after decommit and re-commit: fixed; a decommit drops the ask, and the WARP test's path 1 would fail without forget_ask. (3) untested free and allocation paths: partly fixed; free_in_view and commit_in_view_graphics are called directly by view_graphics_free_decommit_release_and_reuse (~5654) but only with no sparse state, the WARP test calls source_committed_in directly, and the routing inside VirtualAlloc (~944, ~1019, ~1085) and the VirtualFree dispatch are still never reached through the hooks. (4) order of address release and forgetting the title's mappings: fixed (forget_title_mappings, forget_mirrors and remapped now run before u.view_release(a), ~1300-1306), though no test would catch the old order. (5) active_backing: removed. (6) disclosure: a 60 s smoke pair on the default layout, and Not tested says the 16-window branches didn't run. New, all minor: on MEM_RELEASE of a graphics reservation, free_in_view decommits before forget_mirrors, so the new re-queue in take_asks can give a tile of the reservation being released video memory in between (wasted work only); graphics_alloc_align (~1148) copies the alignment block at ~982 instead of replacing it; the kernelx test fills the global AWAY when it's empty and leaves it filled. Fine: the default 4-window layout is still a no-op (view_reserve_graphics returns None with no View windows, and the checks all require is_view); the sparse changes apply only to self-backed tiles; the partial decommit, re-commit, release and address-reuse sequence in free_in_view checks out.
performance: 60 s smoke of a retail title, main 5eaadb54 vs this merge (1de2334d): 1422 -> 1666 frames shown (117 %; last presents per 2 s: 60 60 61), peak commit 17184 -> 17780 MB, 0 device removals, 0 crashes.
verdict: safe to merge (it carries open #3517's commit, which lands with it): no blocking finding in the review (the points there are minor), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7353888182 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7353888182). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T18:02:38Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: 1de2334d6a257c081ed952f3169a2e874d326a04 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2981 passed, 0 failed, 52 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: follow-up on 1de2334d (reworked and rebased from a74a58b9, my last review's head). Rebased onto main 5eaadb54; the carried commit 0de987866 has the same patch as #3517's current head 0b4283d1 (still open). The top commit is now +553/-73, about 330 lines of tests: it drops `title_list::active_backing`, moves the view-window `VirtualFree` branch into `free_in_view` (`kernelx.rs` ~1279) and adds `commit_in_view_graphics` (~1266), which the `VirtualAlloc` commit branch (~944) uses to call the new `sparse::source_committed` / `source_committed_in` (`sparse.rs` ~6475, ~7046); a decommit of a self-backed tile now calls `forget_ask` (~7033), and a re-ask of a linked, unmapped self-backed tile goes back into `later` (~6786). Earlier findings: (1) GPU-only tiles drawing on `XCL_MIRROR_MB`: still open; `fill_later` ~6756 only charges at least one page per tile now, and the description states the trade-off but gives no mirror or refusal counts from a 16-window run. (2) no video memory after decommit and re-commit: fixed; a decommit drops the ask, and the WARP test's path 1 would fail without `forget_ask`. (3) untested free and allocation paths: partly fixed; `free_in_view` and `commit_in_view_graphics` are called directly by `view_graphics_free_decommit_release_and_reuse` (~5654) but only with no sparse state, the WARP test calls `source_committed_in` directly, and the routing inside `VirtualAlloc` (~944, ~1019, ~1085) and the `VirtualFree` dispatch are still never reached through the hooks. (4) order of address release and forgetting the title's mappings: fixed (`forget_title_mappings`, `forget_mirrors` and `remapped` now run before `u.view_release(a)`, ~1300-1306), though no test would catch the old order. (5) `active_backing`: removed. (6) disclosure: a 60 s smoke pair on the default layout, and Not tested says the 16-window branches didn't run. New, all minor: on `MEM_RELEASE` of a graphics reservation, `free_in_view` decommits before `forget_mirrors`, so the new re-queue in `take_asks` can give a tile of the reservation being released video memory in between (wasted work only); `graphics_alloc_align` (~1148) copies the alignment block at ~982 instead of replacing it; the kernelx test fills the global `AWAY` when it's empty and leaves it filled. Fine: the default 4-window layout is still a no-op (`view_reserve_graphics` returns None with no View windows, and the checks all require `is_view`); the sparse changes apply only to self-backed tiles; the partial decommit, re-commit, release and address-reuse sequence in `free_in_view` checks out. performance: 60 s smoke of a retail title, main 5eaadb54 vs this merge (1de2334d): 1422 -> 1666 frames shown (117 %; last presents per 2 s: 60 60 61), peak commit 17184 -> 17780 MB, 0 device removals, 0 crashes. verdict: safe to merge (it carries open #3517's commit, which lands with it): no blocking finding in the review (the points there are minor), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
bmjask commented 2026-12-02 19:34:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:35Z.

Code review location: crates/xcl/src/gpu/uma.rs; line 48

@@ -34,12 +34,32 @@ pub const MAX_WINDOWS: usize = 4;
 /// Maximum number of windows addressable through the shared descriptor heap (`XCL_HEAP_WINDOWS=1`).
 pub const MAX_HEAP_WINDOWS: usize = 16;
 
-/// Maximum sparse VRAM windows reserved in runtime layouts (3 × 4 GiB = 12 GiB VA).
+/// Maximum sparse VRAM windows reserved in the 4- and 8-window runtime layouts (3 × 4 GiB = 12 GiB VA).
 /// Keeping sparse VA capped at 12 GiB prevents huge startup `MEM_64K_PAGES` title heaps from
 /// being pulled into sparse VRAM (which causes multi-minute tile-mapping stalls and multi-GB
 /// sparse pool bloat), while still giving expanded 8/16-window layouts extra coherent windows.
 const MAX_RUNTIME_SPARSE_WINDOWS: usize = 3;
 
+/// Sparse VRAM windows of the 16-window layout (4 × 4 GiB = 16 GiB VA): one more, taken from the
+/// windows it leaves empty (4 sparse + 1 coherent + 6 view windows of 16), so it costs no address
+/// space. A retail title's BVH builder works in a 3.5 GB `MEM_RESERVE | MEM_64K_PAGES` reservation
+/// made once windows 1..2 are taken: with 3 it found no room and became plain write-watched
+/// memory, which shaders read as zeros (every acceleration structure stayed empty).
+const SIXTEEN_WINDOW_SPARSE_WINDOWS: usize = 4;

High: With 16 windows, SIXTEEN_WINDOW_SPARSE_WINDOWS = 4 moves the coherent window (the title's GPU heaps) from window 3 to window 4, which a pipeline rebuilt in switch form by with_switch_fallback (MAX_WINDOWS = 4, root UAVs 0..3) can't reach. The PR makes gpu_sparse_vram_descriptors_buffers_and_xmem skip on the 16-window layout instead of fixing it. With XCL_UMA_WINDOWS=16 and XCL_HEAP_WINDOWS=1, when the driver refuses a heap-window PSO and it's rebuilt in switch form, that shader's reads and writes to GPU heaps (xcl_w == 4) fall outside its windows and are dropped, so heaps read as zero or writes are lost. The only test that covered the coherent window now skips, so nothing catches it. This comes from the stacked #3517 commit but is in this diff.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774881631 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#discussion_r4774881631). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:35Z. **Code review location:** `crates/xcl/src/gpu/uma.rs`; line 48 ~~~~diff @@ -34,12 +34,32 @@ pub const MAX_WINDOWS: usize = 4; /// Maximum number of windows addressable through the shared descriptor heap (`XCL_HEAP_WINDOWS=1`). pub const MAX_HEAP_WINDOWS: usize = 16; -/// Maximum sparse VRAM windows reserved in runtime layouts (3 × 4 GiB = 12 GiB VA). +/// Maximum sparse VRAM windows reserved in the 4- and 8-window runtime layouts (3 × 4 GiB = 12 GiB VA). /// Keeping sparse VA capped at 12 GiB prevents huge startup `MEM_64K_PAGES` title heaps from /// being pulled into sparse VRAM (which causes multi-minute tile-mapping stalls and multi-GB /// sparse pool bloat), while still giving expanded 8/16-window layouts extra coherent windows. const MAX_RUNTIME_SPARSE_WINDOWS: usize = 3; +/// Sparse VRAM windows of the 16-window layout (4 × 4 GiB = 16 GiB VA): one more, taken from the +/// windows it leaves empty (4 sparse + 1 coherent + 6 view windows of 16), so it costs no address +/// space. A retail title's BVH builder works in a 3.5 GB `MEM_RESERVE | MEM_64K_PAGES` reservation +/// made once windows 1..2 are taken: with 3 it found no room and became plain write-watched +/// memory, which shaders read as zeros (every acceleration structure stayed empty). +const SIXTEEN_WINDOW_SPARSE_WINDOWS: usize = 4; ~~~~ --- **High**: With 16 windows, `SIXTEEN_WINDOW_SPARSE_WINDOWS = 4` moves the coherent window (the title's GPU heaps) from window 3 to window 4, which a pipeline rebuilt in switch form by `with_switch_fallback` (MAX_WINDOWS = 4, root UAVs 0..3) can't reach. The PR makes `gpu_sparse_vram_descriptors_buffers_and_xmem` skip on the 16-window layout instead of fixing it. With XCL_UMA_WINDOWS=16 and XCL_HEAP_WINDOWS=1, when the driver refuses a heap-window PSO and it's rebuilt in switch form, that shader's reads and writes to GPU heaps (`xcl_w == 4`) fall outside its windows and are dropped, so heaps read as zero or writes are lost. The only test that covered the coherent window now skips, so nothing catches it. This comes from the stacked #3517 commit but is in this diff.
bmjask commented 2026-12-02 19:34:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:35Z.

Code review location: crates/xcl/src/hle/kernelx.rs; line 945

@@ -922,8 +936,17 @@ pub unsafe extern "system" fn VirtualAlloc(addr: *const c_void, size: usize, t:
         return q;
     }
     // committing in a GPU view (a view window): plain pages, as before the views had windows –
-    // never the sparse windows' commit, whose tiles would take these pages for the view's bytes
-    if !addr.is_null() && t & 0x1000 != 0 && uma.is_some_and(|u| u.is_view(addr as usize)) {
+    // never the sparse windows' commit, whose tiles would take these pages for the view's bytes.
+    // A self-backed graphics reservation in a trailing view window (`in_graphics_reservation`) is
+    // expected to be committed on the CPU and reaches the GPU through on-demand view tiles; notify
+    // sparse so any previously decommitted self-backed tiles regain video memory without needing a
+    // CPU write.
+    if !addr.is_null() && t & mem::MEM_COMMIT != 0 && uma.is_some_and(|u| u.is_view(addr as usize)) {
+        if in_graphics_reservation(addr as usize) {

Medium: A commit in a trailing view window only checks that its start address is in a graphics reservation and never bounds the range, and all trailing windows are one OS MEM_RESERVE, so a commit past the reservation's end silently succeeds in free or neighbouring address space. If the title reserves 4 MiB at r (placed in window 11) and then calls VirtualAlloc(r + 3 MiB, 2 MiB, MEM_COMMIT), the call failed with ERROR_INVALID_ADDRESS before (as a separate plain reservation). Now commit_in_view_graphics commits 1 MiB past the reservation, possibly inside another title reservation placed right after it, and calls sparse::source_committed over that foreign range. A commit at a trailing address that was already released also falls through to the plain-pages path and succeeds. Checking a + n <= reservation end would restore the old failure.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774881666 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#discussion_r4774881666). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:35Z. **Code review location:** `crates/xcl/src/hle/kernelx.rs`; line 945 ~~~~diff @@ -922,8 +936,17 @@ pub unsafe extern "system" fn VirtualAlloc(addr: *const c_void, size: usize, t: return q; } // committing in a GPU view (a view window): plain pages, as before the views had windows – - // never the sparse windows' commit, whose tiles would take these pages for the view's bytes - if !addr.is_null() && t & 0x1000 != 0 && uma.is_some_and(|u| u.is_view(addr as usize)) { + // never the sparse windows' commit, whose tiles would take these pages for the view's bytes. + // A self-backed graphics reservation in a trailing view window (`in_graphics_reservation`) is + // expected to be committed on the CPU and reaches the GPU through on-demand view tiles; notify + // sparse so any previously decommitted self-backed tiles regain video memory without needing a + // CPU write. + if !addr.is_null() && t & mem::MEM_COMMIT != 0 && uma.is_some_and(|u| u.is_view(addr as usize)) { + if in_graphics_reservation(addr as usize) { ~~~~ --- **Medium**: A commit in a trailing view window only checks that its start address is in a graphics reservation and never bounds the range, and all trailing windows are one OS MEM_RESERVE, so a commit past the reservation's end silently succeeds in free or neighbouring address space. If the title reserves 4 MiB at r (placed in window 11) and then calls VirtualAlloc(r + 3 MiB, 2 MiB, MEM_COMMIT), the call failed with ERROR_INVALID_ADDRESS before (as a separate plain reservation). Now `commit_in_view_graphics` commits 1 MiB past the reservation, possibly inside another title reservation placed right after it, and calls `sparse::source_committed` over that foreign range. A commit at a trailing address that was already released also falls through to the plain-pages path and succeeds. Checking `a + n <= reservation end` would restore the old failure.
bmjask commented 2026-12-02 19:34:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:35Z.

Code review location: crates/xcl/src/hle/kernelx.rs; line 1020

@@ -993,6 +1016,11 @@ pub unsafe extern "system" fn VirtualAlloc(addr: *const c_void, size: usize, t:
             trace_mem("VirtualAlloc (graphics reserve, UMA)", 0, size, t as u64, p, q as usize);
             return q as *mut c_void;
         }
+        let align = graphics_alloc_align(t);
+        if let Some(q) = reserve_in_view_graphics(uma, size, align, t & !mem::MEM_COMMIT, p) {

Medium: MEM_GRAPHICS overflow reservations now go through reserve_in_view_graphics, which calls mirrors::reserved with MEM_COMMIT stripped, so a MEM_GRAPHICS reservation of 64 KiB pages is recorded as an unpaired CPU view (the old plain fallback never called mirrors::reserved). If such a reservation of size X lands in a trailing window, a later GPU-view reservation (PAGE_NOACCESS|PAGE_GRAPHICS_NOACCESS) of the same size calls unpaired_cpu, which picks the most recent CPU view of size X: the graphics reservation, not the title's real CPU view. The GPU view's tiles then show the wrong memory. Not registering graphics reservations as CPU views would avoid it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774881674 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#discussion_r4774881674). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:35Z. **Code review location:** `crates/xcl/src/hle/kernelx.rs`; line 1020 ~~~~diff @@ -993,6 +1016,11 @@ pub unsafe extern "system" fn VirtualAlloc(addr: *const c_void, size: usize, t: trace_mem("VirtualAlloc (graphics reserve, UMA)", 0, size, t as u64, p, q as usize); return q as *mut c_void; } + let align = graphics_alloc_align(t); + if let Some(q) = reserve_in_view_graphics(uma, size, align, t & !mem::MEM_COMMIT, p) { ~~~~ --- **Medium**: MEM_GRAPHICS overflow reservations now go through `reserve_in_view_graphics`, which calls `mirrors::reserved` with MEM_COMMIT stripped, so a MEM_GRAPHICS reservation of 64 KiB pages is recorded as an unpaired CPU view (the old plain fallback never called `mirrors::reserved`). If such a reservation of size X lands in a trailing window, a later GPU-view reservation (PAGE_NOACCESS|PAGE_GRAPHICS_NOACCESS) of the same size calls `unpaired_cpu`, which picks the most recent CPU view of size X: the graphics reservation, not the title's real CPU view. The GPU view's tiles then show the wrong memory. Not registering graphics reservations as CPU views would avoid it.
bmjask commented 2026-12-02 19:34:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:35Z.

Code review location: crates/xcl/src/hle/d3d12x/title_textures.rs; line 176

@@ -168,10 +168,12 @@ static COARSE_GEN: AtomicU64 = AtomicU64::new(0);
 /// the piece (1 MiB) of an address, for `Table::src_pieces`
 const SRC_PIECE_SHIFT: usize = 20;
 
-/// Whether `src` lies in a view window of unified memory: never watched (`Uma::watch_regions`),
-/// so a texture read there (`Entry::paged`) adds no block to `Table::coarse`.
+/// Whether `src` lies in a CPU-inaccessible GPU-view window of unified memory: never watched
+/// (`Uma::watch_regions`), so a texture read there (`Entry::paged`) adds no block to
+/// `Table::coarse`. Self-backed graphics reservations placed in trailing view windows
+/// (`kernelx::in_graphics_reservation`) are write-watched and remain tracked.
 fn in_view_window(src: usize) -> bool {
-    crate::gpu::uma::get().is_some_and(|u| u.is_view(src))
+    crate::gpu::uma::get().is_some_and(|u| u.is_view(src)) && !crate::hle::kernelx::in_graphics_reservation(src)

Medium: in_view_window now depends on the changing GRAPHICS_RESERVATIONS map, so link_src and unlink_src can get different answers for the same texture source and the coarse refcount goes wrong. A texture placed in a graphics reservation in a trailing view window is linked with in_view_window false, so coarse is incremented. If the title then calls VirtualFree(MEM_RELEASE) before destroying the texture, free_in_view removes the GRAPHICS_RESERVATIONS entry, unlink_src sees in_view_window true and returns early, and the 16 MiB coarse block is never decremented. It stays in cached_watch_ranges forever, or is miscounted when the address is reused. Recording the answer at link time would keep the two in step.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774881684 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#discussion_r4774881684). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:35Z. **Code review location:** `crates/xcl/src/hle/d3d12x/title_textures.rs`; line 176 ~~~~diff @@ -168,10 +168,12 @@ static COARSE_GEN: AtomicU64 = AtomicU64::new(0); /// the piece (1 MiB) of an address, for `Table::src_pieces` const SRC_PIECE_SHIFT: usize = 20; -/// Whether `src` lies in a view window of unified memory: never watched (`Uma::watch_regions`), -/// so a texture read there (`Entry::paged`) adds no block to `Table::coarse`. +/// Whether `src` lies in a CPU-inaccessible GPU-view window of unified memory: never watched +/// (`Uma::watch_regions`), so a texture read there (`Entry::paged`) adds no block to +/// `Table::coarse`. Self-backed graphics reservations placed in trailing view windows +/// (`kernelx::in_graphics_reservation`) are write-watched and remain tracked. fn in_view_window(src: usize) -> bool { - crate::gpu::uma::get().is_some_and(|u| u.is_view(src)) + crate::gpu::uma::get().is_some_and(|u| u.is_view(src)) && !crate::hle::kernelx::in_graphics_reservation(src) ~~~~ --- **Medium**: `in_view_window` now depends on the changing GRAPHICS_RESERVATIONS map, so `link_src` and `unlink_src` can get different answers for the same texture source and the `coarse` refcount goes wrong. A texture placed in a graphics reservation in a trailing view window is linked with `in_view_window` false, so `coarse` is incremented. If the title then calls VirtualFree(MEM_RELEASE) before destroying the texture, `free_in_view` removes the GRAPHICS_RESERVATIONS entry, `unlink_src` sees `in_view_window` true and returns early, and the 16 MiB coarse block is never decremented. It stays in `cached_watch_ranges` forever, or is miscounted when the address is reused. Recording the answer at link time would keep the two in step.
bmjask commented 2026-12-02 19:34:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:35Z.

Review: COMMENTED


Review of 1de2334d: 6 finding(s) (1 high, 5 medium), most severe first.

  1. High crates/xcl/src/gpu/uma.rs:48: With 16 windows, SIXTEEN_WINDOW_SPARSE_WINDOWS = 4 moves the coherent window (the title's GPU heaps) from window 3 to window 4, which a pipeline rebuilt in switch form by with_switch_fallback (MAX_WINDOWS = 4, root UAVs 0..3) can't r.... (inline)
  2. Medium crates/xcl/src/hle/kernelx.rs:945: A commit in a trailing view window only checks that its start address is in a graphics reservation and never bounds the range, and all trailing windows are one OS MEM_RESERVE, so a commit past the reservation's end silently succeeds in f.... (inline)
  3. Medium crates/xcl/src/hle/kernelx.rs:1020: MEM_GRAPHICS overflow reservations now go through reserve_in_view_graphics, which calls mirrors::reserved with MEM_COMMIT stripped, so a MEM_GRAPHICS reservation of 64 KiB pages is recorded as an unpaired CPU view (the old plain fall.... (inline)
  4. Medium crates/xcl/src/hle/d3d12x/title_textures.rs:176: in_view_window now depends on the changing GRAPHICS_RESERVATIONS map, so link_src and unlink_src can get different answers for the same texture source and the coarse refcount goes wrong. (inline)
  5. Medium crates/xcl/src/hle/kernelx.rs:1285: On MEM_RELEASE of a self-backed graphics reservation, free_in_view uses sparse::source_decommit and calls forget_mirrors only afterwards, outside the freeing span, which is the gap sparse::source_release exists to close. (inline)
  6. Medium crates/xcl/src/hle/d3d12x/sparse.rs:6759: Self-backed tiles with no committed page (h == 0xFFFF) now get video memory but are charged 1 page against the per-submit fill_pages budget, while each takes a full 64 KiB tile plus a zero-fill. (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6157548535 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#pullrequestreview-6157548535). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:35Z. **Review:** COMMENTED --- Review of `1de2334d`: 6 finding(s) (1 high, 5 medium), most severe first. 1. **High** `crates/xcl/src/gpu/uma.rs:48`: With 16 windows, `SIXTEEN_WINDOW_SPARSE_WINDOWS = 4` moves the coherent window (the title's GPU heaps) from window 3 to window 4, which a pipeline rebuilt in switch form by `with_switch_fallback` (MAX_WINDOWS = 4, root UAVs 0..3) can't r.... (inline) 2. **Medium** `crates/xcl/src/hle/kernelx.rs:945`: A commit in a trailing view window only checks that its start address is in a graphics reservation and never bounds the range, and all trailing windows are one OS MEM_RESERVE, so a commit past the reservation's end silently succeeds in f.... (inline) 3. **Medium** `crates/xcl/src/hle/kernelx.rs:1020`: MEM_GRAPHICS overflow reservations now go through `reserve_in_view_graphics`, which calls `mirrors::reserved` with MEM_COMMIT stripped, so a MEM_GRAPHICS reservation of 64 KiB pages is recorded as an unpaired CPU view (the old plain fall.... (inline) 4. **Medium** `crates/xcl/src/hle/d3d12x/title_textures.rs:176`: `in_view_window` now depends on the changing GRAPHICS_RESERVATIONS map, so `link_src` and `unlink_src` can get different answers for the same texture source and the `coarse` refcount goes wrong. (inline) 5. **Medium** `crates/xcl/src/hle/kernelx.rs:1285`: On MEM_RELEASE of a self-backed graphics reservation, `free_in_view` uses `sparse::source_decommit` and calls `forget_mirrors` only afterwards, outside the freeing span, which is the gap `sparse::source_release` exists to close. (inline) 6. **Medium** `crates/xcl/src/hle/d3d12x/sparse.rs:6759`: Self-backed tiles with no committed page (`h == 0xFFFF`) now get video memory but are charged 1 page against the per-submit `fill_pages` budget, while each takes a full 64 KiB tile plus a zero-fill. (inline) --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 19:34:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:36Z.

Code review location: crates/xcl/src/hle/kernelx.rs; line 1285

@@ -1194,6 +1260,55 @@ unsafe fn source_part_going<R>(part: Option<(usize, usize)>, release: bool, os:
     }
 }
 
+/// Commit `[addr, addr + size)` inside a self-backed graphics reservation in a trailing view window
+/// and tell `sparse::source_committed` so any previously decommitted self-backed tiles regain video
+/// memory on the next submit without requiring a CPU write.
+unsafe fn commit_in_view_graphics(addr: *const c_void, size: usize, t: u32, p: u32) -> *mut c_void {
+    let q = mem::VirtualAlloc(addr, size, sanitize_alloc_type(t), sanitize_protect(p));
+    if !q.is_null() {
+        let span = (addr as usize).saturating_add(size).saturating_sub(q as usize);
+        crate::hle::d3d12x::sparse::source_committed(q as usize, span);
+    }
+    q
+}
+
+/// Decommit or release a GPU view or self-backed graphics reservation inside the view windows.
+/// Cleans up `GRAPHICS_RESERVATIONS`, mirror pairings, title physical-page mappings, and sparse
+/// mirror state before calling `u.view_release(a)` so another thread cannot reserve and map the
+/// recycled address before old state is forgotten.
+unsafe fn free_in_view(u: &crate::gpu::uma::Uma, addr: *mut c_void, size: usize, t: u32) -> BOOL {
+    let a = addr as usize;
+    let Some((n, release)) = reservation_part(a, size, t, u.view_reservation(a)) else { return 0 };
+    let graphics = in_graphics_reservation(a);
+    if n > 0 {
+        let ok = if graphics {
+            crate::hle::d3d12x::sparse::source_decommit(a, n, || mem::VirtualFree(addr, n, mem::MEM_DECOMMIT))

Medium: On MEM_RELEASE of a self-backed graphics reservation, free_in_view uses sparse::source_decommit and calls forget_mirrors only afterwards, outside the freeing span, which is the gap sparse::source_release exists to close. A submit on another thread in that gap can run fill_later on tiles re-queued by take_asks or source_committed_in, and with the new h == 0xFFFF && w == c rule map video memory again over the released tiles, burning XCL_MIRROR_MB and racing forget_mirrors. Using source_release(a, n, ..) for the release case would fix it.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774881696 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#discussion_r4774881696). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:36Z. **Code review location:** `crates/xcl/src/hle/kernelx.rs`; line 1285 ~~~~diff @@ -1194,6 +1260,55 @@ unsafe fn source_part_going<R>(part: Option<(usize, usize)>, release: bool, os: } } +/// Commit `[addr, addr + size)` inside a self-backed graphics reservation in a trailing view window +/// and tell `sparse::source_committed` so any previously decommitted self-backed tiles regain video +/// memory on the next submit without requiring a CPU write. +unsafe fn commit_in_view_graphics(addr: *const c_void, size: usize, t: u32, p: u32) -> *mut c_void { + let q = mem::VirtualAlloc(addr, size, sanitize_alloc_type(t), sanitize_protect(p)); + if !q.is_null() { + let span = (addr as usize).saturating_add(size).saturating_sub(q as usize); + crate::hle::d3d12x::sparse::source_committed(q as usize, span); + } + q +} + +/// Decommit or release a GPU view or self-backed graphics reservation inside the view windows. +/// Cleans up `GRAPHICS_RESERVATIONS`, mirror pairings, title physical-page mappings, and sparse +/// mirror state before calling `u.view_release(a)` so another thread cannot reserve and map the +/// recycled address before old state is forgotten. +unsafe fn free_in_view(u: &crate::gpu::uma::Uma, addr: *mut c_void, size: usize, t: u32) -> BOOL { + let a = addr as usize; + let Some((n, release)) = reservation_part(a, size, t, u.view_reservation(a)) else { return 0 }; + let graphics = in_graphics_reservation(a); + if n > 0 { + let ok = if graphics { + crate::hle::d3d12x::sparse::source_decommit(a, n, || mem::VirtualFree(addr, n, mem::MEM_DECOMMIT)) ~~~~ --- **Medium**: On MEM_RELEASE of a self-backed graphics reservation, `free_in_view` uses `sparse::source_decommit` and calls `forget_mirrors` only afterwards, outside the freeing span, which is the gap `sparse::source_release` exists to close. A submit on another thread in that gap can run `fill_later` on tiles re-queued by `take_asks` or `source_committed_in`, and with the new `h == 0xFFFF && w == c` rule map video memory again over the released tiles, burning XCL_MIRROR_MB and racing `forget_mirrors`. Using `source_release(a, n, ..)` for the release case would fix it.
bmjask commented 2026-12-02 19:34:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:36Z.

Code review location: crates/xcl/src/hle/d3d12x/sparse.rs; line 6759

@@ -6725,10 +6753,10 @@ impl State {
                 if self.mirror_src.get(&w) != Some(&c) || self.mapped.contains_key(&w) {
                     continue;
                 }
-                if h == 0xFFFF {
+                if h == 0xFFFF && w != c {
                     self.refused.remove(&w);
                 } else if self.new_mirror(w, c, h, false) {
-                    *budget = budget.saturating_sub(PAGES_PER_TILE - h.count_ones() as usize);
+                    *budget = budget.saturating_sub((PAGES_PER_TILE - h.count_ones() as usize).max(1));

Medium: Self-backed tiles with no committed page (h == 0xFFFF) now get video memory but are charged 1 page against the per-submit fill_pages budget, while each takes a full 64 KiB tile plus a zero-fill. So one submit can map up to 16x more tiles than intended and drain the shared XCL_MIRROR_MB pool. When a BVH or scratch view in a multi-GiB uncommitted trailing reservation is asked for whole, the pool fills with GPU-only scratch, and later GPU-view tiles hit mirror_cap and are refused, so the GPU reads zeros there. Charging the tile's full size would keep the budget meaningful.

<!-- greyfinch-sync:ivall/xcl:review-comment:4774881710 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#discussion_r4774881710). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:36Z. **Code review location:** `crates/xcl/src/hle/d3d12x/sparse.rs`; line 6759 ~~~~diff @@ -6725,10 +6753,10 @@ impl State { if self.mirror_src.get(&w) != Some(&c) || self.mapped.contains_key(&w) { continue; } - if h == 0xFFFF { + if h == 0xFFFF && w != c { self.refused.remove(&w); } else if self.new_mirror(w, c, h, false) { - *budget = budget.saturating_sub(PAGES_PER_TILE - h.count_ones() as usize); + *budget = budget.saturating_sub((PAGES_PER_TILE - h.count_ones() as usize).max(1)); ~~~~ --- **Medium**: Self-backed tiles with no committed page (`h == 0xFFFF`) now get video memory but are charged 1 page against the per-submit `fill_pages` budget, while each takes a full 64 KiB tile plus a zero-fill. So one submit can map up to 16x more tiles than intended and drain the shared XCL_MIRROR_MB pool. When a BVH or scratch view in a multi-GiB uncommitted trailing reservation is asked for whole, the pool fills with GPU-only scratch, and later GPU-view tiles hit `mirror_cap` and are refused, so the GPU reads zeros there. Charging the tile's full size would keep the budget meaningful.
bmjask commented 2026-12-02 19:34:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:34:38Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7356393745 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7356393745). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:34:38Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Kalmarv commented 2026-12-02 21:04:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T21:04:03Z.


Thanks @bmjask for the thorough review (and @Prime1997 for taking a look). Fixed all five medium findings from 1de2334d in 5c963d8fe:

  1. gpu/uma.rs:48 (High — inherited from stacked #3517): Left unchanged here since it belongs to @CharlyRien's carried #3517 commit (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4 and with_switch_fallback's 4-window limit), already noted in the PR description.
  2. kernelx.rs:945 (view-window VirtualAlloc(MEM_COMMIT) bounds): Both VirtualAlloc (view-window branch) and commit_in_view_graphics now verify u.view_reservation(a) covers [a, a + size) and fail out-of-bounds or already-released addresses with ERROR_INVALID_ADDRESS.
  3. kernelx.rs:1020 (MEM_GRAPHICS overflow registered as unpaired CPU view): Removed mirrors::reserved from reserve_in_view_graphics so MEM_GRAPHICS overflow reservations are never recorded as unpaired CPU views (non-MEM_GRAPHICS gpu_visible_fallback reservations still call mirrors::reserved).
  4. title_textures.rs:176 (Table::coarse refcount drift when reservation is released before texture unlink): Recorded link-time coarse membership in Table::coarse_res so unlink_src decrements the exact resources link_src added regardless of subsequent GRAPHICS_RESERVATIONS changes.
  5. kernelx.rs:1285 (free_in_view release gap): On MEM_RELEASE of a self-backed graphics reservation, free_in_view now uses sparse::source_release(a, n, ...) and removes GRAPHICS_RESERVATIONS / calls mirrors::released(a) inside its freeing span before forget_mirrors runs.
  6. sparse.rs:6759 (fill_later budget for uncommitted self-backed tiles): Uncommitted self-backed tiles (h == 0xFFFF) now charge the full PAGES_PER_TILE (16) against fill_later's per-submit page budget instead of 1 page.

Also addressed @Foniass's minor cleanup notes (graphics_alloc_align reuse at line 982 and restoring AWAY in the kernelx test) and added unit-test coverage for each fix (reserve_in_view_graphics_places_and_tracks_fallback_reservations, view_graphics_free_decommit_release_and_reuse, coarse_refcount_stays_balanced_after_graphics_reservation_release, and self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp).

Verified on 5c963d8fe (RTX 5070 Ti, Windows 11, DXC 1.9.2609.5): cargo build --release -p xcl (39 warnings, 0 new), .\scripts\test.ps1 (2982 passed, 0 failed, 52 ignored, 24 SKIPPED), and fresh 60 s smoke (1663 frames, 17392 MB peak commit, 0 device removals, 0 crashes; PR description updated).

AI use: Antigravity (Gemini 4 Neon) implemented the fixes and tests, ran the build/test/smoke checks, and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7358741325 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7358741325). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T21:04:03Z. --- Thanks @bmjask for the thorough review (and @Prime1997 for taking a look). Fixed all five medium findings from `1de2334d` in `5c963d8fe`: 1. **`gpu/uma.rs:48` (High — inherited from stacked #3517):** Left unchanged here since it belongs to @CharlyRien's carried #3517 commit (`SIXTEEN_WINDOW_SPARSE_WINDOWS = 4` and `with_switch_fallback`'s 4-window limit), already noted in the PR description. 2. **`kernelx.rs:945` (view-window `VirtualAlloc(MEM_COMMIT)` bounds):** Both `VirtualAlloc` (view-window branch) and `commit_in_view_graphics` now verify `u.view_reservation(a)` covers `[a, a + size)` and fail out-of-bounds or already-released addresses with `ERROR_INVALID_ADDRESS`. 3. **`kernelx.rs:1020` (`MEM_GRAPHICS` overflow registered as unpaired CPU view):** Removed `mirrors::reserved` from `reserve_in_view_graphics` so `MEM_GRAPHICS` overflow reservations are never recorded as unpaired CPU views (non-`MEM_GRAPHICS` `gpu_visible_fallback` reservations still call `mirrors::reserved`). 4. **`title_textures.rs:176` (`Table::coarse` refcount drift when reservation is released before texture unlink):** Recorded link-time `coarse` membership in `Table::coarse_res` so `unlink_src` decrements the exact resources `link_src` added regardless of subsequent `GRAPHICS_RESERVATIONS` changes. 5. **`kernelx.rs:1285` (`free_in_view` release gap):** On `MEM_RELEASE` of a self-backed graphics reservation, `free_in_view` now uses `sparse::source_release(a, n, ...)` and removes `GRAPHICS_RESERVATIONS` / calls `mirrors::released(a)` inside its freeing span before `forget_mirrors` runs. 6. **`sparse.rs:6759` (`fill_later` budget for uncommitted self-backed tiles):** Uncommitted self-backed tiles (`h == 0xFFFF`) now charge the full `PAGES_PER_TILE` (16) against `fill_later`'s per-submit page budget instead of 1 page. Also addressed @Foniass's minor cleanup notes (`graphics_alloc_align` reuse at line 982 and restoring `AWAY` in the `kernelx` test) and added unit-test coverage for each fix (`reserve_in_view_graphics_places_and_tracks_fallback_reservations`, `view_graphics_free_decommit_release_and_reuse`, `coarse_refcount_stays_balanced_after_graphics_reservation_release`, and `self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp`). Verified on `5c963d8fe` (RTX 5070 Ti, Windows 11, DXC 1.9.2609.5): `cargo build --release -p xcl` (39 warnings, 0 new), `.\scripts\test.ps1` (`2982 passed, 0 failed, 52 ignored, 24 SKIPPED`), and fresh 60 s smoke (`1663 frames`, `17392 MB` peak commit, 0 device removals, 0 crashes; PR description updated). AI use: Antigravity (Gemini 4 Neon) implemented the fixes and tests, ran the build/test/smoke checks, and drafted this reply.
jsalzy commented 2026-12-03 00:00:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T00:00:03Z.


merge-check claim
head: 5c963d8fe9

<!-- greyfinch-sync:ivall/xcl:comment:7362677842 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7362677842). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-12-03T00:00:03Z. --- merge-check claim head: 5c963d8fe94168b1e5ff1855ce09978300c6c9b5
jsalzy commented 2026-12-03 00:13:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jsalzy on 2026-12-03T00:13:42Z.


merge-check
base: 078358a058
head: 5c963d8fe9
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3014 passed, 0 failed, 52 ignored (44 test binaries); SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. All 8 tests the PR adds ran and passed. git diff --check clean; 39 compiler warnings, the same as main.
title run: RTX 4070 SUPER 12 GB (621.24), release build of this merge (9f1d2cc4) with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_DEVICE_TYPE=lockhart XCL_NETWORK=0, everything else main's defaults (plus XCL_ACTIVITY, XCL_DRED and XCL_TRACE_MEM for the log); layout 4 sparse + 2 coherent (4543 MB) + 10 view windows. [In the world on a save / In the intro cutscenes]: about 422 s there (the loading screen ended at 838 s; I closed the window at 1260 s). 0 device removals, 0 crashes (exit code 0). 0.68 presents/s there: 1.58/s for the first ~110 s, 0.90/s for the next ~70 s, 0.22/s for the last ~240 s (60/s on the menus and loading screen). No colored blocks or black screen seen. At least 128 presents took long in the driver (up to 2.1 s), and 7 driver stalls of 2 s or more were logged, all recovered. Video memory use grew to 15.5 GB against a 10.5 GB budget. Not compared with main on the same settings.
review: (1) Caveat, carried over from #3517 and not from this PR's own commit: the PR carries 0de98786, which has the same patch as #3517's head 0b4283d1. With 16 windows, uma.rs:48 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) moves the coherent window to window 4. But with_switch_fallback (real.rs:5191, comment at 5197-5198) reaches only windows 0..3, so a pipeline built in the switch form reads 0 from coherent memory. This is unchanged at this head (the author's 21:04 reply leaves it to #3517). #3517 has two not-yet checks for this, and merging this PR lands it along with #3517. (2) Found in the title run: the 24 GiB cut-off in view_reserve_graphics (size >= VIEW_WINDOWS * WINDOW) keeps only the Series X profile's CPU view out of the trailing windows. On the Series S profile (title memory 8192 MiB) the title's CPU view is 16 GiB (VirtualAlloc of 0x400000000 bytes, flags 0x20402000, protect 0x4). kernelx.rs ~1086 put it at 0x1c00000000, in windows 12..15, which are all four trailing windows when the layout has 2 coherent windows; its GPU view went to 0x1600000000. On main that CPU view stays in plain write-watched memory. So on this profile there is no room left for the overflow MEM_GRAPHICS reservations the PR is for (none overflowed in this run: 477 memory calls of 64 KiB or more were logged, 0 of them "graphics reserve, view windows"). The PR description says CPU views are rejected, but the test checks only the 24 GiB size. Nothing visibly broke in the run. (3) Missing tests: the new tests call reserve_in_view_graphics / commit_in_view_graphics / free_in_view directly on a local Uma. The routing inside the hooks (kernelx.rs VirtualAlloc ~944, ~1020, ~1086; the VirtualFree dispatch ~1380) goes through uma::get(), which is the 4-window layout in the suite, so no test reaches those branches. (4) A fully uncommitted self-backed tile (h == 0xFFFF, w == c) now gets video memory when asked for (sparse.rs:6756-6759) and is charged 16 pages. That comes out of the GPU-view budget (XCL_MIRROR_MB). No mirror or refusal counts from a 16-window run are given (Foniass's earlier point 1). (5) #3696 is open and uses the same slots after the six views: uma.rs:401 reserves views_at + view_wins..windows as write-watched view windows, and #3696 puts committed heap windows at views_at + view_wins. The author has noted this; whichever PR lands second needs a rebase. Checked and fine: the default 4-window layout is unaffected (view_reserve_graphics returns None with no view windows, and every new branch needs is_view). The GRAPHICS_RESERVATIONS locks are short-lived and none is held across a sparse call. Readback skips uncommitted holes, so GPU-only scratch can't fault the CPU copy-back. coarse_res keeps link and unlink balanced. Stripping MEM_COMMIT at ~1020 matches main's plain fallback, which also only reserves. Duplicates: I searched open and merged PRs for view_reserve_graphics, graphics_view_windows, in_graphics_reservation, coarse_res, SIXTEEN_WINDOW_SPARSE_WINDOWS, trailing view windows, self-backed graphics and #3517, and checked #1607's groups (none lists 3653, 3517, 3662 or 3696). Not a duplicate: #3517 is stacked underneath (all of it is carried here). #3662 (BVH builder hooks) and #3696 (heap windows) make different changes.
performance: Default layout: no cost (reasoned: every new path is behind the 16-window layout). 16 windows, measured in the title run but not against main: GPU-view tiles with video memory peaked at 10,453 (about 653 MB), 0 refused (cap 65,536); video memory use 15.5 GB against a 10.5 GB budget at the end; 0.68 presents/s in the run. Reasoned: four or five more 4 GiB tiled buffers (one per trailing window), with no memory until tiles are mapped. GPU-only scratch in graphics reservations takes video memory from the GPU-view budget. list_x.rs:430 read_back is true for every view address, which now includes the trailing windows, so tiles the GPU writes there are copied back to the CPU after each submit.
verdict: safe to merge, with caveats: this PR's own commit has no blocking finding, the suite passes, and the title run had no crash or device removal. It carries open #3517's commit, which lands with it, including #3517's 16-window switch-form gap (review (1)), which is still open there. On the Series S profile the title's 16 GiB CPU view fills the new trailing windows (review (2)).
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; release build of the merge for the title run, played by me; diff review and log reading by Claude Opus 5.5.

<!-- greyfinch-sync:ivall/xcl:comment:7362945203 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7362945203). Originally posted by [jsalzy](https://github.com/jsalzy) on 2026-12-03T00:13:42Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 5c963d8fe94168b1e5ff1855ce09978300c6c9b5 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3014 passed, 0 failed, 52 ignored (44 test binaries); SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none. All 8 tests the PR adds ran and passed. git diff --check clean; 39 compiler warnings, the same as main. title run: RTX 4070 SUPER 12 GB (621.24), release build of this merge (9f1d2cc4) with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_DEVICE_TYPE=lockhart XCL_NETWORK=0, everything else main's defaults (plus XCL_ACTIVITY, XCL_DRED and XCL_TRACE_MEM for the log); layout 4 sparse + 2 coherent (4543 MB) + 10 view windows. [In the world on a save / In the intro cutscenes]: about 422 s there (the loading screen ended at 838 s; I closed the window at 1260 s). 0 device removals, 0 crashes (exit code 0). 0.68 presents/s there: 1.58/s for the first ~110 s, 0.90/s for the next ~70 s, 0.22/s for the last ~240 s (60/s on the menus and loading screen). No colored blocks or black screen seen. At least 128 presents took long in the driver (up to 2.1 s), and 7 driver stalls of 2 s or more were logged, all recovered. Video memory use grew to 15.5 GB against a 10.5 GB budget. Not compared with main on the same settings. review: (1) Caveat, carried over from #3517 and not from this PR's own commit: the PR carries 0de98786, which has the same patch as #3517's head 0b4283d1. With 16 windows, uma.rs:48 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) moves the coherent window to window 4. But with_switch_fallback (real.rs:5191, comment at 5197-5198) reaches only windows 0..3, so a pipeline built in the switch form reads 0 from coherent memory. This is unchanged at this head (the author's 21:04 reply leaves it to #3517). #3517 has two not-yet checks for this, and merging this PR lands it along with #3517. (2) Found in the title run: the 24 GiB cut-off in view_reserve_graphics (size >= VIEW_WINDOWS * WINDOW) keeps only the Series X profile's CPU view out of the trailing windows. On the Series S profile (title memory 8192 MiB) the title's CPU view is 16 GiB (VirtualAlloc of 0x400000000 bytes, flags 0x20402000, protect 0x4). kernelx.rs ~1086 put it at 0x1c00000000, in windows 12..15, which are all four trailing windows when the layout has 2 coherent windows; its GPU view went to 0x1600000000. On main that CPU view stays in plain write-watched memory. So on this profile there is no room left for the overflow MEM_GRAPHICS reservations the PR is for (none overflowed in this run: 477 memory calls of 64 KiB or more were logged, 0 of them "graphics reserve, view windows"). The PR description says CPU views are rejected, but the test checks only the 24 GiB size. Nothing visibly broke in the run. (3) Missing tests: the new tests call reserve_in_view_graphics / commit_in_view_graphics / free_in_view directly on a local Uma. The routing inside the hooks (kernelx.rs VirtualAlloc ~944, ~1020, ~1086; the VirtualFree dispatch ~1380) goes through uma::get(), which is the 4-window layout in the suite, so no test reaches those branches. (4) A fully uncommitted self-backed tile (h == 0xFFFF, w == c) now gets video memory when asked for (sparse.rs:6756-6759) and is charged 16 pages. That comes out of the GPU-view budget (XCL_MIRROR_MB). No mirror or refusal counts from a 16-window run are given (Foniass's earlier point 1). (5) #3696 is open and uses the same slots after the six views: uma.rs:401 reserves views_at + view_wins..windows as write-watched view windows, and #3696 puts committed heap windows at views_at + view_wins. The author has noted this; whichever PR lands second needs a rebase. Checked and fine: the default 4-window layout is unaffected (view_reserve_graphics returns None with no view windows, and every new branch needs is_view). The GRAPHICS_RESERVATIONS locks are short-lived and none is held across a sparse call. Readback skips uncommitted holes, so GPU-only scratch can't fault the CPU copy-back. coarse_res keeps link and unlink balanced. Stripping MEM_COMMIT at ~1020 matches main's plain fallback, which also only reserves. Duplicates: I searched open and merged PRs for view_reserve_graphics, graphics_view_windows, in_graphics_reservation, coarse_res, SIXTEEN_WINDOW_SPARSE_WINDOWS, trailing view windows, self-backed graphics and #3517, and checked #1607's groups (none lists 3653, 3517, 3662 or 3696). Not a duplicate: #3517 is stacked underneath (all of it is carried here). #3662 (BVH builder hooks) and #3696 (heap windows) make different changes. performance: Default layout: no cost (reasoned: every new path is behind the 16-window layout). 16 windows, measured in the title run but not against main: GPU-view tiles with video memory peaked at 10,453 (about 653 MB), 0 refused (cap 65,536); video memory use 15.5 GB against a 10.5 GB budget at the end; 0.68 presents/s in the run. Reasoned: four or five more 4 GiB tiled buffers (one per trailing window), with no memory until tiles are mapped. GPU-only scratch in graphics reservations takes video memory from the GPU-view budget. list_x.rs:430 read_back is true for every view address, which now includes the trailing windows, so tiles the GPU writes there are copied back to the CPU after each submit. verdict: safe to merge, with caveats: this PR's own commit has no blocking finding, the suite passes, and the title run had no crash or device removal. It carries open #3517's commit, which lands with it, including #3517's 16-window switch-form gap (review (1)), which is still open there. On the Series S profile the title's 16 GiB CPU view fills the new trailing windows (review (2)). hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; release build of the merge for the title run, played by me; diff review and log reading by Claude Opus 5.5.
Kalmarv commented 2026-12-03 00:56:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T00:56:34Z.


Thanks @jsalzy for catching the Series S (lockhart) 16 GiB CPU-view issue in the live 16-window title run! Fixed in ebef2ce9d (leaving #3517's carried commit 0de987866 untouched):

  • crates/xcl/src/hle/kernelx.rs: Added mirrors::is_cpu_view_reservation(t, p) (MEM_64K_PAGES reserve-only, without MEM_GRAPHICS or PAGE_GRAPHICS_* GPU-accessible protection, and not PAGE_NOACCESS) and checked it in both VirtualAlloc's gpu_visible_fallback branch and reserve_in_view_graphics. Pure CPU views — including the 16 GiB Series S (0x400000000, flags 0x20402000, protect 0x4) and 24 GiB Series X CPU views — now stay in plain write-watched memory (reserve_watched + mirrors::reserved), while genuine overflow MEM_GRAPHICS and PAGE_GRAPHICS_* large-page fallbacks continue to land in the trailing view windows.
  • crates/xcl/src/gpu/uma.rs: Tightened Uma::view_reserve_graphics's size guard from VIEW_WINDOWS * WINDOW (24 GiB) to (hi - lo) * WINDOW (the trailing pool size, e.g. 16 GiB with 2 coherent windows or 20 GiB with 1) so no single reservation can swallow the entire trailing overflow pool.
  • Tests: Updated reserve_in_view_graphics_places_and_tracks_fallback_reservations (covering the 16 GiB Series S 0x20402000/0x4 CPU view, 24 GiB Series X CPU view, smaller pure CPU views, and positive MEM_GRAPHICS/PAGE_GRAPHICS_* cases) and graphics_view_windows_cover_reservations_and_support_commit_and_write_watch (full trailing-pool rejection).

Verified on ebef2ce9d (RTX 5070 Ti, Windows 11, DXC 1.9.2609.5): cargo build --release -p xcl (39 warnings, 0 new), .\scripts\test.ps1 (2982 passed, 0 failed, 52 ignored, 24 SKIPPED), and fresh 60 s smoke (1701 frames, 16860 MB peak commit, 0 device removals, 0 crashes; PR description updated).

AI use: Antigravity (Gemini 4 Neon) implemented the fix and unit tests, ran the build/test/smoke checks, and drafted this reply.

<!-- greyfinch-sync:ivall/xcl:comment:7363769247 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7363769247). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T00:56:34Z. --- Thanks @jsalzy for catching the Series S (`lockhart`) 16 GiB CPU-view issue in the live 16-window title run! Fixed in `ebef2ce9d` (leaving #3517's carried commit `0de987866` untouched): - **`crates/xcl/src/hle/kernelx.rs`:** Added `mirrors::is_cpu_view_reservation(t, p)` (`MEM_64K_PAGES` reserve-only, without `MEM_GRAPHICS` or `PAGE_GRAPHICS_*` GPU-accessible protection, and not `PAGE_NOACCESS`) and checked it in both `VirtualAlloc`'s `gpu_visible_fallback` branch and `reserve_in_view_graphics`. Pure CPU views — including the 16 GiB Series S (`0x400000000`, flags `0x20402000`, protect `0x4`) and 24 GiB Series X CPU views — now stay in plain write-watched memory (`reserve_watched` + `mirrors::reserved`), while genuine overflow `MEM_GRAPHICS` and `PAGE_GRAPHICS_*` large-page fallbacks continue to land in the trailing view windows. - **`crates/xcl/src/gpu/uma.rs`:** Tightened `Uma::view_reserve_graphics`'s size guard from `VIEW_WINDOWS * WINDOW` (24 GiB) to `(hi - lo) * WINDOW` (the trailing pool size, e.g. 16 GiB with 2 coherent windows or 20 GiB with 1) so no single reservation can swallow the entire trailing overflow pool. - **Tests:** Updated `reserve_in_view_graphics_places_and_tracks_fallback_reservations` (covering the 16 GiB Series S `0x20402000`/`0x4` CPU view, 24 GiB Series X CPU view, smaller pure CPU views, and positive `MEM_GRAPHICS`/`PAGE_GRAPHICS_*` cases) and `graphics_view_windows_cover_reservations_and_support_commit_and_write_watch` (full trailing-pool rejection). Verified on `ebef2ce9d` (RTX 5070 Ti, Windows 11, DXC 1.9.2609.5): `cargo build --release -p xcl` (39 warnings, 0 new), `.\scripts\test.ps1` (`2982 passed, 0 failed, 52 ignored, 24 SKIPPED`), and fresh 60 s smoke (`1701 frames`, `16860 MB` peak commit, 0 device removals, 0 crashes; PR description updated). AI use: Antigravity (Gemini 4 Neon) implemented the fix and unit tests, ran the build/test/smoke checks, and drafted this reply.
Foniass commented 2026-12-03 05:10:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T05:10:06Z.


merge-check
base: 078358a058
head: ebef2ce9df
merge: clean
build: ok
tests: 3014 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 5 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1682 frames (100 % of main), peak commit 17577 → 17940 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 231 s there, 0 device removals, 0 crashes, 3 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: The PR places overflow MEM_GRAPHICS and GPU-visible fallback reservations in the trailing view windows of the 16-window layout. It carries #3517's commit unchanged, and this push (5c963d8f -> ebef2ce9) only adds mirrors::is_cpu_view_reservation and a trailing-pool size limit, fixing the Series S 16 GiB CPU view that jsalzy's title run caught. None of the seven findings from my 5c963d8f review are fixed at this head and all stay open, but none blocks merging.

Medium

  1. Carries #3517's switch-form cutoff. The carried commit 0de987866 is still the same patch as open #3517's head 0b4283d1. With 16 windows, uma.rs:48 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) moves the coherent window to window 4, which with_switch_fallback (4 root-UAV windows, 0..3) cannot reach, so a pipeline in the switch form reads zeros from coherent memory. It lands with this PR unless #3517 fixes it first.
  2. GPU-only tiles still share XCL_MIRROR_MB with the GPU view. sparse.rs did not change in this push. fill_later still gives video memory to uncommitted self-backed tiles (h == 0xFFFF) from the same XCL_MIRROR_MB cap (4096 MB by default) as the 24 GiB GPU view, so a whole-range ask on a multi-GiB overflow reservation can use up the cap and GPU-view tiles are then refused (zeros). The description states the trade-off, but no mirror or refusal counts from a 16-window run are given. Give these tiles their own budget or report the counts.
  3. The hooks' routing is still untested. The new assertions call is_cpu_view_reservation and reserve_in_view_graphics directly on a local Uma. The routing inside VirtualAlloc (kernelx.rs ~1032 MEM_GRAPHICS reserve, ~1096 gpu_visible_fallback, where the Series S CPU view went wrong) and the VirtualFree dispatch (~1356) go through uma::get(), which has the 4-window layout in the suite, so no test reaches them. A test that drives VirtualAlloc/VirtualFree with a 16-window Uma would cover the path this push fixes.
  4. No title run of the 16-window layout at this head. This push changes the 16-window routing that jsalzy's title run at 5c963d8f found wrong (the Series S 16 GiB CPU view in windows 12..15). The smoke blocks use the default 4-window layout, and Not tested says no 16-window title run was done on ebef2ce9. A lockhart run with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 showing the 0x400000000-byte CPU view as "GPU-visible, write-watched" (plain memory) would confirm the fix.
  5. Conflicts with open #3696 and #3517, and no issue link. A test merge with #3696's head 73a68e2e conflicts in crates/xcl/src/gpu/uma.rs, because both use the windows after the six primary views. #3517, which is carried whole, is still open. The description still has no "Fixes #N" or "Part of #N".

Nit

  1. WARP test prints its own SKIPPED line. sparse.rs ~13728 prints eprintln!("SKIPPED ...") instead of calling gpu::recomp:🏃:skip_test, so XCL_REQUIRE_GPU cannot turn a missing WARP device into a failure. Use skip_test and return.
  2. Looser view-span assertion in bind.rs. bind.rs ~7860 changed assert_eq!(span.1, VIEW_WINDOWS * WINDOW) into view_wins >= VIEW_WINDOWS plus span == view_wins * WINDOW, which no longer pins how many view windows the test layout has. Assert the exact count (VIEW_WINDOWS plus the trailing windows of this layout).
  3. The trailing-pool limit does less than its comment says. uma.rs ~535 rejects only size >= (hi - lo) * WINDOW, so a reservation one 64 KiB grain smaller can still take nearly the whole pool, while the doc comment says no single reservation can swallow all trailing windows. Now that CPU views are excluded by their flags, either reword the comment or set a real cap. The is_cpu_view_reservation check in VirtualAlloc (kernelx.rs ~1096) also repeats the one inside reserve_in_view_graphics (~1178).
Checked and fine
  • The jsalzy Series S finding from the 5c963d8f merge-check is fixed: is_cpu_view_reservation (kernelx.rs ~218) matches MEM_RESERVE | MEM_64K_PAGES (0x20402000) with PAGE_READWRITE and no MEM_GRAPHICS or PAGE_GRAPHICS_* access, so that CPU view goes to reserve_watched + mirrors::reserved, as on main
  • The predicate excludes MEM_GRAPHICS, PAGE_GRAPHICS_* GPU-access protections, committed allocations and PAGE_NOACCESS GPU views, so real overflow graphics reservations still reach the trailing windows
  • The new kernelx assertion would fail at 5c963d8f: its 16 GiB CPU view fits in the 20 GiB trailing pool of the test's 1-coherent-window layout, and only the new flag check rejects it
  • Default 4-window layout: still a no-op by reading; the new check runs only before reserve_in_view_graphics, which returns None with no view windows, and CPU views take the same reserve_watched path as on main
  • The carried commit 0de987866 has the same patch as #3517's head 0b4283d1, and the PR merges cleanly onto main 078358a0
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 61 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7368447226 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7368447226). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T05:10:06Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: ebef2ce9df61b39a70f479b486870e60c45bdd2b merge: clean build: ok tests: 3014 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 5 medium, 3 nits (below) performance: 60 s smoke run: 1669 → 1682 frames (100 % of main), peak commit 17577 → 17940 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 231 s there, 0 device removals, 0 crashes, 3 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** The PR places overflow MEM_GRAPHICS and GPU-visible fallback reservations in the trailing view windows of the 16-window layout. It carries #3517's commit unchanged, and this push (5c963d8f -> ebef2ce9) only adds mirrors::is_cpu_view_reservation and a trailing-pool size limit, fixing the Series S 16 GiB CPU view that jsalzy's title run caught. None of the seven findings from my 5c963d8f review are fixed at this head and all stay open, but none blocks merging. #### Medium 1. **Carries #3517's switch-form cutoff.** The carried commit 0de987866 is still the same patch as open #3517's head 0b4283d1. With 16 windows, uma.rs:48 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) moves the coherent window to window 4, which with_switch_fallback (4 root-UAV windows, 0..3) cannot reach, so a pipeline in the switch form reads zeros from coherent memory. It lands with this PR unless #3517 fixes it first. 2. **GPU-only tiles still share XCL_MIRROR_MB with the GPU view.** sparse.rs did not change in this push. fill_later still gives video memory to uncommitted self-backed tiles (h == 0xFFFF) from the same XCL_MIRROR_MB cap (4096 MB by default) as the 24 GiB GPU view, so a whole-range ask on a multi-GiB overflow reservation can use up the cap and GPU-view tiles are then refused (zeros). The description states the trade-off, but no mirror or refusal counts from a 16-window run are given. Give these tiles their own budget or report the counts. 3. **The hooks' routing is still untested.** The new assertions call is_cpu_view_reservation and reserve_in_view_graphics directly on a local Uma. The routing inside VirtualAlloc (kernelx.rs ~1032 MEM_GRAPHICS reserve, ~1096 gpu_visible_fallback, where the Series S CPU view went wrong) and the VirtualFree dispatch (~1356) go through uma::get(), which has the 4-window layout in the suite, so no test reaches them. A test that drives VirtualAlloc/VirtualFree with a 16-window Uma would cover the path this push fixes. 4. **No title run of the 16-window layout at this head.** This push changes the 16-window routing that jsalzy's title run at 5c963d8f found wrong (the Series S 16 GiB CPU view in windows 12..15). The smoke blocks use the default 4-window layout, and Not tested says no 16-window title run was done on ebef2ce9. A lockhart run with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 showing the 0x400000000-byte CPU view as "GPU-visible, write-watched" (plain memory) would confirm the fix. 5. **Conflicts with open #3696 and #3517, and no issue link.** A test merge with #3696's head 73a68e2e conflicts in crates/xcl/src/gpu/uma.rs, because both use the windows after the six primary views. #3517, which is carried whole, is still open. The description still has no "Fixes #N" or "Part of #N". #### Nit 6. **WARP test prints its own SKIPPED line.** sparse.rs ~13728 prints eprintln!("SKIPPED ...") instead of calling gpu::recomp::runner::skip_test, so XCL_REQUIRE_GPU cannot turn a missing WARP device into a failure. Use skip_test and return. 7. **Looser view-span assertion in bind.rs.** bind.rs ~7860 changed assert_eq!(span.1, VIEW_WINDOWS * WINDOW) into view_wins >= VIEW_WINDOWS plus span == view_wins * WINDOW, which no longer pins how many view windows the test layout has. Assert the exact count (VIEW_WINDOWS plus the trailing windows of this layout). 8. **The trailing-pool limit does less than its comment says.** uma.rs ~535 rejects only size >= (hi - lo) * WINDOW, so a reservation one 64 KiB grain smaller can still take nearly the whole pool, while the doc comment says no single reservation can swallow all trailing windows. Now that CPU views are excluded by their flags, either reword the comment or set a real cap. The is_cpu_view_reservation check in VirtualAlloc (kernelx.rs ~1096) also repeats the one inside reserve_in_view_graphics (~1178). <details><summary>Checked and fine</summary> - The jsalzy Series S finding from the 5c963d8f merge-check is fixed: is_cpu_view_reservation (kernelx.rs ~218) matches MEM_RESERVE | MEM_64K_PAGES (0x20402000) with PAGE_READWRITE and no MEM_GRAPHICS or PAGE_GRAPHICS_* access, so that CPU view goes to reserve_watched + mirrors::reserved, as on main - The predicate excludes MEM_GRAPHICS, PAGE_GRAPHICS_* GPU-access protections, committed allocations and PAGE_NOACCESS GPU views, so real overflow graphics reservations still reach the trailing windows - The new kernelx assertion would fail at 5c963d8f: its 16 GiB CPU view fits in the 20 GiB trailing pool of the test's 1-coherent-window layout, and only the new flag check rejects it - Default 4-window layout: still a no-op by reading; the new check runs only before reserve_in_view_graphics, which returns None with no view windows, and CPU views take the same reserve_watched path as on main - The carried commit 0de987866 has the same patch as #3517's head 0b4283d1, and the PR merges cleanly onto main 078358a0 </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 61 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Kalmarv commented 2026-12-03 05:13:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T05:13:05Z.


Thanks @Foniass for the re-check and the 231 s world run.

One note on PR description showing red: the description itself passes main's scripts/pr_check.py --local (description ok) on ebef2ce9df61b39a70f479b486870e60c45bdd2b, and Build and test (Windows, no GPU) is green (47010321717). All pull_request_target workflows across the repository (PR checks, Auto triage, Testing feed, Discord mirror) are currently failing with startup_failure before running any step (e.g. run 47010323458), so the red status is repo-wide rather than a description check failure.

AI use: Antigravity (Gemini 4 Neon) checked the workflow runs and scripts/pr_check.py --local against main and drafted this note.

<!-- greyfinch-sync:ivall/xcl:comment:7368501635 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7368501635). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T05:13:05Z. --- Thanks @Foniass for the re-check and the 231 s world run. One note on `PR description` showing red: the description itself passes `main`'s `scripts/pr_check.py --local` (`description ok`) on `ebef2ce9df61b39a70f479b486870e60c45bdd2b`, and `Build and test (Windows, no GPU)` is green (`47010321717`). All `pull_request_target` workflows across the repository (`PR checks`, `Auto triage`, `Testing feed`, `Discord mirror`) are currently failing with `startup_failure` before running any step (e.g. run `47010323458`), so the red status is repo-wide rather than a description check failure. AI use: Antigravity (Gemini 4 Neon) checked the workflow runs and `scripts/pr_check.py --local` against `main` and drafted this note.
Foniass commented 2026-12-03 15:36:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:36:08Z.


merge-check
base: 078358a058
head: ebef2ce9df
merge: clean
build: ok
tests: 3014 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 5 medium, 3 nits (below)
performance: 60 s smoke run: 1669 → 1682 frames (100 % of main), peak commit 17577 → 17940 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 231 s there, 0 device removals, 0 crashes, 3 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: The PR places overflow MEM_GRAPHICS and GPU-visible fallback reservations in the trailing view windows of the 16-window layout. It carries #3517's commit unchanged, and this push (5c963d8f -> ebef2ce9) only adds mirrors::is_cpu_view_reservation and a trailing-pool size limit, fixing the Series S 16 GiB CPU view that jsalzy's title run caught. None of the seven findings from my 5c963d8f review are fixed at this head and all stay open, but none blocks merging.

Medium

  1. Carries #3517's switch-form cutoff. The carried commit 0de987866 is still the same patch as open #3517's head 0b4283d1. With 16 windows, uma.rs:48 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) moves the coherent window to window 4, which with_switch_fallback (4 root-UAV windows, 0..3) cannot reach, so a pipeline in the switch form reads zeros from coherent memory. It lands with this PR unless #3517 fixes it first.
  2. GPU-only tiles still share XCL_MIRROR_MB with the GPU view. sparse.rs did not change in this push. fill_later still gives video memory to uncommitted self-backed tiles (h == 0xFFFF) from the same XCL_MIRROR_MB cap (4096 MB by default) as the 24 GiB GPU view, so a whole-range ask on a multi-GiB overflow reservation can use up the cap and GPU-view tiles are then refused (zeros). The description states the trade-off, but no mirror or refusal counts from a 16-window run are given. Give these tiles their own budget or report the counts.
  3. The hooks' routing is still untested. The new assertions call is_cpu_view_reservation and reserve_in_view_graphics directly on a local Uma. The routing inside VirtualAlloc (kernelx.rs ~1032 MEM_GRAPHICS reserve, ~1096 gpu_visible_fallback, where the Series S CPU view went wrong) and the VirtualFree dispatch (~1356) go through uma::get(), which has the 4-window layout in the suite, so no test reaches them. A test that drives VirtualAlloc/VirtualFree with a 16-window Uma would cover the path this push fixes.
  4. No title run of the 16-window layout at this head. This push changes the 16-window routing that jsalzy's title run at 5c963d8f found wrong (the Series S 16 GiB CPU view in windows 12..15). The smoke blocks use the default 4-window layout, and Not tested says no 16-window title run was done on ebef2ce9. A lockhart run with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 showing the 0x400000000-byte CPU view as "GPU-visible, write-watched" (plain memory) would confirm the fix.
  5. Conflicts with open #3696 and #3517, and no issue link. A test merge with #3696's head 73a68e2e conflicts in crates/xcl/src/gpu/uma.rs, because both use the windows after the six primary views. #3517, which is carried whole, is still open. The description still has no "Fixes #N" or "Part of #N".

Nit

  1. WARP test prints its own SKIPPED line. sparse.rs ~13728 prints eprintln!("SKIPPED ...") instead of calling gpu::recomp:🏃:skip_test, so XCL_REQUIRE_GPU cannot turn a missing WARP device into a failure. Use skip_test and return.
  2. Looser view-span assertion in bind.rs. bind.rs ~7860 changed assert_eq!(span.1, VIEW_WINDOWS * WINDOW) into view_wins >= VIEW_WINDOWS plus span == view_wins * WINDOW, which no longer pins how many view windows the test layout has. Assert the exact count (VIEW_WINDOWS plus the trailing windows of this layout).
  3. The trailing-pool limit does less than its comment says. uma.rs ~535 rejects only size >= (hi - lo) * WINDOW, so a reservation one 64 KiB grain smaller can still take nearly the whole pool, while the doc comment says no single reservation can swallow all trailing windows. Now that CPU views are excluded by their flags, either reword the comment or set a real cap. The is_cpu_view_reservation check in VirtualAlloc (kernelx.rs ~1096) also repeats the one inside reserve_in_view_graphics (~1178).
Checked and fine
  • The jsalzy Series S finding from the 5c963d8f merge-check is fixed: is_cpu_view_reservation (kernelx.rs ~218) matches MEM_RESERVE | MEM_64K_PAGES (0x20402000) with PAGE_READWRITE and no MEM_GRAPHICS or PAGE_GRAPHICS_* access, so that CPU view goes to reserve_watched + mirrors::reserved, as on main
  • The predicate excludes MEM_GRAPHICS, PAGE_GRAPHICS_* GPU-access protections, committed allocations and PAGE_NOACCESS GPU views, so real overflow graphics reservations still reach the trailing windows
  • The new kernelx assertion would fail at 5c963d8f: its 16 GiB CPU view fits in the 20 GiB trailing pool of the test's 1-coherent-window layout, and only the new flag check rejects it
  • Default 4-window layout: still a no-op by reading; the new check runs only before reserve_in_view_graphics, which returns None with no view windows, and CPU views take the same reserve_watched path as on main
  • The carried commit 0de987866 has the same patch as #3517's head 0b4283d1, and the PR merges cleanly onto main 078358a0
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 61 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7383420673 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3653#issuecomment-7383420673). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:36:08Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: ebef2ce9df61b39a70f479b486870e60c45bdd2b merge: clean build: ok tests: 3014 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 5 medium, 3 nits (below) performance: 60 s smoke run: 1669 → 1682 frames (100 % of main), peak commit 17577 → 17940 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 231 s there, 0 device removals, 0 crashes, 3 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** The PR places overflow MEM_GRAPHICS and GPU-visible fallback reservations in the trailing view windows of the 16-window layout. It carries #3517's commit unchanged, and this push (5c963d8f -> ebef2ce9) only adds mirrors::is_cpu_view_reservation and a trailing-pool size limit, fixing the Series S 16 GiB CPU view that jsalzy's title run caught. None of the seven findings from my 5c963d8f review are fixed at this head and all stay open, but none blocks merging. #### Medium 1. **Carries #3517's switch-form cutoff.** The carried commit 0de987866 is still the same patch as open #3517's head 0b4283d1. With 16 windows, uma.rs:48 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4) moves the coherent window to window 4, which with_switch_fallback (4 root-UAV windows, 0..3) cannot reach, so a pipeline in the switch form reads zeros from coherent memory. It lands with this PR unless #3517 fixes it first. 2. **GPU-only tiles still share XCL_MIRROR_MB with the GPU view.** sparse.rs did not change in this push. fill_later still gives video memory to uncommitted self-backed tiles (h == 0xFFFF) from the same XCL_MIRROR_MB cap (4096 MB by default) as the 24 GiB GPU view, so a whole-range ask on a multi-GiB overflow reservation can use up the cap and GPU-view tiles are then refused (zeros). The description states the trade-off, but no mirror or refusal counts from a 16-window run are given. Give these tiles their own budget or report the counts. 3. **The hooks' routing is still untested.** The new assertions call is_cpu_view_reservation and reserve_in_view_graphics directly on a local Uma. The routing inside VirtualAlloc (kernelx.rs ~1032 MEM_GRAPHICS reserve, ~1096 gpu_visible_fallback, where the Series S CPU view went wrong) and the VirtualFree dispatch (~1356) go through uma::get(), which has the 4-window layout in the suite, so no test reaches them. A test that drives VirtualAlloc/VirtualFree with a 16-window Uma would cover the path this push fixes. 4. **No title run of the 16-window layout at this head.** This push changes the 16-window routing that jsalzy's title run at 5c963d8f found wrong (the Series S 16 GiB CPU view in windows 12..15). The smoke blocks use the default 4-window layout, and Not tested says no 16-window title run was done on ebef2ce9. A lockhart run with XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 showing the 0x400000000-byte CPU view as "GPU-visible, write-watched" (plain memory) would confirm the fix. 5. **Conflicts with open #3696 and #3517, and no issue link.** A test merge with #3696's head 73a68e2e conflicts in crates/xcl/src/gpu/uma.rs, because both use the windows after the six primary views. #3517, which is carried whole, is still open. The description still has no "Fixes #N" or "Part of #N". #### Nit 6. **WARP test prints its own SKIPPED line.** sparse.rs ~13728 prints eprintln!("SKIPPED ...") instead of calling gpu::recomp::runner::skip_test, so XCL_REQUIRE_GPU cannot turn a missing WARP device into a failure. Use skip_test and return. 7. **Looser view-span assertion in bind.rs.** bind.rs ~7860 changed assert_eq!(span.1, VIEW_WINDOWS * WINDOW) into view_wins >= VIEW_WINDOWS plus span == view_wins * WINDOW, which no longer pins how many view windows the test layout has. Assert the exact count (VIEW_WINDOWS plus the trailing windows of this layout). 8. **The trailing-pool limit does less than its comment says.** uma.rs ~535 rejects only size >= (hi - lo) * WINDOW, so a reservation one 64 KiB grain smaller can still take nearly the whole pool, while the doc comment says no single reservation can swallow all trailing windows. Now that CPU views are excluded by their flags, either reword the comment or set a real cap. The is_cpu_view_reservation check in VirtualAlloc (kernelx.rs ~1096) also repeats the one inside reserve_in_view_graphics (~1178). <details><summary>Checked and fine</summary> - The jsalzy Series S finding from the 5c963d8f merge-check is fixed: is_cpu_view_reservation (kernelx.rs ~218) matches MEM_RESERVE | MEM_64K_PAGES (0x20402000) with PAGE_READWRITE and no MEM_GRAPHICS or PAGE_GRAPHICS_* access, so that CPU view goes to reserve_watched + mirrors::reserved, as on main - The predicate excludes MEM_GRAPHICS, PAGE_GRAPHICS_* GPU-access protections, committed allocations and PAGE_NOACCESS GPU views, so real overflow graphics reservations still reach the trailing windows - The new kernelx assertion would fail at 5c963d8f: its 16 GiB CPU view fits in the 20 GiB trailing pool of the test's 1-coherent-window layout, and only the new flag check rejects it - Default 4-window layout: still a no-op by reading; the new check runs only before reserve_in_view_graphics, which returns None with no view windows, and CPU views take the same reserve_watched path as on main - The carried commit 0de987866 has the same patch as #3517's head 0b4283d1, and the PR merges cleanly onto main 078358a0 </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 61 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3653:upstream-pr/3653'
git switch 'upstream-pr/3653'

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/3653'
git switch 'upstream-pr/3653'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3653'
git switch 'upstream-pr/3653'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3653'
git switch 'main'
git merge --squash 'upstream-pr/3653'
git switch 'main'
git merge --ff-only 'upstream-pr/3653'
git switch 'main'
git merge 'upstream-pr/3653'
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
xcl-dev/xcl!3653
No description provided.