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

Merged
bmjask merged 3 commits from upstream-pr/2371 into main 2026-11-26 00:48:16 +00:00
bmjask commented 2026-11-25 16:59:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T16:59:07Z.


Split-eligible compute programs can use an offline whole-pipeline blob at runtime. A missing or rejected blob falls back to building the split pieces. Part of #2088.

What is in it

  • Reuse the cached whole pipeline with its ordinary compute root signature. A fresh-process GPU test covers cache hit, stale blob and miss.
  • Use compact DXIL for repeated split-wave compute blocks with returning buffer atomic adds. Retain the existing table budget per wave.
  • Add opt-in offline timing and GPU output replay for locally supplied shader inputs. Slot reuse and duplicate-phi experiments are test-only.

Tested

  • Head f8f9de65, Windows 11 build 26200, Core i9-12900K, RTX 4090 driver 610.88, Rust 1.100.0.
  • cargo build --locked --workspace; cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output (debug): 1,435 passed, 0 failed, 47 ignored. 25 explicit GPU skip messages across 15 tests, including wave64 and unavailable instruction forms. The bridged-mask barrier regression passed on this head.
  • cargo test --locked -p xcl --test gpu_compute_e2e -- --test-threads=1 --show-output with XCL_HEAP_WINDOWS=1: 7 passed, 0 failed, 0 ignored, 0 skipped for each of XCL_DIRECT_DXIL=0 and 1.
  • Earlier RTX 4090 measurements on fa14dc47: five cold trials per form on each of two recorded shaders. Median driver creation fell from 4.07 s to 0.60 s and from 4.07 s to 0.52 s. Output counters and IDs matched; these measurements predate the rebase.

Regression run
Release, same title, machine and 60-second guest interval, using scripts/smoke.ps1.

Main

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1020 (PresentX 1020)
presents per 2 s (last 3): 47 47 41
device removals: 0
crashes: 0
peak commit: 15910 MB

PR head

xcl-smoke v1
commit: f8f9de654f82aba63dc80451b895ac4e49e691d6
gpu: NVIDIA GeForce RTX 4090
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1266 (PresentX 1266)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16336 MB

Not tested

  • AMD or Intel GPU on this revision. The short smoke establishes startup regression coverage. World-entry performance and cold-compile timing on this head remain unmeasured.

AI use
OpenAI Codex, GPT-6: implementation, test harness, upstream conflict resolution, fixture update, validation and PR description.

<!-- greyfinch-sync:ivall/xcl:issue:6609487258 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2371). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T16:59:07Z. --- Split-eligible compute programs can use an offline whole-pipeline blob at runtime. A missing or rejected blob falls back to building the split pieces. Part of #2088. **What is in it** - Reuse the cached whole pipeline with its ordinary compute root signature. A fresh-process GPU test covers cache hit, stale blob and miss. - Use compact DXIL for repeated split-wave compute blocks with returning buffer atomic adds. Retain the existing table budget per wave. - Add opt-in offline timing and GPU output replay for locally supplied shader inputs. Slot reuse and duplicate-phi experiments are test-only. **Tested** - Head `f8f9de65`, Windows 11 build 26200, Core i9-12900K, RTX 4090 driver 610.88, Rust 1.100.0. - `cargo build --locked --workspace`; `cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output` (debug): 1,435 passed, 0 failed, 47 ignored. 25 explicit GPU skip messages across 15 tests, including wave64 and unavailable instruction forms. The bridged-mask barrier regression passed on this head. - `cargo test --locked -p xcl --test gpu_compute_e2e -- --test-threads=1 --show-output` with `XCL_HEAP_WINDOWS=1`: 7 passed, 0 failed, 0 ignored, 0 skipped for each of `XCL_DIRECT_DXIL=0` and `1`. - Earlier RTX 4090 measurements on `fa14dc47`: five cold trials per form on each of two recorded shaders. Median driver creation fell from 4.07 s to 0.60 s and from 4.07 s to 0.52 s. Output counters and IDs matched; these measurements predate the rebase. **Regression run** Release, same title, machine and 60-second guest interval, using `scripts/smoke.ps1`. Main ``` xcl-smoke v1 commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea gpu: NVIDIA GeForce RTX 4090 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1020 (PresentX 1020) presents per 2 s (last 3): 47 47 41 device removals: 0 crashes: 0 peak commit: 15910 MB ``` PR head ``` xcl-smoke v1 commit: f8f9de654f82aba63dc80451b895ac4e49e691d6 gpu: NVIDIA GeForce RTX 4090 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1266 (PresentX 1266) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16336 MB ``` **Not tested** - AMD or Intel GPU on this revision. The short smoke establishes startup regression coverage. World-entry performance and cold-compile timing on this head remain unmeasured. **AI use** OpenAI Codex, GPT-6: implementation, test harness, upstream conflict resolution, fixture update, validation and PR description.
DavidM1911 commented 2026-11-25 19:09:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T18:56:18Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7171605327 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2371#issuecomment-7171605327). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T18:56:18Z. --- 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 commented 2026-11-25 19:09:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T19:06:10Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7171821637 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2371#issuecomment-7171821637). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T19:06:10Z. --- **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.
bmjask commented 2026-11-25 21:04:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:43:16Z.

Review: COMMENTED


No confirmed source-level cache/keying defect found; whole-blob hit/miss/rejection fallback coverage is useful. This draft is not merge-ready: it is dirty/non-mergeable, current Windows build/test and PR-description checks fail, the full suite is not clean, and paired smoke plus AMD/Intel/in-game validation are pending. Please resolve/rebase and provide required evidence before merge.

<!-- greyfinch-sync:ivall/xcl:review:6064715379 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2371#pullrequestreview-6064715379). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:43:16Z. **Review:** COMMENTED --- No confirmed source-level cache/keying defect found; whole-blob hit/miss/rejection fallback coverage is useful. This draft is not merge-ready: it is dirty/non-mergeable, current Windows build/test and PR-description checks fail, the full suite is not clean, and paired smoke plus AMD/Intel/in-game validation are pending. Please resolve/rebase and provide required evidence before merge.
upstream-sync closed this pull request 2026-11-26 01:05:14 +00:00
DavidM1911 commented 2026-11-26 01:05:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T00:23:16Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier failure is fixed.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7178702198 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2371#issuecomment-7178702198). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T00:23:16Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier` failure is fixed. Thanks! — Devin
humsterbumster commented 2026-11-26 14:03:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by humsterbumster on 2026-11-26T13:57:28Z.


Offline compute pass measured on Linux with the same retail title (1.0.2.1) at b49be18, this PR merged. One behaviour first, because it silently produces a no-op run.

A folder argument finds no shader records for this title. The installed folder has no loose shaders\ directory; the corpus is shaders.rpf (411,695,600 B). Pointing the tool at the installed folder:

--used-only: 1845 pipelines earlier runs used (used-pipelines.txt); compute programs of other pipelines are passed over
precompiling 109 shaders into C:\users\steamuser\AppData\Local\xcl\dxil (15 compile threads; 4 memory windows, split wave64 for a GPU with 32-lane waves)
compiled 0, already cached 0, errors 0, skipped (GS – paired at pipeline creation) 0, time 292.4 s
compute programs passed over (no earlier run used their pipeline): 0
pipelines made on the GPU 0, refused 0
pipelines loaded from the driver cache 0

109 inputs, 0 compiled, 0 made, no error, 292 s and 24.4 GB peak RSS. The 109 are the folder's loose files, not shader records.

Naming the container works. xcl shaders shaders.rpf --precompile --only cs --pipelines --used-only --split 1 is read as an RPF9 package and makes pipelines: pipelines: 1500 made, 0 refused in 15 min at ~300% CPU / 11.7 GB RSS, driver blobs 4,226 -> 4,402, vkd3d-proton.cache 0 -> 283,440 B on exit. That is ~1.7 pipelines/s against 0.23/s in the title's own load, so the offline path is the right lever here.

The pass stops at 1,500 with two stack overflows, and then hangs. Twice, at the same count:

thread '<unknown>' (316) has overflowed its stack

thread '<unknown>' (340) has overflowed its stack

after which all 24 threads sit in futex_do_wait, utime stays frozen for minutes and the GPU is at 0 %; the summary lines never print and the process never exits on its own. Reproduced with 128 MB and with 512 MB pipeline-worker stacks, so it is not one of the named xcl-pso* threads. This build of main also carries local, uncommitted changes (worker stack size, a huge-compile cgroup gate, driver-blob interning), so I am not claiming it as a defect of this PR - just that 1,500 is where this title's shader set reaches it.

Cache plumbing checked (vkd3d-proton 3.2.0, libs/vkd3d/cache.c): vkd3d-proton.cache is read at start, .cache.write appended and merged on clean exit (vkd3d_pipeline_library_disk_cache_merge, cache.c:3173), and a leftover .write is merged on the next start (cache.c:2968-3024), so the 1,500 made here survive as long as the process exits cleanly.

Lane: Arch, kernel 7.3.5, Wine 11 (Proton), vkd3d-proton 3.2.0 ec20719, RTX 5090, Rust 1.100.0, x86_64-pc-windows-gnu, 1080p.

<!-- greyfinch-sync:ivall/xcl:comment:7194073246 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2371#issuecomment-7194073246). Originally posted by [humsterbumster](https://github.com/humsterbumster) on 2026-11-26T13:57:28Z. --- Offline compute pass measured on Linux with the same retail title (1.0.2.1) at `b49be18`, this PR merged. One behaviour first, because it silently produces a no-op run. **A folder argument finds no shader records for this title.** The installed folder has no loose `shaders\` directory; the corpus is `shaders.rpf` (411,695,600 B). Pointing the tool at the installed folder: ``` --used-only: 1845 pipelines earlier runs used (used-pipelines.txt); compute programs of other pipelines are passed over precompiling 109 shaders into C:\users\steamuser\AppData\Local\xcl\dxil (15 compile threads; 4 memory windows, split wave64 for a GPU with 32-lane waves) compiled 0, already cached 0, errors 0, skipped (GS – paired at pipeline creation) 0, time 292.4 s compute programs passed over (no earlier run used their pipeline): 0 pipelines made on the GPU 0, refused 0 pipelines loaded from the driver cache 0 ``` 109 inputs, 0 compiled, 0 made, no error, 292 s and 24.4 GB peak RSS. The 109 are the folder's loose files, not shader records. **Naming the container works.** `xcl shaders shaders.rpf --precompile --only cs --pipelines --used-only --split 1` is read as an RPF9 package and makes pipelines: `pipelines: 1500 made, 0 refused` in 15 min at ~300% CPU / 11.7 GB RSS, driver blobs 4,226 -> 4,402, `vkd3d-proton.cache` 0 -> 283,440 B on exit. That is ~1.7 pipelines/s against 0.23/s in the title's own load, so the offline path is the right lever here. **The pass stops at 1,500 with two stack overflows, and then hangs.** Twice, at the same count: ``` thread '<unknown>' (316) has overflowed its stack thread '<unknown>' (340) has overflowed its stack ``` after which all 24 threads sit in `futex_do_wait`, utime stays frozen for minutes and the GPU is at 0 %; the summary lines never print and the process never exits on its own. Reproduced with 128 MB and with 512 MB pipeline-worker stacks, so it is not one of the named `xcl-pso*` threads. This build of `main` also carries local, uncommitted changes (worker stack size, a huge-compile cgroup gate, driver-blob interning), so I am not claiming it as a defect of this PR - just that 1,500 is where this title's shader set reaches it. **Cache plumbing checked** (vkd3d-proton 3.2.0, `libs/vkd3d/cache.c`): `vkd3d-proton.cache` is read at start, `.cache.write` appended and merged on clean exit (`vkd3d_pipeline_library_disk_cache_merge`, cache.c:3173), and a leftover `.write` is merged on the next start (cache.c:2968-3024), so the 1,500 made here survive as long as the process exits cleanly. Lane: Arch, kernel 7.3.5, Wine 11 (Proton), vkd3d-proton 3.2.0 `ec20719`, RTX 5090, Rust 1.100.0, `x86_64-pc-windows-gnu`, 1080p.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2361
No description provided.