AMD's compiler makes the compute pipelines it crashed on: a buffer's size through a handle of its own (VICTORY_SIZE_OWN_HANDLE) #252

Closed
github-bot wants to merge 3 commits from github-bot/gh-252 into rx9070xt AGit
Owner

@⁠thejacte on GitHub · 2026-11-26 12:57 UTC · original
thejacte:shader/size-own-handle → rx9070xt · +470 −51 · 9 files · 3 commits · closed without merging

On an RX 9070 XT (driver 32.0.32029.2010) the driver's shader compiler crashes making some compute pipelines; the crash guard leaves them out, so their draws are dropped. In my logs every one of these crashes is the same: compute, the same instruction in the driver, a read at address 0x8.

Cause. The compiler crashes on any pipeline in which one raw buffer view taken from the heap is both read and asked for its size (GetDimensions). Bisected on the card with variants of emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index (which crashes the test process on this card for that reason) and with plain HLSL compiled by Microsoft's dxc, so it is the driver and not our DXIL:

One ByteAddressBuffer from ResourceDescriptorHeap RX 9070 XT
GetDimensions + Load, any index, f32 or u32, size used before or after crash
GetDimensions only, or Load only made
Load before GetDimensions made
NonUniformResourceIndex on one or both handles crash
GetDimensions on a second handle from WaveReadLaneFirst(index) made

Change (two commits):

  1. VICTORY_SIZE_OWN_HANDLE=1 (off by default; emit::size_own_handle): a buffer's size query gets a handle of its own, made from the same heap index read from the first lane, so the compiler cannot merge it with the handle the buffer is read through. Only for buffers read from a heap table, not in a waterfall loop, not in pixel shaders (a helper lane's first-lane read is undefined). The shader cache keys on it (shader_cache.rs; the translator fingerprint picks it up through build.rs).
  2. scripts/play.ps1 turns it on; -More @{VICTORY_SIZE_OWN_HANDLE='0'} turns it off.

Measured (Windows 11, RX 9070 XT, driver 32.0.32029.2010, Ryzen 7 9800X3D, 64 GB, play.ps1 -Safe):

  • victory warm --used over the 2,248 pipelines my runs drew with (warm-bad.txt emptied first): switch off, the compiler crashed on 25; on, on none. Pipelines left without a host pipeline: 40 either way.
  • In game, the same place of the same save, a few minutes each:
Run Switch Compiler crashes Left out (warm-bad.txt) Median fps in the world Draws dropped for want of a pipeline
1 on 0 0 18.3 9.2 % (driver cache still cold)
5 on 0 0 16.1 2.0 %
2 off 35 0 (still making pipelines all run) —
3 on 0 35 (listed by run 2) 15.2 4.3 %
4 off 3 35 16.2 3.5 %

All 35 compute shaders the compiler crashed on in run 2 were made in run 5. No errors and no device loss in any run. The frame rate is about the same: this brings the effects back, it does not make frames faster.

Checked:

  • cargo test --workspace --locked: 918 passed, 0 failed (without the one test that crashes on this card with the switch off, as before).
  • New tests: the_record_count_through_a_handle_of_its_own (the record-count programs with the switch on give the same values on the card and on WARP; it no longer crashes here) and the_size_handle_stays_apart_from_the_read (in the written DXIL, after the clean-up passes, the size and the load use two handles and the size's index comes from WaveReadLaneFirst; it fails with the switch off; needs dxc beside the validator, skipped without).
  • cargo clippy both ways: no new warnings (this branch still has the older ones the CI fix in my other pull request deals with; on top of it, -D warnings passes).
  • cargo xtask policy --staged: ok.
  • Reviewed by Codex; its two findings (helper lanes in pixel shaders, a test of the written DXIL) are in.

Whether the switch should be the code's default on AMD hosts (host_rdna) is your call; I kept the old path as the default and turned it on in play.ps1. I can also report the driver bug to AMD with the HLSL reproducer.

🤖 Generated with Claude Code

**@⁠thejacte** on GitHub · 2026-11-26 12:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/252) `thejacte:shader/size-own-handle` → `rx9070xt` · +470 −51 · 9 files · 3 commits · closed without merging On an RX 9070 XT (driver 32.0.32029.2010) the driver's shader compiler crashes making some compute pipelines; the crash guard leaves them out, so their draws are dropped. In my logs every one of these crashes is the same: compute, the same instruction in the driver, a read at address 0x8. **Cause.** The compiler crashes on any pipeline in which one raw buffer view taken from the heap is both read and asked for its size (`GetDimensions`). Bisected on the card with variants of `emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index` (which crashes the test process on this card for that reason) and with plain HLSL compiled by Microsoft's dxc, so it is the driver and not our DXIL: | One `ByteAddressBuffer` from `ResourceDescriptorHeap` | RX 9070 XT | |---|---| | `GetDimensions` + `Load`, any index, f32 or u32, size used before or after | crash | | `GetDimensions` only, or `Load` only | made | | `Load` before `GetDimensions` | made | | `NonUniformResourceIndex` on one or both handles | crash | | `GetDimensions` on a second handle from `WaveReadLaneFirst(index)` | made | **Change** (two commits): 1. `VICTORY_SIZE_OWN_HANDLE=1` (off by default; `emit::size_own_handle`): a buffer's size query gets a handle of its own, made from the same heap index read from the first lane, so the compiler cannot merge it with the handle the buffer is read through. Only for buffers read from a heap table, not in a waterfall loop, not in pixel shaders (a helper lane's first-lane read is undefined). The shader cache keys on it (`shader_cache.rs`; the translator fingerprint picks it up through build.rs). 2. `scripts/play.ps1` turns it on; `-More @{VICTORY_SIZE_OWN_HANDLE='0'}` turns it off. **Measured** (Windows 11, RX 9070 XT, driver 32.0.32029.2010, Ryzen 7 9800X3D, 64 GB, `play.ps1 -Safe`): - `victory warm --used` over the 2,248 pipelines my runs drew with (warm-bad.txt emptied first): switch off, the compiler crashed on 25; on, on none. Pipelines left without a host pipeline: 40 either way. - In game, the same place of the same save, a few minutes each: | Run | Switch | Compiler crashes | Left out (warm-bad.txt) | Median fps in the world | Draws dropped for want of a pipeline | |---|---|---|---|---|---| | 1 | on | 0 | 0 | 18.3 | 9.2 % (driver cache still cold) | | 5 | on | 0 | 0 | 16.1 | 2.0 % | | 2 | off | 35 | 0 | (still making pipelines all run) | — | | 3 | on | 0 | 35 (listed by run 2) | 15.2 | 4.3 % | | 4 | off | 3 | 35 | 16.2 | 3.5 % | All 35 compute shaders the compiler crashed on in run 2 were made in run 5. No errors and no device loss in any run. The frame rate is about the same: this brings the effects back, it does not make frames faster. **Checked:** - `cargo test --workspace --locked`: 918 passed, 0 failed (without the one test that crashes on this card with the switch off, as before). - New tests: `the_record_count_through_a_handle_of_its_own` (the record-count programs with the switch on give the same values on the card and on WARP; it no longer crashes here) and `the_size_handle_stays_apart_from_the_read` (in the written DXIL, after the clean-up passes, the size and the load use two handles and the size's index comes from `WaveReadLaneFirst`; it fails with the switch off; needs dxc beside the validator, skipped without). - `cargo clippy` both ways: no new warnings (this branch still has the older ones the CI fix in my other pull request deals with; on top of it, `-D warnings` passes). - `cargo xtask policy --staged`: ok. - Reviewed by Codex; its two findings (helper lanes in pixel shaders, a test of the written DXIL) are in. Whether the switch should be the code's default on AMD hosts (`host_rdna`) is your call; I kept the old path as the default and turned it on in play.ps1. I can also report the driver bug to AMD with the HLSL reproducer. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On an RX 9070 XT (driver 32.0.32029.2010) the driver's compiler crashes making
a pipeline in which one raw buffer view from the heap is both read and asked
for its size: whatever the order of use in the source, the index, or the type
loaded, with our DXIL and with plain HLSL compiled by dxc alike. The size asked
through a second handle, made from the same heap index read from the first
lane, is made; so is a load that comes before the size query, which a program
cannot always do. With the switch on, the size query of a buffer read from a
heap table (not in a waterfall loop, not in a pixel shader, where a helper
lane's first-lane read is undefined) gets that handle. Off by default; the
shader cache keys on it.

Of the title's pipelines the compiler had crashed on (25 of them in warm
here), none crashes with the switch on; the others are made as before.
The record-count test that crashed the test process on this card passes with
the switch on, on the card and on WARP, and a test of the written DXIL checks
that the two handles stay apart after the clean-up passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
So that AMD's compiler makes the compute pipelines it crashed on (see the
commit before). In a run here (RX 9070 XT, the same place of the same save)
the compiler crashed on 35 pipelines with it off, on none with it on, and the
draws left out for want of a pipeline went from 3.5-4.3 % to 2.0 %.
`-More @{VICTORY_SIZE_OWN_HANDLE='0'}` turns it off.

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

