diff options
Diffstat (limited to 'Ryujinx.Ava/Program.cs')
-rw-r--r-- | Ryujinx.Ava/Program.cs | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/Ryujinx.Ava/Program.cs b/Ryujinx.Ava/Program.cs index 8af7af7a..be27e9cd 100644 --- a/Ryujinx.Ava/Program.cs +++ b/Ryujinx.Ava/Program.cs @@ -3,6 +3,7 @@ using Avalonia; using Avalonia.OpenGL; using Avalonia.Rendering; using Avalonia.Threading; +using Ryujinx.Ava.Ui.Backend; using Ryujinx.Ava.Ui.Controls; using Ryujinx.Ava.Ui.Windows; using Ryujinx.Common; @@ -11,9 +12,12 @@ using Ryujinx.Common.GraphicsDriver; using Ryujinx.Common.Logging; using Ryujinx.Common.System; using Ryujinx.Common.SystemInfo; +using Ryujinx.Graphics.Vulkan; using Ryujinx.Modules; using Ryujinx.Ui.Common; using Ryujinx.Ui.Common.Configuration; +using Silk.NET.Vulkan.Extensions.EXT; +using Silk.NET.Vulkan.Extensions.KHR; using System; using System.Collections.Generic; using System.IO; @@ -25,17 +29,20 @@ namespace Ryujinx.Ava internal class Program { public static double WindowScaleFactor { get; set; } + public static double ActualScaleFactor { get; set; } public static string Version { get; private set; } public static string ConfigurationPath { get; private set; } public static string CommandLineProfile { get; set; } public static bool PreviewerDetached { get; private set; } public static RenderTimer RenderTimer { get; private set; } + public static bool UseVulkan { get; private set; } [DllImport("user32.dll", SetLastError = true)] public static extern int MessageBoxA(IntPtr hWnd, string text, string caption, uint type); private const uint MB_ICONWARNING = 0x30; + private const int BaseDpi = 96; public static void Main(string[] args) { @@ -66,7 +73,7 @@ namespace Ryujinx.Ava EnableMultiTouch = true, EnableIme = true, UseEGL = false, - UseGpu = true, + UseGpu = !UseVulkan, GlProfiles = new List<GlVersion>() { new GlVersion(GlProfileType.OpenGL, 4, 3) @@ -75,7 +82,7 @@ namespace Ryujinx.Ava .With(new Win32PlatformOptions { EnableMultitouch = true, - UseWgl = true, + UseWgl = !UseVulkan, WglProfiles = new List<GlVersion>() { new GlVersion(GlProfileType.OpenGL, 4, 3) @@ -84,6 +91,19 @@ namespace Ryujinx.Ava CompositionBackdropCornerRadius = 8f, }) .UseSkia() + .With(new Ui.Vulkan.VulkanOptions() + { + ApplicationName = "Ryujinx.Graphics.Vulkan", + VulkanVersion = new Version(1, 2), + MaxQueueCount = 2, + PreferDiscreteGpu = true, + PreferredDevice = !PreviewerDetached ? "" : ConfigurationState.Instance.Graphics.PreferredGpu.Value, + UseDebug = !PreviewerDetached ? false : ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value != GraphicsDebugLevel.None, + }) + .With(new SkiaOptions() + { + CustomGpuFactory = UseVulkan ? SkiaGpuFactory.CreateVulkanGpu : null + }) .AfterSetup(_ => { AvaloniaLocator.CurrentMutable @@ -136,9 +156,6 @@ namespace Ryujinx.Ava } } - // Make process DPI aware for proper window sizing on high-res screens. - WindowScaleFactor = ForceDpiAware.GetWindowScaleFactor(); - // Delete backup files after updating. Task.Run(Updater.CleanupUpdate); @@ -162,6 +179,18 @@ namespace Ryujinx.Ava ReloadConfig(); + UseVulkan = PreviewerDetached ? ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan : false; + + if (UseVulkan) + { + // With a custom gpu backend, avalonia doesn't enable dpi awareness, so the backend must handle it. This isn't so for the opengl backed, + // as that uses avalonia's gpu backend and it's enabled there. + ForceDpiAware.Windows(); + } + + WindowScaleFactor = ForceDpiAware.GetWindowScaleFactor(); + ActualScaleFactor = ForceDpiAware.GetActualScaleFactor() / BaseDpi; + // Logging system information. PrintSystemInfo(); |