fix(agc): drop layer I/O when linking mesh pipelines in driver to prevent AMD crash #6379
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6379"
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 Feuris on 2026-10-15T13:40:45Z.
What
Sanitize mesh layer outputs and unconsumed fragment layer inputs in
Pipeline.cppprior tovkCreateShaderModulewhile keeping the shader recompiler's meshBuiltInLayerexport intact.In the proprietary AMD Windows Vulkan driver (
amdvlk64.dll), declaringgl_Layeras an output from a mesh shader marks the interface variable asPerPrimitiveEXT. When linking against a fragment shader, AMD's stage matcher (0x1821f30d0) fails to match the inputs, leaving a null pointer and triggering an unconditional dereference atamdvlk64.dll+0x21f3221(mov 0x4(%r9), %r10d).Reverting the changes in
SpirvModuleEmitter.cppensures that the recompiler emitsspv::BuiltInLayeras expected, passingagc_driver_layered_volume_draw. Sanitizing the SPIR-V at the Vulkan driver level inPipeline.cppviaDropMeshLayerOutputandDropFragmentLayerInputavoids the AMD crash duringvkCreateGraphicsPipelines.Tested
agc_driver_layered_volume_draw,agc_driver_mesh, andagc_vertex_layer_exportall pass 100%.PPSA31162): boots and renders continuously past the layered volume draw on AMD Radeon RX 6700 XT with zero crashes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T13:47:46Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppL345, L347-348core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppL10core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppL345, L347-348Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppImported from boykopovar/AnyPS5. Originally posted by Neithennn on 2026-10-15T15:14:57Z.
Windows NVIDIA run: this change fails
agc_driver_layered_volume_draw, which passes on main.Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1. Head17d8442aemerged onto mainff23657f3; full build succeeds.agc_driver_layered_volume_draw: fails 7/7 with this PR (targeted, broad and 5 serial reruns); passed in the baseline run on unchanged mainff23657f3on the same machine.agc_driver_mesh,agc_vertex_layer_export,agc_driver_layered_volume_submit,agc_driver_layered_volume_vertex,agc_driver_layered_volume_vertex_no_gpl,agc_driver_array_layer_target,agc_driver_depth_plane_guest_layers: pass.ctest -R "agc_|shader|recompiler|spirv|video_out" -j 8: 620/623. Besidesagc_driver_layered_volume_draw:agc_driver_store_over_untracked(#6347/#6383, also on main) andagc_driver_multisample_fill_host_only, which failed once under parallel load and passes 5/5 alone.The assertion is not NVIDIA-specific: with the
Layeroutput no longer declared as a mesh stage output, a mesh program that writes the layer has noLayeroutput, which this test requires. Expected on every vendor, but only measured here.AI-assisted: yes (runs done with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by PYTHONRETARDE on 2026-10-15T20:18:47Z.
AMD Windows run (RDNA 3): the change fails
agc_driver_layered_volume_drawhere too, as on the RTX 4080 above.RX 7800 XT (
1002:747e), driver 32.0.31041.1004, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,BUILD_TESTING=ON. Baselinemain03c4cb5e7+ #6452 (needed to build on Windows); test build adds this PR's head17d8442ae.%LOCALAPPDATA%\AMD\VkCacheemptied before each run (see #4768).agc_driver_layered_volume_drawthe mesh program declares no Layer outputagc_driver_mesh,agc_vertex_layer_exportagc_driver_layered_volume_vertex,_submitFull CTest with the PR: 1293 of 1298 pass. The other failures also occur on the baseline, so they're not from this PR:
agc_driver_quad_pixel_mask(fails 5/5 on the baseline),agc_driver_depth_surface_from_storage(fails 1/5 on the baseline),agc_driver_layered_volume_vertex(#4768 cache swap; passes 3/3 alone),guest_kqueue(#6173).So dropping the
Layerinterface variable loses the layer the mesh program writes. I couldn't test PPSA31162, so I can't say whether the crash it fixes reproduces on RDNA 3.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Feuris on 2026-10-16T09:04:39Z.
Reverted the change in
SpirvModuleEmitter.cppto keep the shader recompiler's meshBuiltInLayerexport intact, resolving the regression onagc_driver_layered_volume_draw.To resolve the AMD proprietary driver crash (
amdvlk64.dll+0x21f3221null pointer dereference during stage interface linking), mesh layer outputs and unconsumed fragment layer inputs are sanitized inPipeline.cppbeforevkCreateShaderModule.Verified:
ctest -R "agc_driver_layered_volume_draw|agc_driver_mesh|agc_vertex_layer_export" -Vpasses 100% (3/3).python tools/check_conventions.pypasses cleanly.PPSA31162) boots and renders through the layered volume draw on AMD host (RX 6700 XT) with zero crashes.Imported from boykopovar/AnyPS5. Originally posted by Neithennn on 2026-10-16T11:30:43Z.
Windows NVIDIA rerun of the new head:
agc_driver_layered_volume_drawpasses again.Windows 11 Pro 26200, NVIDIA GeForce RTX 4080 (driver 617.42), AMD Ryzen 7 5800X, WinLibs GCC 15.2.0 r7, Ninja, Release, bundled dependencies,
BUILD_TESTING=ON,ANYPS5_NO_SHADER_CACHE=1. Current main72c5eed1fdoes not build on Windows here without #6452, so the base is main + #6452 (4fe92c9c2); head04ab941ffmerged on top.agc_driver_layered_volume_draw: passes (targeted and 5 serial runs); it failed 7/7 on the previous head.agc_driver_mesh,agc_driver_mesh_index_cache,agc_vertex_layer_export,agc_driver_layered_volume_submit,agc_driver_layered_volume_vertex,agc_driver_layered_volume_vertex_no_gpl,agc_driver_array_layer_target,agc_driver_depth_plane_guest_layers: pass.ctest -j 8, excludingagc_shader_helpers: 1301/1302; the failure isguest_kqueue(0xc0000409, #6173), which also fails on the base alone.agc_shader_helpersis excluded because it hangs intermittently on this machine both with and without this PR (base alone: 3 of 10 runs hit a 60 s limit; it has no timeout of its own, and one full run waited on it for 38 minutes). It looks like a separate problem and is not attributed to this change.No AMD GPU here, so the
amdvlk64.dllcrash this PR targets is not tested.AI-assisted: yes (runs done with Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T05:17:58Z.
A cross-vendor check, since the description lists AMD/Windows only: NVIDIA GeForce RTX 4070 Ti (595.99.02), Ubuntu 24.04, Release. This PR's head (
c857ea6057) merged ontomain661a1118cc, clean merge:agc_driver_layered_volume_drawpasses 3 of 3.mainand 2 with this PR: all four reach the limit with nodriver failurelines. The scene the runs reach depends on input timing, so I'm not comparing frame rates.No regression on NVIDIA as far as these go.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-18T12:37:21Z.
@Feuris I hit the same
amdvlk64.dll+0x21f3221crash on the same RX 6700 XT and driver (32.0.21045.5002) while writing the layer test asked for on #7374. I found a way around it that keeps the layer: declare the meshgl_Layeras a member of aPerPrimitiveEXTBlockstruct (the way glslang declares it insidegl_MeshPerPrimitiveEXT) instead of as the standalonePerPrimitiveEXTarray. With that, AMD's driver creates the pipeline and each primitive lands in its own slice, also when the pixel shader reads the layer, which is the caseDropFragmentLayerInputcovers.Branch:
thuanquang/AnyPS5fix/mesh-layer-block(c99657f8d). It changes the emitter's declaration, teachesShaderValidationaboutPerPrimitiveEXTmember decorations, and addsagc_driver_mesh_provoking_layer:mainthe first draw crashes;With #6379 the layer output is removed from every mesh pipeline, so layered mesh draws always land in slice 0, and this test's last-mode case would fail. Would you take the block form into #6379 instead of dropping the layer? Or should I open it as a separate PR? Super Meat Boy 3D (PPSA31162) would be worth a rerun with it; I don't have the game.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-18T21:36:06Z.
@Feuris I opened the block form as #7674, rebased on current
main, so you and the reviewers can compare the two. It keeps the layer, which #6959's layer windows need: on this RX 6700 XT, #6959'sagc_driver_layered_volume_meshcrashes atamdvlk64.dll+0x21f3221and passes with #7674 on top (run).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T00:10:03Z.
Thanks for tracking down the AMD mesh-shader crash. We're going with #7674 for it: that one keeps the mesh layer output and declares it the way glslang does, so layered mesh draws still land in the right slice on every vendor, while removing the layer here would send them all to slice 0. Closing this as superseded by #7674. If you hit an AMD case that #7674 doesn't fix, please reopen or open a follow-up on top of it.
Pull request closed