Shaders: compile the four compute shaders the RDNA 4 compiler crashes on #2

Closed
BrokeAsh wants to merge 2 commits from upstream-pr/2 into beta
BrokeAsh commented 2026-11-25 14:27:19 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by BrokeAsh on 2026-11-25T14:27:19Z.


On an RX 9070 XT (Adrenalin 32.0.32029.2010), AMD's shader compiler kills the process on four of the title's compute shaders. The crash is a null read at amdxc64.dll+0x861b9f:

  • 878933b499cfa14d
  • a567b9ef845fb680
  • f16876929fa64f9f
  • c1eee35dbc50a9ef

With VICTORY_SHADER_OPT=0 only the last two crash. Those two are the ones your pre-build puts in prebuild-crashed.txt, so a run skips their pipelines. This PR makes all four compile, so nothing needs to be skipped.

Cause

This is a driver bug:

  • The DXIL passes dxil.dll's validator and the D3D12 debug layer.
  • The same DXIL compiles on an RDNA 2 card's older AMD compiler.

I reduced the shaders to find the trigger. It's a scalar buffer load at an offset computed from that same buffer's record count (dword 2 of its descriptor). That's the console's "last record" idiom, buf[(size / stride - 1) * stride].

  • What compiles: the same offset taken from a constant buffer, or the same load through another view.
  • What still crashes: every other way of computing the size that I tried (WaveReadLaneFirst, WaveActiveMax, a clamp, a second handle of the same index).

Change

Rebased onto beta (was main), per the note that test builds go there first. The only conflict was shader_cache.rs, where build() on beta returns the key by value.

  • emit::Options { self_sized_loads_via_memory } and emit::translate_with.
    • Such a load reads the bytes at the view's title address plus the offset, through title memory (the path memory loads already use).
    • Past the view's end it reads 0, as the console's load does; the end comes from getDimensions on the view. The check is offset < size && size - offset >= 4, so it can't wrap for an offset just under 4 GiB (the last record of an empty buffer).
    • If the view's address isn't known, it reads through the view as before.
  • shader_cache::host_shader_with. A translation made with non-default options is cached separately from the default one.
  • pipeline.rs. On an AMD RDNA 4 card (PCI device 0x7550, 0x7551 or 0x7590), the four shaders are translated in the other form. They come from a built-in list, like the default for VICTORY_SKIP_PIPELINES. Every other card keeps the default form, which it compiles. VICTORY_OTHER_FORM overrides the list on any card: comma-separated 16-digit hashes, or 0 for none.

The default translation doesn't change for any other shader. 322 of the title's 25,652 programs have this kind of load, and the rest compile as they are, so only these four get the other form.

Tested

  • On an RX 9070 XT (32.0.32029.2010), using this branch's translator, one process per shader:
    • Unpatched: each of the four crashes at amdxc64.dll+0x861b9f. With VICTORY_SHADER_OPT=0, f16876929fa64f9f and c1eee35dbc50a9ef still crash.
    • This PR: each of the four makes its compute pipeline, with and without VICTORY_SHADER_OPT=0.
  • cargo test -p victory-shader -p victory-gpu: passes on beta (154 + 224).
  • cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: no warnings in the files this PR changes.
    • On beta it already fails in files this PR doesn't touch: resource.rs:2667 (placed_filler_twins unused), draw.rs:2441 (sort_unstable_by_key), indirect.rs:1574 (depth_written never read).

Not tested

I haven't run the game on this branch myself. The same fix has been in my own build since 2026-11-24: there all four shaders pre-build into 1,722 compute pipelines with none refused, and runs reach the world.

After merging

  • Pipelines that crashed before: delete prebuild-crashed.txt from the pipelines cache (or remove those keys from it) and run the pre-build again, so these pipelines get built instead of skipped.
  • Other cards: they keep the default form unless VICTORY_OTHER_FORM names the shaders. The other form reads through the title-memory copies, and a page with no copy yet reads 0 until the next frame, so it isn't always identical to reading through the view.

🤖 Generated with Claude Code

