[PR #294] [MERGED] Add macOS support #1457

Closed
opened 2026-02-27 21:12:38 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/294
Author: @squidbus
Created: 7/15/2024
Status: Merged
Merged: 7/21/2024
Merged by: @raphaelthegreat

Base: mainHead: main


📝 Commits (10+)

  • 3d572a6 Add initial macOS support.
  • 7e25149 Fix one-off bug with user data registers.
  • f40d3c2 Migrate TLS patches to new patching system.
  • 2a72b9a Downgrade Vulkan requirement to 1.2 with extensions.
  • a50e118 Add fallback system for unsupported pixel formats.
  • 0009c7c Remap SDL face buttons to be usable without a keypad.
  • 29077eb Add GitHub Actions workflows for macOS.
  • 0aded5c Set minimum macOS target to 11 and fix compile errors.
  • 3def73b Tidy up Vulkan extension list.
  • 65c54bf Change format list from vector to array/span.

📊 Changes

44 files changed (+1168 additions, -236 deletions)

View changed files

.github/workflows/macos-qt.yml (+63 -0)
.github/workflows/macos.yml (+56 -0)
📝 .gitmodules (+3 -0)
📝 CMakeLists.txt (+31 -1)
📝 externals/CMakeLists.txt (+7 -0)
externals/date (+1 -0)
📝 src/common/path_util.cpp (+35 -0)
📝 src/common/thread.cpp (+1 -0)
📝 src/core/address_space.cpp (+116 -22)
📝 src/core/address_space.h (+42 -10)
src/core/cpu_patches.cpp (+407 -0)
src/core/cpu_patches.h (+15 -0)
📝 src/core/libraries/gnmdriver/gnmdriver.cpp (+6 -5)
📝 src/core/libraries/kernel/event_flag/event_flag_obj.cpp (+2 -1)
📝 src/core/libraries/kernel/event_queue.cpp (+1 -0)
📝 src/core/libraries/kernel/libkernel.cpp (+10 -1)
📝 src/core/libraries/kernel/memory_management.cpp (+6 -1)
📝 src/core/libraries/kernel/thread_management.cpp (+35 -1)
📝 src/core/libraries/kernel/threads/keys.cpp (+4 -1)
📝 src/core/libraries/kernel/time_management.cpp (+1 -0)

...and 24 more files

📄 Description

Adds basic support for macOS. Currently requires a minimum of macOS 11 for Intel Macs, and macOS 15 for M series Macs for the AVX support added to Rosetta 2.

Summary of changes:

  • Fixes for some compile issues on macOS, such as missing includes and lack of std::chrono::time_zone
  • CPU/HLE changes:
    • Address space mapping code paths for missing memfd_create and inability to map to the desired fixed location
    • Code patches for missing BMI1 instructions when running under Rosetta 2. Rather than using fixed byte patterns, it uses Zydis to disassemble and search for instructions
    • Thread local storage patches for macOS. Also moved these patches to the new system created for the other code patches
    • Using SIGBUS for the texture cache signal handler instead of SIGSEGV
    • pthread_mutex_timedlock polyfill when unavailable
  • GPU changes:
    • Reducing the requirements from Vulkan 1.3 to Vulkan 1.2 with the needed extensions that were rolled into 1.3, as MoltenVK has not reached full 1.3 support yet
    • Support for Metal-based Vulkan surfaces
    • Support for using alternative formats and swizzles when a surface format is unavailable
    • Fix for an off-by-one issue with accessing shader user data
  • Misc
    • SDL face button mappings that are usable on keyboards without a keypad, e.g. Macbook keyboards
    • GitHub Actions workflows for macOS builds

Updated TLS patches are not fully tested on other platforms as I'm not currently set up to do so.

screenshot

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/294 **Author:** [@squidbus](https://github.com/squidbus) **Created:** 7/15/2024 **Status:** ✅ Merged **Merged:** 7/21/2024 **Merged by:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`3d572a6`](https://github.com/shadps4-emu/shadPS4/commit/3d572a6d06adfe61f1f08bd7e38d8f711d2b1bb5) Add initial macOS support. - [`7e25149`](https://github.com/shadps4-emu/shadPS4/commit/7e2514930e72fba79c9b8a2a13eb52f6b7146212) Fix one-off bug with user data registers. - [`f40d3c2`](https://github.com/shadps4-emu/shadPS4/commit/f40d3c28665f1522fb064dd5ee415eb6e4ec368c) Migrate TLS patches to new patching system. - [`2a72b9a`](https://github.com/shadps4-emu/shadPS4/commit/2a72b9a3d6b324589328d0542859a87ab03b97b1) Downgrade Vulkan requirement to 1.2 with extensions. - [`a50e118`](https://github.com/shadps4-emu/shadPS4/commit/a50e118808eebf94060f8ff8ca35fc6da2fca406) Add fallback system for unsupported pixel formats. - [`0009c7c`](https://github.com/shadps4-emu/shadPS4/commit/0009c7ca7952abeb8f4e551e7e9598226259ecf9) Remap SDL face buttons to be usable without a keypad. - [`29077eb`](https://github.com/shadps4-emu/shadPS4/commit/29077eb3165bbeff6230adadcd9a6eb63441d47f) Add GitHub Actions workflows for macOS. - [`0aded5c`](https://github.com/shadps4-emu/shadPS4/commit/0aded5c1693d51de20df853a79655e7b149f049e) Set minimum macOS target to 11 and fix compile errors. - [`3def73b`](https://github.com/shadps4-emu/shadPS4/commit/3def73b5a3fdc4c6d4fa4c2c11c504768978f11a) Tidy up Vulkan extension list. - [`65c54bf`](https://github.com/shadps4-emu/shadPS4/commit/65c54bfc1ececf55a52d24f8c90bd1f99cece88b) Change format list from vector to array/span. ### 📊 Changes **44 files changed** (+1168 additions, -236 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/macos-qt.yml` (+63 -0) ➕ `.github/workflows/macos.yml` (+56 -0) 📝 `.gitmodules` (+3 -0) 📝 `CMakeLists.txt` (+31 -1) 📝 `externals/CMakeLists.txt` (+7 -0) ➕ `externals/date` (+1 -0) 📝 `src/common/path_util.cpp` (+35 -0) 📝 `src/common/thread.cpp` (+1 -0) 📝 `src/core/address_space.cpp` (+116 -22) 📝 `src/core/address_space.h` (+42 -10) ➕ `src/core/cpu_patches.cpp` (+407 -0) ➕ `src/core/cpu_patches.h` (+15 -0) 📝 `src/core/libraries/gnmdriver/gnmdriver.cpp` (+6 -5) 📝 `src/core/libraries/kernel/event_flag/event_flag_obj.cpp` (+2 -1) 📝 `src/core/libraries/kernel/event_queue.cpp` (+1 -0) 📝 `src/core/libraries/kernel/libkernel.cpp` (+10 -1) 📝 `src/core/libraries/kernel/memory_management.cpp` (+6 -1) 📝 `src/core/libraries/kernel/thread_management.cpp` (+35 -1) 📝 `src/core/libraries/kernel/threads/keys.cpp` (+4 -1) 📝 `src/core/libraries/kernel/time_management.cpp` (+1 -0) _...and 24 more files_ </details> ### 📄 Description Adds basic support for macOS. Currently requires a minimum of macOS 11 for Intel Macs, and macOS 15 for M series Macs for the AVX support added to Rosetta 2. Summary of changes: * Fixes for some compile issues on macOS, such as missing includes and lack of `std::chrono::time_zone` * CPU/HLE changes: * Address space mapping code paths for missing `memfd_create` and inability to map to the desired fixed location * Code patches for missing BMI1 instructions when running under Rosetta 2. Rather than using fixed byte patterns, it uses Zydis to disassemble and search for instructions * Thread local storage patches for macOS. Also moved these patches to the new system created for the other code patches * Using `SIGBUS` for the texture cache signal handler instead of `SIGSEGV` * `pthread_mutex_timedlock` polyfill when unavailable * GPU changes: * Reducing the requirements from Vulkan 1.3 to Vulkan 1.2 with the needed extensions that were rolled into 1.3, as MoltenVK has not reached full 1.3 support yet * Support for Metal-based Vulkan surfaces * Support for using alternative formats and swizzles when a surface format is unavailable * Fix for an off-by-one issue with accessing shader user data * Misc * SDL face button mappings that are usable on keyboards without a keypad, e.g. Macbook keyboards * GitHub Actions workflows for macOS builds Updated TLS patches are not fully tested on other platforms as I'm not currently set up to do so. <img width="1299" alt="screenshot" src="https://github.com/user-attachments/assets/f52c4f2a-dc43-4a91-96d6-230ab9b8ba11"> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:12:38 +03:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
starred/shadPS4#1457
No description provided.