Repository navigation
D3D12.X: a reused spare keeps the allocator of deferred work still on the GPU - #2549
tiagonleal wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Test run on exact head Tested
Regression run (60 s, default settings, a retail title) main: this PR: No crash or device removal; frames 101 % of Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
|
Independent AMD RDNA4 (native wave64) verification of exact PR head Tested
(Compare against Not tested
AI use
|
Eliminate the global sparse STATE lock convoy across synchronous GPU fence waits in sparse::readback_now (triggered on ID3D12Resource::Map readbacks) by pooling per-Map ReadbackJob objects (COPY command allocator + list + persistently-mapped READBACK staging buffer + OS fence event) outside STATE. STATE is now only held briefly to flush pending zero/dirty pages and snapshot mapped spans, to submit/signal on the copy queue, and to copy still-committed non-hole bytes back into host memory after the fence wait completes unlocked. Also adapt three upstream fixes cleanly atop our runtime branch: - #2548: use pso_async::resolve (non-blocking) instead of resolve_for_bind in device_x::create_list, list_x::kickoff_x, and list_x::reset_pc so list creation/reset with a compiling compute PSO never stalls the title thread. - #2549: preserve own_alloc when split() reuses a spare segment whose previous recording held deferred dispatches' allocator. - #2550: add pso_async::is_stand_in and bind::note_skipped_indirect to call list_x::note_dropped_draw on skipped graphics ExecuteIndirect paths (including stand-in / two-pass PSOs) so dropped draws stay tracked consistently. Assisted-by: Antigravity (Gemini 4 Neon High)
|
A question on AI use: Claude Code (Claude Opus 5.5) reviewed the diff; I checked the reasoning but did not reproduce it. |
…ixes Integrates upstream amd-dev 61121fe/xcl-dev#2569 (DirectStorage ordered completion wakeups) plus open PRs xcl-dev#2577 (skip AMD cache-reference driver blobs on disk, xcl-dev#2512), xcl-dev#2578 (clear LAST_CONTENT on placed texture unmap/remap, xcl-dev#2460), xcl-dev#2579 (mark put-off builds wanted immediately), xcl-dev#2556 (NULL-ppv CreateDescriptorHeap test), xcl-dev#2550 (skipped ExecuteIndirect occlusion query), xcl-dev#2549 (reused spare keeps in-flight deferred allocator, with Wine raw fences and UnadoptGuard), and xcl-dev#2548 (Reset/KickoffX/CreateCommandList do not wait on building compute pipelines). Assisted-by: Antigravity (Gemini 4 Neon)
|
Tested: current PR head merged onto current
Not tested: retail titles (no title data on this lane, counts only). AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting. |
…ev#2549) (cherry picked from commit 510e55c41d9d4a9984b168b756bea553bb39a5c9)
|
RTX 3090 Ti Windows validation of the allocator-lifetime regression Windows 10, NVIDIA 621.40, Rust 1.98.1 MSVC. Local
The unpatched af2 retail run had its render thread in native command-list Reset under Matched retail replay update. The backport reproduced the same submit-thread native AI use: Codex (GPT-6) adapted the backport and fixture, ran these tests and wrote this report. |
… the GPU Since xcl-dev#2118 a dispatch whose pipeline is still being built is recorded at the submit on an allocator kept in the ListState of the recording's first segment (own_alloc), which holds its only reference. When that first segment is a stand-in (xcl-dev#1452), the next Reset puts it among the spares, and a later split reuses it as soon as its own submit is done: split removed and dropped its ListState, releasing the allocator without the in-flight guard on_release has. With a Wait64BitValueX between the first segment and the deferred dispatch, the two are submitted in blocks with their own fence values, so the deferred segment can still be on the GPU then, recorded on a destroyed allocator. split now keeps own_alloc of the reused spare's old state, moved into its new one, only while alloc_pool::allocator_in_flight says the GPU may still run work recorded on it. Kept, the allocator stays with its PC list as it did while the list was a spare, and on_release keeps it while it is in flight. Once the GPU is done with it, it goes with the old state, released outside the LISTS lock as before this change. Moving it unconditionally would leave it (and the scratch of its split dispatches, dispatch_chain::RECORDINGS) charged against XCL_SPLIT_SCRATCH_TOTAL_MB: the list is reset from then on only through alloc_pool::reset_list (split, deferred_segment, record_deferred), not reset_pc, so reset_own_alloc does not run for it. Tests a_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpu and a_spare_reused_by_a_split_drops_an_own_allocator_the_gpu_is_done_with. Without the change the first fails (reference count 2, expected 3: the allocator is released while the GPU may still run work recorded on it); with the allocator moved unconditionally the second fails (the reused spare's state keeps an allocator the GPU is done with). With the change both pass, 3 of 3 runs. cargo build --release -p xcl and cargo test --workspace --no-fail-fast -- --test-threads=4, twice: 1421 passed, 4 failed, 46 ignored, 25 SKIPPED both times; the 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (E_OUTOFMEMORY), failing on this machine without this change too. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a041834 to
468f8df
Compare
|
That was not intended. After a split reuses the spare, the list is reset only through Fixed in 468f8df (the two commits are squashed into it, and the message no longer says Run on 468f8df: Not run: the four fuzz tests on |
|
@raylitebull a note for amd-dev already keeps AI use: Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Sonnet 5.5) compared the trees and wrote this; I checked it. |
Runs 4-6 on an RTX 5080 grew non-local video memory to 45 GB within a minute of the first intro frames and ended in E_OUTOFMEMORY and a device removal; run 7 with XCL_ALLOC_SWAP=0 stayed near 16 GB. The entry records the cause and the user's decision to adopt xcl-dev#2725, xcl-dev#2549, xcl-dev#2581 and xcl-dev#2707 through the gate. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RbZY1Ag73eDeCUZHpW3is
Commit: 468f8df Reviewer: Claude Code (Claude Opus 5.5), Opus worker, full read (clean) Review: sha256 e5a5e021d6fe4906a2283a6b11272e8f86b206d2efe792e0cdff4110dd77af2e
…s are left out With draws off the title's thread, a retail title on an RTX 5080 still stopped presenting 70 s after its loading screen: 31 of 32 compute waits built the pipeline in the call (up to 15 s each), and it then sat for 450 s behind about 35 ray-tracing resolve programs of 700 to 940 KB of DXIL that take up to 167 s each in the driver compiler. A waiting compute bind no longer takes the build job: the build is marked wanted, goes ahead of the workers' queue and is waited for, at most XCL_PSO_COMPUTE_WAIT_MS (default 120 s, 0: no limit); after that the pipeline is late and its dispatches are skipped until it is built. XCL_PSO_IMAGE_SKIP is now on unless set to 0: a big compute program that writes only images is not waited for and not put off to the submit. It writes no buffer, so no ExecuteIndirect can read stale counts from it. Tested on Windows 11, RTX 5080, driver 32.0.16.2140, on top of xcl-dev#2581, xcl-dev#2549 and xcl-dev#2707: cargo test -p xcl --lib -- pso_async:: bind:: list_x:: alloc_pool:: title_list:: : 95 passed, 0 failed; whole suite 1639 passed, 4 failed (the dxil fuzz_validate_and_gpu_0..3 that fail on this GPU without the change), 47 ignored, 45 SKIPPED lines. Not tested on AMD. Unit U5 of the stall-fix entry in decisions.md. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018RbZY1Ag73eDeCUZHpW3is
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2549 updated head Setup
Targeted RTX 4060 release unit & GPU tests (
|
|
Independent test report under Wine/Proton (not native Windows) for head Setup
Tests (debug,
Retail title, 300 s (release, from a copy of the same warm-cache snapshot;
Not tested
AI use
|
Since #2118 a dispatch whose pipeline is still being built gets a segment of its own, recorded at the submit on an allocator that
deferred_segmentcreates and keeps in theListStateof the recording's first segment (own_alloc). ThatListStateholds the only reference. When the first segment is a stand-in (#1452: the title reset the list while its last submit was on the GPU), the next Reset puts it among the wrapper's spares. A latersplittakes the spare as soon as its own submit is done, removes itsListStateand drops it, and the allocator is released.on_releasekeeps such an allocator whilealloc_pool::allocator_in_flightsays the GPU may still use it;splithad no such guard.The deferred segments can still be running then. With a
Wait64BitValueXbetween the first segment and a deferred dispatch,execute_with_waits_onsubmits them in two blocks with their own fence values, so the first segment's block can finish while the block with the deferred segment is still waiting for its producer. The GPU then runs a list whose allocator was destroyed.splitnow keepsown_allocof the reused spare's old state, moved into its new one, only whilealloc_pool::allocator_in_flightsays the GPU may still run work recorded on it. Kept, the allocator stays with its PC list as it did while the list was a spare, andon_releasekeeps it while it is in flight. Once the GPU is done with it, it goes with the old state, released outside theLISTSlock as before this change. Moving it unconditionally would leave it, and the scratch of its split dispatches (dispatch_chain::RECORDINGS), charged againstXCL_SPLIT_SCRATCH_TOTAL_MB: from then on the list is reset only throughalloc_pool::reset_list(split,deferred_segment,record_deferred), notreset_pc, soreset_own_allocdoes not run for it. No tracked issue covers this; #2118 added the allocator, and #2320 and #2417 touch the same code without changing how it is kept.What is in it
list_x.rs:splitkeeps theown_allocof a spare it reuses whileallocator_in_flightsays the GPU may still use it, and releases it with the old state otherwisea_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpu: a spare holding the allocator of a deferred segment held on the GPU by a queue Wait is reused by a split; the allocator must still be referenceda_spare_reused_by_a_split_drops_an_own_allocator_the_gpu_is_done_with: the same spare once the GPU is done with it; the reused spare's state must not keep the allocatorTested
cargo test -p xcl --lib -- a_spare_reused_by_a_split: 2 passed, 0 failed, 3 of 3 runs on 468f8df. Withmain's behaviour (the allocator dropped with the old state) the first fails:the allocator of work still on the GPU stays held, reference count 2, 3 expected. With the allocator moved unconditionally, as in the first version of this PR, the second fails:the reused spare's state keeps no allocator the GPU is done with.cargo test -p xcl --lib -- hle::d3d12x --test-threads=4(run on the earlier head a041834, not repeated on 468f8df), 3 runs: 254 passed, 0 failed, 2 ignored in two runs; in one run 253 passed, 1 failed (a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, 289 segments of 421). That test fails the same way now and then onmain6d12f58 without this change (127 of 421 in an earlier run here).cargo test --workspace --no-fail-fast -- --test-threads=4, run twice on 468f8df: 1421 passed, 4 failed, 46 ignored both times (25SKIPPEDlines). The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(E_OUTOFMEMORY), which failed the same way on this machine without this change in earlier runs; I did not run them onmainagain today.Regression run
60 s each, the same retail title, release builds from clean trees. A first
mainrun gave 914 frames (my guess is a cold start; not checked), so themainblock below is a second run, made about 20 minutes after the run of this PR.main(e1d84b7):This PR:
Not tested
Wait64BitValueXon a list with a stand-in first segment: not known. No device removal on the retail title has been traced to this; the fix comes from reading the code and the unit test.on_create(a list created at the address of one whose release was not seen) is left as it is: it needs a lost Release and has no test here.AI use
🤖 Generated with Claude Code