Skip to content

[upstream #889] D3D12.X: compute pipelines are built ahead of their first bind - #189

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/889
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/889

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

A lazy compute pipeline is built at its first bind, on the title's thread: the bind has to wait (a skipped dispatch corrupts what it computes), and on an NVIDIA GPU the driver takes seconds for a big translated compute shader. xcl-dev#690 preloads only the shaders an earlier run used, so every compute pipeline new to a run is still compiled in the middle of a frame. Here every compute pipeline goes to the preload workers when the title makes it, behind the earlier run's ones; graphics pipelines stay lazy. Part of xcl-dev#505.

Open PRs that change pso_async.rs too: xcl-dev#828 (the same preload function: a textual conflict), xcl-dev#533, #267, xcl-dev#754, xcl-dev#628 – each limits or reorders waits; none builds a pipeline before its first use.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: submit_lazy sends compute pipelines to the preload queue too; the queue has two lines (an earlier run's pipelines first, then the other compute ones). A bind that comes first still builds or waits as before. Test: a_compute_pipeline_is_built_ahead_of_its_first_bind (fails without the change: the compute pipeline is still pending after 10 s).

Tested

Regression run

main:

xcl-smoke v1
commit: 1ec4c98cda119432a4b3f205e146fba2d6f8379a
gpu: NVIDIA GeForce RTX 5080
title: WALKING_SIM
seconds: 90
exit: 0x0
frames shown: 710 (PresentX 711)
presents per 2 s (last 3): 19 16 15
device removals: 0
crashes: 0
peak commit: 17367 MB

PR:

xcl-smoke v1
commit: e1d3b9d1e1bfb4ca068a52516b7466853bf7735e
gpu: NVIDIA GeForce RTX 5080
title: WALKING_SIM
seconds: 90
exit: 0x0
frames shown: 600 (PresentX 600)
presents per 2 s (last 3): 18 16 15
device removals: 0
crashes: 0
peak commit: 16533 MB

Both runs had under 17 GB of commit free at start, so the title's GPU heaps stayed out of the coherent window (512 MB, #284) – hence ~8 fps in both. The PR's run shows 15 % fewer frames; one run each, so whether that is the background compute builds or run-to-run noise is not settled.

Not tested

AI use

  • Claude Code with Claude Opus 5.5: found the cause (profiling the title's threads and the counter on resolve_wait), wrote the change and the test, ran the tests and the runs, and wrote this description.

Mirror of xcl-dev#889 (auto-synced, do not edit).

A lazy compute pipeline was built at its first bind, on the title's
thread: the bind has to wait for it (a skipped dispatch corrupts what it
computes), and the driver takes seconds for a big one. Preloading (xcl-dev#690)
covered only the shaders an earlier run used, so every compute pipeline
new to a run was still compiled in the middle of a frame.

Every compute pipeline now goes to the preload workers when the title
makes it, after the ones of an earlier run (a second, lower line of the
same queue). Graphics pipelines stay lazy: a retail title makes ~58 000
pipelines and only 2 734 of them have a compute shader, so building
these costs little. A bind that comes first still builds or waits as
before, and each build is kept on disk for later runs (driver_cache).

Measured on the retail title of xcl-dev#505 (RTX 5080, driver 32.0.16.2124,
XCL_NETWORK=0, 240 s), counting resolve_wait calls that found their
pipeline not built: without this, 16 compute binds built theirs on a
title thread, 3 - 23 s each and 92.7 s in all, on five threads within
10 s, and the title's hang watchdog ended the run at 125 s. With it, one
bind waited 2 ms; the run went on until XboxBvhBuilder refused an
acceleration structure above 2^40 (xcl-dev#585) at 137 s.

Part of xcl-dev#505.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#889 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/889 branch November 25, 2026 00:06
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