diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34f3005f7..9d5af4caa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,7 +74,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + os: [windows-latest, ubuntu-latest, macos-26] include: - os: windows-latest compiler_cxx: clang-cl @@ -82,7 +82,7 @@ jobs: - os: ubuntu-latest compiler_cxx: clang++ compiler_c: clang - - os: macos-latest + - os: macos-26 compiler_cxx: clang++ compiler_c: clang @@ -187,7 +187,7 @@ jobs: path: ${{github.workspace}}/build/shadPS4.exe macos-sdl: - runs-on: macos-15 + runs-on: macos-26 needs: get-info steps: - uses: actions/checkout@v6 @@ -199,6 +199,11 @@ jobs: with: xcode-version: latest + - name: Install Build Dependencies + run: | + brew install cmake meson pkg-config llvm spirv-tools spirv-llvm-translator libclc + pip3 install --break-system-packages mako packaging pyyaml + - name: Cache CMake Configuration uses: actions/cache@v5 env: diff --git a/.gitmodules b/.gitmodules index b0b663c6b..2fabb2873 100644 --- a/.gitmodules +++ b/.gitmodules @@ -150,3 +150,8 @@ [submodule "externals/mesa-kosmickrisp"] path = externals/mesa-kosmickrisp url = https://github.com/shadexternals/mesa-kosmickrisp + shallow = true +[submodule "externals/vulkan-loader"] + path = externals/vulkan-loader + url = https://github.com/KhronosGroup/Vulkan-Loader + shallow = true diff --git a/CMakeLists.txt b/CMakeLists.txt index 89878147b..8dda0d0b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,9 @@ if(UNIX AND NOT APPLE) endif() endif() +include(CMakeDependentOption) +cmake_dependent_option(ENABLE_SYSTEM_VULKAN "Enable the system Vulkan driver" OFF APPLE OFF) + option(ENABLE_DISCORD_RPC "Enable the Discord RPC integration" ON) option(ENABLE_UPDATER "Enables the options to updater" ON) option(ENABLE_TESTS "Build unit tests (requires GTest)" OFF) @@ -1216,10 +1219,30 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") endif() if (APPLE) - # Bundle Vulkan loader and KosmicKrisp driver with the emulator. - set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path") - add_subdirectory(externals/mesa-kosmickrisp) - AddCopyKosmicKrisp(shadps4 ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + if (NOT ENABLE_SYSTEM_VULKAN) + # Bundle Vulkan loader and KosmicKrisp driver with the emulator. + set_property(TARGET shadps4 APPEND PROPERTY BUILD_RPATH "@executable_path") + + set(LOADER_DEST "${CMAKE_CURRENT_BINARY_DIR}/libvulkan.dylib") + set(DRIVER_DEST "${CMAKE_CURRENT_BINARY_DIR}/libvulkan_kosmickrisp.dylib") + set(ICD_DEST "${CMAKE_CURRENT_BINARY_DIR}/kosmickrisp_mesa_icd.json") + + add_custom_command( + OUTPUT ${LOADER_DEST} + DEPENDS ${VULKAN_LOADER_PATH} vulkan + COMMAND ${CMAKE_COMMAND} -E copy ${VULKAN_LOADER_PATH} ${LOADER_DEST}) + add_custom_command( + OUTPUT ${DRIVER_DEST} + DEPENDS ${VULKAN_DRIVER_PATH} kosmickrisp + COMMAND ${CMAKE_COMMAND} -E copy ${VULKAN_DRIVER_PATH} ${DRIVER_DEST}) + add_custom_command( + OUTPUT ${ICD_DEST} + DEPENDS ${VULKAN_ICD_PATH} kosmickrisp + COMMAND ${CMAKE_COMMAND} -E copy ${VULKAN_ICD_PATH} ${ICD_DEST}) + + add_custom_target(CopyVulkanDriver DEPENDS ${LOADER_DEST} ${DRIVER_DEST} ${ICD_DEST}) + add_dependencies(shadps4 CopyVulkanDriver) + endif() if (ARCHITECTURE STREQUAL "x86_64") # Reserve system-managed memory space. diff --git a/documents/building-macos.md b/documents/building-macos.md index a36988ce1..6425f6089 100644 --- a/documents/building-macos.md +++ b/documents/building-macos.md @@ -25,6 +25,12 @@ Then, use Homebrew to install the required build tools: brew install clang-format cmake ``` +Finally, install the dependencies required for building the KosmicKrisp Vulkan driver. You can skip this by setting `-DENABLE_SYSTEM_VULKAN=ON` when configuring, but you are responsible for having a compatible Vulkan setup installed. +``` +brew install meson ninja pkg-config llvm spirv-tools spirv-llvm-translator libclc +pip3 install --break-system-packages mako packaging pyyaml +``` + ### Cloning and compiling: Clone the repository recursively: diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index a7660bbc2..42d87d691 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -87,6 +87,7 @@ endif() if (NOT TARGET Vulkan::Headers) set(VULKAN_HEADERS_ENABLE_MODULE OFF) add_subdirectory(vulkan-headers) + set(VulkanHeaders_VERSION "1.4.330") endif() # VMA @@ -370,3 +371,13 @@ if (DEFINED SSL_DEPENDENCIES) else() message(STATUS "cpp-httplib: OpenSSL/LibreSSL not available — libSceHttp HTTPS will fall back to mock at runtime.") endif() + +# macOS Vulkan driver +if (APPLE AND NOT ENABLE_SYSTEM_VULKAN) + add_subdirectory(vulkan-loader) + set(VULKAN_LOADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/vulkan-loader/loader/libvulkan.dylib" PARENT_SCOPE) + + add_subdirectory(mesa-kosmickrisp) + set(VULKAN_DRIVER_PATH "${CMAKE_CURRENT_BINARY_DIR}/mesa-kosmickrisp/outputs/libvulkan_kosmickrisp.dylib" PARENT_SCOPE) + set(VULKAN_ICD_PATH "${CMAKE_CURRENT_BINARY_DIR}/mesa-kosmickrisp/outputs/kosmickrisp_mesa_icd.json" PARENT_SCOPE) +endif() diff --git a/externals/mesa-kosmickrisp b/externals/mesa-kosmickrisp index 801e2de8e..73e64c4fc 160000 --- a/externals/mesa-kosmickrisp +++ b/externals/mesa-kosmickrisp @@ -1 +1 @@ -Subproject commit 801e2de8ef2e3e89fd7ee1da52d67a1294ad6135 +Subproject commit 73e64c4fc8468a786700ae4cec97aba4a341ff2b diff --git a/externals/vulkan-loader b/externals/vulkan-loader new file mode 160000 index 000000000..466498bc6 --- /dev/null +++ b/externals/vulkan-loader @@ -0,0 +1 @@ +Subproject commit 466498bc64eb77955c3b782f0127520548224de0