AMD driver compiles take 3-8x the budget's estimate and grow quadratically: one compute program cannot be built on 64 GB #19

Open
opened 2026-11-27 03:13:59 +00:00 by github-bot · 5 comments
Owner

@⁠Sr-0w on GitHub · 2026-11-25 05:22 UTC · original

On an AMD card the driver's pipeline compiles take far more memory than CompileBudget expects, and the memory a compile takes grows about quadratically with its DXIL. With the default 4 driver compiles the loader reaches the machine's commit limit during the story load (51 GB private at 37 s); a single compute program cannot be built on a 64 GB machine at all.

Setup: RX 7800 XT (16 GB), Adrenalin driver 32.0.32029.2010, 64 GB RAM, Windows 11 26300; main at f9fab82, DXIL backend (default), --min-free-memory used to stop runs before the machine ran out.

In game: the [budget] lines (ff3914e)

Pipeline DXIL Estimate Private peak
InstanceCulling~CS_Prop_BatchNoCull 0.48 MB 1.3 GB +10.43 GB over 49 s
PS_OctaSLODReZ + MS_VS_OctaSLOD 0.85 MB 2.3 GB +9.85 GB over 21 s
PS_OctaSLODReZ + MS_VS_OctaSLODWind 1.54 MB 4.2 GB +9.83 GB over 60 s
PS_BakeDecorations_0000 + MSNC_VS_BakeDecorations 0.33 MB 0.9 GB +4.00 GB over 9 s
standard_lod~CS_RaytracingResolve 0.28 MB 0.8 GB +2.41 GB over 5 s
sr_tracing~CS_RaytraceVBuffer_RayBinning_ShaderBinning_Mixed_WithFar 0.85 MB 2.3 GB +3.50 GB over 32 s

So 3 to 8 times the estimate, with several running at once. indirect_diffuse_lighting~CS_ScreenProbes_ActivateProbes (12-13 MB of DXIL, a 60,000-instruction program) goes to its own thread and takes the process from about 20 GB to over 50 GB private in 30 s; every run that requested it ended on the free-memory limit (or the machine ran out without one).

Isolated: fivestar shader pso on that one program

A folder holding results.json and <name>.dxil, fivestar shader pso <dir> --jobs 1 --max-memory N, peak private memory sampled every 0.5 s. Same HLSL (fivestar shader translate), compiled with dxc -Od (as for sources over 2.5 M characters), main's body cut after a fraction of its lines, open blocks closed, and the XOR of every s/v register stored to a UAV so nothing is dead:

Body kept DXIL Peak Result
3 % 0.48 MB 1.0 GB accepted in 5 s
8 % 1.5 MB 4.9 GB accepted in 19 s
15 % 2.9 MB 17.2 GB accepted in 46 s
25 % 5.0 MB > 30 GB over-memory after 23 s
100 % 20.9 MB > 40 GB over-memory after 63 s

What I ruled out, each with the same harness or in game:

  • Optimisation level: the dxc -O3 DXIL is 8.0 MB (13.1 MB from the DXIL backend, 22.0 MB -Od). In game, with the -O3 file placed in the program cache, the compile still passed 53 GB.
  • g_code: the program has an s_getpc_b64, so its 122,191 code words are a static array that 210 pointer loads index through the CODE_TAG fallback. With only the 11-word table after s_endpgm, it is still over 40 GB at 63 s.
  • FmtLoad: 3,281 calls, each a 4-component format decode. With FmtLoad replaced by a plain Load4, it is still over 40 GB at 46 s.
  • --dispatch form: 8.7 MB of HLSL, but dxc -Od had not finished after 9 minutes.

None of these is the cause on its own. The growth follows the size of one function with deeply nested if (vw_any(active)) blocks and the whole register file live across them. NVIDIA handles that, per the 2.75 GB per MB measurement; AMD's compiler does not.

Effect

With --max-driver-compiles 1, and the pipelines of 4 MB of DXIL or more left unbuilt (a local change), the same machine runs the story load and the opening credits, and reaches the first deferred-world draws (9,000 presents). The defaults run out of memory before that.

