misc: More places need to factor in Auto, oops

This commit is contained in:
Evan Husted 2024-12-23 23:53:58 -06:00
parent f3545f5eae
commit 89f3c8235c
3 changed files with 33 additions and 13 deletions

View File

@ -305,14 +305,15 @@ namespace Ryujinx.UI.Common.Configuration
private static GraphicsBackend DefaultGraphicsBackend() private static GraphicsBackend DefaultGraphicsBackend()
{ {
// Any system running macOS or returning any amount of valid Vulkan devices should default to Vulkan. // Any system running macOS should default to auto, so it uses Vulkan everywhere and Metal in games where it works well.
// Checks for if the Vulkan version and featureset is compatible should be performed within VulkanRenderer. if (OperatingSystem.IsMacOS())
if (OperatingSystem.IsMacOS() || VulkanRenderer.GetPhysicalDevices().Length > 0) return GraphicsBackend.Auto;
{
return GraphicsBackend.Vulkan;
}
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;
} }
}
}

View File

@ -3,6 +3,7 @@ using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Threading; using Avalonia.Threading;
using Gommon;
using LibHac.Common; using LibHac.Common;
using LibHac.Ns; using LibHac.Ns;
using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem;
@ -142,6 +143,23 @@ namespace Ryujinx.Ava
public ulong ApplicationId { get; private set; } public ulong ApplicationId { get; private set; }
public bool ScreenshotRequested { get; 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( public AppHost(
RendererHost renderer, RendererHost renderer,
InputManager inputManager, InputManager inputManager,
@ -895,15 +913,16 @@ namespace Ryujinx.Ava
// Initialize Renderer. // Initialize Renderer.
IRenderer 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( renderer = VulkanRenderer.Create(
ConfigurationState.Instance.Graphics.PreferredGpu, ConfigurationState.Instance.Graphics.PreferredGpu,
(RendererHost.EmbeddedWindow as EmbeddedWindowVulkan)!.CreateSurface, (RendererHost.EmbeddedWindow as EmbeddedWindowVulkan)!.CreateSurface,
VulkanHelper.GetRequiredInstanceExtensions); VulkanHelper.GetRequiredInstanceExtensions);
} }
else if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Metal && OperatingSystem.IsMacOS()) else if (ShouldInitMetal)
{ {
renderer = new MetalRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowMetal).CreateSurface); renderer = new MetalRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowMetal).CreateSurface);
} }

View File

@ -30,7 +30,7 @@ namespace Ryujinx.Ava.UI.Renderer
Initialize(); Initialize();
} }
private readonly string[] _knownGreatMetalTitles = public static readonly string[] KnownGreatMetalTitles =
[ [
"01006A800016E000", // Smash Ultimate "01006A800016E000", // Smash Ultimate
"0100000000010000", // Super Mario Odyessy "0100000000010000", // Super Mario Odyessy
@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.Renderer
EmbeddedWindow = EmbeddedWindow =
OperatingSystem.IsMacOS() && OperatingSystem.IsMacOS() &&
RuntimeInformation.ProcessArchitecture == Architecture.Arm64 && RuntimeInformation.ProcessArchitecture == Architecture.Arm64 &&
_knownGreatMetalTitles.ContainsIgnoreCase(titleId) KnownGreatMetalTitles.ContainsIgnoreCase(titleId)
? new EmbeddedWindowMetal() ? new EmbeddedWindowMetal()
: new EmbeddedWindowVulkan(); : new EmbeddedWindowVulkan();
break; break;