Skip to content

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

Open
madaraXor wants to merge 1 commit into
xcl-dev:mainfrom
madaraXor:d3d12x-binds-skip-image-only-cs
Open

madaraXor wants to merge 1 commit into
xcl-dev:mainfrom
madaraXor:d3d12x-binds-skip-image-only-cs

Conversation

@madaraXor

Copy link
Copy Markdown

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.

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