Skip to content

D3D12.X: add opt-in per-frame PSO wait budget (XCL_PSO_FRAME_WAIT_MS) - #1931

Draft
gsucristo wants to merge 1 commit into
xcl-dev:mainfrom
gsucristo:d3d12x/pso-frame-wait-budget
Draft

gsucristo wants to merge 1 commit into
xcl-dev:mainfrom
gsucristo:d3d12x/pso-frame-wait-budget

Conversation

@gsucristo

Copy link
Copy Markdown
Contributor

Adds an opt-in shared per-frame wait budget (XCL_PSO_FRAME_WAIT_MS=<ms>, off by default) for pso_async::resolve_wait. When a title binds dozens of uncompiled compute pipelines in a single frame, a per-pipeline timeout (XCL_PSO_WAIT_MS) multiplies across each pending pipeline and can stall a frame for seconds; sharing one budget across the frame caps total stall time and refills on PresentX.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: parse XCL_PSO_FRAME_WAIT_MS, track remaining microsecond wait budget for the current frame, cap each resolve_wait by min(XCL_PSO_WAIT_MS, frame_remaining), deduct elapsed wait time, and expose begin_frame() to refill the budget. Pipelines skipped solely because the frame budget ran out are not marked permanently late, so they can still be waited for on the next frame if not finished by a worker yet.
  • crates/xcl/src/hle/d3d12x/present.rs: call super::pso_async::begin_frame() in present_x_frame.
  • README.md: document XCL_PSO_FRAME_WAIT_MS.
  • Unit test shared_frame_budget_caps_multiple_slow_pipelines_and_refills_on_next_frame verifying that a second pending pipeline returns immediately once the shared frame budget is spent and resolves after refill.

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 4090 (Linux NVIDIA driver 610.57.4 via Proton / Wine + vkd3d-proton), AMD Ryzen 9 7950X3D, rustc 1.98.1, debug test build cross-compiled to x86_64-pc-windows-msvc
  • cargo test --target x86_64-pc-windows-msvc -p xcl --lib -- pso_async::: 7 passed, 0 failed, 0 ignored

Regression run

main:

PR:

Not tested

  • Native Windows 10/11 build and full cargo test --workspace -- --test-threads=4
  • scripts/smoke.ps1 regression run on main and this PR (required before leaving draft)

AI use

  • Antigravity (exact model name not provided to the agent): implemented the per-frame budget, unit test, README note, ran the pso_async:: unit tests under Wine, and drafted this PR description.

When a title binds many uncompiled compute pipelines in a single frame (e.g. during world load), a per-pipeline wait budget (XCL_PSO_WAIT_MS) still multiplies across every pending pipeline in that frame.

Add an opt-in XCL_PSO_FRAME_WAIT_MS=<ms> setting (off by default) that caps the total time spent waiting on pending pipelines across a frame and refills on PresentX. Pipelines skipped because the frame budget was exhausted are not marked permanently late so they can still wait on subsequent frames if needed.
anoyarou pushed a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
…xcl-dev#1931)

When a title binds many uncompiled compute pipelines in a single frame (e.g. during world load), a per-pipeline wait budget (XCL_PSO_WAIT_MS) still multiplies across every pending pipeline in that frame.

Add an opt-in XCL_PSO_FRAME_WAIT_MS=<ms> setting (off by default) that caps the total time spent waiting on pending pipelines across a frame and refills on PresentX. Pipelines skipped because the frame budget was exhausted are not marked permanently late so they can still wait on subsequent frames if needed.
@raylitebull

Copy link
Copy Markdown
Member

