fix(agc): lower a fragment Layer input through the viewport index layer extension #6164
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6164"
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 011010 on 2026-10-15T00:01:17Z.
What
When a fragment shader reads the
Layerinput,DefineModuleemittedCapabilityGeometryunconditionally. On a device without geometry shaders (MoltenVK on macOS) the module then names a capability the device does not advertise, and validation fails.Emit
SPV_EXT_shader_viewport_index_layerandCapabilityShaderViewportIndexLayerEXTinstead when the device supports that capability and does not supportGeometry. The previous behaviour is kept everywhere else, so NVIDIA and lavapipe (which advertiseGeometry) emit exactly what they did before.Asked about the placement in #1; @mugurc confirmed it should go against
mainnow, independently of the macOS series, since none of those branches touchSpirvModuleSetup.cpp.Tested
ctest -R agc→ 566/566 passed, including the newagc_layer_input.agc_layer_input. The rebase onto currentmainwas clean, and the Linux run above is on the rebased head.The new
agc_layer_inputtest forcessupportedCapabilitiesto the no-geometry case, so it covers the fallback without a GPU.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 repositoryImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T01:02:48Z.
Ran this on PR head
b7948261a(merge baseab9a47684, which is current main).Setup: PR head checked out as-is, default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), Linux.
The test checks the emitted SPIR-V capability and extension. Its no-geometry device reports ShaderViewportIndexLayerEXT as available, so it covers only a device that has the extension. I did not check a device without it, and did not run a title.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T01:21:21Z.
Review: COMMENTED
Ran this on Apple silicon at head
b7948261a, as an end-to-end GPU check of the fallback (the runs so far cover the CPU unit test).Setup: Apple M2 Max, macOS 27.2, x86-64 Release build under Rosetta, SDK MoltenVK 1.4.2. Base is macos-port @ b7eb6b6b + ImportWatched + PR diff, not main. MoltenVK on this device reports
geometryShader = false,VK_EXT_shader_viewport_index_layerandshaderOutputLayer = true, so it is the no-geometry case this PR targets.The port predates
105561775, so its device setup never enabledVK_EXT_shader_viewport_index_layerand the new branch could not fire. For this run I added a minimal stand-in for the part of105561775that the PR relies on (+8/-2 lines):VulkanDeviceenables the extension and addsShaderViewportIndexLayerEXTandSPV_EXT_shader_viewport_index_layerto the target, andShaderValidationaccepts that capability and extension. Currentmainalready has the real version of this.agc_driver_relative_ancillary(the fragment shader reads the ancillary word, which carries the render target index, and the test checks the pixels it writes):SPIR-V requires unsupported device capability 2(Geometry)With stand-in + PR it also passes on MoltenVK main + SPIRV-Cross #2704.
-R ^agc, flip/display/lds_atomics64 excluded,-j1 --timeout 30): 13 failures on base, 12 with the stand-in + PR. The only change isagc_driver_relative_ancillary, which now passes. No new failures.agc_layer_inputpasses. With only the test applied on base it fails witha Layer input without geometry shaders must declare the viewport index layer capability.GPUs tested: Apple M2 Max (MoltenVK 1.4.2 / Vulkan SDK 1.4.363), macOS 27.2.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:15:51Z.
Some 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/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by 011010 on 2026-10-15T16:03:19Z.
Thanks to both of you, this is more than I could produce on my own.
@Dextroid17 the mutation check is the part that matters: putting
SpirvModuleSetup.cppback tomainwhile keeping the test fails 3/3, so the test is not passing by accident. On the coverage caveat, you are right. The branch is now:Geometrysupported →CapabilityGeometry, unchanged, so NVIDIA and lavapipe emit exactly what they did before.Geometrynot supported,ShaderViewportIndexLayerEXTsupported → the extension plusCapabilityShaderViewportIndexLayerEXT.CapabilityGeometry, the previous behaviour.The third case is deliberate: with neither capability there is nothing to declare a fragment
Layerinput with, so the module fails validation exactly as it did before this PR. It adds a path, it does not remove one. There is one candidate this PR does not take: the output-layer branch a few lines above falls back toShaderLayerwith SPIR-V 1.5 when the extension is missing, and the input could mirror it. I left it out because neither of us has a device that reports neither, so it would be an untested path — say the word and I will add it as a follow-up.@jotitadev thank you for the GPU run, it is the evidence I could not produce myself. You read the base correctly:
mainalready carries the real device setup from105561775(VulkanDevice.cpppushesCapabilityShaderViewportIndexLayerEXTand the extension), so the +8/-2 stand-in was the right call for the port branch and nothing else is needed onmain. The two numbers I care about are the ones you measured:agc_driver_relative_ancillarygoes fromSPIR-V requires unsupported device capability 2to passing with matching pixels, and the suite goes from 13 to 12 failures with no new ones.