@⁠luisaugustz on GitHub · 2026-11-26 14:36 UTC · original

Independent confirmation on a different CPU. RX 9070 XT 16 GB, driver 32.0.32029.2010, Ryzen 7 5800X, 32 GB, Windows 11.

Applied this PR alone on rx9070xt @ 81ebb7bd, with VICTORY_SIZE_OWN_HANDLE=1 and an empty warm-bad.txt (own copy of the cache):

  • Without it (same build, old warm-bad.txt): 38 pipelines left out as "the driver's compiler crashed on it before", 32 distinct compute shaders.
  • With it: 0 compiler crashes caught, 0 keys written to warm-bad.txt, none of those 32 shaders refused. Queue went to 0 and stayed there.
  • In game, same scene (the cell, frame ~8000): 13.4 fps / 74 ms with it, 13 fps without. No change in speed, as you wrote. About 18 minutes in the world, no crash, no device loss.

Also stacked it with #235, #231 and avatarmanz 4fd34fd (exact cascade shadows on wave32) on the same base: 24 minutes, 13 fps, 0 compiler crashes, no crash. Cell frames look the same as without them. One note on #231: the "texture picked by index changed after its upload" warning still reached its 200-line cap with it applied, so I cannot show it removing those here.

Happy to run anything else on this card.

**@⁠luisaugustz** on GitHub · 2026-11-26 14:36 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/252#issuecomment-7195065580) Independent confirmation on a different CPU. RX 9070 XT 16 GB, driver 32.0.32029.2010, Ryzen 7 5800X, 32 GB, Windows 11. Applied this PR alone on rx9070xt @ 81ebb7bd, with `VICTORY_SIZE_OWN_HANDLE=1` and an empty warm-bad.txt (own copy of the cache): - Without it (same build, old warm-bad.txt): 38 pipelines left out as "the driver's compiler crashed on it before", 32 distinct compute shaders. - With it: 0 compiler crashes caught, 0 keys written to warm-bad.txt, none of those 32 shaders refused. Queue went to 0 and stayed there. - In game, same scene (the cell, frame ~8000): 13.4 fps / 74 ms with it, 13 fps without. No change in speed, as you wrote. About 18 minutes in the world, no crash, no device loss. Also stacked it with #235, #231 and avatarmanz 4fd34fd (exact cascade shadows on wave32) on the same base: 24 minutes, 13 fps, 0 compiler crashes, no crash. Cell frames look the same as without them. One note on #231: the "texture picked by index changed after its upload" warning still reached its 200-line cap with it applied, so I cannot show it removing those here. Happy to run anything else on this card.
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 16:16 UTC · original · reviewed

AI-assisted review. I inspected the changed shader-lowering path and existing size-handle tests statically; I did not run tests or a GPU/game build. This review suggests a focused regression test for the pixel-shader fallback.

**@⁠gut0to** on GitHub · 2026-11-26 16:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/252#pullrequestreview-6077405347) · **reviewed** AI-assisted review. I inspected the changed shader-lowering path and existing size-handle tests statically; I did not run tests or a GPU/game build. This review suggests a focused regression test for the pixel-shader fallback.
@ -6521,0 +6523,4 @@
// read through; with one handle for both it crashes (`size_own_handle`).
// Not in pixel shaders: a helper lane's first-lane read is undefined.
let h = if super::size_own_handle()
&& !self.s.pixel
Author
Owner

@⁠gut0to on GitHub · 2026-11-26 16:16 UTC · original