<!-- greyfinch-sync:PastiiJay/klbf-lab:issue:5493267356 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2). Originally posted by [BrokeAsh](https://github.com/BrokeAsh) on 2026-11-25T14:27:19Z. --- On an RX 9070 XT (Adrenalin 32.0.32029.2010), AMD's shader compiler kills the process on four of the title's compute shaders. The crash is a null read at `amdxc64.dll+0x861b9f`: - `878933b499cfa14d` - `a567b9ef845fb680` - `f16876929fa64f9f` - `c1eee35dbc50a9ef` With `VICTORY_SHADER_OPT=0` only the last two crash. Those two are the ones your pre-build puts in `prebuild-crashed.txt`, so a run skips their pipelines. This PR makes all four compile, so nothing needs to be skipped. ### Cause This is a driver bug: - The DXIL passes `dxil.dll`'s validator and the D3D12 debug layer. - The same DXIL compiles on an RDNA 2 card's older AMD compiler. I reduced the shaders to find the trigger. It's a scalar buffer load at an offset computed from that same buffer's record count (dword 2 of its descriptor). That's the console's "last record" idiom, `buf[(size / stride - 1) * stride]`. - **What compiles:** the same offset taken from a constant buffer, or the same load through another view. - **What still crashes:** every other way of computing the size that I tried (WaveReadLaneFirst, WaveActiveMax, a clamp, a second handle of the same index). ### Change Rebased onto `beta` (was `main`), per the note that test builds go there first. The only conflict was `shader_cache.rs`, where `build()` on `beta` returns the key by value. - **`emit::Options { self_sized_loads_via_memory }` and `emit::translate_with`.** - Such a load reads the bytes at the view's title address plus the offset, through title memory (the path memory loads already use). - Past the view's end it reads 0, as the console's load does; the end comes from `getDimensions` on the view. The check is `offset < size && size - offset >= 4`, so it can't wrap for an offset just under 4 GiB (the last record of an empty buffer). - If the view's address isn't known, it reads through the view as before. - **`shader_cache::host_shader_with`.** A translation made with non-default options is cached separately from the default one. - **`pipeline.rs`.** On an AMD RDNA 4 card (PCI device `0x7550`, `0x7551` or `0x7590`), the four shaders are translated in the other form. They come from a built-in list, like the default for `VICTORY_SKIP_PIPELINES`. Every other card keeps the default form, which it compiles. `VICTORY_OTHER_FORM` overrides the list on any card: comma-separated 16-digit hashes, or `0` for none. The default translation doesn't change for any other shader. 322 of the title's 25,652 programs have this kind of load, and the rest compile as they are, so only these four get the other form. ### Tested - **On an RX 9070 XT (32.0.32029.2010),** using this branch's translator, one process per shader: - **Unpatched:** each of the four crashes at `amdxc64.dll+0x861b9f`. With `VICTORY_SHADER_OPT=0`, `f16876929fa64f9f` and `c1eee35dbc50a9ef` still crash. - **This PR:** each of the four makes its compute pipeline, with and without `VICTORY_SHADER_OPT=0`. - **`cargo test -p victory-shader -p victory-gpu`:** passes on `beta` (154 + 224). - **`cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings`:** no warnings in the files this PR changes. - On `beta` it already fails in files this PR doesn't touch: `resource.rs:2667` (`placed_filler_twins` unused), `draw.rs:2441` (`sort_unstable_by_key`), `indirect.rs:1574` (`depth_written` never read). ### Not tested I haven't run the game on this branch myself. The same fix has been in my own build since 2026-11-24: there all four shaders pre-build into 1,722 compute pipelines with none refused, and runs reach the world. ### After merging - **Pipelines that crashed before:** delete `prebuild-crashed.txt` from the pipelines cache (or remove those keys from it) and run the pre-build again, so these pipelines get built instead of skipped. - **Other cards:** they keep the default form unless `VICTORY_OTHER_FORM` names the shaders. The other form reads through the title-memory copies, and a page with no copy yet reads 0 until the next frame, so it isn't always identical to reading through the view. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PastiiJay commented 2026-11-25 14:31:27 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-25T14:31:27Z.


Thank you @brokeash, this is great work: a reduced trigger, a narrow fix only for the four shaders, and a clean opt-out. Main is our stable build, so we'll first carry this into our next test build (Lab 43, on top of the water physics fix) and run it in game on our RX 9070 XT; if it holds, we merge it here. Will report back in this PR.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7165409148 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7165409148). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-25T14:31:27Z. --- Thank you @brokeash, this is great work: a reduced trigger, a narrow fix only for the four shaders, and a clean opt-out. Main is our stable build, so we'll first carry this into our next test build (Lab 43, on top of the water physics fix) and run it in game on our RX 9070 XT; if it holds, we merge it here. Will report back in this PR.
BrokeAsh commented 2026-11-25 16:58:57 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by BrokeAsh on 2026-11-25T16:58:57Z.


Rebased onto beta so it drops straight into the Lab 43 test build. Happy to retarget to main once it holds

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7168823171 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7168823171). Originally posted by [BrokeAsh](https://github.com/BrokeAsh) on 2026-11-25T16:58:57Z. --- Rebased onto `beta` so it drops straight into the Lab 43 test build. Happy to retarget to `main` once it holds
PastiiJay commented 2026-11-25 17:02:43 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-25T17:02:43Z.


Thanks @BrokeAsh, perfect. It goes into the next beta test build on the RX 9070 XT (pre-build + world run), results here.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7168918589 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7168918589). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-25T17:02:43Z. --- Thanks @BrokeAsh, perfect. It goes into the next beta test build on the RX 9070 XT (pre-build + world run), results here.
BrokeAsh commented 2026-11-25 17:09:37 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by BrokeAsh on 2026-11-25T17:09:37Z.


