Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC / WIP] iOS support with working JIT #8492

Closed
wants to merge 81 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
3312ed2
update androidSupportVersion and compileSdkVersion to 28
Simonx22 Nov 10, 2019
352beb5
Allow user to change DPLII decoding quality
LAGonauta Mar 18, 2019
8d5a499
CMakeLists: Add iOS-specific build settings
OatmealDome Oct 25, 2019
ba30143
iOS: Add CMake toolchain
OatmealDome Oct 25, 2019
66c5a56
iOS: Add barebones Host interface file
OatmealDome Oct 25, 2019
fe9fe45
Arm64Emitter: Add header for sys_cache_control
OatmealDome Oct 25, 2019
0845330
ArmCPUDetect: Add barebones support for iOS
OatmealDome Oct 25, 2019
ea39d4b
WindowSystemInfo: Add iOS type
OatmealDome Oct 25, 2019
303211c
Analytics: Use custom os-type on iOS
OatmealDome Oct 25, 2019
cfc2fd2
IOdarwin: Use fake WiimoteScannerDarwin on iOS
OatmealDome Oct 25, 2019
3d185b4
MachineContext: Add context for iOS's arm64
OatmealDome Oct 25, 2019
a4365f3
InputCommon: Don't compile GCAdapter on iOS
OatmealDome Oct 25, 2019
2e4ba09
ControllerInterface: Don't use macOS's interface on iOS
OatmealDome Oct 25, 2019
ae903a1
CMakeLists: Add iOS's Interface
OatmealDome Oct 25, 2019
8d35222
curl: Don't use MSG_NOSIGNAL as it isn't defined on Apple platforms
OatmealDome Oct 25, 2019
7e9e576
UICommon: Don't use macOS screensaver code on iOS
OatmealDome Oct 25, 2019
14f933e
GCAdapter: Add dummy class for iOS
OatmealDome Oct 26, 2019
39b15a8
ArmCPUDetect: Correct ifdef for Android
OatmealDome Oct 26, 2019
089ea47
MemTools: Add arm64 support on iOS
OatmealDome Oct 27, 2019
bb39097
Arm64Emitter: Check for IPHONEOS define instead of IOS
OatmealDome Oct 31, 2019
2fd5017
CMakeLists: Enable CRC instruction set on iOS
OatmealDome Nov 1, 2019
bde5d8c
Externals: Add MoltenVK dylib for iOS
OatmealDome Nov 1, 2019
5f0abac
VulkanLoader: Define VK_USE_PLATFORM_IOS_MVK on iOS
OatmealDome Nov 1, 2019
b2f1fba
VulkanLoader: Correct dylib path for iOS
OatmealDome Nov 1, 2019
dce8801
VulkanContext: Check for iOS surface extension
OatmealDome Nov 1, 2019
449d46c
SwapChain: Create surface on iOS
OatmealDome Nov 1, 2019
a84d70a
SwapChain: Call vkCreateIOSSurfaceMVK on the UI thread to avoid a lon…
OatmealDome Nov 15, 2019
975899e
iOS: Add MainiOS
OatmealDome Nov 17, 2019
6450874
iOS: Add gitignore for Xcode
OatmealDome Nov 17, 2019
621ce0b
iOS: Add barebones application
OatmealDome Nov 17, 2019
ca9d9da
lint: Update clang-format to 9.0
OatmealDome Nov 17, 2019
948e5d8
InputCommon: Add iOS controller interface
OatmealDome Nov 20, 2019
9de2c0c
MainiOS: Add methods to signal ButtonManager events
OatmealDome Nov 20, 2019
84c8861
InputCommon: Add source files for iOS controller interface
OatmealDome Nov 20, 2019
4910547
iOS: Add basic touchscreen buttons and joystick
OatmealDome Nov 20, 2019
b2d3bc2
iOS: Disable Metal API debugger to increase performance
OatmealDome Nov 20, 2019
d34d43f
iOS: Create touchscreen GameCube pad during emulation
OatmealDome Nov 20, 2019
995d674
iOS: Add xcassets for Dolphin images
OatmealDome Nov 20, 2019
2858405
iOS: Automatically populate DolphinImages.xcassets with Android images
OatmealDome Nov 20, 2019
e63a361
iOS: Update project to Xcode recommended settings
OatmealDome Nov 20, 2019
eaf106e
Build: Don't set CMAKE_OSX_ARCHITECTURES on iOS
OatmealDome Nov 20, 2019
5b10428
iOS: Don't recopy images if they are already present
OatmealDome Nov 20, 2019
69437b8
iOS: Correct directory names for 2x and 3x images
OatmealDome Nov 20, 2019
80094a2
TouchController: Always load images from the application's bundle
OatmealDome Nov 20, 2019
c517a2e
TouchController: Add TCButtonType enum
OatmealDome Nov 20, 2019
c3fb723
TouchController: Scale buttons down
OatmealDome Nov 20, 2019
f31a2f2
AudioCommon: Re-add CoreAudio backend for on iOS
OatmealDome Nov 21, 2019
11b8ee4
iOS: Add a nearly complete GameCube controller layout to TCGameCubePad
OatmealDome Nov 21, 2019
b833e27
iOS: Add basic layout for a touchscreen Wiimote
OatmealDome Nov 21, 2019
4ebe0ca
iOS: Copy Sys directory to application bundle
OatmealDome Nov 22, 2019
f30052e
FileUtil: Get correct Sys and executable path on iOS
OatmealDome Nov 23, 2019
b4d057d
VulkanContext: Use AddExtension for iOS
OatmealDome Nov 23, 2019
5442787
iOS: Swiftify EmulationViewController
OatmealDome Nov 23, 2019
196f9bf
iOS: Add dynamic-codesigning entitlement to application for jailbroke…
OatmealDome Nov 24, 2019
c8cec61
iOS: Set render scale in WindowSystemInfo
OatmealDome Nov 24, 2019
6799e78
iOS: Use MTKView for MoltenVK
OatmealDome Nov 24, 2019
d309225
iOS: Tell the renderer that the window has resized when needed
OatmealDome Nov 24, 2019
e437f56
iOS: Fix project building on non-jailbroken device
OatmealDome Nov 24, 2019
e0ed37a
AudioCommon: CoreAudioSound code should only be defined on iOS
OatmealDome Nov 25, 2019
51b3eef
iOS: Add D-Pad to touchscreen controllers
OatmealDome Nov 27, 2019
2b7e24f
AudioCommon: Allow cubeb to be optional
OatmealDome Nov 27, 2019
61d5dc5
CMake: Add define for macOS
OatmealDome Nov 27, 2019
236299f
CDUtils: Return no CD drives on iOS
OatmealDome Nov 27, 2019
eb21883
Core: Convert some preprocessor checks to use new MACOS define
OatmealDome Nov 27, 2019
b17ba84
DiscIO: Don't compile DriveBlob on iOS
OatmealDome Nov 27, 2019
01a118d
GL: Use MACOS define instead of generic APPLE
OatmealDome Nov 27, 2019
72851fd
GLContext: Add method to return default framebuffer
OatmealDome Nov 27, 2019
b5421c9
GLInterface: Add EAGL GLContext for iOS
OatmealDome Nov 27, 2019
c8a067b
MemArena: Use mach VM functions to allocate memory on iOS
OatmealDome Nov 30, 2019
e5d8532
CMakeLists: Add new ENABLE_WX_EXCLUSIVITY option for W^X platforms
OatmealDome Nov 30, 2019
e3c5c42
MemoryUtil: Implement W^X in memory protection functions
OatmealDome Nov 30, 2019
b86d20d
MemoryUtil: Add utility function on W^X platforms which checks if a p…
OatmealDome Nov 30, 2019
ec8a475
MemoryUtil: Add utility function which returns the platform's page size
OatmealDome Nov 30, 2019
9017b32
CodeBlock: Add functions for writing to the code space
OatmealDome Nov 30, 2019
c0d469b
Jit64: Use WriteCode and WriteCodeAtRegion for W^X compliance
OatmealDome Nov 30, 2019
1b86da4
ConstantPool: Mark the assigned memory region as writable
OatmealDome Nov 30, 2019
6cfab44
JitArm64: Use WriteCode and WriteCodeAtRegion for W^X compliance
OatmealDome Nov 30, 2019
076b3ee
VideoCommon: Use WriteCode and WriteCodeAtRegion in vertex loaders fo…
OatmealDome Nov 30, 2019
b9a620a
EXI: Only compile DeviceMic if cubeb is available
OatmealDome Nov 30, 2019
05a1938
AudioCommon: Clean up CoreAudioSoundStream
OatmealDome Nov 30, 2019
5d0bf96
iOS: Silence OpenGL ES deprecation warnings
OatmealDome Nov 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 64 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# General setup
#
cmake_minimum_required(VERSION 3.10)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
# Minimum OS X version.
# This is inserted into the Info.plist as well.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10.0" CACHE STRING "")