AI-assisted review; I did not run tests. Could we add a pixel-stage case with VICTORY_SIZE_OWN_HANDLE enabled that asserts this path does not emit waveReadLaneFirst for a raw-buffer size query? The explicit pixel guard protects helper lanes, where the first-lane read is undefined, but the current new tests exercise only compute translation, so a later refactor could remove this guard without failing them.

**@⁠gut0to** on GitHub · 2026-11-26 16:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/252#discussion_r4710986441) AI-assisted review; I did not run tests. Could we add a pixel-stage case with VICTORY_SIZE_OWN_HANDLE enabled that asserts this path does not emit waveReadLaneFirst for a raw-buffer size query? The explicit pixel guard protects helper lanes, where the first-lane read is undefined, but the current new tests exercise only compute translation, so a later refactor could remove this guard without failing them.
Author
Owner

@⁠LOCKhart07 on GitHub · 2026-11-26 20:40 UTC · original

Another data point on an RX 9070 XT, driver 32.0.32029.2010, Ryzen 7 7800X3D, 32 GB, Windows 11.

Before (a different VIctory fork, no compiler guard): 3 of 3 runs ended in 0xc0000005 in amdxc64.dll, read 0x8, from a pipeline worker. That was +0x85fd0f on 32.0.32015.7029, and +0x861b9f after updating to 32.0.32029.2010. Every crash came right after FFX FSR4 ACO: DeserializeComputePipelineStateX FAILED ... falling back to NewBE.

With this PR: only b148067 cherry-picked onto a-publier @ cd8dfc0 (it applied cleanly; only the play.ps1 hunk conflicted, so I set the switch in my launcher instead). Release build, VICTORY_SIZE_OWN_HANDLE=1, shaders re-translated (25,790 / 195 untranslated, as before). Two runs: Series X ~5 min and Series S ~7.5 min, the second ended by hand. 0 compiler crashes caught by the guard, no warm-bad.txt written, 0 ERROR lines.

I didn't run this fork without the switch, so I can't separate this PR's effect from the rest of rx9070xt. But the crash that ended every run before didn't happen once. Series S world: ~16 fps, 62.9 ms per frame at ~6,800 draws.

**@⁠LOCKhart07** on GitHub · 2026-11-26 20:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/252#issuecomment-7202964696) Another data point on an RX 9070 XT, driver 32.0.32029.2010, Ryzen 7 7800X3D, 32 GB, Windows 11. **Before** (a different VIctory fork, no compiler guard): 3 of 3 runs ended in `0xc0000005` in `amdxc64.dll`, read `0x8`, from a pipeline worker. That was `+0x85fd0f` on 32.0.32015.7029, and `+0x861b9f` after updating to 32.0.32029.2010. Every crash came right after `FFX FSR4 ACO: DeserializeComputePipelineStateX FAILED ... falling back to NewBE`. **With this PR:** only `b148067` cherry-picked onto `a-publier` @ `cd8dfc0` (it applied cleanly; only the `play.ps1` hunk conflicted, so I set the switch in my launcher instead). Release build, `VICTORY_SIZE_OWN_HANDLE=1`, shaders re-translated (25,790 / 195 untranslated, as before). Two runs: Series X ~5 min and Series S ~7.5 min, the second ended by hand. **0 compiler crashes caught by the guard, no `warm-bad.txt` written, 0 ERROR lines.** I didn't run this fork without the switch, so I can't separate this PR's effect from the rest of `rx9070xt`. But the crash that ended every run before didn't happen once. Series S world: ~16 fps, 62.9 ms per frame at ~6,800 draws.
github-bot closed this pull request 2026-11-26 21:01:59 +00:00
Author
Owner

@⁠thejacte on GitHub · 2026-11-26 20:55 UTC · original

Superseded by #339: the same fix rebased onto the rebuilt rx9070xt (cd8dfc0), with the pixel-shader test asked for in the review and the play.ps1 default. The results reported here are summarised there. Thanks for testing and reviewing.

**@⁠thejacte** on GitHub · 2026-11-26 20:55 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/252#issuecomment-7203215258) Superseded by #339: the same fix rebased onto the rebuilt `rx9070xt` (cd8dfc0), with the pixel-shader test asked for in the review and the `play.ps1` default. The results reported here are summarised there. Thanks for testing and reviewing.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.