Repository navigation
rdna2spirv: lift known-%pc guards in mesh shaders, so a join's barrier is not in a selection (AMD 24.10.24 crash in ms_wave_info_s3) - #8502
Open
SpaghettiMaster545 wants to merge 1 commit into
Conversation
…r is not in a selection (AMD 24.10.24 crash) AMD's Windows driver 24.10.24 (Vulkan driver 2.0.302, a gfx1036 iGPU) crashes inside vkCreateGraphicsPipelines on a mesh shader with any barrier inside a selection construct. That includes OpControlBarrier and also OpMemoryBarrier on its own, even when the condition is a push constant. In ms_wave_info_s3 the barrier sits in the join after a skipped s_sendmsg, a block every path reaches, but cfg_structure leaves it behind if (%pc == 2). assemble() now runs wave64_emulate_opt._unwrap_known_pc_guards on the native structured tree of mesh shaders. It interprets %pc over each block's successors, plus past-the-end for a conditional branch with no block after it (Gen.pc_may_end). A guard that every path reaches with %pc already naming its block is always taken, so its items go in unguarded, and the same blocks run in the same order. Other stages are left as they were until the step is measured over the corpus. Tested on Windows 11 (VS 2026, Vulkan SDK 1.4.363.0, llvm-mc 23.1.6): - run_gpu_tests on the AMD iGPU: 219 -> 220 of 241, with ms_wave_info_s3 going from crash to 4096/4096; no other verdict changes. - run_gpu_tests on an RTX 5070 Ti (621.24): identical verdicts. - Translated modules: only ms_wave_info_s3 of 261 changes. - test_cfg_structure checks the step on 18,228 random graphs. The new semantic/test_ms_barrier_top_level fails on main and passes here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Tested
|
|
I'll independently test this PR on an NVIDIA RTX 4070. Windows. I'll report the exact commit, driver, test command and results. Synthetic tests only, no game files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim: #8047, from my finding in #7913.
What and why
On AMD's Windows driver 24.10.24 (Vulkan driver 2.0.302),
ms_wave_info_s3crashes the driver's shader compiler insidevkCreateGraphicsPipelineswith 0xC0000005 (VK_LAYER_LUNARG_api_dumpends there). Hand-edited modules, allspirv-valclean for vulkan1.2 and 1.3, isolate the trigger: a mesh shader with any barrier inside a selection construct. That includesOpControlBarrier, and alsoOpMemoryBarrieron its own. It crashes even when the condition is a push constant orLocalInvocationIndex < 128.ms_triwith one barrier added behindif (pushconst == 0)crashes too. The same barrier outside the selection compiles and draws.VKH_MESH=1,LEONIDA_PC_TAIL_UBO=1)ms_wave_info_s3onmainms_countsstore ungated, viaOpAtomicStore, or gated as in #5741 / #5855 / #7136OpMemoryBarrieronly, or Subgroup scope%pc == 2selection, or that guard removedms_tri+if (pushconst == 0) { barrier }, orif (local_index < 128) { barrier }ms_tri+ the same selection with no barrierIn
ms_wave_info_s3, the barrier sits in the join of the skippeds_sendmsg GS_ALLOC_REQ, a block that every path reaches. Butcfg_structureleaves that join behindif (%pc == 2), and the driver can't fold the test.assemble()now runs the existingwave64_emulate_opt._unwrap_known_pc_guardson the native structured tree of mesh shaders; until now only the emulated wave64 tree did. It interprets what each block can leave in%pc: its successors, plus "past the end" for a conditional branch with no block after it, whichGen.pc_may_endnow records becausesuccdoesn't list it. A guard that every path reaches with%pcalready equal to its block is always taken, so its items are emitted without it. The shader runs the same blocks in the same order.needs_barrier_roundsstill decides from the tree before this step, which is conservative.Scope: mesh shaders only. Applied to every stage, the step changes 13 of the 247 test modules (structured cs, ms and ps). All of those stay
spirv-valvalid and get the same GPU verdicts. It can't be measured over the corpus here, though, so this PR limits it to the stage that crashes.docs/design.mdsays the barrier stays "inside a selection or loop construct in every ms … shader of the corpus" on the native wave64 path. If those are known-%pcguards like this one, the same crash would hit most game mesh shaders on that driver. That is a hypothesis; I couldn't check it without the corpus. A barrier that is really inside a loop or a branch would still crash there.The NVIDIA failure of
ms_wave_info_s3(SHADER-766: the counts are never written) is separate. All three open fixes for it (#5741, #7136, #5855) still crash on this AMD driver, because the barrier stays behindif (%pc == 2). Combined with this change, #7136 passesms_wave_info_s34096/4096 on both GPUs.Changes
tools/rdna2spirv.py: the step inassemble(), andGen.pc_may_end.tests/test_cfg_structure.py: checks the step on 18,228 random structured graphs. Each graph runs once as is and once with random blocks that may also end the program, compared against the graph and the original tree (18,423 guards dropped over 36,430 runs).tests/test_runner_calls_all_tests.pylists the new function, following the existing pattern.tests/semantic/test_ms_barrier_top_level.py: a hand-written mesh listing. It checks that the join and its barrier sit outside any construct, while the send stays guarded. It fails withmain's translator and passes with this PR.docs/design.md: a new contract row, "Known-%pc guards (native structured form)", and one sentence in "Workgroup barriers".Tested
Windows 11 IoT Enterprise LTSC 2024 (26100), Vulkan SDK 1.4.363.0, llvm-mc 23.1.6, Python 3.14. Test programs built with MSVC 14.50 (VS 2026). Both GPUs are in one machine. Synthetic fixtures only, no game files.
scripts/run_gpu_tests.py, every testmaindfe4e4aLEONIDA_PC_TAIL_UBO=1ms_wave_info_s3crashms_wave_info_s34096/4096 pixels exact. No other verdict changes. The only failure left isms_clip, fixed by #8097.ms_wave_info_s3.spvdiffers frommain; the other 260 are byte-identical.ms_wave_info_s3on either GPU.test_translate,test_mesh_compute,test_mesh_compute_vs,test_wave64_emulate_opt_cfg,test_ab_control_flowandtest_cfg_run_limit: 776 passed, 1 skipped.test_cfg_structure,test_runner_calls_all_testsandcompileall: OK.scripts/run_semantic_tests.py tests/semantic: 448 files, 5,958 tests. Onlytest_image_atomics_guardandtest_image_store_d16fail; both are red onmaintoo, with fixes in test: cover supported d16 cube image stores #7194, test: exercise narrowed EXEC for image atomic guards #7212 and tests: the image atomics guard accepts the folded %true when no lane can be inactive #7292.Overlap: this PR touches
tools/rdna2spirv.py, as #8097 does, but in different places. This PR adds the step aftercapped_tree, theGenfield and one line intranslate(); #8097 changes the mesh output declarations and the epilogue. They don't conflict textually.AI-assisted (Claude Code).
🤖 Generated with Claude Code