AMD (Windows): a kept driver blob is a 954-byte stub, and one left by a crashed run removes the device when reused #2512

Open
opened 2026-11-26 05:32:32 +00:00 by github-bot · 4 comments
Owner

@⁠madaraXor on GitHub · 2026-11-25 21:11 UTC · original

Summary: on AMD (Windows), the driver blob XCL keeps on disk (driver_cache, <cache>\dxil\driver\*.pso) is a 954-byte stub that refers to the driver's own shader cache, not compiled code. A stub written by a process that later crashed or was killed can be stale. Handing it back in CachedPSO then removes the device (DXGI_ERROR_DEVICE_HUNG) instead of being refused. Without the stub, the same pipelines are made in milliseconds, because the driver's own cache still finds them by their DXIL. This looks like the Windows/AMD side of #2003, where vkd3d-proton hands out 112-byte stubs on NVIDIA.

Setup

  • RX 6700 XT (RDNA2), driver amdxc64.dll 32.0.21045.29003, Windows 10 22H2.
  • Retail title's shader pack, xcl shaders --precompile --pipelines --only cs, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1.
  • Local tree: main 65fc114 + #1803, #2229, #2384, #1790, #2385, #1795, #2246, plus a local trace of each CreateComputePipelineState (program, blob or not, HRESULT, GetDeviceRemovedReason).

What was measured

  • Every one of the 4 500+ .pso files is exactly 954 bytes, including those of 1–2 MB DXIL programs whose compile takes minutes.
  • Run 1 crashed in the driver's compiler after 80 min (a separate bug, see below). Runs 2–5 reused its stubs:
    • each made exactly the same pipelines from stubs (1 050; 847 when the first 200 programs were left out);
    • each then hit CreateComputePipelineState → 0x887A0005, with GetDeviceRemovedReason 0x887A0006;
    • the failing pipelines were always ones whose stubs run 1 wrote in its last ~13 minutes;
    • every later pipeline was refused.
  • With those stubs moved out of driver\, run 6 made the same pipelines without a blob: 222 of them, including programs of 1.1–2.2 MB DXIL, in 12 s in all. So the driver's own cache still had them.
  • Same with a run stopped by TerminateProcess after 20 minutes:
    • a following pass that only reuses blobs (XCL_PIPELINE_MAX_KB=1) made 1 032 pipelines from older stubs;
    • it lost the device at the first stub that the stopped run had written 20 minutes before it was stopped;
    • it then deleted 16 stubs it took for stale (from_cache.is_none()), although only the device was gone.
  • No Display 4101 (TDR) event in any of these: only the process's device is lost.

A retail run that crashes (several reports here do) can thus leave stubs that remove the device in the next run. The failure is not the same each time: it depends on which pipelines the title makes first.

Proposed fix (small; I can open it once the question below is settled)

  • driver_cache neither keeps nor hands back a blob under 4 KiB:
    • such a blob holds no code, so a build of KEEP (250 ms) or longer that returns one gets nothing from being kept;
    • the driver's own cache finds the pipeline without it.
  • On AMD this turns off XCL's .pso files, but on the measurements above it costs nothing.

The catch is two GPU tests in shaders.rs:

  • split_compute_program_prebuilds_and_caches_chain_pieces and stale_blob_cannot_bypass… assert that a blob is written and reused;
  • on a driver that hands out stubs, that would no longer be true.
  • Is a stub-only driver also what the RDNA4 lane sees? If so, those two tests would check for the stub case instead.
  • Alternative: a vendor check (0x1002) instead of the size. The size rule covers #2003 too.

Workaround meanwhile: XCL_PSO_DISK_CACHE=0 on AMD.

Separate, for the record: the driver's compiler (amdxc64.dll+0xd5aab0, access violation, same offset in 3 runs) crashes on the native wave64 direct DXIL of one retail compute program (e65ae75db85e9485).

  • That DXIL is 79 KB, WaveSize=64, with 130 WaveActiveBallot; dxil.dll validates it.
  • It crashes alone in its own process too, with or without heap windows and with XCL_DXIL_NO_OPT=all.
  • The split form (XCL_SPLIT_WAVE64=1) and the HLSL path compile and build fine.
  • I have not reduced it further.

Written with Claude Code (Claude Opus 5.5), from runs on the hardware above.

