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

Open
github-bot wants to merge 2 commits from github-bot/gh-2 into beta AGit
Owner

@⁠BrokeAsh on GitHub · 2026-11-25 14:27 UTC · original
BrokeAsh:rdna4-self-sized-loads → beta · +262 −8 · 5 files · 2 commits · open

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

**@⁠BrokeAsh** on GitHub · 2026-11-25 14:27 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2) `BrokeAsh:rdna4-self-sized-loads` → `beta` · +262 −8 · 5 files · 2 commits · open 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)
The RX 9070 XT's shader compiler (amdxc64.dll 32.0.32029.2010) kills the
process with a null read at amdxc64.dll+0x861b9f on four of the title's
compute shaders: 878933b499cfa14d, a567b9ef845fb680, f16876929fa64f9f and
c1eee35dbc50a9ef (with VICTORY_SHADER_OPT=0, the last two; they are the
pipelines the pre-build lists in prebuild-crashed.txt on that card). The
DXIL passes dxil.dll's validator and the D3D12 debug layer, and the same
DXIL compiles on an RDNA 2 adapter's older AMD compiler: a driver bug.

Reduced, the trigger is a scalar buffer load at an offset computed from
that same buffer's record count (dword 2 of its descriptor): the console's
"last record" idiom, buf[(size / stride - 1) * stride]. The offset taken
from a constant buffer, or the load through another view, compiles; no
form of the size (WaveReadLaneFirst, WaveActiveMax, a clamp, a second
handle of the same index) does.

- 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-reading loads already take), 0
  past the view's end as the console's load reads (getDimensions on the
  view). Where the view's address is not known, it reads through the view
  as before. The default translation is unchanged: 322 of the title's
  25,652 programs have such a load and compile as they are.
- shader_cache::host_shader_with: a translation with other options is
  cached apart from the default one.
- pipeline.rs: the four shaders are translated in the other form (built-in
  list, as VICTORY_SKIP_PIPELINES has one); VICTORY_OTHER_FORM names the
  shaders instead (16-digit hashes, comma-separated; 0: none).

Tested on an RX 9070 XT (Adrenalin 32.0.32029.2010), in a separate process
per shader: each of the four crashes the compiler at amdxc64.dll+0x861b9f
in the default form (the two above with VICTORY_SHADER_OPT=0) and makes
its compute pipeline in the other form, with and without
VICTORY_SHADER_OPT=0. cargo test -p victory-shader -p victory-gpu passes;
clippy -D warnings is clean on both crates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- pipeline.rs: the built-in list of shaders translated in the other form
  applies only on an AMD RDNA 4 card (vendor 0x1002; Navi 48 0x7550,
  0x7551; Navi 44 0x7590), whose compiler crashes on their default form.
  Other cards compile the default form and keep it: the other form reads
  title memory, where a page without a copy reads 0. VICTORY_OTHER_FORM
  still names the shaders on any card.
- host.rs: Host::adapter_ids, the adapter's PCI vendor and device IDs.
- lower.rs: a self-sized load's dword is inside the view when
  `a < size && size - a >= 4`. `a + 4 <= size` wrapped for an offset just
  under 4 GiB (the last record of an empty buffer: (0 / 80 - 1) * 80 + 76)
  and read 4 GiB past the view instead of 0. Only a dword inside notes a
  missing page for the host (the guard of `memory`).
- mod.rs: translate_with puts the thread's options back with a drop
  guard, so a panicking translation cannot leave them set for the
  thread's next (default, cached as default) translation.

Tested on an RX 9070 XT (32.0.32029.2010), one process per shader: the
four shaders' other form passes dxil.dll's validator and makes its compute
pipeline, with and without VICTORY_SHADER_OPT=0. cargo test -p
victory-shader -p victory-gpu passes (154 + 224).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:50:23 +00:00
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 14:31 UTC · original

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.

**@⁠PastiiJay** on GitHub · 2026-11-25 14:31 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7165409148) 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.
Author
Owner

@⁠BrokeAsh on GitHub · 2026-11-25 16:58 UTC · original

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

**@⁠BrokeAsh** on GitHub · 2026-11-25 16:58 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7168823171) Rebased onto `beta` so it drops straight into the Lab 43 test build. Happy to retarget to `main` once it holds
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 17:02 UTC · original

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

**@⁠PastiiJay** on GitHub · 2026-11-25 17:02 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7168918589) Thanks @⁠BrokeAsh, perfect. It goes into the next beta test build on the RX 9070 XT (pre-build + world run), results here.
Author
Owner

@⁠BrokeAsh on GitHub · 2026-11-25 17:09 UTC · original

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.

**@⁠BrokeAsh** on GitHub · 2026-11-25 17:09 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7169094050) 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.
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 17:39 UTC · original

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.

**@⁠PastiiJay** on GitHub · 2026-11-25 17:39 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7169806919) 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.
Author
Owner

@⁠KingKaom on GitHub · 2026-11-25 20:30 UTC · original

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)

**@⁠KingKaom** on GitHub · 2026-11-25 20:30 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7173779782) 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)
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-25 20:35 UTC · original

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.

**@⁠PastiiJay** on GitHub · 2026-11-25 20:35 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/2#issuecomment-7173891913) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2/head:github-bot/gh-2'
git switch 'github-bot/gh-2'

Merge

Merge the changes and update on Forgejo.
git switch 'beta'
git merge --no-ff 'github-bot/gh-2'
git switch 'github-bot/gh-2'
git rebase 'beta'
git switch 'beta'
git merge --ff-only 'github-bot/gh-2'
git switch 'github-bot/gh-2'
git rebase 'beta'
git switch 'beta'
git merge --no-ff 'github-bot/gh-2'
git switch 'beta'
git merge --squash 'github-bot/gh-2'
git switch 'beta'
git merge --ff-only 'github-bot/gh-2'
git switch 'beta'
git merge 'github-bot/gh-2'
git push origin 'beta'
This discussion has been locked. Commenting is limited to contributors.
No description provided.