Code review on \e870dd2:\n\n- \XCL_PSO_FRAME_WAIT_MS\ in \pso_async.rs\ and \present.rs\ cleanly shares a microsecond per-frame budget across
esolve_wait\ calls, refills on \PresentX, avoids marking frame-budget-exhausted pipelines permanently \late, and handles \�udget.is_zero()\ after \p.want(). \Build and test (Windows, no GPU)\ is green.\n\nWhat is still needed before merge:\n1. Fix the \PR description\ check (include an exact-head \xcl-smoke\ pair in the PR body for \hle/d3d12x/*\ changes).\n2. Independent AMD and NVIDIA verification on \e870dd2.

@Pipodi

Pipodi commented Nov 25, 2026

Copy link
Copy Markdown

Test report: #1931 on the retail title's world load

I tested head e870dd2, merged without conflicts onto main bf9eebd (local merge 2bce47f), in a release build. The title stops presenting at about 76 s on main. With XCL_PSO_FRAME_WAIT_MS=500 it gets past that point, but then it crawls, and with a warm cache it crashes.

Setup

  • RTX 4090 (driver 617.42), i9-13900K, 32 GB, Windows 11 Pro 26300.
  • 300 s runs, XCL_PRESS_AT=16:A, default settings otherwise (no direct DXIL, no heap windows).

Results

main bf9eebd, fresh cache #1931 at 500 ms, fresh cache #1931 at 500 ms, warm cache (the fresh run's)
presents end 76 s, then none until 300 s 0–4 per 10 s after ~100 s, until 289 s 1–6 per 10 s after 76 s; last at 128 s
frames 1368 1391 1397
queue.Wait watchdog lines 0 163 (111–246 s) 25 (127–133 s)
draws: translated / skipped – 15,602 / 49,886 14,406 / 27,447
dispatches: run / skipped – 40,487 / 77,580 52,914 / 14,469
peak commit 29.6 GB 46.9 GB 38.8 GB
end alive at 300 s alive at 300 s access violation at 134 s, title code reading 0xFFFFFFFFFFFFFFFF; no device removal

Findings

  • The budget works as described: binds that wait past the budget skip their draws and dispatches, and the title keeps presenting.
  • The warm cache doesn't fix the crawl: with the pipelines built, it skips far fewer dispatches, but presents stay at a few per 10 s. So the wait that remains is not only pipeline builds.
  • The crash follows a burst of bridged queue.Wait timeouts: each waits on a value one step past what the GPU has completed. It is the same access violation @STmihan reported on [OFFICIAL] Looking for PRs with shaders optimization #1269 (comment), which they tie to split recordings whose older segments are not reset. I did not test that fix; it has no PR. D3D12.X: a copy back after a submission does not wait for the title #1993 conflicts with main in sparse.rs, so I did not run it.

Not tested

  • Other budgets (only 500 ms).
  • Runs longer than 300 s.
  • More than one run per configuration.
  • XCL_DIRECT_DXIL, heap windows, AMD.

AI use

  • Claude Code. Claude Sonnet 5.5 (a second session) ran the three title runs and read the logs.
  • Claude Opus 5.5 checked the numbers and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
@Dezmonius

Copy link
Copy Markdown

Native Windows comparison of the runtime hunks from e870dd2, applied to cbc296ab with the same local DirectStorage late-page adaptation and activity counters in both runs. RTX 5070 / 610.88, i7-7700K, 32 GiB RAM, Windows 10 19045, Rust 1.100.0 release. Both runs were offline with direct DXIL, Series X profile, same scripted input and same warm cache location. XCL_PSO_WAIT_MS=1000 in both; the 500 ms frame budget ran second.

Frame budget off Frame budget 500 ms
PresentX calls (sampled) 817 821
Last 2 s activity sample with presents (one-based) 93 106
Samples reporting a title thread waiting for PSO 53 1
GPU queue.Wait watchdog releases 0 10
Timing/end 300 s timer, exit 0 title exception 0xc0000005 at 266.6 s

The enabled run had only a few later presents. The last sampled image remained loading artwork, and I did not verify any rendered gameplay. The final queue timeouts included a producer whose fence had been submitted but was still one value short of the requested completion. This directly shows the PSO wait signal dropping and queue timeouts appearing in this pair, without establishing that the timeouts caused the crash.

cargo test --locked --offline -j 4 -p xcl --lib pso_async:: -- --test-threads=1: 7 passed, 0 failed, 0 ignored on the candidate. Full suite not run. No game assets or raw logs attached. AI-assisted (OpenAI Codex, GPT-6).

@Pipodi

Pipodi commented Nov 25, 2026

Copy link
Copy Markdown

Test report for e870dd2 (this PR's head) on main 568e7db, alone and together with #929 (b3a969b), on the retail title.

Builds: local merges, never pushed. This PR conflicts with main in README.md only; that conflict was resolved to main's side, and no code conflicted.

Tested

  • RTX 4090 (driver 617.42), i9-13900K, 32 GB, Windows 11 Pro 26300, release.
  • xcl run of the retail title for 300 s, with a new empty XCL_DXIL_CACHE per run. One run per row.
build env last window with presents frames end peak commit queue.Wait watchdog lines draws translated / skipped dispatches / skipped
main 568e7db default 70.0 s 1,347 alive to 300 s, exit 0 30.1 GB – 12,127 / 0 8,192 / 0
5ada3de (this PR) XCL_PSO_FRAME_WAIT_MS=500 158.1 s 1,414 access violation at 193.3 s (write at 0x0, title +0x23cf683) 38.2 GB 89 (111.6–167.0 s) 16,475 / 44,579 65,536 / 35,754
80ffe43 (this PR + #929) XCL_PSO_FRAME_WAIT_MS=500 290.2 s 1,415 access violation at 293.7 s (read, title +0x4e51965) 45.7 GB (46.8 GB at 290 s) 3 (150.3–155.0 s) 19,330 / 113,080 131,072 / 90,967
  • With the wait budget, the title presents past main's stop at about 70 s, but slowly. Presents per 10 s after the stop:
  • Adding D3D12.X: newer list layout #139 Reset goes through title_list::reset #929 kept the title presenting about 130 s longer, and the watchdog lines went from 89 to 3. The access violation moved from a null write at +0x23cf683 (the offset seen on main in earlier runs) to a later bad read.
  • In both runs most of the work after the stop is skipped draws and dispatches, and peak commit grows with the run's length.
  • No device removal in any run.

Not tested

  • Other XCL_PSO_FRAME_WAIT_MS values, a warm cache, and more than one run per build.
  • AMD and other titles.
  • What causes either access violation.

AI use: Claude Code. A Claude Sonnet 5.5 session made the local merges, ran the title runs and collected the counts; Claude Opus 5.5 wrote this report.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants