Shaders: give buffer size queries their own bounded heap handle (AMD compiler crash) #109

Open
WHOISJARDAS wants to merge 1 commit from upstream-pr/109 into main
WHOISJARDAS commented 2026-11-25 12:07:11 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by WHOISJARDAS on 2026-11-25T12:05:30Z.


Fixes the AMD shader compiler crash 0xc0000005 at amdxc64.dll+0x861b9f ("read 0x8") that ends runs when a pipeline is created, here on an RX 9070 XT and in the reports on other Radeon cards (#81, #46; upstream fxceless/victory-fork#3 and fxceless/victory-fork#120), without leaving any pass out and without skip lists.

What was wrong

Some programs read a buffer's last records at an offset made from that buffer's own size: the record count comes from the descriptor read as data (descriptor_data, lowered to getDimensions), and the read or write goes through the same descriptor. Both went through one heap handle. AMD's compiler (driver 32.0.32029.2010, RDNA 4) crashes building exactly that shape, an access through a handle at an offset computed from that handle's own getDimensions. The DXIL is valid (the validator passes it), so this is the driver, but the shape is ours to avoid.

descriptor_data now asks the size through a handle of its own (Shader::size_handle): its heap index goes through a dx.op.binary UMin, one slot below the view limit when there is one (VIEW_LIMIT - 1), else 2^26 - 1 (past any host heap, below what an index made from a 32-bit address can be), so it is never the access's handle. shortcut: with a limit, an index at or past the slot below the null slot reads that slot's size where reads go to the null slot; neither holds one of the title's views.

This also covers 501f0865fdf45dfd, the program #61 leaves the reuse pass out on AMD for: with this, it builds with every pass on.

Tested

AMD Radeon RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26200, Rust 1.98.1, shaders.rpf of the title's build b99f876b.

Offline, one process per program (VICTORY_TRANSLATE_ONLY=<hash> victory translate --validate --pipelines --jobs 1):

main (90b529f) this branch
the 70 compute programs whose pipeline crashes this card's compiler on main (among them 501f0865fdf45dfd) 70 crash 70 pipelines, 0 crash

Whole archive:

  • translate --validate --list: the same outcome as main for all 25,889 programs (26,084 translated, 0 differences).
  • The change alters the DXIL of 22,380 programs (most programs read a record count). All 22,379 of them (all but 39f0e9aeb156a61c, left out as the program whose compile does not finish in fxceless/victory-fork#3) were built as host pipelines on this card in 13 batches: 22,379 created, 0 refused, 0 crashes.

In game (diag build, Series X profile, default switches, no skip list, cold shader cache; both runs also carry #108, without which main does not start on this machine):

port only port + this
run 197 s, then 0xc0000005 at amdxc64.dll+0x861b9f (the last compute programs translated were 072f5fe96efd27e1 and 501f0865fdf45dfd) 18 min (closed by hand), 0 exceptions
compute programs from the 70 that got a host pipeline in game - 33
frame rate in the world ~1.3 fps median 3.7 fps (0.6-6.6), 1,600-6,800 draws/frame
pipelines refused - one, mesh f5e50eb2108c425b (integer-target blending, #36)
  • cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored, including the new emit::descriptor_tests::every_lane_reads_the_last_dword_its_buffers_record_count_names, which runs on the GPU and on WARP. Without the lower.rs change its process dies on this card with 0xc0000005 (STATUS_ACCESS_VIOLATION); with it, it passes.
  • Both clippy runs (-D warnings, with and without --all-features): clean. cargo xtask policy: ok.

Overlap

#58 moves the same getDimensions call into a new Lower::dimensions. Whichever lands first, the other is a small rebase: with #58 in, buffer views take size_handle inside dimensions. Happy to rebase this onto it.

Not tested

NVIDIA (where VIEW_LIMIT is set, so the VIEW_LIMIT - 1 bound is what runs) and Intel; RDNA 2/3; Linux/Wine.

AI use

Claude Code (Claude Opus 5.5) reduced the crash, wrote the change and the test, and ran the offline batches. The hardware, the title copy and the runs are mine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Zettrox/ztrx:issue:6604075758 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/109). Originally posted by [WHOISJARDAS](https://github.com/WHOISJARDAS) on 2026-11-25T12:05:30Z. --- Fixes the AMD shader compiler crash `0xc0000005` at `amdxc64.dll+0x861b9f` ("read 0x8") that ends runs when a pipeline is created, here on an RX 9070 XT and in the reports on other Radeon cards (#81, #46; upstream fxceless/victory-fork#3 and fxceless/victory-fork#120), without leaving any pass out and without skip lists. ## What was wrong Some programs read a buffer's last records at an offset made from that buffer's own size: the record count comes from the descriptor read as data (`descriptor_data`, lowered to `getDimensions`), and the read or write goes through the same descriptor. Both went through one heap handle. AMD's compiler (driver 32.0.32029.2010, RDNA 4) crashes building exactly that shape, an access through a handle at an offset computed from that handle's own `getDimensions`. The DXIL is valid (the validator passes it), so this is the driver, but the shape is ours to avoid. `descriptor_data` now asks the size through a handle of its own (`Shader::size_handle`): its heap index goes through a `dx.op.binary` UMin, one slot below the view limit when there is one (`VIEW_LIMIT - 1`), else `2^26 - 1` (past any host heap, below what an index made from a 32-bit address can be), so it is never the access's handle. `shortcut:` with a limit, an index at or past the slot below the null slot reads that slot's size where reads go to the null slot; neither holds one of the title's views. This also covers `501f0865fdf45dfd`, the program #61 leaves the reuse pass out on AMD for: with this, it builds with every pass on. ## Tested AMD Radeon RX 9070 XT 16 GB (driver 32.0.32029.2010), Ryzen 7 9800X3D, 32 GB, Windows 11 Pro 26200, Rust 1.98.1, `shaders.rpf` of the title's build `b99f876b`. Offline, one process per program (`VICTORY_TRANSLATE_ONLY=<hash> victory translate --validate --pipelines --jobs 1`): | | `main` (`90b529f`) | this branch | |---|---:|---:| | the 70 compute programs whose pipeline crashes this card's compiler on `main` (among them `501f0865fdf45dfd`) | 70 crash | 70 pipelines, 0 crash | Whole archive: - `translate --validate --list`: the same outcome as `main` for all 25,889 programs (26,084 translated, 0 differences). - The change alters the DXIL of 22,380 programs (most programs read a record count). All 22,379 of them (all but `39f0e9aeb156a61c`, left out as the program whose compile does not finish in fxceless/victory-fork#3) were built as host pipelines on this card in 13 batches: **22,379 created, 0 refused, 0 crashes**. In game (diag build, Series X profile, default switches, no skip list, cold shader cache; both runs also carry #108, without which `main` does not start on this machine): | | port only | port + this | |---|---|---| | run | 197 s, then `0xc0000005` at `amdxc64.dll+0x861b9f` (the last compute programs translated were `072f5fe96efd27e1` and `501f0865fdf45dfd`) | 18 min (closed by hand), **0 exceptions** | | compute programs from the 70 that got a host pipeline in game | - | 33 | | frame rate in the world | ~1.3 fps | median 3.7 fps (0.6-6.6), 1,600-6,800 draws/frame | | pipelines refused | - | one, `mesh f5e50eb2108c425b` (integer-target blending, #36) | - `cargo test --workspace --locked`: 497 passed, 0 failed, 7 ignored, including the new `emit::descriptor_tests::every_lane_reads_the_last_dword_its_buffers_record_count_names`, which runs on the GPU and on WARP. Without the `lower.rs` change its process dies on this card with `0xc0000005` (STATUS_ACCESS_VIOLATION); with it, it passes. - Both clippy runs (`-D warnings`, with and without `--all-features`): clean. `cargo xtask policy`: ok. ## Overlap #58 moves the same `getDimensions` call into a new `Lower::dimensions`. Whichever lands first, the other is a small rebase: with #58 in, buffer views take `size_handle` inside `dimensions`. Happy to rebase this onto it. ## Not tested NVIDIA (where `VIEW_LIMIT` is set, so the `VIEW_LIMIT - 1` bound is what runs) and Intel; RDNA 2/3; Linux/Wine. ## AI use Claude Code (Claude Opus 5.5) reduced the crash, wrote the change and the test, and ran the offline batches. The hardware, the title copy and the runs are mine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/109:upstream-pr/109'
git switch 'upstream-pr/109'

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/109'
git switch 'upstream-pr/109'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/109'
git switch 'upstream-pr/109'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/109'
git switch 'main'
git merge --squash 'upstream-pr/109'
git switch 'main'
git merge --ff-only 'upstream-pr/109'
git switch 'main'
git merge 'upstream-pr/109'
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
Zettrox/ztrx!109
No description provided.