Skip to content

D3D12.X: with bounded pipeline waits, dispatches are not put off to the submit - #2581

Open
brothernog wants to merge 1 commit into
xcl-dev:mainfrom
brothernog:bounded-wait-no-putoff
Open

brothernog wants to merge 1 commit into
xcl-dev:mainfrom
brothernog:bounded-wait-no-putoff

Conversation

@brothernog

@brothernog brothernog commented Nov 26, 2026 •

Copy link
Copy Markdown

With XCL_PSO_WAIT_MS set, a dispatch whose pipeline is still being built is recorded at once instead of being put off to the submit (#2118). On an RTX 3050 with XCL_PSO_WAIT_MS=1, main lost the device in 2 of 2 runs right after the retail title's world start; with this change the title presented to the end of every 240 s run (4 runs, 0 device removals). The runs that led here and what they show about the stop after the world start are in a comment on #2088: #2088 (comment)

What changes

  • list_x::defer returns false when pso_async::waits_bounded(), so Dispatch and a dispatching ExecuteIndirect with an unbuilt pipeline take the path they took before D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118: the bind waits at most XCL_PSO_WAIT_MS, then the call is skipped as a stand-in's.
  • Why: the submit's wait for a put-off call is bounded by the same XCL_PSO_WAIT_MS, so with a bound the put-off only moves the wait, and it costs a segment (a PC command list) per call. With XCL_PSO_WAIT_MS=1 the title's world start put off thousands of calls (the log's counter passed 8,192 in one run; up to 1,024 extra segments per list), the lists' Close returned E_OUTOFMEMORY (then E_FAIL), and the device was removed (0x887a0001, "invalid call").
  • The cost: with a large budget the title's thread waits again, which D3D12.X: a dispatch waits for its pipeline at the submit, not in the bind #2118 moved off it. Measured only with XCL_PSO_WAIT_MS=1.
  • Unset (the default): nothing changes. A default run put off over 1,024 calls with no Close failure.

Files

  • hle/d3d12x/pso_async.rs: waits_bounded().
  • hle/d3d12x/list_x.rs: the check at the top of defer.

Tested

  • RTX 3050 8 GB (desktop, Ryzen 7 5800XT, 32 GB), NVIDIA 610.88, Windows 11 build 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17.
  • On main 08db802 + this PR (d5d694b):
    • cargo test --release -p xcl --lib -- --test-threads=4: 1304 passed, 0 failed, 27 ignored.
    • cargo clippy --release -p xcl --all-targets: 838 warnings on 08db802 and on this branch.
  • In the title (A pressed at 25 s, 240 s per run, XCL_NETWORK=0 XCL_PAGE_BUDGET_MB=4096; XCL and NVIDIA caches warm from earlier runs):
tree XCL_PSO_WAIT_MS runs last present device removals
main e1d84b7 unset 1 136 s (0 presents after) 0
main e1d84b7 1 2 132 / 138 s 2 (0x887a0001, after Close → E_OUTOFMEMORY)
this change on e1d84b7 (0a3d310, with a second change switched off by XCL_SKIPPED_COMPUTE_GUARD=0) 1 2 238 / 238 s (end of run) 0
this change on e1d84b7 (0a3d310), unset, after all the runs above unset 1 112 s (0 presents after) 0
this PR (d5d694b) 1 2 238 / 236 s (end of run) 0 (no put-offs, no Close failure)

The default control was repeated last because driver blobs kept piling up over the runs: the title still stops with warm caches. Past that point, with XCL_PSO_WAIT_MS=1, the title records 1,000–10,000 dispatches per 2 s but presents only about every 2 s; that slow phase is not explained here.

Regression run
Default settings (XCL_PSO_WAIT_MS unset, where this PR changes nothing), back to back, main first, one run each; frame counts vary from run to run:

main 08db802:

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 3050
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1544 (PresentX 1545)

This PR (d5d694b):

xcl-smoke v1
commit: d5d694b04b3e26abdef656af21c03d30a5027d9b
gpu: NVIDIA GeForce RTX 3050
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1559 (PresentX 1559)

Overlap

Not tested

  • XCL_PSO_WAIT_MS values other than 1; what the title draws with skipped dispatches; runs longer than 240 s.
  • AMD, Intel; Linux/Proton; cold caches.

AI use

  • Claude Code (Claude Opus 5.5): the runs, the change, the tests and this description. I checked the diff and the runs.

AI-assisted.

…he submit

With XCL_PSO_WAIT_MS set, a dispatch whose pipeline is still being built
is recorded at once instead of being put off to the submit (xcl-dev#2118): its
bind waits at most XCL_PSO_WAIT_MS on the title's thread, as before. The
submit's wait has the same bound, so the put-off only moved it. With
XCL_PSO_WAIT_MS=1 a retail title's world start put off thousands of
calls, a segment each; its command lists ran out of memory (Close:
E_OUTOFMEMORY) and the device was removed (0x887a0001). Unset (the
default), nothing changes.
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.

Thanks!

— Devin

raylitebull added a commit that referenced this pull request Nov 26, 2026
…ts, and keep split whole builds async

Eliminate the remaining multi-second stalls observed past the 12 s per-frame pipeline wait window on cold/warm world frames:
- Track in-flight wall-clock waits (`active_waiters` / `active_since`) in `pso_async::FrameWaitBudget` so staggered concurrent title threads share one hard wall-clock ceiling per kind per frame instead of each getting a fresh 12 s window (applied to both `FRAME_BUDGET_GFX`/`FRAME_BUDGET_CS` and `FRAME_WAIT`).
- Skip deferring pending compute dispatches to submit in `list_x::defer` when `XCL_PSO_WAIT_MS` is set (#2581), when the current frame's compute wait window is already spent, or once 16 deferred segments have already been allocated on the current frame (prevents 512+ deferred segments and command-allocator/RAM churn).
- Never compile `Chain::whole()` synchronously on a title/submit thread inside `dispatch_chain::dispatch` when scratch allocation fails under memory pressure or missing backing allocator: kick off `start_whole_async()` and return an error so the dispatch is skipped cleanly until the background whole build finishes, matching `whole_nonblocking`.

Assisted-by: Antigravity (Gemini 4 Neon High)
@itsSio

itsSio commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent dual-PC NVIDIA full-workspace test report on clean head d5d694b04b3e26abdef656af21c03d30a5027d9b.

Tested

  • Machine 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, rustc 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA)
    • cargo build --workspace: exit 0
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1429 passed, 0 failed, 47 ignored (all 14 existing pso_async/defer tests pass)
    • SKIPPED: 26 (wave64-only GPU tests, #1426 wave32 f16/cvt refusals, heap_window_out_of_memory_falls_back_to_the_switch_form, pso_measurement_compiles_an_exact_synthetic_record)
  • Machine 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, rustc 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA)
    • cargo build --workspace: exit 0
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1429 passed, 0 failed, 47 ignored (all 14 existing pso_async/defer tests pass)
    • SKIPPED: 29 (same 26 as Machine 1 plus 3 requiring d3d12SDKLayers.dll)

Not tested

  • Retail title / scripts/smoke.ps1 runs (including bounded-wait behavior under XCL_PSO_WAIT_MS)
  • Release builds (--release)
  • AMD / Intel GPUs, native wave64, Linux / Wine / vkd3d-proton

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Claude Opus 5.5 (High)): built the branch and ran the workspace test suite on both NVIDIA machines.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated the runs and wrote this test report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
When XCL_PSO_WAIT_MS is positive, record a dispatch immediately and use the same bounded bind wait instead of splitting one deferred command-list segment per call. This prevents bounded mode from exhausting command-list memory during large cold-pipeline bursts.

Unset, zero, and malformed values preserve the default deferred-submit path. The change is stacked on atomic ExecuteIndirect stand-in classification.

GNU Windows-target cargo check passed. Windows/MSVC, GPU, and title smoke execution were not available on this host.

Adapted from PR xcl-dev#2581.
Assisted-by: Codex (GPT-5.6-sol)
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
When XCL_PSO_WAIT_MS is positive, record a dispatch immediately and use the same bounded bind wait instead of splitting one deferred command-list segment per call. This prevents bounded mode from exhausting command-list memory during large cold-pipeline bursts.

Unset, zero, and malformed values preserve the default deferred-submit path. The change is stacked on atomic ExecuteIndirect stand-in classification.

GNU Windows-target cargo check passed. Windows/MSVC, GPU, and title smoke execution were not available on this host.

Adapted from PR xcl-dev#2581.
Assisted-by: Codex (GPT-5.6-sol)
Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 26, 2026
Runs 4-6 on an RTX 5080 grew non-local video memory to 45 GB within a
minute of the first intro frames and ended in E_OUTOFMEMORY and a device
removal; run 7 with XCL_ALLOC_SWAP=0 stayed near 16 GB. The entry records
the cause and the user's decision to adopt xcl-dev#2725, xcl-dev#2549, xcl-dev#2581 and xcl-dev#2707
through the gate.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RbZY1Ag73eDeCUZHpW3is
Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 26, 2026
Commit:   d5d694b
Reviewer: Claude Code (Claude Opus 5.5), Opus worker, full read (findings)
Review:   sha256 a62622c16d253262ad9b5b40cbf5d29f6d9c16575a9956b233d7af56776ee98d
Osanchez pushed a commit to Osanchez/xcl that referenced this pull request Nov 26, 2026
…s are left out

With draws off the title's thread, a retail title on an RTX 5080 still
stopped presenting 70 s after its loading screen: 31 of 32 compute waits
built the pipeline in the call (up to 15 s each), and it then sat for
450 s behind about 35 ray-tracing resolve programs of 700 to 940 KB of
DXIL that take up to 167 s each in the driver compiler.

A waiting compute bind no longer takes the build job: the build is marked
wanted, goes ahead of the workers' queue and is waited for, at most
XCL_PSO_COMPUTE_WAIT_MS (default 120 s, 0: no limit); after that the
pipeline is late and its dispatches are skipped until it is built.
XCL_PSO_IMAGE_SKIP is now on unless set to 0: a big compute program that
writes only images is not waited for and not put off to the submit. It
writes no buffer, so no ExecuteIndirect can read stale counts from it.

Tested on Windows 11, RTX 5080, driver 32.0.16.2140, on top of xcl-dev#2581,
xcl-dev#2549 and xcl-dev#2707:
cargo test -p xcl --lib -- pso_async:: bind:: list_x:: alloc_pool::
title_list:: : 95 passed, 0 failed; whole suite 1639 passed, 4 failed
(the dxil fuzz_validate_and_gpu_0..3 that fail on this GPU without the
change), 47 ignored, 45 SKIPPED lines. Not tested on AMD. Unit U5 of the
stall-fix entry in decisions.md.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018RbZY1Ag73eDeCUZHpW3is
@throny

throny commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Test report: in the world on an RTX 4080 16 GB with XCL_PSO_WAIT_MS=1. Tested together with #2422; with the two, no device loss in 2 runs against 2 of 2 without.

Tested

run tree time in the world presents end
28 without 92 s 23 device removed (0x887a0005)
29 with #2581 + #2422 238 s 48 title stop (0xc0000005 in title code), no device loss
30 with #2581 + #2422 446 s 92 ran to the 600 s limit, no device loss
31 without 100 s 24 device removed (0x887a0005)

Not tested

  • Each PR alone, the PRs' own heads on main, their tests and the suite, AMD.

AI use: Claude Code (Claude Sonnet 5.5 ported the two diffs, Claude Fable 5.2 ran the runs and wrote this).

Follow-up, same day: at default waits the two PRs do not stop the removal. Three more world runs of the same tree with both PRs and without XCL_PSO_WAIT_MS: device removed (0x887a0005) in 3 of 3, after 76 s, 334 s and 114 s of world. So the 0 of 2 above is either specific to XCL_PSO_WAIT_MS=1 or chance, and the removal this card has on this branch is a different one.

@throny

throny commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #2547 solves the same problem in a different way: #1607, group D131. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@ClosetPie107

Copy link
Copy Markdown

Independent test report under Wine/Proton (not native Windows) for head d5d694b0, merged cleanly onto main 8b957bec (test commit 967bba96), compared with main and with #2547. Part of the D131 check in #1607.

Tested

Retail title, release builds, 300 s per run (XCL_RUN_SECONDS), A pressed every 10 s from 20 s. All 9 runs started from one copy of the same warm cache (DXIL, driver pipeline blobs, Mesa, vkd3d), seeded by two main runs; shader preparation took 30 s in each. Run in rounds of main → #2581 → #2547. Flags: XCL_PSO_WAIT_MS=50, XCL_DIRECT_DXIL=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_SPLIT_MIDLIST_WAIT=0, XCL_COHERENT_MB=1024, XCL_PSO_PRELOAD=1, XCL_NETWORK=0, VKD3D_CONFIG=ignore_shared_fence.

tree run end presents before 100 s / after put off to the submit dispatches (skipped)
main 8b957bec 1 crash at 293 s 1,672 / 356 256+ 779,672 (1)
2 300 s, exit 0 1,625 / 407 512+ 927,998 (3)
3 300 s, exit 0 1,426 / 339 512+ 675,433 (2)
main + #2581 (967bba96) 1 300 s, exit 0 1,496 / 360 0 863,527 (128)
2 crash at 166 s 1,636 / 242 0 291,599 (35)
3 crash at 225 s 1,675 / 252 0 524,288 (16)
main + #2547 (01e09d7f) 1 crash at 172 s 1,690 / 299 128+ 524,288 (0)
2 crash at 241 s 1,453 / 244 256+ 332,594 (0)
3 crash at 281 s 1,642 / 377 512+ 655,949 (0)

(Put-off counts are the last power of two the log reported; dispatch counts are the last console code so far line.)

What the change does in the title: with it, no dispatch was put off to the submit (main 256–512+ per run), and 16–128 dispatches per run were skipped instead (main 1–3). I could not reproduce the device removal from the description: main with XCL_PSO_WAIT_MS=50 had no Close failure or device removal in 3 runs. I did not test XCL_PSO_WAIT_MS=1. The change did not change the stall after the world start on this setup.

Not tested

  • XCL_PSO_WAIT_MS=1 (the setting in the description), unset, or other values; native Windows, NVIDIA/Intel, cold caches
  • Whether this PR changes how often the ucrtbase crash happens: 3 runs are too few
  • The full workspace suite on this merge

AI use

  • Claude Code (Claude Opus 5.5) merged the PRs, wrote the test scripts, ran the tests and the title on this machine, and wrote this report.

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.

5 participants