mirror of
https://github.com/Vita3K/Vita3K-Android.git
synced 2025-02-21 13:51:26 +00:00
vita3k: Bring back the macOS build.
Co-Authored-By: Zangetsu <dante38@free.fr> Co-Authored-By: Seungyun Lee <khora.lee.0@gmail.com>
This commit is contained in:
parent
8812eaf2d0
commit
6c46e0aa40
8
.github/workflows/c-cpp.yml
vendored
8
.github/workflows/c-cpp.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
config: [Release]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
@ -34,6 +34,10 @@ jobs:
|
||||
C:\vcpkg\packages
|
||||
extra_cmake_args: -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
|
||||
cmake_preset: windows-ninja
|
||||
- os: macos-latest
|
||||
cache_path: ~/Library/Caches/ccache
|
||||
extra_cmake_args:
|
||||
cmake_preset: macos-ninja
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@ -43,7 +47,7 @@ jobs:
|
||||
|
||||
- name: Set up build environment (macos-latest)
|
||||
run: |
|
||||
brew install boost ccache ninja
|
||||
brew install boost ccache ninja molten-vk openssl
|
||||
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
|
||||
if: matrix.os == 'macos-latest'
|
||||
|
||||
|
@ -288,6 +288,48 @@
|
||||
"description": "Build with compiler optimizations enabled and no debugging information",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "linux-ninja-gnu"
|
||||
},
|
||||
{
|
||||
"name": "macos-ninja-debug",
|
||||
"displayName": "Debug",
|
||||
"description": "Build with debugging information and no compiler optimizations",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-ninja"
|
||||
},
|
||||
{
|
||||
"name": "macos-ninja-relwithdebinfo",
|
||||
"displayName": "Release with debugging information",
|
||||
"description": "Build with compiler optimizations enabled and limited debugging information",
|
||||
"configuration": "RelWithDebInfo",
|
||||
"configurePreset": "macos-ninja"
|
||||
},
|
||||
{
|
||||
"name": "macos-ninja-release",
|
||||
"displayName": "Release",
|
||||
"description": "Build with compiler optimizations enabled and no debugging information",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "macos-ninja"
|
||||
},
|
||||
{
|
||||
"name": "macos-xcode-debug",
|
||||
"displayName": "Debug",
|
||||
"description": "Build with debugging information and no compiler optimizations",
|
||||
"configuration": "Debug",
|
||||
"configurePreset": "macos-xcode"
|
||||
},
|
||||
{
|
||||
"name": "macos-xcode-relwithdebinfo",
|
||||
"displayName": "Release with debugging information",
|
||||
"description": "Build with compiler optimizations enabled and limited debugging information",
|
||||
"configuration": "RelWithDebInfo",
|
||||
"configurePreset": "macos-xcode"
|
||||
},
|
||||
{
|
||||
"name": "macos-xcode-release",
|
||||
"displayName": "Release",
|
||||
"description": "Build with compiler optimizations enabled and no debugging information",
|
||||
"configuration": "Release",
|
||||
"configurePreset": "macos-xcode"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
## Introduction
|
||||
|
||||
Vita3K is an experimental PlayStation Vita emulator for Windows and Linux.
|
||||
Vita3K is an experimental PlayStation Vita emulator for Windows, Linux and macOS.
|
||||
|
||||
* [Website](https://vita3k.org/) (information for users)
|
||||
* [Wiki](https://github.com/Vita3K/Vita3K/wiki) (information for developers)
|
||||
|
@ -71,8 +71,6 @@ If you aren't satisfied with the way the Visual Studio integrates CMake projects
|
||||
|
||||
## macOS (Xcode)
|
||||
|
||||
**Note: As of June 2022, running Vita3K in macOS is considered unsupported due to incompatibilities with the OpenGL implementation.**
|
||||
|
||||
- Install Xcode at App Store.
|
||||
|
||||
- Install [`brew`](https://brew.sh).
|
||||
@ -80,7 +78,7 @@ If you aren't satisfied with the way the Visual Studio integrates CMake projects
|
||||
- Install dependencies with `brew`.
|
||||
|
||||
```sh
|
||||
brew install git cmake
|
||||
brew install git cmake molten-vk openssl
|
||||
```
|
||||
|
||||
- Clone this repo.
|
||||
|
5
external/CMakeLists.txt
vendored
5
external/CMakeLists.txt
vendored
@ -272,6 +272,11 @@ set_property(TARGET psvpfsparser PROPERTY FOLDER externals)
|
||||
set_property(TARGET libzRIF PROPERTY FOLDER externals)
|
||||
set_property(TARGET libb64 PROPERTY FOLDER externals)
|
||||
|
||||
if(APPLE)
|
||||
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
|
||||
set(OPENSSL_LIBRARIES "/usr/local/opt/openssl/lib")
|
||||
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
endif()
|
||||
find_package(OpenSSL QUIET)
|
||||
|
||||
if(NOT OPENSSL_FOUND)
|
||||
|
@ -181,6 +181,16 @@ if(APPLE)
|
||||
set(MACOSX_BUNDLE_ICON_FILE Vita3K.icns)
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.github.Vita3K.Vita3K")
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME "Vita3K")
|
||||
|
||||
# taken from https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/DolphinQt/CMakeLists.txt
|
||||
find_file(MOLTENVK_DYLIB NAMES libMoltenVK.dylib PATH_SUFFIXES lib)
|
||||
if(NOT MOLTENVK_DYLIB)
|
||||
message(FATAL_ERROR "Couldn't find libMoltenVK.dylib.")
|
||||
else()
|
||||
message("Found Molten-VK dylib: ${MOLTENVK_DYLIB}")
|
||||
endif()
|
||||
target_sources(vita3k PRIVATE ${MOLTENVK_DYLIB})
|
||||
set_source_files_properties(${MOLTENVK_DYLIB} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks)
|
||||
elseif(LINUX)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
|
||||
add_custom_command(
|
||||
|
@ -118,10 +118,16 @@ bool init(EmuEnvState &state, Config &cfg, const Root &root_paths) {
|
||||
state.pref_path = string_utils::utf_to_wide(state.cfg.pref_path);
|
||||
}
|
||||
|
||||
if (string_utils::toupper(state.cfg.backend_renderer) == "VULKAN")
|
||||
state.backend_renderer = renderer::Backend::Vulkan;
|
||||
else
|
||||
state.backend_renderer = renderer::Backend::Vulkan;
|
||||
|
||||
if (string_utils::toupper(state.cfg.backend_renderer) == "OPENGL") {
|
||||
#ifndef __APPLE__
|
||||
state.backend_renderer = renderer::Backend::OpenGL;
|
||||
#else
|
||||
state.cfg.backend_renderer = "Vulkan";
|
||||
config::serialize_config(state.cfg, state.cfg.config_path);
|
||||
#endif
|
||||
}
|
||||
|
||||
int window_type = 0;
|
||||
switch (state.backend_renderer) {
|
||||
|
@ -486,12 +486,19 @@ void draw_settings_dialog(GuiState &gui, EmuEnvState &emuenv) {
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::Spacing();
|
||||
|
||||
#ifdef __APPLE__
|
||||
ImGui::BeginDisabled();
|
||||
#endif
|
||||
static const char *LIST_BACKEND_RENDERER[] = { "OpenGL", "Vulkan" };
|
||||
if (ImGui::Combo("Backend Renderer", reinterpret_cast<int *>(&emuenv.backend_renderer), LIST_BACKEND_RENDERER, IM_ARRAYSIZE(LIST_BACKEND_RENDERER)))
|
||||
emuenv.cfg.backend_renderer = LIST_BACKEND_RENDERER[int(emuenv.backend_renderer)];
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("Select your preferred backend renderer.");
|
||||
#ifdef __APPLE__
|
||||
ImGui::EndDisabled();
|
||||
#else
|
||||
ImGui::Spacing();
|
||||
#endif
|
||||
|
||||
const bool is_vulkan = (emuenv.backend_renderer == renderer::Backend::Vulkan);
|
||||
if (is_vulkan) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#define VK_NO_PROTOTYPES
|
||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
||||
#define VULKAN_HPP_NO_SPACESHIP_OPERATOR
|
||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
|
@ -250,8 +250,50 @@ static void bind_vertex_streams(VKContext &context, MemState &mem) {
|
||||
context.render_cmd.bindVertexBuffers(0, max_stream_idx, buffers, context.vertex_buffer_offsets.data());
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// convert indices for triangle fans to indices for a triangle list
|
||||
// needed for metal because it does not support a triangle fan implementation
|
||||
template <typename T>
|
||||
void triangle_fan_to_triangle_list(void *&indices, size_t &count) {
|
||||
// if N is the number of faces, there are N + 2 indices for triangle fans and 3N indices for triangle list
|
||||
if (count < 3)
|
||||
// safety check
|
||||
return;
|
||||
|
||||
const uint32_t nb_triangle = count - 2;
|
||||
|
||||
T *old_indices = reinterpret_cast<T *>(indices);
|
||||
indices = new uint8_t[3 * nb_triangle * sizeof(T)];
|
||||
T *curr_indices = reinterpret_cast<T *>(indices);
|
||||
|
||||
for (uint32_t triangle = 0; triangle < nb_triangle; triangle++) {
|
||||
curr_indices[0] = old_indices[0];
|
||||
curr_indices[1] = old_indices[triangle + 1];
|
||||
curr_indices[2] = old_indices[triangle + 2];
|
||||
curr_indices += 3;
|
||||
}
|
||||
|
||||
count = 3 * nb_triangle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void draw(VKContext &context, SceGxmPrimitiveType type, SceGxmIndexFormat format,
|
||||
void *indices, size_t count, uint32_t instance_count, MemState &mem, const Config &config) {
|
||||
#ifdef __APPLE__
|
||||
bool replaced_indices = (type == SCE_GXM_PRIMITIVE_TRIANGLE_FAN);
|
||||
// metal does not support triangle fans
|
||||
if (replaced_indices) {
|
||||
if (format == SCE_GXM_INDEX_FORMAT_U16) {
|
||||
triangle_fan_to_triangle_list<uint16_t>(indices, count);
|
||||
} else {
|
||||
triangle_fan_to_triangle_list<uint32_t>(indices, count);
|
||||
}
|
||||
type = SCE_GXM_PRIMITIVE_TRIANGLES;
|
||||
}
|
||||
#else
|
||||
constexpr bool replaced_indices = false;
|
||||
#endif
|
||||
|
||||
// do we need to check for a pipeline change?
|
||||
if (context.refresh_pipeline || !context.in_renderpass || type != context.last_primitive) {
|
||||
context.refresh_pipeline = false;
|
||||
@ -334,6 +376,9 @@ void draw(VKContext &context, SceGxmPrimitiveType type, SceGxmIndexFormat format
|
||||
|
||||
context.render_cmd.drawIndexed(count, instance_count, 0, 0, 0);
|
||||
|
||||
if (replaced_indices)
|
||||
delete[] reinterpret_cast<uint8_t *>(indices);
|
||||
|
||||
context.vertex_uniform_storage_allocated = false;
|
||||
context.fragment_uniform_storage_allocated = false;
|
||||
}
|
||||
|
@ -910,7 +910,10 @@ static SpirvShaderParameters create_parameters(spv::Builder &b, const SceGxmProg
|
||||
spv_params.buffer_container = b.createVariable(spv::NoPrecision, spv::StorageClassStorageBuffer, buffer_container_type,
|
||||
is_vert ? "vertexData" : "fragmentData");
|
||||
|
||||
#ifndef __APPLE__
|
||||
// Most Apple GPUs do not support the keyword restrict in MSL
|
||||
b.addDecoration(spv_params.buffer_container, spv::DecorationRestrict);
|
||||
#endif
|
||||
b.addDecoration(spv_params.buffer_container, spv::DecorationNonWritable);
|
||||
b.addDecoration(spv_params.buffer_container, spv::DecorationBinding, is_vert ? 0 : 1);
|
||||
if (translation_state.is_vulkan)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#define VK_NO_PROTOTYPES
|
||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
||||
#define VULKAN_HPP_NO_SPACESHIP_OPERATOR
|
||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user