D3D12.X: add opt-in XCL_SPARSE_VRAM_CAP_MB to overflow sparse pools to L0 system memory #3112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3112"
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?
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-28T08:44:32Z.
Adds an opt-in
XCL_SPARSE_VRAM_CAP_MB=<N>environment variable (unset by default: zero behavior change) that overflows sparse page-pool allocations pastNMiB of local video memory into L0 write-back system-memory heaps, and reports L0 sparse pools separately inmemory_report.rs.TL;DR — Before vs After
origin/amd-dev41aa60ce)93570fea,XCL_SPARSE_VRAM_CAP_MBunset)XCL_SPARSE_VRAM_CAP_MB=1024, RX 7800 XT report)1,654/15,902 MB(0crashes)1,645/15,818 MB(0crashes)2,236 MB/6,896 MB1,024 MB/5,784 MB(−1,112 MB local)"sparse pools in system memory"(uma_segment)What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:XCL_SPARSE_VRAM_CAP_MBparsing,pool_is_sysparallel tracking, heap-kind matching when recycling retired pools, L0 fallback to video memory onCreateHeapfailure, split local/L0memory_bytes_for, unit testsparse_vram_cap_parses_pool_counts, and GPU testsparse_vram_cap_overflows_to_l0_and_reports_separately.crates/xcl/src/hle/d3d12x/memory_report.rs: exposes"sparse pools in system memory"onuma_segment(non_local)(non-local on discrete GPUs, local on single-segment/UMA adapters).Tested
32.0.21045.29003), AMD Ryzen 7 5700X, Windows 11 x64,rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2,960 passed, 13 failed, 49 ignored. All 13 failures reproduce identically on cleanorigin/amd-dev41aa60ce(2,954 passed, 17 failed, 49 ignored: 3 pre-existing RDNA2 f32/NaN tests, 6 parallelsparse/title_texturesshared-global contention tests,test_title_runs_and_game_folder_is_untouched, andtwo_pass_driver_cache_e2e).SKIPPED(7): 4×f16_programs_on_the_gpu(unsupportedV_MUL_F16/V_PK_MUL_F16per-lane), 2× heap-window tests (XCL_HEAP_WINDOWS=1opt-in), 1×pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode not enabled).cargo test -p xcl --lib -- hle::d3d12x::sparse::tests::sparse_vram_cap hle::d3d12x::memory_report::tests --test-threads=1: all passed, 0 failed, 0 skipped.5ca76771: JJAutoCompare (12/12 env-parsing cases) and moombathepilot (RX 7800 XT 300 s run showing local sparse pools capped at1,024 MBvs2,236 MBbaseline, local VRAM5,784vs6,896 MB).Regression run
Base (
main, required bypr_check.py):Base (
origin/amd-devmerge base):PR head (
93570fea,XCL_SPARSE_VRAM_CAP_MBunset):Not tested
uma_segment(non_local)), and Wine.AI use
memory_report.rsto useuma_segment(non_local), ran the workspace GPU test suite and 60 s smoke, and updated this description.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T09:35:51Z.
Tested
Exact
5ca76771ad326f8df7f68731bd7fa8112883ef2aon theamd-devPR, Windows 11 x64 build 26200.9974, Ryzen 7 3800X, and Rust 1.100.1 MSVC. I reran the pinned standalone CPU harness after verifying thatTILE,POOL_TILES, andsparse_vram_cap_poolsmatched the Git source byte-for-byte. The harness used a print-only stand-in forxlog_info!.I ran
sparse_cap.exe --exact fresh_process_cap --nocapture --test-threads=1once per setting in 12 fresh processes with child-only environments. Each process returned the same result on its second call.XCL_SPARSE_VRAM_CAP_MBinvalid,-1,4.5None0,3Some(0)4,7Some(1)8Some(2)1024, space-padded" 1025 "Some(256)The process readbacks distinguished
Err(NotPresent)fromOk("")and showed both spaces in" 1025 ". 12 passed, 0 failed, 0 ignored, 0 runtime skips. Every native process exited 0 with zero tests filtered out.Not tested
Device or GPU behavior, heap allocation or fallback, tile mapping, VRAM accounting, production logging, performance, retail smoke, and the full suite.
AI use
T3 Code through the Codex harness (
gpt-6.2-sol) verified the source and executable, reran the cases, and wrote this report.Imported from ivall/xcl. Originally posted by moombathepilot on 2026-11-28T10:39:41Z.
RX 7800 XT comparison
I compared release builds of the latest
amd-dev(7c795f5eefa0661eaf3f9f696d0cba3a75ce9628) and this PR (5ca76771ad326f8df7f68731bd7fa8112883ef2a), whose parent is thatamd-devcommit. Both source trees were clean. Neither build included the local XG compatibility patch.Hardware: RX 7800 XT, AMD driver
32.0.32029.2010, Ryzen 7 5700X3D, 64 GiB RAM, Windows 11 build26300.9974. I used separate title-data folders and separate copies of the same starting warm DXIL cache. There was one run per revision.Common settings:
XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RT_GATE=miss XCL_PRESS_A_AT=20,24,30,45,60,90,120,150,180,210,240,270 XCL_RUN_SECONDS=300 XCL_PIPELINE_MAX_KB=1150 XCL_PSO_MAX_KB=1150 XCL_DRED=1 XCL_PREPARE=0 XCL_COHERENT_CAP_MB=2048 XCL_TEXTURE_LEVEL_PAGES=1. Each run also setXCL_DATA_ROOTandXCL_DXIL_CACHEto its own folder.XCL_SPARSE_VRAM_CAP_MBwas unset on the amd-dev baseline and1024on the PR. Both logs confirmed a 2,048 MB coherent window and the first scripted A press at 20.003 s.console code so far0xe06d7363; stack includesxboxbvhbuilder.dll+0xd2538The PR log confirms the cap setting and reports local sparse pools staying at 1,024 MB. The drop in local video memory and rise in non-local use are consistent with overflow to system memory. These counters do not directly count L0 heaps. Both runs ended at the same earlier BVH builder exception, so this test shows the memory cap taking effect on RDNA3, not improved world-load progress. With one run per revision, I cannot attribute the frame-count difference to the PR.
cargo test -p xcl --lib hle::d3d12x::sparse:: -- --test-threads=4on the PR: 39 passed, 0 failed, 1 ignored. I did not run the full workspace suite orscripts/smoke.ps1.Driver compile starts without a logged finish at exit: amd-dev baseline, one MS PSO (339,108 B DXIL); PR, two MS PSOs (376,292 B and 265,320 B DXIL). Those start lines contain no hashes and do not establish a driver hang.
AI use: OpenAI Codex (GPT-6) verified the commits, prepared the builds and runs, analyzed the logs, and drafted this report. I ran the test on my PC.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:32:01Z.
Triage (#1607) – head
a0f65e2Related, not the same: #2987 (against main) puts sparse tiles outside the title's GPU heaps into L0 system-memory pools (
XCL_SPARSE_SYSMEM), choosing by what a range holds. This PR caps video-memory sparse pools by size on amd-dev. The change is not on amd-dev yet.No correctness problems found in
sparse.rs.pool_is_sysis kept alongsidepools, retired heaps are reused only for the same kind, andpool_bytesleaves L0 pools out.sparse_vram_cap_overflows_to_l0_and_reports_separatelynow covers the L0 overflow path (take_tile_with_cap), reuse of a retired L0 pool, and the separate byte counts.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:36:27Z.
Review (head
b0077129, diff read, not a merge-check; draft, baseamd-dev, conflicts with it):sparse.rs~1554). moombathepilot's RDNA3 run had fewer frames, but with one run per side it can't be put on the PR.pool_bytes(~1226) leaves L0 pools out, and nothing else reports them.retiredtuple changed shape (~2746 there).release_tests::the_last_release_drops_entries_before_the_object_goesand exit 0x887a0005 fail the same way on #3111 at the same basef33df5a7. The description check fails on peak commit, which the author shows is amd-dev's own number.Fine: off when unset (parsing checked by JJAutoCompare), retired heaps are reused only for the same kind, and a failed L0 heap creation falls back to video memory. #3335 / #3039 put texture levels in system memory, a different path; #2987 (main) overlaps in what it does.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-12-01T17:14:00Z.
Rebased onto
amd-dev41aa60ce(a0f65e2f) addressing the review points:sparse.rsretiredtuple merge conflict.memory_report.rsas"sparse pools in system memory"onKind::NonLocal(while keeping video-memory counts local-only).sparse_vram_cap_parses_pool_countsand GPU testsparse_vram_cap_overflows_to_l0_and_reports_separatelycovering L0 overflow allocation, retired-pool kind matching, and split accounting.smoke.ps1regression run (1,643 frames, 15,430 MB peak commit — now undermain's 15,479 MB).Note: first-come placement past the cap remains intentional for this opt-in MiB cap (workload-aware placement is tracked separately by #2987 and #3587).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T04:13:30Z.
Follow-up review (head
93570fea, sincea0f65e2f, diff read, not a merge-check; draft):memory_bytes_forreports system-memory pools separately andmemory_reportlists them as "sparse pools in system memory"; this push files them underuma_segment(non_local)(memory_report.rs~151), so on a single-segment adapter they count as local, as DXGI does.sparse_vram_cap_overflows_to_l0_and_reports_separatelyandsparse_vram_cap_parses_pool_countswere added, and the branch now sits on the currentamd-devtip.take_tile_with_cap).New: none; only the segment kind changed since
a0f65e2f.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T13:41:36Z.
Test report (not a merge-check: draft)
base:
41aa60ce84head:
93570fea74merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2963 passed, 9 failed, 49 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on amd-dev); failing: gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, gpu::recomp::tests::gpu_fract_f32_edges, hle::d3d12x::sparse::tests::private_physical_pages_reach_the_gpu_on_mapping, hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, hle::d3d12x::title_textures::tests::remapped_pages_are_compared_with_what_they_held, hle::d3d12x::title_textures::tests::stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, hle::d3d12x::title_textures::tests::stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, hle::d3d12x::title_textures::tests::stream_recheck_schedule_catches_late_writes_and_resets_milestones (the same tests fail on amd-dev
41aa60cealone on this card, so none is from this PR)review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3112#issuecomment-7334687988 and its findings stand. Most serious: past the cap,
take_tile_with_cap(sparse.rs~3886) sends new pools to system memory in arrival order and never moves them back (a limit of an opt-in switch, not a bug).performance: 60 s smoke of a retail title, amd-dev
41aa60cevs this merge (93570fea): 1671 -> 1687 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 16722 -> 16853 MB, 0 device removals, 0 crashes.assessment: merges cleanly into amd-dev, adds no test failure, and the smoke run is clean; the review found no blocking problem (past the cap, new pools go to system memory in arrival order and never move back, a limit of the opt-in switch); ready for a merge-check once it leaves draft
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.