Pushed a small follow-up commit:

  • The fix now only applies on AMD RDNA 4 cards. Other cards keep the original shaders.
  • Fixed an edge case where an empty buffer could read the wrong memory instead of returning 0.

Retested on the 9070 XT and everything still compiles and passes.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7169094050 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7169094050). Originally posted by [BrokeAsh](https://github.com/BrokeAsh) on 2026-11-25T17:09:37Z. --- Pushed a small follow-up commit: - The fix now only applies on AMD RDNA 4 cards. Other cards keep the original shaders. - Fixed an edge case where an empty buffer could read the wrong memory instead of returning 0. Retested on the 9070 XT and everything still compiles and passes.
PastiiJay commented 2026-11-25 17:39:07 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-25T17:39:07Z.


Thanks @BrokeAsh! Both commits, including the RDNA 4-only gate and the empty-buffer fix, are ported onto our next test build (switch VICTORY_OTHER_FORM). It's in the RX 9070 XT test queue right now, and I'll post the results here.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7169806919 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7169806919). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-25T17:39:07Z. --- Thanks @BrokeAsh! Both commits, including the RDNA 4-only gate and the empty-buffer fix, are ported onto our next test build (switch `VICTORY_OTHER_FORM`). It's in the RX 9070 XT test queue right now, and I'll post the results here.
KingKaom commented 2026-11-25 20:30:44 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by KingKaom on 2026-11-25T20:30:44Z.


Second RX 9070 XT machine, fresh pipeline caches, measuring for the RDNA4 picture: on main at head 4c46f37 (this PR not included), an unpatched run dies in the compiler 2/2 with exactly this thread's signature — 0xc0000005 read of 0x8 at amdxc64.dll+0x861b9f, compiler-only stack frames, driver 32.0.32029.2010.

  • Run 1: died t+1m24s, ~15 s after reaching the world, mid pipeline-compile storm (763 pipelines being made).
  • Run 2: died t+16 s, before the menu. The crash spot drifts with compile timing; the signature does not change.

So on our box, unpatched main cannot hold a session at all while those four shaders get compiled during play. Happy to run the next beta build with the VICTORY_OTHER_FORM gate as a second 9070 XT data point when it lands.

🤖 AI-assisted (Hermes Agent)

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7173779782 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7173779782). Originally posted by [KingKaom](https://github.com/KingKaom) on 2026-11-25T20:30:44Z. --- Second RX 9070 XT machine, fresh pipeline caches, measuring for the RDNA4 picture: on `main` at head `4c46f37` (this PR not included), an unpatched run **dies in the compiler 2/2** with exactly this thread's signature — `0xc0000005` read of `0x8` at `amdxc64.dll+0x861b9f`, compiler-only stack frames, driver 32.0.32029.2010. - Run 1: died t+1m24s, ~15 s after reaching the world, mid pipeline-compile storm (763 pipelines being made). - Run 2: died t+16 s, before the menu. The crash spot drifts with compile timing; the signature does not change. So on our box, unpatched `main` cannot hold a session at all while those four shaders get compiled during play. Happy to run the next beta build with the `VICTORY_OTHER_FORM` gate as a second 9070 XT data point when it lands. 🤖 AI-assisted (Hermes Agent)
PastiiJay commented 2026-11-25 20:35:18 +00:00 (Migrated from github.com)

Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-25T20:35:18Z.


Thank you @KingKaom, this is decisive: a second RX 9070 XT where unpatched main dies 2/2 in amdxc64.dll+0x861b9f while those four shaders compile. We saw the very same address tonight when testing another VIctory fork on our 9070 XT. @BrokeAsh's PR is in our current test builds. Given your data, it goes into main with the next release. Your second-card run on that build will be very welcome.

<!-- greyfinch-sync:PastiiJay/klbf-lab:comment:7173891913 --> Imported from [PastiiJay/klbf-lab](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7173891913). Originally posted by [PastiiJay](https://github.com/PastiiJay) on 2026-11-25T20:35:18Z. --- Thank you @KingKaom, this is decisive: a second RX 9070 XT where unpatched main dies 2/2 in `amdxc64.dll+0x861b9f` while those four shaders compile. We saw the very same address tonight when testing another VIctory fork on our 9070 XT. @BrokeAsh's PR is in our current test builds. Given your data, it goes into main with the next release. Your second-card run on that build will be very welcome.

Pull request closed

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
PastiiJay/klbf-lab!2
No description provided.