diff --git a/README.md b/README.md index b08cadc9..552ee2f9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Despite the fact that it was made with Essentials games in mind, there is nothin It supports Windows, Linux and both Intel and Apple Silicon versions of macOS. -Releases are [here](https://gitlab.com/mkxp-z/mkxp-z/-/releases). Requirements for running them are Windows 8.1+, Ubuntu 18.04+ (Fedora and Manjaro releases that age or newer *should* also be fine), or macOS 10.12+. +Releases are [here](https://gitlab.com/mkxp-z/mkxp-z/-/releases). Requirements for running them are Windows 8.1+, Ubuntu 18.04+ (Fedora and Manjaro releases that age or newer *should* also be fine), or macOS 10.12.2+. I'd highly recommend [checking the gitbook](https://roza-gb.gitbook.io/mkxp-z) for more information than this readme contains. @@ -48,7 +48,7 @@ pacman -S git ruby base-devel mingw-w64-x86_64-cmake mingw-w64-x86_64-meson ming pacman -S git ruby base-devel mingw-w64-i686-cmake mingw-w64-i686-meson mingw-w64-i686-gcc ``` -+ **Linux (Ubuntu/Debian)** ++ **Linux (Ubuntu 18.04)** ```sh sudo apt install git build-essential cmake meson autoconf automake libtool pkg-config ruby bison zlib1g-dev xorg-dev lib32z1 libasound2-dev libpulse-dev @@ -99,6 +99,6 @@ If a requested font is not found, no error is generated. Instead, a built-in fon ## What doesn't work (yet) * Movie playback * wma audio files -* Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 16384 on modern cards).^ +* Creating Bitmaps with sizes greater than your hardware's texture size limit (around 16384 on modern cards).^ ^ There is an exception to this, called *mega surface*. When a Bitmap bigger than the texture limit is created from a file, it is not stored in VRAM, but regular RAM. Its sole purpose is to be used as a tileset bitmap. Any other operation to it (besides blitting to a regular Bitmap) will result in an error. diff --git a/macos/Dependencies/Frameworks/ANGLE/README.txt b/macos/Dependencies/Frameworks/ANGLE/README.txt index 57cb8175..5a556c28 100644 --- a/macos/Dependencies/Frameworks/ANGLE/README.txt +++ b/macos/Dependencies/Frameworks/ANGLE/README.txt @@ -3,6 +3,4 @@ Here lives Google's ANGLE, which is pretty necessary right now. On top of Apple deprecating OpenGL, MKXP has crashing issues from the OpenGL -> Metal translation implemented in Apple Silicon macs. -Currently, the build of ANGLE here is the one provided with -Google Chrome/Chromium. Soon as ANGLE's gclient doesn't fail -on Apple Silicon macs, I'll build it myself. \ No newline at end of file +This particular build of ANGLE is made using [this commit](https://github.com/google/angle/tree/0aae0d7ad535aedba34daea325269e419baead68), built with Metal support enabled. Both arm64 and x64 libraries were built using the `target_cpu` arg, then joined using the `lipo` tool. \ No newline at end of file diff --git a/macos/Dependencies/Frameworks/ANGLE/libEGL.dylib b/macos/Dependencies/Frameworks/ANGLE/libEGL.dylib index 5a03b550..30e57be0 100755 Binary files a/macos/Dependencies/Frameworks/ANGLE/libEGL.dylib and b/macos/Dependencies/Frameworks/ANGLE/libEGL.dylib differ diff --git a/macos/Dependencies/Frameworks/ANGLE/libGLESv2.dylib b/macos/Dependencies/Frameworks/ANGLE/libGLESv2.dylib index 260ec9c6..154629fb 100755 Binary files a/macos/Dependencies/Frameworks/ANGLE/libGLESv2.dylib and b/macos/Dependencies/Frameworks/ANGLE/libGLESv2.dylib differ diff --git a/macos/mkxp-z.xcodeproj/project.pbxproj b/macos/mkxp-z.xcodeproj/project.pbxproj index 5b5528af..701efb08 100644 --- a/macos/mkxp-z.xcodeproj/project.pbxproj +++ b/macos/mkxp-z.xcodeproj/project.pbxproj @@ -458,7 +458,7 @@ 3BC65DEB2584F3AD0063AFF1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BD2B47A256534BA003DAD8A /* IOKit.framework */; }; 3BC65DED2584F3AD0063AFF1 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081552568D3A60006849F /* Carbon.framework */; }; 3BC65DEF2584F3AD0063AFF1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081582568D3A60006849F /* AppKit.framework */; }; - 3BC65DF42584F3AD0063AFF1 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081542568D3A60006849F /* Metal.framework */; }; + 3BC65DF42584F3AD0063AFF1 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081542568D3A60006849F /* Metal.framework */; settings = {ATTRIBUTES = (Required, ); }; }; 3BC65DF52584F3AD0063AFF1 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081572568D3A60006849F /* ForceFeedback.framework */; }; 3BC65DF62584F3AD0063AFF1 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081532568D3A60006849F /* CoreVideo.framework */; }; 3BC65DFA2584F3AD0063AFF1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; }; diff --git a/mkxp.json b/mkxp.json index b63e708c..cba250eb 100644 --- a/mkxp.json +++ b/mkxp.json @@ -19,6 +19,11 @@ // (default: 0) // // "rgssVersion": 1, + + // Render using Metal instead of OpenGL, if possible. + // + // Using Metal requires macOS 10.13+ and a compatible GPU. + // "preferMetalRenderer": true, // Create a debug context and log // OpenGL debug information to the console diff --git a/src/config.cpp b/src/config.cpp index bc5b3044..3b0d7a02 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -88,6 +88,7 @@ Config::Config() {} void Config::read(int argc, char *argv[]) { auto optsJ = json::object({ {"rgssVersion", 0}, + {"preferMetalRenderer", true}, {"debugMode", false}, {"printFPS", false}, {"winResizable", true}, @@ -156,7 +157,8 @@ try { exp } catch (...) {} editor.battleTest = true; for (int i = 1; i < argc; i++) { - launchArgs.push_back(argv[i]); + if (!strcmp(argv[i], "debug")) + launchArgs.push_back(argv[i]); } } @@ -191,6 +193,7 @@ try { exp } catch (...) {} #define SET_STRINGOPT(var, key) GUARD(var = std::string(opts[#key].as_string());) SET_OPT(rgssVersion, integer); + SET_OPT(preferMetalRenderer, boolean); SET_OPT(debugMode, boolean); SET_OPT(printFPS, boolean); SET_OPT(fullscreen, boolean); diff --git a/src/config.h b/src/config.h index b67fdb7f..b2ef3fa2 100644 --- a/src/config.h +++ b/src/config.h @@ -35,6 +35,7 @@ struct Config { int rgssVersion; bool debugMode; + bool preferMetalRenderer; bool printFPS; bool winResizable; diff --git a/src/main.cpp b/src/main.cpp index 6338051d..fc34488b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -325,6 +325,8 @@ int main(int argc, char *argv[]) { // LoadLibrary properly initializes EGL, it won't work otherwise. // Doesn't completely do it though, needs a small patch to SDL #ifdef MKXPZ_BUILD_XCODE + // Setting OpenGL only works when building in Release mode due to the config getting re-read later + SDL_setenv("ANGLE_DEFAULT_PLATFORM", (conf.preferMetalRenderer && isMetalSupported()) ? "metal" : "opengl", true); SDL_GL_LoadLibrary("@rpath/libEGL.dylib"); #endif #endif diff --git a/src/system/system.h b/src/system/system.h index 6d3995b0..9ad7eeda 100644 --- a/src/system/system.h +++ b/src/system/system.h @@ -41,6 +41,7 @@ WineHostType getRealHostType(); #ifdef MKXPZ_BUILD_XCODE void openSettingsWindow(); +bool isMetalSupported(); #endif namespace mkxp_sys = systemImpl; diff --git a/src/system/systemImplApple.mm b/src/system/systemImplApple.mm index 736ba222..6e86f712 100644 --- a/src/system/systemImplApple.mm +++ b/src/system/systemImplApple.mm @@ -6,6 +6,8 @@ // #import +#import + #import #import "system.h" #import "SettingsMenuController.h" @@ -53,3 +55,10 @@ void openSettingsWindow() { } [smenu raise]; } + +bool isMetalSupported() { + if (@available(macOS 10.13.0, *)) { + return MTLCreateSystemDefaultDevice() != nil; + } + return false; +}