D3D12.X: a reused spare keeps the allocator of deferred work still on the GPU #2549
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!2549
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2549"
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?
@tiagonleal on GitHub · 2026-11-25 22:41 UTC · original
tiagonleal:own-allocator-kept-until-work-done→main· +128 −1 · 1 files · 1 commits · openSince #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 on468f8dfb. 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 heada0418344, not repeated on468f8dfb), 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 onmain6d12f58awithout this change (127 of 421 in an earlier run here).cargo test --workspace --no-fail-fast -- --test-threads=4, run twice on468f8dfb: 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(e1d84b7d):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
@xpatfussy69x on GitHub · 2026-11-25 22:57 UTC · original
Test run on exact head
a041834(a041834420f21e8d80e3eb76ee85d180b6509993, on its basee1d84b7, currentmain), clean tree.Tested
cargo test --workspace -- --test-threads=4: 1424 passed, 0 failed, 46 ignoredV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32(onmaintoo)cargo test -p xcl --lib a_spare_reused_by_a_split: 1 passed, 0 faileda_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpu: okcrates/xcl/src/hle/d3d12x/list_x.rs(git merge-treeof both heads); whichever lands second needs a rebaseRegression run (60 s, default settings, a retail title)
main:
this PR:
No crash or device removal; frames 101 % of
main's, peak commit 100 %.Not tested
AI use
@futurepro62 on GitHub · 2026-11-25 22:55 UTC · original · edited 2026-11-25 23:00 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
a041834(on its basee1d84b7).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1412 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,dispatch_chain_native_wave64_builds_whole,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.a_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpu.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1423 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on maine1d84b7too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 23:06 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
@emirduran707 on GitHub · 2026-11-25 23:43 UTC · original
Independent AMD RDNA4 (native wave64) verification of exact PR head
a041834420f21e8d80e3eb76ee85d180b6509993on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC1.9.2602.17).Tested
cargo build --workspace(debug): passed (0errors).cargo test --workspace --no-fail-fast -- --test-threads=4:1422 passed, 2 failed, 46 ignored(8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1heap_window_out_of_memory_falls_back_to_the_switch_formno heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordWindows Developer Mode off).hle::d3d12x::list_x::tests::a_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpupassed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3) are pre-existing on unmodifiedmainon this RX 9060 XT / driver32.0.31044.16.cargo build --release -p xcl+ 60 s retail-title smoke test (scripts/smoke.ps1, offline; first attempt exited early with no frames logged, second 60 s run completed cleanly):(Compare against
main08db8020on this machine:1553 frames, 13966 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@xpatfussy69x on GitHub · 2026-11-26 00:18 UTC · original
A question on
a041834: the movedown_allocnow lives in the state of a split segment, not a recording's first segment.reset_own_allocruns fromreset_pcanddeferred_segmentreads the first segment'sown_alloc, and split segments are reset throughalloc_pool::reset_list, so as far as I can see nothing resets the inherited allocator once its GPU work is done. Its split dispatches' scratch (dispatch_chain::RECORDINGS, freed inallocator_reset) would then stay charged againstXCL_SPLIT_SCRATCH_TOTAL_MBuntil that segment's state is removed. Is that intended, or shouldsplitreset it (or drop it) onceallocator_in_flightsays the GPU is done?AI use: Claude Code (Claude Opus 5.5) reviewed the diff; I checked the reasoning but did not reproduce it.
@SlopTart on GitHub · 2026-11-26 05:04 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.Targeted run of
a_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpu: passed.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.
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 22:41 UTC · original · reviewed
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.
@GodlyBDS on GitHub · 2026-11-26 11:00 UTC · original · edited 2026-11-26 11:08 UTC
RTX 3090 Ti Windows validation of the allocator-lifetime regression
Windows 10, NVIDIA 621.40, Rust 1.98.1 MSVC. Local
nvidia-dev af2cecc40886a8682ecf3267f5328c6dc4b66ad7with the same startup and memory diagnostics on both arms. Backporteda041834420f21e8d80e3eb76ee85d180b6509993, adapting the test's list-state access to the NVIDIA branch's per-list shard. The fixture releases the synthetic queue wait before asserting its collected observations.a_spare_reused_by_a_split_keeps_an_own_allocator_still_on_the_gpupasses with the two production changes (1 pass, 0 failures, no skips). With those two changes removed, it fails as expected after GPU completion (observed COM count 2, expected 3).splitwith0xc0000005in both the patched and unpatched tree. This predates the backport. Two existing neighboring tests (a_reset_while_the_last_submit_runs_records_on_another_pc_listanda_dispatch_with_a_pipeline_still_building_waits_at_the_submit) passed on the patched tree with the configured SDK directory. Exact cause of the Agility-specific fixture failure remains open.The unpatched af2 retail run had its render thread in native command-list Reset under
record_deferredafter the final logged native PSO creation had finished. It was stopped after several minutes with no submits, and did not log device removal. This is a separate observed symptom. The synthetic test confirms the ownership repair, and it does not yet establish a connection to that retail stall. A matched-cache replay with the backport and read-only allocator fence logging is running.Matched retail replay update. The backport reproduced the same submit-thread native
Resetwait on this NVIDIA branch. The last logged native PSO finished at 149.162 s. At 195.037 s the submit thread was in D3D12Core belowalloc_pool::reset_list → list_x::record_deferred. Added allocator fence samples show one queue at submitted 6 and completed 5 from 88.317 s through the controlled window close after 323 s. The four other tracked queues were caught up in the static interval. No new device removal was logged. This backport did not resolve that stall in one matched-seed traversal. The pending submission's producer and contributing lifetime remain under investigation. The observedwin32u.dlloffset is inside that installed binary’sNtGdiDdDDIDestroyAllocation2export. That places the block in the native allocation-destruction path underReset, without identifying the destroyed allocation.AI use: Codex (GPT-6) adapted the backport and fixture, ran these tests and wrote this report.
a041834420to468f8dfb3d@tiagonleal on GitHub · 2026-11-26 11:52 UTC · original
That was not intended. After a split reuses the spare, the list is reset only through
alloc_pool::reset_list, soreset_own_allocinreset_pcnever runs for the moved allocator, and the scratch of its split dispatches stayed charged againstXCL_SPLIT_SCRATCH_TOTAL_MB.Fixed in
468f8dfb(the two commits are squashed into it, and the message no longer saysreset_pcresets the allocator).splitnow keepsown_alloconly whileallocator_in_flightsays the GPU may still run work recorded on it. Once the GPU is done with it, it goes with the old state and is released outside theLISTSlock, as before this PR. New test:a_spare_reused_by_a_split_drops_an_own_allocator_the_gpu_is_done_with.Run on
468f8dfb:cargo test -p xcl --lib -- a_spare_reused_by_a_split, 2 passed, 3 of 3 runs. The first test fails without the change (reference count 2, expected 3). The second fails when the allocator is moved unconditionally, as in the first version of this PR.cargo test --workspace --no-fail-fast -- --test-threads=4, twice: 1421 passed, 4 failed, 46 ignored; the 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(E_OUTOFMEMORY, known on this machine). 60 s smoke runs one1d84b7dand468f8dfb: both exit 0, no device removals, 1625 and 1619 frames shown (a first run ofe1d84b7dgave 914 frames, so I repeated it).Not run: the four fuzz tests on
maintoday.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.