Skip to content

D3D12.X: a stalled sparse upload retries its unsent chunks and reuses no busy allocator - #2821

Open
KOLESNiii wants to merge 6 commits into
xcl-dev:mainfrom
KOLESNiii:d3d12x-sparse-ring-stall
Open

KOLESNiii wants to merge 6 commits into
xcl-dev:mainfrom
KOLESNiii:d3d12x-sparse-ring-stall

Conversation

@KOLESNiii

@KOLESNiii KOLESNiii commented Nov 26, 2026 •

Copy link
Copy Markdown

Stacked on #1277 and #1419; only the top four commits belong here. Part of #1833. This is S1 from the extraction plan in #2787.

#1277 (ExoCalibra) stops upload_dirty from looping forever, holding the sparse STATE lock, when the staging ring's oldest fence never advances. That loop blocked xcl-activity and every later title submit. #1419 (gridoe) stops a fence wait from returning early on a stale signal of the reused event. ettehn saw that happen after a timed-out wait on this PR. This PR ports #2778's two follow-ups (bmjask) and adds two fixes to the retry:

  • Retry exactly the unsent part. When the ring wait times out, or there is no staging or upload slot, only the 64-byte chunks not yet submitted are marked for the next upload. Chunks already submitted in the same page are left alone. upload_dirty returns whether everything was submitted. A synchronous readback_now stops instead of copying stale GPU bytes over CPU memory when its upload did not go through.
  • No allocator reuse after a failed wait. begin_slot returns None instead of resetting an allocator the GPU may still be using, and checks Reset/Close results. The readback path stops before Reset or before writing to CPU memory when its wait, Close or Reset fails. Failed zero-fills go back to to_zero. The normal path is unchanged.
  • The marked chunks are scanned again. The write-watch that reported a page is reset when the page is scanned, so marked chunks were found again only after another CPU write to the same page. The pages are now recorded and scanned again at the next submit.
  • CPU writes wait for clears that could not be sent (KDenKC). Otherwise the clears, sent at a later submit, zeroed the newer writes. A failed clear with no CPU writes in the same submit retries nothing (it indexed an empty run list and panicked holding STATE, KDenKC).

The title's own work is not held back while the sparse queue is stalled. Work submitted during the stall can read the chunks left unsent (see gut0to's review thread).

What is in it

  • D3D12.X: stop sparse upload_dirty ring wait when fence times out: D3D12.X: stop sparse upload_dirty ring wait when fence times out #1277's commit, author kept. For current main, I added the two State fields main has since gained (quarantined, queue_fences) to its test's initializer. Without them the test does not compile. D3D12.X: stop sparse upload_dirty ring wait when fence times out #1277 needs the same fix when it is rebased.
  • D3D12.X: wait_for ignores stale signals on the reusable sparse fence event: D3D12.X: wait_for ignores stale signals on the reusable sparse fence event #1419's commit, author kept. On top of D3D12.X: stop sparse upload_dirty ring wait when fence times out #1277, wait_for_ms passes its own timeout to wait_fence_until and still returns whether the fence was reached.
  • D3D12.X: stop stalled sparse ring reclaim cleanly (crates/xcl/src/hle/d3d12x/sparse.rs), ported from faea307a. The conflicts were resolved by hand: Bmjask/ultra performance redesign #2778's stall tracing span and its quarantine-fence helpers are left out. Tests: a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix, a_stalled_upload_ring_returns_and_retries_exact_chunks.
  • D3D12.X: abort sparse allocator reuse after wait failure (same file), ported from 37271a3c. It keeps main's readback ExecuteCommandLists call, not Bmjask/ultra performance redesign #2778's native_queue_execute. The stalled-ring test also checks that a slot whose wait timed out is not reset.
  • D3D12.X: sparse chunks a stalled upload left unsent are scanned again (same file): retry_pages, scan_retry_pages. Test: unsent_chunks_are_scanned_again_without_a_new_cpu_write.
  • D3D12.X: sparse CPU writes wait for tile clears that could not be sent (same file): upload_zeros_then_dirty. Tests: cpu_writes_wait_for_tile_clears_that_could_not_be_submitted, and the empty-runs case in a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix.

Tested

  • NVIDIA GeForce RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, rustc 1.100.0, debug tests and release smoke runs
  • cargo test --workspace -- --test-threads=4 on 970b8a4a: 1441 passed, 0 failed, 47 ignored
  • 25 SKIPPED on this adapter: 24 recompiler GPU tests with no wave64 (or the wave32 per-lane form refused), and heap_window_out_of_memory_falls_back_to_the_switch_form with no heap windows
  • cargo test -p xcl --lib hle::d3d12x::sparse -- --test-threads=1: 23 passed, 0 failed, 1 ignored (early_commit_timing)
  • With the two new fixes taken out, their tests fail (the unsent chunks were not found again, and upload_zeros_then_dirty returning true because the CPU writes were submitted)
  • Each commit of the stack builds (cargo test -p xcl --lib --no-run)
  • The sparse filter run above was on 43425fba; the empty-runs guard was squashed in after it.
  • Others' reports in the thread were made on the earlier head 475341d1, including an AMD RX 9070 XT run of the sparse tests (DarkPanda69). They do not cover the last two commits or D3D12.X: wait_for ignores stale signals on the reusable sparse fence event #1419's.

Regression run

Both runs with XCL_PRESS_AT=15:A.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1458 (PresentX 1458)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17529 MB

This PR:

xcl-smoke v1
commit: 970b8a4ad7c5a64e6bb5e605a5cd16ecbd1cb784
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1504 (PresentX 1504)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17872 MB

Neither run logged a sparse: warning, so no fence wait timed out and the new failure paths were not reached. The PR's run went through the normal upload path (sparse windows: 4096 submits, 1671 MB of CPU writes uploaded at 42 s).

Not tested

  • A real stalled sparse queue on the retail title. The timeout paths are covered only by the unit tests, with a fence nothing signals or a busy upload slot.
  • Reset/Close failures, and a failed zero-buffer allocation. No test injects them.
  • Holding the title's work back until the unsent chunks are uploaded: not done here.
  • Intel GPUs, and AMD on this head. The 47 ignored tests.

AI use

🤖 Generated with Claude Code

sparse::State::wait_for intentionally returns after 5 s with a warning if the sparse queue stalls, but upload_dirty wrapped wait_for in a while loop waiting for staging ring space. When the oldest in-flight fence failed to advance, reclaim_ring freed nothing and upload_dirty looped forever while holding the global STATE mutex, blocking xcl-activity (pool_bytes) and every submitting thread.

Return whether wait_for reached its target fence value, bail out of upload_dirty with a bounded warning on timeout so STATE is released, and add a GPU regression test reproducing a full staging ring with a stalled fence.

(cherry picked from commit 0f66820)
@KOLESNiii
KOLESNiii marked this pull request as ready for review November 26, 2026 14:32
@ettehn

ettehn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent Windows check on 475341d1ee5b173dee4107562b2fd38a5fe73dc3 (RTX 5070 Ti Laptop, driver 621.24, Windows 11 x64 build 26200, Rust 1.97.1 MSVC). The stock sparse tests passed 20/0/1 with no capability skips. A recovery check with a real gated D3D12 queue uncovered an interaction with #1419.

The local fixture logically fills the staging ring, queues a real copy behind a gate fence, and dirties two adjacent 64-byte chunks. The 20 ms upload and allocator waits correctly time out without submitting anything. After releasing the gate, the rescan correctly selects the same 128 bytes and the retry submits. The following wait for fence 4 returns false at completed value 3, with a “5000 ms” warning even though the entire test finished in 0.38–0.50 s. An earlier registration on the shared auto-reset event can still wake this later wait. The focused test reproduced the premature return in 6/6 fresh processes.

I then used the unchanged wait_fence_until helper and test from #1419 (3861d2e2b561482933c657802cc5801b28bc60ba) locally on this head, passing the existing wait_for_ms timeout into the helper. The sparse suite was 22 passed, 0 failed, 1 ignored, and the gated check then passed 10/10 fresh processes. The retry submitted the expected 128 bytes and an actual GPU readback matched all 4,096 bytes, including the untouched neighbors.

Command: cargo test --locked --offline -p xcl --lib -j 2 hle::d3d12x::sparse::tests -- --test-threads=1 --nocapture; repeats ran the gated fixture alone from the resulting test executable. Synthetic fault injection only, no retail run. OpenAI Codex (6.2sol) assisted with verification.

@DarkPanda69

DarkPanda69 commented Nov 26, 2026 •

Copy link
Copy Markdown

Update for head 970b8a4: same, 23 passed, 0 failed, 1 ignored, 0 SKIPPED on the RX 9070 XT, applied on main 8b957be.

Update for head 43425fb: still passes. Applied on main 8b957be, hle::d3d12x::sparse gives 23 passed, 0 failed, 1 ignored, 0 SKIPPED on the RX 9070 XT (the first adapter, as below).


AMD run for the Not tested line.

Tested: pass, head 475341d applied on main b49be18, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X.
cargo test -p xcl --lib -- hle::d3d12x::sparse --test-threads=4 --nocapture:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010: 20 passed, 0 failed, 1 ignored, 0 SKIPPED. a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix, a_stalled_upload_ring_returns_and_retries_exact_chunks and upload_dirty_exits_when_ring_fence_wait_times_out are among them.

The sparse tests make their device with D3D12CreateDevice(None, ..), so they ran on the first adapter, which is the RX 9070 XT here.

Not tested: a real stalled sparse queue in a title; Reset/Close failures; Intel.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Under Wine + vkd3d-proton on an RTX 4070, this pull request's sparse:: tests passed, and in 3 title runs with it no sparse fence wait timed out: no sparse: warning was printed, with it or without it. The title stopped presenting about where it does without it (72.1 to 76.2 s, against 76.1 and 86.7 s in 2 runs without it), and no run lost the device.

Setup: main b49be18 + #684 (e56dbc3, which our runs need to get this far), against the same + this pull request (475341d1), release, Wine 11.21 Staging + vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, RTX 4070 12 GB, driver 615.71.09. Title: 120 s each, A pressed once the title presented steadily, XCL_PSO_PRELOAD=0, the first-run screens completed once, no story progress. Tests: -- sparse:: --test-threads=4.

Run Tree A pressed Last 2 s with presents ends sparse: warnings Frames
1 main + #684 18.4 s 86.7 s 0 1,480
2 main + #684 16.2 s 76.1 s 0 1,346
3 + #2821 16.4 s 74.7 s 0 1,302
4 + #2821 16.5 s 72.1 s 0 1,280
5 + #2821 16.5 s 76.2 s 0 1,308
  • No sparse fence wait timed out, so the title's stop here is not a stalled sparse ring. The runs did go through the changed upload path: by 30.3 s each run with it had logged sparse windows: 2048 submits, 1599 MB of CPU writes uploaded, as the runs without it had by 31.5 s, so the normal path still works here. Its new failure branches were not reached.
  • The two new tests, a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix and a_stalled_upload_ring_returns_and_retries_exact_chunks, and D3D12.X: stop sparse upload_dirty ring wait when fence times out #1277's upload_dirty_exits_when_ring_fence_wait_times_out passed (20 passed, 1 ignored in sparse::).
  • The early return ettehn found could not come up here: it follows a wait that timed out, and no wait timed out in these runs.

Not tested: Windows; a ring stall in the title; Reset or Close failures; the title past the point where it stops here; the whole test suite; this pull request with #1419's wait_fence_until.

AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@tiagonleal

Copy link
Copy Markdown
Contributor

Suite on RTX 5070 Ti (Windows 11) at 475341d1: 1434 passed, 4 failed (the fuzz out-of-memory ones, same on main); the PR's sparse tests pass

