D3D12.X: free buffer mirrors no draw used for 10 seconds #825
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!825
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-825"
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?
@Cattn on GitHub · 2026-11-24 06:12 UTC · original
Cattn:mirror-idle-free→main· +69 −6 · 1 files · 1 commits · openA buffer view outside unified memory gets a mirror that each draw copies what it reads into. Mirrors are never freed, so a title that binds ring buffers at new addresses while it streams its world keeps making them. On a retail title they reached 925 MB at 74 s, on the way to the 2 GiB cap. That memory is both system commit and, through the sparse pools, video memory, and on a 32 GB / 12 GB machine it is part of what runs the process out of memory during world loading.
What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: each mirror records when a lookup last used it. When a new mirror is made, at most once a second, mirrors unused for 10 s are taken out of the table and their sparse or coherent memory is freed. A range bound again later gets a new mirror, filled from the title's memory as before. A unit test covers the lookup marking a mirror used and the idle sweep.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4onb12bf42(rebased onbeaa245): 714 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
main:
this PR:
Not tested
AI use
🤖 Generated with Claude Code
@dcastell1 on GitHub · 2026-11-24 06:50 UTC · original
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, applied on
main@beaa245:That is one more passing test than
mainon the same box (737), so the idle-mirror sweep (free buffer mirrors no draw used for 10 s) runs green here and nothing else in the workspace changes verdict. No game data, hardware adapter, no Wine.AI-assisted (opencode): applied the patch to a built tree, ran the suite, restored the two files.
@SlopTart on GitHub · 2026-11-24 07:17 UTC · original
Linux / AMD RDNA3 datapoint.
Merged state: head
b12bf42onto main1ec4c98, clean merge.Full suite,
cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 706 passed, 10 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Unused buffer mirror reclaim tests green; no new failures.Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.
Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross
x86_64-pc-windows-gnu,XCL_NETWORK=0, release profile,--test-threads=4. Linux rows: #42 / #718.AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@iggyvilla on GitHub · 2026-11-24 07:34 UTC · original
Review of
b12bf42(read only, nothing built or run by me): I think the 10 s idle rule can free a mirror that a recorded list still binds.What the timer measures. A mirror is stamped only by
find_mirror, which runs at record time:gpu_va->mirror_of(list_x.rs:3066) when a buffer is bound, andsync_title_buffers->mirrored(:3199-3200) at every draw. What the PC list holds is the mirror's GPU address (pc_va(p)at:3067), so the GPU reads the mirror when the list executes, not when it is recorded. "Not looked up for 10 s" therefore means "not recorded against for 10 s", not "no GPU work uses it".Where it frees.
mirror_oftakes the idle entries out of the table andfree_mirrorsfrees them straight away on the recording thread:u.free(p)for a coherent block,sparse::free(p)for a sparse one. There is no fence or allocator check. So if a list that bound a mirror is submitted (or is still executing, or is executed again, which D3D12 allows for a closed list) more than 10 s after its last draw was recorded, and any other thread creates a new mirror in between, the GPU reads a mirror that was freed. For a coherent block that can be memory the nextallochas already handed out and overwritten, so the draw reads another range's bytes rather than zeros; the PR text only describes the sparse case.I have not shown that the title does this (the retail runs in the PR may never record that far ahead), so I'd call it a hypothesis about a window, but the code has no protection against it. Two ways to close it that the tree already has: hold the freed blocks until the allocator of the lists that could bind them resets (
console_list::hold_until_reset/allocator_reset, the lifetime #838 relies on for its arena), or stamp each mirror with the submission it was last bound in and free only below completed work. A test that binds a mirror in a closed list, lets it go idle and checks it is not freed would pin it; the current test covers onlyfind_mirrorandtake_idle_mirrors.Smaller points:
mirror_of(:3150returns on a hit first), so once the title stops binding new ranges nothing sweeps and the table stays at its peak. A sweep from submit/present, or whenMIRROR_BYTEScrosses a threshold, would also reclaim after streaming stops.free_mirrorsreturns atlet Some(u) = uma::get() else { return }aftertake_idle_mirrorsalready removed the entries, so their bytes stay inMIRROR_BYTES. Only matters at shutdown.AI use: read with Claude Code, Claude Sonnet 5.5, against the PR head; the findings are mine and I checked each line reference.
@DavidM1911 on GitHub · 2026-11-25 10:38 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a 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.