Shaders: no REUSE pass for compute programs (AMD compiler crash, #145) #195

Open
github-bot wants to merge 1 commit from github-bot/gh-195 into main AGit
Owner

@⁠icecreammule277-dot on GitHub · 2026-11-24 22:25 UTC · original
icecreammule277-dot:reuse-compute → main · +10 −1 · 1 files · 1 commits · open

Fixes most of #145 (and the same crash reported in #3 and #120): amdxc64.dll+0x861b9f (read 0x8) in CreateComputePipelineState on an RX 9070 XT.

Change

Shader::finish no longer runs the REUSE clean-up pass (bitcode::opt::REUSE) on compute programs. VICTORY_REUSE_ALL=1 keeps it, for comparing.

How it was found

The containers of the compute programs a run refused were saved and each was replayed offline with victory translate <container> --pipelines, one process per program (a compiler crash then only ends that process):

VICTORY_SHADER_OPT made crashed
unset (every pass) 104 of 113 9
0 9 of 9 crashers 0
4 (REUSE only) 0 of 9 9
59 (every pass but REUSE) 183 of 183 0

This agrees with the sweep in #145 (68 of 70 crashers build with VICTORY_SHADER_OPT=11).

A first version that dropped REUSE only for compute programs with seven or more immediate samplers (the ray-traced lighting resolves) still crashed in game, on 842de0c32bc8dcc5, which has three; hence every compute program.

Result in game

RX 9070 XT, Adrenalin 32.0.32029.2010, Windows 11: with this change and no compute pipeline refused or skipped for the crash, the compute pipelines build and the opening cutscene draws a lit 3D scene; before, the lighting resolves had to be refused and the world stayed black.

Not fixed

c1eee35dbc50a9ef and f16876929fa64f9f crash with any VICTORY_SHADER_OPT, including 0 (#145), so they have another cause; they still need VICTORY_SKIP_PIPELINES.

Notes

  • The cost is repeated instructions left in compute programs. A narrower fix would bound how far REUSE replaces a value (the crashers carry a couple of hundred values live across 200+ blocks after REUSE, one phi merged across ~1,600 blocks), but that needs more work than this stopgap.
  • cargo test -p victory-shader --lib passes.

🤖 Generated with Claude Code

**@⁠icecreammule277-dot** on GitHub · 2026-11-24 22:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/195) `icecreammule277-dot:reuse-compute` → `main` · +10 −1 · 1 files · 1 commits · open Fixes most of #145 (and the same crash reported in #3 and #120): `amdxc64.dll+0x861b9f` (read 0x8) in `CreateComputePipelineState` on an RX 9070 XT. ## Change `Shader::finish` no longer runs the REUSE clean-up pass (`bitcode::opt::REUSE`) on compute programs. `VICTORY_REUSE_ALL=1` keeps it, for comparing. ## How it was found The containers of the compute programs a run refused were saved and each was replayed offline with `victory translate <container> --pipelines`, one process per program (a compiler crash then only ends that process): | `VICTORY_SHADER_OPT` | made | crashed | |---|---|---| | unset (every pass) | 104 of 113 | 9 | | 0 | 9 of 9 crashers | 0 | | 4 (REUSE only) | 0 of 9 | 9 | | 59 (every pass but REUSE) | 183 of 183 | 0 | This agrees with the sweep in #145 (68 of 70 crashers build with `VICTORY_SHADER_OPT=11`). A first version that dropped REUSE only for compute programs with seven or more immediate samplers (the ray-traced lighting resolves) still crashed in game, on `842de0c32bc8dcc5`, which has three; hence every compute program. ## Result in game RX 9070 XT, Adrenalin 32.0.32029.2010, Windows 11: with this change and no compute pipeline refused or skipped for the crash, the compute pipelines build and the opening cutscene draws a lit 3D scene; before, the lighting resolves had to be refused and the world stayed black. ## Not fixed `c1eee35dbc50a9ef` and `f16876929fa64f9f` crash with any `VICTORY_SHADER_OPT`, including 0 (#145), so they have another cause; they still need `VICTORY_SKIP_PIPELINES`. ## Notes - The cost is repeated instructions left in compute programs. A narrower fix would bound how far REUSE replaces a value (the crashers carry a couple of hundred values live across 200+ blocks after REUSE, one phi merged across ~1,600 blocks), but that needs more work than this stopgap. - `cargo test -p victory-shader --lib` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
amdxc64.dll (RX 9070 XT, Adrenalin 32.0.32029.2010) crashes at +0x861b9f in
CreateComputePipelineState on some compute programs after the REUSE clean-up
pass. Replayed offline, one process per program: with every pass 9 of 113
refused compute programs crash; REUSE alone crashes all 9; every pass but
REUSE builds all 183. The crashers are not only the seven- and eight-sampler
ray-traced lighting resolves: 842de0c32bc8dcc5 has three samplers.

With this, the title's compute pipelines build in game and the world draws lit.
c1eee35dbc50a9ef and f16876929fa64f9f still crash with any passes (#145):
another cause.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGeqyC9iSYLKw2tsLn1HzB
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:59 +00:00
Author
Owner

@⁠ericomeehan on GitHub · 2026-11-24 23:21 UTC · original

The offline replay table (REUSE alone 9/9 crashes, every other pass 183/183 builds) makes the case very clearly, and the shortcut: comment says exactly why.

One small thing: VICTORY_REUSE_ALL changes the translation, but it isn't in the shader-cache key's list of switches in crates/victory-gpu/src/shader_cache.rs (next to VICTORY_WAVE_WIDE, VICTORY_F16_NEAREST and the others). So a run with it set can be served translations cached without it, and the other way round. Adding the name to that list would fix it. Also, since the check is var_os(...).is_none(), VICTORY_REUSE_ALL=0 turns REUSE back on too; comparing with "1" would match how the other switches read.

Separately, the pass is now skipped for compute on every vendor. If REUSE's effect on NVIDIA turns out to matter, gating on AMD's vendor id could be a follow-up.

Written with an AI assistant (Claude).

**@⁠ericomeehan** on GitHub · 2026-11-24 23:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/195#issuecomment-7147317025) The offline replay table (REUSE alone 9/9 crashes, every other pass 183/183 builds) makes the case very clearly, and the `shortcut:` comment says exactly why. One small thing: `VICTORY_REUSE_ALL` changes the translation, but it isn't in the shader-cache key's list of switches in `crates/victory-gpu/src/shader_cache.rs` (next to `VICTORY_WAVE_WIDE`, `VICTORY_F16_NEAREST` and the others). So a run with it set can be served translations cached without it, and the other way round. Adding the name to that list would fix it. Also, since the check is `var_os(...).is_none()`, `VICTORY_REUSE_ALL=0` turns REUSE back on too; comparing with `"1"` would match how the other switches read. Separately, the pass is now skipped for compute on every vendor. If REUSE's effect on NVIDIA turns out to matter, gating on AMD's vendor id could be a follow-up. Written with an AI assistant (Claude).
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 10:59 UTC · original

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head 90d2def into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them); with --all-features it fails with the same number of errors as main (4). This PR adds none and removes none. cargo test --workspace --locked: both runs had one failure and no other. The failure is indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which fails on main itself most runs here (PR #849 fixes its assertion; see issue #850). So I cannot tell you whether the rest passes in a full run; the crate's other 158 tests passed in both. The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 10:59 UTC · [original](https://github.com/fxceless/victory-fork/pull/195#issuecomment-7160436869) Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `90d2def` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings` fails with exactly the errors `main` itself has on this machine (`placed_filler_twins`, `depth_written`, a sort; PR #841 fixes them); with `--all-features` it fails with the same number of errors as `main` (4). This PR adds none and removes none. `cargo test --workspace --locked`: both runs had one failure and no other. The failure is `indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, which fails on `main` itself most runs here (PR #849 fixes its assertion; see issue #850). So I cannot tell you whether the rest passes in a full run; the crate's other 158 tests passed in both. The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
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/195/head:github-bot/gh-195'
git switch 'github-bot/gh-195'

Merge

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