macOS: full support — MoltenVK auto-discovery, portability fix, and KytyPS5.app bundle #394

Manually merged
github merged 7 commits from gh-pr/394/head into gh-pr/394/base 2026-11-26 09:18:43 +00:00
Owner

@⁠nacimoualla on GitHub · 2026-08-29 11:46 UTC · original
nacimoualla:macos/full-support → main · +155 −32 · 6 files · 7 commits · merged 2026-08-29 13:08 UTC

Summary

This PR brings macOS from experimental to first-class by fixing three long-standing papercuts and adding a proper application bundle. The emulator continues to target x86-64 under Rosetta 2 (guest JIT, zerofill guest address space), now with automatic MoltenVK discovery and a double-clickable app.

Commits:

  1. macOS: auto-discover bundled MoltenVK on startup (ae112b9 → 85a5c04)

    • On macOS the Vulkan loader comes from MoltenVK. SDL's default probe only searches system paths, so a bundled libMoltenVK.dylib next to the executable was invisible under the hardened runtime.
    • Now probes SDL_GetBasePath() + "libMoltenVK.dylib" before falling back to SDL's default search. Respects SDL_VULKAN_LIBRARY overrides and logs which loader is used. No error if the bundled file is missing — falls back to system loader.
    • Update README.md to remove the manual SDL_VULKAN_LIBRARY="$PWD/libMoltenVK.dylib" requirement.
  2. window: fix Vulkan portability enumeration on macOS (996c377 → 6b8adb5)

    • MoltenVK requires VK_KHR_portability_enumeration + VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR to surface portability devices. Without the flag vkEnumeratePhysicalDevices hides the MoltenVK adapter on some drivers, causing "Could not find suitable device".
    • Add the instance extension and flag when available, with diagnostic logs for all MoltenVK fallbacks (depthClipEnable, colorWriteEnable, depthBounds, fragmentShaderBarycentric).
    • Verified via otool -l and codesign --verify on Apple Silicon.
  3. macOS: add KytyPS5.app bundle packaging (ba6c251 → f294799)

    • src/launcher/Info.plist.in + src/launcher/CMakeLists.txt: launcher becomes KytyPS5.app (CFBundleIdentifier org.kytyps5.kytyps5, LSMinimumSystemVersion 13.0) with kyty_emulator as helper in Contents/MacOS (found via QCoreApplication::applicationDirPath()). MoltenVK is found via SDL_GetBasePath() in that directory.
    • Re-sign helper with JIT entitlements (src/macos_jit.entitlements) inside the bundle and invoke macdeployqt when available to deploy Qt frameworks to Contents/Frameworks.
    • Keep flat kyty_emulator for CLI usage.
    • .github/workflows/build.yml: bundle MoltenVK into KytyPS5.app/Contents/MacOS when present, verify bundle artifacts (file/lipo/codesign for both flat and bundle), and handle bundle paths in the release zip.
    • README.md: document open _Build/macos/install/KytyPS5.app and bundle MoltenVK locations.
  4. launcher: fix bundle rpath for Qt frameworks (7e61b97 → 6155ce8)

    • The bundle executable had @rpath references to Qt frameworks but no LC_RPATH, causing dyld abort: Library not loaded: @rpath/QtConcurrent.framework, Reason: no LC_RPATH's found (see crash report KytyPS5[57276], Mac16,12, macOS 26.2).
    • Set INSTALL_RPATH "@executable_path/../Frameworks" and BUILD_WITH_INSTALL_RPATH so the built and installed bundles resolve Qt from Contents/Frameworks. Verified via otool -l | grep LC_RPATH and macdeployqt now succeeds.

Testing

  • Configure & build (Apple Silicon, Rosetta, Qt 6.11.2 universal):
    cmake -S . -B _Build/macos -G Ninja -DCMAKE_BUILD_TYPE=Release     -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_PREFIX_PATH="$HOME/Qt/6.11.2/macos"
    cmake --build _Build/macos --target launcher --parallel
    cmake --install _Build/macos --prefix _Build/macos/install
    
  • Artifacts verified: file shows Mach-O x86_64 for KytyPS5/kyty_emulator, lipo -verify_arch x86_64 passes, codesign --verify --strict passes for helper, bundle, and libMoltenVK.dylib (universal x86_64+arm64), otool -l shows LC_RPATH @executable_path/../Frameworks.
  • Runtime: open _Build/macos/install/KytyPS5.app launches GUI (previously crashed with DYLD Library missing). Flat kyty_emulator --game finds bundled libMoltenVK.dylib without SDL_VULKAN_LIBRARY. ctest -R virtual_memory_allocation passes on macos_x86.

