Repository navigation
Conversation
…cl-dev#1732) sparse::readback_after_execute previously stalled sparse::State::queue behind the title queue (s.queue.Wait) and synchronously blocked the submitter thread inside STATE.lock() for up to 5000 ms (s.wait_for). When an async compute queue carried both a sparse write and a wait-before-signal Wait64BitValueX whose producer direct queue had not yet been submitted on the same thread, this deadlocked both the submitter thread (blocking submission of the producer queue) and sparse::State::queue for 5000 ms per submit, triggering xcl-sync-watchdog timeouts and the title's stall watchdog after 5-6 consecutive submits. Dispatch sparse readbacks to per-queue background workers that wait on a raw per-queue fence outside STATE.lock() before invoking readback_ranges, never stalling sparse::State::queue or blocking ExecuteCommandLists.
|
Independent Windows release GPU check on NVIDIA RTX 3060 Ti ( Setup
Workspace tests (
Regression run (
Base ( PR head ( Not tested: Linux / Wine, repeating AI use: Antigravity ( |
…pub(crate) Fixes compilation errors on MSVC Windows target: - D3D12.X: restores pub(crate) unsafe fn create_raw_fence in real.rs required by sparse::readback_after_execute (xcl-dev#1732). Creates an unproxied raw ID3D12Fence bypassing title vtable hooks so internal queue worker threads under Wine/vkd3d-proton signal native fences without hitting proxy mismatches. - KernelX: restores pub(crate) visibility for commit_sparse in kernelx.rs (xcl-dev#549, xcl-dev#1298), required by DirectStorage's lazy MEM_RESERVE sparse window allocation in dstorage.rs and placeholder mappings. - Recompiler: adds #[cfg(test)] gate above mod tests in emit.rs to silence unused PRELUDE_MEM import warnings in non-test release builds (xcl-dev#1524). Assisted-by: Antigravity
…driver gave up callback Eliminates compiler warnings for unused items: - D3D12.X: removes rb_fence and rb_value from sparse::State and test fixtures (xcl-dev#1732). Readback fences are now managed per-queue in RB_QUEUES by async readback workers, making the fields on State obsolete. - D3D12.X: hooks note_driver_gave_up in real::translated_compute_pso_once when driver_compile_identified returns E_OUTOFMEMORY after DRIVER_GAVE_UP_AFTER (xcl-dev#1665, xcl-dev#1524), ensuring failed massive compute pipelines are persisted in used-pipelines.txt (!<key>) and eliminating dead code warnings. Assisted-by: Antigravity
00eec16 to
64cb447
Compare
|
Thanks @LocranKing for catching that on Windows! Your diagnosis was spot on: when an unstalled queue (like Updated
(The two earlier commits |
|
Verification on RTX 3060 Ti (Windows 11): merge conflict with current |
64cb447 to
e4d8229
Compare
|
Thanks @DavidM1911! Rebased the stack (#867 -> #871 -> #877 -> #1732) onto |
XCL PR #1732 verification on Intel Arc A770Head Tested
Workspace failures and skips 24 DXIL/recompiler tests failed (20 compute PSO rejections with 0x80070057 and four output mismatches). The title e2e failed its dynamic depth-bias check (blue pixel, expected green). The log contains 25 exact Not tested Matched main run, retail-title smoke, sample-data coverage, Wine or other GPUs. AI use T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against |
e4d8229 to
2fb4601
Compare
|
Thanks @JJAutoCompare for verifying all three focused Rebased onto |
|
Independent native Windows release test for #1732 on NVIDIA RTX 3070. The synthetic title's D3D12 debug-layer run read Tested
Commands used for the build, isolated tests, grouped E2E, and full suite: cargo build --release --offline --locked --workspace
cargo test --release --offline --locked -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --exact --test-threads=1 --show-output
cargo test --release --offline --locked -p xcl --lib hle::d3d12x::sparse::tests::readback_after_execute_does_not_block_on_stalled_queue -- --exact --test-threads=1 --show-output
cargo test --release --offline --locked -p xcl --test e2e test_title_draws_with_a_root_signature_under_the_debug_layer -- --exact --test-threads=1 --show-output
cargo test --release --offline --locked -p xcl --test e2e -- --test-threads=4 --show-output
cargo test --release --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-outputNot tested
AI use
|
2fb4601 to
6fa3a01
Compare
…1946, xcl-dev#1803, xcl-dev#2297, xcl-dev#2320, xcl-dev#2333 Carries forward still-open high-value upstream PRs onto upstream/main (2898511) + our updated Wine PR stack (xcl-dev#867, xcl-dev#1395-successor, xcl-dev#871, xcl-dev#877, xcl-dev#1732). Preserves UnadoptGuard in xcl-dev#2320 KickoffX reset_one. Assisted-by: Antigravity (Gemini 4 Neon)
|
Thanks @razormontana for catching and isolating the 5/5 Root cause: Rebased onto
|
6fa3a01 to
1be3831
Compare
…1946, xcl-dev#1803, xcl-dev#2297, xcl-dev#2320, xcl-dev#2333 Carries forward still-open high-value upstream PRs onto upstream/main (2898511) + our updated Wine PR stack (xcl-dev#867, xcl-dev#1395-successor, xcl-dev#871, xcl-dev#877, xcl-dev#1732). Preserves UnadoptGuard in xcl-dev#2320 KickoffX reset_one. Assisted-by: Antigravity (Gemini 4 Neon)
|
Rebased onto |
bmjask
left a comment
There was a problem hiding this comment.
P1: a fence timeout can silently lose CPU coherence. The worker waits 5s, logs timeout and skips readback_ranges, but still marks job.done=true; readback_after_execute then returns after its synchronous wait believing immediate visibility is preserved. Timed-out jobs are never retried even if fence later completes. Retain/retry until fence completion or report/defer without claiming sync, with timeout-then-completes regression. The async visibility path also depends on #1993/#2009, whose fence-hook try-lock race remains unresolved.
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
1be3831 to
87287c4
Compare
|
Thanks @bmjask for catching the timeout coherence bug and @DavidM1911 for the Windows 11 re-verification! Addressed the P1 timeout coherence issue and rebased onto
AI use: Antigravity (Gemini 4 Neon) implemented the |
87287c4 to
c7fac70
Compare
|
A data point for this PR's idea, from What we saw on
What fixed it there, along this PR's lines (local tree, not a PR):
One thing to check in this PR's design and ours, found in review and not shown by a run: a readback done later snapshots the host chunk hashes when it is recorded, so a CPU write between the title's submit and the late readback could be overwritten. Not tested: this PR itself on AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this comment; a second pass (Claude Fable 5.2) reviewed the change. |
c7fac70 to
f14d697
Compare
|
Thanks @GreemSC for the Fixed in
Verified at
Not tested: native Windows locally; NVIDIA Linux GPUs. AI use: Antigravity (Gemini 4 Neon) implemented the snapshot guard and regression test, ran the Proton tests and 60 s smoke run, and drafted this comment. |
…er Wine (xcl-dev#175) vkd3d-proton validates iface->lpVtbl on adopted D3D12 objects passed back into d3d12core.dll (command allocators, lists, heaps, resources, PSOs, and fences). On unmodified assertion-free vkd3d-proton (such as GE-Proton or -Db_ndebug=true builds), XCL's in-place vtable adoption causes CreateCommandList/Reset to fail with E_INVALIDARG and fence waits to reject adopted fences. Under Wine (gated behind util::under_wine(), native Windows unchanged): - UnadoptGuard temporarily restores the native vtable on adopted command allocators (including alloc_pool backings and reset_pc_allocator), command lists, heaps (CreatePlacedResource/CreatePlacedResource1), RTV resources, and PSOs around calls into d3d12core.dll. - FenceProxy wraps title ID3D12Fence1 objects so the underlying PC fence keeps its native lpVtbl, unwrapping in queue Signal/Wait while preserving Fence::xcl-dev#12 completed_value_address and freeing on final Release. - real::create_raw_fence creates un-proxied native ID3D12Fence objects for XCL's own internal queue tracking (late_release, alloc_pool, list_x, cpu_writes, present, vram, drain_gpu) so un-adopted internal queues like sparse::queue() never receive a FenceProxy. Note: assert-enabled vkd3d-proton builds (such as stock Proton Experimental) still validate iface->lpVtbl inside an adopted object's own methods, so an assertion-free build (-Db_ndebug=true / GE-Proton) remains required for in-place adoption. Assisted-by: Antigravity (Google DeepMind)
On Linux with amdgpu, a multi-GiB coherent UMA window imported via OpenExistingHeapFromAddress (VK_EXT_external_memory_host userptr) causes two severe stalls: 1. GetWriteWatch(WRITE_WATCH_FLAG_RESET) on the userptr range triggers amdgpu MMU-notifier evictions (~100-200 ms/submit). 2. A multi-GiB userptr BO stalls every Vulkan GPU submission (~150 ms/frame, dropping PresentX frames). Under Wine (native Windows unchanged): - Key the default 512 MiB coherent_hint() cap on AMD GPUs (DXGI VendorId 0x1002) under Wine so NVIDIA Linux keeps a full-size coherent window (unless XCL_COHERENT_MB is set). - Allocate the coherent window without MEM_WRITE_WATCH and exclude it from watch_regions(), notifying title_textures on DirectStorage writes into it and hashing small/dynamic coherent textures with a 1/16 round-robin sweep for large ones. - Route overflow PAGE_GRAPHICS_* title GPU heaps into the sparse VRAM windows so shaders still read them directly. Assisted-by: Antigravity (Google DeepMind)
…#175) Under Wine, overflow PAGE_GRAPHICS_* title heaps are routed to sparse VRAM windows (xcl-dev#871). Eagerly mapping 64 KiB VRAM tiles for the full reserved heap up front consumes ~3.2 GiB of local VRAM for zero-filled or never- written pages before the title even leaves the menus. Add sparse::alloc_lazy (used under util::under_wine() only; native Windows unchanged): - Commits CPU pages up front so host accesses never fault, while deferring 64 KiB VRAM tile allocation until the first non-zero CPU write or GPU write target registration (placed buffers, buffer UAVs, and command-list memory writes via sparse::ensure_lazy_mapped). - Unit tests cover lazy-range overlap, hole masks, non-zero page detection, and coalesced lazy tile allocation. Assisted-by: Antigravity (Google DeepMind)
…g STATE or sparse::State::queue sparse::readback_after_execute previously stalled sparse::State::queue behind the title queue (s.queue.Wait) and synchronously blocked the submitter thread inside STATE.lock() for up to 5000 ms (s.wait_for). When an async compute queue carried both a sparse write and a wait-before-signal Wait64BitValueX whose producer direct queue had not yet been submitted on the same thread, this deadlocked both the submitter thread (blocking submission of the producer queue) and sparse::State::queue for 5000 ms per submit, triggering xcl-sync-watchdog timeouts and the title's stall watchdog after 5-6 consecutive submits. Dispatch sparse readbacks through per-queue FIFO background workers that wait on a raw per-queue fence outside STATE.lock() before invoking readback_ranges, never stalling sparse::State::queue. Track active unsatisfied queue.Wait calls via note_queue_wait (in q_wait_pc and the Wait64BitValueX GPU bridge, cleaned up in q_release via forget_queue): when the queue has an unsatisfied Wait, readback_after_execute returns immediately while the worker finishes asynchronously; when no unsatisfied Wait is active, readback_after_execute waits on the worker's completion condvar outside STATE.lock() so CPU reads immediately after a GPU fence wait (such as Write32BitValueBottomOfPipeX in testtitle) always observe the updated bytes. Snapshot per-64-byte-segment CPU hashes when recording each readback job and skip copying any segment whose CPU bytes changed before the worker runs, so a late/deferred readback never overwrites a newer title CPU write and leaves `sent` dirty for the next upload while still allowing consecutive deferred readbacks on the same range to land. Assisted-by: Antigravity (Gemini 4 Neon)
|
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #1732 updated head Setup
Targeted RTX 4060 release unit & GPU tests (
|
|
@gustavsi thanks for the fix and the test. A note so you don't wait on me for it: our current Linux tree is on AI use: Claude Code (Claude Opus 5.5) wrote this reply. |
f14d697 to
c992ec8
Compare
…add XCL_PREPARE=0 opt-out Bring fork main in sync with the latest upstream PR review fixes: - xcl-dev#867: UnadoptGuard COM +1 refcount pin, under_wine() gate on create_raw_fence, and track_end_title_fence for list_x cell fences. - xcl-dev#2477: skips_guard helper and 10 s deadline loop in concurrent in-place vtable test. - xcl-dev#1732: RbStatus + retained FIFO deferred retry and per-64-byte-segment RbSnapshot/last_rb CPU-write protection for async/deferred readbacks. - present/preparation: allow XCL_PREPARE=0 (matching upstream nvidia-dev) to skip startup shader preparation during smoke runs and quick iterations. Assisted-by: Antigravity (Gemini 4 Neon)
Move
sparse::readback_after_executeoffsparse::State::queueand out from underSTATE.lock()into per-queue FIFO background workers, completing asynchronously when the queue has an unsatisfied title/wait-before-signal GPUqueue.Wait(avoiding CPU/GPU deadlocks on wait-before-signalWait64BitValueX) and synchronously otherwise (preserving immediate CPU visibility after a GPU fence wait). Part of #1452.Stacked on #877; only the top commit (
c992ec81) belongs here.Previously,
sparse::readback_after_executelockedSTATE, calleds.queue.Wait(&s.rb_fence, v), and synchronously executeds.readback_ranges(&merged)(s.wait_for(s.value)with a 5,000 ms timeout) insideExecuteCommandLists. When an async compute queue carried both a sparse memory write and a wait-before-signalWait64BitValueXwhose producer direct queue had not yet been submitted on the same thread, this deadlocked both the submitter thread (preventing submission of the producer queue) andsparse::State::queuefor 5,000 ms per submit, triggering repeatedxcl-sync-watchdogtimeouts and causing a retail title's stall watchdog to abort after 5–6 consecutive submits.With per-queue FIFO workers waiting on a raw per-queue fence outside
STATE.lock()before invokingreadback_ranges,sparse::State::queueis never stalled behind a blocked title queue. Active unsatisfied titlequeue.Waitcalls and unsubmitted wait-before-signalWait64BitValueXbridges are tracked viasparse::note_queue_wait(ignoring XCL's own internal fences such assparse::before_execute'ss.fenceso an in-flight internal upload underXCL_D3D12_DEBUG=1never causesreadback_after_executeto return beforeCopyBufferRegioncompletes, fixing theWrite32BitValueBottomOfPipeXzero-read reported by @razormontana).If a fence wait times out after 5,000 ms (while the device is still alive), the worker wakes any synchronous caller with
RbStatus::Deferred(never falsely claimingRbStatus::Completed) and retains the job in a per-worker FIFOdeferred: VecDeque<RbJob>queue, polling and draining it in order once the fence completes so CPU coherence is never silently lost (fixing @bmjask's P1).To prevent an asynchronous or deferred readback from overwriting a newer CPU write made after the submit (flagged by @GreemSC),
readback_after_executesnapshots the per-64-byte-segment CPU hashes of the committed target ranges when recording the job. At copy-back time,readback_rangesskips any segment whose current CPU bytes differ from the snapshot (unless they match an intervening readback recorded while multiple jobs are in flight, so consecutive deferred readbacks on the same range still land) and leavessentdirty for any skipped 64-byte chunk so the nextbefore_executeuploads the CPU's newer bytes.What is in it
crates/xcl/src/hle/d3d12x/sparse.rs:RB_QUEUESmap (RbQueueStateholding a rawID3D12Fenceviasuper::real::create_raw_fence, monotonic fence value, and channel sender to a dedicatedxcl-sparse-rb-<queue>FIFO worker thread) andQUEUE_WAITStracking (note_queue_wait,queue_has_unsatisfied_wait,forget_queue).readback_after_executefilter/merge sparse ranges usinguma::get(), signal the queue's fence, register new queues withs.note_queue(queue)(preserving D3D12.X: quarantine unmapped parked sparse tiles behind GPU fences #2345's parked-tile quarantine tracking), snapshot committed 64-byte-bounded segment hashes (State::snapshot_ranges) underSTATE.lock(), and enqueue anRbJobwithout holdingSTATEacross GPU waits — returning immediately ifqueue_has_unsatisfied_waitis true, or waiting on the job'sRbStatuscondvar outsideSTATE.lock()otherwise (logging when a synchronous wait is deferred instead of completed).State::readback_rangescheck the recordedRbSnapshot(and a boundedlast_rbmap active only while multiple readback jobs are in flight) before copying each 64-byte-bounded segment, skipping CPU-modified segments without marking their 64-byte chunk clean insent, and flushing staging with at least one tile of headroom so staging flushes never split a 64-byte segment.spawn_rb_worker_with) wait on its fence outsideSTATE.lock()(5,000 ms timeout). On completion, drain any earlier deferred jobs first in FIFO order, runreadback_ranges, and reportRbStatus::Completed; on timeout (whileGetCompletedValue() != u64::MAX), reportRbStatus::Deferredand retain the job indeferred: VecDeque<RbJob>so it retries every 20 ms (and on subsequent jobs / bounded teardown drain) until the fence completes.readback_after_execute_does_not_block_on_stalled_queueinternal_fence_wait_keeps_readback_synchronoustimeout_then_completes_still_reads_back_cpu_memorydeferred_readback_preserves_newer_cpu_writescrates/xcl/src/hle/d3d12x/real.rs&crates/xcl/src/hle/d3d12x/list_x.rs:queue.Waitcalls (is_fenceinq_wait_pcandqueue_dispatch) and unsubmittedWait64BitValueXGPU bridges (unsubmittedintry_gpu_wait) viasparse::note_queue_wait, and clean up per-queue state inq_releaseviasparse::forget_queue.Tested
GE-Proton11-14-x86_64,vkd3d-proton(-Db_ndebug=true), DXC 1.9.2609.5, cross-compiledx86_64-pc-windows-msvc(clang-cl+lld-link).29352403, onmain08db8020+ D3D12.X: preserve native vtables and wrap fences for vkd3d-proton under Wine (#175) #867d9e6ad51+ Memory: avoid amdgpu userptr stalls under Wine (#175) #871a800c38a) atc992ec81(no conflicts, commit diff unchanged) underGE-Proton11-14(XCL_DXC_DIRset):hle::d3d12x::sparse:: --test-threads=1: 22 passed, 0 failed, 1 ignored (includingdeferred_readback_preserves_newer_cpu_writes,timeout_then_completes_still_reads_back_cpu_memory,readback_after_execute_does_not_block_on_stalled_queue, andinternal_fence_wait_keeps_readback_synchronous)hle::d3d12x::list_x:: --test-threads=1: 40 passed, 0 failed, 0 ignoredhle::d3d12x::real:: --test-threads=1: 63 passed, 0 failed, 0 ignoredhle::d3d12x::vram:: --test-threads=1: 19 passed, 0 failed, 1 ignoredgpu::uma:: --test-threads=1: 12 passed, 0 failed, 0 ignoredhle::d3d12x::alloc_pool:: --test-threads=4(× 3): 4 passed, 0 failed, 0 ignored each--exact gpu_sparse_vram_descriptors_buffers_and_xmem gpu_valu_float_and_int: 2 passed, 0 failed, 0SKIPPEDpwsh ./scripts/smoke.ps1(withGE-Proton11-14wrapper):1091frames shown (PresentX 1091,60 60 60/2 s),exit: 0x0,0crashes,0device removals.Regression run
Produced under Wine (
GE-Proton11-14, AMD Radeon RX 9060 XT,XCL_NETWORK=0 XCL_PSO_PRELOAD=0 XCL_RUN_SECONDS=60 XCL_ACTIVITY=1,VKD3D_CONFIG=""). The PR run used unmodifiedpwsh ./scripts/smoke.ps1via a thin Wine wrapper;main(e0d93c84) crashed before writingreport.json, so its block was extracted from the samexcl.log(peak commit: 0 MBis what Wine reports inxcl.log).main(e0d93c84):This PR (
c992ec81, stacked on #877):Not tested
XCL_D3D12_DEBUG=1).AI use
RbSnapshot/last_rbCPU-write protection anddeferred_readback_preserves_newer_cpu_writesregression test for @GreemSC's review, restacked onto updated Memory: lazily map sparse VRAM tiles for Wine graphics heaps (#175) #877 (29352403), ran the Proton tests and 60 s smoke run atc992ec81, and updated this description.c7fac707restack verification.