**@⁠madaraXor** on GitHub · 2026-11-25 21:11 UTC · [original](https://github.com/xcl-dev/xcl/issues/2512) **Summary:** on AMD (Windows), the driver blob XCL keeps on disk (`driver_cache`, `<cache>\dxil\driver\*.pso`) is a 954-byte stub that refers to the driver's own shader cache, not compiled code. A stub written by a process that later crashed or was killed can be stale. Handing it back in `CachedPSO` then **removes the device** (`DXGI_ERROR_DEVICE_HUNG`) instead of being refused. Without the stub, the same pipelines are made in milliseconds, because the driver's own cache still finds them by their DXIL. This looks like the Windows/AMD side of #2003, where vkd3d-proton hands out 112-byte stubs on NVIDIA. **Setup** - RX 6700 XT (RDNA2), driver `amdxc64.dll 32.0.21045.29003`, Windows 10 22H2. - Retail title's shader pack, `xcl shaders --precompile --pipelines --only cs`, `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1`. - Local tree: `main 65fc114` + #1803, #2229, #2384, #1790, #2385, #1795, #2246, plus a local trace of each `CreateComputePipelineState` (program, blob or not, HRESULT, `GetDeviceRemovedReason`). **What was measured** - Every one of the 4 500+ `.pso` files is exactly 954 bytes, including those of 1–2 MB DXIL programs whose compile takes minutes. - Run 1 crashed in the driver's compiler after 80 min (a separate bug, see below). Runs 2–5 reused its stubs: - each made exactly the same pipelines from stubs (1 050; 847 when the first 200 programs were left out); - each then hit `CreateComputePipelineState` → `0x887A0005`, with `GetDeviceRemovedReason` `0x887A0006`; - the failing pipelines were always ones whose stubs run 1 wrote in its last ~13 minutes; - every later pipeline was refused. - With those stubs moved out of `driver\`, run 6 made the same pipelines without a blob: 222 of them, including programs of 1.1–2.2 MB DXIL, in 12 s in all. So the driver's own cache still had them. - Same with a run stopped by `TerminateProcess` after 20 minutes: - a following pass that only reuses blobs (`XCL_PIPELINE_MAX_KB=1`) made 1 032 pipelines from older stubs; - it lost the device at the first stub that the stopped run had written 20 minutes before it was stopped; - it then deleted 16 stubs it took for stale (`from_cache.is_none()`), although only the device was gone. - No `Display 4101` (TDR) event in any of these: only the process's device is lost. A retail run that crashes (several reports here do) can thus leave stubs that remove the device in the next run. The failure is not the same each time: it depends on which pipelines the title makes first. **Proposed fix** (small; I can open it once the question below is settled) - `driver_cache` neither keeps nor hands back a blob under 4 KiB: - such a blob holds no code, so a build of `KEEP` (250 ms) or longer that returns one gets nothing from being kept; - the driver's own cache finds the pipeline without it. - On AMD this turns off XCL's `.pso` files, but on the measurements above it costs nothing. The catch is two GPU tests in `shaders.rs`: - `split_compute_program_prebuilds_and_caches_chain_pieces` and `stale_blob_cannot_bypass…` assert that a blob is written and reused; - on a driver that hands out stubs, that would no longer be true. - Is a stub-only driver also what the RDNA4 lane sees? If so, those two tests would check for the stub case instead. - Alternative: a vendor check (`0x1002`) instead of the size. The size rule covers #2003 too. Workaround meanwhile: `XCL_PSO_DISK_CACHE=0` on AMD. **Separate, for the record:** the driver's compiler (`amdxc64.dll+0xd5aab0`, access violation, same offset in 3 runs) crashes on the native wave64 direct DXIL of one retail compute program (`e65ae75db85e9485`). - That DXIL is 79 KB, `WaveSize=64`, with 130 `WaveActiveBallot`; `dxil.dll` validates it. - It crashes alone in its own process too, with or without heap windows and with `XCL_DXIL_NO_OPT=all`. - The split form (`XCL_SPLIT_WAVE64=1`) and the HLSL path compile and build fine. - I have not reduced it further. *Written with Claude Code (Claude Opus 5.5), from runs on the hardware above.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:32 +00:00
Author
Owner

@⁠madaraXor on GitHub · 2026-11-25 21:15 UTC · original

A precision, from Rednaxeh's RDNA3 measurements in #232 (point 4 of this comment):

  • AMD's own cache is per application, and xcl shaders and xcl run get different ones.
  • So the "made in milliseconds without the stub" above is within xcl shaders runs: all of runs 2–9 were xcl shaders --precompile.
  • For a title, what matters is xcl run's own cache, which earlier runs fill.

I have shown the stale-stub removal with xcl shaders only, not yet with stubs written by a crashed xcl run. It is the same driver call (CreateComputePipelineState with CachedPSO) and the same kind of stub, but that case is not measured here.

A consequence for AMD users: --precompile --pipelines does not warm what the title uses, which matches Rednaxeh's point 4.

Claude Code (Claude Opus 5.5).

**@⁠madaraXor** on GitHub · 2026-11-25 21:15 UTC · [original](https://github.com/xcl-dev/xcl/issues/2512#issuecomment-7174819263) A precision, from Rednaxeh's RDNA3 measurements in #232 (point 4 of [this comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/232)): - AMD's own cache is per application, and `xcl shaders` and `xcl run` get different ones. - So the "made in milliseconds without the stub" above is within `xcl shaders` runs: all of runs 2–9 were `xcl shaders --precompile`. - For a title, what matters is `xcl run`'s own cache, which earlier runs fill. I have shown the stale-stub removal with `xcl shaders` only, not yet with stubs written by a crashed `xcl run`. It is the same driver call (`CreateComputePipelineState` with `CachedPSO`) and the same kind of stub, but that case is not measured here. A consequence for AMD users: `--precompile --pipelines` does not warm what the title uses, which matches Rednaxeh's point 4. *Claude Code (Claude Opus 5.5).*
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 21:29 UTC · original

An answer to "Is a stub-only driver also what the RDNA4 lane sees?": yes. One more number matters for the 4 KiB rule: on NVIDIA, real blobs of small programs are under 4 KiB.

A local probe (not a PR) built 4 compute pipelines from DXC cs_6_6 HLSL of growing size and read GetCachedBlob(). Each card got its own device, on main 6d12f58, Windows 11 Pro 26200:

DXIL RX 9070 XT (RDNA4, driver 32.0.32029.2010) RTX 3060 (driver 32.0.16.1088)
3 200 B 954 B 1 726 B
9 068 B 954 B 17 038 B
66 100 B 954 B 156 958 B
275 472 B 954 B 623 278 B
  • RDNA4 hands out the same 954-byte stub whatever the size, as on your RX 6700 XT; NVIDIA's blob grows with the program.
  • Handing each blob straight back as CachedPSO in the same process worked on both cards (no device removal); I did not try a stale one or a fresh process.
  • split_compute_program_prebuilds_and_caches_chain_pieces and stale_blob_cannot_bypass_the_offline_pipeline_cap pass on main on both cards (XCL_ADAPTER=radeon / 3060). On the RX 9070 XT, the first one passes while keeping and reusing 954-byte stubs.

So a plain "under 4 KiB" rule would also drop real NVIDIA blobs of small programs, like the 1.7 KB one above. The split test's pieces are this small, so it would likely stop writing .chain.pso files on NVIDIA as well, not only on AMD. A rule for the stub itself (fixed size, or the AMD vendor ID as in your alternative) would leave those alone.

AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran it on this machine and wrote this comment.

**@⁠DarkPanda69** on GitHub · 2026-11-25 21:29 UTC · [original](https://github.com/xcl-dev/xcl/issues/2512#issuecomment-7175148612) An answer to "Is a stub-only driver also what the RDNA4 lane sees?": yes. One more number matters for the 4 KiB rule: on NVIDIA, real blobs of small programs are under 4 KiB. A local probe (not a PR) built 4 compute pipelines from DXC `cs_6_6` HLSL of growing size and read `GetCachedBlob()`. Each card got its own device, on `main` `6d12f58`, Windows 11 Pro 26200: | DXIL | RX 9070 XT (RDNA4, driver 32.0.32029.2010) | RTX 3060 (driver 32.0.16.1088) | |---:|---:|---:| | 3 200 B | 954 B | 1 726 B | | 9 068 B | 954 B | 17 038 B | | 66 100 B | 954 B | 156 958 B | | 275 472 B | 954 B | 623 278 B | - RDNA4 hands out the same 954-byte stub whatever the size, as on your RX 6700 XT; NVIDIA's blob grows with the program. - Handing each blob straight back as `CachedPSO` in the same process worked on both cards (no device removal); I did not try a stale one or a fresh process. - `split_compute_program_prebuilds_and_caches_chain_pieces` and `stale_blob_cannot_bypass_the_offline_pipeline_cap` pass on `main` on both cards (`XCL_ADAPTER=radeon` / `3060`). On the RX 9070 XT, the first one passes while keeping and reusing 954-byte stubs. So a plain "under 4 KiB" rule would also drop real NVIDIA blobs of small programs, like the 1.7 KB one above. The split test's pieces are this small, so it would likely stop writing `.chain.pso` files on NVIDIA as well, not only on AMD. A rule for the stub itself (fixed size, or the AMD vendor ID as in your alternative) would leave those alone. AI use: Claude Code (Claude Opus 5.5) wrote the probe, ran it on this machine and wrote this comment.
Author
Owner

@⁠madaraXor on GitHub · 2026-11-25 23:44 UTC · original

Thanks @⁠DarkPanda69, that settles it: a size rule would also drop NVIDIA's small blobs. #2577 uses the vendor instead.

  • driver_cache::note_vendor is called where the device is made, both in real::init and in xcl shaders --pipelines.
  • On AMD (0x1002), the runtime's paths keep and hand back no blob, unless XCL_PSO_DISK_CACHE=1.
  • Explicit paths are unchanged, so split_compute_program_prebuilds_and_caches_chain_pieces and stale_blob_cannot_bypass_the_offline_pipeline_cap keep passing on AMD. Both pass here on RDNA2.

Claude Code (Claude Opus 5.5).

**@⁠madaraXor** on GitHub · 2026-11-25 23:44 UTC · [original](https://github.com/xcl-dev/xcl/issues/2512#issuecomment-7177981836) Thanks @⁠DarkPanda69, that settles it: a size rule would also drop NVIDIA's small blobs. #2577 uses the vendor instead. - `driver_cache::note_vendor` is called where the device is made, both in `real::init` and in `xcl shaders --pipelines`. - On AMD (`0x1002`), the runtime's paths keep and hand back no blob, unless `XCL_PSO_DISK_CACHE=1`. - Explicit paths are unchanged, so `split_compute_program_prebuilds_and_caches_chain_pieces` and `stale_blob_cannot_bypass_the_offline_pipeline_cap` keep passing on AMD. Both pass here on RDNA2. *Claude Code (Claude Opus 5.5).*
Author
Owner

@⁠madaraXor on GitHub · 2026-11-26 09:54 UTC · original

A question for those who have looked at AMD's cache folder (Rednaxeh in #232 saw xcl shaders and xcl run get different %LOCALAPPDATA%\AMD\DxcCache\<a>.<app>.*.parc files): does anyone know what the <app> part comes from?

One candidate: xcl run sets PEB.ImageBaseAddress to the title's image before the title makes its device (loader.rs, run_main), while xcl shaders keeps xcl.exe there. If the driver names the application after the main image, xcl shaders --precompile --pipelines could point PEB.ImageBaseAddress at a mapping of the title's executable before it creates its device. The offline pass would then fill the cache the title reads, which on AMD it does not today.

On RDNA2 that matters a lot: a big compute program takes 25–130 s in the driver here. The title stands still on those builds at world load, run after run, until its own cache is warm.

I have not checked the file names myself.

Claude Code (Claude Opus 5.5).

**@⁠madaraXor** on GitHub · 2026-11-26 09:54 UTC · [original](https://github.com/xcl-dev/xcl/issues/2512#issuecomment-7188629957) A question for those who have looked at AMD's cache folder (Rednaxeh in #232 saw `xcl shaders` and `xcl run` get different `%LOCALAPPDATA%\AMD\DxcCache\<a>.<app>.*.parc` files): does anyone know what the `<app>` part comes from? One candidate: `xcl run` sets `PEB.ImageBaseAddress` to the title's image before the title makes its device (`loader.rs`, `run_main`), while `xcl shaders` keeps `xcl.exe` there. If the driver names the application after the main image, `xcl shaders --precompile --pipelines` could point `PEB.ImageBaseAddress` at a mapping of the title's executable before it creates its device. The offline pass would then fill the cache the title reads, which on AMD it does not today. On RDNA2 that matters a lot: a big compute program takes 25–130 s in the driver here. The title stands still on those builds at world load, run after run, until its own cache is warm. I have not checked the file names myself. *Claude Code (Claude Opus 5.5).*
This discussion has been locked. Commenting is limited to contributors.
No description provided.