Skip to content

D3D12.X: binds go on without big compute programs that write only images - #2176

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
madaraXor:d3d12x-binds-skip-image-only-cs
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
madaraXor:d3d12x-binds-skip-image-only-cs

Conversation

@madaraXor

Copy link
Copy Markdown
Contributor

A compute pipeline is waited for at its first bind, because a dispatch left out would leave its outputs unwritten. That is right for programs that write memory: XCL_PSO_WAIT_MS goes on without every late program, also culling passes whose counts an ExecuteIndirect reads next, and ends in a GPU hang (#675). But many of the programs a retail title's world start waits on write nothing but images: ray-tracing resolves, one per material, 73 – 118 KiB of console code and about 1 MB of DXIL each, 22 – 172 s apiece in an RDNA2 driver, bound one after another. With XCL_PSO_IMAGE_SKIP=1 binds do not wait for those; everything that writes memory is waited for as before. Off by default. Part of #505 and #1269.

What is in it

  • crates/xcl/src/gpu/effects.rs (new): of(code) reads a program's writes from its instructions. Memory: MUBUF / MTBUF / FLAT / GLOBAL / SCRATCH / SMEM stores and atomics, and the global data share (ds_append / ds_consume / ds_ordered_count / GWS, any DS op with GDS set). Images: MIMG stores and atomics. LDS is the group's own. The whole program is read, also past an early s_endpgm; an instruction that does not decode before the end makes the answer unknown (treated as memory). big_and_image_only(blob): the CS of a console container (FSSM or FSPX) with 16 KiB of code or more and no memory write. Not a translator source: translated caches keep their keys.
  • crates/xcl/src/hle/d3d12x/pso_async.rs: image_skip() (XCL_PSO_IMAGE_SKIP=1); image_only(standin) marks a pending pipeline; its binds take resolve_spared: the real pipeline once built, else the stand-in (its dispatches are left out, as for a late pipeline under XCL_PSO_WAIT_MS) with the build sent to the workers. Nobody waits for it, so the build is not "wanted" and takes its turn among the driver's compiles.
  • crates/xcl/src/hle/d3d12x/real.rs: a compute pipeline whose shader is big and image-only is marked when it is created.
  • Tests: gpu::effects::tests (4: images vs memory, code after an early end, GDS, code that does not decode) and pso_async::used_tests::a_bind_does_not_wait_for_a_pipeline_that_writes_only_images (fails without the spared branch: the bind waits for the build and the test times out after 5 s).

Beside #2118, #2114, #1652, #2001. #2118 moves the wait from the bind to the submit, #2001 to the first Dispatch; #2114 and #1652 cap how long binds wait and then go on without any late program. None chooses by what the program writes. This one goes on only without programs that write no memory, and can sit on top of any of them. It touches pso_async.rs and real.rs like #2118; whichever merges first, I rebase.

Tested

Regression run

scripts/smoke.ps1, 60 s, release builds, run back to back, XCL_PSO_IMAGE_SKIP unset (the default).

main:

xcl-smoke v1
commit: 6567c5ffa38fbc7039b2d6bf520154689cc1f482
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 721 (PresentX 723)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18989 MB

PR:

xcl-smoke v1
commit: 5f4d32fbddc04c1408058d40e58f1adf9bdc36de
gpu: AMD Radeon RX 6700 XT
title: 1778c2d9
seconds: 60
exit: 0x0
frames shown: 732 (PresentX 734)
presents per 2 s (last 3): 60 59 58
device removals: 0
crashes: 0
peak commit: 19025 MB

Not tested

  • The smoke runs do not reach the code this changes: it is off by default, and in the title runs above the first big image-only program was bound after 550 s.
  • An image a left-out program would have written keeps its old contents until the pipeline is built. A later pass that takes a count or an argument from such an image is not ruled out by reading the program alone (none seen).
  • NVIDIA / Intel, 32-lane wave GPUs.

AI use

  • Claude Code with Claude Fable 5.2 (analysis of the run logs and the pack, the first version of the change and its tests) and Claude Opus 5.5 (the hardened reading of the program, the tests of it, the runs and this description).

🤖 Generated with Claude Code

A retail title's world start binds one ray-tracing resolve program per
material (`<material>:CS_RaytracingResolve_*`, 801 variants of 16 KiB or more
in its pack, about 1 MB of DXIL each). An RDNA2 driver takes 22 - 172 s to
build each, the title binds them one after another and waits at every bind,
so its world start stood still for 800 - 1 800 s of compiles per run.
Leaving out dispatches of pipelines still being built (`XCL_PSO_WAIT_MS`)
also leaves out culling passes whose counts an ExecuteIndirect reads next,
which hung the GPU (xcl-dev#675).

`gpu::effects` reads what a console program can write from its code: buffer,
flat, global, scratch and scalar stores and atomics, and the global data
share, are memory; image stores and atomics are images; LDS is the group's
own. The whole program is read, past an early S_ENDPGM, and anything that
does not decode before the end makes the answer unknown. With
`XCL_PSO_IMAGE_SKIP=1` (off by default), a bind does not wait for a
compute pipeline of 16 KiB or more of console code that writes no memory:
it gets the stand-in, its dispatches are left out and the build goes to the
workers; once built, binds get the real pipeline. A program that writes
memory waits as before: 338 of the 801 resolve variants write no memory, the
others write a typed buffer.

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

Copy link
Copy Markdown

Passes on NVIDIA (RTX 3060), at the head and merged onto current main, with and without XCL_PSO_IMAGE_SKIP=1. The new bind test fails without the spared branch.

  • Exact head 5f4d32f (base 6567c5f): cargo build --workspace + cargo test --workspace --no-fail-fast -- --test-threads=4: 1002 passed, 0 failed, 45 ignored.
  • Merged onto main 568e7db (no conflicts): 1159 passed, 0 failed, 46 ignored. The same with XCL_PSO_IMAGE_SKIP=1: 1159 passed, 0 failed, 46 ignored. 24 SKIPPED, the same as on main (no wave64, the per-lane refusals, no heap windows).
  • gpu::effects::tests (4) + a_bind_does_not_wait_for_a_pipeline_that_writes_only_images: 10 of 10 runs.
  • Mutation: with the spared check in resolve_wait_for disabled (pso_async.rs:594), the bind test fails (pso_async.rs:447, after 5 s), and it is the only lib test that fails.

Hardware: RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug.

Not tested: a title (no smoke run here), so not the world start this is for or how long its binds take; a release build.

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

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of 5f4d32f merged on main 568e7db with #684, the title, cold driver caches: in 1 of 3 runs with XCL_PSO_IMAGE_SKIP=1 a bind went on without an image-only program, at 148.0 s, where the description's runs first bound one after 550 s. The binding thread did not wait, two ExecuteIndirect calls were left out, and there was no fault or device removal by the end at 150 s. Presents had stopped long before, at 68 to 82 s in every run, while title threads built big compute programs the change does not mark; with one run each way, the table does not show whether the switch moves that.

Setup: Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, RTX 4070 12 GB (driver 615.71.09). Release, x86_64-pc-windows-gnu, Series X profile, XCL_PSO_PRELOAD=0, XCL_SKIP_BINK=1, __GL_SHADER_DISK_CACHE=0, WINEDEBUG=err+all,fixme-all; every logged driver compile had driver blob absent. The title 1.0.2.1, the first-run screens completed once and no story progress, A at 18.2 to 18.3 s. One DXIL cache for all runs; the run without the switch was last.

150 s, 1 run each without XCL_PSO_IMAGE_SKIP=1 XCL_PSO_IMAGE_SKIP=1
first #101 76.6 s 64.3 s 66.5 s
last 2 s with a present 78.4 s 68.2 s 70.1 s
writes only images is still being built lines – (cannot print) 2, at 148.0 s 0
ExecuteIndirect … still being built skipped 0 2 0
driver compiles of 256 KiB or more finished, title threads / workers 6 / 0 10 / 1 13 / 0
faults, device removals, NVIDIA kernel messages 0 0 0
  • 1 ms after those two binds a worker started the only compile of 256 KiB or more that ran on a worker in these runs (1ac709a63ba53d37, 267,764 B of DXIL, 1,963 ms).
  • Every other one was built by the thread that bound it. A marked program is sent to the workers instead (resolve_spared, pso_async.rs:682), so none of those was marked. The first, 2e0055c25f49848a (375,040 B), started at the stop in each run.
  • The 100 s run with the switch had no #101 by 100 s and printed 0 of the change's lines.

Not tested: past 150 s, so whether leaving those dispatches out moves the world load; the preload on; the direct backend; the test suite beyond gpu::effects and pso_async (11 of 11 passed under Wine); Windows; AMD and Intel.

AI use: Claude Code (Claude Opus 5.5) read the change, built the tree, ran the title and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

@raylitebull

Copy link
Copy Markdown
Member

Code review on 5f4d32f:

  • gpu::effects::of cleanly distinguishes memory/LDS-GDS/indirect-arg writers from image-only compute programs, keeping XCL_PSO_IMAGE_SKIP=1 safe for memory-producing passes while preventing binds from stalling on multi-second >=16 KiB image-only shaders.
  • Diff audited and CI workflow approved (running).

Remaining before merge: Build and test finishing green plus dual-vendor (AMD + NVIDIA) verification on 5f4d32f.

@raylitebull
raylitebull merged commit a7ec0db into xcl-dev:main Nov 25, 2026
2 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
Brings main to full parity with upstream/main (cdb0891), including:
- World rendering & gameplay: xcl-dev#1991, xcl-dev#1988, xcl-dev#1984, xcl-dev#2028, xcl-dev#2078
- Memory / VRAM / PSO: xcl-dev#1985, xcl-dev#2157, xcl-dev#2178, xcl-dev#2195, xcl-dev#2176, xcl-dev#1996, xcl-dev#1914
- Direct DXIL & shaders: xcl-dev#2120, xcl-dev#2174, xcl-dev#2194, xcl-dev#2207, xcl-dev#1951, xcl-dev#1973, xcl-dev#2156, xcl-dev#2064
- Preserves local Linux/Wine customizations: docs/linux.md, scripts/linux/*,
  in-process Wine XAsync (xgameruntime/api.rs), loader watchdog bypass, and
  Wine MEM_WRITE_WATCH bypass on coherent UMA windows (gpu/uma.rs).

Assisted-by: Antigravity (Gemini 4)
VolenNakov added a commit to VolenNakov/xcl that referenced this pull request Nov 25, 2026
Conflict in real.rs go_background: xcl-dev#2176's image_only next to xcl-dev#759's
journal entry; both kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants