From beda3206e0a17ff8807fff1bbe014b24c2683e3d Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sat, 18 Jan 2025 10:52:32 -0600 Subject: [PATCH] Only selectively compile Metal & fix some compilation issues --- src/Ryujinx/AppHost.cs | 2 +- src/Ryujinx/Headless/HeadlessRyujinx.Init.cs | 6 ++---- src/Ryujinx/Ryujinx.csproj | 2 +- src/Ryujinx/UI/Renderer/EmbeddedWindow.cs | 3 +-- src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs | 2 ++ 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index a35a79e86..e3a35376c 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -897,7 +897,7 @@ namespace Ryujinx.Ava { #pragma warning disable CA1416 // This call site is reachable on all platforms // SelectGraphicsBackend does a check for Mac, on top of checking if it's an ARM Mac. This isn't a problem. - GraphicsBackend.Metal => new MetalRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowMetal)!.CreateSurface), + GraphicsBackend.Metal => new MetalRenderer(() => new SharpMetal.QuartzCore.CAMetalLayer(((EmbeddedWindowMetal)RendererHost.EmbeddedWindow).MetalLayer)), #pragma warning restore CA1416 GraphicsBackend.Vulkan => VulkanRenderer.Create( ConfigurationState.Instance.Graphics.PreferredGpu, diff --git a/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs b/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs index 7d75ac7c1..e92a56833 100644 --- a/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs +++ b/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs @@ -12,8 +12,6 @@ using Ryujinx.Common.Logging; using Ryujinx.Common.Utilities; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL.Multithreading; -using Ryujinx.Graphics.Metal; -using Ryujinx.Graphics.OpenGL; using Ryujinx.Graphics.Vulkan; using Ryujinx.HLE; using Ryujinx.Input; @@ -312,10 +310,10 @@ namespace Ryujinx.Headless if (options.GraphicsBackend == GraphicsBackend.Metal && window is MetalWindow metalWindow && OperatingSystem.IsMacOS()) { - return new MetalRenderer(metalWindow.GetLayer); + return new Graphics.Metal.MetalRenderer(metalWindow.GetLayer); } - return new OpenGLRenderer(); + return new Graphics.OpenGL.OpenGLRenderer(); } private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options) diff --git a/src/Ryujinx/Ryujinx.csproj b/src/Ryujinx/Ryujinx.csproj index 682a08475..c7cdef14c 100644 --- a/src/Ryujinx/Ryujinx.csproj +++ b/src/Ryujinx/Ryujinx.csproj @@ -72,7 +72,7 @@ - + diff --git a/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs b/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs index eea9be283..87b66e4f3 100644 --- a/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs +++ b/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs @@ -1,6 +1,5 @@ using Avalonia; using Avalonia.Controls; -using Avalonia.Input; using Avalonia.Platform; using Ryujinx.Ava.Utilities.Configuration; using Ryujinx.Common.Configuration; @@ -28,7 +27,7 @@ namespace Ryujinx.Ava.UI.Renderer protected nint WindowHandle { get; set; } protected nint X11Display { get; set; } protected nint NsView { get; set; } - protected nint MetalLayer { get; set; } + public nint MetalLayer { get; protected set; } public delegate void UpdateBoundsCallbackDelegate(Rect rect); private UpdateBoundsCallbackDelegate _updateBoundsCallback; diff --git a/src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs b/src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs index eaf6f7bdf..7a2932075 100644 --- a/src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs +++ b/src/Ryujinx/UI/Renderer/EmbeddedWindowMetal.cs @@ -1,8 +1,10 @@ using SharpMetal.QuartzCore; using System; +using System.Runtime.Versioning; namespace Ryujinx.Ava.UI.Renderer { + [SupportedOSPlatform("macos")] public class EmbeddedWindowMetal : EmbeddedWindow { public CAMetalLayer CreateSurface()