Tested

  • Head 475341d1ee5b173dee4107562b2fd38a5fe73dc3, clean detached worktree, built as is, debug. PR open and head unchanged when I started. Its base is main b49be183; the head is three commits on it: 3f193cf1 (D3D12.X: stop sparse upload_dirty ring wait when fence times out #1277's commit), f6fd35d6 and 475341d1. D3D12.X: stop sparse upload_dirty ring wait when fence times out #1277 was not built on its own.
  • RTX 5070 Ti 16 GB (driver 32.0.16.1742), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, rustc 1.100.0 (0ef1bc386 2026-11-09). NVIDIA profile for xcl.exe: shader heap 1024 MB. DXC in use: Windows SDK 1.8.2502.11.
  • cargo build --workspace: ok. cargo test --workspace --no-fail-fast -- --test-threads=4: 1434 passed, 4 failed, 47 ignored.
  • 25 lines contain SKIPPED: 21 "no wave64", 3 wave32 per-lane forms refused (f16 arithmetic, f16 packed, f32 conversions), 1 heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, each CreateComputePipelineState: Not enough memory resources are available to complete this operation. (0x8007000E). They fail the same way on main b49be183 (cargo test -p xcl --lib gpu::dxil::fuzz_tests::fuzz_validate_and_gpu: 0 passed, 4 failed).
  • New tests: cargo test -p xcl --lib hle::d3d12x::sparse -- --nocapture --test-threads=1: 20 passed, 0 failed, 1 ignored (early_commit_timing), no SKIPPED lines. It includes a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix and a_stalled_upload_ring_returns_and_retries_exact_chunks.

Not tested

AI use

  • Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Sonnet 5.5) ran the builds and tests and wrote this; I checked it.

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Ran the stalled-sparse-upload tests at 475341d1:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib -- a_stalled_ring a_stalled_upload_ring --test-threads=1
2 passed; 0 failed; 0 ignored; 1337 filtered out      (exit 0)

Both new tests pass here. They use an unsignalled fence to exercise the timeout path: only the unsubmitted dirty 64-byte chunks are retried, and the stalled allocator is not reset. These are CPU/D3D12-mock tests; no real stalled GPU queue was produced.

What this adds: the author's suite ran on an RTX 2070 SUPER. This is a Blackwell host, and the thread has no report from another machine.

Not tested: a real stalled sparse queue in the title, injected Reset/Close failures, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, Wine, release profile, title data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@gut0to gut0to left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted review (OpenAI GPT-6). I traced this timeout path in the diff; I did not run the tests or the game.

