D3D12.X: a CPU cycle break also publishes its value into title memory #2078
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2078
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2078/head"
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?
@iggyvilla on GitHub · 2026-11-25 03:19 UTC · original
iggyvilla:xcl-cycle-break-publishes-value→main· +314 −11 · 2 files · 1 commits · merged 2026-11-25 10:41 UTCPart 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(#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 #850 / #317.What is in it
crates/xcl/src/hle/d3d12x/cpu_writes.rs: extractu64_writable_nowfromwrite_u64_now(keepingmain's #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.@futurepro62 on GitHub · 2026-11-25 03:29 UTC · original · edited 2026-11-25 03:31 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
49a2546(on its base3da2abb).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1101 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.publish_cpu_cycle_break_uses_fetch_max_and_skips_sparse_or_unwritable,cpu_cycle_break_publishes_value_to_title_memory_and_keeps_it_monotonic.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1112 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on maincbc296atoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputestsconst_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 05:10 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@JoaoPauluu on GitHub · 2026-11-25 05:22 UTC · original
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1373 here; 1371 and 1356 on the twomainruns). No line about a CPU cycle break appears in the log, so I cannot tell whether this run reached it; this is a regression run only.Tested
x86_64-pc-windows-gnu.49a2546as it is (based on3da2abb) andmainf5c5bdf, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, this PR (with other PRs in between), main.Regression run
main (first run):
this PR:
The second
mainrun: 1356 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@thehollowedone on GitHub · 2026-11-25 08:57 UTC · original
Independent native Windows run on 49a2546, clean detached checkout. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, DXC 1.8.2502.11.
cargo build --workspace --offline --locked -j 4passed.cargo test --offline --locked -j 4 -p xcl --lib cycle_break -- --nocapture --test-threads=1finished with 2 passed, 0 failed, zero skips. The tests checked monotonic publication to title memory and skipped sparse or unwritable destinations.cargo test --workspace --offline --locked --no-fail-fast -j 4 -- --nocapture --test-threads=4finished with 1113 passed, 0 failed, 46 ignored. Cargo's pass count includes 25 runtime skip notices (20 native wave64, 3 unsupported per-lane forms, 1 driver-cache control unavailable, 1 no heap windows).This run used workspace fixtures. Retail world-load behavior remains unverified by this run. AI use: Codex (GPT-6, exact variant unspecified) ran the tests and drafted this report.