Notes

  • Homebrew Qt is arm64-only and will not link for -DCMAKE_OSX_ARCHITECTURES=x86_64; official Qt universal is required (README already documents this).
  • page_manager_tests/memory_tracker_tests use MAP_FIXED_NOREPLACE (Linux-only) and are intentionally not built on macOS.
  • No changes to Windows/Linux code paths (all macOS changes guarded by #if defined(__APPLE__) or if(APPLE)).

AI disclosure

AI tools were used for research and drafting. All code was reviewed, built, and tested locally on Apple Silicon (M4, macOS 26.2) under Rosetta 2 as described above. The contributor understands and is responsible for the correctness of the changes.

**@⁠nacimoualla** on GitHub · 2026-08-29 11:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394) `nacimoualla:macos/full-support` → `main` · +155 −32 · 6 files · 7 commits · merged 2026-08-29 13:08 UTC ## Summary This PR brings macOS from experimental to first-class by fixing three long-standing papercuts and adding a proper application bundle. The emulator continues to target x86-64 under Rosetta 2 (guest JIT, zerofill guest address space), now with automatic MoltenVK discovery and a double-clickable app. **Commits:** 1. **macOS: auto-discover bundled MoltenVK on startup** (`ae112b9` → `85a5c04`) - On macOS the Vulkan loader comes from MoltenVK. SDL's default probe only searches system paths, so a bundled `libMoltenVK.dylib` next to the executable was invisible under the hardened runtime. - Now probes `SDL_GetBasePath() + "libMoltenVK.dylib"` before falling back to SDL's default search. Respects `SDL_VULKAN_LIBRARY` overrides and logs which loader is used. No error if the bundled file is missing — falls back to system loader. - Update `README.md` to remove the manual `SDL_VULKAN_LIBRARY="$PWD/libMoltenVK.dylib"` requirement. 2. **window: fix Vulkan portability enumeration on macOS** (`996c377` → `6b8adb5`) - MoltenVK requires `VK_KHR_portability_enumeration` + `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` to surface portability devices. Without the flag `vkEnumeratePhysicalDevices` hides the MoltenVK adapter on some drivers, causing "Could not find suitable device". - Add the instance extension and flag when available, with diagnostic logs for all MoltenVK fallbacks (depthClipEnable, colorWriteEnable, depthBounds, fragmentShaderBarycentric). - Verified via `otool -l` and `codesign --verify` on Apple Silicon. 3. **macOS: add KytyPS5.app bundle packaging** (`ba6c251` → `f294799`) - `src/launcher/Info.plist.in` + `src/launcher/CMakeLists.txt`: launcher becomes `KytyPS5.app` (`CFBundleIdentifier org.kytyps5.kytyps5`, `LSMinimumSystemVersion 13.0`) with `kyty_emulator` as helper in `Contents/MacOS` (found via `QCoreApplication::applicationDirPath()`). MoltenVK is found via `SDL_GetBasePath()` in that directory. - Re-sign helper with JIT entitlements (`src/macos_jit.entitlements`) inside the bundle and invoke `macdeployqt` when available to deploy Qt frameworks to `Contents/Frameworks`. - Keep flat `kyty_emulator` for CLI usage. - `.github/workflows/build.yml`: bundle MoltenVK into `KytyPS5.app/Contents/MacOS` when present, verify bundle artifacts (`file/lipo/codesign` for both flat and bundle), and handle bundle paths in the release zip. - `README.md`: document `open _Build/macos/install/KytyPS5.app` and bundle MoltenVK locations. 4. **launcher: fix bundle rpath for Qt frameworks** (`7e61b97` → `6155ce8`) - The bundle executable had `@rpath` references to Qt frameworks but no `LC_RPATH`, causing dyld abort: `Library not loaded: @rpath/QtConcurrent.framework, Reason: no LC_RPATH's found` (see crash report `KytyPS5[57276]`, `Mac16,12`, `macOS 26.2`). - Set `INSTALL_RPATH "@executable_path/../Frameworks"` and `BUILD_WITH_INSTALL_RPATH` so the built and installed bundles resolve Qt from `Contents/Frameworks`. Verified via `otool -l | grep LC_RPATH` and `macdeployqt` now succeeds. ## Testing - **Configure & build (Apple Silicon, Rosetta, Qt 6.11.2 universal):** ```bash cmake -S . -B _Build/macos -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_PREFIX_PATH="$HOME/Qt/6.11.2/macos" cmake --build _Build/macos --target launcher --parallel cmake --install _Build/macos --prefix _Build/macos/install ``` - **Artifacts verified:** `file` shows `Mach-O x86_64` for `KytyPS5`/`kyty_emulator`, `lipo -verify_arch x86_64` passes, `codesign --verify --strict` passes for helper, bundle, and `libMoltenVK.dylib` (universal `x86_64+arm64`), `otool -l` shows `LC_RPATH @executable_path/../Frameworks`. - **Runtime:** `open _Build/macos/install/KytyPS5.app` launches GUI (previously crashed with `DYLD Library missing`). Flat `kyty_emulator --game` finds bundled `libMoltenVK.dylib` without `SDL_VULKAN_LIBRARY`. `ctest -R virtual_memory_allocation` passes on `macos_x86`. ## Notes - Homebrew Qt is arm64-only and will not link for `-DCMAKE_OSX_ARCHITECTURES=x86_64`; official Qt universal is required (README already documents this). - `page_manager_tests`/`memory_tracker_tests` use `MAP_FIXED_NOREPLACE` (Linux-only) and are intentionally not built on macOS. - No changes to Windows/Linux code paths (all macOS changes guarded by `#if defined(__APPLE__)` or `if(APPLE)`). ## AI disclosure AI tools were used for research and drafting. All code was reviewed, built, and tested locally on Apple Silicon (M4, macOS 26.2) under Rosetta 2 as described above. The contributor understands and is responsible for the correctness of the changes.
On macOS the Vulkan loader comes from MoltenVK. SDL's default
probe only searches system paths, so a bundled libMoltenVK.dylib
next to the executable is invisible under the hardened runtime.