Comment thread crates/xcl/src/hle/d3d12x/sparse.rs Outdated
}
if !dirty_runs.is_empty() {
s.upload_dirty(&dirty_runs);
let _ = s.upload_dirty(&dirty_runs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When upload_dirty returns false, retry_dirty_from only marks the unsent CPU chunks for a later scan, but before_execute continues toward the title queue submission. That submission can consume stale VRAM for work depending on these writes. Could this failure path defer the title work or otherwise keep it from executing until the dirty suffix has been uploaded? AI-assisted review (OpenAI GPT-6); I checked this against the timeout/retry flow in this diff and did not run tests or the game.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the title's work still goes ahead: this PR does not hold back ExecuteCommandLists, and doing that is a larger change than this PR. Before #1277 the same stall kept upload_dirty looping with the STATE lock held, so the title hung instead. Now its queue still GPU-waits for every upload that was submitted, and only the chunks left unsent can be stale for work submitted during the stall.

Checking this turned up a real gap: the unsent chunks were marked, but their page was scanned again only when the CPU wrote it again, since its write-watch had already been reset. A page written once stayed stale. D3D12.X: sparse chunks a stalled upload left unsent are scanned again now records those pages and scans them again at the next submit (test unsent_chunks_are_scanned_again_without_a_new_cpu_write, which fails without the change). So the stale window ends at the first submit after the queue moves again. Holding the title's work back is listed under Not tested as not done.

AI use: Claude Code (Claude Opus 5.5) checked this and wrote the change and this reply.

@GodlyBDS

Copy link
Copy Markdown

The timeout handling is also relevant to the current nvidia-dev sparse path at af2cecc40886a8682ecf3267f5328c6dc4b66ad7. Its upload-slot wait returns no status before allocator reset, and the ring-space loop can retry the same unfinished fence. Its synchronous readback path also resets after the void wait. That branch has a different sparse/queue implementation from this PR's main base and needs its own validation.

In one retained Ampere world-transition run, the existing five-second sparse warning occurred with the queue one fence behind shortly before a q0 compute ExecuteIndirect hung. The warning alone does not identify which sparse caller was waiting or which operation initiated the stall. The preceding GPU timestamp and the DRED breadcrumb agree on the compute indirect as the unfinished operation. Retained runtime measurements.

On the same Windows 10 19045 / RTX 3090 Ti host, I ran the exact 475341d1ee5b173dee4107562b2fd38a5fe73dc3 timeout fixtures. cargo test --offline --locked -j 30 -p xcl --lib a_stalled_ -- --test-threads=1 --nocapture returned 2 passed, 0 failed, 0 ignored with rustc 1.98.1 MSVC. The fixtures used synthetic unsignalled fences. OpenAI Codex (GPT-6 family) checked the paths, correlated the logs and ran the fixtures.

@KDenKC

KDenKC commented Nov 26, 2026

Copy link
Copy Markdown

Source review of 475341d1, no run. The new retry of failed tile clears can now land after newer data:

In before_execute (sparse.rs:~1702-1709), when upload_zeros fails (ensure_zero_buf fails, or begin_slot returns None), the clears go back to s.to_zero, but the function still goes on to upload_dirty(&dirty_runs). If that succeeds, CPU writes uploaded now (their dirty bits already reset by the write-watch scan) reach VRAM before the clear. On the next before_execute, the re-queued clear zeroes those tiles over them, which is the write-after-write the comment above it ("Submit tile clears before CPU writes…") rules out. readback_now (~1378) already returns right after re-queuing in the same case. Doing the same here, or keeping dirty_runs pending until the clears are submitted, would keep the order. On main a failed clear was dropped (stale data, not newer data overwritten), so this ordering is new with the retry.

How often: we saw no sparse fence timeouts or clear failures in ~150 runs on an RTX 5090. It needs a ring that stays busy past its wait, or a failed zero-buffer allocation (a 5 s sparse wait has been reported on Ampere).

Not tested: no build or run of this head.

AI use: Gemini (Antigravity) found it in a review. Claude Code (Claude Opus 5.5) checked it against 475341d1 and main and wrote this.

…event

(cherry picked from commit 3861d2e, xcl-dev#1419; on top of xcl-dev#1277,
wait_for_ms passes its own timeout to wait_fence_until and keeps returning whether the fence
was reached)
@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2821 at 475341d1ee5b173dee4107562b2fd38a5fe73dc3 (3 commits on merge-base origin/main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7; parent f6fd35d669bcecc476db2901f606a7a5f55f263f). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags, no input)

Targeted RTX 4060 release unit & GPU tests (475341d1)

  • cargo test --release -p xcl --lib a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib a_stalled_upload_ring_returns_and_retries_exact_chunks -- --nocapture: 1 passed, 0 failed, 0 ignored (0.27 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib upload_dirty_exits_when_ring_fence_wait_times_out -- --nocapture: 1 passed, 0 failed, 0 ignored (0.27 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib hle::d3d12x::sparse:: (3 consecutive parallel passes): 20 passed, 0 failed, 1 ignored (early_commit_timing ignored) on all 3 passes (0.43 s / 0.43 s / 0.43 s, 0 SKIPPED).

Paired 60 s RTX 4060 smoke (b49be183 vs 475341d1)

Both runs held steady 60/2 s pacing with 0 device removals and 0 crashes (475341d1 xcl.log: 6,176 MB peak / 6,116 MB end local VRAM, 4,650 MB end non-local VRAM; sparse windows: 4096 submits, 1388 MB of CPU writes uploaded, 308 ms spent, 13412 tiles mapped, 0 frame-event timeouts, 0 sparse ring stalls; 19,549 translated draws / 1,024 dispatches with 0 skipped).

Merge-base origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2821 head (475341d1):

xcl-smoke v1
commit: 475341d1ee5b173dee4107562b2fd38a5fe73dc3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1612 (PresentX 1612)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13978 MB

Limits of coverage

  • No live sparse upload ring-fence stall occurred during the 60 s quiet smoke (0 timeouts/stalls), so the stalled-upload retry/timeout fallback path (including downstream before_execute behavior when upload_dirty returns false) was exercised only by the 3 targeted release tests above rather than live GPU timeout conditions.
  • Full workspace test suite was not re-run (only the 3 new tests individually, 3 parallel passes of hle::d3d12x::sparse::, release build, and paired 60 s smokes).
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit/GPU tests, release build, and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory/upload metrics, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

bmjask and others added 3 commits November 26, 2026 16:36
The sparse upload ring retried a five-second fence wait forever while holding global sparse state. A stalled upload queue therefore blocked activity reporting and every later title submission permanently.\n\nAdapt xcl-dev#1277's bounded exit, but preserve correctness beyond the source patch: mark exactly the unsubmitted 64-byte chunk suffix for retry instead of leaving its sent hashes stale or invalidating already-submitted chunks in the same page. A synchronous readback aborts when its prerequisite upload did not complete, so it cannot overwrite CPU memory with stale GPU data.\n\nThe Windows GNU library/test cross-check passed with the existing warnings. Windows MSVC runtime, GPU execution, and smoke tests were not available here.\n\nSource diagnosis and timeout test: xcl-dev#1277 by ExoCalibra, assisted by Antigravity (Gemini 4 Neon).\n\nAssisted-by: Codex (GPT-5.6-sol)

(cherry picked from commit faea307)
Sparse upload and readback paths continued after a five-second fence timeout, resetting command allocators which the GPU could still be using and publishing readback staging bytes whose copy had not completed. Reset and Close failures were ignored as well.\n\nMake upload-slot acquisition fail closed, retry exact dirty or zero work, and abort readback before allocator reuse or CPU publication whenever its wait or command-list transition fails. The healthy asynchronous path is unchanged.\n\nThe Windows GNU library/test cross-check passed with the existing warnings. Windows MSVC runtime, GPU execution, and smoke tests were not available here.\n\nAssisted-by: Codex (GPT-5.6-sol)

(cherry picked from commit 37271a3)
retry_sent_range marks the chunks a stalled upload could not submit as
unsent, but before_execute only scans the pages the write-watch reports,
and that write-watch was reset when the page was first scanned. The
marked chunks therefore stayed stale in video memory until the CPU wrote
the same page again, which a page written once may never do.

retry_sent_range now records the page, and before_execute scans the
recorded pages again with the write-watch's ones. A chunk already sent
hashes equal and is not uploaded twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KOLESNiii added a commit to KOLESNiii/xcl that referenced this pull request Nov 26, 2026
Since a failed tile clear goes back to to_zero, before_execute could
still upload the submit's CPU writes when the clears found no upload
slot or zero buffer. The clears then went out at a later submit, after
those writes, and zeroed them: the write-after-write that submitting the
clears first is there to avoid. On main a failed clear was dropped.

When the clears cannot be submitted, the CPU writes are now marked for
the next upload with them, as readback_now already stops in that case.

Reported by KDenKC in xcl-dev#2821.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the d3d12x-sparse-ring-stall branch from 475341d to 43425fb Compare November 26, 2026 17:12
@KOLESNiii

Copy link
Copy Markdown
Author

Thanks for the reports and reviews. 43425fba addresses them:

The description has the new test counts and regression runs. The earlier test reports were made on 475341d1 and do not cover the new commits.

AI use: Claude Code (Claude Opus 5.5) made the changes, ran the tests and wrote this comment.

@KDenKC

KDenKC commented Nov 26, 2026

Copy link
Copy Markdown

Thanks @KOLESNiii, the clear/write ordering is fixed in 43425fba. One new edge in it: upload_zeros_then_dirty (sparse.rs:1232-1236) calls retry_dirty_from(dirty_runs, 0, 0) when the clears cannot be submitted, and visit_unsubmitted_dirty (:1693-1694) starts with let (a, n) = runs[index];. before_execute calls it unconditionally (:1757), so a submit that has tile clears but no CPU writes (dirty_runs empty), at a moment when the clears fail, indexes an empty slice and panics while STATE is held, which poisons it for the rest of the run. An if index >= runs.len() { return; } at the top of visit_unsubmitted_dirty (or an empty check in retry_dirty_from) covers it. A synthetic test could make the clear fail with empty dirty runs.

AI use: Gemini (Antigravity) found it in a review. Claude Code (Claude Opus 5.5) checked it against 43425fba and wrote this.

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Re-ran the sparse-upload tests at 43425fb after the head moved from 475341d; this is a new response in the same thread, not an edit of my earlier report:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_stalled_upload_ring_returns_and_retries_exact_chunks -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib unsent_chunks_are_scanned_again_without_a_new_cpu_write -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib cpu_writes_wait_for_tile_clears_that_could_not_be_submitted -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

All four pass here, including the two added in this push (unsent_chunks_are_scanned_again_without_a_new_cpu_write and cpu_writes_wait_for_tile_clears_that_could_not_be_submitted). They use mock fences and unsignalled queues; no real stalled GPU queue was produced. The author's suite ran on an RTX 2070 SUPER; this adds a second NVIDIA datapoint on a Blackwell desktop part.

Not tested: a real stalled sparse queue in the title, injected Reset/Close failures, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

Since a failed tile clear goes back to to_zero, before_execute could
still upload the submit's CPU writes when the clears found no upload
slot or zero buffer. The clears then went out at a later submit, after
those writes, and zeroed them: the write-after-write that submitting the
clears first is there to avoid. On main a failed clear was dropped.

When the clears cannot be submitted, the CPU writes are now marked for
the next upload with them, as readback_now already stops in that case.

Reported by KDenKC in xcl-dev#2821.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KOLESNiii
KOLESNiii force-pushed the d3d12x-sparse-ring-stall branch from 43425fb to 970b8a4 Compare November 26, 2026 18:29
@KOLESNiii

Copy link
Copy Markdown
Author

Thanks @KDenKC, confirmed: with tile clears but no CPU writes in a submit, a failed clear sent an empty dirty_runs to visit_unsubmitted_dirty, which read runs[0]. Fixed in 970b8a4a (squashed into the clear/write ordering commit). visit_unsubmitted_dirty now returns when index >= runs.len(), so every retry_dirty_from caller is covered. a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix gained an empty-runs case, which panics without the guard.

The full suite and a new smoke run on 970b8a4a are running; the description will be updated with them.

AI use: Claude Code (Claude Opus 5.5) checked the report, wrote the fix and this reply.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

At head 970b8a4a, under Wine + vkd3d-proton on the RTX 4070, sparse:: passed (23 passed, 1 ignored). In 3 title runs no sparse: warning was printed, the title stopped presenting at 76.2 to 82.0 s (72.1 to 76.2 s on 475341d1 in my comment above, 76.1 and 86.7 s without this pull request), and no run lost the device.

Setup as there: main b49be18 + #684 (e56dbc3) + this pull request, release, 120 s each, A pressed once the title presented steadily, XCL_PSO_PRELOAD=0.

Run A pressed Last 2 s with presents ends sparse: warnings Frames
1 18.4 s 82.0 s 0 1,430
2 16.4 s 76.5 s 0 1,400
3 16.3 s 76.2 s 0 1,463
  • The tests added since 475341d1 passed here: unsent_chunks_are_scanned_again_without_a_new_cpu_write, cpu_writes_wait_for_tile_clears_that_could_not_be_submitted, and D3D12.X: wait_for ignores stale signals on the reusable sparse fence event #1419's wait_fence_until_ignores_stale_event_signal, now in this pull request. So did a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix with its new empty-runs case.
  • Each run had logged sparse windows: 2048 submits by 31.5 s, so the changed upload path ran. Runs 1 and 2 logged NVIDIA channel-allocation failures (GspRmAlloc failed, NV_ERR_STATE_IN_USE) in their first 2 s, before the first sparse submit, and run 3 none. No run logged an out-of-memory or Xid message.

Not tested: Windows; a ring stall or a failed tile clear in the title; the whole test suite.

AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Re-ran the sparse-upload tests at 970b8a4 after the head moved from 43425fb; this is a new response in the same thread, not an edit of my earlier report:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_stalled_upload_ring_returns_and_retries_exact_chunks -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib unsent_chunks_are_scanned_again_without_a_new_cpu_write -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib cpu_writes_wait_for_tile_clears_that_could_not_be_submitted -- --test-threads=1
1 passed; 0 failed; 0 ignored; 0 measured; 1341 filtered out      (exit 0)

All four pass here. The new push adds a bounds guard in visit_unsubmitted_dirty and one assertion in the first test for failed tile clears with no CPU writes; that assertion ran in this pass. These are mock-fence tests, not a real stalled GPU queue.

Not tested: a real stalled sparse queue, injected Reset/Close failures, the full workspace suite, a paired smoke run, AMD and Intel GPUs, native wave64, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@Decodere

Copy link
Copy Markdown
Contributor

Follow-up independent desktop NVIDIA verification of PR #2821 at updated head 970b8a4ad7c5a64e6bb5e605a5cd16ecbd1cb784 (6 commits 3f193cf1 -> 02728e0d -> 7621090a -> 01981673 -> 405371a0 -> 970b8a4a on merge-base b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, pre-#2555 ancestor of main; parent 405371a0a2d1542faaa6e3353728a8b21eb75939). This supersedes our earlier check at 475341d1ee5b173dee4107562b2fd38a5fe73dc3 after the follow-up commits adding allocator-reuse abort, unsent-chunk re-scanning, and failed-tile-clear / dirty_runs ordering (970b8a4a).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (970b8a4a)

Command Result
cargo test --release -p xcl --lib a_stalled_ring_retries_only_the_unsubmitted_dirty_suffix -- --nocapture 1 passed; 0 failed; 0 ignored; 1341 filtered out (0.00s)
cargo test --release -p xcl --lib a_stalled_upload_ring_returns_and_retries_exact_chunks -- --nocapture 1 passed; 0 failed; 0 ignored; 1341 filtered out (0.25s, on-GPU)
cargo test --release -p xcl --lib unsent_chunks_are_scanned_again_without_a_new_cpu_write -- --nocapture 1 passed; 0 failed; 0 ignored; 1341 filtered out (0.23s, on-GPU)
cargo test --release -p xcl --lib cpu_writes_wait_for_tile_clears_that_could_not_be_submitted -- --nocapture 1 passed; 0 failed; 0 ignored; 1341 filtered out (0.23s, on-GPU)
cargo test --release -p xcl --lib wait_fence_until_ignores_stale_event_signal -- --nocapture 1 passed; 0 failed; 0 ignored; 1341 filtered out (0.26s, on-GPU)
cargo test --release -p xcl --lib upload_dirty_exits_when_ring_fence_wait_times_out -- --nocapture 1 passed; 0 failed; 0 ignored; 1341 filtered out (0.25s, on-GPU)
cargo test --release -p xcl --lib hle::d3d12x::sparse:: (3 consecutive runs) 23 passed; 0 failed; 1 ignored; 1318 filtered out × 3 (0.52s, 0.42s, 0.39s; early_commit_timing is #[ignore])
cargo build --release -p xcl --bin xcl Clean build (1m 14s, exit 0)

Paired quiet 60 s retail smoke (title: 29640639)

Merge-base (b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7, cached baseline on the same machine):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2821 (970b8a4ad7c5a64e6bb5e605a5cd16ecbd1cb784):

xcl-smoke v1
commit: 970b8a4ad7c5a64e6bb5e605a5cd16ecbd1cb784
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1604 (PresentX 1604)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 13976 MB

Runtime log observations (xcl.log)

  • 9223 log lines, 0 [ERROR] / device-removal / panic lines, and 0 sparse-queue stall/timeout warnings.
  • Active steady-state sparse uploads observed through the full smoke window: last sparse windows timing: entry write-watch 8174 ms (407910 dirty pages), lock wait 1 ms, chunk scan 82 ms, upload 177 ms (52551 runs).
  • Final draw/memory telemetry in log: 19606 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 13975 MB committed by the process; video memory 6115 MB local, 4651 MB non-local; sparse pools 896 MB (838 MB mapped).

Limits of coverage

  • The steady-state 60 s retail smoke encountered 0 live sparse-queue stalls or fence timeouts, verifying zero steady-state regression across 52551 sparse upload runs. Stalled-ring reclaim, stale event rejection, unsent-chunk re-scanning, and failed-tile-clear ordering (cpu_writes_wait_for_tile_clears_that_could_not_be_submitted) were verified directly on the RTX 4060 through the 6 targeted tests and 3× hle::d3d12x::sparse:: runs (early_commit_timing remained #[ignore]).
  • Frame-count delta vs. the cached merge-base smoke (1604 vs. 1518 frames) reflects normal single-run startup variance and is not attributed to this PR.

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.