agc_driver_tessellation segfaults on RADV with Mesa 26.2+: nir_opt_varyings corrupts the TCS input offset's use list (Mesa bug) #5444
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from boykopovar/AnyPS5. Originally posted by LloydNicholson on 2026-10-13T19:55:47Z.
What
agc_driver_tessellationsegfaults on RADV with Mesa 26.2 and later, 3 of 3 runs. The rest of the suite passes. The crash is a Mesa bug innir_opt_varyings, not in AnyPS5: the SPIR-V the test builds passesspirv-val --target-env vulkan1.3, and the same pipeline crashes in a standalone Vulkan program without AnyPS5.Environment
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON,mainatdacd78525ab0ab22, 2026-10-01), subgroup 64ANYPS5_GPU=9060 ANYPS5_REQUIRE_VULKAN=1,ctest -j 8,lds_mixed_width_atomicsexcludedagc_driver_tessellationSEGFAULT. On llvmpipe it passes. WithAPS5_NO_GPL=1it also crashes.Where it crashes
A debug build of Mesa
main(eccea0bf, 2026-10-13) stops earlier:nir_validate_shaderafternir_opt_varyingsfails alist_validateassertion on the use list of the TCS's indirect input offset (ushr %447, 4).Cause (Mesa)
remove_dead_varyingsinsrc/compiler/nir/nir_opt_varyings.c, when it shrinks an indirectly indexed varying array to one element, replaces the offset source of indirect loads and stores withon a source that is still linked into the old def's use list. That leaves zeroed links in the list and a null parent pointer. Replacing both sites with
nir_src_rewrite(offset_src, nir_imm_int(b, 0));fixes it. The code came in with Mesa commit 1559e1477076 ("nir/opt_varyings: shrink pathological varying arrays to 1 element"), which is in mesa-26.2.0 through 26.2.4 andmain.The test's TCS (from the dump) reads its per-vertex input with a dynamic vertex, slot and component index (
tess_attributes[umin(n, 2)][(o % 32) >> 4][((o % 32) >> 2) & 3]), which reaches that path.Checked with the fix
Patched debug Mesa
main:agc_driver_tessellationpassesagc_*: 491 of 492 pass;agc_driver_vertex_target_range_copiedaborts on a debug-onlyvk_pipeline_cache_destroyassertion (object_cache->entries == 0), which fails the same way on unpatched debug Mesamain, so it is unrelatedFor AnyPS5
No change is needed in AnyPS5. Titles whose hull programs index inputs this way will crash in pipeline creation on RADV with Mesa 26.2+ until Mesa is fixed. The Mesa fix is not submitted upstream yet; the patch and the standalone reproducer (C file + the three SPIR-V modules) are available on request.
Not tested: other AMD generations, radeonsi, Windows, any title.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T23:53:05Z.
Closing: this is a Mesa bug, with nothing to change in AnyPS5. Please file it at https://gitlab.freedesktop.org/mesa/mesa/-/issues with your reproducer and link it here. Comment here if it still fails once Mesa has the fix.
Imported from boykopovar/AnyPS5. Originally posted by jackthereaper2006 on 2026-10-15T07:46:54Z.
This also reproduces on GCN 5, and @LloydNicholson's two-line fix resolves it there too.
Setup: CachyOS, Linux 7.2.9, Ryzen 5 PRO 5650U iGPU,
AMD Radeon Graphics (RADV RENOIR)0x1638(GCN 5), subgroup 64. AnyPS5maind92a8dad3, GCC 16.2.1, Release,BUILD_TESTING=ON,MESA_SHADER_CACHE_DISABLE=true.agc_driver_tessellationAPS5_NO_GPL=1mesa 3:26.2.4-1)mesa-26.2.4(96cb4312), unpatchednir_src_rewritechangesThe local build is release, RADV only,
-Dllvm=disabled, loaded throughVK_DRIVER_FILES.VK_LOADER_DEBUG=driverconfirms whichlibvulkan_radeon.soeach run used.With the patched driver, the whole
ctestgives 1222/1222. The baseline on the distro driver is 1221/1222, with onlyagc_driver_tessellationfailing. My build has no Wayland WSI, so 5video_outtests that need a Wayland surface skipped in that run. They pass withSDL_VIDEODRIVER=x11. The other 17 skips are the same as on the distro driver.Patch applied to
mesa-26.2.4As of today, Mesa
mainstill has both lines (2393 and 2494), and I found no Mesa issue or merge request for this. @LloydNicholson, are you filing it upstream? You're welcome to reference this GCN 5 result there.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-17T14:57:13Z.
An independent standalone reproducer, and a sharper trigger boundary — I built this from the AnyPS5 side before finding this issue (my #4727 bisect data is upthread-adjacent), and it agrees with and extends the diagnosis here:
gl_inat a data-computed index — but see the next point): creates a pre-raster GPL library (vert + TCS + TES) and a fragment library, then links them. Segfaults insidevkCreateGraphicsPipelineson RADV (Mesa 26.2.4, RX 9070 XT / GFX1201), in the sameremove_dead_varyings→nir_instr_free_and_dcearea.gl_InvocationID(the pattern that predates the AnyPS5 commit) still crashes — the crash is in any tessellation pipeline linked from libraries, not in the new lowering's output. The direct (non-library)vkCreateGraphicsPipelineswith the same four shaders succeeds, which matches the standalone repro already noted here.mov %rdx,0x8(%rcx)withrcx == 0), consistent with the corrupted use list described above.nir_opt_varyingsentry. So 26.2.4 and 26.2.5 both carry it, and the earliest stable pickup would be 26.2.6 (scheduled Oct 28) if the two-line fix lands in it.The reproducer is at
blawesom/AnyPS5branchmesa-gpl-tess-repro(build:cc repro.c -lvulkanwith the four shaders compiled byglslangValidator -V; run plain for the crash,DIRECT=1for the passing control).On the ask to file it at Mesa's GitLab: I don't see a link to a filed issue or MR in this thread — has anyone filed it? If not, this repro plus the description above is ready to go (I can't file on freedesktop GitLab without an account there; if someone files it, my GFX1201 result adds a third hardware data point to @jackthereaper2006's GCN 5 one).