fix(agc): load the Vulkan loader and list MoltenVK on macOS #11554

Merged
maximilianfv merged 2 commits from upstream-pr/11554 into main 2026-11-02 10:29:00 +00:00
maximilianfv commented 2026-10-26 18:42:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-26T18:42:16Z.


What

On macOS the AGC driver cannot create a Vulkan device. VulkanDevice loads libvulkan.so.1, which does not exist there. Even with a loader, MoltenVK is a portability driver, and the loader lists it only for an instance created with VK_KHR_portability_enumeration and VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR.

This PR changes Execution/src/VulkanDevice.cpp, plus one line in core/libs/prx/libSceAgcDriver/CMakeLists.txt that defines VK_ENABLE_BETA_EXTENSIONS for that file only. VkPhysicalDevicePortabilitySubsetFeaturesKHR and its VkStructureType value are only declared under that define, the same way #10920 enables it for its test files:

  • On macOS it loads libvulkan.1.dylib. Windows and Linux keep vulkan-1.dll and libvulkan.so.1.
  • On macOS every instance requests VK_KHR_portability_enumeration and sets VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR, with or without a window. The extension count and names are now set after the window block, so a windowless instance passes its list too (nullptr when it is empty).
  • A device that advertises VK_KHR_portability_subset must enable it. When the device advertises it, the driver enables it, queries VkPhysicalDevicePortabilitySubsetFeaturesKHR with vkGetPhysicalDeviceFeatures2 and chains the reported values into VkDeviceCreateInfo. Without the chained struct, every subset feature counts as off, even the ones MoltenVK supports. Devices that do not advertise the subset, including every Linux and Windows driver I know of, take the same path as before.

imellag reported on #10540 that booting titles on macOS from main needs a local VulkanDevice.cpp patch that loads libvulkan.1.dylib and enables portability enumeration, and that no open PR covers it: https://github.com/boykopovar/AnyPS5/pull/10540#issuecomment-6419715677 . This PR is that patch on its own.

Prior work and credit:

  • mugurc wrote the loader and enumeration parts first, in 62917206d9 ("feat(macos): relink and run titles on macOS (x86-64 under Rosetta)", 2026-10-05), and then in 20ee39de9a ("feat(agc): create the Vulkan device on MoltenVK", 2026-10-12) in the macOS series (ci/macos-series-2). Both also enable the subset extension, but without chaining its features. The loader and enumeration hunks here are ported from 20ee39de9a and credited with a Co-authored-by: trailer. mugurc has not opened a PR for that commit. Both commits are carried in the closed #7332.
  • Gonic0 explained on #10540 that enabling the subset also needs VkPhysicalDevicePortabilitySubsetFeaturesKHR chained into VkDeviceCreateInfo. Without it, the validation layer reports VUID-VkSamplerCreateInfo-samplerMipLodBias-04467. He offered mugurc a follow-up that does this: https://github.com/boykopovar/AnyPS5/pull/10540#issuecomment-6388121653 . The features part here follows that explanation. His follow-up was never published, so no code was taken from it.
  • #5021 (yabanana, open) carries the same three parts in b949b38295 ("feat(aot): run source-built graphics on native Apple ARM64", 2026-10-12), with the subset enabled without its features, inside a 100-commit AOT PR. It conflicts with this branch at these lines.
  • #7201 (marion909, "Macos port", open) does it differently in 840b4e7b50 ("feat(macos): render through MoltenVK", 2026-10-16). On macOS it tries several loader names and an ANYPS5_VULKAN_LIBRARY override, and it requests enumeration only when the instance lists it. It enables the subset without its features.
  • #8658 (iamthehimansh, closed) loads libvulkan.1.dylib and requests enumeration in 8d9b031ccb ("feat(agc): find MoltenVK through the macOS Vulkan loader", 2026-10-17). It does not enable the subset. None of the PRs it was split into (#10362, #10419, #11447 and the other split/macos-* branches) touches VulkanDevice.cpp.
  • #7332 (ycarogabriel-lgtm, closed) carries mugurc's two commits and adds a loader-name search in 245f177de7 (2026-10-18).
  • #7886 (merged) and #10920 (open) do the same for the tests that create their own instance or device. Neither touches the driver.

Tested

Apple M1 Pro, macOS 27.0.1, x86_64 Release build under Rosetta 2, MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363. main alone does not build on macOS, so the tree is mugurc's macOS series (ci/macos-series-2, 27e968974) merged with main at 2742004ed2, plus local build fixes for that merge (the FrameRecorder.cpp and ResidentHeapMirror.cpp changes from #10540, the StandardExceptions.cpp cast from #10419, the __tls_get_addr test excluded as in #10885) and #10898, all identical in the three variants. The PR is based on main 7cf8602234; its hunks are identical in both trees. That tree already carries mugurc's version of this change, so it was built three times, differing only in VulkanDevice.cpp (and the VK_ENABLE_BETA_EXTENSIONS line for the third):

  • without: mugurc's three hunks removed, i.e. main's code;
  • series: mugurc's version (loader, enumeration, subset extension without its features);
  • with: this PR.