Possible directions (to agree on before any PR)

  1. Per-vendor estimate: base the estimate on the adapter (AMD: roughly 10 GB per MB at 0.5-1.5 MB, growing with size), so fewer compiles are admitted together. This would not help a program that alone needs more than the machine has.
  2. Killable compiles: run large driver compiles in a helper process, either the compile host or a second one. It would create the pipeline on its own device and return GetCachedBlob, which the loader loads with CachedPSO and stores in its library. A compile past a memory or time limit is killed, and its pipeline stays a stand-in (its draws skipped, as for a failed one). The failure is recorded in the cache, so later boots do not retry it.
  3. Smaller programs for big compute shaders: a split or a different emission for the few programs over a few MB. That is the real cure, but it is a translator change.

I can send the measurements' scripts, or work on 1 or 2 if one of them fits where the compile budget is going.

**@⁠Sr-0w** on GitHub · 2026-11-25 05:22 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/issues/19) On an AMD card the driver's pipeline compiles take far more memory than `CompileBudget` expects, and the memory a compile takes grows about quadratically with its DXIL. With the default 4 driver compiles the loader reaches the machine's commit limit during the story load (51 GB private at 37 s); a single compute program cannot be built on a 64 GB machine at all. **Setup**: RX 7800 XT (16 GB), Adrenalin driver 32.0.32029.2010, 64 GB RAM, Windows 11 26300; `main` at f9fab82, DXIL backend (default), `--min-free-memory` used to stop runs before the machine ran out. ### In game: the `[budget]` lines (ff3914e) | Pipeline | DXIL | Estimate | Private peak | |---|---|---|---| | `InstanceCulling~CS_Prop_BatchNoCull` | 0.48 MB | 1.3 GB | +10.43 GB over 49 s | | `PS_OctaSLODReZ` + `MS_VS_OctaSLOD` | 0.85 MB | 2.3 GB | +9.85 GB over 21 s | | `PS_OctaSLODReZ` + `MS_VS_OctaSLODWind` | 1.54 MB | 4.2 GB | +9.83 GB over 60 s | | `PS_BakeDecorations_0000` + `MSNC_VS_BakeDecorations` | 0.33 MB | 0.9 GB | +4.00 GB over 9 s | | `standard_lod~CS_RaytracingResolve` | 0.28 MB | 0.8 GB | +2.41 GB over 5 s | | `sr_tracing~CS_RaytraceVBuffer_RayBinning_ShaderBinning_Mixed_WithFar` | 0.85 MB | 2.3 GB | +3.50 GB over 32 s | So 3 to 8 times the estimate, with several running at once. `indirect_diffuse_lighting~CS_ScreenProbes_ActivateProbes` (12-13 MB of DXIL, a 60,000-instruction program) goes to its own thread and takes the process from about 20 GB to over 50 GB private in 30 s; every run that requested it ended on the free-memory limit (or the machine ran out without one). ### Isolated: `fivestar shader pso` on that one program A folder holding `results.json` and `<name>.dxil`, `fivestar shader pso <dir> --jobs 1 --max-memory N`, peak private memory sampled every 0.5 s. Same HLSL (`fivestar shader translate`), compiled with dxc `-Od` (as for sources over 2.5 M characters), main's body cut after a fraction of its lines, open blocks closed, and the XOR of every s/v register stored to a UAV so nothing is dead: | Body kept | DXIL | Peak | Result | |---|---|---|---| | 3 % | 0.48 MB | 1.0 GB | accepted in 5 s | | 8 % | 1.5 MB | 4.9 GB | accepted in 19 s | | 15 % | 2.9 MB | 17.2 GB | accepted in 46 s | | 25 % | 5.0 MB | > 30 GB | over-memory after 23 s | | 100 % | 20.9 MB | > 40 GB | over-memory after 63 s | What I ruled out, each with the same harness or in game: - **Optimisation level**: the dxc `-O3` DXIL is 8.0 MB (13.1 MB from the DXIL backend, 22.0 MB `-Od`). In game, with the `-O3` file placed in the program cache, the compile still passed 53 GB. - **`g_code`**: the program has an `s_getpc_b64`, so its 122,191 code words are a static array that 210 pointer loads index through the `CODE_TAG` fallback. With only the 11-word table after `s_endpgm`, it is still over 40 GB at 63 s. - **`FmtLoad`**: 3,281 calls, each a 4-component format decode. With `FmtLoad` replaced by a plain `Load4`, it is still over 40 GB at 46 s. - **`--dispatch` form**: 8.7 MB of HLSL, but dxc `-Od` had not finished after 9 minutes. None of these is the cause on its own. The growth follows the size of one function with deeply nested `if (vw_any(active))` blocks and the whole register file live across them. NVIDIA handles that, per the 2.75 GB per MB measurement; AMD's compiler does not. ### Effect With `--max-driver-compiles 1`, and the pipelines of 4 MB of DXIL or more left unbuilt (a local change), the same machine runs the story load and the opening credits, and reaches the first deferred-world draws (9,000 presents). The defaults run out of memory before that. ### Possible directions (to agree on before any PR) 1. **Per-vendor estimate**: base the estimate on the adapter (AMD: roughly 10 GB per MB at 0.5-1.5 MB, growing with size), so fewer compiles are admitted together. This would not help a program that alone needs more than the machine has. 2. **Killable compiles**: run large driver compiles in a helper process, either the compile host or a second one. It would create the pipeline on its own device and return `GetCachedBlob`, which the loader loads with `CachedPSO` and stores in its library. A compile past a memory or time limit is killed, and its pipeline stays a stand-in (its draws skipped, as for a failed one). The failure is recorded in the cache, so later boots do not retry it. 3. **Smaller programs for big compute shaders**: a split or a different emission for the few programs over a few MB. That is the real cure, but it is a translator change. I can send the measurements' scripts, or work on 1 or 2 if one of them fits where the compile budget is going.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:13:59 +00:00
Author
Owner

@⁠Sr-0w on GitHub · 2026-11-25 07:23 UTC · original

Thanks for 671b8bc and aca5a03. On 72b7328, the RX 7800 XT gets further: the story load and the opening credits, at about 30 fps. Two things measured since then:

1. With the commit charge at its limit, amdxc64 dereferences null instead of failing the compile. Three boots ended Fatal error. 0xC0000005 at DesktopDevice.CreatePipelineState. A createdump minidump (DOTNET_DbgEnableMiniDump=1) puts it in the driver's compiler:

ExceptionAddress: amdxc64!...+0x70978 (amdxc64.dll 32.0.32029.2010)
ExceptionCode: c0000005 (Access violation), attempt to read from address 0000000000000000
 ... amdxc64 x27 ... D3D12Core!...CREATE_PIPELINE_STATE_0010 ... "fivestar pipeline build"

Each time the commit charge was at the limit just before:

Boot Last sample before the crash Compiles in flight
A 213 s: commit 68.3 of 68.9 GB, 47 GB private PS_PropFoliageDeferredTo_GBuffer + MSNC_VS_PropFoliageSkinDeferred (2 MB), MS_VS_CascadeShadows_drawskinned
B 370 s: commit 70.1 of 70.9 GB PS_PropFoliageDeferredTo_GBuffer + MS_VS_PropFoliageDeferred (2 MB, 180 s in)
C 183 s: commit 52.8 of 67.9 GB 5, two of them ped_standard_lod*~CS_RaytracingResolve (8.8 and 14.8 GB each in isolation)

Alone, with fivestar shader pso --jobs 1, the two RaytracingResolve programs are accepted: 47 s at 8.8 GB, and 78 s at 14.8 GB.

The first crash already had a second build thread inside the same amdxc64 functions, so a race is possible too. But the commit charge points to an allocation failure the compiler does not check.

