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()
{
// 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;
}
}
}

View file

@ -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);
}

View file

@ -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;