if(APPLE AND NOT IOS)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
# Minimum OS X version.
# This is inserted into the Info.plist as well.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10.0" CACHE STRING "")
endif()

project(dolphin-emu)

Expand All @@ -28,6 +31,7 @@ option(ENABLE_QT "Enable Qt (Default)" ON)
option(ENABLE_LTO "Enables Link Time Optimization" OFF)
option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF)
option(ENABLE_HEADLESS "Enables running Dolphin as a headless variant" OFF)
option(ENABLE_WX_EXCLUSIVITY "Enables W^X for platforms that need it" OFF)
option(ENABLE_ALSA "Enables ALSA sound backend" ON)
option(ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON)
option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON)
Expand Down Expand Up @@ -196,13 +200,16 @@ elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
add_definitions(-D_M_X86=1)
add_definitions(-D_M_X86_64=1)
check_and_add_flag(HAVE_SSE2 -msse2)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(_M_ARM 1)
set(_M_ARM_64 1)
add_definitions(-D_M_ARM=1)
add_definitions(-D_M_ARM_64=1)
# CRC instruction set is used in the CRC32 hash function
check_and_add_flag(HAVE_ARCH_ARMV8 -march=armv8-a+crc)

if (ANDROID OR IOS)
# CRC instruction set is used in the CRC32 hash function
check_and_add_flag(HAVE_ARCH_ARMV8 -march=armv8-a+crc)
endif()
else()
message(FATAL_ERROR "You're building on an unsupported platform: "
"'${CMAKE_SYSTEM_PROCESSOR}' with ${CMAKE_SIZEOF_VOID_P}-byte pointers."
Expand Down Expand Up @@ -278,7 +285,7 @@ else()
endif()
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(CMAKE_SYSTEM_NAME MATCHES "Darwin" AND NOT IOS)
if(NOT OSX_USE_DEFAULT_SEARCH_PATH)
# Hack up the path to prioritize the path to built-in OS libraries to
# increase the chance of not depending on a bunch of copies of them
Expand All @@ -299,6 +306,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
# Drop unreachable code and data.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip,-dead_strip_dylibs")

# Add define for macOS
add_definitions(-DMACOS)

find_library(APPKIT_LIBRARY AppKit)
find_library(APPSERV_LIBRARY ApplicationServices)
find_library(CARBON_LIBRARY Carbon)
Expand Down Expand Up @@ -398,12 +408,43 @@ if(ANDROID)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()

if(IOS)
message(STATUS "Building for iOS")

add_definitions(-DIPHONEOS)

if(ENABLE_NOGUI)
message(STATUS "Building iOS app, disabling NoGUI frontend.")
set(ENABLE_NOGUI 0)
endif()

set(ENABLE_WX_EXCLUSIVITY 1)
set(USE_UPNP 0)
set(ENABLE_QT 0)
set(USE_DISCORD_PRESENCE 0)

# We are cross compiling, search only the toolchain for libraries and includes
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()

if(ENABLE_HEADLESS)
message(STATUS "Enabling Headless! Disabling GUI.")
set(ENABLE_QT 0)
set(USE_DISCORD_PRESENCE 0)
endif()

if(ENABLE_WX_EXCLUSIVITY)
message(STATUS "Enabling WX exclusivity.")
if(NOT WIN32 AND NOT APPLE)
message(FATAL_ERROR "WX exclusivity is not supported on this platform.")
endif()

add_definitions(-D_WX_EXCLUSIVITY)
endif()

# Set file offset size to 64 bits.
#
# On modern Unixes, this is typically already the case. The lone exception is
Expand Down Expand Up @@ -621,15 +662,21 @@ endif()
add_subdirectory(Externals/soundtouch)
include_directories(Externals)

find_package(Cubeb)
if(CUBEB_FOUND)
message(STATUS "Using the system cubeb")
else()
message(STATUS "Using static cubeb from Externals")
add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL)
# Cubeb support for iOS is old and broken.
# See: https://github.com/kinetiknz/cubeb/issues/394
if(NOT IOS)
find_package(Cubeb)
if(CUBEB_FOUND)
message(STATUS "Using the system cubeb")
else()
message(STATUS "Using static cubeb from Externals")
add_subdirectory(Externals/cubeb EXCLUDE_FROM_ALL)
set(CUBEB_FOUND true)
endif()
add_definitions(-DHAVE_CUBEB)
endif()

if(NOT ANDROID)
if(NOT ANDROID AND NOT IOS)
add_definitions(-D__LIBUSB__)
if(NOT APPLE)
find_package(LibUSB)
Expand Down Expand Up @@ -700,7 +747,7 @@ if (NOT ANDROID)
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
endif()

if (NOT ANDROID AND ICONV_LIBRARIES AND ICONV_INCLUDE_DIR)
if (NOT ANDROID AND NOT IOS AND ICONV_LIBRARIES AND ICONV_INCLUDE_DIR)
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES)
else()
message(STATUS "Using static iconv from Externals")
Expand All @@ -709,7 +756,7 @@ else()
set(ICONV_LIBRARIES iconv)
endif()

if(NOT ANDROID)
if(NOT ANDROID AND NOT IOS)
find_package(HIDAPI)
if(NOT HIDAPI_FOUND)
message(STATUS "Using static HIDAPI from Externals")
Expand Down
Binary file added Externals/MoltenVK/libvulkan_iOS.dylib
Binary file not shown.
2 changes: 1 addition & 1 deletion Externals/curl/lib/curl_setup_once.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct timeval {
* it as the fourth argument of function send()
*/

#ifdef HAVE_MSG_NOSIGNAL
#if !defined(__APPLE__) && HAVE_MSG_NOSIGNAL
#define SEND_4TH_ARG MSG_NOSIGNAL
#else
#define SEND_4TH_ARG 0
Expand Down
4 changes: 4 additions & 0 deletions Source/Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ android {
}
}

