Shaders: one index clamp per heap handle (AMD's DXIL compiler crashes on shared ones); tools for driver compiler faults #984

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

@⁠Lynkes on GitHub · 2026-11-25 15:09 UTC · original
Lynkes:amd-compiler-clamps → main · +195 −6 · 9 files · 2 commits · open

On an RX 9070 XT, AMD's DXIL compiler crashes the process while building some translated compute pipelines. Most of it comes from the clean-up pass REUSE; this PR fixes that part and adds the tools that found it.

What happens

amdxc64.dll reads a null pointer inside CreateComputePipelineState (+0x85ffbf on driver 32.0.32015.16001, +0x861b9f on 32.0.32029.2010, the same registers) and the process ends. A game run hits it about 70 s in, while the world loads. victory translate --pipelines over shaders.rpf reproduces it without the title: 70 of the pack's programs crash the compiler, namely 66 ped-material CS_RaytracingResolve, three bvh_skinning tree-animation programs and CS_UpdateSkinnedAttachMeshTreeParticles. Microsoft's validator accepts all of them. It does not happen on NVIDIA.

Cause (68 of the 70)

heap_handle clamps every view index (UMin(index, null_slot), tagged Tag::Clamp). The record-count query reads a structured buffer's descriptor through a StructuredBuffer view (getDimensions, lower.rs, Fields::Buffer → (12 | u, stride)), while the reads of the same buffer go through a ByteAddressBuffer view. Each handle has its own clamp until REUSE merges them. The two handles then share one index value, and that is what AMD's compiler crashes on.

To find it, I let REUSE make only its first N merges on CSComputeTreeAnim, with pass 4 alone. 239 merges compile and the 240th crashes. Merge 240 is a clamp, and the DXIL then differs only in that the raw view and the 80-byte structured view of one slot take the same clamped index. With VICTORY_SHADER_OPT=0, 68 of the 70 compile.

The fix (first commit)

  • REUSE leaves clamp-tagged instructions alone, so there is one clamp per handle, as the lowering makes them.
  • Module::tag records Tag::Clamp always. Tags were kept only while the census runs, so the clean-up could not see them.

On the RX 9070 XT, 68 of the 70 now build. With the other two skipped, translate --pipelines builds every program in the pack.

Still open: two programs

bvh_skinning:CSComputeSkinningTreeAnimVelocity and GpuParticleUpdate:CS_UpdateSkinnedAttachMeshTreeParticles crash even with every clean-up pass off. No translator switch helps: I tried VIEW_LIMIT=0, GROUP_SYNC 0 and 1, FIRST_HALF=0, WAVE_LOCAL/WAVE_OWN_BITS/WAVE_DEEP_SKIPS=0, HOST_WAVE=32, a loop limit, F16_NEAREST=1 and FIRSTLANE_OWN=1.

I also tried asking for record counts through a raw view, dividing the bytes by the stride as the code already does for raw views. That keeps one kind of view per slot, but it made two more tree programs crash, so it is not in this PR. Until these two are understood they can be skipped with the switch below; they only drive tree animation for the ray-tracing structures and the particles attached to trees.

Diagnostics (second commit)

  • Crash reports print the faulting thread's id and the notes that other crates register with victory_loader::note_on_crash. A note runs on the faulting thread and never blocks. victory-gpu adds the pipeline library call running on that thread, with its shaders, and translate --pipelines adds the program it was building. A fault inside a driver's compiler then names its shader.
  • VICTORY_NO_HOST_PIPELINE=<shader hash>,... gives no host pipeline to a pipeline that contains one of these shaders. Its draws and dispatches are left out, the same as for a shader that does not translate.
  • VICTORY_TRANSLATE_SKIP=<hash prefix>,..., VICTORY_TRANSLATE_SKIP_FILE and VICTORY_TRANSLATE_DONE_FILE let a translate --pipelines run that a driver ended go on where it stopped, with the faulting container skipped. A whole pass over the pack takes about 7 to 12 minutes here.

To reproduce on AMD (the test host does not ask the device for its wave width):

VICTORY_HOST_WAVE=64 VICTORY_VIEW_LIMIT=2097151 victory translate <shaders.rpf> --pipelines --jobs 14

Validation

  • cargo test -p victory-shader: 215 passed, 3 ignored.
  • cargo test --workspace --locked: 566 passed, 0 failed, 12 ignored (23 suites).
  • cargo clippy --workspace --all-targets --locked, with and without --all-features: no findings in the changed lines. With -D warnings it stops on the four existing victory-gpu warnings that #982 fixes.
  • victory translate --pipelines over the whole pack on the RX 9070 XT (driver 32.0.32029.2010): clean with the two programs above skipped.
  • A game run on this branch reached the world and the prologue's first gameplay scene, with no driver crash; 35 of the 70 programs were built in it (see the comment below).
  • Not tested on NVIDIA (no card here). The change is exact, but it changes translations, so the shader cache key changes.
**@⁠Lynkes** on GitHub · 2026-11-25 15:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/984) `Lynkes:amd-compiler-clamps` → `main` · +195 −6 · 9 files · 2 commits · open On an RX 9070 XT, AMD's DXIL compiler crashes the process while building some translated compute pipelines. Most of it comes from the clean-up pass `REUSE`; this PR fixes that part and adds the tools that found it. ## What happens `amdxc64.dll` reads a null pointer inside `CreateComputePipelineState` (`+0x85ffbf` on driver 32.0.32015.16001, `+0x861b9f` on 32.0.32029.2010, the same registers) and the process ends. A game run hits it about 70 s in, while the world loads. `victory translate --pipelines` over `shaders.rpf` reproduces it without the title: 70 of the pack's programs crash the compiler, namely 66 ped-material `CS_RaytracingResolve`, three `bvh_skinning` tree-animation programs and `CS_UpdateSkinnedAttachMeshTreeParticles`. Microsoft's validator accepts all of them. It does not happen on NVIDIA. ## Cause (68 of the 70) `heap_handle` clamps every view index (`UMin(index, null_slot)`, tagged `Tag::Clamp`). The record-count query reads a structured buffer's descriptor through a `StructuredBuffer` view (`getDimensions`, `lower.rs`, `Fields::Buffer` → `(12 | u, stride)`), while the reads of the same buffer go through a `ByteAddressBuffer` view. Each handle has its own clamp until `REUSE` merges them. The two handles then share one index value, and that is what AMD's compiler crashes on. To find it, I let `REUSE` make only its first N merges on `CSComputeTreeAnim`, with pass 4 alone. 239 merges compile and the 240th crashes. Merge 240 is a clamp, and the DXIL then differs only in that the raw view and the 80-byte structured view of one slot take the same clamped index. With `VICTORY_SHADER_OPT=0`, 68 of the 70 compile. ## The fix (first commit) - `REUSE` leaves clamp-tagged instructions alone, so there is one clamp per handle, as the lowering makes them. - `Module::tag` records `Tag::Clamp` always. Tags were kept only while the census runs, so the clean-up could not see them. On the RX 9070 XT, 68 of the 70 now build. With the other two skipped, `translate --pipelines` builds every program in the pack. ## Still open: two programs `bvh_skinning:CSComputeSkinningTreeAnimVelocity` and `GpuParticleUpdate:CS_UpdateSkinnedAttachMeshTreeParticles` crash even with every clean-up pass off. No translator switch helps: I tried `VIEW_LIMIT=0`, `GROUP_SYNC` 0 and 1, `FIRST_HALF=0`, `WAVE_LOCAL`/`WAVE_OWN_BITS`/`WAVE_DEEP_SKIPS=0`, `HOST_WAVE=32`, a loop limit, `F16_NEAREST=1` and `FIRSTLANE_OWN=1`. I also tried asking for record counts through a raw view, dividing the bytes by the stride as the code already does for raw views. That keeps one kind of view per slot, but it made two more tree programs crash, so it is not in this PR. Until these two are understood they can be skipped with the switch below; they only drive tree animation for the ray-tracing structures and the particles attached to trees. ## Diagnostics (second commit) - Crash reports print the faulting thread's id and the notes that other crates register with `victory_loader::note_on_crash`. A note runs on the faulting thread and never blocks. `victory-gpu` adds the pipeline library call running on that thread, with its shaders, and `translate --pipelines` adds the program it was building. A fault inside a driver's compiler then names its shader. - `VICTORY_NO_HOST_PIPELINE=<shader hash>,...` gives no host pipeline to a pipeline that contains one of these shaders. Its draws and dispatches are left out, the same as for a shader that does not translate. - `VICTORY_TRANSLATE_SKIP=<hash prefix>,...`, `VICTORY_TRANSLATE_SKIP_FILE` and `VICTORY_TRANSLATE_DONE_FILE` let a `translate --pipelines` run that a driver ended go on where it stopped, with the faulting container skipped. A whole pass over the pack takes about 7 to 12 minutes here. To reproduce on AMD (the test host does not ask the device for its wave width): ``` VICTORY_HOST_WAVE=64 VICTORY_VIEW_LIMIT=2097151 victory translate <shaders.rpf> --pipelines --jobs 14 ``` ## Validation - `cargo test -p victory-shader`: 215 passed, 3 ignored. - `cargo test --workspace --locked`: 566 passed, 0 failed, 12 ignored (23 suites). - `cargo clippy --workspace --all-targets --locked`, with and without `--all-features`: no findings in the changed lines. With `-D warnings` it stops on the four existing `victory-gpu` warnings that #982 fixes. - `victory translate --pipelines` over the whole pack on the RX 9070 XT (driver 32.0.32029.2010): clean with the two programs above skipped. - A game run on this branch reached the world and the prologue's first gameplay scene, with no driver crash; 35 of the 70 programs were built in it (see the comment below). - Not tested on NVIDIA (no card here). The change is exact, but it changes translations, so the shader cache key changes.
On an RX 9070 XT (drivers 32.0.32015.16001 and 32.0.32029.2010)
amdxc64.dll reads a null pointer inside CreateComputePipelineState when
two heap handles of different kinds share one index value, and the
process ends. REUSE made such pairs out of the translator's index clamps:
one descriptor read as a ByteAddressBuffer (the reads) and as a
StructuredBuffer (the record-count query through getDimensions) got its
two clamps merged into one. 68 of the pack's compute programs crashed on
it (ped materials' CS_RaytracingResolve, bvh_skinning tree animation).

- REUSE leaves clamp-tagged instructions alone: one clamp per handle, as
  the lowering makes them.
- Module::tag records Tag::Clamp always (tags were kept only while the
  census runs, so the clean-up could not see them).

Found by letting REUSE make only its first N merges on CSComputeTreeAnim:
239 merges compile, the 240th (a clamp) crashes, and the DXIL then differs
only in that index. Microsoft's validator accepts both modules.
- Crash reports print the faulting thread's id and the notes other crates
  register (victory_loader::note_on_crash; run on the faulting thread,
  never blocking): victory-gpu adds the pipeline library call running on
  that thread and its shaders, `translate --pipelines` the program it was
  building. A fault inside a driver's compiler then names its shader.
- VICTORY_NO_HOST_PIPELINE=<shader hash>,...: no host pipeline for a
  pipeline with one of these shaders (its draws and dispatches are left
  out, as for a shader that does not translate), for the ones a driver
  cannot compile. Two of the title's tree-animation compute programs still
  crash AMD's compiler with every clean-up pass off.
- VICTORY_TRANSLATE_SKIP=<hash prefix>,..., VICTORY_TRANSLATE_SKIP_FILE and
  VICTORY_TRANSLATE_DONE_FILE: a `translate --pipelines` run a driver ended
  goes on where it stopped, with the faulting container left out.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:09 +00:00
Author
Owner

@⁠Lynkes on GitHub · 2026-11-25 15:16 UTC · original

Update: a game run on this branch reached the world and the prologue's first gameplay scene. This was on the RX 9070 XT, driver 32.0.32029.2010, with the two remaining programs skipped through VICTORY_NO_HOST_PIPELINE.

  • About 13 minutes in the world, with no driver crash and no device loss.
  • 35 of the 70 programs that used to crash the compiler got host pipelines in that run, namely the ones the scene used. Before this change, the first of them ended the process about 70 s in.
  • 5 to 7 frames a second in the scene, at 1,100 to 2,300 draws a frame.
**@⁠Lynkes** on GitHub · 2026-11-25 15:16 UTC · [original](https://github.com/fxceless/victory-fork/pull/984#issuecomment-7166575050) Update: a game run on this branch reached the world and the prologue's first gameplay scene. This was on the RX 9070 XT, driver 32.0.32029.2010, with the two remaining programs skipped through `VICTORY_NO_HOST_PIPELINE`. - About 13 minutes in the world, with no driver crash and no device loss. - 35 of the 70 programs that used to crash the compiler got host pipelines in that run, namely the ones the scene used. Before this change, the first of them ended the process about 70 s in. - 5 to 7 frames a second in the scene, at 1,100 to 2,300 draws a frame.
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/984/head:github-bot/gh-984'
git switch 'github-bot/gh-984'

Merge

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