D3D12.X: retain resolved async pipelines until reset and retirement #2417
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!2417
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2417"
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?
@fixgep on GitHub · 2026-11-25 18:12 UTC · original
fixgep:fix/pso-async-lifetime-retention→main· +1393 −238 · 8 files · 1 commits · openRetain resolved async pipeline COM references across command list recording, reset, and GPU queue retirement so background-built pipelines cannot be freed while bound or in flight (
XCL-BT-008). Part of #916. Part of #1488.What is in it
Pendingcompletion, state updates, and unstarted/adopted stand-in release underPending::state(Pending::finish_release), return COM-retainingResolvedhandles (resolve_wait_retained,resolve_for_bind_retained,resolve_if_pending,resolve_cached_*including nonwaitingresolve_cached_if_pending) with settled fast-path tracking, and gate adopted stand-in release viatry_release_standin(pso_async.rs)ID3D12PipelineStatereferences on command lists (list_x::ListState::retained_psos,console_list::ListState::retained_psos, and bound-pipeline tracking inbind/list_x) across creation,Reset,ClearState,SetPipelineState,Draw*/Dispatch/ExecuteIndirect,RSSetDepthBiasXrestore/prepare,KickoffX, mid-list split (using nonwaitingresolve_cached_if_pendingso deferred compute dispatches still wait only at submit), andconsole_list::closeuntil reset or releaseadd(this) == 2proves the caller released the actual last ref, removing theelse if f(this) == 1branch so2 -> 1releases stay non-final) and unadopted COM pipeline releases through non-spinninglate_release::hold_deferred, dispatch unadopted COM objects via vtable slot 2 inlate_release::drain_known, and clone queue COM references safely underQUEUES(present::known_queue_refs) while purging retired test queues fromHeld::fences(real.rs,late_release.rs,present.rs,pso_async.rs)UnstartedRealRAII guard), GPU queue retirement (late_release+ stalled queue),standin::shellcommand-list lifetime, pending stand-in bind/retain -> titleRelease(2 -> 1) -> listReset(1 -> 0) regression tests, and extenda_dispatch_with_a_pipeline_still_building_waits_at_the_submitto bind a real still-building stand-in viaSetPipelineStateacross mid-list splits (withXCL_ADAPTER=warp/agility::create_devicefallback and clean skip when no D3D12 adapter is present) inpso_async.rs,late_release.rs,list_x.rs, andreal.rslist_x/bind/console_listand deferred retirement/locking inpso_async/late_release/realform a single COM reference-lifetime invariant across command-list recording, reset, and GPU queue retirement. Landing list-side retention withoutpso_release'sadd(this) == 2guard andtry_release_standinwould misclassify2 -> 1title releases as final (double-releasing or forgetting tracked state while lists still hold refs) or leak retained refs; landingpso_async/late_releasewithout list-sideResolvedretention would leave use-after-free windows while stand-ins or resolved PSOs are bound on open or split command lists.Tested
32.0.15.9144), AMD Ryzen 5 7500F 6-Core Processor, Windows 11 x64 (10.0.26200.0),rustc 1.100.0 (0ef1bc386 2026-11-09), debug and release (rebased ontoupstream/mainb49be1836844, head1a51cb95ebd73348679073a39eaab7f185e6fce6)cargo build --workspace: exited0with 0 new compiler warnings (3 pre-existing warnings inreal.rs,xgameruntime/mod.rs, andvram.rs)cargo test -p xcl --lib pso_async -- --test-threads=1(default RTX 3060):15 passed, 0 failed, 0 ignoredcargo test -p xcl --lib list_x -- --test-threads=1(default RTX 3060):40 passed, 0 failed, 0 ignoredcargo test -p xcl --lib hle::d3d12x -- --test-threads=4(default RTX 3060):260 passed, 0 failed, 2 ignored(0SKIPPEDGPU tests)XCL_ADAPTER=warp cargo test -p xcl --lib pso_async -- --test-threads=1:15 passed, 0 failed, 0 ignoredXCL_ADAPTER=warp cargo test -p xcl --lib list_x -- --test-threads=1:40 passed, 0 failed, 0 ignoredXCL_ADAPTER=warp cargo test -p xcl --lib hle::d3d12x -- --test-threads=1:260 passed, 0 failed, 2 ignored(0SKIPPEDGPU tests)cargo test --workspace --no-fail-fast -- --test-threads=4(default RTX 3060):1440 passed, 1 failed, 47 ignored(26 SKIPPEDGPU tests: 21no wave64, 3 wave32 per-lanerefused, 1no heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordrequiring Windows Developer Mode; the 1 failure is the unrelated pre-existinggpu::recomp::tests::gpu_clamp_and_omod_per_instruction)Regression run
main (
b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7):PR (
1a51cb95ebd73348679073a39eaab7f185e6fce6):Not tested
ShaderCacheControlpaths, Linux / Wine withoutVKD3D_CONFIG=retain_psos, and non-Windows targets (not built / not tested)XCL_SAMPLE_*external shader packs (unset).\scripts\test.ps1pass (unrelated pre-existinggpu::recomp::tests::gpu_clamp_and_omod_per_instructionfailure on RTX 3060)AI use
XCL-BT-008unclaimed via GitHub REST API, authored failing-first and multi-threaded COM lifetime tests, implemented COM reference retention,late_releasesynchronization, and WARP/no-GPU test guards acrossd3d12x, addressed@bmjaskreview feedback (pso_releaseadd(this) == 2check and pending stand-in2 -> 1 -> 0reset regression), addressed@luckyteagirlreview feedback (nonwaitingresolve_cached_if_pendinginlist_x::splitand extendinga_dispatch_with_a_pipeline_still_building_waits_at_the_submitto bind a real stand-in viaSetPipelineState), rebased ontoupstream/mainb49be1836844, and ranhle::d3d12x, WARP, workspace tests, and 60 s smoke runs@Aniseto on GitHub · 2026-11-25 18:25 UTC · original
Ran the async-pipeline lifetime tests at
8142aa1:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
Results
cargo test -p xcl --lib async_pso -- --test-threads=4: 3 passed, 0 failed (exit 0)cargo test -p xcl --lib pso_async -- --test-threads=4: 12 passed, 0 failed (exit 0)cargo test -p xcl --lib late_release -- --test-threads=4: 3 passed, 0 failed (exit 0)cargo test -p xcl --lib list_x -- --test-threads=4: 34 passed, 0 failed (exit 0)The new lifetime tests (
async_pso_stays_alive_through_command_list_reset_and_gpu_retirement,concurrent_resolve_retained_and_release_never_exposes_freed_pipelineand thelate_releasequeue-retirement case) pass here on a real D3D12 device and command list.What this adds: the author ran these filters on an Ampere RTX 3060; this is a Blackwell wave32 part. No test report from another machine exists in the thread yet.
Not tested: the whole
xcl --librun (the description lists a pre-existinggpu_clamp_and_omod_per_instructionfailure), a paired 60 s smoke run, AMD and Intel GPUs, Wine, release profile, title data.AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
@DavidM1911 on GitHub · 2026-11-25 19:47 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1, 1219/1):The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.
— Devin
@emirduran707 on GitHub · 2026-11-25 19:54 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
75726f769e996fdeae51c37f1a6beb26371f9e98(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1349 passed, 3 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.hle::d3d12x::late_release::tests::unadopted_com_object_is_released_after_queue_retirementandhle::d3d12x::pso_async::used_tests::concurrent_resolve_retained_and_release_never_exposes_freed_pipeline.main:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722) andfuzz_validate_and_gpu_3(seed 1599) on this GPU, plusgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(from50a9fde/ #2074, fixed later onmainin #2420).Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@fixgep on GitHub · 2026-11-25 20:50 UTC · original
Thanks for catching this! Removed the
else if f(this) == 1branch inpso_release(crates/xcl/src/hle/d3d12x/real.rs) so it now matchesres_releaseandpso_async::release: a separate deferred ref is held inlate_release::hold_deferredonly whenadd(this) == 2proves the caller is releasing the actual last ref (1 -> 0), and anyadd(this) > 2call immediately drops its speculative ref viaf(this)and runs the caller's releaselet n = f(this)withheld = false. Also addedasync_pso_lifetime_tests::pending_standin_retained_on_command_list_survives_title_release_until_resetcovering pending stand-in bind/retain (1 -> 2) → titleRelease()(2 -> 1) → command listReset()(1 -> 0) and GPU retirement, rebased ontoupstream/main, and refreshed thehle::d3d12xtest and 60 s smoke runs.@itsSio on GitHub · 2026-11-26 00:12 UTC · original · edited 2026-11-26 00:39 UTC
Two points from reading the diff against
main08db802:CONTRIBUTING.mdsays: "Over ~800 lines, the description must say why it cannot be split." The description doesn't say that yet. @pr1sm-dev's comment on #916 (2026-11-25) describes a ~100-line shape of the list-side retention (one reference per pipeline bound on a PC list, keyed byalloc_pool::recording_backing, dropped indispatch_chain::allocator_reset). That suggests the retention could be one PR and thepso_async/late_releasechanges another.goal:world-load, Linux + NVIDIAvkQueueSubmit2AV) is where @pr1sm-dev stood down their own fix in favour of this PR. If this is meant to fix #916, aFixes #916/Part of #916line and one Linux / Wine run withoutVKD3D_CONFIG=retain_psoswould show it does. The current Tested section is Windows only.I checked
pso_release(real.rs, the hunk at 1716): theelse if f(this) == 1branch from @bmjask's review is gone. The last reference is now held forlate_release::hold_deferredonly whenadd(this) == 2.AI use:
Ran via Samaritan:
The points were checked by the account owner as well (edited to complete this AI use line).
@DavidM1911 on GitHub · 2026-11-26 02:23 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: 1 failure under parallel scheduling; clean on--test-threads=1rerun (1308 passed, 0 failed, 27 ignored, 81s). Intermittent single-test flake — tracked in #1978.Thanks!
— Devin
@bmjask on GitHub · 2026-11-25 20:28 UTC · original · reviewed
P1: pso_release can misclassify a normal 2->1 release as final and double-release a retained pending stand-in. With late release enabled, real.rs:1721-1734 treats f(this)==1 as final, removes async state, and queues a deferred raw Release. But this PR intentionally AddRefs a bound pending stand-in via Resolved/retained_psos, so title Release commonly changes title+list retention from 2 to 1. The branch then reports zero/forgets state and schedules release of the list-owned ref; when the list resets and drops its retained ID3D12PipelineState, it releases that same ref again. Please retain a separate deferred ref only after proving the caller released the actual last ref, and add a bind/retain -> title Release -> list reset regression.
@luckyteagirl on GitHub · 2026-11-26 07:58 UTC · original · reviewed
At head
5333a9b91290a0163e2368bc27e89907c5e4207a, the mid-list split now callsresolve_cached_for_bind(bound_pso, &bound_resolved)(list_x.rs:2855). For a still-tracked compute PSO, that callsresolve_for_bind_retained, which waits for the build (or runs an unclaimed job on the recording thread); the defaultXCL_PSO_WAIT_MSbudget is unbounded. A normalSetPipelineStaterecords the pending PSO in bothbindandlist_x, andbind::dispatchcallsdeferspecifically so the build is waited for at submit. The split therefore blocks insideDispatchbeforedefercan return, losing the record-now/wait-at-submit behavior. Could the split use a retained nonwaiting lookup for the continuation's initial PSO, and extenda_dispatch_with_a_pipeline_still_building_waits_at_the_submitthrough the normalSetPipelineStatepath? That test currently initializeslist_x::bound_psoto zero, so it misses this branch.This is a source-derived timing review of the exact head; I did not run a native timing reproduction. AI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source and drafted this point; I checked the call chain and existing test before posting.
5333a9b912to1a51cb95eb@fixgep on GitHub · 2026-11-26 12:25 UTC · original
@luckyteagirl Good catch, thanks! Changed
list_x::splitto use a non-blocking lookup (resolve_cached_if_pending) so it won't wait before submit, and updateda_dispatch_with_a_pipeline_still_building_waits_at_the_submitto cover this with a bound stand-in PSO (1a51cb95).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.