fix(agc): do not use fragment barycentric on MoltenVK #1653

Merged
morten-holm merged 1 commit from upstream-pr/1653 into main 2026-10-10 04:40:33 +00:00
morten-holm commented 2026-10-08 15:44:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by morten-holm on 2026-10-08T15:44:52Z.


What

MoltenVK reports VK_KHR_fragment_shader_barycentric, but its SPIR-V to MSL step rejects the PerVertexKHR decoration that the barycentric path of the translator uses ("SPIR-V to MSL conversion error: PerVertexKHR decoration is not supported in MSL"). Every pixel shader on that path then fails with VK_ERROR_INITIALIZATION_FAILED ("Fragment shader function could not be compiled into pipeline"), and the draw is skipped.

The feature is now treated as unavailable when the driver is MoltenVK (VK_KHR_driver_properties, VK_DRIVER_ID_MOLTENVK), so the existing no-barycentric path is used. The rule is FragmentShaderBarycentricUsable, a small header like SubgroupClock, so it has a unit test that needs no GPU.

Related: #1547 improves the no-barycentric path that MoltenVK now uses. On main today that path does not write the I/J VGPRs, so a shader that reads them for anything other than a plain v_interp_p1/p2 pair gets 0. Both PRs change VulkanDevice.cpp near the same lines; whichever lands second needs a small rebase.

Tested

  • macOS 27 (Apple M2), x86-64 under Rosetta, MoltenVK 1.4.2: one retail title, 30 s run. Before, 5 draws were skipped with the error above. After, none, and the picture is shown.
  • New test agc_fragment_barycentric (7 cases: MoltenVK reported or not, RADV, NVIDIA and AMD proprietary, Intel): passes, and the MoltenVK case fails when the rule is removed.
  • VulkanDevice.cpp compiles on this branch. main does not build libc on macOS yet, so I could not run the full suite here.
  • Not tested: Linux and Windows (CI), and other titles on MoltenVK that read the I/J registers beyond a plain interpolate (see #1547).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4789306172 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1653). Originally posted by [morten-holm](https://github.com/morten-holm) on 2026-10-08T15:44:52Z. --- ### What MoltenVK reports `VK_KHR_fragment_shader_barycentric`, but its SPIR-V to MSL step rejects the `PerVertexKHR` decoration that the barycentric path of the translator uses ("SPIR-V to MSL conversion error: PerVertexKHR decoration is not supported in MSL"). Every pixel shader on that path then fails with `VK_ERROR_INITIALIZATION_FAILED` ("Fragment shader function could not be compiled into pipeline"), and the draw is skipped. The feature is now treated as unavailable when the driver is MoltenVK (`VK_KHR_driver_properties`, `VK_DRIVER_ID_MOLTENVK`), so the existing no-barycentric path is used. The rule is `FragmentShaderBarycentricUsable`, a small header like `SubgroupClock`, so it has a unit test that needs no GPU. Related: #1547 improves the no-barycentric path that MoltenVK now uses. On `main` today that path does not write the I/J VGPRs, so a shader that reads them for anything other than a plain `v_interp_p1/p2` pair gets 0. Both PRs change `VulkanDevice.cpp` near the same lines; whichever lands second needs a small rebase. ### Tested - macOS 27 (Apple M2), x86-64 under Rosetta, MoltenVK 1.4.2: one retail title, 30 s run. Before, 5 draws were skipped with the error above. After, none, and the picture is shown. - New test `agc_fragment_barycentric` (7 cases: MoltenVK reported or not, RADV, NVIDIA and AMD proprietary, Intel): passes, and the MoltenVK case fails when the rule is removed. - `VulkanDevice.cpp` compiles on this branch. `main` does not build libc on macOS yet, so I could not run the full suite here. - Not tested: Linux and Windows (CI), and other titles on MoltenVK that read the I/J registers beyond a plain interpolate (see #1547). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
popcoder565 commented 2026-10-09 19:43:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:43:42Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 5333a205, merged onto main 8b393b6e in one build with 31 other PRs that had no Windows run.

  • The change targets MoltenVK, so on Windows this checks that agc_fragment_barycentric and the rest still pass.
  • Full ctest in that build: 520 of 521. The one failure is guest_offline_imports, broken by #2359 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088037563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1653#issuecomment-6088037563). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:43:42Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `5333a205`, merged onto `main` 8b393b6e in one build with 31 other PRs that had no Windows run. - The change targets MoltenVK, so on Windows this checks that `agc_fragment_barycentric` and the rest still pass. - Full ctest in that build: 520 of 521. The one failure is `guest_offline_imports`, broken by #2359 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
github-actions[bot] commented 2026-10-10 04:18:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T04:18:03Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2545 core/libs/prx/libSceAgcDriver/Execution/include/FragmentBarycentric.hpp
core/libs/prx/libSceAgcDriver/tests/FragmentBarycentric.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093684542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1653#issuecomment-6093684542). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T04:18:03Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2545 | | | `core/libs/prx/libSceAgcDriver/Execution/include/FragmentBarycentric.hpp`<br>`core/libs/prx/libSceAgcDriver/tests/FragmentBarycentric.cpp` |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1653
No description provided.