2. The quadratic estimate is low for the 1.3-2.2 MB mesh pipelines. These are the in-game [budget] lines from today's boots (79 compiles). The peaks are the process's growth, so concurrent compiles add noise:

DXIL Compiles Estimate (avg) Peak (avg / max) Time (avg)
0.25-0.5 MB 27 1.6 GB 1.2 / 5.6 GB 3 s
0.5-0.75 MB 8 3.3 GB 1.2 / 3.5 GB 6 s
0.75-1.0 MB 14 5.4 GB 0.4 / 4.8 GB 2 s
1.25-1.5 MB 5 9.9 GB 11.2 / 28.8 GB 27 s
1.5-1.75 MB 10 11.3 GB 19.1 / 37.5 GB 52 s
1.75-2.0 MB 7 14.5 GB 20.6 / 37.5 GB 70 s
2.0-2.25 MB 2 16.9 GB 23.2 / 23.6 GB 135 s

Below 1 MB the estimate covers the peaks. Above about 1.25 MB the mesh+pixel pipelines (PropFoliage*, OctaSLOD*, TexturedDeferredAlphaClipNC + MS_VS_TransformSkinD) go past it. On a 64 GB machine with a system-managed page file, the commit limit is then reached.

These slow, large compiles also cap the world's progress. With the cutscene's ~3,000 pipelines queued, a boot builds 13 to 100 of them. So the in-engine cutscene between the load and the credits stays black, and its draws are skipped as stand-ins.

Given (1), a compile in its own process (point 2 of the first post) would turn this crash into a failed compile. I can take that on if it fits your plans.

**@⁠Sr-0w** on GitHub · 2026-11-25 07:23 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/issues/19#issuecomment-7155813052) Thanks for 671b8bc and aca5a03. On 72b7328, the RX 7800 XT gets further: the story load and the opening credits, at about 30 fps. Two things measured since then: **1. With the commit charge at its limit, amdxc64 dereferences null instead of failing the compile.** Three boots ended `Fatal error. 0xC0000005 at DesktopDevice.CreatePipelineState`. A createdump minidump (`DOTNET_DbgEnableMiniDump=1`) puts it in the driver's compiler: ``` ExceptionAddress: amdxc64!...+0x70978 (amdxc64.dll 32.0.32029.2010) ExceptionCode: c0000005 (Access violation), attempt to read from address 0000000000000000 ... amdxc64 x27 ... D3D12Core!...CREATE_PIPELINE_STATE_0010 ... "fivestar pipeline build" ``` Each time the commit charge was at the limit just before: | Boot | Last sample before the crash | Compiles in flight | |---|---|---| | A | 213 s: commit 68.3 of 68.9 GB, 47 GB private | `PS_PropFoliageDeferredTo_GBuffer` + `MSNC_VS_PropFoliageSkinDeferred` (2 MB), `MS_VS_CascadeShadows_drawskinned` | | B | 370 s: commit 70.1 of 70.9 GB | `PS_PropFoliageDeferredTo_GBuffer` + `MS_VS_PropFoliageDeferred` (2 MB, 180 s in) | | C | 183 s: commit 52.8 of 67.9 GB | 5, two of them `ped_standard_lod*~CS_RaytracingResolve` (8.8 and 14.8 GB each in isolation) | Alone, with `fivestar shader pso --jobs 1`, the two RaytracingResolve programs are accepted: 47 s at 8.8 GB, and 78 s at 14.8 GB. The first crash already had a second build thread inside the same amdxc64 functions, so a race is possible too. But the commit charge points to an allocation failure the compiler does not check. **2. The quadratic estimate is low for the 1.3-2.2 MB mesh pipelines.** These are the in-game `[budget]` lines from today's boots (79 compiles). The peaks are the process's growth, so concurrent compiles add noise: | DXIL | Compiles | Estimate (avg) | Peak (avg / max) | Time (avg) | |---|---|---|---|---| | 0.25-0.5 MB | 27 | 1.6 GB | 1.2 / 5.6 GB | 3 s | | 0.5-0.75 MB | 8 | 3.3 GB | 1.2 / 3.5 GB | 6 s | | 0.75-1.0 MB | 14 | 5.4 GB | 0.4 / 4.8 GB | 2 s | | 1.25-1.5 MB | 5 | 9.9 GB | 11.2 / 28.8 GB | 27 s | | 1.5-1.75 MB | 10 | 11.3 GB | 19.1 / 37.5 GB | 52 s | | 1.75-2.0 MB | 7 | 14.5 GB | 20.6 / 37.5 GB | 70 s | | 2.0-2.25 MB | 2 | 16.9 GB | 23.2 / 23.6 GB | 135 s | Below 1 MB the estimate covers the peaks. Above about 1.25 MB the mesh+pixel pipelines (`PropFoliage*`, `OctaSLOD*`, `TexturedDeferredAlphaClipNC` + `MS_VS_TransformSkinD`) go past it. On a 64 GB machine with a system-managed page file, the commit limit is then reached. These slow, large compiles also cap the world's progress. With the cutscene's ~3,000 pipelines queued, a boot builds 13 to 100 of them. So the in-engine cutscene between the load and the credits stays black, and its draws are skipped as stand-ins. Given (1), a compile in its own process (point 2 of the first post) would turn this crash into a failed compile. I can take that on if it fits your plans.
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-25 08:10 UTC · original

