Skip to content

D3D12.X: a slow graphics pipeline waits at most 4 s once per build (#232) - #267

Closed
heretic1321 wants to merge 1 commit into
xcl-dev:mainfrom
heretic1321:fix/retail-null-write-232
Closed

heretic1321 wants to merge 1 commit into
xcl-dev:mainfrom
heretic1321:fix/retail-null-write-232

Conversation

@heretic1321

@heretic1321 heretic1321 commented Nov 23, 2026 •

Copy link
Copy Markdown

Part of #232. Rebased cleanly onto upstream/main (6bac4b4, head ef98154), integrating #574 and #690 and addressing @Kalmarv's and @qinrxx's review findings.

Root cause & change

  • On main, graphics pipelines created lazily are sent to xcl-pso workers at SetPipelineState, and bind::graphics_bound / execute_indirect then call pso_async::resolve_wait, holding the title's recording thread without limit (and compiling on the title thread itself if no worker has taken the job yet). On NVIDIA GPUs where big translated shaders can take > 10 s, that stalls watched threads long enough to trip the title's watchdog (title+0x2215c35, *(int *)0 = 0, Retail title: null write at +0x2215c35 (#159) still hits on NVIDIA RTX 4070 Ti, with and without XCL_NETWORK=0 #232).
  • What is in it:
    • crates/xcl/src/hle/d3d12x/pso_async.rs:
      • resolve_for_draw / resolve_within with XCL_PSO_WAIT_MS (parse_wait_limit, default 4000 ms as a safety margin under NVIDIA (RTX 5070): graphics pipelines never finish – nvgpucomp64 stalls on large translated shaders (+ 2 fixes: chad.dll XDsp, XMemMapPhysicalPagesScatter) #156's 23 s one-call watchdog trigger; 0 = unbounded).
      • Per-pipeline timeout latch (Pending::late): once one draw times out waiting for a graphics pipeline still building on a worker, p.late is set so subsequent draws of that pipeline while it is still building return the stand-in immediately (incrementing STANDIN_DRAWS) instead of holding a thread for N * limit.
      • p.note_use() is called in resolve_within so #690 tracks used graphics pipelines, and resolve_wait logs waits >= 2 s.
      • Updated draw_wait_tests (a_graphics_pipeline_waits_at_most_once_up_to_the_limit_and_never_builds_on_the_title_thread, compute_pipelines_and_no_limit_wait_as_before, wait_limit_parses_env_values).
    • crates/xcl/src/hle/d3d12x/bind.rs:
      • Routes execute_indirect and graphics_bound through pso_async::resolve_for_draw (keeping #574's is_pending skip in execute_indirect and rs_gfx root-signature binding for failed/PC pipelines, and using pso_async::resolve inside trace_frame).
      • Keeps execute_indirect_with_a_stand_in_binds_the_titles_root_signature_first and adds execute_indirect_skips_when_a_still_building_graphics_pipeline_times_out covering a timed-out pending graphics stand-in.
    • crates/xcl/src/hle/d3d12x/real.rs:
      • Adds standin_draws: usize to D3d12Stats (report.json → d3d12.standin_draws).

Overlaps

  • #891 (Sr-0w) implements opt-in XCL_PSO_WAIT_MS across both compute and graphics binds via Pending::late, and #533 (XaviFortes) bounds compute waits. @imnicho's RTX 5080 retail run on 043d1f7 showed compute pipeline binds can also trip #232's watchdog when graphics waits stay under 4 s. Keeping this PR cleanly rebased and review-complete for the graphics-only path (where draws are safe to drop without corrupting compute state) unless maintainers prefer #891/#533.

Tested

  • Linux host (no Windows, no GPU), Rust 1.95.0, head ef98154 on upstream/main 6bac4b4:
    • AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspace --target x86_64-pc-windows-msvc — exit 0 (15.16s, 0 errors, 0 warnings).
    • AR_x86_64_pc_windows_msvc=llvm-ar cargo check --tests --workspace --target x86_64-pc-windows-msvc — exit 0 (17.72s, 0 errors, 0 warnings).
    • python3 scripts/pr_check.py --local verified all required sections and asset/model checks (failing only on the missing Windows xcl-smoke blocks for ef98154).
  • Earlier community runs (on older commits b5c9057 / 043d1f7, NOT covering ef98154):
    • @qinrxx tested 043d1f7 merged onto 2997c9a on RTX 5080 (d3d12x:: 90/0/1; scripts/smoke.ps1 -Seconds 300: 5116 vs 5099 frames, 14991 vs 15011 MB; menus/pre-world only, 0 standin_draws).
    • @Chrysana tested 043d1f7 on RX 9070 XT (cargo test --workspace: 655/0/40, plus 60 s smoke.ps1 merged onto 9ce2070: 1526 vs 1536 frames).
    • @imnicho tested 043d1f7 merged onto 508a0c7 on RTX 5080 (standin_draws: 0 at 190 s watchdog; 4 title threads waiting in resolve_wait for compute).
    • @woreksami tested 043d1f7 on RTX 3060 (together with #214, plus conflict resolution onto 6025201).
    • @Kalmarv reviewed b5c9057 and 043d1f7 on RTX 5070 Ti and WARP.

Regression run

  • Missing for head ef98154 (no Windows GPU host here; earlier 043d1f7 smoke blocks from @qinrxx and @Chrysana do not cover ef98154).

Not tested

  • Windows MSVC link, cargo test --workspace execution, GPU tests, and scripts/smoke.ps1 / retail title runs on ef98154.

AI use

  • Antigravity with Claude Opus 5.5: wrote the original change, initial tests, and root-cause notes.
  • T3 Code / Antigravity, Orchestrator (Neon) / gemini-pro-orchestrator-neon: rebased onto upstream/main (6bac4b4), added the Pending::late per-pipeline latch, execute_indirect timeout test, parse_wait_limit test, p.note_use() call in resolve_within, and ran Linux-to-x86_64-pc-windows-msvc cargo check and scripts/pr_check.py --local.

@Kalmarv

Kalmarv commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Review of b5c9057 against main 9ab7d76. The limit does what the description says in a synthetic frame (numbers below). Five things I would change or settle before it goes in.

1. The 4 s default is not tied to a known threshold.

2. ExecuteIndirect past the limit goes to D3D12 without the title's root signature.

  • execute_indirect returns pc(…) as soon as the pipeline is not a translated one (bind.rs:220). graphics_bound binds rs_gfx first in the same situation (bind.rs:389), with the comment that a draw without a root signature is invalid and faults on WARP. set_graphics_root_signature only records it.
  • On main an indirect draw reaches that branch with a stand-in only when its build failed. With this PR every indirect draw past the limit does.
  • This is from reading. I did not run an indirect draw.
  • At 043d1f7 (2026-11-23): fixed. The branch binds rs_gfx before pc(…). The new execute_indirect_with_a_stand_in_binds_the_titles_root_signature_first passes on Windows, and fails with the binding taken out (only ExecuteIndirect is recorded).

3. Merged with #214 (f007d4a) the tests do not compile.

4. The limit is one budget per present interval for the whole process, not per draw or per thread.

  • A draw reads what is left before it waits and adds what it used afterwards. Draws on several threads that start before the first one returns each get the whole remainder, so a frame can be held for up to twice the limit (from the code, not run).
  • The budget refills only at PresentX. Everything drawn before the first present shares one 4 s. A thread that records while another thread keeps presenting gets a new 4 s after every present, so it can still be held for 4 s per unbuilt pipeline, back to back (also from the code).
  • A build shorter than the limit can still lose, because the second draw of a frame only gets what the first left. In the last row of the table the second pipeline needed 2 s and had 2 s left: it was built in time on the RTX 5070 Ti and drawn with its stand-in in the same run on WARP.
  • At 043d1f7 (2026-11-23): the shared budget is gone, so the three bullets above no longer apply: every draw call now waits up to the limit on its own. That makes the limit per draw call, not per pipeline or per frame. Draws on one unbuilt pipeline wait one after another until it is built, so a frame with a few draws per pipeline is held as long as on main. Same synthetic frame, two 10 s builds, on WARP: with 1 draw per pipeline the draws take 4.01 s and 4.01 s and the frame 8.03 s; with 4 draws per pipeline they take 4.00, 4.01, 1.99, 0.00 s for each pipeline and the frame 20.01 s, which is main's time in the table below. With XCL_PSO_WAIT_MS=1 the same 8 draws take 0.12 s in all. Remembering per pipeline that its wait was used up would keep the hold at one limit per pipeline.

5. A draw past the limit is lost, not delayed.

  • It is issued with the stand-in (title's root signature bound, counted as DRAWS_PC) and draws nothing. Nothing replays it when the pipeline arrives. Later draws use the real pipeline.
  • The description says this. Two things it does not say: report.json cannot tell these draws from draws with PC pipelines (only the log lines can), and a graphics build is no longer taken by the thread that needs it, so it waits its turn behind everything queued at SetPipelineState. With a deep queue, or D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214's two driver slots on NVIDIA, the budget buys less than 4 s of progress on the pipeline being drawn.
  • At 043d1f7 (2026-11-23): these draws are now counted on their own (report.json → d3d12.standin_draws) and the log line says the draw is lost. The remark about queue order is unchanged, and the description now states it.

Tested

Synthetic frame, the same test on both trees (bind::tests, local, not in the PR): two graphics pipelines whose builds take a fixed time (the job sleeps, then hands over a pipeline made beforehand) are first drawn in one frame through set_pipeline_state / draw_instanced on a title list of a real D3D12 device. Times are the two draw calls and the whole frame (record, execute, fence).

Tree Builds XCL_PSO_WAIT_MS Draw 1 Draw 2 Frame
main 9ab7d76 10 s – 10.00 s 10.00 s 20.01 s
b5c9057 10 s default 4.01 s 0.00 s 4.01 s
b5c9057 10 s 0 10.00 s 10.00 s 20.00 s
b5c9057 10 s 1000 1.01 s 0.00 s 1.01 s
b5c9057 2 s default 2.00 s 2.00 s 4.00 s

Not tested

  • The retail game, on any card. Whether a draw wait is what stalls its frames is still the PR's hypothesis.
  • The watchdog's threshold: I read the public threads only.
  • Translated pipelines: the test's real pipeline is a PC one, so the next frame gets it through SetPipelineState. The rebind in bind_abi after a stand-in draw in the same list is from reading.
  • ExecuteIndirect, mesh and two-pass pipelines, more than one drawing thread.
  • A real slow driver build (the delay is a sleep), a deep worker queue, and this PR together with D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214's driver slots.
  • AMD and Intel.

🤖 Claude Fable 5.2

@vladbondarenko97

Copy link
Copy Markdown
Contributor

Tested on an NVIDIA RTX 3080 Ti (Windows 11 10.0.26300, driver 32.0.16.2124, DXC 1.9.2602.17, package 1.0.2.1 verified by hash). Built this branch on top of 9ab7d76 (merge clean, -X theirs; both commits applied) and ran with XCL_NETWORK=0, XCL_ACTIVITY=1, lazy pipelines (default), frame dumps on.

Result: the run still dies at the early assert before any frame — this PR does not change it here.

  • report.json: presents: 0, frame_boundaries: 0, shaders.unique: 0, translated_pipelines: 0, failed_pipelines: 0, called_stubs: []
  • Crash: unhandled exception 0x80000003 in game_scarlett_master.exe+0x2237178, rax=0 rbx=0 rcx=0 rdx=0x66 r8=0x7efefefefefefeff r9=0x7f656f712d2f6073, vtable game+0x677c997; stack +0x677c997, +0x579105c, +0x700b71d, +0x53ec0f0, +0x4fac3d7
  • Same signature as plain 9ab7d76 and 60565c4 on this card, and the same first-chance exception under an unrelated clean-room layer (already reported in Retail title: early assert 0x80000003 at title+0x2237178 on an RTX 3080 Ti, 0 presents, reproducible on main 9ab7d76 #301). So on this host the failure predates any pipeline build this PR could wait on.

Two data points that may matter for the hypothesis:

Happy to run any revision of this PR on the 3080 Ti and return reports/traces. AI-assisted (Claude Code CLI via a model proxy).

@heretic1321
heretic1321 force-pushed the fix/retail-null-write-232 branch from b5c9057 to 043d1f7 Compare November 23, 2026 23:13
@heretic1321 heretic1321 changed the title D3D12.X: draws wait at most 4 s a frame for pipelines still building (#232) D3D12.X: a draw waits at most 4 s for a pipeline still building (#232) Nov 23, 2026
@heretic1321
heretic1321 marked this pull request as ready for review November 23, 2026 23:57
@heretic1321

Copy link
Copy Markdown
Author

All five review points are addressed at 043d1f7, and the PR is now ready for review.

  • ExecuteIndirect: binds the title's graphics root signature before any stand-in indirect draw (also covers a failed build and a plain PC pipeline), with a regression test that fails without it.
  • The wait budget is per draw, not a shared per-present remainder. Trade-off documented: N slow pipelines on one thread cost N × limit; XCL_PSO_WAIT_MS=1 collapses it.
  • The 4 s default is now described as a safety margin, not a measured threshold, with the decode's unit ambiguity (300 ms vs 300 s) spelled out and XCL_PSO_WAIT_MS=1 added to the reporter steps.
  • Test module renamed to draw_wait_tests; a real merged-tree build with D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214 at f007d4a passes cargo check --release -p xcl --lib --tests, so the collision is gone. If D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214 lands first, resolve_within should call enqueue(p.clone()).
  • Skipped stand-in draws are now counted in report.json → d3d12.standin_draws instead of being log-only.

What is still missing to merge: the two xcl-smoke blocks from scripts/smoke.ps1 (one from main, one from 043d1f7) — I don't have a Windows host. The 4090 and 5070 Ti runs earlier were build/suite and synthetic only.

@Kalmarv @vladbondarenko97 @yous0serious — would one of you run the smoke pair on 043d1f7 against plain main with the same package and the same duration, and paste both blocks under Regression run? Note this branch is intended to be measured together with #214, so if the smoke shows the crash it can help to also run once with XCL_PSO_WAIT_MS=1.

@qinrxx qinrxx 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.

Review of 043d1f7, on correctness and tests only. The diff was read against main 2997c9a.

What I ran: cargo test -p xcl --lib d3d12x:: -- --test-threads=4

  • on the PR head (base 4017f8f): 81 passed, 0 failed, 1 ignored;
  • on the PR head merged into main 2997c9a (merges without conflicts): 90 passed, 0 failed, 1 ignored. The three new tests pass.
  • Not run: the whole workspace suite, any GPU test beyond this filter, the retail title.

1. The limit applies per draw, so a thread that records several draws is still held for about the whole build.
resolve_within gives every draw the full XCL_PSO_WAIT_MS, and each_draw_waits_… asserts exactly that ("every draw gets the whole limit"). Take a 17 s NVIDIA build (#156) and a thread that records 5 draws with that pipeline: the draws wait 4 + 4 + 4 + 4 + 1 s, so the thread is held about 17 s, much the same as with resolve_wait. The limit only shortens the hold when each draw of a still-building pipeline comes from a different recording. Would a budget per pipeline work better? Once one draw has given up on a pipeline, later draws of it would not wait (resolve) until it is built. The test would then assert that the second draw returns at once.

2. The new execute_indirect path is tested only with a failed build, not one that timed out.
execute_indirect_with_a_stand_in_binds_the_titles_root_signature_first uses submit(standin, false, Box::new(|| 0)), so the pipeline is done and has failed, and the 4 s limit is never reached. A test with a build that is still running and a short limit would cover the case the PR is for: the stand-in returned at the deadline, then the root signature, then ExecuteIndirect. graphics_bound past the limit has no test either. (From the code, the bind test would fail on main, whose path doesn't bind the root signature, so it does cover that half. I didn't run it there.)

3. XCL_PSO_WAIT_MS is read once into a OnceLock.
The tests get around this by calling resolve_within directly, which is fine. Parsing the variable (0 = no limit, junk = the default) has no test. That's minor and could stay as it is.

Overlap with a change I'm preparing (for #232, compute pipelines):

  • I plan to send lazy compute pipelines to the xcl-pso workers when the title creates them, so that the first bind usually finds them built. This PR keeps compute on resolve_wait, and nothing here would change.
  • The workers have one FIFO queue. With compute builds sent when they are made, a graphics pipeline sent at its first draw can sit behind them, and under this PR's limit its draws would time out and be lost more often. My change will have to handle that (for example graphics ahead in the queue). I'm noting it here so the two PRs are not judged separately on it.
  • Both PRs change the module doc of pso_async.rs (lines 3–8), and mine also changes the lazy() doc. Whichever lands second rebases. Mine changes submit_as, which this PR doesn't touch.

AI use: Claude Code (Claude Opus 5.5) read the diff, ran the tests above and wrote this review. I checked each point myself before posting.

@qinrxx qinrxx 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.

Review of 043d1f7, on correctness and tests only. The diff was read against main 2997c9a.

What I ran: cargo test -p xcl --lib d3d12x:: -- --test-threads=4

  • on the PR head (base 4017f8f): 81 passed, 0 failed, 1 ignored;
  • on the PR head merged into main 2997c9a (merges without conflicts): 90 passed, 0 failed, 1 ignored. The three new tests pass.
  • Not run: the whole workspace suite, any GPU test beyond this filter, the retail title.

1. The limit applies per draw, so a thread that records several draws is still held for about the whole build.
resolve_within gives every draw the full XCL_PSO_WAIT_MS, and each_draw_waits_… asserts exactly that ("every draw gets the whole limit"). Take a 17 s NVIDIA build (#156) and a thread that records 5 draws with that pipeline: the draws wait 4 + 4 + 4 + 4 + 1 s, so the thread is held about 17 s, much the same as with resolve_wait. The limit only shortens the hold when each draw of a still-building pipeline comes from a different recording. Would a budget per pipeline work better? Once one draw has given up on a pipeline, later draws of it would not wait (resolve) until it is built. The test would then assert that the second draw returns at once.

2. The new execute_indirect path is tested only with a failed build, not one that timed out.
execute_indirect_with_a_stand_in_binds_the_titles_root_signature_first uses submit(standin, false, Box::new(|| 0)), so the pipeline is done and has failed, and the 4 s limit is never reached. A test with a build that is still running and a short limit would cover the case the PR is for: the stand-in returned at the deadline, then the root signature, then ExecuteIndirect. graphics_bound past the limit has no test either. (From the code, the bind test would fail on main, whose path doesn't bind the root signature, so it does cover that half. I didn't run it there.)

3. XCL_PSO_WAIT_MS is read once into a OnceLock.
The tests get around this by calling resolve_within directly, which is fine. Parsing the variable (0 = no limit, junk = the default) has no test. That's minor and could stay as it is.

Overlap with a change I'm preparing (for #232, compute pipelines):

  • I plan to send lazy compute pipelines to the xcl-pso workers when the title creates them, so that the first bind usually finds them built. This PR keeps compute on resolve_wait, and nothing here would change.
  • The workers have one FIFO queue. With compute builds sent when they are made, a graphics pipeline sent at its first draw can sit behind them, and under this PR's limit its draws would time out and be lost more often. My change will have to handle that (for example graphics ahead in the queue). I'm noting it here so the two PRs are not judged separately on it.
  • Both PRs change the module doc of pso_async.rs (lines 3–8), and mine also changes the lazy() doc. Whichever lands second rebases. Mine changes submit_as, which this PR doesn't touch.

AI use: Claude Code (Claude Opus 5.5) read the diff, ran the tests above and wrote this review. I checked each point myself before posting.

@woreksami

Copy link
Copy Markdown

Test report on NVIDIA, together with #214 (the stall it times out needs #214 to drain at all on this card).

Tested

Not tested

  • 150 ms without the thread cap, and the thread cap without this PR; the workspace suite; scripts/smoke.ps1; AMD.

AI use

  • Claude Code with Claude Opus 5.5: built the branch, ran the title, read the logs and wrote this report from those runs.

@qinrxx

qinrxx commented Nov 24, 2026

Copy link
Copy Markdown

@heretic1321 we have a Windows host with an RTX 5080 and the retail title, and we'll run the smoke pair for 043d1f7 tonight. That saves the others asking.

We'll post the blocks here with the stand-in draw counts and long-wait lines from the logs.

AI use: Claude Code (Claude Opus 5.5) drafted this comment.

@imnicho

imnicho commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Test report on the retail title and an NVIDIA card – the run listed under What the reporter must verify. 043d1f7 merged onto main 508a0c7, release; #334, #266, #435, #490 and the CopyFromSubresource fix (as in #539) are merged as well (this PC needs them to get as far as the world's graphics set-up).

Machine: Intel Core i7-7700K (4 cores / 8 threads), 16 GB RAM, NVIDIA GeForce RTX 5080 16 GB (driver 610.47, 32-lane waves), Windows 10 22H2 (19045), rustc 1.100.0. XCL_NETWORK=0, a pad script (XCL_PRESS_AT), default XCL_PSO_WAIT_MS.

With this PR the title still ends by its null write (#232; at 190 s, 29 s after its last frame) – but not in a draw:

How long those compute builds are – the same build with the title's null write stepped over (a local change, not a fix, so that the compiles finish and the run goes on), cold driver cache for these programs, 4 title threads building at once from ~165 s:

DXIL of the compute program builds in a title thread among the first 32 waits of 2 s and more (what gets logged) median longest
under 100 KB 11 3.6 s 4.4 s
100 – 200 KB 12 8.8 s 14.6 s
200 – 400 KB 5 26.9 s 33.9 s

In that 15-minute run: 318 compute pipelines built (24.4 MB of DXIL), 438 DXC compiles (the DXIL cache had none of the world's programs), 39 stand-in draws (this PR at work, with the "not built after 4.0 s" lines), and no frame after about 150 s. For its last nine minutes mostly one title thread built compute pipelines one after another – 125 KB to 222 KB of DXIL each, DXC and then the driver, 4 to 8 a minute – with the other cores and the xcl-pso workers idle. The run before it had left three such programs (153 KB – 390 KB, 6 s – 22 s) in the driver's cache; this one did not wait for them again.

Not tested: AMD; XCL_PSO_WAIT_MS=1 and =0; a second run on the driver cache this one filled; the draws in the world (not reached yet).

AI use: Claude Code with Claude Fable 5.2 ran the builds and runs and wrote this report; every number is from a run on the machine named. No game files are attached.

@qinrxx

qinrxx commented Nov 24, 2026

Copy link
Copy Markdown

Smoke pair for 043d1f7, as offered above. Windows host, retail title, the same package and duration for both runs.

Setup: NVIDIA GeForce RTX 5080 16 GB, driver 32.0.16.2124; AMD Ryzen 7 9800X3D; 31.6 GB RAM; Windows 11 Pro 26200; rustc 1.100.0; release builds; title 1.0.2.1.

  • main: 2997c9a, no local changes.
  • This PR: 043d1f7 merged into main 2997c9a. That's local merge commit 83be934, with no conflicts and nothing else in the tree (D3D12.X: bound driver PSO compile concurrency and surface stage progress (#156) #214 not included).
  • scripts/smoke.ps1 -Seconds 300 (it sets XCL_NETWORK=0, XCL_ACTIVITY=1), A pressed at 14 / 17 / 21 s through XCL_PRESS_A_AT in both runs. Default XCL_PSO_WAIT_MS (4 s).

Regression run

xcl-smoke v1
commit: 2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 300
exit: 0x0
frames shown: 5099 (PresentX 5099)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15011 MB
xcl-smoke v1
commit: 83be934fd100dee8d519efd1131412326fae8cfa
gpu: NVIDIA GeForce RTX 5080
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 300
exit: 0x0
frames shown: 5116 (PresentX 5116)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14991 MB

Against main: 100.3 % of its frames, 99.9 % of its peak commit. No crash and no device removal in either run. The PR run did not end at the watchdog, so the XCL_PSO_WAIT_MS=1 run was not needed.

From the PR run's logs:

  • d3d12.standin_draws: 0. No not built after line, and no waited … for … pipeline line (no wait of 2 s or more).
  • Pipelines: background_pipelines [13, 0, 57810], 3 compute pipelines built.

What it does not cover: neither run got to world loading, where #232 stops.

  • 126 BCPack refusals in total, against ~2,000 in the stall reports.
  • Commit flat at ~15 GB.
  • Presents at 60 per 2 s to the end.

So this is a regression check of the menus and loading before the world (nothing broke there). It doesn't test the draw waits this PR bounds: none reached the limit, or even 2 s.

Not tested: together with #214; world loading; AMD; other cards; a cold DXIL cache.

AI use: Runs: OpenCode with GLM (Z.ai) GLM-5.3, which executed the runs on the hardware above and extracted the numbers. Drafts: Claude Code (Claude Opus 5.5), which built XCL (both trees), checked the figures against the logs and report.json, and wrote this comment. A human (Qinrxx) reviewed it before posting.

@woreksami

Copy link
Copy Markdown

@heretic1321 this now conflicts with main (#574's ExecuteIndirect skip in bind.rs, #690's note_use and submit_lazy(…, key) in pso_async.rs). In case it saves you time, here is a resolution I tested; nothing is pushed anywhere.

What it does

Tested

Not tested

  • This merge alone with the title, scripts/smoke.ps1, the workspace suite.
Resolution (git show --remerge-diff of the merge)
diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs
remerge CONFLICT (content): Merge conflict in crates/xcl/src/hle/d3d12x/bind.rs
index 20b1ce8..7b70f0c 100644
--- a/crates/xcl/src/hle/d3d12x/bind.rs
+++ b/crates/xcl/src/hle/d3d12x/bind.rs
@@ -218,7 +218,6 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us
     let (gfx, compute) = (super::real::is_translated_graphics(pso), super::real::is_translated_compute(pso));
     let (args_off, count_off) = (args_off + super::real::buffer_delta(args), count_off + super::real::buffer_delta(count_buf));
     if !gfx && !compute {
-<<<<<<< 6025201 (Merge pull request #771 from gefydev/readme/discord-invite)
         // A pipeline still being built (or whose build failed): its stand-in draws nothing, and
         // the list may hold XCL's ABI root signature from a translated draw before it – the PC
         // call with that pair is invalid (debug layer 953, "the currently set Root Signature
@@ -233,10 +232,6 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us
             return;
         }
         // a PC pipeline: the title's root signature, as for a draw (`graphics_bound`)
-=======
-        // a PC pipeline (also a stand-in whose build is not done within the limit or failed):
-        // the title's root signature first, as in `graphics_bound` (nothing else binds it)
->>>>>>> 043d1f7 (D3D12.X: a draw waits at most 4 s for a pipeline still building)
         let rs = with(this, |s| s.rs_gfx) as *mut c_void;
         if let (Some(list), Some(r)) = (ID3D12GraphicsCommandList::from_raw_borrowed(&this), ID3D12RootSignature::from_raw_borrowed(&rs)) {
             list.SetGraphicsRootSignature(r);
diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs
remerge CONFLICT (content): Merge conflict in crates/xcl/src/hle/d3d12x/pso_async.rs
index 3662af0..4d30ea3 100644
--- a/crates/xcl/src/hle/d3d12x/pso_async.rs
+++ b/crates/xcl/src/hle/d3d12x/pso_async.rs
@@ -345,11 +345,8 @@ pub fn resolve(pso: usize) -> usize {
 /// it yet (a queue of a title's hundreds of pipelines must not hold up the one it binds now).
 pub fn resolve_wait(pso: usize) -> usize {
     let Some(p) = entry(pso) else { return pso };
-<<<<<<< 6025201 (Merge pull request #771 from gefydev/readme/discord-invite)
     p.note_use();
-=======
     let start = Instant::now();
->>>>>>> 043d1f7 (D3D12.X: a draw waits at most 4 s for a pipeline still building)
     let job = p.job.lock().unwrap().take();
     let here = job.is_some();
     if let Some(job) = job {
@@ -513,6 +510,7 @@ mod draw_wait_tests {
                 let _ = go_rx.recv();
                 real
             }),
+            0,
         );
         let limit = Some(Duration::from_millis(300));
         let lost = standin_draws();
@@ -546,10 +544,11 @@ mod draw_wait_tests {
                 std::thread::sleep(Duration::from_millis(100));
                 c_real
             }),
+            0,
         );
         assert_eq!(resolve_within(c, Some(Duration::ZERO)), c_real);
         let (g, g_real) = (0x7410_0021usize, 0x7410_0022usize);
-        submit_lazy(g, false, Box::new(move || g_real));
+        submit_lazy(g, false, Box::new(move || g_real), 0);
         assert_eq!(resolve_within(g, None), g_real);
         assert_eq!(resolve_within(0x7410_0031, Some(Duration::ZERO)), 0x7410_0031, "not a stand-in");
         let _ = released(c);

AI use: Claude Code with Claude Opus 5.5 resolved the conflicts, ran the tests and wrote this comment.

Part of xcl-dev#232. Bounds graphics pipeline waits at draws/ExecuteIndirect to XCL_PSO_WAIT_MS (default 4000 ms, 0 = no limit) and runs builds on workers rather than the title thread. Latches each timed-out pipeline as late so later draws while it is still building return the stand-in immediately instead of waiting N * limit, counts skipped draws in report.json (d3d12.standin_draws), composes with xcl-dev#574's pending ExecuteIndirect skip, and adds unit tests for the per-pipeline latch, timed-out ExecuteIndirect, and env parsing.

Assisted-by: Antigravity (Claude Opus 5.5) and T3 Code / Antigravity (gemini-pro-orchestrator-neon)
@heretic1321
heretic1321 force-pushed the fix/retail-null-write-232 branch from 043d1f7 to ef98154 Compare November 24, 2026 09:46
@heretic1321 heretic1321 changed the title D3D12.X: a draw waits at most 4 s for a pipeline still building (#232) D3D12.X: a slow graphics pipeline waits at most 4 s once per build (#232) Nov 24, 2026
@heretic1321

Copy link
Copy Markdown
Author

Rebased onto upstream/main (6bac4b4) at ef98154fe389c94736d241997c83bccb755c65bb (0 errors, 0 warnings on AR_x86_64_pc_windows_msvc=llvm-ar cargo check --release --workspace and --tests).

Thank you @qinrxx, @Chrysana, @imnicho, @woreksami, and @Kalmarv for all the reviews, test runs, and conflict notes!

Review points addressed in ef98154:

  1. Per-pipeline timeout latch (Pending::late) (@Kalmarv point 4, @qinrxx point 1): Once one draw times out waiting for a graphics pipeline still building on a worker, p.late is latched so subsequent draws of that pipeline return the stand-in immediately (and increment standin_draws) instead of waiting N * limit. Updated draw_wait_tests to assert the second draw returns immediately (< 100 ms).
  2. Timed-out execute_indirect test (@qinrxx point 2): Added bind::tests::execute_indirect_skips_when_a_still_building_graphics_pipeline_times_out covering a blocked graphics build after late is tripped, verifying #574's pending skip runs without waiting another limit and without calling PC ExecuteIndirect.
  3. Env var parsing test (@qinrxx point 3): Factored parse_wait_limit and added draw_wait_tests::wait_limit_parses_env_values.
  4. Conflict resolution (#574 + #690) (@woreksami): Preserved #574's pending ExecuteIndirect skip and #690's p.note_use() / submit_lazy(..., key) (and called p.note_use() in resolve_within so #690 records used graphics pipelines).

Note on overlap with #891 / #533:
@imnicho's RTX 5080 run on 043d1f7 showed that compute pipeline waits in resolve_wait also hit #232's watchdog when graphics waits stayed under the limit (0 standin_draws at the 190 s abort), and #891 (with XCL_PSO_WAIT_MS opt-in across compute + graphics) / #533 address that side. This PR stays focused on the safe-by-default 4 s graphics-only bound (since dropping graphics draws does not corrupt compute state); happy to close if maintainers prefer #891 alone, or ask for a fresh xcl-smoke pair on ef98154 if the default graphics bound is still wanted independently.

@heretic1321

Copy link
Copy Markdown
Author

Closing as superseded by #891 (5fab112 / 8cada26), which merged XCL_PSO_WAIT_MS (with 0 / unset waiting indefinitely) and the Pending::late latch directly into pso_async::resolve_wait, covering both compute binds and graphics draws.

Thanks to @qinrxx, @Chrysana, @imnicho, @woreksami, and @Kalmarv for all the reviews and Windows/GPU test runs.

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.

7 participants