Repository navigation
UMA: support 8/16 heap windows (5/13 coherent) with 3-sparse (12 GiB) cap - #1998
Conversation
…nd sparse GPU-view mirrors
…ts while keeping 5/13 coherent windows
|
Verified expanded-window GPU access at One coverage trap: Tested — native Windows 10 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust 1.98.1 MSVC, DXC 1.8.2502.11, debug. Exact head plus the test-only patch below; no runtime changes in positive runs. Common environment:
Zero skips in all three runs. All 311 source-file hashes matched before/after, with XCL rebuilt at each source switch. The negative control changes only Not tested — full workspace suite, retail smoke/gameplay, runtime sparse/coherent allocation and mirror cleanup, multi-GiB memory pressure, graphics stages, AMD, or performance improvement. These results establish the high-window access path, not that this PR resolves world loading or reduces total memory. #822 remains relevant overlapping layout work; this is complementary test coverage for the current author-owned PR, not another implementation. AI use — Codex (GPT-6) reviewed the paths, adapted the test with provenance, ran native tests and prepared this report. Test-only patch (26 additions, 8 deletions)diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index e1f73ef..bae2c2b 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -3237,23 +3237,32 @@ fn gpu_mesh_mode_reads_memory_windows() {
/// accesses in window 0.
#[test]
fn gpu_memory_windows_above_4_gib() {
- memory_windows_above_4_gib(false);
+ memory_windows_above_4_gib(2, false);
}
/// The same program with the windows taken from the descriptor heap (`Options::heap_windows`):
/// same results, and no `switch` over windows in the HLSL.
#[test]
fn gpu_memory_windows_from_the_heap() {
- memory_windows_above_4_gib(true);
+ memory_windows_above_4_gib(2, true);
}
-fn memory_windows_above_4_gib(heap: bool) {
+// Adapted from XCL PR #822, e9705bb (GPL-2.0-only):
+// https://github.com/xcl-dev/xcl/pull/822. Also check 8 windows and explicit Direct DXIL.
+#[test]
+fn gpu_memory_windows_beyond_the_root_uavs() {
+ for windows in [8, 16] {
+ memory_windows_above_4_gib(windows, true);
+ }
+}
+
+fn memory_windows_above_4_gib(windows: usize, heap: bool) {
if !gpu_ready() {
return;
}
- let arena = crate::gpu::uma::Uma::with_windows(2, 1 << 20).unwrap();
- let (w0, w1) = (arena.window(0).0 as u64, arena.window(1).0 as u64);
- assert_eq!(w1 - w0, 1 << 32);
+ let arena = crate::gpu::uma::Uma::with_windows(windows, 1 << 20).unwrap();
+ let (w0, w1) = (arena.window(0).0 as u64, arena.window(windows - 1).0 as u64);
+ assert_eq!(w1 - w0, ((windows - 1) as u64) << 32);
let word = |a: u64| unsafe { &mut *(a as *mut u32) };
*word(w1 + 0x1000) = 0xC0FFEE;
*word(w1 + 0x1004) = 0x1234;
@@ -3278,12 +3287,20 @@ fn memory_windows_above_4_gib(heap: bool) {
let p = prog(&refs);
let one = translate(&p, &Options::default()).unwrap();
assert!(!one.hlsl.contains("mem1") && !one.hlsl.contains("xcl_w =") && !one.hlsl.contains("xcl_m"), "one window: the single-window HLSL");
- let t = translate(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() })).unwrap();
+ let t = translate(&p, &on_gpu(Options { mem_windows: windows as u32, heap_windows: heap, ..Default::default() })).unwrap();
assert!(t.hlsl.contains("RWByteAddressBuffer mem1 : register(u3)"));
assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap, "heap windows: no switch over windows");
assert_eq!(t.hlsl.contains("ResourceDescriptorHeap[NonUniformResourceIndex(0u + xcl_w)]"), heap);
let hlsl_dxil = || super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap();
- let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil());
+ let dxil = if windows > 4 && runner::direct_dxil() {
+ // direct_or intentionally falls back above four windows: do not count that as DXIL coverage.
+ crate::gpu::dxil::kernel::translate(&p, crate::gpu::dxil::kernel::KernelOptions {
+ wave64: true, split: runner::split_wave64(),
+ mem_windows: windows as u32 | super::HEAP_WINDOWS, sampler_base: 0,
+ }).expect("expanded direct DXIL")
+ } else {
+ direct_or(&p, &on_gpu(Options { mem_windows: windows as u32, heap_windows: heap, ..Default::default() }), hlsl_dxil())
+ };
let hi = |a: u64| (a >> 32) as u32;
let mut st = KernelState::default();
st.sgpr[2..4].copy_from_slice(&[(w1 + 0x1000) as u32, hi(w1)]);
@@ -3312,6 +3329,7 @@ fn memory_windows_above_4_gib(heap: bool) {
}
assert_eq!(*word(w1 + 0x6000), 64, "global_atomic_add in window 1");
assert_eq!(*word(w0 + 0x6000), 0, "nothing in window 0 at the same low address");
+ println!("{windows} windows, target {}, direct={}: scalar/buffer/global loads, stores and atomic output correct", windows - 1, runner::direct_dxil());
}
/// Out-of-UMA addresses must NEVER alias onto live UMA windows via `& 3`: |
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Regression run for this PR: head main this PR: No device removals or crashes; 101 % of main's frames, 98 % of its peak commit. Not tested: the whole suite; world loading; whether the title reaches all of the changed code in these 60 s (default settings: Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
Thanks @Anon64 for running and sharing the 60 s |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
…them With heap windows (XCL_HEAP_WINDOWS=1) each memory access was guarded by `[branch] if (xcl_w >= windows)`. The guard gives every access two paths, and DXC's GVN can join their descriptor handles into a `phi` of `%dx.types.Handle`; NVIDIA refused such programs with E_OUTOFMEMORY in under a second (xcl-dev#756). Nothing in the form prevented it. Now the index is clamped instead: `min(xcl_w, 16)` with all heap windows in use, or a `select` with fewer, into ResourceDescriptorHeap. Slot MEM_HEAP_NULL = MEM_HEAP_BASE + MAX_HEAP_WINDOWS, after the window views, holds a null raw UAV: it reads 0 and drops stores and atomics, which is what the switch's `default` does. One path per access, so no handle `phi` can form. The shared heap's own allocations start after it. Heap views also need D3D12_OPTIONS11's AtomicInt64OnDescriptorHeapResourceSupported, for the 64-bit atomics on the windows; a device without it gets no views, and the shaders keep the switch over the root UAVs (window_views_failed). Rebased onto main with xcl-dev#1992 and xcl-dev#1998 (16 heap windows, expanded-window checks) by WebIdentity1's integration: the null view at MEM_HEAP_BASE + MAX_HEAP_WINDOWS rather than + MAX_WINDOWS, which would clamp valid higher windows; the window tests cover 4 / 8 / 16 layouts. Co-authored-by: WebIdentity1 <212448219+WebIdentity1@users.noreply.github.com>
Adds multi-coherent 8- and 16-window UMA layouts (
XCL_HEAP_WINDOWS=1withXCL_UMA_WINDOWS=8|16), while capping runtime sparse VRAM windows at 3 (12 GiB) so expanded layouts keep 5 or 13 committed coherent windows (max_coherent_windows), alongside sparse 64 KiB GPU-view mirror cleanup on release.Part of #1833.
What is in it
crates/xcl/src/gpu/uma.rs: addMAX_HEAP_WINDOWS = 16, multi-coherent pool sizing (max_coherent_windows,max_coherent_bytes,coherent_window_sizes), 3-window (12 GiB) sparse cap on runtime 8/16-window layouts, anduma::tests(runtime_layout_supports_eight_and_sixteen_heap_windows,expanded_runtime_layout_splits_large_coherent_heaps_across_multiple_windows).crates/xcl/src/gpu/dxil/kernel.rs,crates/xcl/src/gpu/recomp/emit.rs,mod.rs,runner.rs: shader translation & DXIL validation support for expanded heap-window layouts (expanded_heap_window_shaders_translate_and_validate).crates/xcl/src/hle/d3d12x/console_heap.rs&real.rs: expanded descriptor heap/window view registration.crates/xcl/src/hle/kernelx.rs: register and clean up sparse 64 KiB GPU-view mirrors (sparse_64k_reservation_registers_gpu_view_mirror_and_releases_cleanly).Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto6567c5f(06308bc).cargo check --workspace --tests: passed.cargo test -p xcl --lib runtime_layout_supports_eight_and_sixteen_heap_windows: 1 passed, 0 failed.cargo test -p xcl --lib expanded_heap_window_shaders_translate_and_validate: 1 passed, 0 failed.cargo test -p xcl --lib expanded_runtime_layout_splits_large_coherent_heaps_across_multiple_windows: 1 passed, 0 failed.cargo test -p xcl --lib sparse_64k_reservation_registers_gpu_view_mirror_and_releases_cleanly: 1 passed, 0 failed.06308bc:@WebIdentity1(NVIDIA RTX 3090, HLSL + Direct DXIL):3/0/0passed on 8- and 16-window tests (plus negative control2/1/0).@futurepro62(NVIDIA RTX 5070 Ti:990 passed, 0 failed, 43 ignored; AMD Radeon RDNA2 iGPU:1000 passed, 0 failed, 45 ignored), including all 4 new#1998tests.@Anon64(NVIDIA RTX 3060, 60 sscripts/smoke.ps1pair vsmain80f4819):1606vs1588frames (101%),0device removals,0crashes,24883MB vs25184MB peak commit (98%).Regression run
60 s
scripts/smoke.ps1pair on exact head06308bcvsmain80f4819(NVIDIA GeForce RTX 3060 12 GB, driver 581.80, Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s on a retail title), contributed by@Anon64:main
80f4819:this PR:
Not tested
AI use
6567c5f, and unit tests; the author reviewed the diff and test output.