D3D12.X: retain resolved async pipelines until reset and retirement #2407
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by fixgep on 2026-11-25T18:12:27Z.
Close the remaining async PSO fallback, command-list reset, and
pso_releaselifetime gaps on top ofmain's pipeline generation pins (dcfbb49,665ce02,3f91865) andlate_release::hold_pipeline(eb49926b) (XCL-BT-008). Part of #916. Part of #1488.What
mainalready covers vs. what this rebased PR keeps:main'sPipelineResolution,NativeGenerationrecording/submission pins, andlate_release::hold_pipelinealready retain completed async builds through recording/GPU retirement and defer released backing/two-pass pipelines. RedundantResolved/Pending::statetracking from the pre-rebase PR has been dropped.main: (1)real::pso_releasecalledf(this)beforeforget_ready_compute/forget_pso/pso_async::released(address-reuse race even whenXCL_LATE_RELEASE=0) and did not defer the adopted stand-in/PSO itself throughlate_release; (2)InitialFallbackbinds (unbuilt stand-ins withgeneration = None) and PCcl_reset(PreparedNativePipeline::record_generationleaving stalebind::State.resolutionacross resets, plusset_depth_bias_x/prepare_drawre-probingPENDING) left fallback/bound lifetime gaps; and (3)resolve_and_pin_if_enabled*gated one-shot pinning behindrebuild_recipes_enabled(). Rebased ontoupstream/main(6bfb5c51), the diff is 5 files (+817/-102, mostly tests).What is in it
pso_async::resolve_and_pin_if_enabled*regardless ofXCL_REBUILD_RECIPES, alignresolve_and_pin_mode/resolve_and_pin_pendingwithresolve_wait_budgets, and exposeis_trackedandretain_com(crates/xcl/src/hle/d3d12x/pso_async.rs)ListState::retained_fallbacks) inlist_xwheneverbind::select_native_choiceselects an unbuilt stand-in (InitialFallback), propagate them acrossExecuteBundle, mid-list splits, andKickoffX, release them vialate_release::hold_pipeline(unadopted) or normalDrop(adopted) on reset/release, routeset_depth_bias_xandprepare_drawthroughbind::resolve_bound_native_pipeline, and extenda_dispatch_with_a_pipeline_still_building_waits_at_the_submitto bind an adopted stand-in across mid-list splits (crates/xcl/src/hle/d3d12x/bind.rs,crates/xcl/src/hle/d3d12x/list_x.rs)PreparedNativePipelineinreal::cl_resetsobind::State.resolutionpins do not outlive PC list resets, probe final refs inreal::pso_release(add(this)/f(this) == 1) soforget_ready_compute,forget_pso, andpso_async::releasedalways run before final driver release (even withXCL_LATE_RELEASE=0), and defer adopted PSO release vialate_release::hold_adopted_pipeline(orig_fn, avoiding re-enteringpso_release) with unit tests inlate_releaseandreal::async_pso_lifetime_tests(crates/xcl/src/hle/d3d12x/late_release.rs,crates/xcl/src/hle/d3d12x/real.rs)Tested
32.0.16.2140), AMD Ryzen 5 7500F 6-Core Processor, Windows 11 x64 (10.0.26200.0),rustc 1.100.0 (0ef1bc386 2026-11-09)(stable-x86_64-pc-windows-msvc), plusXCL_ADAPTER=warp; debug and release (6908ee6d6208b86e573187209c2ba719bd6ed751onupstream/main6bfb5c5153ccc23517daf30aa1071ddb0fadb53c)cargo build -j 4 --workspace,cargo test -j 4 --workspace --no-run, andcargo build -j 4 --release -p xcl: exited0, 0 new compiler warnings (36 pre-existing inxcllib vs. 39 onupstream/main; 17 pre-existing inxcllib tests)--test-threads=1):cargo test -j 4 -p xcl --lib late_release -- --test-threads=1:9 passed, 0 failed, 0 ignored(0SKIPPED)cargo test -j 4 -p xcl --lib pso_async -- --test-threads=1:193 passed, 0 failed, 0 ignored(0SKIPPED)cargo test -j 4 -p xcl --lib hle::d3d12x::bind -- --test-threads=1:116 passed, 0 failed, 0 ignored(1 SKIPPED:two_pass_binds_set_the_shared_view_heap, opt-inXCL_HEAP_WINDOWS=1)cargo test -j 4 -p xcl --lib hle::d3d12x::list_x -- --test-threads=1:114 passed, 0 failed, 0 ignored(0SKIPPED)cargo test -j 4 -p xcl --lib hle::d3d12x::console_list -- --test-threads=1:11 passed, 0 failed, 0 ignored(0SKIPPED)cargo test -j 4 -p xcl --lib hle::d3d12x::device_x -- --test-threads=1:23 passed, 0 failed, 0 ignored(0SKIPPED)cargo test -j 4 -p xcl --lib hle::d3d12x::real -- --test-threads=1:178 passed, 0 failed, 0 ignored(0SKIPPED)XCL_ADAPTER=warp(--test-threads=1):late_release:9 passed, 0 failed, 0 ignored;pso_async:193 passed, 0 failed, 0 ignored;hle::d3d12x::bind:116 passed, 0 failed, 0 ignored(1 SKIPPED:no heap windows);hle::d3d12x::list_x:114 passed, 0 failed, 0 ignored;hle::d3d12x::console_list:11 passed, 0 failed, 0 ignored;hle::d3d12x::device_x:23 passed, 0 failed, 0 ignored;hle::d3d12x::real:178 passed, 0 failed, 0 ignored(1 SKIPPED:gpu_image_load_of_a_stencil_view_gives_the_stencil,no wave64)Regression run
main (
6bfb5c5153ccc23517daf30aa1071ddb0fadb53c):PR (
6908ee6d6208b86e573187209c2ba719bd6ed751):Not tested
cargo test --workspaceexecution (only--no-runand the 7 targetedhle::d3d12xtest modules above ran on RTX 3060 and WARP)VKD3D_CONFIG=retain_psos, non-Windows targets (not built / not tested)XCL_SAMPLE_*external shader packs (unset)AI use
upstream/maingeneration pins (dcfbb49,665ce02,3f91865) andlate_release::hold_pipeline, rebasedfix/pso-async-lifetime-retentionontoupstream/main6bfb5c51by dropping superseded retention logic and rebuilding the remainingInitialFallback/cl_reset/pso_release/ one-shot-pin fixes, updatedlate_releaseandreal::async_pso_lifetime_testsregression tests, and ran the builds, targeted RTX 3060 + WARP tests, and paired 60 s smoke runs.Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-25T18:25:18Z.
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.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:47:37Z.
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
Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T19:54:44Z.
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
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:28:30Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by fixgep on 2026-11-25T20:50:13Z.
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.Imported from ivall/xcl. Originally posted by itsSio on 2026-11-26T00:12:43Z.
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).
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:23:52Z.
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
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T07:58:31Z.
Review: COMMENTED
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.
Imported from ivall/xcl. Originally posted by fixgep on 2026-11-26T12:25:46Z.
@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).Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:34:19Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:00:22Z.
Triage (#1607) – head
6908ee6No open PR makes the same change. #2422 also changes
real.rs:pso_releaseso thatforget_psoruns before the last driver release, but only for the address-reuse race. Hereforget_psoandpso_async::releasedrun before the final driver release whether or not late release is enabled.Main has since reworked this area: native pipeline generations are pinned in recordings (
dcfbb49c,665ce029,3f91865b), andpso_releasenow hands the real pipeline tolate_release::hold_pipeline.6908ee6dis rebuilt on that rework and only closes the gaps left on top of it.The diff is now +817/-102 across 5 files. The description argues it cannot be split, but the
pso_release/late-release part and the list-side retention look separable.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.