Memory windows from the descriptor heap (no per-access switch); NVIDIA OOM fallback; physical-page fixes #187
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!187
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/187/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@RemingtonWilcox on GitHub · 2026-11-23 19:34 UTC · original
memory-windows-redesign→main· +1348 −25 · 14 files · 6 commits · closed without mergingWhat the PR is now:
ResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + w)]instead of the per-accessswitchover root UAVs.XCL_HEAP_WINDOWS=0turns it off. The raw views are 2^30 − 1 dwords, so a sparse window's last 64 KiB tile is reachable; only the window's last dword is not.SetDescriptorHeaps(0, NULL)clears the record, so the shared heap is bound again before the next translated draw.0x8007000E, the program is translated again in the switch form and built from that, before the stand-in. Tested by injecting the refusal through the PSO hook, then dispatching and checking the output.FreeTitlePhysicalPageskeepsAWAYheld while it releases homes (plain homes areMEM_RELEASEd, so a concurrent map/read/write could touch released memory), and a page freed from a block that lives on gives its lazy home back at once. Tests included.Full suite green on an RTX 3090 (driver 616.92). Not run against a retail title after the rebase.
Earlier versions of this PR also moved physical-page homes out of GPU address space; that part is dropped in favour of main's
38b05b7design (see the comment thread).🤖 Generated with Claude Code
@TheHoracio on GitHub · 2026-11-23 19:39 UTC · original
AMD run of the two tests you asked about. This is not the RX 9070: it is RDNA3 Radeon RX 7800 XT (16 GB, native 64-lane waves,
amdxc64), driver 32.0.32015.7029, Windows 11 Pro 10.0.26300, Rust 1.100.0x86_64-pc-windows-msvc, DXC 1.9.2602.17, debug build, PR head8c0346d.cargo test -p xcl --lib:XCL_SPLIT_WAVE64=1XCL_HEAP_WINDOWS=0(gpu::tests)gpu_memory_windows_from_the_heapandgpu_raw_window_view_reaches_its_toppass in all three runs, natively at 64 lanes and split. No driver crash, no TDR or device removal.gpu_wave64_ps_whole_wave_reductions. It fails the same way onmain956a476on RDNA2/RDNA3 and is fixed by #155. It is unrelated to this PR.@MiguelMachado-dev on GitHub · 2026-11-23 20:00 UTC · original
I tested
8c0346don a GeForce RTX 5080 (driver 32.0.16.2124), Core i7-14700KF, Windows 11 Pro build 26300, Rust 1.97.1 MSVC, DXC 1.8.2502.11 (Windows SDK 10.0.26100.0), debug profile.gpu_memory_windows_above_4_gib,gpu_memory_windows_from_the_heap, andgpu_raw_window_view_reaches_its_topall passed.cargo test --locked -p xcl --lib -- --test-threads=4reported 541 passes, 0 failures and 21 ignored. Two GPU tests reportedSKIPPEDfor requiring hardware wave64 and are included in the pass count. The optional game sample variables were unset.e2_window_compile_timewithXCL_E2_BLOCKS=250andXCL_E2_REPS=3used a synthetic compute shader of about 7,000 instructions. Median DXC time was 2.55 s with one window, 21.56 s with four windows using the switch, and 2.78 s with four windows from the descriptor heap. The DXC samples for the two four-window paths were [18.49, 21.56, 25.08] s and [2.70, 2.78, 2.78] s, respectively.The measurements cover the synthetic cases on this setup. AI-assisted with Codex.
@gw1337x on GitHub · 2026-11-23 20:19 UTC · original
Setup: AMD Radeon RX 7800 XT (RDNA3, 16 GB), driver 32.0.32015.7029, 32 GB RAM, Windows 11 Pro 26200, GTA VI retail,
XCL_NETWORK=0, release build.Test branch:
main956a476+ #170 (incl. #163 @634c423) + #162 @641f551+ #168 @070a737+xg.rsof #169 + #176 + #164.Tested 8c0346d merged onto the branch above (clean merge, release build), two runs: cold and warm cache. Both runs: 0 presents, no DXC compiles, private commit flat at 18 GB from ~1 s on, then the game's watchdog at 31.5 s (
+0x2215c35, write at 0).The thread dump shows a game thread inside XCL for those 30 s:
It looks like page mapping became quadratic: a
retainover a list for every page mapped. Also logged at 0.4 s:Without #187 the same branch presents from ~3 s. Debug info: release build with
line-tables-only.🤖 Generated with Claude Code
@mastrr9 on GitHub · 2026-11-23 20:27 UTC · original
Independent Windows + RTX 5080 GPU verification of
8c0346da2(merge-base956a476bf) on NVIDIA GeForce RTX 5080 (Blackwell desktop, driver617.42, D3D12 SM 6.6 + mesh shaders, 32-wide waves, Windows 11, Ryzen 7 9800X3D, Rust1.100.0, DXC1.9.2602.17, noXCL_SAMPLE_*, no game files):Build & Tests
cargo build --workspace && cargo test --workspace -- --test-threads=4: 574 passed, 0 failed, 41 ignored (git diff --checkclean; 2 expectedno wave64skips).gpu_memory_windows_from_the_heap,gpu_aperture_structured_rows_above_4_gib,gpu_raw_window_view_reaches_its_top,gpu_aperture_probe_where_it_wraps,a_6_gib_reservation_fits_once_page_homes_take_no_window_space, andphysical_pages_have_cpu_homes_and_map_into_the_windows.Code review note (edge case)
shared_heapslot reservation (0..MAX_WINDOWS),set_window_viewsfallback to window 0, andemit.rsclamping (xcl_w < windows ? xcl_w : 0u) beforeResourceDescriptorHeap[NonUniformResourceIndex(...)]all look solid.list_x.rs::ensure_view_heap()/console_list.rs:ensure_view_heap()checksif b.heaps.is_empty()(andconsole_list.rssetsheaps_set = true). If a command list callsSetDescriptorHeaps(1, &[sampler_heap])with only a sampler heap (no CBV/SRV/UAV heap),heapsis non-empty, soglobal_heap()won't be bound—leavingResourceDescriptorHeap[MEM_HEAP_BASE + w]unbound on draw/dispatch. Tracking whether a CBV/SRV/UAV heap is bound (rather thanheaps.is_empty()) would close that case cleanly.(AI-assisted)
@Kalmarv on GitHub · 2026-11-23 20:29 UTC · original
AI-assisted review (Claude Code). Windows 11 (10.0.26200), Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Rust 1.99.0 MSVC, debug profile. Synthetic memory only, no game files.
Tested
8c0346d(3 commits directly onmain956a476, so the PR head is the merge result).GPU (5070 Ti):
gpu_memory_windows_from_the_heap,gpu_memory_windows_above_4_gibandgpu_raw_window_view_reaches_its_toppass (no skips). I did not run the full suite; the 5080 runs above cover that.Negative control for the homes change. I carried the behavioural assertions of
physical_pages_have_cpu_homes_and_map_into_the_windowsontomain, keeping only the lines that compile there (noAUTO_MAPPED/PhysPagesfields):main: failsa home takes no GPU address space. The home is0x420010000, inside UMA, andMapTitlePhysicalPages(NULL, 3, …)returns the home itself.On gw1337x's 30 s stall (
unmap_away → sparse::decommitted → Vec::retain). This cost is insparse.rsand predates this PR. The PR only routes the retail reservation onto it.Before the sparse state exists (no device yet):
sparse::committedappends one(addr, len)per mapped page toEARLY;sparse::decommitteddoesEARLY.retain(..), a scan of the whole list, once per page moved away.So remapping N pages that sit in a sparse range costs O(N²).
To show this I used a CPU-only probe (no D3D12 device). It allocates N pages, maps them consecutively, remaps them in reverse order with
XMemMapPhysicalPagesScatter, then unmaps them. It runs the same calls into a plainVirtualAllocreservation and into asparse_reserverange. The kernelx code is identical for both targets, so the difference between them is onlycommitted/decommitted. One run each, in ms:mainin every row.mainthe retail title's reservation was plain Windows memory, so it never took this path. With this PR it lands in the sparse windows. At about 100,000 pages, a quadratic term that is already 1.2–2.5 s at 16k would plausibly take tens of seconds, past the 30 s watchdog. That is an estimate, not measured.to_zero.retainindecommit_tilesis the otherVec<(usize, usize)>::retainto look at.EARLYkeyed by address (aBTreeMapof ranges, merging neighbours), sodecommittedbefore the device is O(log n), not O(n).Also seen, but not attributed: the reverse remap is slow on plain memory as well, on both sides (16k pages: 7–9 s). One candidate is
unmap_away'saway.gone.retain(|&h| Some(h) != page_home(page)), which callspage_home(a lock and aBTreeMaplookup) for each of up to 4,096 entries per page. I haven't measured that.Not tested: the retail title, the full suite on this GPU, AMD, Wine, and the timing with a D3D12 device present (sparse state set up).
I'll open a separate small PR that keys
EARLYby address so the pre-devicedecommittedis O(log n), with this probe as its test, unless someone is already on it.@srcamarda on GitHub · 2026-11-23 20:54 UTC · original
Found the cause of the stall @gw1337x reported (game thread stuck in
XMemMapPhysicalPagesScatter → … → sparse::decommitted → Vec::retain). Reproduced on RDNA3: RX 7800 XT, driver 32.0.32029.2010, Windows 11 26300, PR head8c0346d, release build, retail title withXCL_NETWORK=0,XCL_RUN_SECONDS=60, cold shader cache:8c0346d+0x2215c35, write at 0)8c0346d+ the patch belowmain)XCL_RUN_SECONDS, exit 0At the watchdog, the thread dump has a title thread running in XCL. Symbolized with the build's PDB:
Vec<(usize, usize)>::retaininsparse::decommit_tiles←sparse::decommitted←kernelx::XMemMapPhysicalPagesScatter.Two quadratic pieces, both needed
to_zero.retainat every tile unmap. The scatter mapping's pattern is: unmap a page (a whole 64 KiB tile goes, soretainruns over all ofto_zero), then map one (a reused tile queues a whole-tile clear).to_zeroonly drains at the nextbefore_execute, so it grows by one entry per page, and every unmap walks all of it.FxHasher::finishreturnsk * Cunchanged. Keys ofmappedare tile addresses (multiples of 64 KiB), so the low 16 bits of every hash are zero. hashbrown takes the bucket from the low bits, so past 64 K entries every lookup walks one long probe chain. That includes themapped.contains_keyinside theretainclosure, and themappedlookups on the submit path (before_execute).Synthetic measurement, 100 000 map / unmap steps (
many_tile_unmaps_stay_linear, debug build):retain, fixed hasher: 84 sThe patch (
sparse.rsonly)ZeroList:to_zerokept per tile. Unmapping a tile drops its entries in O(1) (forget_tile). This is exactly what theretainremoved: onlydecommit_tilesremoves tiles frommapped, and every entry is pushed for a tile that is mapped at that point. The drains get the same ranges, sorted by address (the order doesn't matter to the clears).FxHasher::finish→rotate_left(26), as rustc-hash 2 does.EARLY(commits before the device exists) had the same shape: a push per commit and aretainper decommit. It is now a set of disjoint ranges (RangeSet, merges on insert, cuts on remove). One behaviour change: decommitting a page out of a larger early commit now keeps the rest of that commit. Before, the whole entry was dropped, so those pages were never mapped once the device came up. Not hit in this run (the stall was theto_zeroone); happy to drop this part if you'd rather keep the PR minimal.many_tile_unmaps_stay_linear,early_commits_stay_linear,range_set_merges_and_cuts;decommit_sub_tile_reclaims_pool_tile_when_all_pages_become_holesadapted toZeroList.cargo test -p xcl --lib: 543 passed, 1 failed (gpu_wave64_ps_whole_wave_reductions, the 32-lane PS case on RDNA2/3, fixed by #155). Patch below.Not checked: the rendered image (the run only got as far as cold-cache loading), NVIDIA, and a warm-cache run.
Patch against
8c0346d(git apply)@Kalmarv on GitHub · 2026-11-23 21:07 UTC · original
Linux / Turing run of
8c0346don its own base956a476. That's the head before the four commits pushed at 21:02 (now603f546); the heap-window path these numbers cover is the same, and I'll rerun on the rebased head. It doesn't merge onto currentmaineaa36b6: 10 conflicting hunks inhle/kernelx.rs, where main's coherent-heapVirtualAllocbranch and its physical-page home rework (PHYS_BLOCKS,lazy_home, sparse decommit) meet this PR'sPhysPages/AUTO_MAPPED/ sparse-reserve changes. A rebase ontoeaa36b6is needed (as asked on #198), and the numbers below should be rerun afterwards. Ubuntu 24.04, RTX 2060 (Turing, 32-lane waves), NVIDIA 595.91.07, Wine 11.21 Staging (wow64), vkd3d-protonmaster30b0eb9 (relaxed as in #175), DXVK 3.1.1dxgi; cross-built forx86_64-pc-windows-gnu, release.This stack has the known zero-read gap: Wine without
userfaultfdwrite watches, so the imported UMA heap falls back to a copy of its own (#175). So I ran the PR twice: as is, and withMEM_WRITE_WATCH= 0 ingpu/uma.rs(an experiment that makes the import work here).gpu::recompfilter,--test-threads=1:main956a476(the base)8c0346d8c0346d,MEM_WRITE_WATCH= 0(
maineaa36b6for reference: 166 passed / 5 failed / 18 ignored, the same 5.)gpu_memory_windows_above_4_gib,gpu_unified_memory_arena,gpu_mesh_mode_reads_memory_windows,gpu_bvh64_…andgpu_sparse_vram_descriptors_buffers_and_xmem.gpu_memory_windows_from_the_heapfails as is ("s_load from window 1", left(0, 0), right(12648430, 4660)), with the same signature as the others. With the import working it passes, along with 4 of the 5 old ones.ResourceDescriptorHeap[NonUniformResourceIndex(...)]) reads correctly through vkd3d-proton / dxil-spirv on Turing. Its failure here is the import gap, not this PR.gpu_raw_window_view_reaches_its_top,gpu_aperture_structured_rows_above_4_gibandgpu_aperture_probe_where_it_wrapspass in both builds.e1b_raw_views_under_debug_layerande2_window_compile_timeare ignored.gpu_sparse_vram_descriptors_buffers_and_xmemstill fails with the import working, as onmain: a second, separate cause on this stack (#175).hle::kernelxtests: 13 passed, 1 failed at both the base and the PR. The failure is the known Wine error-code difference,get_proc_address_and_load_library_ex_reject_null_name.physical_pages_have_cpu_homes_and_map_into_the_windowspasses.Not covered: the rebased PR; AMD; the DXC timing (
e2);XCL_HEAP_WINDOWS=0;XCL_SPARSE_RESERVE_MB; any title.AI-assisted test report (Claude); tests run locally as stated.
@Kalmarv on GitHub · 2026-11-23 21:15 UTC · original
Driver and GPU timings for the heap form next to the switch and #174's linked form, on an RTX 5070 Ti. In short: on an access-dense compute program the heap form brings the driver's compile back to what one window costs, and it does not cost GPU time.
Driver compile. A synthetic split-wave64 compute program with a load and a store of title memory every round and an exec-masked block every 4 rounds. Each row is 2 programs the driver had never seen, created from one thread:
main)tasklistsamples of 11.8–12.1 GB).GPU time. #174's
bench_memory_window_accessorswith a heap form added, 1600 accesses, GPU timestamps around a dispatch of 2048 groups, 2 rounds:The
0x8007000Erefusal from #156 does not reproduce here with hand-written HLSL. I tried n distinct dynamically indexed raw UAVs fromResourceDescriptorHeap, with loops, atomics andgloballycoherent: compute with n up to 2048 and pixel with n up to 4096 all build. This card is on driver 610.74 and the report was on 616.92, so this narrows nothing down beyond "not the handle count alone on 610.74".Two notes on the code:
emit.rs::mem_accessors. Keeping #174'smem_methods()split and putting this PR's heap branch at the top ofmem_accessors(windows, heap)resolves it (linked_formthen callsmem_accessors(w, None)).linked_formfinds no switch accessors in a heap program, so such a program is compiled whole once, and #174 then only serves programs in the switch form, including the ones603f546rebuilds.603f546, not run):with_switch_fallbackwraps the D3D12.X pipeline hooks, whilexcl shaders --precompile --pipelines(shaders.rs) counts a refused pipeline and goes on. A program the driver refuses in the heap form would then still pay its switch-form driver compile at its first bind in the title.Offer: I can add differential GPU tests on top of this PR: each existing multi-window test program (
gpu_memory_windows_above_4_gib, the 4-window compute one, mesh mode, the other arena tests) run in the switch form and in the heap form, with registers and memory compared bit for bit. Today only one program runs in both forms. Tell me whether you would rather have that as a PR against your branch or after this lands.Tested
main956a476+ this PR at8c0346d+ #174 at328cf29, merged locally, plus local ignored benches (not pushed).XCL_BENCH_MEMORY_EVERY=1 XCL_BENCH_WAVE64=1 XCL_BENCH_BRANCH_EVERY=4, one process per row, 14 GiB commit cap.Not tested
8c0346d(4eae211,c014788,375fc07,603f546): read, not built or run.AI use: Claude Code, Claude Fable 5.2.
@TheFrenchPepeAI on GitHub · 2026-11-23 21:16 UTC · original
Data point from an RTX 4090 / Windows 10 machine: #187 brings back the null write that #169 clears.
956a476+ #1690x80000003at+0x344196(PS pipelines)956a476+ #187 alone0xc0000005write at 0x0 at+0x2215c35956a476+ #169 + #187+0x2215c35null writeSo on this machine #187 lands earlier than #169 alone, and adding #169 on top does not recover it — the subresource layout from #169 is presumably computed against a window #187 has moved out of the GPU reservation. Both runs use
anaconda,title_memory = auto,XCL_NETWORK=0; a partial precompile cache (22 800 of 26 503 programs) is in place, so this is not a shader-compilation artefact.@Kalmarv on GitHub · 2026-11-23 21:38 UTC · original
On the null write @TheFrenchPepeAI reports above: in compute on NVIDIA, the heap form and the switch form give the same results, including through the views
open_umamakes. So that crash isn't explained by the two forms computing different values. Two commits onc74b03ayou can take if they're useful; neither changes any program's HLSL:1562dd7, tests only (recomp/tests.rs, +311 / −3). It adds two tests that run one program in both forms and compare all SGPRs, all VGPRs and the first 64 KiB of every window:gpu_window_forms_agree_on_every_access_kindcovers every accessor kind (scalar loads, bounds-checked scalar buffer loads, buffer loads and stores including sub-dword, global stores, 32- and 64-bit atomics) over four windows.gpu_runtime_windows_agree_in_both_formsuses the runtime layout: sparse windows 0..2, coherent window 3, and V#s loaded from a console descriptor heap in title memory.The mesh and BVH window tests also run in the heap form.
9263711, precompile (shaders.rs, +78 / −10).xcl shaders --precompile --pipelinesdidn't make the switch form of a pipeline the driver refuses withE_OUTOFMEMORY, so that program's DXC and driver compiles were still paid at its first bind. It now does whatwith_switch_fallbackdoes, under the same cache keys. Its test injects the refusals, because 610.74 refused none of my programs.Controls
gpu_runtime_windows_agree_in_both_formsfails. None of the PR's existing tests reads through the viewsopen_umamakes, so none of them would catch a wrong view.Tested
c74b03amerged ontomain0cd0a53.Not tested
E_OUTOFMEMORYrefusal.c74b03aalone: type-checked only.🤖 Claude Fable 5.2, Claude Opus 5.5
@srcamarda on GitHub · 2026-11-23 22:15 UTC · original
Follow-up to my comment above, on the current head
c74b03a: the startup hang is gone, and nothing from my patch is needed any more.mainas #230 (rotate_right(23)), and theEARLYpart as68a6640(merged page ranges).to_zeropart (per-tile list instead ofretainat every unmap) still applies. With it the run below is the same within run-to-run noise (934 / 1116 frames vs 877 / 1101), so this title no longer reaches that path hard enough to matter. I'm not proposing it here.Regression run (
scripts/smoke.ps1, 90 s, the retail title,XCL_NETWORK=0), RX 7800 XT (RDNA3, driver 32.0.32029.2010), Ryzen 5 5600G, 32 GB, Windows 11 26300, release build.c74b03amerged ontomain(clean merge; the PR conflicts with nothing in my tree).Two runs each: the first with a cold translation cache, since each binary has its own, and the second warm. The
gpu:line names a virtual display adapter on this machine, but XCL ran on the RX 7800 XT.main(9ab7d76):(cold run: 1129 frames, peak 17169 MB)
main+c74b03a:(cold run: 877 frames, peak 17229 MB; the heap form recompiles every translated shader once)
main's frames. Both sit at ~12 presents/s on the account prompt.@shelbykb2 on GitHub · 2026-11-23 22:20 UTC · original
RDNA2 result for the two tests asked about: AMD Radeon RX 6800 (16 GB), driver 32.0.21045.29003, Windows 11, Rust 1.100.0, release, head
c74b03a.cargo test --release -p xcl --lib -- --test-threads=1 gpu_memory_windows_from_the_heap gpu_raw_window_view_reaches_its_top: 2 passed, 0 failed, no SKIPPED.8c0346d(on main956a476+ #170) the startup stall reported above reproduced on this card as well: no present, and the title's watchdog fired at 32.0 s. Not rerun on a title atc74b03a.Report written with Claude Code, from our own runs.
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175Pull request closed