Repository navigation
Memory: the 16-window layout keeps 4 runtime sparse windows - #3517
CharlyRien wants to merge 1 commit into
Conversation
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>
|
Focused follow-up on head I added the test-only regression below to a clean merge of this head onto For the intended four-sparse-window behavior, the fallback needs a path that can address both sparse window 3 and coherent window 4. Please carry the wider reach through translation, root signature and binding, and test a forced fallback that reads distinct nonzero sentinels from both in one dispatch. Keeping three sparse windows as the default until that path works would avoid introducing the gap while the wider fallback is developed. Test-only regression diffdiff --git a/crates/xcl/src/gpu/uma.rs b/crates/xcl/src/gpu/uma.rs
index 5d9df8ff..69ee1f26 100644
--- a/crates/xcl/src/gpu/uma.rs
+++ b/crates/xcl/src/gpu/uma.rs
@@ -1276,6 +1276,20 @@ pub fn get() -> Option<&'static Uma> {
mod tests {
use super::*;
+ #[test]
+ fn first_coherent_window_remains_reachable_by_switch_fallback() {
+ let u = Uma::for_runtime_windows(16 << 20, RUNTIME_COMMITTED_CAP, MAX_HEAP_WINDOWS)
+ .expect("16-window aperture");
+ let coherent = u.committed_window().expect("coherent window");
+ let reachable = crate::gpu::recomp::pso::in_switch_form(|| {
+ crate::gpu::recomp::pso::windows_for(u.shader_windows() as u32)
+ }) as usize;
+ assert!(
+ coherent < reachable,
+ "the switch fallback translates {reachable} windows but coherent memory starts in window {coherent}"
+ );
+ }
+
/// Arena blocks come from XCL's pool while the title holds the rest of window 0, and go
/// back to it when freed.
#[test]AI use: OpenAI Codex (GPT-6.2 Sol) wrote and ran the focused test and drafted this report; OpenAI Codex (GPT-6.2 Astra) reviewed the fallback design. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check claim |
|
No other open PR changes the number of sparse windows. #3521/#3522 also target XboxBvhBuilder memory, but under AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check claim withdrawn AI use: an agent posted this withdrawal. |
|
merge-check |
|
Diff review (head Clean layout math in
Minor note: AI use: Antigravity (Gemini 4 Neon) audited the full diff against |
|
I compared the production sparse allocator on main
Setting This identifies a case where the fourth sparse window preserves a reservation that main cannot satisfy. The fixture exercised the CPU allocator only. The separate question raised above about a fallback shader reaching coherent window 4 still needs GPU validation. OpenAI Codex GPT-6.2 Sol ran the test, a separate GPT-6.2 Sol agent repeated it, and GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 0b4283d1: 3 finding(s). 3 are 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.
| /// 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). |
There was a problem hiding this comment.
With 4 sparse windows, the 16-window layout's coherent window moves from window 3 to window 4, which pipelines in the switch form (4 root UAVs, windows 0..3 only) can't reach. With XCL_UMA_WINDOWS=16 and XCL_HEAP_WINDOWS=1 on NVIDIA, a big program that gets E_OUTOFMEMORY with heap windows is rebuilt in the switch form by real::with_switch_fallback (real.rs:5145-5158). The same happens to every pipeline when console_heap::window_views_failed() turns pso::heap_windows() off. Window 3 is now an empty sparse window, so per-draw arguments, readback buffers, spilled root tables and coherent-window GPU heaps read 0 in those pipelines, and their writes are dropped. The skip added to gpu_sparse_vram_descriptors_buffers_and_xmem ("4 root-UAV windows do not reach" window 4) shows the regression rather than testing it.
| /// layout's default). | ||
| fn sparse_windows_setting(v: Option<&str>, windows: usize) -> usize { | ||
| let default = if windows == MAX_HEAP_WINDOWS { SIXTEEN_WINDOW_SPARSE_WINDOWS } else { MAX_RUNTIME_SPARSE_WINDOWS }; | ||
| v.and_then(|v| v.trim().parse::<usize>().ok()).map_or(default, |n| n.clamp(1, 8)) |
There was a problem hiding this comment.
XCL_SPARSE_WINDOWS is clamped to 1..=8, so 7 or 8 sparse windows give the title 27.5+ GiB of sparse space, and its 24 GiB MEM_64K_PAGES CPU view then lands in sparse VRAM. With XCL_UMA_WINDOWS=16 (or 8) and XCL_SPARSE_WINDOWS=7, kernelx::VirtualAlloc sends the retail title's 24 GiB CPU-view reservation to sparse_reserve, which now finds room, so 24 GiB becomes tiled video memory, which the view windows were built to prevent (see the sparse_end doc). The upper bound has to depend on the layout (below 6 for 16 windows, similar for 8). Values outside it are clamped or ignored with no log line.
| windows.saturating_sub(MAX_RUNTIME_SPARSE_WINDOWS + view_windows(windows)).max(1) | ||
| windows.saturating_sub(sparse + view_windows(windows)).max(1) | ||
| } else { | ||
| 1 |
There was a problem hiding this comment.
Not certain about this one: the 16-window coherent cap drops from 7 to 6 windows, so stored coherent needs between ~24 and ~28 GB are now cut down. A title whose coherent_file holds a ~26 GB need (with enough commit) used to get 7 coherent windows. Now coherent_window_sizes stops at 6 x 4095 MB, and the GPU heaps past that leave the coherent window. note_coherent_need / settle_coherent_need also report the smaller cap.
|
merge-check Regression run (default layout, 60 s, standard presses, gamesave moved aside, one warm-up first) this merge (main 1c8b551 + head 0b4283d): AI-written (Claude Code, Claude Opus 5.5) and posted by Pipodi. |
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
The 16-window layout (
XCL_UMA_WINDOWS=16) now keeps 4 runtime sparse windows instead of 3. The 4- and 8-window layouts keep 3.XCL_SPARSE_WINDOWS=<n>(1 to 8) overrides the count for any layout.Why: a retail title's BVH builder works in a 3.39 GB
MEM_RESERVE | MEM_64K_PAGESreservation (0xd4920000bytes, protect0x2404), made once sparse windows 1..2 are taken. With 3 sparse windows it finds no room and becomes plain write-watched memory, which shaders read as zeros, so every acceleration structure the title builds stays empty. With 4 it lands in window 3, where the GPU sees it. The 16-window layout already leaves 5 of its windows empty (3 sparse + 1 coherent + 6 view), so the 4th sparse window costs no address space: 4 + 1 + 6 = 11 of 16.claudetools-gh found this and proposed the same
XCL_SPARSE_WINDOWSswitch on #505 (comment 7273597036): withmain's root-constant clamp82b7cb3eand a 4th sparse window, the title builds real BVHs without crashing and the room gets bounce light, on an RTX 5070 Ti. This PR is his switch with 4 as the 16-window default.mainalready has82b7cb3e(#1319), so this PR needs nothing else.Part of #505.
What is in it
One commit:
crates/xcl/src/gpu/uma.rs:SIXTEEN_WINDOW_SPARSE_WINDOWS = 4, next toMAX_RUNTIME_SPARSE_WINDOWS = 3(now the 4- and 8-window value);runtime_sparse_windows(windows):XCL_SPARSE_WINDOWS(parsed and clamped to 1..=8), else the layout's default. It replaces the constant at the only two places that bound the sparse windows:max_coherent_windows(throughmax_coherent_windows_for) andreserve_runtime;committed_window()/is_sparse_window()/is_view_window(). A coherent plan in the 16-window layout can now take 6 windows instead of 7.uma.rs):sparse_windows_setting_parses_clamps_and_fits_the_layout(parse, clamp, per-layout default; for 1..=8 sparse windows the 16-window layout still fits),sixteen_windows_keep_four_sparse_windows(the 16-window layout's windows, the whole aperture reserved, the write-watch regions),a_bvh_scratch_reservation_lands_in_the_fourth_sparse_window(with windows 1..2 taken, a0xd4920000reservation lands in window 3, and 6.09 GB more takes no other window). The last two use only APIsmainhas, and fail onmain, where the reservation gets no room;runtime_layout_supports_eight_and_sixteen_heap_windows,the_series_x_plan_is_pinned,sparse_alloc_above_keeps_window_0_for_the_title,sparse_reserve_keeps_single_window_reservations_inside_one_window,view_windows_hold_gpu_views,expanded_runtime_layout_splits_large_coherent_heaps_across_multiple_windows).crates/xcl/src/hle/d3d12x/console_heap.rs(test only):title_memory_holds_a_heap_only_in_window_0probes the coherent window and a view window at their new indices.crates/xcl/src/gpu/recomp/tests.rs(test only):gpu_sparse_vram_descriptors_buffers_and_xmemruns a 4-root-UAV program that expects the coherent window at window 3. WithXCL_UMA_WINDOWS=16that is now window 4, so the test skips there (SKIPPED …: the coherent window is not window 3);XCL_SPARSE_WINDOWS=3runs it with 16 windows. The default 4-window run is unchanged.README.md:XCL_SPARSE_WINDOWSin the switch list.+148 / −36 in 4 files; about 30 of them are runtime lines, the rest tests and docs.
Tested
Head
0b4283d1onmain9dfbe3ea. RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631; Rust 1.100.0, release.cargo check --release -p xcl --lib --bins --tests: 0 errors, no warning in the changed files.cargo test --release -p xcl --lib -- gpu::uma:: title_memory_holds_a_heap_only_in_window_0 gpu_sparse_vram_descriptors_buffers_and_xmem root_views_in_a_gpu_view_are_wanted_with_their_bytes d3d12x::real::gpu_view_tests:: a_gpu_view_buffer_reaches_the_pc_at_its_windows_address a_view_across_a_window_end_is_bound_up_to_it a_wait_on_a_gpu_view_reads_its_cpu_view physical_home expanded_heap_window --test-threads=1(XCL_REQUIRE_GPU=mesh): 35 passed, 0 failed, 0 ignored; SKIPPED: none. The two new layout tests fail withXCL_SPARSE_WINDOWS=3(main's layout): 0 passed, 2 failed.Not run: the whole suite (
cargo test --workspace).On the retail title, on our lab tree (not this PR's head), same binary, same shader cache, same switches except
XCL_SPARSE_WINDOWS(two runs with 4 windows, one with 3):64K pagesreservation0x1300000000), at 59.5 smain53e85fb1+ 42 of our commits (ports of D3D12.X: the depth plane of an R24G8 buffer has a twin, drawn into the plane before its DSV is bound #3089, D3D12.X: a placed sparse buffer can wait for its tiles until first use #2798 / D3D12.X: GPU-only buffers placed outside the memory windows live in them #2799 and the stencil part of D3D12.X: depth UAV twins on by default, stencil twins copied with the plane #3290; D3D12.X: a sampled texture in the memory of a written one of another format is copied from it (XCL_ALIAS_COPY=1) #3094; D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281) +82b7cb3echerry-picked + a lab version of this switch (uma.rsonly; default 3, so the A/B is the switch alone). Switches:XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_ALIAS_COPY=1 XCL_PLACE_RETIRE=0 XCL_DEPTH_UAV_TWIN=1 XCL_PAIR_PAGES=1 XCL_OUTSIDE_VIEW_USE=1 XCL_OUTSIDE_ONLY_BYTES=0x3200000,0x1900000 XCL_TWO_PASS_MB=2048 XCL_VIEW_REACH_MB=36 XCL_PREPARE=0 XCL_DRED=1 XCL_HUGE_PSO_CONCURRENCY=8 XCL_HUGE_PSO_WANTED_CONCURRENCY=8 XCL_PSO_WAIT_MS=5000 XCL_TRACE_MEM=5000.Regression run
Same machine as under Tested, same title, 60 s each, both through
maind52ff48'sscripts/smoke.ps1,XCL_PREPARE=0, the same scripted A presses (XCL_PRESS_A_AT), every otherXCL_*unset (so the default 4-window layout, which this PR does not change: see Not tested). Each run started from its own copy of the same shader cache, made by anothermaincommit, so cold for both. The head is onmain9dfbe3ea; themainrun is ofmaind52ff48(8 commits earlier): the check asks for a commit ofmain.maind52ff48:This PR's head
0b4283d1:Not tested
XCL_UMA_WINDOWS=16: the A/B above is on our lab tree, not on this head, and the regression runs use the default 4-window layout, which this PR does not touch.MEM_64K_PAGESreservations now fit in 16 GiB of sparse windows gets them in video memory, which is what the cap of 3 was there to avoid.acceleration structure at …: 0 nodes) said 0 nodes in both runs; claudetools-gh's GPU-side read-back on an RTX 5070 Ti shows real trees, and that the CPU-side walk does not see the GPU's writes.XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1; Windows 10 and Wine.AI use
AI use: the port of the switch, the new default, the tests, the A/B runs and their readings, and this description were done with Claude Code (Claude Opus 5.5), checked and posted by me. The switch itself is claudetools-gh's (#505).
🤖 Generated with Claude Code