D3D12.X: a sparse pool retired a moment ago is taken back (#913) #923
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!923
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/923/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?
@maximecmb on GitHub · 2026-11-24 08:23 UTC · original
sparse-take-back-retired-pool→main· +87 −1 · 1 files · 1 commits · merged 2026-11-24 09:31 UTCFixes #913.
Freeing the last tile in use of a 64 MiB sparse pool retires the pool for at least 2 s (
retire_free_pools); the next tile allocation found the free list empty andtake_tilemade a new heap. A free / alloc loop therefore made a new pool every time: #913 counted 288 pools and about 18 GB asked of a 12 GB card in one test (a_freed_block_is_decommitted_before_its_address_is_reused), and lib test runs on 12 GB cards fail withE_OUTOFMEMORY. A title that frees and allocates the same way gets the same growth.take_tilenow takes back the most recently retired pool before it creates a heap. Its tiles are flagged for clearing (reused), as the freed tiles of a pool in use already are when they are handed out again at once, so this is no less safe than the existing reuse.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:take_tiletakes a retired pool back first; the pool registration both paths share isadd_pool.a_pool_retired_a_moment_ago_is_taken_back– a tile freed and taken 8 times in a row gets the one retired pool back each time (flagged for clearing) instead of a new heap. It fails without the change (a new, unflagged heap comes back).Tested
stable-x86_64-pc-windows-msvc, debug, DXC 1.9.2602.17cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on this branch: 717 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware; noXCL_SAMPLE_*setnvidia-smi, sampled every 0.5 s) duringcargo test -p xcl --lib -- --test-threads=4, one run each:main09940bbmain's failures:placed_title_textures_share_vram_and_preserve_pixels(the #718 cubemap check), thentransitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memoryon its poisoned lock. That the cubemap failure comes from the memory pressure is not shown, only that it went with it here.Regression run
main:This PR:
A first pair of runs, made right after each build, did not compare:
main1618 frames / 16 414 MB, this PR 1488 frames / 21 586 MB (over the 125 % limit), its last 2-second samples at 3–4 presents. The two runs'XCL_ACTIVITYlines show why: both go through the same loading steps, and this PR's run reached them about 12 s sooner (the DirectStorage burst that takes target pages from 3.6 to 4.5 GB came at 44–46 s instead of 56–60 s), so its window ended in the next stage – 12 000 DirectStorage requests per 2 s, target pages to 6.6 GB – whichmain's never reached. At the same step the sparse pools this PR changes were the same in both (1 024 MB); the extra commit was in target pages (vram.rs). The pair above was made afterwards with warm caches for both builds, in the order main → this PR.Not tested
take_tile, next to this change, and aparkedfield toState, which the new test'sStateliteral would then need. Whichever lands second needs a small rebaseAI use
🤖 Generated with Claude Code
@ettehn on GitHub · 2026-11-24 08:32 UTC · original
On a 12 GB RTX 5070 Ti Laptop GPU (Windows, driver 621.24), this change reduced peak device-wide VRAM use by about 9 GiB in the debug library suite. Two runs per commit, in base → PR → PR → base order. I built both clean worktrees before measuring and sampled
nvidia-smievery 250 ms duringcargo test --offline --locked -p xcl --lib -- --test-threads=4.09940bb71bda9371bda9309940bbIdle samples before the runs were 899–920 MiB. The three failures in the first base run were the cubemap reuse check and the two tests that subsequently saw a poisoned lock. The second base run passed at the higher peak. This confirms the memory reduction on a 12 GB card. Retail world loading and per-process residency were outside this measurement.
OpenAI Codex (GPT-6.2 Astra) assisted with verification.
@ClosetPie107 on GitHub · 2026-11-24 08:45 UTC · original
Tested on AMD under Linux / Wine: it fixes #913 there too. Video memory went from the full 16 GB card to ~2.3 GB.
Tested
experimental-11.0-20261112), vkd3d-proton v3.1 + #257's patch (-Db_ndebug=true, dxil-spirv53aac418), DXVKv3.1.1-209, DXC 1.9.2609.5. Rust 1.96.0,x86_64-pc-windows-gnu, release.71bda93against its basemain1ec4c98. The lib test binary runs under Wine withVKD3D_CONFIG=ignore_shared_fence XCL_NETWORK=0 XCL_ADAPTER=9070. Peak VRAM comes from amdgpu'smem_info_vram_used, sampled every 0.2 s.--test-threads=4 --skip write_buffer_immediate_on_open_existing_heap_visible_to_cpu. Thatlist_xtest causes a separate device loss on this stack (see the edited comment in #175), so I left it out of both sides.gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes1ec4c98, 3 runsTimeout(5000)(title_textures.rs:1291), then 3PoisonErrorfailures. The aborted run lost the device (0x887a0005) during a title-texture upload71bda93, 3 runsgpu_f64_rootsandgpu_f64_math_random(#530),gpu_nonfused_mad_and_mac_prevent_fma_contraction(#676), and the XMA2 and OpusGetStatetests (#890).a_pool_retired_a_moment_ago_is_taken_back: 3 of 3 pass.mainmoved:077ce40still shows the problem (665 / 9, 16 287–16 295 MiB peak,gpu_mirror_upload…fails, 2 of 2). The commits since1ec4c98don't touchsparse.rs.Not tested: the head rebased onto
077ce40, Windows, a retail title, #532.AI use: T3 Code (Claude Opus 5.5) built both trees, ran the tests and wrote this comment from the logs. The runs are real, on the hardware above, and I checked the report before posting.
@ivall on GitHub · 2026-11-24 09:31 UTC · original
Merged (
6bac4b4). Checked on an RX 9070 (RDNA4) on main6bac4b4together with #923 and #849:cargo test --workspace -- --test-threads=4- 678 unit tests passed, 0 failed; the retail game plays its intro and menus at 30 fps and starts loading the world (the run then hits this machine's commit limit, not a crash). Picked over #930, which a tester saw fail the sparse e2e check.