Repository navigation
Conversation
|
Diff review (head Nice design on the trailing
Testing note: the default 4-window AI use: Antigravity (Gemini 4 Neon) audited the full diff against |
|
Review (head a74a58b, diff read, not a merge-check):
Fine: on the default 4-window layout this is a no-op by reading. There are no View windows, so AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
The 16-window layout (XCL_UMA_WINDOWS=16) now reserves 4 sparse VRAM windows instead of 3: 4 sparse + 1 coherent + 6 view windows still fit in 16, and the 4th window was one of the 5 it left empty, so it costs no address space. The 4- and 8-window layouts keep 3. A retail title's BVH builder works in a 3.39 GB MEM_RESERVE | MEM_64K_PAGES reservation made once windows 1..2 are taken. With 3 sparse windows it found no room and became plain write-watched memory, which shaders read as zeros, so every acceleration structure stayed empty (xcl-dev#505). With 4 it lands in window 3, where the GPU sees it. XCL_SPARSE_WINDOWS=<n> (1..=8) overrides the count for any layout (README). A coherent plan in the 16-window layout now gets at most 6 windows instead of 7. Tests: the setting's parse, clamp and per-layout default and the layout accounting for 1..=8 sparse windows; the 16-window layout's windows; the 3.39 GB reservation landing in window 3 (fails on main, where it gets no room). Existing layout tests follow the new window indices; the GPU test of the 4-root-UAV program skips when the coherent window is not window 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a74a58b to
1de2334
Compare
|
Thanks @Decodere and @Foniass for the thorough reviews — rebased onto
Verified on AI use: Antigravity (Gemini 4 Neon) implemented these fixes, ran the checks, and drafted this reply. |
|
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 AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source and drafted this note. Claude Code (Claude Fable 5.2) independently checked it. |
|
Thanks @pvfreis — good catch, noted. Right now AI use: Antigravity (Gemini 4 Neon) checked |
|
Linux / AMD RDNA4 (RADV, Wine + vkd3d-proton): full test suite on Merged onto Setup
Tested:
About the failures on
|
|
merge-check AI-written and posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 1de2334d: 6 finding(s) (1 high, 5 medium), most severe first.
- High
crates/xcl/src/gpu/uma.rs:48: With 16 windows,SIXTEEN_WINDOW_SPARSE_WINDOWS = 4moves the coherent window (the title's GPU heaps) from window 3 to window 4, which a pipeline rebuilt in switch form bywith_switch_fallback(MAX_WINDOWS = 4, root UAVs 0..3) can't r.... (inline) - 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) - Medium
crates/xcl/src/hle/kernelx.rs:1020: MEM_GRAPHICS overflow reservations now go throughreserve_in_view_graphics, which callsmirrors::reservedwith MEM_COMMIT stripped, so a MEM_GRAPHICS reservation of 64 KiB pages is recorded as an unpaired CPU view (the old plain fall.... (inline) - Medium
crates/xcl/src/hle/d3d12x/title_textures.rs:176:in_view_windownow depends on the changing GRAPHICS_RESERVATIONS map, solink_srcandunlink_srccan get different answers for the same texture source and thecoarserefcount goes wrong. (inline) - Medium
crates/xcl/src/hle/kernelx.rs:1285: On MEM_RELEASE of a self-backed graphics reservation,free_in_viewusessparse::source_decommitand callsforget_mirrorsonly afterwards, outside the freeing span, which is the gapsparse::source_releaseexists to close. (inline) - 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-submitfill_pagesbudget, 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.
| /// 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; |
There was a problem hiding this comment.
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.
| // 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) { |
There was a problem hiding this comment.
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.
| 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) { |
There was a problem hiding this comment.
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.
| /// (`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) |
There was a problem hiding this comment.
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.
| 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)) |
There was a problem hiding this comment.
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.
| 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)); |
There was a problem hiding this comment.
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.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
…dows In the 16-window UMA layout (4 sparse + 1..2 coherent + 6 primary GPU-view = 11..12 windows), the trailing 4..5 windows (16..20 GiB) stayed unused WindowKind::None while overflow MEM_GRAPHICS and GPU-visible fallback reservations fell out to plain Windows memory outside UMA. Shaders drop reads and writes past xcl_w >= 16, leaving GPU-side buffers in those overflow reservations unreadable. - Reserve trailing 16-window view windows past the 6 primary GPU-view windows as MEM_RESERVE | MEM_WRITE_WATCH (PAGE_READWRITE) via Uma::view_reserve_graphics, keeping the 6 primary GPU-view windows isolated for 24 GiB GPU views. - Route overflow MEM_GRAPHICS and non-GPU-view fallback reservations in kernelx into those trailing view windows, tracking them in GRAPHICS_RESERVATIONS and keeping them write-watched in title_textures. - Clean up GRAPHICS_RESERVATIONS, mirror pairings, title physical-page mappings (forget_title_mappings), and sparse mirrors before calling u.view_release(a) on VirtualFree(MEM_RELEASE) so a recycled address cannot race with cleanup. - Let sparse map both committed CPU tiles and uncommitted/lazy GPU-only tiles (h == 0xFFFF when self-backed) for self-backed graphics reservations, forget asks on self-backed tile decommit (and re-queue linked unmapped self-backed tiles on re-ask or VirtualAlloc MEM_COMMIT) so GPU-only tiles regain video memory after decommit. - Add CPU and WARP-only unit tests covering trailing graphics view windows (commit + GetWriteWatch), kernelx reserve/commit/decommit/release/reuse lifecycle, and self-backed committed/uncommitted tile mapping and post-decommit remapping. Assisted-by: Antigravity (Gemini 4 Neon)
1de2334 to
5c963d8
Compare
|
Thanks @bmjask for the thorough review (and @Prime1997 for taking a look). Fixed all five medium findings from
Also addressed @Foniass's minor cleanup notes ( Verified on AI use: Antigravity (Gemini 4 Neon) implemented the fixes and tests, ran the build/test/smoke checks, and drafted this reply. |
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 windows11..16= 20 GiB with 1 coherent window) remained unusedWindowKind::Nonewhile overflowMEM_GRAPHICSand GPU-visible fallback reservations fell out to plain Windows memory outside UMA. Translated shaders drop reads and writes pastxcl_w >= 16, leaving GPU-side buffers in those overflow reservations unreadable.Notes on scope and trade-offs:
MEM_GRAPHICS/ GPU-visible fallback reservations that spill past the sparse and coherent windows.XCL_MIRROR_MBbudget: Self-backed tiles mapped in trailing view windows (including uncommitted GPU-only tiles,h == 0xFFFF, charged fullPAGES_PER_TILEagainstfill_later's per-submit page budget) draw video memory from the sameXCL_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 untilXCL_MIRROR_MBis raised or budgeted separately.#3517switch-fallback window-4 cutoff: Moving 16-window coherent memory from window 3 to window 4 (SIXTEEN_WINDOW_SPARSE_WINDOWS = 4in Memory: the 16-window layout keeps 4 runtime sparse windows #3517) leaves#156with_switch_fallback(MAX_WINDOWS = 4, root UAVs0..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 Memory: the 16-window layout keeps 4 runtime sparse windows #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 asMEM_RESERVE | MEM_WRITE_WATCH(PAGE_READWRITE) and addUma::view_reserve_graphicsandUma::graphics_view_windows. Keep the 6 primary GPU-view windows (VIEW_WINDOWS) isolated for 24 GiB GPU views and reject 24 GiB CPU views from the trailing windows.crates/xcl/src/hle/kernelx.rs: Route overflowMEM_GRAPHICSand non-GPU-viewgpu_visible_fallbackreservations into the trailing write-watched view windows viareserve_in_view_graphicswithout registeringMEM_GRAPHICSreservations as unpaired CPU views inmirrors; bound view-windowVirtualAlloc(MEM_COMMIT)ranges againstu.view_reservation(a)(failing out-of-bounds or released ranges withERROR_INVALID_ADDRESS); notifysparse::source_committedon self-backed graphics commits (commit_in_view_graphics); and onVirtualFree(MEM_RELEASE)of a self-backed graphics reservation (free_in_view), runsparse::source_release(removingGRAPHICS_RESERVATIONSand unpairingmirrorsinside its freeing span beforeforget_mirrors) and clean up title mappings beforeu.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 intitle_textureswrite-watch tracking (recordingTable::coarsemembership per resource atlink_srctime sounlink_srcstays balanced if the reservation is released first); resolvetile_showsto the tile's own CPU address whenin_graphics_reservationis true; allowState::fill_laterto map uncommitted/lazy GPU-only tiles (h == 0xFFFFwhen self-backed) while charging fullPAGES_PER_TILEagainst 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) orVirtualAlloc(MEM_COMMIT)(source_committed_in).VirtualAlloccommit +GetWriteWatch),kernelxreserve_in_view_graphics(including non-registration ofMEM_GRAPHICS | MEM_64K_PAGESinmirrors) andview_graphics_free_decommit_release_and_reuse(bounds/post-releaseERROR_INVALID_ADDRESS,MEM_DECOMMIT/ re-commit /MEM_RELEASE/AWAY.titlecleanup / address reuse),title_texturescoarse_refcount_stays_balanced_after_graphics_reservation_release, and WARPself_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warpcovering committed/uncommitted mapping, post-decommit remapping, andPAGES_PER_TILEfill_laterbudget charging.Tested
rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5.cargo build --release -p xcl: succeeded with 39 warnings (0 new vsorigin/main5eaadb54c).reserve_in_view_graphics_places_and_tracks_fallback_reservations,view_graphics_free_decommit_release_and_reuse,coarse_refcount_stays_balanced_after_graphics_reservation_release,self_backed_graphics_reservation_maps_committed_and_uncommitted_tiles_on_warp,graphics_view_windows_cover_reservations_and_support_commit_and_write_watch): 5 passed, 0 failed, 0 ignored, 0 skipped..\scripts\test.ps1(workspace build, bench--test, andcargo test --workspace -- --test-threads=4with DXC 1.9): 2982 passed, 0 failed, 52 ignored, 24 SKIPPED GPU tests (22no wave64on RTX 5070 Ti, 2no heap windows).Regression run
Base (
origin/main):PR (
5c963d8fe94168b1e5ff1855ce09978300c6c9b5):Not tested
scripts/smoke.ps1runs with defaultXCL_UMA_WINDOWS=4(XCL_HEAP_WINDOWSunset), 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 was re-run on5c963d8fe; coverage of the updated commit comes from the CPU and WARP unit tests.scripts/test.ps1runs withoutXCL_HEAP_WINDOWS=1(2 heap-window GPU tests skipped in the full suite).XCL_MIRROR_MBpressure or concurrent decommit/release churn on trailing graphics view reservations.AI use
origin/main(5eaadb54c), addressed the @Decodere, @Foniass, and @bmjask review findings, added unit tests, ran the release build, test suite, and 60 s smoke runs, and updated this PR description.