D3D12.X: sparse tiles outside the GPU heaps can live in system memory #2987
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!2987
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2987"
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?
@treybertram06 on GitHub · 2026-11-27 07:35 UTC · original
treybertram06:nv-sparse-sysmem→nvidia-dev· +130 −5 · 2 files · 1 commits · openTarget:
nvidia-dev. Part of #2688. Related: gefydev's planned budget-triggered L0 sparse pools (#2688), and #1702 (texture pages in system memory).With
XCL_COHERENT_HEAPS=sparsethe title's GPU heaps live in the sparse windows instead of the coherent window. These heaps are committed memory with aPAGE_GRAPHICS_*protection, about 4.5 GB in a retail title. Shaders read and write them every frame. In the coherent window (system RAM, read over PCIe), one retail compute program took 1,364 ms per frame on an RTX 3080; with the heaps in video memory it falls under 33 ms (XCL_GPU_TIMES). An RTX 4080 report on #2688 found the same factor. But with the heaps in video memory, the sparse windows hold about 7.5 GB of tiles. On a 10 GB card the device runs out of budget: 19 GB in use against 8.9 GB, removed at 659 s.XCL_SPARSE_SYSMEM=1(off by default) keeps the GPU heaps' tiles in video memory and puts every other sparse-window tile in system memory:sparse::alloc_as) before its commit maps its tiles;MEMORY_POOL_L0, write-back), which the GPU reads over PCIe.gefydev's plan moves new pools past the budget. This one decides by what a range holds, so the heaps the shaders depend on are never the ones moved.
What is in it
D3D12.X: sparse tiles outside the GPU heaps can live in system memory(hle/d3d12x/sparse.rs,hle/kernelx.rs):note_hot/is_hot/alloc_asmark the hot ranges;SysPools, pool index tagged withSYS) with their own free and cooling lists;pool_heapresolves either kind.the_title_gpu_heaps_are_hot_and_nothing_around_them.Tested
xcl.exe(#2590). Debug tests, release title runs.cargo test --workspace --no-fail-fast -- --test-threads=4, withXCL_DXC_DIRset to DXC 1.9, at this PR's head6c5904f9: 1822 passed, 11 failed, 48 ignored.nvidia-deva5e2d851without this change (the same list as in #2975).SKIPPED: theno wave64tests, plus one that needsXCL_HEAP_WINDOWS=1.cargo test -p xcl --lib the_title_gpu_heaps_are_hot: 1 passed.XCL_COHERENT_HEAPS=sparse XCL_SPARSE_SYSMEM=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PREPARE_WORKERS=6, scripted presses. Over the 400 s after the menus: 0.72 presents/s, video memory 15.1 GB local / 5.0 GB non-local (budget 9.2 GB), commit 41.5 GB, no device removal.XCL_GPU_TIMESwith the heaps in the coherent window: the top programcs 10eaefe801508781took 1,364 ms per frame. With them in video memory, the top program is under 70 ms.Regression run
Base, a commit of
main:b49be183, the lastmaincommit before #2555's launch preparation gate, which takes hours with this title on this card. The switch is off in both runs.This PR's head:
Not tested
XCL_COHERENT_HEAPS=sparseisn't onamd-dev. A 16 GB RDNA3 card stays under its budget anyway (oni-swr on #2688).0x887a0006, at 48 s and 202 s); the cause is not known. Runs without these switches also lose it on this title (#2688).AI use
@thehollowedone on GitHub · 2026-11-27 07:56 UTC · original
Independent RTX 3080 Ti check of
6c5904f9: withXCL_SPARSE_SYSMEM=1, the eager path places a cold control tile in the system-memory pool, but a lazy cold tile receives a default video-memory pool tile at its first CPU write. The lazy materialization path callstake_tile()directly, bypassing the cold/hot choice inensure_mapped. This undercuts the VRAM saving whenXCL_SPARSE_LAZY=1is used.I extended the existing synthetic lazy first-write test to first verify L0 support with an eager control tile and then assert the lazy tile's pool class. On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC, I set
XCL_SPARSE_SYSMEM=1andXCL_REQUIRE_GPU=1and rancargo test --offline --locked -j 4 -p xcl --lib a_lazy_tile_gets_memory_at_its_first_bytes_and_keeps_them -- --nocapture --test-threads=1. It failed on the PR head (0 passed, 1 failed, 0 ignored, no GPU skip; lazy pool class was video). Sharing the selection intake_tile_for(t)made the same test pass (1 passed, 0 failed, 0 ignored, no GPU skip), including its existing 64-KiB GPU readback. This is a local candidate, not a committed change or a full title validation.Candidate fix and focused regression diff
The broader policy still needs the lazy path's
at_hand/low-memory decision to consider ready system-pool tiles, plus reservation-lifetime handling when an address changes between hot and cold. Those cases were not exercised by this focused test. No game files were used. AI use: Codex (GPT-6.2 Sol) ran the red/green GPU test and wrote the local candidate; Codex (GPT-6.2 Astra) reviewed the sparse allocation paths.@3L1A5-1 on GitHub · 2026-11-27 08:05 UTC · original
8 GB VRAM / 16 GB RAM data point with
XCL_SPARSE_SYSMEM=1alone (no hot heaps, which an 8 GB card can't hold): local video memory is cut from ~4.1 GB to ~1.1 GB over budget, and it stays under budget until title ~180 s. The cost is system memory, roughly one-for-one, and on 16 GB the run still ends on host memory. One run with the switch. The comparison is against single runs of the same stack without it, and the local over-budget peak was stable at +3.7 to +4.5 GB across 8 runs of this base with and without the other PRs.Tested
nvidia-deve0821b12+ #2817 (a2c10b4a) + #2921 (8b57c36e) + #2898 (8cf249e5) + this PR (6c5904f9). This PR and #2898 conflict insparse.rs(FreePools), which I resolved locally, so a rebase will be needed if #2898 lands first. Baseline: the same stack without this PR (ona5e2d851).XCL_SPARSE_SYSMEM=1(noXCL_COHERENT_HEAPS=sparse).Results
XCL_SPARSE_SYSMEM=1no system-memory pool heapwarnings. The end time difference is within the 340–440 s spread I see between single runs of this stack, so I'm not reading a gain or loss from it.Not tested: repeats,
XCL_COHERENT_HEAPS=sparse(no room in 8 GB), 32 GB RAM, AMD.AI use: build, run and log analysis by Claude Code agents (Claude Sonnet 5.5), report written and checked against the run logs by Claude Code (Claude Opus 5.5).
@SzczepanGrela on GitHub · 2026-11-27 08:06 UTC · original
RX 9070 / Wine: an eager sparse-window system-memory readback works in a focused native GPU fixture at
6c5904f9426ffdfd4772399c92bfa84ddf29f6e2. Both copies and a wave64 compute shader preserve the expected contents through the mixed pool mapping.Tested
RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1, Ryzen 7 7700, CachyOS 7.3.0-5, GE-Proton11-12 / Wine 11.0 Staging, vkd3d-proton
8293130ebe370b1+with local asserts-disabled build, DXC/DXIL 1.9.2602.17, Rust 1.97.1 Windows-GNU release. Explicit adapter, network off, private enabled caches. Owned tests were appended to source copies; production functions and original assertions were unchanged.Compared the exact head with its actual parent
a5e2d851a503fc0e04609f773ea53f2d2c4e3269; the targetnvidia-devhad advanced toe0821b12.cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run, then the resulting PE under Wine:hle::d3d12x::sparse::tests::the_title_gpu_heaps_are_hot_and_nothing_around_them --exact --nocapture --test-threads=1and=4: 1 passed, 0 failed each.hle::d3d12x::sparse::workflow_sysmem_native::workflow_cold_system_tiles_and_hot_video_tiles_read_back --exact --nocapture --test-threads=1: three fresh full processes per source/switch combination, plus one pilot each.XCL_SPARSE_SYSMEM=0and=1were tested in separate processes. Each harness passed; zero ignored or skipped tests.The fixture maps eagerly through
ensure_mapped, withXCL_SPARSE_LAZYunset. It uses a 16-tile reserved buffer, with 6 tiles marked hot and 10 cold. It calls productionnew_state,ensure_mapped,flush_pendingandupload_dirty, registering hot ranges directly throughnote_hoton head.These are actual pool tags and native
ID3D12Heap::GetDescresults. All cold tiles in the enabled head used the system-pool path; no fallback to DEFAULT was counted as coverage.Every window word was checked after CPU upload, after partial native GPU writes with untouched regions retained, and after an owned wave64 shader loaded, transformed and stored every word through the same window. A separate width buffer verified lane count 64 and its 15 untouched guards.
Independent Python verification checked all 10,223,872 readback words, including 39 MiB of window payload, across 64 native readbacks and 16 wave64 dispatches. Data, guards and shader containers match across sources, switches and fresh repeats. No device removal occurred.
Not tested
Lazy first-write materialization, including the bypass already reported here, the full kernelx
VirtualAlloc/alloc_ascaller, hot-range free/reuse lifecycle, title workload, smoke, full suite, native Windows, physical residency, budget reduction or performance. Heap properties and GPU data correctness do not establish those measurements. Main83b00818was not integrated or built: the three-way file application conflicts insparse.rsandkernelx.rs; no manual repairs were made.AI use
OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the public change, wrote and ran the fixture and independent verifier, and drafted this report. Publication authorized by the account owner.
@thehollowedone on GitHub · 2026-11-27 08:16 UTC · original
New, separate finding on #2987 head
6c5904f9, following my earlier lazy-placement report: a cold tile can be decommitted intoparked, then immediately recommitted at the same address after that address becomes a title GPU heap.ensure_mappedtakes the parked tuple before checkingis_hot, so the new hot heap inherits system-memory backing. This is distinct from the lazy first-write path.I added a synthetic one-tile GPU regression that commits cold, flushes the mapping, verifies the SYS pool bit, decommits, calls
note_hotfor the same address, and recommits. On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC, withXCL_SPARSE_SYSMEM=1andXCL_REQUIRE_GPU=1,cargo test --offline --locked -j 4 -p xcl --lib a_parked_cold_tile_does_not_back_a_new_hot_heap -- --nocapture --test-threads=1failed on the PR head (0 passed, 1 failed, 0 ignored, no GPU skip; pool index retained the SYS bit). The candidate below passed the same test (1 passed, 0 failed, 0 ignored, no GPU skip).The candidate acquires a video-memory replacement before touching the parked mapping, then unmaps and quarantines the old tile behind the existing queue fences. It leaves pinned tiles on their existing backing so placed-buffer aliases remain intact. It is a focused local candidate, not a full proof of safe retirement under every queue schedule; the author should review and extend the pinned/blocked-queue tests before merging.
Candidate correction and regression diff
Separate test-coverage note: with
XCL_SPARSE_SYSMEM=1, the broaderparkedfilter still has two existing failures because those tests expect released tiles in the video-memorys.coolingqueue. The candidate does not change them. With the feature unset, that filter completed 6 passed, 0 failed, with the new SYS-only case reporting a skip; those six passes are not six SYS-mode coverage cases.No game files or title executable were used. AI use: Codex (GPT-6.2 Sol) wrote and ran the red/green test and candidate; Codex (GPT-6.2 Astra) checked the mapping and fence sequence.
@Decodere on GitHub · 2026-11-27 08:29 UTC · original
Independent desktop NVIDIA verification of PR #2987 at head
6c5904f9426ffdfd4772399c92bfa84ddf29f6e2(1commit; exact parent & merge-base:a5e2d851a503fc0e04609f773ea53f2d2c4e3269onnvidia-dev).Environment
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted release tests & build (
6c5904f9)cargo test --release -p xcl --lib -- hle::d3d12x::sparse::tests::the_title_gpu_heaps_are_hot_and_nothing_around_them --exact --nocapture(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1727 filtered out× 3 (0.00s× 3,0skipped)cargo test --release -p xcl --lib -- hle::d3d12x::sparse:: --test-threads=1 --nocapture(3 consecutive runs)67 passed; 0 failed; 1 ignored; 1660 filtered out× 3 (5.20s,4.74s,4.98s,0skipped;1#[ignore]:early_commit_timing)cargo test --release -p xcl --lib -- hle::kernelx:: --test-threads=1 --nocapture(3 consecutive runs)61 passed; 0 failed; 1 ignored; 1666 filtered out× 3 (1.25s,1.25s,1.26s,0skipped;1#[ignore]:scatter_timing)cargo build --release -p xcl2m 16s, exit0,0new warnings insparse.rs/kernelx.rs; pre-existingrbq_valuewarning unchanged froma5e2d851)Paired quiet 60 s retail smokes (
title: 29640639,XCL_PREPARE=0 XCL_NETWORK=0)Exact parent & merge-base (
a5e2d851a503fc0e04609f773ea53f2d2c4e3269,XCL_PREPARE=0 XCL_NETWORK=0):PR #2987 default (
6c5904f9426ffdfd4772399c92bfa84ddf29f6e2,XCL_SPARSE_SYSMEMunset,XCL_PREPARE=0 XCL_NETWORK=0):PR #2987 opt-in (
6c5904f9426ffdfd4772399c92bfa84ddf29f6e2,XCL_SPARSE_SYSMEM=1,XCL_PREPARE=0 XCL_NETWORK=0):Runtime memory & sparse-pool telemetry (
xcl.logsteady-state ~48–58 s)a5e2d851(default)6115 MB4741 MB896 MB(838 MBmapped)14755 MB0.17–0.18 msXCL_SPARSE_SYSMEMunset)6116 MB4782 MB896 MB(838 MBmapped)14740 MB0.18–0.19 msXCL_SPARSE_SYSMEM=1)5218 MB(-898 MB/-14.7%)5597 MB(+815 MB)0 MB(0 MBmapped)14637 MB0.15–0.16 msUnder
XCL_SPARSE_SYSMEM=1, the runtime log confirmed activation (sparse windows: XCL_SPARSE_SYSMEM=1 - tiles outside the title's GPU heaps in system memory) and system-memory pool heap growth (64 -> 128 -> 256 -> 512 MBlogged at power-of-two checkpoints), keeping VRAM sparse pools at0 MBand reducing RTX 4060 local VRAM usage by898 MBwith0device removals and0crashes.Limits of coverage
note_hot/is_hotrange boundary predicate (the_title_gpu_heaps_are_hot_and_nothing_around_them3/3),hle::d3d12x::sparse::(67/0/1× 3),hle::kernelx::(61/0/1× 3), default-off non-regression, and liveXCL_SPARSE_SYSMEM=1L0 pool routing (-898 MBlocal VRAM) on RTX 4060 (8 GB).XCL_SPARSE_SYSMEM=1alone (withoutXCL_COHERENT_HEAPS=sparse); did not run a combinedXCL_COHERENT_HEAPS=sparse+XCL_SPARSE_SYSMEM=1multi-minute post-menu world-load stress test.XCL_PREPARE=0(XCL_NETWORK=0), bypassing startupprepare_for_launch, and the 2#[ignore]timing tests (early_commit_timing,scatter_timing) were not executed.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
@thehollowedone on GitHub · 2026-11-27 12:04 UTC · original
The Windows no-GPU CI run for head
6c5904f9exits with D3D12 device removal0x887a0020on Microsoft Basic Render Driver. Its last allocation is a 3 GiB GPU-view alias. In this test module,a_gpu_view_tile_is_filled_from_its_cpu_view_and_follows_its_writesis the path that requests exactly 3 GiB whensoftware(&test_device())returns false; its software path requests 53 tiles. The abort suppresses the test name, so this is a source/log correlation, not a definitive harness attribution.software()currently returns false when factory creation, adapter lookup, orGetDesc1fails. For this test's allocation decision, an unknown adapter should use the bounded software case. The candidate below does that while preserving the large case when a known hardware adapter reports no software flag. Microsoft documents the Basic Render Driver's software flag.On Windows 11 build 26300, RTX 3080 Ti / driver 621.35, the new
unknown_adapter_uses_the_small_gpu_view_caseregression failed 0/1/0 before the policy change and passed 1/0/0 afterward. WithXCL_TEST_WARP=1,cargo test --offline --locked -p xcl --lib a_gpu_view_tile_is_filled_from_its_cpu_view_and_follows_its_writes -- --nocapture --test-threads=1passed 1/0/0, no skip, and logged a 0x350000-byte GPU view. That WARP test also passed on the unchanged PR head here; I could not reproduce the runner's failed adapter classification locally. The full suite and CI on this candidate are untested. Rerunning the same CI job after the author integrates the small guard would decide whether it resolves this crash.Candidate test-only diff
AI use: Codex (GPT-6.2 Sol) traced the CI and source, wrote the candidate, and ran the focused tests.
@LocranKing on GitHub · 2026-11-27 12:20 UTC · original
Tested PR #2987 (
6c5904f9) on Windows 11 with a Series S (lockhart) profile, including a paired A/B 240 s open-world comparison withXCL_SPARSE_SYSMEM=1vs unset and the unit test.Environment
GPU_UPLOADsupported, driver32.0.16.2140)nvidia-devDXIL cache (XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PREPARE_GRAPHICS=0,XCL_DRED=1),XCL_COHERENT_HEAPS=sparsefor both PR runsUnit test
cargo test --locked -p xcl --lib -- the_title_gpu_heaps_are_hot --nocaptureon6c5904f9:hle::d3d12x::sparse::tests::the_title_gpu_heaps_are_hot_and_nothing_around_them— ok (1 passed, 0 failed)Paired A/B 240 s World Runs (
XCL_COHERENT_HEAPS=sparse, RTX 3060 Ti 8 GB)PresentX)180 s, default heaps)a5e2d8510x00 / 01861151.36 s25770 MB8974 MB4677 MB3880 MB2560 MB(2393 MBmapped)240 s, default heaps)a5e2d8510xc0000005(188.46 s)2 / 0126.29 s25909 MB9351 MB4768 MB3864 MB2624 MB(2423 MBmapped)#2987unset (240 s)6c5904f9,XCL_COHERENT_HEAPS=sparse0x00 / 01999(0 1 3last 3/2s)138.55 s31745 MB13121 MB2019 MB4380 MB5568 MB(5344 MBmapped)#2987+XCL_SPARSE_SYSMEM=1(240 s)6c5904f9,XCL_COHERENT_HEAPS=sparse,XCL_SPARSE_SYSMEM=10x00 / 01896(1 2 2last 3/2s)120.65 s31726 MB10560 MB4915 MB4518 MB2944 MB(2892 MBmapped)Summary
240 sruns underXCL_COHERENT_HEAPS=sparsereached the world cleanly and exited0x0with0device removals and0crashes on this 8 GB card.XCL_SPARSE_SYSMEM=1loggedsparse windows: XCL_SPARSE_SYSMEM=1 - tiles outside the title's GPU heaps in system memoryand reduced peak local VRAM by2,561 MB(13,121 MB->10,560 MB), shifting~2.6 GBof sparse pool allocations (5,568 MB->2,944 MBlocal; non-local2,019 MB->4,915 MB) into system memory while keeping the hot GPU heaps in local VRAM.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.