Repository navigation
D3D12.X: per-queue worker dispatch and atomic 64-bit immediate writes (#1488) - #1643
slopgobblercobbler wants to merge 1 commit into
Conversation
- Replace the single global xcl-cpu-writes FIFO thread with dedicated per-queue worker threads and channels in cpu_writes.rs, preventing cross-queue head-of-line blocking and deadlocks when independent command queues await inter-queue fences (finding XCL-BT-003 from xcl-dev#1488). - Ensure 64-bit immediate writes are stored atomically as a single u64 via AtomicU64::store(..., Ordering::Release) on 8-byte aligned addresses (and via Write::ImmediateU64 in list_x.rs), preventing torn reads. - Add unit test atomic_64bit_write_ordering verifying atomic 64-bit store without tearing under concurrent multi-threaded polling. - Add unit test independent_queues_do_not_head_of_line_block verifying that an unblocked queue executes immediately even when another queue remains stalled on an unsignalled fence.
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review; I traced the fence-value and channel-enqueue ordering.
| static FIRST: std::sync::Once = std::sync::Once::new(); | ||
| FIRST.call_once(|| crate::xlog_info!("D3D12.X: bottom-of-pipe writes outside unified memory are done by the CPU after the GPU ({} in the first submission)", job.writes.len())); | ||
| let _ = worker().lock().unwrap().send(job); | ||
| let _ = tx.send(job); |
There was a problem hiding this comment.
The fence value and Signal are serialized under QUEUES, but the job is sent after that lock is released. Two concurrent after() calls can therefore signal values 1 then 2 yet enqueue job 2 before job 1. Once the fence reaches 2, the worker can apply the newer payload and then overwrite it with the stale value-1 payload, violating the per-queue FIFO guarantee. Please keep enqueue order serialized with fence-value assignment (or use another ordering mechanism). AI-assisted review; I verified the race from this call sequence.
…README Integrates 10 open upstream PRs on top of upstream/main (c160d86): - xcl-dev#1643: per-queue cpu_writes worker threads (eliminating cross-queue head-of-line stalls) and atomic 64-bit immediate writes - xcl-dev#1618: skip DXC validator where the runtime accepts the BYPASS hash - xcl-dev#1535, xcl-dev#1536: PresentX COPY_SOURCE barrier and sparse upload COMMON state transitions - xcl-dev#1516: route stream graphics PSO creation through tracked path - xcl-dev#1478: avoid taking sparse state lock on resource final Release - xcl-dev#1473: implement S_QUADMASK_B32 and S_QUADMASK_B64 - xcl-dev#1621, xcl-dev#1625: frame clock revalidation and short uncompressed DirectStorage request zero-padding - xcl-dev#1557: accept no buffer context before Start in XMA2 voice test under Wine Verified under GE-Proton11-14 + vkd3d-proton ec20719452e916b: - Release build (x86_64-pc-windows-msvc): ok (32.14s) - Proton unit tests (heap_window_tests, dxil::core_tests, cpu_writes, frame, sparse, present, dstorage, xma2_source_voice, gpu_sparse_vram_descriptors_buffers_and_xmem, gpu_valu_float_and_int): 71 passed, 0 failed, 2 ignored, 0 skipped.
|
Regression run for this PR: head main this PR: No device removals or crashes; 99 % of main's frames, 98 % of its peak commit. Peak commit on this machine is mostly the pipeline preload's DXC compiles (#1035) and varies from run to run, so it says little about this PR. Not tested: the whole suite; whether the title reaches the changed code in these 60 s. Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Two contributors checked independently and found that #562 solves the same problem in a different way: #1607, group D63. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
Summary
Implements dedicated per-queue worker dispatch and atomic 64-bit immediate writes in
crates/xcl/src/hle/d3d12x/cpu_writes.rsandlist_x.rs(Issue #1488, findingXCL-BT-003):xcl-cpu-writesworker thread handled writes across all command queues.spawn_queue_worker), ensuring independent command queues make forward progress without blocking each other while preserving strict in-queue FIFO ordering.Write::ImmediateU64(usize, u64)and updatedwrite_nowto commit 8-byte aligned word pairs as a single atomicu64viaAtomicU64::store(..., Ordering::Release).list_x.rs, recordsWrite::ImmediateU64directly for 64-bit bottom-of-pipe writes to title memory, preventing 64-bit tearing under concurrent title polling.atomic_64bit_write_ordering: Validates atomicu64store without tearing under high-frequency concurrent polling reader.independent_queues_do_not_head_of_line_block: Validates that an unblocked command queue executes immediately (< 3s) without being head-of-line blocked behind a stalled command queue waiting on an unsignalled fence.Changes
crates/xcl/src/hle/d3d12x/cpu_writes.rs: per-queue worker dispatch channels, atomic 64-bit stores, and regression tests.crates/xcl/src/hle/d3d12x/list_x.rs: emitWrite::ImmediateU64for 64-bit immediate writes.Tested
cargo test -p xcl -- cpu_writes: 5 passed, 0 failed.cargo test -p xcl -- list_x: 27 passed, 0 failed.upstream/main(c160d86), GPL-2.0-only compliant, zero retail game data or keys.Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity