D3D12.X: couple deferred sync-cell publication to stored memory #2439
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!2439
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2439"
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?
@LANgmas on GitHub · 2026-11-25 18:55 UTC · original
LANgmas:d3d12x/sync-cell-store-before-publication→main· +1155 −41 · 2 files · 2 commits · draftOpen for design review — draft. The integration relationship with the existing deferred-Write64 work (#850, #562/#1643/#1819) is an open maintainer design question; coordination comment: #1607 — please read it before reviewing shape rather than detail.
What and why
On console,
Write64BitValue*progress values are written by the GPU itself in execution order, so a consumer that observes a fence value can rely on the memory content being present. XCL defers non-aperture writes to CPU worker threads, and for writes to registered sync cells two ordering defects result:0x0); with this change it reads the written value.The invariant this change implements: a deferred sync-cell value must not be published to consumers before the corresponding CPU store has actually completed.
What is in it
list_x.rs(+175 production, first commit): classify registered sync-cell MARKER_OUT writes at the realwrite64_bottom_xinterception path;stored_max/cpu_signaled_maxwatermark separation on the sync cell;sync_cell_deferred_storeserializing staleness decision + memory store + watermark update + publication in one critical section per cell; publication gating so the consumer-visible fence never leads confirmed stored memory; stale-store suppression; consumer publication retry and fence backfill for late consumers; signal suppression in the GPU path; cycle-break participation in the stored watermark.cpu_writes.rs(+144/−30): per-queue workers;Write::SyncU64carrying the cell generation; strict producer-fence completion for classified writes; confirmed-store contracts; queue-release cancellation with a bounded grace — abandoned jobs never store and never publish; bounded device-gone exit of the strict wait.list_x.rs(+30 production, second commit336c6c2): the same-batch deferred self-wait resolution — see below.Same-batch deferred self-wait (second commit
336c6c2, in response to review)bmjask's review found that a deferred sync-cell write followed by a wait on the same cell in the same command list can take
try_gpu_wait's same-batchCycleSkip— treated as handled — while the deferred CPU store only happens after submission, so work ordered behind the wait executes before the marker exists.Investigation refined the picture:
device_x.rswraps every title-created command list) and the record-time split moves such a wait into its own PC segment; the write and the wait never share a submission. This path already orders correctly — pinned byd19_title_list_self_wait_orders_the_work_recorded_after_it, which records write → wait → copy in ONE title list through a realtitle_listwrapper and proves the copy is held until the store publishes. It passes before and after the second commit.XCL_SPLIT_MIDLIST_WAIT=0) were the real defect: the wait stayed on the same list andCycleSkipsilently discarded it. Reproduced through the production chain —write64_bottom_x/wait64_x/execute_with_waits_on/signal_write64_fences/cpu_writes_after— ind19_deferred_self_wait_is_not_dropped_for_following_work.What
336c6c2does in the residual case: the wait is neither hoisted (a GPU wait before the list would deadlock — the strict store needs this list's own completion) nor skipped. The list is submitted alone, then the deferred self-wait is enforced on the submission thread — bounded by the existing 2 s wait timeout with a warning — before anything after it is submitted. Waits recorded before their producing write keep the existing skip: no ordering can satisfy those and none is promised. Submission granularity already varies in this path (batches are split around waits), so the solo submit is not a behavior change in kind.Known remaining limitations (not resolved cases)
wait_all_onbefore a single exec). It is deliberately unmodified: no production-path regression test currently proves the defect there, and this PR only fixes what is reproduced. It is a separate unclosed investigation.Wine/vkd3d reports (SlopTart) — investigated, not resolved
Two deterministic failures on Wine/vkd3d-proton 3.1, reproduced solo at
--test-threads=1and unchanged when combined with #2499:d11_consumer_cannot_observe_deferred_value_before_the_cpu_store— the dependent copy executes early and reads0x0(~0.42 s, no watchdog involvement).d11_publication_not_memory_releases_the_consumer— the store itself never lands within 5 s; the armed-wait watchdog releases at ~5.1 s as a symptom.Source-level analysis (no Wine lane was available for verification): both shapes are consistent with one backend divergence — on vkd3d-proton, device-side
queue.Waitnot observing host-sideID3D12Fence::Signalthe way native D3D12 does. This design depends on that behavior inherently: a CPU-side store can only ever be published by a CPU-side signal, and the only correct release path is host-side publication after the store. This is a hypothesis, not a proven universal cause — pinning it needs a Wine lane with vkd3d debug logging. The failures are not fixed; the tests are not weakened or skipped; on native Windows both pass deterministically (11/11 twice).RTX 3060 Ti recompiler report (DavidM1911) — exact-parent control negative
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierwas reported failing on RTX 3060 Ti. This PR touches onlycpu_writes.rs/list_x.rs. Control run on RTX 3050,cargo test -p xcl --lib gpu::recomp::lower_dxil -- --test-threads=1:2898511af1c038a2ef809719e9b6f89e5675c422→ 21 passed / 0 failedCurrent evidence does not attribute the failure to this patch. One provenance question remains open: the reported panic line (
lower_dxil.rs:1155, pre-c828d8cassertion text) does not match any tree this PR or its base could produce, so the reporter's exact tested SHA is unresolved and the hardware difference (3060 Ti vs 3050) cannot be excluded.Tested
Hardware: RTX 3050 Laptop, real D3D12, Windows. Base commit
2898511af1c038a2ef809719e9b6f89e5675c422(upstream main at branch creation). Test categories below are deliberately kept separate — they are not interchangeable evidence.Production-path regression tests, real hardware, at head
336c6c2eeafbef907e3d47c72624158a3c52f2d0(--test-threads=1throughout, deliberate: several tests share global injection slots):cargo test -p xcl --lib d19_→ 2/2, 5/5 consecutive runs; the same tests fail 3/3 runs on the same tree with only the enforcement logic reverted (fail-before proof: the copy behind the dropped wait reads0x0, with the exactskipped to avoid same-batch self-deadlocklog line)cargo test -p xcl --lib d13_→ 3/3cargo test -p xcl --lib d11_→ 11/11, two consecutive runscargo test -p xcl --lib hle::d3d12x(module regression) → 260 passed / 1 failed / 2 ignored — the one failure (bind::execute_indirect_reads_the_arguments_written_before_itatbind.rs:1225:13) is byte-identical on pristine upstream in a path this patch does not touchExact-parent controls:
gpu::recomp::lower_dxilmodule: base2898511a21/21 = head 21/21 (above)3f2777019544c0ada2cd294aa792d3c378ff0df8: module regression 258/1/2 vs pristine same-SHA baseline 244/1/2 — delta exactly the 14 added tests, zero collateralBackend-specific evidence (reporter's lane, not reproduced locally): Wine/vkd3d-proton 3.1 — two deterministic failures analyzed above, unresolved.
Injected-seam tests (clearly labeled
cfg(test)): device-removal worker exit and publication-failure injection are test-only seams at the decision boundary — not physical GPU removal, not production behavior.Not tested
scripts/smoke.ps1regression blocks not yet run (merge prerequisite; will produce them if this moves toward merge readiness).AI use
Implementation, tests, verification and this description prepared with Devin CLI, SWE-2.1 Max under human direction; all test counts are real executions on the hardware named. Multi-phase independent review of the invariants (line-cited), evidence-gap closure, and repeated forward-port verification preceded this PR.
@SlopTart on GitHub · 2026-11-25 19:46 UTC · original
FAILS on the Wine/vkd3d lane: 2 of the 11 new
d11_*sync-cell tests fail here, deterministically (3/3 solo at--test-threads=1); I have no native run of this head to compare against. Head534529f1on top of current main; suite160 passed; 4 failed(baseline quartet), then targetedd11_runs: 9 passed / 2 failed, 24 s.The two have different signatures:
d11_publication_not_memory_releases_the_consumer: fails atlist_x.rs:7508after 5.12 s, i.e. thexcl-sync-watchdogreleases the bridged GPU wait on the CPU:GPU queue.Wait at 0x3e1220 >= 0x64 did not complete within 5000 ms (waiter=q0/ty0, prod=qSome(0)/tyNone, recorded=0x64, submitted=0x64, completed=0x0) - released on CPU to prevent GPU hang. On this lane (vkd3d-proton 3.1) the fence the wait keys on never completes, so the test's premise "consumer stays blocked on the GPU" turns into "watchdog releases at 5 s" before the assertion.XCL_GPU_WAIT_RELEASE_MS(#1046) may be the intended lever for tests that arm this path.d11_consumer_cannot_observe_deferred_value_before_the_cpu_store: fails atlist_x.rs:7377in 0.42 s, a plain assertion, no watchdog log. This one is not a timing artifact; it is a straight behavioral divergence on this lane.Other nine
d11_*tests pass, including the watchdog-release and cross-queue monotonicity ones.gpu_suite (cold cache): 160 passed / 4 failed, no crashes. Three are the known baseline trio on this lane; the fourth isgpu_promoted_uav_clear_values_pass_create_committed_resource, newly red on main since #2280 (report), unrelated to this PR.@DavidM1911 on GitHub · 2026-11-25 20:04 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
@SlopTart on GitHub · 2026-11-25 21:08 UTC · original
Follow-up on the two Wine-lane reds from my earlier comment: re-tested this PR's
d11_*tests on a merge of this head plus currentorigin/mainplus #2499's armed-wake watchdog fix.Still
9 passed; 2 failed, same two tests, same timing:d11_consumer_cannot_observe_deferred_value_before_the_cpu_storeat 0.42 s (assertion atcrates/xcl/src/hle/d3d12x/list_x.rs:7377) andd11_publication_not_memory_releases_the_consumerat 5.1 s (released by the GPU-wait watchdog, not by the publication).So #2499's fix (watchdog not missing a wake armed during its check) does not cover these two. The shape that stays red on wine-11.0 / vkd3d-proton 3.1 is: a bridged Wait64 whose producer store is made on the CPU side never takes the memory-release path here, and the consumer-observation assertion at
list_x.rs:7377fails outright rather than by timeout. Deterministic on this lane (both reproduce solo at--test-threads=1).@LANgmas on GitHub · 2026-11-26 05:08 UTC · original
Thank you all for testing and reviewing this so quickly. Conversation comments and review summaries can't be threaded, so each section below links the item it answers. The PR stays a draft while these are open.
@SlopTart: Wine/vkd3d report (comment)
Thank you for the deterministic reproduction, and in particular for keeping the two signatures apart; that separation is what makes this actionable. Both are real findings, and nine passing tests do not offset them.
d11_consumer_cannot_observe_deferred_value_before_the_cpu_store, 0.42 s, no watchdog log. Agreed that this is not timing noise. At this PR's head,list_x.rs:7377is theobserved == 100assertion ("released before the CPU store landed"), which comes after the sentinel check. Read that way, the dependent copy ran and read something other than 100, so the ordering this PR exists for does not hold on that lane.d11_publication_not_memory_releases_the_consumer, 5.12 s, with the watchdog releasing the bridged wait (completed=0x0). At this head,:7508is the 5 s wait for the worker's store ("store never landed"). Read that way, the store itself did not arrive within 5 s of the producer hold being signalled, and the watchdog release is the same absence seen from the consumer side.I will investigate these as two separate items: what released the consumer and what the copy read in the first, and why producer-side completion and the bridged wait do not progress on vkd3d-proton in the second.
XCL_GPU_WAIT_RELEASE_MSlooks useful there as a diagnostic lever; I won't treat a different timeout as a fix.Both line numbers land on assertions inside the named tests at the PR head, which is why I read them as above. If your merged tree numbered them differently, the panic strings from the logs you already have would settle it; no rerun needed.
@DavidM1911: RTX 3060 Ti run (comment)
Thank you for the independent run on a second NVIDIA card. Acknowledged:
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierfails deterministically in your tree.This PR changes only
cpu_writes.rsandlist_x.rs, but that alone does not show the failure is unrelated. I will run an exact-parent control: that test at this PR's head and at its parent on main, same machine and settings, and report whether it is pre-existing on that base, introduced here, or an interaction in the merged tree.One detail to pin down the tested tree: the message you quote (
group barriers in the program,lower_dxil.rs:1155) is the form that assertion had before #2420 (c828d8c). This PR's head, its base2898511aand current main all carry the later form (group barriers after entry branch, line 1156). Which main commit was merged into the tree you tested?@bmjask: P1 review (review)
Thank you. This is a control-flow case the PR misses, and your description of it is exact. I traced it at head
3e12eda:try_gpu_waitreaches the same-batch self-wait branch (sub_max < w.value, andlist_writescontains the producer) and returnsCycleSkip. That branch has nodeferredcheck, unlike the same-queue FIFO branch directly above it;wait_all_ontreatsCycleSkiplikeHandled, soexecute_with_waits_onsubmits the list whole;SyncU64store runs on the worker only after that submission's producer fence completes;That is a correctness gap against what this PR claims. The branch itself is inherited from main, but the deferred-aware check added here should have covered it.
Agreed that
queue.Waitis not the fix: hoisted ahead of the submission that contains the producer, it waits on a fence the worker publishes only after that same submission completes, so neither can make progress.I will write the exact regression first (deferred write, same-list wait, GPU work after it, through the production record and wait path), then look at an ordered split/submit at the wait or another mechanism that keeps queue order and cannot deadlock. So far this is traced by reading, not reproduced. The review stays open until a test shows the behaviour before and after.
@SlopTart: follow-up with #2499 (comment)
Thank you for the extra combined-tree run; it rules out something I would otherwise have had to guess at. Acknowledged: with this head, current main and #2499's armed-wake fix merged, the same two tests stay red with the same timings, so #2499 does not address them.
I will keep two things apart. One is the watchdog missing a wake armed during its check, which is what #2499 fixes. The other is what you describe here: on wine-11.0 / vkd3d-proton 3.1, a bridged Wait64 whose producer store is made on the CPU side does not take the memory-release path, and the consumer-observation assertion fails outright rather than by timeout. Both stay on the list as separate items.
AI use: written with Devin (Claude Fable 5.2 High) under human direction. Nothing in this comment is a new test result; the code reading above is of the PR head
3e12eda.@LANgmas on GitHub · 2026-11-26 05:53 UTC · original
@bmjask — follow-up on your P1 review (posted as a conversation comment because the review has no inline thread to reply under). Thank you again for identifying the same-batch self-wait case — the reproduction confirmed you were right that the ordering was silently lost, and commit
336c6c2now addresses it. The investigation did refine where the defect lives, and I want to be precise about both what is fixed and what is not.Where the reviewed shape does not arise. Every title-created command list is wrapped (
device_x.rs), so the record-time split moves a wait that follows the list's own Write64 into a fresh PC segment — the write and the wait never share a submission, and the bridged wait releases only when the store publishes. New testd19_title_list_self_wait_orders_the_work_recorded_after_itdrives exactly your scenario — deferred Write64, Wait64 on the same cell, then a copy, all in ONE title list through a realtitle_listwrapper — and proves the copy is GPU-held until the store publishes. It passes before and after the fix, pinning that this main path was already correct.Where it was genuinely broken, reproduced as you described. When the split cannot happen (no wrapper, bundle, unknown allocator, segment budget,
XCL_SPLIT_MIDLIST_WAIT=0), the wait stays on the same list andCycleSkipdiscards it.d19_deferred_self_wait_is_not_dropped_for_following_workdrives that residual through the production chain (write64_bottom_x/wait64_x/execute_with_waits_on/signal_write64_fences/cpu_writes_after): unfixed it fails 3/3 runs — the exact "skipped to avoid same-batch self-deadlock" log fires and GPU work behind the wait reads0x0before the marker exists.The fix (
336c6c2): noqueue.Waithoisting — you were right that it deadlocks, since the strict store needs the list's own completion. Instead the wait is neither hoisted nor skipped: the list is submitted alone, then the deferred self-wait is enforced on the submission thread (bounded by the existing 2 s timeout with a warning) before anything after it is submitted. The producer retires independently once in flight, so this is bounded by completion rather than circular. Waits recorded before their producing write keep the existing skip — no ordering can satisfy those. Fixed: 5/5 passes; d11 11/11 twice, d13 3/3, module 260/1/2 with the one failure byte-identical pre-existing.What is explicitly not solved, so you can judge scope honestly:
Does this resolve the P1 scenario you reported to your satisfaction, and are the two documented residual limitations acceptable for this PR's scope? I have not marked anything resolved — the thread is yours.
Evidence detail is in the updated PR description (sections "Same-batch deferred self-wait" and "Known remaining limitations"). AI use as disclosed there: Devin CLI, SWE-2.1 Max.
@bmjask on GitHub · 2026-11-25 20:49 UTC · original · reviewed
P1: deferred same-batch self-waits are still silently skipped. For a deferred registered sync-cell write then later wait, try_gpu_wait takes CycleSkip because list_writes contains the producer; execute_with_waits treats that as handled. But SyncU64 CPU store occurs only after the submission completes, so post-wait GPU commands run before the marker exists. The new deferred-aware check misses this self-wait branch. Split/submit at the wait or use another ordered mechanism; queue.Wait is not a simple fix because it would deadlock the worker. Add this exact regression.
@pickles976 on GitHub · 2026-11-26 06:20 UTC · original
Wine/NVIDIA follow-through on
336c6c2eeafbef907e3d47c72624158a3c52f2d0: distinguish fixture admission from ordering.With owner production and fixtures (only fail-closed adapter checks and panic-safe release of the held test fence),
d19_produced0passed/2failed. The first test loggedWrite64BitValueBottomOfPipeX ... not in unified memoryandWait64BitValueX ... not readable memoryfor its mapped upload-buffer address, then failedpending_waits.len():0,expected1. The second failure was LISTS mutex poisoning from that assertion, not an independent ordering observation. Logverify-pr2439-d19-wine.log. Thus this run never exercised the intended ordering contract; I have not attributed it to host-side fence Signal behavior.Adapted test memory only:
d11_cell_buffersnow allocates64KiB withVirtualAlloc(MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE), imports it via realID3D12Device13::OpenExistingHeapFromAddress1, and creates a256-byte cross-adapter placed buffer in COMMON state plus the original readback buffer. Committed allocation/heap are held for the fixture lifetime; original sentinel/data assertions remain. Assert both productioncpu_writes::writableand shaderreadablebefore driving the interception. No production guard bypass or production changes. This lets the CPU and real GPU observe the same Windows-committed memory rather than the upload mapping rejected above.Both
d19_deferred_self_wait_is_not_dropped_for_following_workandd19_title_list_self_wait_orders_the_work_recorded_after_itthen passed: 2passed/0failed/0ignored,1.11s, fresh compile25.14s. The real mid-list split logged, and dependent GPU copies met both sentinel and100-value assertions. Logverify-pr2439-d19-imported-memory.log.Platform: Wine11.0, RTX4060Laptop8GiB, NVIDIA590.48.1, DXVK3.1.1, diagnostic relaxed vkd3d-proton3.2.0
2576c0b4adfae4a+(assertions disabled, allocator/listfrom_ifacevtable checks removed, null checks retained). Real NVIDIA enumerated, serial fixtures, vendor masking off. Same6,000MiB GPU/2,048MiB availableRAM/10GiB disk guards and9GiB/512MiB scope caps. Not stock-runtime certification, not a pristine-owner-fixture pass, not a fulld11_/d13_matrix or title proof. These results do not resolve the other reporter's two Wine failures or the documented watchdog/unsplittable-tail limitations; they do show a concrete fixture-admission distinction worth checking before assigning a universal fence-publication cause.@luckyteagirl on GitHub · 2026-11-26 07:41 UTC · original · reviewed
cpu_writes.rs:126,136–139: a removed D3D12 device makesID3D12Fence::GetCompletedValue()returnUINT64_MAX(Microsoft contract). If that happens before the worker's first check,MAX < job.valueis false; if it happens while the strict worker polls,MAX >= job.valuebreaks beforedevice_gone. In both pathsremoved_incompletestays false, so a deferredSyncU64can be stored and published at lines 173–181 even though its producer batch did not execute. That defeats this PR's fail-closed publication rule on device removal.Could each completion probe classify the
UINT64_MAXsentinel as removal before comparing withjob.value, with a focused fake-fence test for both the initial and later-poll paths? This is exact-head source/API-contract review at336c6c2eeafbef907e3d47c72624158a3c52f2d0; I have not injected native device removal or run a title. AI-assisted review with Codex.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.