diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index 04ddd442f..90bdc3409 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -305,14 +305,15 @@ namespace Ryujinx.UI.Common.Configuration private static GraphicsBackend DefaultGraphicsBackend() { - // Any system running macOS or returning any amount of valid Vulkan devices should default to Vulkan. - // Checks for if the Vulkan version and featureset is compatible should be performed within VulkanRenderer. - if (OperatingSystem.IsMacOS() || VulkanRenderer.GetPhysicalDevices().Length > 0) - { - return GraphicsBackend.Vulkan; - } + // Any system running macOS should default to auto, so it uses Vulkan everywhere and Metal in games where it works well. + if (OperatingSystem.IsMacOS()) + return GraphicsBackend.Auto; - return GraphicsBackend.OpenGl; - } - } + // Any system returning any amount of valid Vulkan devices should default to Vulkan. + // Checks for if the Vulkan version and featureset is compatible should be performed within VulkanRenderer. + return VulkanRenderer.GetPhysicalDevices().Length > 0 + ? GraphicsBackend.Vulkan + : GraphicsBackend.OpenGl; } + } +} diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index cbf073caa..b42bd1d49 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -3,6 +3,7 @@ using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Input; using Avalonia.Threading; +using Gommon; using LibHac.Common; using LibHac.Ns; using LibHac.Tools.FsSystem; @@ -142,6 +143,23 @@ namespace Ryujinx.Ava public ulong ApplicationId { get; private set; } public bool ScreenshotRequested { get; set; } + public bool ShouldInitMetal + { + get + { + return OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64 && + ( + ( + ( + ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Auto && + RendererHost.KnownGreatMetalTitles.ContainsIgnoreCase(ApplicationId.ToString("X16")) + ) || + ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Metal + ) + ); + } + } + public AppHost( RendererHost renderer, InputManager inputManager, @@ -895,15 +913,16 @@ namespace Ryujinx.Ava // Initialize Renderer. IRenderer renderer; + GraphicsBackend backend = ConfigurationState.Instance.Graphics.GraphicsBackend; - if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan) + if (backend == GraphicsBackend.Vulkan || (backend == GraphicsBackend.Auto && !ShouldInitMetal)) { renderer = VulkanRenderer.Create( ConfigurationState.Instance.Graphics.PreferredGpu, (RendererHost.EmbeddedWindow as EmbeddedWindowVulkan)!.CreateSurface, VulkanHelper.GetRequiredInstanceExtensions); } - else if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Metal && OperatingSystem.IsMacOS()) + else if (ShouldInitMetal) { renderer = new MetalRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowMetal).CreateSurface); } diff --git a/src/Ryujinx/UI/Renderer/RendererHost.axaml.cs b/src/Ryujinx/UI/Renderer/RendererHost.axaml.cs index 58eba063c..8b5dd3065 100644 --- a/src/Ryujinx/UI/Renderer/RendererHost.axaml.cs +++ b/src/Ryujinx/UI/Renderer/RendererHost.axaml.cs @@ -30,7 +30,7 @@ namespace Ryujinx.Ava.UI.Renderer Initialize(); } - private readonly string[] _knownGreatMetalTitles = + public static readonly string[] KnownGreatMetalTitles = [ "01006A800016E000", // Smash Ultimate "0100000000010000", // Super Mario Odyessy @@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.Renderer EmbeddedWindow = OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64 && - _knownGreatMetalTitles.ContainsIgnoreCase(titleId) + KnownGreatMetalTitles.ContainsIgnoreCase(titleId) ? new EmbeddedWindowMetal() : new EmbeddedWindowVulkan(); break;