Skip to content

D3D12.X: a list wait after a deferred CPU write waits for that store - #3035

Open
KOLESNiii wants to merge 2 commits into
xcl-dev:mainfrom
KOLESNiii:d3d12x-deferred-write-wait
Open

KOLESNiii wants to merge 2 commits into
xcl-dev:mainfrom
KOLESNiii:d3d12x-deferred-write-wait

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What is in it

  • 1387d97c (bmjask's write-producer classification) and 4cb6808a (bmjask's wait ordering after deferred CPU writes, with Bmjask/ultra performance redesign #2778's fix) came in with D3D12.X: track exact command-list write intervals #3033 / D3D12.X: snapshot command-list effects and generalize segmentation #3034 and are in main now.
  • ebbe6b5a e2e: a same-list wait on title memory follows the CPU-done write (tests/testtitle/src/gpu.rs).
    New test: a bottom-of-pipe write to an ordinary title allocation, then Wait32BitValueX on the same
    cell, submitted by ExecuteCommandLists and by KickoffX.
  • cdae9ad6 D3D12.X: a CPU-write receipt says whether the GPU got to its submission (cpu_writes.rs, list_x.rs), from pickles976's and Royalflamejlh's review. The worker's receipt says whether the fence reached the job's value. It is no longer sent as done after the 10 s limit, and the worker rechecks the fence after a stale wake of its event. A job that never reaches the worker gives a failed receipt. ExecuteCommandLists and KickoffX log an unconfirmed receipt and then evaluate the wait as before. New tests: a_receipt_says_whether_the_queue_got_there (GPU) and an_unconfirmed_cpu_receipt_is_counted_and_the_continuation_goes_on.

Tested

Regression run

Current head e638c349, rebased onto main 765b2c5b on 2026-11-28 to resolve conflicts with main. RTX 2070 SUPER, the retail game, 60 s, XCL_PRESS_AT=25:A, XCL_PREPARE=0 (no startup shader preparation), release builds; each run started from a copy of the same DXIL cache (one queue job: main, then PR heads one after the other).

main:

xcl-smoke v1
commit: 7db2f391cefd748d47c7de63d50dd43ebb852185
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1530 (PresentX 1530)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 17023 MB

This PR's head:

xcl-smoke v1
commit: e638c3497598d81d6bccf32dbf015a7dad384acc
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1236 (PresentX 1236)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15334 MB

Not tested

AI use

  • The code and unit tests are bmjask's, written with Codex (GPT-5.6-sol). Claude Code (Claude Opus 5.5)
    did the cherry-picks, made the two fixes above, wrote the e2e test and 698acd70 with its tests, ran the tests and
    smoke runs, and drafted this description.
  • Claude Code (Claude Opus 5.5) rebased it onto main 336fddda, ran the suite and the regression runs and updated this description.

🤖 Generated with Claude Code

@pickles976

Copy link
Copy Markdown

Exact production head c57b5f6a38df6adf669d37277dc22d5b81abc183, local checkout xcl-pr3035 with one test-only regression. Found a completion-contract gap on physical RTX 4060 Laptop 8 GiB / NVIDIA590.48.1 / Wine11 / Linux6.17 /16GiB. Diagnostic-relaxed vkd3d 2576c0b4adfae4a+, vendor masking disabled; not stock certification.

The description says an unfinished GPU producer blocks the title thread waiting for its store. However, cpu_writes::worker still applies stores after the old10s timeout and then sends the new job.done receipt unconditionally. Thus Completion::wait() succeeds without GPU completion. The old premature-store fallback predates this PR; the new receipt carries that fallback into the dependent-segment ordering contract.

Real native queue probe, no shaders or busy GPU loop:

  1. Create a physical NVIDIA device and DIRECT queue; queue.Wait(cpu_gate,1) with gate initially0.
  2. after_with_completion(queue, [Immediate(cell,[7,0])]), initially atomic cell0.
  3. Receive with12s deadline while gate remains0.
  4. Observe receipt=Ok(()) cell=7 gate=0 elapsed_ms=10053 and worker diagnostic fence at0,wanted1.
  5. Signal gate1 using a panic-safe release guard, signal a fresh drain fence and require the queue to drain; only then assert the semantic failure.

lab_completion_does_not_acknowledge_an_unfinished_producer fails at the assertion that no completion may be acknowledged before producer completion. The two existing cpu_writes fixtures plus producer-classification, split-failure and continuation-completion fixtures pass: 5passed/1failed,0ignored,10.73s after fresh25.68s intended-worktree compilation. The existing continuation test uses a synthetic completion sender; it does not test this worker timeout. The existing readback fixture also logged a fallback in this shared-process run, so its passing bytes do not prove confirmed fence completion (it preloads the readback memory).

Command: cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib -- cpu_writes::tests wait_placement_distinguishes_cpu_gpu_and_write64_producers failed_cpu_wait_split_never_reuses_the_producer_segment cpu_producer_completion_precedes_the_continuation_wait --nocapture --test-threads=1 via our guarded Wine wrapper. Evidence .compat-runtime/logs/verify-xcl3035-producer-completion-20261127T153302Z/. Scope9GiB/512MiB, global safety cutoffs unchanged; GPUpeak218MiB, minavailableRAM9921MiB, mindisk14.347GiB. No retail title run, same-list E2E certification, matched-parent test, or causal claim for our historical Game-Init fence0/wanted1 stall.

Suggested owner correction: completion-bearing jobs must distinguish confirmed GPU completion from timeout/device-loss/event-registration failure. Do not acknowledge success or consume pending readback bytes on the fallback path. Propagate failure/retire dependent submissions safely rather than checking the title cell and continuing. Preserve release/acquire publication after actual stores, and cover the delayed-producer path with a real queue/fence regression. Integrating #850's policy requires an explicit compatibility check; it is not present in this head. Local probe retained, production unchanged.

AI-assisted verification (OpenAI GPT-6 Astra); review-only, no code PR or upstream source changes.

@pickles976

Copy link
Copy Markdown

Follow-through on the pending-producer report: #3035 (comment) . Exact production remains c57b5f6a38df6adf669d37277dc22d5b81abc183; only local regression fixtures changed.

There is a separate consumer-side failure path even after the worker's premature-success acknowledgement is corrected:

  • schedule() returns None on device/fence creation, queue Signal or channel-send failure, indistinguishable from no deferred work.
  • execute_submission_plan_with_completions() proceeds when its required receipt is absent. For a returned receipt it discards the bool from Completion::wait() at list_x.rs:2422; KickoffX does likewise at line3673.

New CPU-only fixture lab_missing_or_disconnected_cpu_receipt_blocks_continuation builds an immutable two-segment plan: a CpuAfterSegment producer and a continuation waiting on the same address. The cell starts with an already-matching value, as in the existing owner success fixture; it must not stand in for this submission's completion. The fixture exercises the actual ordinary-submission executor, first with the submit callback returning None (failed scheduling), then with a real completion channel whose sender is dropped without sending (worker failure). Both release the dependent continuation:

missing_receipt=true disconnected_receipt=false continuation_submitted=true
missing_receipt=false disconnected_receipt=true continuation_submitted=true
left: [true, true]
right: [false, false]

The existing successful-completion consumer fixture passes in the same invocation. 1 passed / 1 failed, 0 ignored, 0.09s, fresh intended-worktree compilation25.71s. Command: cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib -- lab_missing_or_disconnected_cpu_receipt_blocks_continuation cpu_producer_completion_precedes_the_continuation_wait --nocapture --test-threads=1, guarded Wine wrapper. Evidence .compat-runtime/logs/verify-xcl3035-failed-receipt-20261127T155548Z/. Wine11/Linux6.17/16GiB; no GPU adapter initialization, GPU dispatch, native queue failure injection, title run or historical crash-causality claim. The callback models scheduling failure and the channel really disconnects; this does not exercise the native cause of either failure. No production changes.

Suggested correction: distinguish no deferred work from failed required scheduling, propagate unsuccessful completion through ordinary submission and Kickoff, and prevent dependent submission/unsafe resource retirement after failure. Fixing only the timeout acknowledgement is insufficient. Keep the old real pending-queue regression and add these failed-receipt consumer cases. There is no justification here for bypassing the wait or applying stores early to make loading advance.

Historical scope remains explicit: our old two-write/fence0-wanted1 log identifies the legacy CPU-publication path, not its retail queue/list/operation. The retained dump lacks the heap state needed to identify that producer. This new failure is not presented as the cause of that old watchdog.

AI-assisted verification (OpenAI GPT-6 Astra); review-only, no code PR or upstream source changes.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Under Wine + vkd3d-proton on an RTX 4070, the new test title check failed with only the test commit c57b5f6a cherry-picked and passed with this pull request, 2 of 2 runs each: write-then-wait on title memory (0x0, 0x66667777), as on your 8b957bec run. The title's own runs made no deferred CPU write, so they do not reach the new ordering.

Setup: main f9a0cb80 + #684 (which our runs need): alone, + the test commit c57b5f6a cherry-picked, and + this pull request (merged cleanly); release, Wine 11.21 Staging + vkd3d-proton v3.1-90-g30b0eb9b with local patches (#175's relaxed vtables, dxil-spirv), RTX 4070 12 GB, driver 615.71.09. cargo test --release -p xcl --test e2e --target x86_64-pc-windows-gnu -- --test-threads=1; title runs 120 s in turn, A pressed once steady, XCL_PREPARE=0, XCL_PSO_PRELOAD=0, first-run screens done once, no story progress.

Tree Test title checks failed (e2e, 2 runs) Title: last 2 s window with presents ends at Frames
main + #684 "W: not cloaked" 72.2 s, 70.1 s 1338, 1333
+ the test commit c57b5f6a only the cloaking one and "write-then-wait on title memory (0x0, 0x66667777)" — —
+ this pull request "W: not cloaked" 72.2 s, 72.2 s 1362, 1367
  • test_title_runs_and_game_folder_is_untouched fails in all six runs on "W: not cloaked", a Wine difference on main here. The two debug-layer e2e tests were skipped (no d3d12SDKLayers.dll), so one test carries the new check, not three as in your run.
  • No title run logged bottom-of-pipe writes outside unified memory are done by the CPU after the GPU (cpu_writes.rs:212), as in your 60 s run; all four printed the same four splits, all after Write64, and no queue.Wait timeout or device removal.

Read: at c57b5f6a the worker waits at most WAIT_MS (10 s), then applies the stores and sends done whether or not the fence got there (cpu_writes.rs:63–85), and list_x.rs:2422 and :3673 drop Completion::wait()'s result. So a producer the GPU never finishes costs a 10 s stall and then a store the GPU had not reached, not the indefinite block the description's Not tested names; pickles976's two comments read it the same way.

Not tested: native Windows; #3033 and #3034 alone; the debug-layer e2e tests and the rest of the suite; the title past the loading screens.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the title and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

KOLESNiii added a commit to KOLESNiii/xcl that referenced this pull request Nov 28, 2026
The receipt a wait after a deferred CPU write waits for (xcl-dev#3035) was sent
whenever the worker had done the stores, also after it gave up on the
fence after WAIT_MS (10 s) and wrote anyway; a job that never reached the
worker (no fence, a failed Signal, no thread) had no receipt at all, the
same as no deferred work; and both callers dropped the result.

- The worker sends whether the fence got to the job's value. It rechecks
  the fence after every wake until its deadline: the one auto-reset event
  can also be set by an earlier job's value registered before that job
  gave up, which ended the next job's wait at once.
- A nonempty job asked for a receipt always has one; a job dropped before
  the worker has it drops its sender, and the receipt reads as failed.
- ExecuteCommandLists and KickoffX log an unconfirmed receipt and go on to
  the wait as before: the continuation is on the same queue, so the GPU
  still runs it after the producer, and a wait the store did not satisfy
  times out in wait_all_on. Holding the continuation for ever would turn a
  lost producer into a hang.

Reported by pickles976 and Royalflamejlh on xcl-dev#3035.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii

Copy link
Copy Markdown
Contributor Author

@pickles976 @Royalflamejlh thanks, all three points confirmed by reading c57b5f6a:

  1. the worker sent done after giving up on the fence at WAIT_MS (10 s) and writing anyway, so Completion::wait() said yes without the GPU;
  2. a job that never reached the worker (no fence, a failed Signal, a closed channel) gave no receipt, the same as no deferred work;
  3. list_x.rs:2422 and :3673 dropped the result.

Fixed in 698acd70 (a new commit on top, D3D12.X: a CPU-write receipt says whether the GPU got to its submission):

  • The worker sends whether the fence reached the job's value. It also rechecks the fence after every wake until its deadline. The worker's one auto-reset event can be set by an earlier job's value that was registered before that job gave up. That ended the next job's wait at once, the same stale-wake pattern as in D3D12.X: a sparse readback its wait gave up on is not copied into title memory #3063.
  • A nonempty job asked for a receipt always gets one. A job dropped before the worker has it drops its sender, so the receipt reads as failed.
  • ExecuteCommandLists and KickoffX log an unconfirmed receipt (8 times at most). They then go on to the continuation's wait as before, rather than holding the continuation. The continuation is on the same queue, so the GPU still runs it after the producer. A wait the store did not satisfy times out in wait_all_on, as on main. Holding the continuation until a receipt confirms would turn a lost producer or a removed device into a hang. If you see a case where same-queue order is not enough, I'd like to hear it.

Tests:

  • New GPU test cpu_writes::tests::a_receipt_says_whether_the_queue_got_there. The queue waits at a CPU gate, so the receipt must say no after a 50 ms limit. A second job waits behind a second gate while the first gate's value sets the event: it must not be written early, and it must be confirmed once its gate opens. A job with no queue gives a failed receipt.
  • New CPU test list_x::tests::an_unconfirmed_cpu_receipt_is_counted_and_the_continuation_goes_on.

Results on 698acd70, RTX 2070 SUPER, Windows 11 26300, debug:

  • cargo test -p xcl --lib -- cpu_writes:: an_unconfirmed_cpu_receipt cpu_producer_completion_precedes --test-threads=1: 5 passed, 0 failed.
  • Negative check: with the worker's receipt forced back to always confirmed, a_receipt_says_whether_the_queue_got_there fails with "a write done before its queue got there is not confirmed".
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1465 passed, 0 failed, 47 ignored; 25 SKIPPED (21 × no wave64, 3 refused per gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426, 1 × no heap windows).
  • The smoke run of this head is queued; I'll add its block to the description.

The description's Not tested line about an indefinite block was wrong, as you both read it. It now says what happens.

AI use: Claude Code (Claude Opus 5.5) made the fix and the tests and wrote this reply.

@KOLESNiii
KOLESNiii marked this pull request as ready for review November 28, 2026 03:22
KOLESNiii added a commit to KOLESNiii/xcl that referenced this pull request Nov 28, 2026
The receipt a wait after a deferred CPU write waits for (xcl-dev#3035) was sent
whenever the worker had done the stores, also after it gave up on the
fence after WAIT_MS (10 s) and wrote anyway; a job that never reached the
worker (no fence, a failed Signal, no thread) had no receipt at all, the
same as no deferred work; and both callers dropped the result.

- The worker sends whether the fence got to the job's value. It rechecks
  the fence after every wake until its deadline: the one auto-reset event
  can also be set by an earlier job's value registered before that job
  gave up, which ended the next job's wait at once.
- A nonempty job asked for a receipt always has one; a job dropped before
  the worker has it drops its sender, and the receipt reads as failed.
- ExecuteCommandLists and KickoffX log an unconfirmed receipt and go on to
  the wait as before: the continuation is on the same queue, so the GPU
  still runs it after the producer, and a wait the store did not satisfy
  times out in wait_all_on. Holding the continuation for ever would turn a
  lost producer into a hang.

Reported by pickles976 and Royalflamejlh on xcl-dev#3035.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the d3d12x-deferred-write-wait branch from 698acd7 to cdae9ad Compare November 28, 2026 11:40
@Aniseto

Aniseto commented Nov 28, 2026

Copy link
Copy Markdown

Ran the CPU-write receipt tests at cdae9ad6 on an NVIDIA Blackwell desktop part:

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.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib -- a_receipt_says_whether_the_queue_got_there an_unconfirmed_cpu_receipt_is_counted_and_the_continuation_goes_on --test-threads=1
2 passed; 0 failed; 0 ignored; 0 measured; 2025 filtered out      (exit 0)

Both new tests pass on a real NVIDIA part: the worker's receipt records whether the queue reached the submitted fence value, and an unconfirmed receipt is counted while the continuation still runs. The thread already has a report from another NVIDIA card; this adds a Blackwell desktop datapoint for the focused tests.

Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game 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.

@KOLESNiii

Copy link
Copy Markdown
Contributor Author

@pickles976 Could you rerun your pending-producer fixture on cdae9ad6 through both ExecuteCommandLists and KickoffX? For the successful case, please verify that the producer segment reaches its fence and the deferred CPU store lands before the continuation evaluates the wait. If you still have the failed or unscheduled producer fixture, please check that XCL logs an unconfirmed receipt and that the continuation takes the bounded wait path without hanging. Please report which paths you exercised and the observed result for each.

Please include the commit, test or fixture used, GPU and driver, and OS or Wine/vkd3d versions. A Blackwell report already covers the two focused receipt tests, so the pending-producer fixture would add new coverage.

— Codex, exact model unavailable, on behalf of the PR author

@kole07139

kole07139 commented Nov 28, 2026 •

Copy link
Copy Markdown

Update for the current head e638c349 (rebased): the whole suite on it, which the description says was not rerun. No new failures; the two new unit tests pass.

Tested: the same machine as below (RTX 3070 8 GB, driver 617.42, i9-9900K, 32 GB, Windows 11 Pro N 26200, rustc 1.99.0, debug, no XCL_* set). Two trees with separate target directories:

  • main 7db2f391;
  • main 7db2f391 + this head (clean merge, 5cdd5aeb).
main 7db2f391 main + e638c349
cargo test --workspace --no-fail-fast -- --test-threads=4 2590 passed, 4 failed, 49 ignored 2592 passed, 4 failed, 49 ignored
the same 4 e2e tests after cargo build --workspace: cargo test -p xcl --test e2e -- --test-threads=1 5 passed, 0 failed 5 passed, 0 failed
SKIPPED lines 28 28 (the same tests)
  • The 4 failures in the suite runs are my setup, not the code. I ran the suite without building the workspace first, so the 4 title tests panicked with missing ...\debug\xcl_testtitle.exe ... build first: cargo build --workspace on both trees. After the build, all 5 e2e tests pass on both trees. So the counts are 2594 / 0 / 49 on main and 2596 / 0 / 49 with this head.
  • a_receipt_says_whether_the_queue_got_there and an_unconfirmed_cpu_receipt_is_counted_and_the_continuation_goes_on pass.
  • git range-diff from cdae9ad6 to e638c349: the test commit is unchanged. The receipt commit differs only in reading the fence through main's super::real::fence_completed instead of GetCompletedValue, plus the rebase context. So the review notes below still apply.

Not tested (in addition to the list below): a title run with this head; main past 7db2f391.

AI use: Claude Code (Claude Opus 5.5) ran the merges, builds and tests and wrote this update.


Earlier report, for head cdae9ad6:

Test report for head cdae9ad6 on main 309c3ec5, which has #3149 (so the e2e title tests no longer fail on #3093's post-Wait32/64 check). The whole suite passes with this PR, and the new title check is exercised through both paths. On current main, though, the title check passes without this PR's runtime commit too.

Tested: NVIDIA GeForce RTX 3070 8 GB (driver 617.42, wave32), Intel i9-9900K, 32 GB RAM, Windows 11 Pro N 26200, rustc 1.99.0, DXC 1.8.2502.11, debug, no XCL_* set. The D3D12 debug layer is installed, so all three e2e title tests carry the new check (none skipped). Three trees with separate target directories:

  • main 309c3ec5;
  • main + this head (clean merge);
  • main + only the test commit ebbe6b5a (cherry-picked).
main 309c3ec5 main + cdae9ad6 main + ebbe6b5a only
cargo test --workspace --no-fail-fast -- --test-threads=4 2142 passed, 0 failed, 48 ignored 2144 passed, 0 failed, 48 ignored –
SKIPPED lines 26 26 –
cargo test -p xcl --test e2e -- --test-threads=1 – 5 passed (2 runs of 2, plus the suite run) 5 passed (2 runs of 2)
  • The two new tests, a_receipt_says_whether_the_queue_got_there and an_unconfirmed_cpu_receipt_is_counted_and_the_continuation_goes_on, pass in the suite run and in 3 more runs of cargo test -p xcl --lib -- --test-threads=1 cpu_writes:: an_unconfirmed_cpu_receipt_is_counted_and_the_continuation_goes_on (4 passed each time).
  • The title check runs the new ordering on both trees. With --nocapture, test_title_runs_and_game_folder_is_untouched logs bottom-of-pipe writes outside unified memory are done by the CPU after the GPU, then split command list (type 0) around mid-list Wait after CPU-after-segment write Implement XSystemGetDeviceType/PLS thunks and Opus audio carrier parsing #1 and #2 (by ExecuteCommandLists and by KickoffX). It reports [PASS] D3D12.X: console command list memory methods (…). With this head the run logs no goes on without the GPU warning.
  • Not a regression test for cdae9ad6 any more: with only the test commit on main 309c3ec5, the check passes as well. That is expected: the ordering itself came with D3D12.X: track exact command-list write intervals #3033 / D3D12.X: snapshot command-list effects and generalize segmentation #3034 and is in main now. So this section of the description is out of date: "fails 3 e2e tests ... It passes on this head" was measured on main 8b957bec. On current main the title check guards D3D12.X: track exact command-list write intervals #3033 / D3D12.X: snapshot command-list effects and generalize segmentation #3034, and only the two unit tests cover the receipt commit.
  • Review of cdae9ad6:
    • The worker now rechecks the fence after each wake until its deadline, which covers the stale wake from a job that was given up.
    • A job dropped before the worker gets it drops its sender, so its receipt reads false.
    • ExecuteCommandLists and KickoffX log an unconfirmed receipt and keep the bounded wait, as described.
    • I found nothing to change.

main has since moved to bb9a6b4b (#3100, which touches none of this PR's files). The head merges into it without conflict; I did not rerun the suite there.

Not tested: a title run (the title's 60 s run logs no deferred CPU write, per the description), a GPU that really stops in the producer segment (pickles976's fixture), a release build, AMD and Intel GPUs, Wine.

AI use: Claude Code (Claude Opus 5.5) ran the merges, builds and tests, reviewed the diff, and wrote this report.

@KOLESNiii

Copy link
Copy Markdown
Contributor Author

Thanks for the three-tree run. You're right that the e2e paragraph was out of date: #3033 / #3034 (whose commits are all in main now) brought the ordering the e2e section checks, so on current main the section passes with only ebbe6b5a. I updated Tested and Not tested: ebbe6b5a now guards that ordering, and cdae9ad6 is covered by the two unit tests only. No code change, head stays cdae9ad6.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

@kole07139

Copy link
Copy Markdown

Thanks for the three-tree run. You're right that the e2e paragraph was out of date: #3033 / #3034 (whose commits are all in main now) brought the ordering the e2e section checks, so on current main the section passes with only ebbe6b5a. I updated Tested and Not tested: ebbe6b5a now guards that ordering, and cdae9ad6 is covered by the two unit tests only. No code change, head stays cdae9ad6.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

If you need some other test, mention me and ill do. Say what's up to the author from me :D

KOLESNiii and others added 2 commits November 28, 2026 19:54
console_list_methods records Write32BitValueBottomOfPipeX to an ordinary
title allocation outside graphics memory, then Wait32BitValueX on the
same cell, and submits it by ExecuteCommandLists and by KickoffX. The CPU
does that write after the GPU segment, so the wait can only be met after
the producer segment has run and its deferred store has landed. Without
that ordering the wait is checked before the list is submitted and times
out (2 s) before the list runs; the test fails above 1 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The receipt a wait after a deferred CPU write waits for (xcl-dev#3035) was sent
whenever the worker had done the stores, also after it gave up on the
fence after WAIT_MS (10 s) and wrote anyway; a job that never reached the
worker (no fence, a failed Signal, no thread) had no receipt at all, the
same as no deferred work; and both callers dropped the result.

- The worker sends whether the fence got to the job's value. It rechecks
  the fence after every wake until its deadline: the one auto-reset event
  can also be set by an earlier job's value registered before that job
  gave up, which ended the next job's wait at once.
- A nonempty job asked for a receipt always has one; a job dropped before
  the worker has it drops its sender, and the receipt reads as failed.
- ExecuteCommandLists and KickoffX log an unconfirmed receipt and go on to
  the wait as before: the continuation is on the same queue, so the GPU
  still runs it after the producer, and a wait the store did not satisfy
  times out in wait_all_on. Holding the continuation for ever would turn a
  lost producer into a hang.

Reported by pickles976 and Royalflamejlh on xcl-dev#3035.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the d3d12x-deferred-write-wait branch from cdae9ad to e638c34 Compare November 28, 2026 19:57
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 28, 2026
@andrewDoing

Copy link
Copy Markdown
Contributor

A healthy two-queue control on e638c3497598d81d6bccf32dbf015a7dad384acc, RTX 5070 driver 616.92, distinguishes queue completion from publication of the deferred CPU store.

  1. Queue B alone: its bottom-of-pipe CPU receipt returned true and an acquire load read 0xc3c3c3c3.
  2. I put queue A behind a bounded fence gate, then scheduled an ordinary deferred store on A and another on independent queue B. The stores targeted different CPU cells. B had no GPU wait on A. A marker enqueued on B after XCL's write fence reached value 1, proving B had passed its own write's signal.
  3. While A was gated, B's CPU receipt remained pending for the 100 ms observation and both cells still read zero. I then released A. Both receipts returned true, and dependent acquire loads read 0xa1a1a1a1 and 0xb2b2b2b2. Neither worker fence timed out.

The per-queue fences do their job; the single FIFO CPU-write worker can still delay publication for an already-finished independent queue behind an older pending one. This distinguishes what a successful receipt guarantees from when an independent caller can obtain it. The fixture used the production CPU-write scheduler, ordinary queue signals and tracked host cells. It bypassed the guest ExecuteCommandLists/KickoffX hooks. This isolates an existing progress limit, without attributing a regression or a retail stall to this PR.

AI use: OpenAI Codex wrote and ran the test-only fixture and drafted this report.

@KOLESNiii

Copy link
Copy Markdown
Contributor Author

Thanks @andrewDoing, that is a clean way to separate the two. I checked it against the source and agree: the delay is not new in this PR. main already has one xcl-cpu-writes thread for every queue (crates/xcl/src/hle/d3d12x/cpu_writes.rs:67-96). It takes jobs from a single channel in submission order (the module comment at :8 says so) and blocks on each job's fence, up to WAIT_MS, before it moves on. So a finished queue B waits behind a gated queue A. This PR keeps that worker and only adds the receipt saying whether the GPU got there, so the order your fixture measured is the same as main's.

Giving each queue its own worker, or skipping ahead to jobs whose fence has already completed, would remove the delay. That changes the order of writes between queues, so it belongs in its own PR and is not something I'll add here. I'll note it as a follow-up.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run of head e638c349, on its own base 765b2c5 and merged with current main 53e85fb1, to go with the reports above by kole07139, since none of them covers AMD. Nothing here fails because of this PR: the failures on its base come from main and pass merged (details below). On the Radeon the lib test binary stops partway on this base and on main alike (#3488), so the AMD runs are partial. The bare-head runs come first.

Tested

Not tested

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head e638c34

The ordering the title describes is on main already (#3033/#3034, 342ba2dd); what this PR still adds is the e2e guard for it and receipts that say whether the fence was reached, with the worker re-checking the fence after a stale event wake.
The stale-wake part overlaps #1379 (same re-check loop in cpu_writes.rs worker) and #3104 (replaces the event wait with polling and never publishes early); they touch the same lines, so at most one approach should land.
No problems found in the diff. The description says the suite was not rerun on this head.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 493dbd3
head: e638c34
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+188/-29). The title and description are stale: the ordering fix (#3033 / #3034) is already on main, and the hashes in the description (ebbe6b5, cdae9ad) aren't the head's (f6cb6e7, e638c34). What this head adds is a confirmed / unconfirmed receipt, the worker rechecking the fence after a stale event wake (cpu_writes.rs ~81-97), a warning and an e2e test. Findings: (1) The stale-wake fix is real. On main, a job that timed out leaves its SetEventOnCompletion registration on the shared event, which can wake a later job early so its writes land before its queue got there; a_receipt_says_whether_the_queue_got_there covers it. The description should say that this is the change. (2) Overlap: #3104 rewrites the same worker loop and receipt, and #1819 also targets the stale event. Only one can land as is. (3) If native_queue_signal fails (~300) or the queue is null, the writes are dropped, as on main, but the new warning (list_x.rs ~3658) says the wait goes on "without the GPU having finished", which misdescribes that case. (4) The e2e test passes on main (kole07139's report), so it guards rather than shows the fix, and its took < 1 s checks (gpu.rs ~602, ~617) could flake on a slow machine. The PR's red CI is the pipeline_library lock poisoning fixed by 2c003dd, after its base. Fine: waits still run on the same queue after the producer, and it merges cleanly. No smoke run: the retail title's 60 s run logs no deferred CPU write.
performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: not yet: the title and description still describe the ordering fix already on main; the change here (the stale-wake recheck and receipt) needs its own description, and it overlaps #3104 / #1819 on the same worker loop, so a maintainer should pick one. The code itself passes the suite
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants