Skip to content

Shaders: reuse offline compute PSOs and compact repeated atomic shaders - #2371

Draft
bmjask wants to merge 5 commits into
xcl-dev:mainfrom
bmjask:perf/offline-compute-pipelines
Draft

bmjask wants to merge 5 commits into
xcl-dev:mainfrom
bmjask:perf/offline-compute-pipelines

Conversation

@bmjask

@bmjask bmjask commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Compute pipelines prepared offline can already contain a driver blob for the whole shader. This change lets split-eligible runtime requests use that blob and reduces cold build time for a narrow class of repeated compute programs.

What is in it

  • Try the cached whole pipeline before building split pieces. On a missing or rejected blob, continue through the split path.
  • Use compact DXIL for highly repetitive, branch-heavy split-wave compute programs with a returning buffer atomic add. Respect the existing per-wave table budget.
  • Add opt-in offline shader replay and timing tools. Slot reuse and duplicate-phi experiments are test-only. The harness takes locally supplied inputs.

Tested

Windows, NVIDIA RTX 4090. Measurements below apply to the pre-rebase implementation based on 0829441. On two recorded compute shaders, median cold driver build times fell from 3.51 s to 0.51 s and from 3.33 s to 0.50 s. Both forms matched CPU-expected counters and all 65,536 output IDs at 1,024 groups of 64 active lanes. At small dispatch sizes the compact form took several microseconds longer.

Before rebase, cargo test --release -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1 with XCL_HEAP_WINDOWS=1 ran 5 tests, all passed, zero ignored or skipped. On head 2092425, using an isolated Cargo target directory, cargo test --locked -p xcl --lib -- --nocapture --test-threads=4 reported 1,224 passed, 1 failed, 26 ignored, with 27 runtime skip messages. The failing bridged-mask test counted three group barriers where it expects one. The same isolated test on unmodified base 68a284a also counted three barriers and failed. On fa14dc4 (the later commit restores comment text), five cold trials on the first recorded shader per form on this head gave medians of 4.07 s plain and 0.60 s automatic. On the second shader the five-trial medians were 4.07 s plain and 0.52 s automatic. Both dense replays matched every expected ID and counter. On 2092425, cargo test --locked -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1 with XCL_HEAP_WINDOWS=1 passed all 5 tests with zero failures, ignores or runtime skips.

On head 49aae6c, cargo test --locked -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1 with XCL_HEAP_WINDOWS=1 passed all five tests with zero failures, ignores or runtime skips with each of XCL_DIRECT_DXIL=0 and 1. The cache regression now checks the driver key and confirms a fresh process loads the replacement after rejecting a corrupt blob.

Full workspace on 49aae6c, after cargo build --locked --workspace: cargo test --locked --workspace --no-fail-fast -- --nocapture --test-threads=4 reported 1,295 passed, 1 failed, 46 ignored and 26 explicit runtime skip messages. The sole failure was the bridged-mask barrier count described above. All four synthetic title integration tests passed.

Warm loading on three split-eligible shaders (fa14dc4, five trials per mode, RTX 4090, implicit driver cache disabled, up to four workers). Times are median milliseconds spent creating PSOs on the driver. Shader translation and disk I/O are outside the timer.

Shader Build pieces cold Load saved whole Load saved pieces
A (6 pieces) 1368 113 66
B (6 pieces) 1675 98 63
C (12 pieces) 2658 273 94

An offline whole blob saves 1.25–2.39 s per shader when the pieces would be cold. When all piece blobs exist, loading them in parallel takes less driver wall time. A whole pipeline executes in one dispatch.

Regression run

Paired title smoke runs are pending. This PR is a draft.

Not tested

In-game performance and non-NVIDIA driver performance.

AI use

OpenAI Codex, GPT-6. Implemented the changes, ran offline tests and measurements, and prepared the PR.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1, 1219/1):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).
One red on this lane, and it is invisible to the usual gpu_ sweep because the test name does not contain gpu_: gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier fails deterministically, 3/3 solo at --test-threads=1 with a cold cache:

panicked at crates/xcl/src/gpu/recomp/lower_dxil.rs:1155:9:
assertion `left == right` failed: group barriers in the program:
  left: 3
 right: 1

The disassembled compute_split program contains three call void @dx.op.barrier(i32 80, i32 9) where the test expects only the one at the start. The barrier count is taken over XCL's own lowering disassembly, so DXC does not compile this step; the run uses the pinned official DXC build the lane normally runs (the same one other checks here pass with). The companion new test recorded_split_selects_cached_whole_or_pieces passes 4/4, and the d3d12core.dll + 0x1AB118 crash site from #2338/#2344/#2349 does not reproduce at this head.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

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.

3 participants