Shaders: a buffer's size query has a handle of its own (AMD's compiler crashes on RDNA4) #422

Open
github-bot wants to merge 1 commit from github-bot/gh-422 into a-publier AGit
Owner

@⁠Gooshy on GitHub · 2026-11-27 00:50 UTC · original
Gooshy:amd-size-query-crash → a-publier · +36 −4 · 2 files · 1 commits · open

What fails

On a Radeon RX 9060 XT (RDNA4, amdxc64 32.0.32029.2010, the driver version in #324), cargo test -p victory-shader dies with STATUS_ACCESS_VIOLATION in
emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index. The Windows crash log puts the fault in amdxc64.dll, at offset 0x861b9f in every run, while the test makes the compute pipeline. On WARP the test passes.

The translated program asks a raw buffer view for its size (getDimensions), then reads it (rawBufferLoad), both through one handle.

What the compiler makes

I built HLSL variants of that program with dxc and ran each one on the card in place of the translated DXIL:

Variant RX 9060 XT
getDimensions then load, one handle (the translator's output) crash
Same, without the WaveReadLaneFirst on the loaded value crash
Same, with an i32 load instead of f32 crash
A second handle at the same heap index for the size query (translator change, REUSE off) crash
getDimensions after the load, one handle made, correct
Size query's handle at WaveReadLaneFirst(index) made, correct
Size query's handle at an index from another constant made, correct

So it is the same kind of crash as #324's: the compiler fails when a buffer's size query comes before a read of a view it can see is the same one.

The change

  • lower.rs: the size query of a descriptor read as data (handle_for(.., size: true)) takes a handle of its own, at WaveReadLaneFirst(index). The index is uniform, so it is the same one, but the compiler does not follow it. The handle cache is keyed on that as well, so loads keep their own handle.
  • Not in programs with a waterfall loop (waterfall.compares non-empty). There the queries of the descriptor words the loop compares go once the loop is each lane's own access, and those programs translate exactly as before (the waterfall tests check that no wave operation is emitted).
  • A size query nothing uses still goes: the wave operation is dropped with it and the feature flag is cleared from usage, as before.
  • TRANSLATOR_VERSION 2 → 3, because translations change.

Tested

  • cargo test --release --locked --workspace on the RX 9060 XT: 1,064 passed, 0 failed (victory-shader 303 passed, 4 ignored, including the hardware and WARP dispatches). Before the change the victory-shader test binary crashed.
  • cargo clippy --release --locked --workspace --all-targets: clean.
  • Not run: victory shaders over a title's shaders, so I don't know how many title programs translate differently or whether any of them hit this crash. It would be good to run that on an RDNA4 card before merging.

🤖 Generated with Claude Code

**@⁠Gooshy** on GitHub · 2026-11-27 00:50 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/422) `Gooshy:amd-size-query-crash` → `a-publier` · +36 −4 · 2 files · 1 commits · open ## What fails On a Radeon RX 9060 XT (RDNA4, amdxc64 32.0.32029.2010, the driver version in #324), `cargo test -p victory-shader` dies with `STATUS_ACCESS_VIOLATION` in `emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index`. The Windows crash log puts the fault in `amdxc64.dll`, at offset `0x861b9f` in every run, while the test makes the compute pipeline. On WARP the test passes. The translated program asks a raw buffer view for its size (`getDimensions`), then reads it (`rawBufferLoad`), both through one handle. ## What the compiler makes I built HLSL variants of that program with dxc and ran each one on the card in place of the translated DXIL: | Variant | RX 9060 XT | |---|---| | `getDimensions` then load, one handle (the translator's output) | crash | | Same, without the `WaveReadLaneFirst` on the loaded value | crash | | Same, with an i32 load instead of f32 | crash | | A second handle at the same heap index for the size query (translator change, REUSE off) | crash | | `getDimensions` **after** the load, one handle | made, correct | | Size query's handle at `WaveReadLaneFirst(index)` | made, correct | | Size query's handle at an index from another constant | made, correct | So it is the same kind of crash as #324's: the compiler fails when a buffer's size query comes before a read of a view it can see is the same one. ## The change - `lower.rs`: the size query of a descriptor read as data (`handle_for(.., size: true)`) takes a handle of its own, at `WaveReadLaneFirst(index)`. The index is uniform, so it is the same one, but the compiler does not follow it. The handle cache is keyed on that as well, so loads keep their own handle. - Not in programs with a waterfall loop (`waterfall.compares` non-empty). There the queries of the descriptor words the loop compares go once the loop is each lane's own access, and those programs translate exactly as before (the waterfall tests check that no wave operation is emitted). - A size query nothing uses still goes: the wave operation is dropped with it and the feature flag is cleared from usage, as before. - `TRANSLATOR_VERSION` 2 → 3, because translations change. ## Tested - `cargo test --release --locked --workspace` on the RX 9060 XT: 1,064 passed, 0 failed (victory-shader 303 passed, 4 ignored, including the hardware and WARP dispatches). Before the change the victory-shader test binary crashed. - `cargo clippy --release --locked --workspace --all-targets`: clean. - Not run: `victory shaders` over a title's shaders, so I don't know how many title programs translate differently or whether any of them hit this crash. It would be good to run that on an RDNA4 card before merging. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On an RX 9060 XT (RDNA4, amdxc64 32.0.32029.2010) the driver's compiler
crashes making the pipeline (an access violation in amdxc64.dll, always
at offset 0x861b9f) when a buffer's getDimensions comes before a read of
the same view and it can see the two are the same.
size_tests::the_record_count_of_a_structured_buffer_read_by_index took
the test process down with it; it passes on WARP.

Variants of that program built on the card:
- getDimensions then rawBufferLoad, one handle: crash
- the same without the wave operation, or with an i32 load: crash
- a second handle at the same heap index: crash
- getDimensions after the load, same handle: made
- the size query's handle at WaveReadLaneFirst(index): made

So the size query of a descriptor read as data takes a handle of its
own, at the first lane's index: the same index (it is uniform), which
the compiler does not follow. Not in a program with a waterfall loop:
there the queries of the descriptor words the loop compares go once the
loop is each lane's own access, and those programs translate as before.

Translations change, so TRANSLATOR_VERSION goes to 3.

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

@⁠MamaLeVrai on GitHub · 2026-11-27 02:22 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At cbaa0e2: cargo test --release -p victory-shader --lib 303 passed, 0 failed, 4 ignored. No compiler crash in the suite on RDNA 2. The RDNA 4 case itself cannot be checked here.

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

**@⁠MamaLeVrai** on GitHub · 2026-11-27 02:22 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/422#issuecomment-7208065332) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `cbaa0e2`: `cargo test --release -p victory-shader --lib` 303 passed, 0 failed, 4 ignored. No compiler crash in the suite on RDNA 2. The RDNA 4 case itself cannot be checked here. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 06:48 UTC · original

Tested on RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300, Rust 1.98.1, release. PR head cbaa0e2 against a-publier 4eb6cfd.

Whole-archive translation (translate --validate --list, all of shaders.rpf, 25694 emitted programs):

  • Default wave: 21687 programs change. By stage: PS 9676/12056, MS 8481/8765, VS 1523/2191, CS 2007/2682.
  • VICTORY_HOST_WAVE=32: the same set plus 4 CS, 21691 in all.
  • Validation outcomes are unchanged. All changed PS validate. The same 71 MS fail on output size > 32768, as on 4eb6cfd.
  • About 84% of the archive is retranslated, not only buffers read by index.

Scope against #339 (merged onto 4eb6cfd, VICTORY_SIZE_OWN_HANDLE=1, 12654 changed):

  • Both change 11656 programs.
  • Only #422: 10031. Of these, 9676 are PS, because #422 does not skip pixel shaders.
  • The other 355 (CS 340, VS 15) are texture size queries, for example CS_Texture2DArrayMipmap* and CS_DepthCopy. The new path has no image.is_none() check, so images take it too, not only buffers.
  • Only #339: 998 (CS 670, MS 284, VS 44). These are the programs #422 skips whole because they have a waterfall loop. They include 575 of the 1000 CS_RaytracingResolve and 39 of the 41 bvh_skinning programs.
  • bvh_skinning:CSComputeSkinningTreeAnimVelocity is the compute pipeline reported on #324 as still crashing amdxc64 in a game launch on an RX 9070 XT. The same report says it made a pipeline on cd8dfc06 with VICTORY_SIZE_OWN_HANDLE=1. #422 emits the same program for it as 4eb6cfd, at both waves, so #422 does not change that case.
  • The other tree-animation programs named on #324 (CSComputeSkinningTreeAnim, CSComputeTreeAnim, CSComputeTreeAnimVelocity) are unchanged too. So are the 2 CSComputeSkinningUmWind* programs.

GPU, RDNA 3:

  • emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index: 6/6 passes on the head and on 4eb6cfd, hardware and WARP.
  • emit::size_tests 8/8, emit::waterfall_tests 6/6 and emit::lower::tests::waterfall* 2/2 pass on both.
  • victory-shader full lib on the head: 303 passed, 0 failed, 4 ignored.
  • translate --validate --pipelines over every changed container, head and 4eb6cfd:
    • Adapter wave: all 21687 pipelines created on both (PS 9676 through a stub VS; MS 8481 and VS 1523 through a stub PS; CS 2007).
    • Wave 32: all 21691 created on both.
    • None refused, no process died, and no container's outcome differs. The head still changes every listed program under these runs.

Not tested:

  • RDNA 4. Here neither form crashes, so this does not show whether the change fixes the crash.
  • The game.
  • victory-gpu tests.
**@⁠adrianmjim** on GitHub · 2026-11-27 06:48 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/422#issuecomment-7211858693) Tested on RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300, Rust 1.98.1, release. PR head cbaa0e2 against a-publier 4eb6cfd. Whole-archive translation (`translate --validate --list`, all of shaders.rpf, 25694 emitted programs): - Default wave: 21687 programs change. By stage: PS 9676/12056, MS 8481/8765, VS 1523/2191, CS 2007/2682. - `VICTORY_HOST_WAVE=32`: the same set plus 4 CS, 21691 in all. - Validation outcomes are unchanged. All changed PS validate. The same 71 MS fail on output size > 32768, as on 4eb6cfd. - About 84% of the archive is retranslated, not only buffers read by index. Scope against #339 (merged onto 4eb6cfd, `VICTORY_SIZE_OWN_HANDLE=1`, 12654 changed): - Both change 11656 programs. - Only #422: 10031. Of these, 9676 are PS, because #422 does not skip pixel shaders. - The other 355 (CS 340, VS 15) are texture size queries, for example `CS_Texture2DArrayMipmap*` and `CS_DepthCopy`. The new path has no `image.is_none()` check, so images take it too, not only buffers. - Only #339: 998 (CS 670, MS 284, VS 44). These are the programs #422 skips whole because they have a waterfall loop. They include 575 of the 1000 `CS_RaytracingResolve` and 39 of the 41 `bvh_skinning` programs. - `bvh_skinning:CSComputeSkinningTreeAnimVelocity` is the compute pipeline reported on #324 as still crashing amdxc64 in a game launch on an RX 9070 XT. The same report says it made a pipeline on cd8dfc06 with `VICTORY_SIZE_OWN_HANDLE=1`. #422 emits the same program for it as 4eb6cfd, at both waves, so #422 does not change that case. - The other tree-animation programs named on #324 (`CSComputeSkinningTreeAnim`, `CSComputeTreeAnim`, `CSComputeTreeAnimVelocity`) are unchanged too. So are the 2 `CSComputeSkinningUmWind*` programs. GPU, RDNA 3: - `emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index`: 6/6 passes on the head and on 4eb6cfd, hardware and WARP. - `emit::size_tests` 8/8, `emit::waterfall_tests` 6/6 and `emit::lower::tests::waterfall*` 2/2 pass on both. - victory-shader full lib on the head: 303 passed, 0 failed, 4 ignored. - `translate --validate --pipelines` over every changed container, head and 4eb6cfd: - Adapter wave: all 21687 pipelines created on both (PS 9676 through a stub VS; MS 8481 and VS 1523 through a stub PS; CS 2007). - Wave 32: all 21691 created on both. - None refused, no process died, and no container's outcome differs. The head still changes every listed program under these runs. Not tested: - RDNA 4. Here neither form crashes, so this does not show whether the change fixes the crash. - The game. - victory-gpu tests.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 11:11 UTC · original

Follow-up to my corpus numbers above: one real frame, replayed with base and PR translations. Same machine (RX 7900 XT / RDNA 3, driver 32.0.32029.2010, Windows 11 26300), diag profile this time, cbaa0e2 against a-publier 4eb6cfd.

Setup:

  • A world frame recorded with the frame recorder (VICTORY_RECORD, docs/replay.md) on 4eb6cfd: 39 submissions, 274 lists, 1,024 pipelines, 3,287 MB of card memory.
  • replay --retranslate of that capture with each build (--view-limit 2097151 --raw-views 2097152). 1,162 of its 1,183 title shaders translate on both. The other 21 containers were not found on either, so pipelines that use them keep the recorded shader in every run.
  • replay --compare --shaders <A> --shaders-b <B> --loops 11, in both orders. The replay exe is 4eb6cfd plus the replay fix in #550. It only loads the two folders.

Measured:

  • 959 of the 1,162 shaders differ from base: CS 503 of 635, PS 324 of 354, VS 86 of 122, MS 46 of 51.
  • With either folder the report says 994 of 1024 pipelines made with shaders of the folder given, 0 refused.
  • Card time per frame, median of 11 loops (min-max without each run's first loop, 45.8 and 122.2 ms):
Order base #422
base first (--timing detailed) 17.89 ms (17.76-18.11) 17.90 ms (17.70-18.70)
#422 first 17.43 ms (17.29-17.55) 17.44 ms (17.34-17.56)
  • Control, recorded shaders against base-retranslated: 17.44 against 17.41 ms.
  • The changed shaders run in this frame. Of the 16 title pipelines among the report's 20 costliest, 11-12 use a shader #422 changes (2.6-2.7 of their 3.5 ms). The other 4-5 use one of the 21 not found. By kind, base / #422: dispatches 4.97 / 4.96 ms, indirect dispatches 2.19 / 2.20, indirect mesh draws 0.88 / 0.88, draws 0.78 / 0.78.
  • Picture, PSNR against the presented frame per loop: 57.2-59.1 dB for base, 57.3-59.3 dB for #422, apart from the first loop of the #422-first run (65.7 dB). The control's first loop with the recorded shaders is 66.0 dB. No two loops give the same picture in any set, so I read the differences as the replay's own spread.

So on this frame I cannot measure a cost of the own handle and its WaveReadLaneFirst on RDNA 3, and the picture stays within the replay's spread.

What this cannot show:

  • One frame, one scene, one card.
  • It is card time only. Three ~4 min passes of the opening sequence on 4eb6cfd (Series S profile, frame capture on) ran at 13.8-14.8 fps, 67.8-72.2 ms per frame (each pass's median of the 5 s stats lines), so card time of this size is about a quarter of a frame. I did not run the game with #422.
  • Nothing on RDNA 4 or on the crash.
**@⁠adrianmjim** on GitHub · 2026-11-27 11:11 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/422#issuecomment-7216791257) Follow-up to my corpus numbers above: one real frame, replayed with base and PR translations. Same machine (RX 7900 XT / RDNA 3, driver 32.0.32029.2010, Windows 11 26300), `diag` profile this time, cbaa0e2 against a-publier 4eb6cfd. Setup: - A world frame recorded with the frame recorder (`VICTORY_RECORD`, docs/replay.md) on 4eb6cfd: 39 submissions, 274 lists, 1,024 pipelines, 3,287 MB of card memory. - `replay --retranslate` of that capture with each build (`--view-limit 2097151 --raw-views 2097152`). 1,162 of its 1,183 title shaders translate on both. The other 21 containers were not found on either, so pipelines that use them keep the recorded shader in every run. - `replay --compare --shaders <A> --shaders-b <B> --loops 11`, in both orders. The replay exe is 4eb6cfd plus the replay fix in #550. It only loads the two folders. Measured: - 959 of the 1,162 shaders differ from base: CS 503 of 635, PS 324 of 354, VS 86 of 122, MS 46 of 51. - With either folder the report says `994 of 1024 pipelines made with shaders of the folder given, 0 refused`. - Card time per frame, median of 11 loops (min-max without each run's first loop, 45.8 and 122.2 ms): | Order | base | #422 | |---|---|---| | base first (`--timing detailed`) | 17.89 ms (17.76-18.11) | 17.90 ms (17.70-18.70) | | #422 first | 17.43 ms (17.29-17.55) | 17.44 ms (17.34-17.56) | - Control, recorded shaders against base-retranslated: 17.44 against 17.41 ms. - The changed shaders run in this frame. Of the 16 title pipelines among the report's 20 costliest, 11-12 use a shader #422 changes (2.6-2.7 of their 3.5 ms). The other 4-5 use one of the 21 not found. By kind, base / #422: dispatches 4.97 / 4.96 ms, indirect dispatches 2.19 / 2.20, indirect mesh draws 0.88 / 0.88, draws 0.78 / 0.78. - Picture, PSNR against the presented frame per loop: 57.2-59.1 dB for base, 57.3-59.3 dB for #422, apart from the first loop of the #422-first run (65.7 dB). The control's first loop with the recorded shaders is 66.0 dB. No two loops give the same picture in any set, so I read the differences as the replay's own spread. So on this frame I cannot measure a cost of the own handle and its `WaveReadLaneFirst` on RDNA 3, and the picture stays within the replay's spread. What this cannot show: - One frame, one scene, one card. - It is card time only. Three ~4 min passes of the opening sequence on 4eb6cfd (Series S profile, frame capture on) ran at 13.8-14.8 fps, 67.8-72.2 ms per frame (each pass's median of the 5 s stats lines), so card time of this size is about a quarter of a frame. I did not run the game with #422. - Nothing on RDNA 4 or on the crash.
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 14:32 UTC · original · reviewed

AI-assisted static review (ChatGPT); I did not run tests.

**@⁠gut0to** on GitHub · 2026-11-27 14:32 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/422#pullrequestreview-6089677022) · **reviewed** AI-assisted static review (ChatGPT); I did not run tests.
@ -7878,0 +7897,4 @@
// shortcut: not in a program with a waterfall loop, whose
// descriptor words the loop compares (those queries go once
// the loop is each lane's own access).
let own = size && self.x.res.waterfall.compares.is_empty();
Author
Owner

@⁠gut0to on GitHub · 2026-11-27 14:32 UTC · original

Could you add a deterministic translator test for a buffer size query followed by a read through the same descriptor source? This path creates a distinct handle and normalizes its index with waveReadLaneFirst; a focused test could verify the size query and subsequent read do not reuse one handle, while a waterfall case still preserves its per-lane path. That would protect this driver workaround without needing AMD hardware to reproduce the pipeline-creation crash.

**@⁠gut0to** on GitHub · 2026-11-27 14:32 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/422#discussion_r4720602701) Could you add a deterministic translator test for a buffer size query followed by a read through the same descriptor source? This path creates a distinct handle and normalizes its index with `waveReadLaneFirst`; a focused test could verify the size query and subsequent read do not reuse one handle, while a waterfall case still preserves its per-lane path. That would protect this driver workaround without needing AMD hardware to reproduce the pipeline-creation crash.
This pull request can be merged automatically.
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/422/head:github-bot/gh-422'
git switch 'github-bot/gh-422'

Merge

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