D3D12.X: release alloc_pool queue fence on queue release #1957
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1967"
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 n-romanovich on 2026-11-25T00:04:04Z.
Fixes #1909.
alloc_pool::State.fencespreviously retained(ID3D12Fence, u64)per command queue indefinitely with no cleanup whenreal::q_releasereleased the queue at refcount 0.This PR adds
alloc_pool::on_queue_release(queue), called fromreal::q_releasewhenn == 0, to drop the queue's retained fence fromState.fencesand clear any already-completedBacking.marksentries for that queue (while leaving in-flight marks alive until completion/reset).What is in it
crates/xcl/src/hle/d3d12x/alloc_pool.rs: addon_queue_release(queue)and unit testreleased_queue_drops_retained_fence_from_state.crates/xcl/src/hle/d3d12x/real.rs: callsuper::alloc_pool::on_queue_release(this as usize)inq_releasewhenn == 0.Tested
Hardware: Windows 11 x64, NVIDIA GeForce RTX 5060 Ti.
cargo test -p xcl --lib alloc_pool -- --test-threads=4: 4 passed, 0 failed, 0 ignored (961 filtered out)cargo test --workspace -- --test-threads=4: 989 passed, 0 failed, 45 ignoredSKIPPED: 22gpu::recompwave64 / refused per-lane f16 tests (no wave64/ refused per-lane f16),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is required,0x887A002D),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Regression run
Main (
5478c4a7c1ae5adba127c8d27018d7fdbf3a8725):PR (
4fffef38d1edb0be45b3c51859b0f711e7f85098):Not tested
AI use
smoke.ps1runs.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T00:26:02Z.
Full-suite run, since this PR has no test report yet. Tested exact head
61db31a(on its basefc14fab).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::dxil::fuzz_tests: 978 passed, 0 failed, 43 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,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.released_queue_drops_retained_fence_from_state.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 988 passed, 0 failed, 45 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 main80f4819too, 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 andconst_and_null_mask_operands_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
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T01:54:19Z.
Code review on
61db31a:crates/xcl/src/hle/d3d12x/alloc_pool.rs,real.rs) andCIworkflow approved (running).#1945(alloc_pool.rs+q_release):#1945additionally moves still-pending queue marks intoBacking.retiredonforget_queue(so a new queue reusing the same address cannot overwrite an in-flight mark) and usescreate_pc_fenceto bypassreal::FENCES. If#1967moves forward instead, it still needsBuild and testgreen plus AMD verification.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T02:54:59Z.
PR #1967 compatibility verification
Tested
61db31aacab5bcc912eb8426f180ba6881d12d2fon STOR-WINLAB. The allocator-pool regression test passed in both runs. The workspace suite exited 101 with 25 failures.Environment
Windows 11 Enterprise Evaluation build 26200.9974, Ryzen 7 3800X, Intel Arc A770 16 GiB with driver 32.0.101.9175. Wave range 8–32,
DoublePrecisionFloatShaderOps=0, and nod3d12SDKLayers.dll. Rust 1.100.0 (0ef1bc386, 2026-11-09), DXC/DXIL 1.9.2609.5, unoptimized builds with debug info and incremental compilation disabled,XCL_ADAPTER=A770.Tested
cargo build --workspaceandcargo test --workspace --no-runsucceeded.cargo test -p xcl hle::d3d12x::alloc_pool::tests -- --nocapturereported 4 passed, 0 failed, 0 ignored, and 0 skip markers.released_queue_drops_retained_fence_from_statesubmitted a D3D12 list, waited for completion, then called the cleanup directly and verified removal of the retained fence and completed backing mark. Source inspection confirmed thatq_releasecalls the cleanup when the native reference count reaches zero.cargo test --workspace --no-fail-fast -- --test-threads=4ran once under the shared Arc lock. Across 20 result summaries, Cargo reported 964 passed, 25 failed, 45 ignored. The log contained 23SKIPPEDlines. Some tests emit multiple markers, and skipped paths contribute no coverage.Of the 25 failures, 20 library tests reported
CreateComputePipelineStateerror0x80070057, and four library tests had result mismatches in fused FMA, implicit-LOD sampling, f16 VALU, and wave reductions. The test-title e2e case failed itsRSSetDepthBiasXcheck (blue pixel, expected green). Skip markers covered 18 wave64 cases, three refused wave32 lowering cases, one driver-cache prerequisite, and one heap-window case.Not tested
Baseline on
main, retail-title smoke, other GPUs, the D3D12 debug layer, or optionalXCL_SAMPLE_*data. The focused test did not exercise the release hook directly, an in-flight mark at release, or queue-address reuse.AI use
T3 Code / Codex (
gpt-6.2-sol,reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity,gemini-4-neon) verified counts againstpr1967-suite.logand published this report.upstream-sync referenced this pull request2026-11-25 04:08:41 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T03:09:12Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T11:12:00Z.
Independent Windows check on 4fffef3. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, debug.
The stock allocator-pool tests passed 5/0/0 with zero skips (
cargo test --offline --locked -p xcl --lib hle::d3d12x::alloc_pool::tests -- --test-threads=1 --nocapture).I also tested simulated queue-key reuse with native D3D12 fences. An unsignaled fence represented the old queue. The backing stayed busy after the release callback. After a new native submission under the same key completed, the backing reported free while the old fence was still unsignaled. The same fixture on #1945’s f581057 kept the backing busy until I signaled the old fence.
The scratch check used
cargo test --offline --locked -p xcl --lib released_queue_key_reuse_keeps_the_older_pending_fence -- --test-threads=1 --nocapture(with-j 4on #1945). It failed the busy-state assertion on #1967 and passed 1/0/0 on #1945, with zero skips in both runs. The fixture only queried eligibility. It never reset a busy allocator or blocked live GPU work. AI-assisted. Codex (GPT-6, exact variant unavailable) wrote the fixture, ran the checks, and drafted this report.Imported from ivall/xcl. Originally posted by thiagocalile on 2026-11-25T16:44:55Z.
Independent test report for head
4fffef38d1edb0be45b3c51859b0f711e7f85098on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).Tested
32.0.21045.29003,XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust1.100.0(stable-x86_64-pc-windows-msvc), DXC1.8.2502.11.XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- alloc_pool --test-threads=4: 5 passed, 0 failed, 0 ignored (0skipped).Regression run (
scripts/smoke.ps1 -Seconds 60, release builds,XCL_ADAPTER=radeon)main(06c9f55):PR
#1967(4fffef3):Not tested: full workspace test suite on this head, NVIDIA/Intel GPUs, Linux/Wine, or world load past the 60 s smoke window.
AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.
Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T18:05:03Z.
AMD RX 7800 XT run of
4fffef38d1edb0be45b3c51859b0f711e7f85098(PR head, as-is).Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on the head: lib 1161 passed, 4 failed, 26 ignored; every other test binary passed. The newalloc_pool::tests::released_queue_drops_retained_fence_from_statepassed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1fails (seed 722:res[30] = 0x1, CPU 0x7fffffff); it fails the same way onmainin my run, so it is not caused by this PR. The other three (pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator,recomp::tests::gpu_image_get_resinfo_past_last_level,d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa) pass on current main, so I think they come from the old base (5478c4a): the branch is behind main.origin/main68a284a596bd558b6bd9db6eedda6d6aa178c360locally (clean merge,cargo test -p xcl --lib): 1219 passed, 2 failed, 26 ignored. The 2 failures are the fuzz test above andlower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier; plainmaingives the same 2 (1218 passed). So no regression from this change on this card.Not tested
scripts/smoke.ps1regression run on a real title (no title I can use for a posted smoke block), so the runtime-change requirement is not met by this report.AI use
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T19:05:08Z.
NVIDIA test report for
4fffef3. RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug, aftercargo build --workspace,cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2:5478c4a): 1217 passed, 2 failed, 46 ignored. The two aregpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translatorandhle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa. Both are stale test expectations thatmainfixed in0d13b071, which this PR's base doesn't have. The PR only touchesalloc_pool.rsandreal.rs, so a rebase ontomainfixes both.mainat569f0fc: 1320 passed, 1 failed, 46 ignored. The one failure isgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier.mainat569f0fcalone, same machine and command: 1319 passed, 1 failed, 46 ignored, the same test. #2420 (merged 18:45Z) fixed that test onmain;mainat2898511is green. So the merge adds one passing test and no failure.hle::xaudio2, because its tests fail or hang on this machine onmaintoo. SKIPPED lines: 26 in the merged run, the same as onmain.AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only; no title run.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:33:32Z.
Review: COMMENTED
P1 queue-address reuse: on_queue_release removes State.fences[queue] but leaves incomplete backing marks keyed by raw queue address. If new queue reuses address before old work completes, executed() creates new fence and b.marks.insert overwrites old incomplete mark, allowing backing reuse while old queue still uses it. Key marks by queue generation/fence identity or retain multiple marks; add release-with-incomplete-submit then same-address-reuse regression. Current test waits completion before release and misses this.
Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:44:08Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-26T04:48:50Z.
Independent NVIDIA test report on exact head
4fffef38d1edb0be45b3c51859b0f711e7f85098(clean detached checkout, no local changes).Tested
32.0.16.2140/ 621.40), AMD Ryzen 5 5500, 32 GB RAM, Windows 11 Home (build 26300), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), Windows SDK10.0.26100.0.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4(debug): 1226 passed, 2 failed, 46 ignored (xcl --lib: 1163 passed, 2 failed, 26 ignored).mainbase (08db802) and pass on currentmain(b49be18):gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator(left: 68, right: 1)hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa(left: 28, right: 85)alloc_pool, integration, ande2etests passed.SKIPPEDGPU tests on this adapter: 20 wave64-only (no wave64), 3 wave32 per-lane f16/f32 semantics, 1no heap windows, 1no d3d12SDKLayers.dll, 1 cannot disable driver cache without Developer Mode (0x887A002D).Regression run
scripts/smoke.ps1 -Seconds 60, release builds oforigin/main(b49be18) and this PR's head (4fffef38):main:
PR:
Not tested
XCL_SAMPLE_*tests; the 60 s smoke run covers boot/intro/menus and does not enter the 3D world.AI use
smoke.ps1commands on this machine and drafted this report from the captured outputs.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T06:51:34Z.
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
Imported from ivall/xcl. Originally posted by throny on 2026-11-27T20:52:36Z.
merge-check claim
head:
4fffef38d1Imported from ivall/xcl. Originally posted by throny on 2026-11-27T21:10:37Z.
merge-check
base:
6089122ahead:
4fffef38d1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1466 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1465 passed, 0 failed, 47 ignored
review: open from the thread and still present on this head: queue-address reuse. After a release, the next execute on a queue at the same address makes a new fence under the same key, and the insert overwrites a mark of the old queue that is still pending; free() and allocator_in_flight then no longer see that work (raised as P1 earlier and confirmed there with a scratch test; read in the code here, not reproduced). The test waits for completion before the release, so it does not reach this case. What it does right: only completed marks are removed, so it does not hide pending work the way #1945's retired list does. Also: on main the presenter keeps a reference to every submitting queue, so this cleanup does not run for them until #1691 lands; and fences made through the hooked device are kept in another table (not verified by a run). #1945 does the same job and the two conflict in alloc_pool.rs and real.rs: one of them.
performance: one scan of the backings per queue release (reasoned).
verdict: not yet: decide between this and #1945; here it needs the address-reuse fix and a test of it.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T00:18:54Z.
merge-check claim
head:
4fffef38d1Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T01:10:58Z.
merge-check
base:
2c717a043chead:
4fffef38d1merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1467 passed, 0 failed, 47 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: none. The suite ran on this PC at the same time as 5 other PRs' suites, in one queued job.
review: none. Whole diff read (alloc_pool.rs on_queue_release + 1 test, real.rs q_release). On the final queue release its retained internal fence is dropped from State.fences and its completed backing marks are cleared; pending marks stay. Note: #1945 changes the same q_release line and covers the same cleanup more fully (pending marks, last_submit); the two conflict.
performance: reasoned, not measured: queue release only; no per-frame cost.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 79dfca9ba40adcd09a79bb4d5dec0f15c4bb8f0d (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Imported from ivall/xcl. Originally posted by akimfomin on 2026-11-28T01:31:32Z.
Pinned pair check:
4fffef38dand #1899 conflict inreal.rseven though the ordinary individual merge is clean. Both cleanup consumers need the final-release notification if they land together. The control is borrowed reference release versus final release, followed by reuse of the queue address: live cache state should survive the first release, both old entries should disappear on the second. This is a source/Git review of the pair.Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-29T16:08:50Z.
Mac test of
4fffef3(D3DMetal):alloc_pool::tests5 passed, 0 failed, includingreleased_queue_drops_retained_fence_from_state, on the PR head as is (it no longer merges cleanly withmain).Tested
x86_64-pc-windows-gnu, debug.cargo test -p xcl --lib alloc_pool::tests -- --test-threads=1(the test binary run under CrossOver): 5 passed, 0 failed.Not tested
main, a title run.AI use: Claude Code with Claude Opus 5.5 ran the tests on my Mac and drafted this report. I checked it before posting.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:09:46Z.
Triage (#1607) – head
4fffef3Main now does what this PR does. Commit
4a4c5f7baddedalloc_pool::forget_queue(QueueId), whichpresent::invalidate_queue_cachesruns from the queue retirement worker once a released queue's GPU work is done. It removes the queue's entry fromState.fences, itsmarkson every backing and itslast_submitentries.That covers
on_queue_releasehere, and it does so after GPU completion instead of at refcount 0. #1945 also touches this, and adds theFENCESpart of #1909 that is still missing.Recommendation: close (superseded by main commit
4a4c5f7b).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:50:06Z.
Closing as superseded: this change is already on
main(4a4c5f7b). main alloc_pool::forget_queue (called from present::invalidate_queue_caches) removes State.fences, backing marks and last_submit for the queue; superset of PR's on_queue_releaseTwo independent checks found this: Foniass's close list on #1607 and ours against current
main. If something here is still missing onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.
Pull request closed