diff --git a/src/ARMeilleure/Translation/Cache/JitCache.cs b/src/ARMeilleure/Translation/Cache/JitCache.cs index 9a088b84d..ffcb3540f 100644 --- a/src/ARMeilleure/Translation/Cache/JitCache.cs +++ b/src/ARMeilleure/Translation/Cache/JitCache.cs @@ -15,11 +15,11 @@ namespace ARMeilleure.Translation.Cache static partial class JitCache { private static readonly int _pageSize = (int)MemoryBlock.GetPageSize(); - private static readonly int _pageMask = _pageSize - 8; + private static readonly int _pageMask = _pageSize - 4; private const int CodeAlignment = 4; // Bytes. - private const int CacheSize = 128 * 1024 * 1024; - private const int CacheSizeIOS = 64 * 1024 * 1024; + private const int CacheSize = 1024 * 1024 * 1024; + private const int CacheSizeIOS = 128 * 1024 * 1024; private static ReservedRegion _jitRegion; private static JitCacheInvalidation _jitCacheInvalidator; diff --git a/src/MeloNX/MeloNX.xcodeproj/project.pbxproj b/src/MeloNX/MeloNX.xcodeproj/project.pbxproj index 0664aa8fc..7b86e1b25 100644 --- a/src/MeloNX/MeloNX.xcodeproj/project.pbxproj +++ b/src/MeloNX/MeloNX.xcodeproj/project.pbxproj @@ -650,6 +650,7 @@ "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", + "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", ); MARKETING_VERSION = 0.0.8; PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.MeloNX; @@ -702,6 +703,7 @@ "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", + "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", ); MARKETING_VERSION = 0.0.8; PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.MeloNX; diff --git a/src/MeloNX/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate b/src/MeloNX/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate index 5919120d2..bff7dabf1 100644 Binary files a/src/MeloNX/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate and b/src/MeloNX/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/src/MeloNX/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist b/src/MeloNX/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist index 19b8e18b3..8ff6cf524 100644 --- a/src/MeloNX/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/src/MeloNX/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,12 +12,12 @@ Ryujinx.xcscheme_^#shared#^_ orderHint - 4 + 2 com.Stossy11.MeloNX.RyujinxAg.xcscheme_^#shared#^_ orderHint - 3 + 1 SuppressBuildableAutocreation diff --git a/src/MeloNX/MeloNX/App/Core/Ryujinx/Controller/WaitforVC.swift b/src/MeloNX/MeloNX/App/Core/Ryujinx/Controller/WaitforVC.swift index c6b4d9fe4..76174742f 100644 --- a/src/MeloNX/MeloNX/App/Core/Ryujinx/Controller/WaitforVC.swift +++ b/src/MeloNX/MeloNX/App/Core/Ryujinx/Controller/WaitforVC.swift @@ -12,6 +12,7 @@ import SwiftUI var hostingController: UIHostingController? // Store reference to prevent deallocation +// Swts up a timer that adds subview to the Window and Repeats until the ControllerView is found in the Window to ensure that the controller shows. func waitForController() { guard let window = theWindow else { return } @@ -40,8 +41,10 @@ func waitForController() { containerView.frame = window.bounds containerView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + // Timer for controller Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { timer in if findGCControllerView(in: window) == nil { + // Adds Virtual Controller Subview window.addSubview(containerView) window.bringSubviewToFront(containerView) diff --git a/src/MeloNX/MeloNX/App/Core/Ryujinx/Display/DisplayVisible.swift b/src/MeloNX/MeloNX/App/Core/Ryujinx/Display/DisplayVisible.swift index b122900ec..55214daa3 100644 --- a/src/MeloNX/MeloNX/App/Core/Ryujinx/Display/DisplayVisible.swift +++ b/src/MeloNX/MeloNX/App/Core/Ryujinx/Display/DisplayVisible.swift @@ -13,6 +13,8 @@ import UIKit var theWindow: UIWindow? = nil extension UIWindow { + // Makes the SDLWindow use the current WindowScene instead of making its own window. + // Also waits for the window to append the on-screen controller @objc func wdb_makeKeyAndVisible() { if #available(iOS 13.0, *) { self.windowScene = (UIApplication.shared.connectedScenes.first! as! UIWindowScene) @@ -29,7 +31,7 @@ extension UIWindow { } } - +// Patches makeKeyAndVisible to wdb_makeKeyAndVisible func patchMakeKeyAndVisible() { let uiwindowClass = UIWindow.self if let m1 = class_getInstanceMethod(uiwindowClass, #selector(UIWindow.makeKeyAndVisible)), diff --git a/src/MeloNX/MeloNX/App/Core/Ryujinx/Ryujinx.swift b/src/MeloNX/MeloNX/App/Core/Ryujinx/Ryujinx.swift index b42154d66..e7fb25308 100644 --- a/src/MeloNX/MeloNX/App/Core/Ryujinx/Ryujinx.swift +++ b/src/MeloNX/MeloNX/App/Core/Ryujinx/Ryujinx.swift @@ -182,11 +182,15 @@ class Ryujinx { func MainThread(_ block: @escaping @Sendable () -> Void) { if #available(iOS 17.0, *) { RunLoop.current.perform { - block() + autoreleasepool { + block() + } } } else { DispatchQueue.main.async { - block() + autoreleasepool { + block() + } } } } diff --git a/src/MeloNX/MeloNX/App/Views/ContentView.swift b/src/MeloNX/MeloNX/App/Views/ContentView.swift index 85b4d0fc1..2e7a88df0 100644 --- a/src/MeloNX/MeloNX/App/Views/ContentView.swift +++ b/src/MeloNX/MeloNX/App/Views/ContentView.swift @@ -19,23 +19,31 @@ struct MoltenVKSettings: Codable, Hashable { } struct ContentView: View { - // MARK: - Properties - @State private var theWindow: UIWindow? + // Games @State private var game: Game? + + // Controllers @State private var controllersList: [Controller] = [] @State private var currentControllers: [Controller] = [] + @State var onscreencontroller: Controller = Controller(id: "", name: "") + @State private var isVirtualControllerActive: Bool = false + @AppStorage("isVirtualController") var isVCA: Bool = true + + // Settings and Configuration @State private var config: Ryujinx.Configuration @State var settings: [MoltenVKSettings] @AppStorage("useTrollStore") var useTrollStore: Bool = false - @State private var isVirtualControllerActive: Bool = false - @AppStorage("isVirtualController") var isVCA: Bool = true - @State var onscreencontroller: Controller = Controller(id: "", name: "") + + // JIT @AppStorage("JIT") var isJITEnabled: Bool = false + + // Other Configuration @State var isMK8: Bool = false @AppStorage("quit") var quit: Bool = false + @State var quits: Bool = false @AppStorage("MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS") var mVKPreFillBuffer: Bool = true - @State var quits: Bool = false + // Loading Animation @State private var clumpOffset: CGFloat = -100 private let clumpWidth: CGFloat = 100 private let animationDuration: Double = 1.0 @@ -50,11 +58,11 @@ struct ContentView: View { let defaultSettings: [MoltenVKSettings] = [ // MoltenVKSettings(string: "MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS", value: "1"), // MoltenVKSettings(string: "MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS", value: "2"), + // Metal Private API isn't needed and causes more stutters MoltenVKSettings(string: "MVK_USE_METAL_PRIVATE_API", value: "0"), - // MoltenVKSettings(string: "MVK_CONFIG_RESUME_LOST_DEVICE", value: "1"), - MoltenVKSettings(string: "MVK_CONFIG_MAX_ACTIVE_METAL_COMMAND_BUFFERS_PER_QUEUE", value: "192"), - //MVK_CONFIG_LOG_LEVEL - MoltenVKSettings(string: "MVK_CONFIG_USE_METAL_PRIVATE_API", value: "0") + MoltenVKSettings(string: "MVK_CONFIG_USE_METAL_PRIVATE_API", value: "0"), + // Uses more ram but makes performance higher, may add an option in settings to change or enable / disable this value (default 64 or 192 depending on what i decide) + MoltenVKSettings(string: "MVK_CONFIG_MAX_ACTIVE_METAL_COMMAND_BUFFERS_PER_QUEUE", value: "1024"), ] _settings = State(initialValue: defaultSettings) @@ -70,6 +78,8 @@ struct ContentView: View { if isLoading { emulationView .onAppear() { + // This is fro the old exiting game feature that didn't work properly. will look into it and figure out a better alternative + /* Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { timer in timer.invalidate() quits = quit @@ -79,8 +89,10 @@ struct ContentView: View { timer.invalidate() } } + */ } } else { + // This is when the game starts to stop the animation VStack { } @@ -89,11 +101,12 @@ struct ContentView: View { } } } else { + // This is the main menu view that includes the Settings and the Game Selector mainMenuView .onAppear() { quits = false - initControllerObservers() + initControllerObservers() // This initializes the Controller Observers that refreshes the controller list when a new controller connecvts. } } @@ -217,12 +230,12 @@ struct ContentView: View { } // MARK: - Helper Methods - var SdlInitFlags: uint = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO; + var SdlInitFlags: uint = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO; // Initialises SDL2 for Events, Game Controller, Joystick, Audio and Video. private func initializeSDL() { setMoltenVKSettings() - SDL_SetMainReady() - SDL_iPhoneSetEventPump(SDL_TRUE) - SDL_Init(SdlInitFlags) + SDL_SetMainReady() // Sets SDL Ready + SDL_iPhoneSetEventPump(SDL_TRUE) // Allow iOS Set Event Pump (Check out SDL2 Documentation here) + SDL_Init(SdlInitFlags) // Initialises SDL2 initialize() } @@ -305,9 +318,8 @@ struct ContentView: View { - + // Sets MoltenVK Environment Variables private func setMoltenVKSettings() { - settings.forEach { setting in setenv(setting.string, setting.value, 1) } diff --git a/src/MeloNX/MeloNX/App/Views/GamesList/GameListView.swift b/src/MeloNX/MeloNX/App/Views/GamesList/GameListView.swift index eb4cb15e9..8aac6be9a 100644 --- a/src/MeloNX/MeloNX/App/Views/GamesList/GameListView.swift +++ b/src/MeloNX/MeloNX/App/Views/GamesList/GameListView.swift @@ -449,9 +449,10 @@ struct GameListRow: View { } Button { - // Add info action + let pasteboard = UIPasteboard.general + pasteboard.string = game.titleId } label: { - Label("Game Info", systemImage: "info.circle") + Label("Game ID: \(game.titleId)", systemImage: "info.circle") } } } diff --git a/src/MeloNX/MeloNX/MeloNX.entitlements b/src/MeloNX/MeloNX/MeloNX.entitlements index 99f471672..aff1d9915 100644 --- a/src/MeloNX/MeloNX/MeloNX.entitlements +++ b/src/MeloNX/MeloNX/MeloNX.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.kernel.extended-virtual-addressing + + com.apple.developer.kernel.increased-debugging-memory-limit + com.apple.developer.kernel.increased-memory-limit diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs index a71074995..16e8fdd4a 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs @@ -10,7 +10,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache class NoWxCache : IDisposable { private const int CodeAlignment = 4; // Bytes. - private const int SharedCacheSize = 2047 * 1024 * 1024; + private const int SharedCacheSize = 192 * 1024 * 1024; private const int LocalCacheSize = 128 * 1024 * 1024; // How many calls to the same function we allow until we pad the shared cache to force the function to become available there diff --git a/src/Ryujinx.Memory/MachJitWorkaround.cs b/src/Ryujinx.Memory/MachJitWorkaround.cs index bb123dd43..1b69b7444 100644 --- a/src/Ryujinx.Memory/MachJitWorkaround.cs +++ b/src/Ryujinx.Memory/MachJitWorkaround.cs @@ -46,7 +46,7 @@ namespace Ryujinx.Memory private const IntPtr TASK_NULL = 0; private static readonly IntPtr _selfTask; - private static readonly int DEFAULT_CHUNK_SIZE = 16 * 1024 * 1024; + private static readonly int DEFAULT_CHUNK_SIZE = 1024 * 1024; static MachJitWorkaround() { @@ -61,6 +61,8 @@ namespace Ryujinx.Memory { return totalSize; } + + chunkSize /= 2; int chunkCount = Math.Max(4, totalSize / DEFAULT_CHUNK_SIZE); return (totalSize + chunkCount - 1) / chunkCount; @@ -211,4 +213,4 @@ namespace Ryujinx.Memory } } } -} \ No newline at end of file +}