D3D12.X: arm intermediate pre-cell fence signals and initialise cell before publishing #1287
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1297"
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 b3IKK on 2026-11-24T14:29:19Z.
fence_x::note_queue_signalonly recorded the maximum signalled value (f.signalled) beforecompleted_value_addresswas first called. If a queue signalledV1and thenV2(V2 > V1) beforecompleted_value_address, onlyV2was armed: when the GPU completedV1and paused beforeV2, the completion event never fired and*cellstayed stale at0even thoughGetCompletedValue() == V1(deadlocking any caller waiting on*cell >= V1).In addition,
completed_value_addresspublishedCell(0)intoFENCESbefore callingrefresh(), allowing a concurrent caller ofcompleted_value_addressto observe0instead of the fence's currentGetCompletedValue().This records pre-cell queued signal values in a pruned
BTreeSet<u64>socompleted_value_addressarms every pending value> initial, and initialises the cell fromGetCompletedValue()before inserting it.What is in it
crates/xcl/src/hle/d3d12x/fence_x.rs: track pre-cell queued signals inFence::pending(pruning completed values whenpending.len() >= 16), initialiseCellwithGetCompletedValue()before publishing, and arm all pending values> initial; add GPU testintermediate_signal_queued_before_completed_value_address_updates_cell(verified failing before the fix withcell stayed at 0 while fence GetCompletedValue() == 1).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib intermediate_signal_queued_before_completed_value_address_updates_cellandthe_cell_follows_the_fence: both pass (first timed out atcell == 0before the fix)Regression run
main:
PR:
Not tested
AI use
fence_x.rs, wrote the fix and GPU test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:37:11Z.
Full-suite run, since this PR has no test report yet. Tested exact head
cb60656(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.intermediate_signal_queued_before_completed_value_address_updates_cell.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:56:03Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-25T09:59:33Z.
Independent Windows run on cb60656. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC.
cargo build --workspace --offline --locked -j 4passed.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 752 passed, 0 failed, 41 ignored, including two wave64 runtime skips in Cargo’s pass count. The PR's intermediate-signal regression passed.With the D3D12 debug layer enabled,
cargo test --offline --locked -j 4 -p xcl --lib local_signal_x_keeps_intermediate_fence_values_observable -- --nocapture --test-threads=1passed 1 of 1 without skips. The scratch fixture called XCL'sSignalXimplementation on a native queue. The first completed-value address read was 16. As the fixture released five queue gates in turn, the value at that address followed the native fence through 17, 18, 19, 20 and 21. Signals 17–20 were queued before the address was requested. Signal 21 was queued after. When the scratch control armed only the highest pre-address value, the native fence reached 17 while the value at the address stayed 16. The control edit was restored. Synthetic queue coverage only.AI use: Codex (GPT-6, exact variant unspecified) wrote the scratch fixture, ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-25T11:03:04Z.
Linux/RADV + Wine GPU test report on PR
#1297headcb60656(cb60656233fc6537600105941ba65124f211e733, local mergec374a88d6b8a0ed5c522057456eb565d07bdb3e4ontoorigin/main568e7db7729c8fa6c8f0f4b32d798faaf11462bb).Setup
7.3.0-5-cachyos)AMD Radeon RX 9070 (RADV GFX1201, native wave64)(device0x7550, Vulkan1.4.354, Mesa RADV26.2.5-arch3.1)GE-Proton11-12(wine-11.0 (Staging)),vkd3d-proton v3.1, DXVKdxgi.dll, DXC1.9.2602.17(21d28f72)rustc 1.97.1,cargo test --target x86_64-pc-windows-gnu --release --workspace --no-run(43.42s, exit0, zero compiler warnings),XCL_REQUIRE_GPU=wave64 XCL_NETWORK=0Results
cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::fence_x::tests -- --nocapture: 2 passed, 0 failed, 0 ignored (0.09s, exit0; boththe_cell_follows_the_fenceand newintermediate_signal_queued_before_completed_value_address_updates_cellpassed), vs baseline568e7db(hle::d3d12x::fence_x) 1 passed, 0 failed, 0 ignored (0.08s, exit0).hle::d3d12x::fence_x::tests -- --nocaptureunder concurrent Vulkan compute load (vk_tool burn burner.spv gfx 2048 4096 256 30, 803 dispatches, avg dispatch 6.34-6.81 ms): 5 of 5 consecutive runs passed (2 passed, 0 failed, 0 ignored in 0.07s per run, exit0).cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::late_release: 2 passed, 0 failed, 0 ignored (0.18s, exit0), matching baseline568e7db2 passed, 0 failed, 0 ignored (0.19s, exit0).cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x::real -- --test-threads=1: 45 passed, 1 failed, 0 ignored (1.18s, exit101;dma_list_release_cleans_up_list_stateatcrates/xcl/src/hle/d3d12x/real.rs:6752:120withHRESULT(0x80070057)), matching baseline568e7db45 passed, 1 failed, 0 ignored (1.12s, exit101, same file, line, and error).cargo test --target x86_64-pc-windows-gnu --release -p xcl --lib hle::d3d12x -- --test-threads=4: 157 passed, 21 failed, 2 ignored (1.72s, exit101), vs baseline568e7db156 passed, 21 failed, 2 ignored (1.63s, exit101; +1 passed fromfence_x::tests, identical set of 21 pre-existing failures).cargo test --target x86_64-pc-windows-gnu --release --test d3d12_resource_and_sync(default and-- --test-threads=1): 2 passed, 1 failed, 0 ignored in both (0.62s and 0.64s, exit101;fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_consolefailed atcrates/xcl/tests/d3d12_resource_and_sync.rs:481:118withHRESULT(0x80070057)), matching baseline568e7db2 passed, 1 failed, 0 ignored in both (0.25s and 0.26s, exit101, same file, line, and error).cargo test --target x86_64-pc-windows-gnu --release --test gpu_compute_e2e: 2 passed, 2 failed, 0 ignored (1.49s, exit101;console_wave64_compute_through_the_pso_hook_dispatch_and_read_backfailed with0x80070057andheap_window_out_of_memory_falls_back_to_the_switch_formfailed withno heap windows, but XCL_REQUIRE_GPU=wave64), matching baseline568e7db2 passed, 2 failed, 0 ignored (1.03s, exit101, same 2 failures).Not tested
scripts/smoke.ps1(no retail title files locally).XCL_HEAP_WINDOWS=1(left unset) and--lib/--testtargets outside those listed above.d3d12_resource_and_sync(fence_and_command_queue_sync_timing_and_allocator_reset_match_host_and_console) andconsole_wave64_compute_through_the_pso_hook_dispatch_and_read_backhit the pre-existing Winereal::init()HRESULT(0x80070057)failure present on baseline568e7db.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:22:02Z.
Triage (#1607) – head
cb60656No open or merged PR makes the same change. The bug is still on main:
FenceTable::completed_value_address_withcreates the cell at 0 and arms only the highestsignalledvalue, so intermediate signals queued earlier never update the cell.Main rewrote
fence_x.rsintoFenceTable(per-cell refresh lock,fence_completedinstead of the hookedGetCompletedValue, cell stores gated bycomplete_fence_downloads), so the rebase must read the initial value throughreal::fence_completedand keep that gating.note_queue_signalnow inserts into aBTreeSeton every signal of every fence that never gets a cell, and callsGetCompletedValueunder the table lock once 16 are outstanding. This is cheap, but it runs on every Signal.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T05:28:02Z.
Source review of head
cb606562againstmaind0832e6. The intermediate-signal fix is still needed; the existing rebase note covers the newer fence table and download gating. Two additional points are worth addressing during that rebase:Pending-signal pruning scales quadratically while a queue is gated. In the PR's
note_queue_signal, once 16 distinct values are pending, every later signal callsBTreeSet::retainover the entire growing set while holding the shared fence lock. If the GPU is held behind a wait and completion stays at zero, N pre-cell signals cause roughly N² predicate visits and delay unrelated fences. Query completion outside the table lock, then remove only completed values from the ordered front (first/pop_first) after reacquiring it. Recheck whether the cell was installed while the lock was released. A regression can queue many distinct values behind a closed gate, confirm none is lost, and check that a signal on a separate fence can proceed while the native completion query is held.The new test's fence lifetime is unsafe on failure.
intermediate_signal_queued_before_completed_value_address_updates_cellputs the raw fence pointer into the global table, but callsmem::forget(fence)only on the success path. Its timeout branch panics; the fence then drops while the background refresh worker can still dereference that pointer. On currentmain, useforget_fence_for_testin a scope guard before the COM owner drops, including on assertion failure. Alternatively, keep the test fence alive on every exit as the old test intended.For the rebase, keep
main's zero-initialized mirror andrefresh_onepublication gate: a native completed value must not appear in the title's cell before pending readbacks and downloads are published. If concurrent first callers must observe the initial value synchronously, serialize their first refresh attempt outside the table lock; a withheld download still returns the conservative cell value.This is source analysis, not a current-head build, GPU run, or merge-check. AI use: OpenAI Codex (GPT-6.2 Sol) traced the PR and current source; OpenAI Codex (GPT-6.2 Astra) independently checked the fence lifecycle and lock path.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.