Shaders: a buffer's size query has a handle of its own (AMD's compiler crashes on RDNA4) #422
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!422
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-422"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Gooshy on GitHub · 2026-11-27 00:50 UTC · original
Gooshy:amd-size-query-crash→a-publier· +36 −4 · 2 files · 1 commits · openWhat fails
On a Radeon RX 9060 XT (RDNA4, amdxc64 32.0.32029.2010, the driver version in #324),
cargo test -p victory-shaderdies withSTATUS_ACCESS_VIOLATIONinemit::size_tests::the_record_count_of_a_structured_buffer_read_by_index. The Windows crash log puts the fault inamdxc64.dll, at offset0x861b9fin 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:
getDimensionsthen load, one handle (the translator's output)WaveReadLaneFirston the loaded valuegetDimensionsafter the load, one handleWaveReadLaneFirst(index)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, atWaveReadLaneFirst(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.waterfall.comparesnon-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).TRANSLATOR_VERSION2 → 3, because translations change.Tested
cargo test --release --locked --workspaceon 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.victory shadersover 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
@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 --lib303 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.
@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
cbaa0e2against a-publier4eb6cfd.Whole-archive translation (
translate --validate --list, all of shaders.rpf, 25694 emitted programs):VICTORY_HOST_WAVE=32: the same set plus 4 CS, 21691 in all.4eb6cfd.Scope against #339 (merged onto
4eb6cfd,VICTORY_SIZE_OWN_HANDLE=1, 12654 changed):CS_Texture2DArrayMipmap*andCS_DepthCopy. The new path has noimage.is_none()check, so images take it too, not only buffers.CS_RaytracingResolveand 39 of the 41bvh_skinningprograms.bvh_skinning:CSComputeSkinningTreeAnimVelocityis 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 oncd8dfc06withVICTORY_SIZE_OWN_HANDLE=1. #422 emits the same program for it as4eb6cfd, at both waves, so #422 does not change that case.CSComputeSkinningTreeAnim,CSComputeTreeAnim,CSComputeTreeAnimVelocity) are unchanged too. So are the 2CSComputeSkinningUmWind*programs.GPU, RDNA 3:
emit::size_tests::the_record_count_of_a_structured_buffer_read_by_index: 6/6 passes on the head and on4eb6cfd, hardware and WARP.emit::size_tests8/8,emit::waterfall_tests6/6 andemit::lower::tests::waterfall*2/2 pass on both.translate --validate --pipelinesover every changed container, head and4eb6cfd:Not tested:
@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),
diagprofile this time,cbaa0e2against a-publier4eb6cfd.Setup:
VICTORY_RECORD, docs/replay.md) on4eb6cfd: 39 submissions, 274 lists, 1,024 pipelines, 3,287 MB of card memory.replay --retranslateof 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 is4eb6cfdplus the replay fix in #550. It only loads the two folders.Measured:
994 of 1024 pipelines made with shaders of the folder given, 0 refused.--timing detailed)So on this frame I cannot measure a cost of the own handle and its
WaveReadLaneFirston RDNA 3, and the picture stays within the replay's spread.What this cannot show:
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.@gut0to on GitHub · 2026-11-27 14:32 UTC · original · 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();@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.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.