D3D12.X: drop shared heap locks during CopyDescriptorsSimple and clamp publish_range to heap bounds #2631
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!2631
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2631"
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?
@Decodere on GitHub · 2026-11-26 03:19 UTC · original
Decodere:fix-console-heap-publish-lock-and-bounds→main· +426 −37 · 1 files · 1 commits · openWhat is in it
Drops shared descriptor-heap locks (
GLOBAL/GLOBAL_SAMPLER/HEAPS) before callingID3D12Device::CopyDescriptorsSimpleon the hot descriptor publish path, clampspublish_rangestrictly to each heap's bounds, and defers recycling of in-flight destination ranges until copies complete (crates/xcl/src/hle/d3d12x/console_heap.rs):publish(s, uav): snapshotsdevfromGLOBAL_SAMPLER(or(dev, inc)fromGLOBAL), records a zero-allocationSingleLeaseon the destination slot (dst_base..dst_base + 1) under that lock, and drops the mutex guard before callingCopyDescriptorsSimple, avoiding global lock serialization across D3D12 device calls and re-entrancy hazards with adopted device hooks.publish_range(first, n): returns early onn == 0; acquiresHEAPSfirst and thenGLOBAL_SAMPLER/GLOBAL(preserving the strictHEAPS -> GLOBAL*lock order); collects(dst, src, count)runs in a singleHEAPSpass clamping each run toh.n - start_kand page boundaries (preventing overruns past tightly sized small/tail pages into adjacent shared-heap ranges, with a standalone syntheticSlotfallback when not registered inHEAPS); registers destination run leases inRangeLeaseunderGLOBAL*while still holdingHEAPSso a concurrentunregister()cannot recycle those destination ranges before leases are recorded; drops both locks and executes everyCopyDescriptorsSimplecall with zero locks held.LeasePool):GlobalandGlobalSamplertrack active destination leases (leased) and ranges freed while leased (deferred).release_global/release_global_samplerdefer any released range overlapping an active lease without blockingunregister(), and droppingSingleLease/RangeLeaseimmediately promotes newly unblocked deferred ranges back intofree(coalesced).vt[24] = CopyDescriptorsSimple, zero GPU/UMA required):publish_and_publish_range_do_not_hold_locks_during_device_calls: assertsGLOBAL,GLOBAL_SAMPLER, andHEAPSare unlocked duringCopyDescriptorsSimplefor singlepublish(SRV, UAV, Sampler) and multi-pagepublish_range(views and samplers), and checks exact descriptor counts and CPU handles.publish_range_clamps_to_heap_bounds_without_overrunning_tail_pages: registers a 4-slot view heap, a 3-slot sampler heap, and a 260-slot view heap (4-slot tail page) and verifiespublish_rangeextending pasth.nclamps strictly toh.n - start_kwith zero overrun (n == 0emits zero calls).publish_leases_prevent_unregister_range_reuse_while_copy_in_flight: blocks a worker thread inside mockCopyDescriptorsSimplefor singlepublish, multi-page viewpublish_range, and samplerpublish_rangewhile the main thread callsunregister+reserve_global*, verifying zero overlap with the in-flight destination range, verifying all locks stay unlocked duringCopyDescriptorsSimple, and verifying full slot reclamation as soon as the copy finishes.Part of #2508
Part of #1833
Tested
origin/main(b49be183) with the lock-free/bounds tests (cargo test -p xcl --lib hle::d3d12x::console_heap::tests::publish_ -- --test-threads=1 --nocapture): 0 passed, 2 failed (CopyDescriptorsSimple ran while GLOBAL, GLOBAL_SAMPLER, or HEAPS was locked;publish_rangeoverran tail pages with 20 vs 6, 7 vs 2, and 28 vs 8 descriptors).XCL_ADAPTER=warp,XCL_WARP=1,cargo test -p xcl --lib -- hle::d3d12x::console_heap::tests:: --nocapture): 15 passed, 0 failed, 0 ignored, 0 skipped.XCL_ADAPTER=warp,XCL_WARP=1,cargo test --release -p xcl --lib -- hle::d3d12x::console_heap::tests:: --nocapture): 15 passed, 0 failed, 0 ignored, 0 skipped.cargo test --release -p xcl --lib -- hle::d3d12x::console_heap::tests:: --nocapture): 15 passed, 0 failed, 0 ignored, 0 skipped.cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture): 37 test binaries (36 compiled + 1 doc-test), 1438 passed, 0 failed, 47 ignored, 29SKIPPEDlines:no wave64on wave32-only RTX 4060 (dispatch_chain_native_wave64_builds_whole, 4 ingpu::recomp::lower, 14 ingpu::recomp::lower_dxil, 2 ingpu::recomp::tests)per-lane form: refusedingpu::recomp::lower_dxil(f16 arithmetic, f16 packed, f32 conversions on wave32)no d3d12SDKLayers.dllx2,uploads_start_from_each_subresources_state)cannot disable the driver cache(shaders::tests::pso_measurement_compiles_an_exact_synthetic_record)no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form)Regression run
Paired 60-second smoke runs on NVIDIA GeForce RTX 4060 against
origin/mainancestor (889ef3e8aa7f267323ab4879e735e65da6bcef10, ancestor ofb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7):PR head:
Base (
origin/mainancestor):Both runs exit
0x0with steady60 60 60presents per 2 s, 0 device removals, and 0 crashes (1518 vs 1550 frames, 97.9%; peak commit 14001 MB vs 13981 MB).Not tested
d3d12SDKLayers.dllis not installed on this host; 3 tests skipped).CopyDescriptorsSimple(lock-release and unregister-lease behavior are verified deterministically via synchronized mockID3D12Device::CopyDescriptorsSimplecallbacks).#[ignore]tests.AI use
Written and verified with Google Antigravity (Gemini 4 Neon). Every change in
console_heap.rs, the failing-first reproducer, the debug/release WARP, RTX 4060, and full workspace test runs, and the paired 60 s smoke runs were verified locally.@pickles976 on GitHub · 2026-11-26 03:29 UTC · original
Exact PR head
3b49f094ec06e7f7a8c1f6d085b42f62382390bf, Windows-target Wine 11.0/vkd3d-proton 3.2.0 on a 16 GiB RTX 4060 Laptop host: focusedhle::d3d12x::console_heap::tests::publish_2/2 passed, 0 skipped/ignored, after a confirmed fresh compile from the clean head checkout. The mock-COM callback observed all three shared heap locks released for both single and multi-pageCopyDescriptorsSimple, and the tightly sized view/sampler/tail heap cases clamped exactly to the heap ends. Log:.compat-xcl/logs/verify-pr2631-wine-rtx4060-descriptor-publish.log(not attached).These are CPU/mock-device fixtures: the actual NVIDIA GPU was not exercised by the tests, and I have no matched parent run or live title contention/frame-time data on this laptop. The existing stock-vkd3d console-facing in-place D3D12 object/root-signature assertion (#175) still blocks a safe XCL retail-title comparison on this host; this positive result does not imply that blocker or our 16 GiB world-load limit is solved.
3b49f094ecto40a9bcc980@Decodere on GitHub · 2026-11-26 05:59 UTC · original
@luckyteagirl Good catch — pushed
40a9bcc9to preventunregister()/release_global*()from recycling destination descriptor ranges while a lock-freeCopyDescriptorsSimpleis in flight:GlobalandGlobalSamplernow track active destination leases and deferred releases (LeasePool):publishtakes a zero-allocationSingleLeaseunderGLOBAL*, andpublish_rangetakes aRangeLeaseunderGLOBAL*while still holdingHEAPS(preserving strictHEAPS -> GLOBAL*lock order) before dropping both locks forCopyDescriptorsSimple.release_global/release_global_samplerdefer ranges overlapping an active lease without blockingunregister(), and dropping the RAII lease guard promotes unblocked ranges back intofree.publish_leases_prevent_unregister_range_reuse_while_copy_in_flightverifying singlepublish, multi-page viewpublish_range, and samplerpublish_rangehold off reuse during concurrentunregister()+reserve_global*(), keep all locks unlocked duringCopyDescriptorsSimple, and reclaim the slots once the copy finishes.console_heap::tests::(15/0/0), full release workspace (1438/0/47), and paired 60 s RTX 4060 smoke (1518frames,60 60 60,0removals/crashes).@luckyteagirl on GitHub · 2026-11-26 04:38 UTC · original · reviewed
The new
publish()snapshotsGLOBALand releases its lock beforeCopyDescriptorsSimple;publish_range()likewise collects shared destination handles and releasesHEAPSbefore its copy loop.unregister()can then remove that title heap and immediately return its shared ranges throughrelease_global, where a new heap can reserve the same indices. Interleaving: T1 captures a destination, T2 unregisters the old heap, T3 reserves its freed range, then T1's delayed copy overwrites T3's descriptors. The previous copy underGLOBALprevented that particular reuse until the copy finished. Could these destination ranges be leased until their copies complete, while keeping the device call outside the locks? A mock callback test that blocks a copy while another thread unregisters and reallocates the range would cover it. This is a source-derived concurrency point; I did not run a title or test this interleaving.@Aniseto on GitHub · 2026-11-26 10:25 UTC · original
Ran the descriptor-heap publish tests at
40a9bcc9:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves 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.
All three new subprocess-isolated tests pass here: no heap locks held during
CopyDescriptorsSimple,publish_rangeclamped to the registered heap bounds, and leases preventingunregisterfrom recycling an in-flight destination range. They use a mock COM device, so they do not measure NVIDIA GPU performance.What this adds: the author ran the targeted tests on WARP and an RTX 4060; this is a second NVIDIA host (Blackwell, different driver/DXC). The thread has no report from another machine.
Not tested: a live multi-threaded contention benchmark, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, native wave64, 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.
github-bot referenced this pull request2026-11-26 12:40:17 +00:00
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.