Skip to content

d3d12x: cap cumulative PSO bind waits per PresentX frame - #2114

Open
rdj415 wants to merge 3 commits into
xcl-dev:mainfrom
rdj415:d3d12x-pso-per-frame-wait-cap
Open

rdj415 wants to merge 3 commits into
xcl-dev:mainfrom
rdj415:d3d12x-pso-per-frame-wait-cap

Conversation

@rdj415

@rdj415 rdj415 commented Nov 25, 2026

Copy link
Copy Markdown

Split from #1652 (Part of #156 / #1833): cap cumulative pipeline bind waits per PresentX frame so bursts of cold pipeline builds cannot stall PresentX past a title's watchdog, while keeping XCL_PSO_WAIT_MS and XCL_PSO_FRAME_WAIT_MS configurable and independent of the larger changes in #1652.

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs: expose present::frame_generation() reading the monotonic BOUNDARIES frame counter.
  • crates/xcl/src/hle/d3d12x/pso_async.rs:
    • Add WaitCaps / resolve_caps and FrameBudget (thread-local cumulative wait tracking keyed by present::frame_generation()): defaults to 250 ms per pipeline (XCL_PSO_WAIT_MS) and 2,000 ms cumulative per frame (XCL_PSO_FRAME_WAIT_MS) while a title is running (XCL_PSO_WAIT_MS=0 waits until built; XCL_PSO_FRAME_WAIT_MS=0 disables the per-frame cap; unit tests without a booted title remain unbounded).
    • Once a frame's cumulative wait budget is exhausted, remaining pending binds enqueue their background builds and continue immediately with the stand-in without marking those pipelines late, so they get a fresh wait window on the next frame; already-built pipelines still resolve immediately.
    • Add 3 deterministic unit tests (wait_caps_respect_env_and_title_boot_state, frame_budget_caps_cumulative_wait_and_resets_on_new_frame, a_frame_budget_caps_a_burst_of_slow_pipelines_and_resets_next_frame).

Tested

  • hardware & toolchain: NVIDIA GeForce RTX 5060 Ti (driver 616.64 / 32.0.16.1664), 12th Gen Intel(R) Core(TM) i5-12400F, rustc 1.98.0-nightly (096694416 2026-06-29), release build and debug unit tests on Windows.
  • cargo test -p xcl --lib pso_async -- --nocapture: 9 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib -- --test-threads=4 --nocapture: 1044 passed, 4 failed (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, unrelated CreateComputePipelineState 0x8007000E on driver 616.64, reproduced standalone), 26 ignored (SKIPPED GPU tests on 32-lane hardware without Developer Mode: wave64 gpu::recomp::lower / lower_dxil / recomp::tests cases, #1426 f16/f32 per-lane cases, and shaders::tests::pso_measurement_compiles_an_exact_synthetic_record).
  • Paired retail smoke comparison via scripts/smoke.ps1 -Seconds 60 on clean bf9eebd (upstream/main) and clean 8044bed (d3d12x-pso-per-frame-wait-cap).

Regression run

main:

xcl-smoke v1
commit: bf9eebd53e3ebf9a0311326d3d2a92c0e240ee5c
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1428 (PresentX 1428)
presents per 2 s (last 3): 60 60 50
device removals: 0
crashes: 0
peak commit: 10933 MB

PR:

xcl-smoke v1
commit: 8044bedde5c82ca5d405a49986c904b32a38c0e9
gpu: NVIDIA GeForce RTX 5060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1397 (PresentX 1397)
presents per 2 s (last 3): 50 60 60
device removals: 0
crashes: 0
peak commit: 11092 MB

Not tested

  • cargo test --workspace -- --test-threads=4 integration test binaries (gpu_compute_e2e, shaders_e2e), Python helper tests, and world-loading runs past 60 s (e.g. #1452 Wait64BitValueX behavior on skipped producer dispatches).
  • Wave64 AMD GPUs, Linux (Wine + vkd3d-proton), and XCL_DXC_THREADS=4 multi-run memory stress testing.

AI use

@milesah3ad

Copy link
Copy Markdown

Test report and three review notes for 8044bed. The split came out well: 249 lines in two files, and the tests reset per frame as described.

Tested

  • RTX 5080 16 GB, driver 621.24; Ryzen 7 9800X3D, 64 GB; Windows 11 Pro 26300; rustc 1.100.0 MSVC; DXC 1.9.2609.5; debug.
  • cargo test -p xcl --lib pso_async: 9 passed, 0 failed.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1,093 passed, 4 failed, 46 ignored. The 4 are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (0x8007000E), the same as on main here, so not this PR. SKIPPED: the wave64-only tests.
  • The two new timing tests (frame_budget) 20 times in a row with 14 busy threads loading the 16-thread CPU: 20 / 20 passed. The < 20 ms and < 250 ms bounds held under load.

Review notes

  1. This changes the default, not only the knobs. On main, with XCL_PSO_WAIT_MS unset, a bind waits until its pipeline is built. The module's own doc says why for compute: "a skipped dispatch would corrupt what it computes". With this PR, while a title runs, the unset default becomes 250 ms per pipeline and 2,000 ms per frame. So compute dispatches are skipped during compile bursts by default (your run: 46,227 skipped). That is what gets the title past its watchdog, and it is also a candidate for wrong output in those frames (cf. the flat grey intro shots on Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505). Worth stating plainly in the description and README. It may also be worth asking @ivall whether the first step should be opt-in, as heap windows were.
  2. The cap is per thread. FRAME_BUDGET is thread_local! and the WaitCaps doc says "per thread within one PresentX frame", but the description and the wait_caps doc say "cumulative per frame". With several recording threads, the waits of one frame can add up to N × 2,000 ms if they happen one after another (they overlap when the threads wait at the same time). Either the docs could say per thread, or a process-wide atomic keyed on frame_generation would make it per frame.
  3. Minor, resolve_caps: XCL_PSO_WAIT_MS=0 ("wait until built") together with XCL_PSO_FRAME_WAIT_MS=N gives per_pso = per_frame = N, so the 0 no longer means "until built". That may be intended (the frame cap wins), but the doc of wait_caps doesn't say so.

Not tested: any title (no smoke pair here), AMD / Intel, release builds.

AI use: Claude Code (Claude Opus 5.5) ran the tests on the machine above, read the diff and wrote this. I checked the results.

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Test of 8044bed merged onto main 6020a33, on the retail title, XCL_DIRECT_DXIL=1, otherwise defaults. Caches were warm: every compute pipeline had been precompiled and the graphics pipelines built in earlier runs. No input after the menus.

run last presents presents after 82 s budget exhausted skipped draws / dispatches queue waits released device removed end
15-minute run 134 s 78 27 times 10 111 / 1 889 14, from 111 s no stopped by my memory guard at 137 s (process commit 34.3 GB)
two earlier runs 96 s, 102 s 6, 66 – ~4 400 / ~800 – 1 000 0 no memory guard at 98 s, 108 s (33 GB)

For comparison, main 177cd40 with the same warm caches ends in a device removal (0x887a0005) at 92 – 100 s, in 4 of 4 runs (#1452). With this PR none of the three runs removed the device, and the longest kept presenting to 134 s. Whether it gets past the watchdog, as in your 694 s run, I can't tell here: this machine gives the process about 34 GB before my guard stops it, and the title passes that at 137 s.

Tested: RTX 4080 16 GB (driver 610.88), i9-12900K, 64 GB RAM (commit limit 68 GB), Windows 11 26300, release.
Not tested: the suite on this head, runs past 137 s, AMD.

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

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@futurepro62

Copy link
Copy Markdown

NVIDIA and AMD full-suite run, to go with the RTX 5080 and RTX 4080 reports above, since neither covers AMD. Tested exact head 8044bed (on its base bf9eebd).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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: 1086 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.
  • The new tests ran and passed: wait_caps_respect_env_and_title_boot_state, frame_budget_caps_cumulative_wait_and_resets_on_new_frame, a_frame_budget_caps_a_burst_of_slow_pipelines_and_resets_next_frame.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1096 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 6020a33 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@JoaoPauluu

Copy link
Copy Markdown

A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with main (1411 here; 1368 and 1370 on the two main runs). No a pipeline still being built after … ms line appears in the log, so the cap is not seen to act in this run; this is a regression run only.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 6e1e2befc7430126b1e7b98b5c3fe93813c866b6
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1368 (PresentX 1368)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 378a0775001770ee48f6d820a69f9da4a54017ad
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1411 (PresentX 1411)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The second main run: 1370 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the whole test suite on this head, a run where binds wait on pipelines (XCL_PSO_WAIT_MS or similar), native Windows.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

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

thehollowedone commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent Windows verification at 378a077. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, debug.

Tested

  • Clean head: cargo build --offline --locked --workspace -j 3 passed. cargo test --offline --locked --workspace --no-fail-fast -j 3 -- --nocapture --test-threads=4 reported 1,158 passed, 0 failed, 46 ignored. Separately, 25 runtime skip notices (20 no native wave64, three unsupported per-lane forms, one driver cache disable probe, one no heap windows).

  • Two additional synthetic cases in cargo test --offline --locked -p xcl --lib pso_async -j 3 -- --nocapture --test-threads=1 failed on the PR implementation (10 passed, 2 failed, 0 ignored, 0 runtime skips). Two pending binds started together in the same frame charged 501.7 ms in total against a 250 ms cap. In a separate test, frame 2 spent 40 ms of its 100 ms allowance. Recording a late completion from frame 1 gave frame 2 its full 100 ms back instead of leaving 60 ms.

  • A local candidate reserved each capped wait while holding the budget mutex and settled it only against the frame that granted it. The same focused command then passed all 12 tests with 0 failures, ignores, or runtime skips. I have the patch if useful.

  • Follow-up on the local candidate applied to the same PR head: the workspace build and the full workspace test command above passed on the RTX 3080 Ti. The suite reported 1,160 passed, 0 failed, 46 ignored, and the same 25 runtime skip notices. Both added cases passed with four test threads.

Not tested
Retail load and frame pacing. The description check still asks for a smoke block from the current head.

AI use
Codex (GPT-6.2 Sol) wrote the synthetic cases and local candidate, ran the tests, and drafted 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.

7 participants