Skip to content

D3D12.X: a bind's driver compile is not on the title thread - #8

Merged
stolk88 merged 1 commit into
mainfrom
cursor/bind-off-thread-bd70
Nov 24, 2026
Merged

stolk88 merged 1 commit into
mainfrom
cursor/bind-off-thread-bd70

Conversation

@stolk88

@stolk88 stolk88 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

A lazy compute PSO is built on the title thread inside resolve_wait when no worker has started it. On this NVIDIA GPU that driver compile takes 5–10 s (517 KB DXIL measured at 9673 ms). The title's stall check, a thread that Sleeps once a second and gives up after 30 ticks without a sign of the main thread (xcl-dev#505), then writes 0 at game_scarlett_master.exe+0x23cf683. The device is still alive, so #7's GPU-wait hold has nothing to log: that path is not an armed queue.Wait.

What the other approaches do, and why this is the small one:

This PR is that hold, plus the compile itself leaving the title thread. The bind still waits until the PSO exists. It does not run CreatePipelineState on the title thread, and it does not build every compute PSO at create.

What is in it

  • resolve_wait runs a compile no worker has started on xcl-pso-bind, then waits. The caller is not inside the driver compile.
  • title_held is set for that wait, with or without XCL_PSO_WAIT_MS.
  • kernelx::Sleep: a sleep of 100 ms or more (XCL_SLEEP_HOLD, 0 leaves the PC Sleep) does not count time title_held is set. Shorter sleeps, a yield and INFINITE are passed on.
  • Tests for the hold, for the compile running on another thread, and for which part of a sleep is counted.

Tested

  • hardware: not built / not tested (Linux; the crate is Windows-only)
  • cargo test --workspace: not run

Regression run

main: not run (no Windows host)

PR: not run

Not tested

  • Windows test suite, scripts/smoke.ps1, the retail title, RTX 4080.
  • A stall check that reads a clock instead of Sleep. Upstream kernelx: Sleep does not count the time a bind waits for a pipeline build xcl-dev/xcl#1288 calls that out; it did not fire in their runs.
  • Whether world setup finishes once the pipelines exist. The title thread still waits for each compile, on a condvar rather than inside the driver, so the frame rate stays low until those PSOs are built.

AI use

  • Cursor, Grok 4.7. Compared the open and merged compute-bind PRs, and wrote this hold, the off-thread compile, the tests and this description.
Open in Web Open in Cursor 

Dispatch waited in resolve_wait and ran the driver's compile on the
title thread, 5–10 s for a large compute PSO. The title's stall check
Sleeps once a second and gives up after 30 ticks while that thread has
not returned, then writes 0. The compile now runs on its own thread, and
a Sleep of 100 ms or more does not count the time a bind is waiting.
No dispatch is skipped and pipelines are not built ahead.

Assisted-by: Cursor (Grok 4.7)
Co-authored-by: stolk88 <stolk88@users.noreply.github.com>
@stolk88
stolk88 merged commit 89e90f1 into main Nov 24, 2026
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.

2 participants