Probe it explicitly via SDL_GetBasePath() before falling back to
SDL's default search. Respect SDL_VULKAN_LIBRARY overrides and
log which loader is used. Update README to reflect that no
environment variable is required for bundled builds.

Co-Authored-By: internal-model
MoltenVK requires VK_KHR_portability_enumeration and
VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR to surface
portability devices via enumeratePhysicalDevices. Without the flag
the adapter is hidden on some driver versions, causing
"Could not find suitable device" failures.

Add the instance extension and flag when available, and add
diagnostic logs for all MoltenVK fallbacks (depthClipEnable,
colorWriteEnable, depthBounds, fragmentShaderBarycentric)
so black-screen diagnostics are actionable.
Add a proper macOS application bundle when the launcher is built.
launcher becomes KytyPS5.app (CFBundleIdentifier org.kytyps5.kytyps5)
with KytyPS5 as the executable, and kyty_emulator is installed as a
helper inside Contents/MacOS so QCoreApplication::applicationDirPath()
finds it. MoltenVK is auto-discovered via SDL_GetBasePath() in that
directory, so no SDL_VULKAN_LIBRARY is required.

- src/launcher/Info.plist.in: minimal bundle plist (version from
  PROJECT_VERSION, LSMinimumSystemVersion 13.0).
- src/launcher/CMakeLists.txt: set MACOSX_BUNDLE, BUNDLE DESTINATION,
  install helper, re-sign helper with JIT entitlements, and invoke
  macdeployqt when available. Keep flat kyty_emulator for CLI.
- .github/workflows/build.yml: bundle MoltenVK into
  KytyPS5.app/Contents/MacOS when present, verify bundle artifacts
  (file/lipo/codesign), and handle bundle paths in the release zip.
- README.md: document bundle double-click and MoltenVK locations.
The bundle executable had @rpath references to Qt frameworks but no
LC_RPATH, causing dyld to abort at launch:

  Library not loaded: @rpath/QtConcurrent.framework
  Reason: no LC_RPATH's found

Set INSTALL_RPATH to @executable_path/../Frameworks and
BUILD_WITH_INSTALL_RPATH so the built and installed bundles
resolve Qt from Contents/Frameworks. Verified via otool -l
(LC_RPATH now present) and macdeployqt now succeeds without
"Cannot resolve rpath" errors.
Add a prominent Import button to ConfigurationListWidget that lets
users select a game folder (containing eboot.bin) or a folder
containing multiple games via QFileDialog. Handles:

- Single game folder selected: adds its parent to game_dirs (Scan
  searches subdirectories, so parent is needed)
- Folder with multiple games: adds the selected folder
- Deduplication via PathKey/NormalizeGameDirectories, writes
  settings, rescans, and selects the imported game if found
- Shows info/warning dialogs when no games are found

UI: QToolButton with SP_DirOpenIcon and text Import beside the
existing toolbar, styled with a blue background for visibility.
Logic in ConfigurationListWidget::import_game().
This reverts commit 2f670ef95c.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:18:42 +00:00
github manually merged commit dc899127f8 into gh-pr/394/base 2026-11-26 09:18:43 +00:00
Author
Owner

@⁠Nmzik on GitHub · 2026-08-29 12:54 UTC · original · edited 2026-08-29 12:55 UTC

@⁠nacimoualla I cleaned it up a bit. Please pull the latest changes and check them locally. CI is good. Im ready to merge as soon as everything looks good on your side

**@⁠Nmzik** on GitHub · 2026-08-29 12:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462527880) · edited 2026-08-29 12:55 UTC @⁠nacimoualla I cleaned it up a bit. Please pull the latest changes and check them locally. CI is good. Im ready to merge as soon as everything looks good on your side
Author
Owner

@⁠nacimoualla on GitHub · 2026-08-29 12:59 UTC · original

@⁠Nmzik Hi thanks for your changes but can I ask you if you can make this branch because Mac support need a lot of work

**@⁠nacimoualla** on GitHub · 2026-08-29 12:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462549173) @⁠Nmzik Hi thanks for your changes but can I ask you if you can make this branch because Mac support need a lot of work
Author
Owner

@⁠Nmzik on GitHub · 2026-08-29 13:03 UTC · original · edited 2026-08-29 13:04 UTC

@⁠nacimoualla Please stop. Don’t make any more commits for now.

I understand that macOS requires some additional changes, but let’s split things up first. Please check the current changes in this PR by pulling my fixes.

Your renderer fixes should go into a separate PR later, so please keep those changes separate for now.

For now, only pull the latest changes (don’t push anything) and test locally on your Mac to see if the launcher is working.

**@⁠Nmzik** on GitHub · 2026-08-29 13:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462569889) · edited 2026-08-29 13:04 UTC @⁠nacimoualla Please stop. Don’t make any more commits for now. I understand that macOS requires some additional changes, but let’s split things up first. Please check the current changes in this PR by pulling my fixes. Your renderer fixes should go into a separate PR later, so please keep those changes separate for now. For now, only pull the latest changes (don’t push anything) and test locally on your Mac to see if the launcher is working.
Author
Owner

@⁠nacimoualla on GitHub · 2026-08-29 13:05 UTC · original

@⁠Nmzik yes and sorry for this error I did revert all the changes that I made after you now it's clean

**@⁠nacimoualla** on GitHub · 2026-08-29 13:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462578296) @⁠Nmzik yes and sorry for this error I did revert all the changes that I made after you now it's clean
Author
Owner

@⁠Nmzik on GitHub · 2026-08-29 13:07 UTC · original

@⁠nacimoualla launcher is working on your Mac with all changes in PR? Can you confirm?

**@⁠Nmzik** on GitHub · 2026-08-29 13:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462585240) @⁠nacimoualla launcher is working on your Mac with all changes in PR? Can you confirm?
Author
Owner

@⁠nacimoualla on GitHub · 2026-08-29 13:07 UTC · original

@⁠nacimoualla launcher is working on your Mac with all changes in PR? Can you confirm?

yes it work natively on apple silicon chip m4

**@⁠nacimoualla** on GitHub · 2026-08-29 13:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462588089) > @⁠nacimoualla launcher is working on your Mac with all changes in PR? Can you confirm? yes it work natively on apple silicon chip m4
Author
Owner

@⁠Nmzik on GitHub · 2026-08-29 13:09 UTC · original

@⁠nacimoualla Super, I merged it. Now please create a separate PR with the renderer fixes.
Please keep your changes small, compact, and simple. I’ll be happy to accept them.

**@⁠Nmzik** on GitHub · 2026-08-29 13:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/394#issuecomment-5462594892) @⁠nacimoualla Super, I merged it. Now please create a separate PR with the renderer fixes. Please keep your changes small, compact, and simple. I’ll be happy to accept them.
This discussion has been locked. Commenting is limited to contributors.
No description provided.