main now has --host-pipelines (off by default for now): compiles over 2 MB run in a separate copy of the loader with a memory and time limit, and if amdxc64 crashes or runs out of memory in there, the pipeline just stays a stand-in instead of taking the game down. once a host has built one, the driver's disk cache lets the loader create it in under a second (checked on NVIDIA, not on AMD yet). we also raised the AMD estimate above 1 MB from your table. if you get a chance, a run with --host-pipelines on the 7800 XT would tell us whether AMD's cache carries over the same way

**@⁠ThatRecompDev** on GitHub · 2026-11-25 08:10 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/issues/19#issuecomment-7156704659) main now has `--host-pipelines` (off by default for now): compiles over 2 MB run in a separate copy of the loader with a memory and time limit, and if amdxc64 crashes or runs out of memory in there, the pipeline just stays a stand-in instead of taking the game down. once a host has built one, the driver's disk cache lets the loader create it in under a second (checked on NVIDIA, not on AMD yet). we also raised the AMD estimate above 1 MB from your table. if you get a chance, a run with `--host-pipelines` on the 7800 XT would tell us whether AMD's cache carries over the same way
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-25 11:42 UTC · original

quick update since your 7800 XT numbers. a lot of the AMD cost is gone thanks to your PRs: the simplifier (#24), lane masks staying bools (#26, ActivateProbes went from 11k ballots to 925 in the DXIL) and the readfirstlane crash fix (#27). the 4 CompileBudgetTests that failed on your machine were our bug too (a device created in another test left the vendor set to AMD), fixed on main in 376adc4.

when you get a chance, could you check whether CS_ScreenProbes_ActivateProbes builds on the 7800 XT now, and roughly what it costs? that's the one that couldn't be built on 64 GB, so it tells us whether this issue can close

**@⁠ThatRecompDev** on GitHub · 2026-11-25 11:42 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/issues/19#issuecomment-7161402590) quick update since your 7800 XT numbers. a lot of the AMD cost is gone thanks to your PRs: the simplifier (#24), lane masks staying bools (#26, ActivateProbes went from 11k ballots to 925 in the DXIL) and the readfirstlane crash fix (#27). the 4 CompileBudgetTests that failed on your machine were our bug too (a device created in another test left the vendor set to AMD), fixed on main in 376adc4. when you get a chance, could you check whether CS_ScreenProbes_ActivateProbes builds on the 7800 XT now, and roughly what it costs? that's the one that couldn't be built on 64 GB, so it tells us whether this issue can close
Author
Owner

@⁠Sr-0w on GitHub · 2026-11-25 16:01 UTC · original · edited 2026-11-25 16:37 UTC

CS_ScreenProbes_ActivateProbes on the RX 7800 XT, current backend: it still can't be built.

Setup: 64 GB, Adrenalin 32.0.32029.2010. fivestar shader pso with --jobs 1, --max-memory 48, --timeout 900, outside the game. The DXIL comes from the DXIL backend (--backend dxil-only).

DXIL instructions blocks phis waveAnyTrue waveActiveBallot driver compile
before #33 (main 77187ce) 7.4 MB, 1,256,697 33,599 44,498 9,920 925 over 48 GB private at 277 s
with #33 4.9 MB, 735,530 about the same CFG over 48 GB private at 279 s

So #24, #26 and #33 shrank the DXIL a lot (#33 removed 41% of the instructions), but the driver's peak doesn't move. The memory doesn't seem to follow the instruction count. It seems to follow the control flow: about 33k blocks, nested up to 28 levels deep. Each guarded VOP or memory group of the console program becomes an if (vw_any(active)), and the source has 122k dwords. That points at the driver's structurizer or uniformity analysis rather than instruction selection.

What I'll try next, and post here:

  • Fold successive if (vw_any(active)) blocks with the same mask into one region, and turn plain select-only bodies into straight-line code, so the block count drops without changing semantics.
  • Measure peak driver memory against block count and nesting depth on a few mid-size programs, to confirm the driver memory follows the CFG and not the size.
**@⁠Sr-0w** on GitHub · 2026-11-25 16:01 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/issues/19#issuecomment-7167525100) · edited 2026-11-25 16:37 UTC **`CS_ScreenProbes_ActivateProbes` on the RX 7800 XT, current backend: it still can't be built.** Setup: 64 GB, Adrenalin 32.0.32029.2010. `fivestar shader pso` with `--jobs 1`, `--max-memory 48`, `--timeout 900`, outside the game. The DXIL comes from the DXIL backend (`--backend dxil-only`). | DXIL | instructions | blocks | phis | `waveAnyTrue` | `waveActiveBallot` | driver compile | |---|---|---|---|---|---|---| | before #33 (main 77187ce) | 7.4 MB, 1,256,697 | 33,599 | 44,498 | 9,920 | 925 | over 48 GB private at 277 s | | with #33 | 4.9 MB, 735,530 | about the same CFG | | | | over 48 GB private at 279 s | So #24, #26 and #33 shrank the DXIL a lot (#33 removed 41% of the instructions), but the driver's peak doesn't move. The memory doesn't seem to follow the instruction count. It seems to follow the control flow: about 33k blocks, nested up to 28 levels deep. Each guarded VOP or memory group of the console program becomes an `if (vw_any(active))`, and the source has 122k dwords. That points at the driver's structurizer or uniformity analysis rather than instruction selection. What I'll try next, and post here: - Fold successive `if (vw_any(active))` blocks with the same mask into one region, and turn plain select-only bodies into straight-line code, so the block count drops without changing semantics. - Measure peak driver memory against block count and nesting depth on a few mid-size programs, to confirm the driver memory follows the CFG and not the size.
Author
Owner

@⁠ThatRecompDev on GitHub · 2026-11-25 16:43 UTC · original

great measurements, the CFG theory fits what we see on NVIDIA too. folding same-mask regions sounds right. one thing from our side: our --fast-waves experiment found some any-lane branches can't be folded safely when the paths have different barrier counts, so keep an eye on barriers inside those regions. looking forward to the numbers

**@⁠ThatRecompDev** on GitHub · 2026-11-25 16:43 UTC · [original](https://github.com/ThatRecompDev/five-star-recomp/issues/19#issuecomment-7168446147) great measurements, the CFG theory fits what we see on NVIDIA too. folding same-mask regions sounds right. one thing from our side: our --fast-waves experiment found some any-lane branches can't be folded safely when the paths have different barrier counts, so keep an eye on barriers inside those regions. looking forward to the numbers
This discussion has been locked. Commenting is limited to contributors.
No description provided.