All runs: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -E 'audio_in|voice' -V. No log has was not found but was requested by env var VK_INSTANCE_LAYERS.

without series with
agc_driver_image* (64 tests, 1 run) 1 pass, 63 fail 55 pass, 2 skip, 7 fail 55 pass, 2 skip, 7 fail
Validation Error lines in that run 0 114 22
focused (image_cache_bits, lazy_resolved_abi, native_multisample_depth), 3 runs 0/3 each 1/3 each 1/3 each
  • Without the change every driver test that opens the device stops at Vulkan loader: Failed loading libvulkan.so.1: dlopen(libvulkan.so.1, ...) (no such file).
  • series and with fail the same 7 agc_driver_image* tests, all failures this change does not touch and other open PRs address: image_cache_bits and image_texel_status (#10652), image_srgb_sample_copy and ..._forced (#10859), image_table_reuse and ..._draw_pipeline (#10651), and image_plane_bias_on_single_level_volume. In the focused set, lazy_resolved_abi fails in both because its child process loses DYLD_FALLBACK_LIBRARY_PATH (fixed by #10650), and image_cache_bits is the #10652 failure.
  • Validation, series → with: VUID-VkImageViewCreateInfo-imageViewFormatReinterpretation-04466 50 → 0, VUID-VkImageViewCreateInfo-imageViewFormatSwizzle-04465 41 → 0, VUID-VkImageCreateInfo-imageView2DOn3DImage-04459 1 → 0. The remaining 22 are the same in both: 13 VUID-vkCreateDescriptorSetLayout-support-09582 and 9 VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251. With the features chained, the validation layer checks against what MoltenVK reports instead of treating every subset feature as off. No VUID appears in with that is not in series. Against main's code (without, 0 Validation Error lines) the 22 are new only because those tests now reach a device at all: without stops before any Vulkan call. The two skips are agc_driver_image_atomics64 and agc_driver_image_sample_reduction, in both series and with.

Known gap, not changed here: MoltenVK reports pointPolygons as false, and State.cpp can still request VK_POLYGON_MODE_POINT (Pipeline.cpp checks only fillModeNonSolid and maintenance5). Before this PR the driver could not create a device on macOS at all; a check on pointPolygons or a debt entry belongs in a follow-up.

Not tested on Linux or Windows; there the loader name and instance flags are unchanged, and a device that does not advertise VK_KHR_portability_subset gets no new extension or struct.

uv run tools/check_conventions.py --base origin/main passes.

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 under Silent stubs in their library's technical debt file
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M1 Pro, MoltenVK 1.4.2 (LunarG Vulkan SDK 1.4.363), macOS 27.0.1
  • AI-assisted: yes

The first box: #5021 and #7201 also change these lines, but as parts of an AOT compiler and a whole macOS port. No open PR makes this change on its own.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5022814227 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11554). Originally posted by [maximilianfv](https://github.com/maximilianfv) on 2026-10-26T18:42:16Z. --- ### What On macOS the AGC driver cannot create a Vulkan device. `VulkanDevice` loads `libvulkan.so.1`, which does not exist there. Even with a loader, MoltenVK is a portability driver, and the loader lists it only for an instance created with `VK_KHR_portability_enumeration` and `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR`. This PR changes `Execution/src/VulkanDevice.cpp`, plus one line in `core/libs/prx/libSceAgcDriver/CMakeLists.txt` that defines `VK_ENABLE_BETA_EXTENSIONS` for that file only. `VkPhysicalDevicePortabilitySubsetFeaturesKHR` and its `VkStructureType` value are only declared under that define, the same way #10920 enables it for its test files: - On macOS it loads `libvulkan.1.dylib`. Windows and Linux keep `vulkan-1.dll` and `libvulkan.so.1`. - On macOS every instance requests `VK_KHR_portability_enumeration` and sets `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR`, with or without a window. The extension count and names are now set after the window block, so a windowless instance passes its list too (`nullptr` when it is empty). - A device that advertises `VK_KHR_portability_subset` must enable it. When the device advertises it, the driver enables it, queries `VkPhysicalDevicePortabilitySubsetFeaturesKHR` with `vkGetPhysicalDeviceFeatures2` and chains the reported values into `VkDeviceCreateInfo`. Without the chained struct, every subset feature counts as off, even the ones MoltenVK supports. Devices that do not advertise the subset, including every Linux and Windows driver I know of, take the same path as before. imellag reported on #10540 that booting titles on macOS from `main` needs a local `VulkanDevice.cpp` patch that loads `libvulkan.1.dylib` and enables portability enumeration, and that no open PR covers it: https://github.com/boykopovar/AnyPS5/pull/10540#issuecomment-6419715677 . This PR is that patch on its own. Prior work and credit: - mugurc wrote the loader and enumeration parts first, in `62917206d9` ("feat(macos): relink and run titles on macOS (x86-64 under Rosetta)", 2026-10-05), and then in `20ee39de9a` ("feat(agc): create the Vulkan device on MoltenVK", 2026-10-12) in the macOS series (`ci/macos-series-2`). Both also enable the subset extension, but without chaining its features. The loader and enumeration hunks here are ported from `20ee39de9a` and credited with a `Co-authored-by:` trailer. mugurc has not opened a PR for that commit. Both commits are carried in the closed #7332. - Gonic0 explained on #10540 that enabling the subset also needs `VkPhysicalDevicePortabilitySubsetFeaturesKHR` chained into `VkDeviceCreateInfo`. Without it, the validation layer reports `VUID-VkSamplerCreateInfo-samplerMipLodBias-04467`. He offered mugurc a follow-up that does this: https://github.com/boykopovar/AnyPS5/pull/10540#issuecomment-6388121653 . The features part here follows that explanation. His follow-up was never published, so no code was taken from it. - #5021 (yabanana, open) carries the same three parts in `b949b38295` ("feat(aot): run source-built graphics on native Apple ARM64", 2026-10-12), with the subset enabled without its features, inside a 100-commit AOT PR. It conflicts with this branch at these lines. - #7201 (marion909, "Macos port", open) does it differently in `840b4e7b50` ("feat(macos): render through MoltenVK", 2026-10-16). On macOS it tries several loader names and an `ANYPS5_VULKAN_LIBRARY` override, and it requests enumeration only when the instance lists it. It enables the subset without its features. - #8658 (iamthehimansh, closed) loads `libvulkan.1.dylib` and requests enumeration in `8d9b031ccb` ("feat(agc): find MoltenVK through the macOS Vulkan loader", 2026-10-17). It does not enable the subset. None of the PRs it was split into (#10362, #10419, #11447 and the other `split/macos-*` branches) touches `VulkanDevice.cpp`. - #7332 (ycarogabriel-lgtm, closed) carries mugurc's two commits and adds a loader-name search in `245f177de7` (2026-10-18). - #7886 (merged) and #10920 (open) do the same for the tests that create their own instance or device. Neither touches the driver. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Apple M1 Pro, macOS 27.0.1, x86_64 Release build under Rosetta 2, MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363. `main` alone does not build on macOS, so the tree is mugurc's macOS series (`ci/macos-series-2`, 27e968974) merged with `main` at 2742004ed2, plus local build fixes for that merge (the `FrameRecorder.cpp` and `ResidentHeapMirror.cpp` changes from #10540, the `StandardExceptions.cpp` cast from #10419, the `__tls_get_addr` test excluded as in #10885) and #10898, all identical in the three variants. The PR is based on `main` 7cf8602234; its hunks are identical in both trees. That tree already carries mugurc's version of this change, so it was built three times, differing only in `VulkanDevice.cpp` (and the `VK_ENABLE_BETA_EXTENSIONS` line for the third): - **without:** mugurc's three hunks removed, i.e. `main`'s code; - **series:** mugurc's version (loader, enumeration, subset extension without its features); - **with:** this PR. All runs: `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -E 'audio_in|voice' -V`. No log has `was not found but was requested by env var VK_INSTANCE_LAYERS`. | | without | series | with | |---|---|---|---| | `agc_driver_image*` (64 tests, 1 run) | 1 pass, 63 fail | 55 pass, 2 skip, 7 fail | 55 pass, 2 skip, 7 fail | | `Validation Error` lines in that run | 0 | 114 | 22 | | focused (`image_cache_bits`, `lazy_resolved_abi`, `native_multisample_depth`), 3 runs | 0/3 each | 1/3 each | 1/3 each | - Without the change every driver test that opens the device stops at `Vulkan loader: Failed loading libvulkan.so.1: dlopen(libvulkan.so.1, ...) (no such file)`. - `series` and `with` fail the same 7 `agc_driver_image*` tests, all failures this change does not touch and other open PRs address: `image_cache_bits` and `image_texel_status` (#10652), `image_srgb_sample_copy` and `..._forced` (#10859), `image_table_reuse` and `..._draw_pipeline` (#10651), and `image_plane_bias_on_single_level_volume`. In the focused set, `lazy_resolved_abi` fails in both because its child process loses `DYLD_FALLBACK_LIBRARY_PATH` (fixed by #10650), and `image_cache_bits` is the #10652 failure. - Validation, `series` → `with`: `VUID-VkImageViewCreateInfo-imageViewFormatReinterpretation-04466` 50 → 0, `VUID-VkImageViewCreateInfo-imageViewFormatSwizzle-04465` 41 → 0, `VUID-VkImageCreateInfo-imageView2DOn3DImage-04459` 1 → 0. The remaining 22 are the same in both: 13 `VUID-vkCreateDescriptorSetLayout-support-09582` and 9 `VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251`. With the features chained, the validation layer checks against what MoltenVK reports instead of treating every subset feature as off. No VUID appears in `with` that is not in `series`. Against `main`'s code (`without`, 0 `Validation Error` lines) the 22 are new only because those tests now reach a device at all: `without` stops before any Vulkan call. The two skips are `agc_driver_image_atomics64` and `agc_driver_image_sample_reduction`, in both `series` and `with`. Known gap, not changed here: MoltenVK reports `pointPolygons` as false, and `State.cpp` can still request `VK_POLYGON_MODE_POINT` (`Pipeline.cpp` checks only `fillModeNonSolid` and `maintenance5`). Before this PR the driver could not create a device on macOS at all; a check on `pointPolygons` or a debt entry belongs in a follow-up. Not tested on Linux or Windows; there the loader name and instance flags are unchanged, and a device that does not advertise `VK_KHR_portability_subset` gets no new extension or struct. `uv run tools/check_conventions.py --base origin/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: Apple M1 Pro, MoltenVK 1.4.2 (LunarG Vulkan SDK 1.4.363), macOS 27.0.1 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> The first box: #5021 and #7201 also change these lines, but as parts of an AOT compiler and a whole macOS port. No open PR makes this change on its own. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-26 18:44:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T18:44:42Z.

Review: CHANGES_REQUESTED


Two repository requirements still need attention before this is ready:\n\n1. Resolve and declare the overlap. VulkanDevice.cpp changes overlap the still-open #5021 and #7201 branches (the PR description also identifies the conflicts). CONTRIBUTING.md requires the authors to agree which change goes first and to declare that order with Depends on; the checklist currently says Depends on: none. Please coordinate the order and update the field, or resolve the overlapping hunks so the overlap no longer applies.\n\n2. Record the acknowledged MoltenVK gap. The PR description says MoltenVK reports pointPolygons false and that Pipeline.cpp can still request VK_POLYGON_MODE_POINT after checking only fillModeNonSolid and maintenance5. I confirmed the current pipeline guard does not check pointPolygons, and I could not find this gap in docs/dev/debt/libSceAgcDriver.md. AGENTS.md and CONTRIBUTING.md require known gaps to be recorded there. Please add the concise debt entry (or include a general guard that throws when the unsupported mode is requested).\n\nThe portability-subset feature query and device-create chain are present, and the current eligibility, conventions, intake, label, and report checks pass. The Linux/Windows product and relinker jobs are skipped by path policy; the detailed macOS/MoltenVK validation results in the PR description are therefore the available platform evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5657270159 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11554#pullrequestreview-5657270159). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T18:44:42Z. **Review:** CHANGES_REQUESTED --- Two repository requirements still need attention before this is ready:\n\n1. **Resolve and declare the overlap.** `VulkanDevice.cpp` changes overlap the still-open #5021 and #7201 branches (the PR description also identifies the conflicts). `CONTRIBUTING.md` requires the authors to agree which change goes first and to declare that order with `Depends on`; the checklist currently says `Depends on: none`. Please coordinate the order and update the field, or resolve the overlapping hunks so the overlap no longer applies.\n\n2. **Record the acknowledged MoltenVK gap.** The PR description says MoltenVK reports `pointPolygons` false and that `Pipeline.cpp` can still request `VK_POLYGON_MODE_POINT` after checking only `fillModeNonSolid` and `maintenance5`. I confirmed the current pipeline guard does not check `pointPolygons`, and I could not find this gap in `docs/dev/debt/libSceAgcDriver.md`. `AGENTS.md` and `CONTRIBUTING.md` require known gaps to be recorded there. Please add the concise debt entry (or include a general guard that throws when the unsupported mode is requested).\n\nThe portability-subset feature query and device-create chain are present, and the current eligibility, conventions, intake, label, and report checks pass. The Linux/Windows product and relinker jobs are skipped by path policy; the detailed macOS/MoltenVK validation results in the PR description are therefore the available platform evidence.
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!11554
No description provided.