D3D12.X: fall back to 256 KiB sparse arenas when coherent UMA is full #2142
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!2142
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2142"
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?
@Simon-CR on GitHub · 2026-11-25 06:06 UTC · original
Simon-CR:pr/bind-sparse-arena-fallback→main· +1143 −108 · 6 files · 2 commits · openStacked on #2138; only the top commit belongs here.
When coherent unified memory fills up during heavy scene recording, every draw still needs small chunks of unified memory for its per-draw shader tables and constant-buffer copies, and console middleware calls
AllocateUploadMemory. Previously, when coherent unified memory ran out on a small request, recording either failed (unified memory is full) or risked allocating a separate 64 KiB sparse block for each tiny copy (burning sparse reservation blocks and virtual-address tiles on every small draw).This change handles small upload and binding requests cleanly when coherent unified memory is full: first it asks the swap pool to reclaim idle put-aside PC command allocators (rate-limited to once every 50 ms across concurrent threads so threads do not thrash a contended pool) and retries coherent memory; if coherent memory is still full and sparse unified memory windows are enabled, it allocates one 256 KiB sparse block, seeds the command list's bump arena with it, and serves subsequent small draws out of that same 256 KiB block until the allocator resets (doing the same for console command lists on
cl_allocate_upload_memoryanduma_copy). Larger requests continue taking dedicated sparse blocks before falling back to coherent memory + reclaim.What is in it
crates/xcl/src/gpu/uma.rs: splitArena::take_bumpout ofArena::take, addArena::seed_block(with overflow-safe bounds checks) so callers can attach a 256 KiB backing block to an active arena, and add unit testarena_seed_block_bump_allocates_and_tracks_block_oncecrates/xcl/src/hle/d3d12x/bind.rs: add a 50 ms cooldownmaybe_reclaim_alloc_poolretry, extract sharedalloc_recording_uma/alloc_recording_uma_withfallback helper used by bothallocate_upload_memoryandbind_abi's copy closure (dropping redundant sparse blocks outsideSTATESif another thread seeds concurrently), plus unit testalloc_recording_uma_falls_back_to_sparse_arena_block_without_per_copy_churnand GPU testgpu_sparse_arena_fallback_maps_va_uploads_to_gpu_and_frees_on_resetcrates/xcl/src/hle/d3d12x/console_list.rs: share the 256 KiB sparseArenablock seeding fallback incl_allocate_upload_memoryanduma_copywhen coherent unified memory is fullTested
rustc 1.100.0 (0ef1bc386 2026-11-09)cargo test -p xcl --lib ... -- --test-threads=1):gpu::uma::tests13 passed / 0 failed / 0 ignored;hle::d3d12x::bind::tests9 passed / 0 failed / 0 ignored;hle::d3d12x::console_list::tests5 passed / 0 failed / 0 ignored;XCL_HEAP_WINDOWS=1standalonehle::d3d12x::bind::tests::gpu_sparse_arena_fallback1 passed / 0 failed / 0 ignoredcargo test --workspace --no-fail-fast -- --test-threads=4: 1269 passed, 2 failed (only pre-existinggpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599 reproduced on unmodifiedorigin/main06c9f550, tracked in #2115 / #1679), 46 ignored across 23 test result summaries (debug build)SKIPPEDtests: gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D); test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))cargo build --release -p xcl) and 60 s retail title run (5ec87c56) completed cleanly with 0 device removals and 0 crashes; peak commit was 16108 MB vs 19392 MB onmainRegression run
Not tested
mainalone (verified locally across a 240 s retail world-load soak with 0unified memory is fullerrors alongside the rest of the local patch set), NVIDIA GPUs, Intel Arc GPUs, wave32-only GPUs, and Linux/WineAI use
Arena::seed_blockand the throttled reclaim/sparse fallback path, porting/rebasing onto the updated#2138base, adding the unit and GPU tests, running the test suite and smoke runs, and drafting this description. All builds, tests, and regression runs were executed locally on the hardware above.@JoaoPauluu on GitHub · 2026-11-25 06:25 UTC · original
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1379 here; 1353 and 1380 on the twomainruns). The 6 new tests pass under Wine, the GPU one (gpu_sparse_arena_fallback_maps_va_uploads_to_gpu_and_frees_on_reset) included. In 60 s the coherent window here is far from full (the log's lastcoherentfigure is 116/512 MB in this run), so the fallback is not reached; this is a regression run only.Tested
x86_64-pc-windows-gnu.583fe45as it is (based on6020a33) andmain6e1e2be, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, #2138, #2142, main. New lib tests under Wine, one test per process.Regression run
main (first run):
this PR:
The second
mainrun: 1380 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 06:49 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@Simon-CR on GitHub · 2026-11-25 14:52 UTC · original
Rebased cleanly onto the updated
#2138head (a6574154, onmain06c9f550) ->3f3d7627. Thanks @JoaoPauluu and @DavidM1911 for the earlier checks!Re-tested on
3f3d7627(RX 9070 XT, Win10):--test-threads=1):gpu::uma13/0,bind9/0,console_list5/0,XCL_HEAP_WINDOWS=1gpu_sparse_arena_fallback1/0--no-fail-fast -- --test-threads=4): 1269 passed, 2 pre-existing#2115fuzz failures, 46 ignored06c9f550: 1568 frames (16108 MBpeak commit) vs 1373 (19392 MB) onmain, 0 device removals, 0 crashes.@DavidM1911 on GitHub · 2026-11-26 08:15 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.