Repository navigation
Conversation
When a Write64BitValue* cycle is broken on the CPU (SignalAction::CpuCycleBreak in signal_write64_pairs, or a mixed title-fence cycle in break_cycles_before_title_signal), XCL signalled the per-VA PC fence and updated cpu_signaled_max without writing the released value into the title's memory. A title polling that counter on the CPU (or a Wait64 checking memory) never saw it move while the blocked queue had not yet executed its write. Publish the released value with AtomicU64::fetch_max right before signalling the fence, skipping sparse UMA windows (where CPU writes dirty write-watched pages and upload stale sibling bytes into VRAM) and non-monotonic cells. Committed coherent UMA takes an O(1) path; non-UMA title memory reuses a shared max_u64_now helper in cpu_writes.rs (off the hot path: cycle breaks only). Part of xcl-dev#1164 Assisted-by: Antigravity (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
Contributor
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with Tested
Regression run main (first run): this PR: The second Not tested
AI use
|
IvyNotFound
added a commit
to IvyNotFound/xcl
that referenced
this pull request
Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1164 (the remaining local change: publishing a CPU cycle-break's released value into title memory; the gate timeout and
XCL_GPU_WAIT_RELEASE_MSare left out because they overlap #1046).When
signal_write64_pairs(SignalAction::CpuCycleBreak) orbreak_cycles_before_title_signalbreaks aWrite64BitValue*/Wait64BitValueXGPU cycle on the CPU, XCL signalled the per-VA PC fence and updatedcpu_signaled_max, but did not write the released value into the title's memory. Any CPU poll or memory-checking wait on that counter never saw it move while the blocked queue had not yet executed its write.This change publishes the released value with
AtomicU64::fetch_maxright before signalling the fence (skippingval == 0as well as null or non-8-byte-aligned addresses):Uma::in_committed_windowshortcut without callingVirtualQuery.publish_cpu_cycle_break's committed-UMA path now matchesmain(Memory: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx #1005), whosein_committed_windowshortcut is also preserved inside the sharedcpu_writes::u64_writable_nowhelper.cpu_writes::max_u64_nowhelper (VirtualQuery+MEM_COMMIT+!PAGE_GUARD+ RW/ERW + region-end check). This path only runs on cycle breaks (rare, warning-throttled), never on per-draw or per-submit hot paths, and has the same best-effort TOCTOU trade-off before the atomic write ascpu_writes::write_u64_now.Uma::is_sparse). CPU writes into a sparse window dirty its write-watched page and causesparse::before_executeto upload the surrounding 64-byte chunk to tiled VRAM, which can overwrite adjacent GPU-written data. Existingcpu_writespaths (Write::ImmediateandWrite::ReadbackU64) do not need a sparse check because they only ever receive addresses outside unified memory (real::uma_window_bufferisNone), whereasSyncCelltracksWrite64BitValue*across both UMA and non-UMA addresses.fetch_maxnever rewinds a counter that already advanced, andbreak_cycles_before_title_signalnow skipsnon_monotoniccells too. Note that an earlier-queued non-UMAWrite::Immediatecompleting later onxcl-cpu-writesstill writes via plain 32-bit stores incpu_writes::write_now; changingwrite_nowis left out of this PR to avoid changing existing write-worker behaviour and overlapping D3D12.X: retain deferred Write64 until the producer fence completes #850 / D3D12.X: honour OS QPC timestamp flags and atomic 64-bit CPU writes (#103) #317.What is in it
crates/xcl/src/hle/d3d12x/cpu_writes.rs: extractu64_writable_nowfromwrite_u64_now(keepingmain's Memory: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx #1005Uma::in_committed_windowshortcut beforeVirtualQuery) and exposepub(super) unsafe fn max_u64_now. One behaviour change in the existingwrite_u64_now: it now also ignores a null or non-8-byte-alignedva(the check moved into the shared helper); before, it stored through such an address.crates/xcl/src/hle/d3d12x/list_x.rs: addpublish_cpu_cycle_break/publish_cpu_cycle_break_with, call it beforefence.Signal(val)inSignalAction::CpuCycleBreakandbreak_cycles_before_title_signal(adding anon_monotonicguard to the mixed-cycle site), and add unit testpublish_cpu_cycle_break_uses_fetch_max_and_skips_sparse_or_unwritableand GPU testcpu_cycle_break_publishes_value_to_title_memory_and_keeps_it_monotonic.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09). Debug for tests; release (cargo build --release -p xcl) for smoke runs. Head commit49a25463d62b14bc2dec833b6efc58b09382528eonmain3da2abb81606df622610e009f0430de99aa9881c.--test-threads=1):cargo test -p xcl --lib cycle_break -- --test-threads=1: 2 passed, 0 failed, 0 ignored.cargo test -p xcl --lib hle::d3d12x::cpu_writes -- --test-threads=1: 2 passed, 0 failed, 0 ignored.cross_queue_cycle_and_same_queue_fifo_do_not_deadlock,rotating_queue_self_deadlock_and_non_monotonic_rescue_do_not_hang,mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares): 3 passed, 0 failed, 0 ignored.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4): 1112 passed, 1 failed, 46 ignored, 8 SKIPPED lines (across 4 tests).SKIPPED:gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: 4 sub-cases (f16 arithmeticwave32/wave64:refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's));f16 packedwave32/wave64:refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)))gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: 2 sub-cases (f32 conversionswave32/wave64:refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)))shaders::tests::pso_measurement_compiles_an_exact_synthetic_record:cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)heap_window_out_of_memory_falls_back_to_the_switch_form:no heap windowsgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1:seed 540: res[833] = 0x7, CPU 0x6) is pre-existing onmain3da2abb81606df622610e009f0430de99aa9881cin DXIL code untouched by this PR: runningcargo test -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 -- --test-threads=1on plain3da2abbfailed 3/3 deterministically with the exact sameseed 540: res[833] = 0x7, CPU 0x6.Regression run
Four 60 s smoke runs were executed back-to-back in
main, head, head, mainorder from the same worktree and executable path (main3da2abbvs head49a2546, clean trees,scripts/smoke.ps1 -Game C:\games\retail):main): 1560 frames (PresentX 1560), peak commit 18752 MB (steady 20–60 s median 16115 MB)head): 1570 frames (PresentX 1570), peak commit 17178 MB (steady 20–60 s median 15854 MB)head): 1579 frames (PresentX 1579), peak commit 17294 MB (steady 20–60 s median 15774 MB)main): 1577 frames (PresentX 1578), peak commit 19043 MB (steady 20–60 s median 16021 MB)Steady-state commit (~15.8–16.1 GB) and peak commit (~17.2–19.0 GB) match between
mainand this PR; none of the runs hitCpuCycleBreak. Pair 2 (runs 3 and 4) is pasted verbatim below:main:This PR:
Related
break_cycles_before_title_signal(a sibling rewind fix, a different problem); the two conflict textually there.cpu_writes::write_u64_now, which this PR factors intou64_writable_now; they conflict incpu_writes.rs, they are not duplicates.cpu_writes(per-queue workers, atomic 64-bit stores); not a duplicate, and I did not check it for textual conflicts.Not tested
CpuCycleBreak.AI use
3da2abb, ran the targeted tests, full workspace test suite,mainfuzz reproduction, and paired 60 s regression smoke runs, and wrote this PR description.cpu_writeshelper reuse, thenon_monotonicguard inbreak_cycles_before_title_signal, and a test that passed without the fix), and verified the outbox counts, smoke blocks, and diff against the saved files.