ext {
androidSupportVersion = '28.0.0'
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.exifinterface:exifinterface:1.1.0'
Expand Down
4 changes: 4 additions & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ if (ANDROID)
add_subdirectory(Android/jni)
endif()

if (IOS)
add_subdirectory(iOS/Interface)
endif()

if (ENABLE_TESTS)
add_subdirectory(UnitTests)
endif()
Expand Down
15 changes: 11 additions & 4 deletions Source/Core/AudioCommon/AudioCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "AudioCommon/AudioCommon.h"
#include "AudioCommon/AlsaSoundStream.h"
#include "AudioCommon/CoreAudioSoundStream.h"
#include "AudioCommon/CubebStream.h"
#include "AudioCommon/Mixer.h"
#include "AudioCommon/NullSoundStream.h"
Expand All @@ -29,14 +30,16 @@ constexpr int AUDIO_VOLUME_MAX = 100;

static std::unique_ptr<SoundStream> CreateSoundStreamForBackend(std::string_view backend)
{
if (backend == BACKEND_CUBEB)
if (backend == BACKEND_CUBEB && CubebStream::isValid())
return std::make_unique<CubebStream>();
else if (backend == BACKEND_OPENAL && OpenALStream::isValid())
return std::make_unique<OpenALStream>();
else if (backend == BACKEND_NULLSOUND)
return std::make_unique<NullSound>();
else if (backend == BACKEND_ALSA && AlsaSound::isValid())
return std::make_unique<AlsaSound>();
else if (backend == BACKEND_COREAUDIO && CoreAudioSound::isValid())
return std::make_unique<CoreAudioSound>();
else if (backend == BACKEND_PULSEAUDIO && PulseAudio::isValid())
return std::make_unique<PulseAudio>();
else if (backend == BACKEND_OPENSLES && OpenSLESStream::isValid())
Expand Down Expand Up @@ -92,10 +95,12 @@ std::string GetDefaultSoundBackend()
std::string backend = BACKEND_NULLSOUND;
#if defined ANDROID
backend = BACKEND_OPENSLES;
#elif defined IPHONEOS
backend = BACKEND_COREAUDIO;
#elif defined __linux__
if (AlsaSound::isValid())
backend = BACKEND_ALSA;
#elif defined(__APPLE__) || defined(_WIN32)
#elif defined HAVE_CUBEB
backend = BACKEND_CUBEB;
#endif
return backend;
Expand All @@ -111,7 +116,8 @@ std::vector<std::string> GetSoundBackends()
std::vector<std::string> backends;

backends.emplace_back(BACKEND_NULLSOUND);
backends.emplace_back(BACKEND_CUBEB);
if (CubebStream::isValid())
backends.emplace_back(BACKEND_CUBEB);
if (AlsaSound::isValid())
backends.emplace_back(BACKEND_ALSA);
if (PulseAudio::isValid())
Expand Down Expand Up @@ -149,7 +155,8 @@ bool SupportsVolumeChanges(std::string_view backend)
// FIXME: this one should ask the backend whether it supports it.
// but getting the backend from string etc. is probably
// too much just to enable/disable a stupid slider...
return backend == BACKEND_CUBEB || backend == BACKEND_OPENAL || backend == BACKEND_WASAPI;
return backend == BACKEND_COREAUDIO || backend == BACKEND_CUBEB || backend == BACKEND_OPENAL ||
backend == BACKEND_WASAPI;
}

void UpdateSoundStream()
Expand Down
20 changes: 16 additions & 4 deletions Source/Core/AudioCommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ add_library(audiocommon
AudioCommon.h
AudioStretcher.cpp
AudioStretcher.h
CubebStream.cpp
CubebStream.h
CubebUtils.cpp
CubebUtils.h
Enums.h
Mixer.cpp
Mixer.h
Expand All @@ -18,6 +14,15 @@ add_library(audiocommon
WaveFile.h
)

if(CUBEB_FOUND)
target_sources(audiocommon PRIVATE
CubebStream.cpp
CubebStream.h
CubebUtils.cpp
CubebUtils.h
)
endif()

find_package(OpenSLES)
if(OPENSLES_FOUND)
message(STATUS "OpenSLES found, enabling OpenSLES sound backend")
Expand Down Expand Up @@ -75,4 +80,11 @@ if(WIN32)
)
endif()

if(IOS)
target_sources(audiocommon PRIVATE
CoreAudioSoundStream.cpp
CoreAudioSoundStream.h
)
endif()

target_link_libraries(audiocommon PRIVATE cubeb SoundTouch FreeSurround)
Loading