Repository navigation
D3D12.X: an idle allocator's pool state goes before its last Release - #3611
ArtuArtaza wants to merge 1 commit into
Conversation
alloc_release dropped what XCL keeps by a command allocator's address (the pool's namespace and type, the dispatch chain's and list_x's state) after the Release that frees the object. In between, the driver can give that address to an allocator another thread creates, and the cleanup then ran on the new one: alloc_pool::forget took its type and stand-ins, and marked one that already held a recording for release by the pool. For an allocator nothing uses, the cleanup now runs while the hook still holds its probe reference, before the Release that frees it. One the pool keeps for the GPU, and a Release that did not see the last reference, are cleaned up after it as before. sage-sage's xcl-dev#2701 proposed this order for heaps, queues and allocators; the allocator part is not on main. Measured on main b2b1f10 (RX 6700 XT, driver 32.0.21045.29003) with a GPU test that creates allocators between the Release and the cleanup until one comes back at the freed address: it failed 5 of 5 runs there and passed 5 of 5 with this order. That test needs a hook in alloc_release and is not part of this commit. Assisted-by: Claude Code (Claude Fable 5.2)
|
Review (head 73a197a, diff read, not a merge-check):
Fine: AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
|
merge-check
|
|
Thanks @fromthemoonx for the check and the mutation run. |
|
Test report on head
Not tested: a card (NVIDIA or other) for these tests, native Windows, the bug's own reproduction. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
Setup. Native Windows 11, RX 7900 XT 20 GB, Ryzen 5 7600, 32 GB RAM. XCL release builds, Series S / lockhart, DXC 1.9.2609.5. A = base Startup smoke (60 s, no input). A–B–B–A passed 4/4 with clean timed exits, zero crashes and zero device removals. Each run ended at about 30 presents/s. An extra B smoke run also passed and was excluded from the ordered comparison. Interactive New Game attempts (300 s limit, A–B–B–A).
AI use. 6.1 Sol (Codex) prepared the startup launchers and analyzed the initial smoke results. 6.2 Sol (Codex) prepared the interactive launcher, analyzed the follow-up logs, and compiled this report. The tester launched the runs and provided the input and observations. |
alloc_release(real.rs) removed what XCL keeps by a command allocator's address after theReleasethat frees the object. In between, the driver can give that address to an allocator another thread creates, and the cleanup then ran on the new one:alloc_pool::forgettook its type and stand-ins, and marked one that already held a recording for release by the pool. For an allocator nothing uses, the cleanup now runs before the lastRelease, while the hook still holds a reference.Credit: @sage-sage proposed this order for heaps, queues and allocators in #2701 (closed). The allocator part is not on
main; this is that part on today's code. A follow-up that releases idle allocators needs it, because a reused address becomes common there.What is in it
crates/xcl/src/hle/d3d12x/alloc_pool.rs:release_with_probetakesbefore_last, called when the caller's reference was the last one and the pool does not keep the allocator; a unit test of the order.crates/xcl/src/hle/d3d12x/real.rs:alloc_releasepasses its cleanup (dispatch chain,alloc_pool::forget,list_x::on_allocator_release) asbefore_last. An allocator the pool keeps for the GPU, and aReleasethat did not see the last reference, are cleaned up after it as before.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on 73a197a: 2900 passed, 6 failed, 51 ignored. The 6 are 5 tests (the two-pass cache e2e test runs itself as a child and prints two results). The same 5 fail onmain6bfb5c5 on this card (2899 passed, 6 failed, 51 ignored):gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form,f32_programs_on_the_gpu,gpu_f32_compares_with_nan,gpu_float_compares_random,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs. None is in the code this PR touches.cargo test -p xcl --lib alloc_pool -- --test-threads=4, 30 times: no run with a failure.mainb2b1f10: a GPU test that creates allocators between the lastReleaseand the cleanup, until one comes back at the freed address, failed 5 of 5 runs ("the title's new allocator would be released when its recording is done") and passed 5 of 5 with this order. It needs a hook insidealloc_release, so it is not in this PR; say if you want it added.Regression run
main:
PR:
Not tested
mainends at the first world load on this card (Recompiler: a pixel shader's carry ballot reads its quad lane by lane, not through quadOp #3455).AI use