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

Open
Lynkes wants to merge 2 commits from upstream-pr/984 into main
Lynkes commented 2026-11-25 15:09:48 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Lynkes on 2026-11-25T15:09:48Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6607593849 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/984). Originally posted by [Lynkes](https://github.com/Lynkes) on 2026-11-25T15:09:48Z. --- 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 commented 2026-11-25 16:12:50 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Lynkes on 2026-11-25T15:16:17Z.


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.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7166575050 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/984#issuecomment-7166575050). Originally posted by [Lynkes](https://github.com/Lynkes) on 2026-11-25T15:16:17Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/984:upstream-pr/984'
git switch 'upstream-pr/984'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/984'
git switch 'upstream-pr/984'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/984'
git switch 'upstream-pr/984'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/984'
git switch 'main'
git merge --squash 'upstream-pr/984'
git switch 'main'
git merge --ff-only 'upstream-pr/984'
git switch 'main'
git merge 'upstream-pr/984'
git push origin 'main'
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
fxceless/victory-fork!982
No description provided.