Просмотр исходного кода

Only selectively compile Metal & fix some compilation issues

Evan Husted 1 год назад
Родитель
Сommit
beda3206e0

+ 1 - 1
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,

+ 2 - 4
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)

+ 1 - 1
src/Ryujinx/Ryujinx.csproj

@@ -72,7 +72,7 @@
   <ItemGroup>
     <ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
     <ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
-    <ProjectReference Include="..\Ryujinx.Graphics.OpenGL\Ryujinx.Graphics.OpenGL.csproj" Condition="'$(RuntimeIdentifier)' != 'osx-x64' AND '$(RuntimeIdentifier)' != 'osx-arm64'" />
+    <ProjectReference Include="..\Ryujinx.Graphics.OpenGL\Ryujinx.Graphics.OpenGL.csproj" />
     <ProjectReference Include="..\Ryujinx.Graphics.Metal\Ryujinx.Graphics.Metal.csproj" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'linux-arm64' AND '$(RuntimeIdentifier)' != 'win-x64'" />
     <ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
     <ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />

+ 1 - 2
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;

+ 2 - 0
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()