fix(shader): write a mesh shader's layer through a per-primitive block #7674
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7674"
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 thuanquang on 2026-10-18T21:35:18Z.
What
On AMD's Windows driver, a draw through a geometry program that writes a layer crashes the process on
main. The mesh shader the recompiler builds for it declares the per-primitive layer as a standaloneOutputarray ofuint, decoratedBuiltIn LayerandPerPrimitiveEXT. Creating the pipeline crashes inside the driver:The layer is now written through an array of a one-member
Blockstruct whose member is decoratedBuiltIn LayerandPerPrimitiveEXT, stored with an access chain to member 0. That is how glslang declaresgl_Layer, as a member ofgl_MeshPerPrimitiveEXT. AMD's driver creates that pipeline and draws with it, also when the pixel shader reads the layer.ShaderValidationnow readsPerPrimitiveEXTmember decorations, so the block's array is checked againstmaxPrimitiveslike the other per-primitive outputs. The debt entry records why the block form is used.#6379 (@Feuris) works around the same crash by removing the mesh layer output and the fragment layer input when pipelines are created, so layered mesh draws land in slice 0 on every vendor. This keeps the layer instead. I offered the block form for #6379 there first (comment); this is the separate PR that comment mentions. #7377 notes that Demon's Souls (PPSA01342) needed #6379 for this crash on AMD. #6959 (@JJenkx) renders layered mesh targets in windows and needs the layer output that #6379 removes; on this driver its new
agc_driver_layered_volume_meshcrashes the same way, atamdvlk64.dll+0x21f3221.The test is the one @oneandonlydean asked for on #7374: the layer each triangle lands on in first and last provoking vertex mode. On
mainit never reaches the comparison on this GPU, because the first draw crashes the driver.Tested
Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ANYPS5_REQUIRE_VULKAN=1,main05171bc66:agc_driver_mesh_provoking_layer. It draws one quad through the geometry programagc_driver_layered_volume_drawcompiles, which exports each vertex's layer, into a 2-slice target. Each triangle's vertices carry layers 0, 0 and 1.main's emitter andShaderValidation, the test crashes at the first draw, 3 of 3, with theamdvlk64.dll+0x21f3221crash above. With this change it passes 3 of 3.VK_EXT_mesh_shader,VK_EXT_shader_viewport_index_layeror a last provoking vertex mode, and on llvmpipe like the other mesh execution tests, so CI does not run it.ctest -R "mesh|layer|provoking"(18 tests): all pass exceptagc_driver_layered_volume_vertex_no_gpl, which fails onmainhere too (#4768).ctest --parallel 4 --timeout 120onmain023106ae4with this change, before the rebase onto05171bc66: 1509 tests. The failures are the three thatmainhas on this machine (agc_driver_lds_mixed_width_atomics#6976,agc_driver_lds_lock_budget,agc_driver_layered_volume_vertex_no_gpl#4768), pluslog_macrosandlog_macros_timestamps, which fail in this build only because ccache rewrites__FILE__.python tools/check_conventions.py --base origin/mainwith this title and body passes.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T21:46:30Z.
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/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppL1003-1004Some 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/ShaderValidation.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T00:10:07Z.
Thanks, this looks good on our side: review passes and all the mesh and layered tests pass on NVIDIA, including the new one. We don't have an AMD GPU, so before merging we'd like one independent AMD run: the crash on current main, and no crash with this PR. Could anyone with an RDNA2 card (or another AMD GPU) on a recent Windows driver post that?
Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T01:23:58Z.
Independent AMD run, as requested. Windows 11, AMD Radeon(TM) Graphics iGPU (Granite Ridge, RDNA2, deviceID 0x13c0), driver 32.0.21042.62, WinLibs GCC 15.2.0, Release,
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_GPU=AMD. Base ismaina373e85e5; head is that plusa9cd39045.main: the new test, built againstmain's emitter andShaderValidation, crashes at the first draw with0xc0000005 ... amdvlk64.dll+0x21f31a1, read of 0x0000000000000004. That is the same crash as the reported offset0x21f3221, shifted by the driver build.main, so only an AMD run catches this regression.agc|shader|spirv|recomp|video|pad|record|mesh|layer, 793 tests) has no new failures on either GPU. The AMD failureslds_lock_budget,lds_mixed_width_atomicsandlayered_volume_vertex_no_gplalso fail onmain.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by Feuris on 2026-10-19T05:33:38Z.
Tested on Windows 11 with AMD Radeon RX 6700 XT and AMD Ryzen 9 7900X:
Fully support closing #6379 in favor of this cleaner solution. Thanks @thuanquang and @oneandonlydean!