D3D12.X: a wait after a write into title memory in the same list is met by that write #1246
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1256"
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 upipibi on 2026-11-24T13:48:17Z.
wait_memorydrops aWait32/64BitValueXwhose address the same list already wrote (has_prior_write): the GPU reaches the write before the wait, and polling the address on the CPU before the list is submitted would only run into the timeout. Two writers do not record their range, because they go to the CPU instead (cpu_writes):Write32/64BitValueXinto the title's own memory outside the unified-memory windows;So a wait on such an address later in the same list stayed.
execute_with_waits_onpolled it before submitting the list, while the CPU makes the write only after the submit, so every such wait ran out its timeout and was then let through. Both writers now record the range, as the GPU writers (write,fill,CopyMemoryToMemoryX, timestamps into a window) already do.Found while checking defect 1 of @chazi123's report on #646 ("the CPU poll for a list's Wait ran before that same list was submitted"). For writes into the unified-memory windows,
mainalready drops or splits such waits. This was the one path where it can still happen. I can't tell whether it is the case in that report (their counter is in a window), so this PR does not claim to fix the+0x23cf683stop.What is in it
hle/d3d12x/list_x.rs:write()'s title-memory branch andtimestamp()'s readback branch callnote_writefor the range they queue.a_wait_after_a_title_memory_write_in_the_same_list_is_met_by_it: a synthetic list writes a heap word throughwrite()(no unified memory in the test, so it takes the CPU path), then waits on it and on another word. Only the wait on the other word may stay. It fails onmain(2 waits left) and passes here. It needs no GPU.Tested
cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4:23d1aa8): 752 passed, 0 failed, 41 ignored;main930e8b4: 751 passed, 0 failed, 41 ignored.gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware.Regression run
From Kalmarv's run (https://github.com/ivall/xcl/pull/1256#issuecomment-7136777645), thanks:
main:
PR:
Limits (from bmjask's review): the write stays CPU-emulated and is made only after the whole list's fence completes (
cpu_writes::after), so commands after the dropped wait can run before the marker or timestamp lands.mainhas the same ordering (its CPU poll of the wait times out and lets the list through); this PR removes only the timeout. Ordering it properly means splitting the list at such a wait, which is a separate, larger change.Overlap with #2506 (tiagonleal): #2506 drops a same-list wait only when the value the list wrote meets it, and keeps dropping it when no value is recorded. This PR records the title-memory and timestamp writes with
note_write(no value), so on top of #2506 it would drop those waits whatever the value. The two conflict inlist_x.rs. If #2506 lands first, I'll rebase this so the title-memorywrite()records its value through #2506'snote_write_value, and the timestamp readback (value unknown) no longer drops a wait.Not tested
AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:02:10Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:Thanks!
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-24T15:53:15Z.
Regression pair for
23d1aa8againstmain930e8b4(this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 100 % ofmain's frames, 106 % of its peak commit.Tested
scripts/smoke.ps1, the same retail title for 60 s each:mainat930e8b4(this PR's base) first, then this PR's head, one after the other on the same machine.XCL_ACTIVITY=1on both.main930e8b4:this PR,
23d1aa8:Wait…BitValueX timed outlines (the run you asked for): 0 onmainand 0 on this PR. Both logs have the 30activity (2 s)lines and their other warnings, so the warning would have been logged; neither 60 s run hit a wait timeout at all. The activity lines' frame-event waits also match: 2624 onmain, 2620 here, none timed out.Not tested
AI use: Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T11:06:30Z.
Independent Windows run on 23d1aa8. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, debug.
cargo build --offline --locked --workspacepassed.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapturereported 752 passed, 0 failed, 41 ignored, with two wave64 skips included in Cargo's pass count.I extended the checked-in timestamp fixture in a scratch copy. One native D3D12 list recorded a 32-bit immediate write, two 64-bit timestamp writes, and matching waits on all three CPU-memory destinations. All three destinations were zero before submission. The recording left only an unrelated wait pending. Once I satisfied that wait, one native submission delivered the immediate value 42 and both nonzero GPU timestamps. The device remained healthy. Restoring the original recording code left all four waits pending and failed the assertion before submission.
cargo test --offline --locked -p xcl --lib timestamps_outside_unified_memory_land_after_the_queue -- --nocapture --test-threads=1passed 1/0/0 with zero fixture skips. This covers matching same-list waits in the synthetic case. AI-assisted. Codex (GPT-6, exact variant unavailable) extended the fixture, ran the tests, and drafted this report.Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T19:44:25Z.
AMD RX 7800 XT test report
Tested locally by merging PR head
23d1aa8dfa38db7f468991d2850db0dfacbe79c7onto basemain3f2777019544c0ada2cd294aa792d3c378ff0df8(no push). The base is an ancestor of currentmainand both trees merge cleanly.Hardware and tools: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Windows 10 Pro; Rust 1.100.0 / Cargo 1.100.0; DXC 1.8.2502.11 (DXIL 1.8.2502.11). Debug test build.
cargo test --workspace --no-fail-fast -- --test-threads=4: 1,356 passed, 2 failed, 46 ignored. There were 7SKIPPEDreports: six GPU cases (wave32/wave64 variants for three unsupported instruction forms) and one heap-window case. The two failures and all 7SKIPPEDreports match the baseline (1,355 passed, 2 failed, 46 ignored).Not tested
AI use
Codex (gpt-6-luna) ran Phase 2 tests and wrote this report (Phase 1 pre-compile / initial baseline run used Claude Code (Claude Sonnet 5.5)).
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:41:32Z.
Review: COMMENTED
P1: this removes a wait after a CPU-emulated title-memory write as if the write were GPU-ordered. write() queues cpu_writes::Write::Immediate then note_write; wait_memory sees a prior write and drops the wait. But cpu_writes::after performs the immediate write only after a fence for the submitted list completes. Thus intended write -> wait -> later commands becomes entire list (including later commands) -> CPU write; no PC/GPU write orders the marker before post-wait work. Timestamp readbacks have the same issue. Split/fence/write before the post-wait segment, or retain waits for CPU-emulated writes. The test only asserts removal and does not execute/verify ordering.
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T20:46:20Z.
Independent AMD RDNA4 / Linux (RADV, native wave64) test report for head
23d1aa8dfa38db7f468991d2850db0dfacbe79c7(merged cleanly ontomain6d12f58).Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnu(debug for tests, release for retail)Unit / GPU tests (
XCL_REQUIRE_GPU=wave64,XCL_DXC_DIR,VKD3D_CONFIG=ignore_shared_fence,--test-threads=1 --nocapture)hle::d3d12x::list_x::: 41 passed, 0 failed, 0 ignored (0 skipped)Combined retail sanity run (
main6d12f58+#2068,#1771,#1740,#1256merged together;XCL_DIRECT_DXIL=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PSO_WAIT_MS=50,XCL_SPLIT_MIDLIST_WAIT=0,XCL_COHERENT_MB=1024,VKD3D_CONFIG=ignore_shared_fence,XCL_PSO_PRELOAD=0,XCL_NETWORK=0)exit=0) with 0 crashes and 0 device removals (11.55 GiBpeak VRAM / 0 GTT spill,13.35 GiBpeak RSS,1,800+frames presented,16,442translated draws,4,499dispatches,11,257Opus packets).Not tested
AI use
main, ran the tests and combined retail run under Proton on this machine, and drafted this report.Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T20:50:14Z.
@bmjask Agreed on P1: this doesn't order the CPU-emulated write before the commands after the wait.
cpu_writes::aftermakes the write only once the whole list's fence completes, so commands after the wait can run before the marker lands. The same holds for the timestamp readback.For context,
maindoesn't order it either. There,execute_with_waits_onpolls that wait on the CPU before the list is submitted, the write only happens after the submit, so the wait runs out its timeout and is then let through, and the later commands still run before the write. This PR removes that timeout; it doesn't change the ordering. I've added that to the description as a limit.The proper fix is what you describe: split the list at such a wait and make the write (or a GPU write of the same value) before the post-wait part. That is a bigger change in
execute_with_waits_on's segmenting than this PR, so I'd rather do it separately than grow this one. If the maintainers prefer to hold this PR until then, that's fine.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T05:33:09Z.
merge-check claim
head:
23d1aa8dfaImported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T05:33:47Z.
merge-check
base:
d52ff48caahead:
23d1aa8dfamerge: clean
build: cargo build --workspace -> failed
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> not run (build failed)
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: not yet: cargo build --workspace failed
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-30T05:59:41Z.
Independent Windows check of
23d1aa8dfa38db7f468991d2850db0dfacbe79c7merged locally ontomaind52ff48caade1f5350d513bfffd370396dadfeb6. The merge was clean. The PR build failed with twoE0061errors, at the addeds.note_write(va, size)calls inwrite()andtimestamp()(list_x.rslines 4137 and 4261 in the merged tree). The current API takes aWriteProducer, and both paths already recordCpuAfterSegmentin the line just above.#2959 already adds the ordering discussed above.
342ba2ddsplits the list for a wait overlapping a deferred CPU write, andd8ba6e8aprepares the earlier producer's completion for the continuation. I would treat this PR as superseded on current main unless there is a separate case missing from that path.On the same Windows machine (RTX 5070 Ti Laptop, driver 621.24, Rust 1.97.1 MSVC),
cargo build --offline --release --workspacepassed on clean main. Five targeted main tests passed with no skips, includingwait_placement_distinguishes_cpu_gpu_and_write64_producers,cpu_producer_completion_precedes_the_continuation_wait, andtimestamps_outside_unified_memory_land_after_the_queue. The PR tests were blocked by its build failure. No retail run or full test-suite result in this check.AI use
OpenAI Codex (GPT-6.2 Sol) assisted with source review and Windows verification.
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T09:46:40Z.
merge-check claim
head:
23d1aa8dfaImported from ivall/xcl. Originally posted by BBareth on 2026-11-30T09:53:21Z.
merge-check
base:
9dfbe3ea66head:
23d1aa8dfamerge: clean
build: cargo build --workspace -> failed
tests: not run (the merge result does not compile)
review: git merges it without a textual conflict, but the result does not build: both added calls are
s.note_write(va, n)/s.note_write(va, 8), and on current mainnote_writetakes aWriteProducerfirst (error E0061 at both call sites inlist_x.rs). Beyond the signature: main has since gained its own handling of this case (d8ba6e8a"D3D12.X: prepare prior CPU-write dependencies": CPU-side writes are recorded asWriteProducer::CpuAfterSegmentand a later wait on the range getsWaitPlacement::SplitAfterCpuWrite), so the PR should be rebased and checked against that code first; it may be superseded. I did not verify that main's handling covers the timestamp write.performance: not assessed.
verdict: not yet: does not compile when merged into current main; rebase needed, and possibly superseded by
d8ba6e8ahardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by upipibi on 2026-12-01T00:11:32Z.
Closing: superseded on
mainby6f01fb12and342ba2dd(@bmjask).write()andtimestamp()now record their CPU writes (note_write(WriteProducer::CpuAfterSegment, …), list_x.rs:4132 and :4255), and a wait on such a range splits the list after the CPU write (WaitPlacement::SplitAfterCpuWrite) rather than being dropped. That also covers the ordering problem raised in review here. This branch no longer builds onmain(note_writetakes the producer now), and nothing in it is left to add.Pull request closed