From 03cf8183a799b1212ee33f9692d27761e06ac798 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 11 Dec 2022 14:48:22 -0800 Subject: [PATCH] feat: add DXVK settings tab * removed a few settings from wine tab * Added dxvk settings to launcher.ini * Updated CreateCompatToolsInstance to work with new dxvkSettings * Requires PR#1205 from FFXIVQuickLauncher * Suggest doing PR#13, #15 on xlcore, for better look and feel. --- .../Components/SettingsPage/SettingsPage.cs | 1 + .../SettingsPage/Tabs/SettingsTabDXVK.cs | 66 +++++++++++++++++++ .../SettingsPage/Tabs/SettingsTabWine.cs | 2 - .../Configuration/ILauncherConfig.cs | 8 +++ src/XIVLauncher.Core/Program.cs | 6 +- 5 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDXVK.cs diff --git a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs index c4886f48..2d066a82 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/SettingsPage.cs @@ -11,6 +11,7 @@ public class SettingsPage : Page new SettingsTabGame(), new SettingsTabPatching(), new SettingsTabWine(), + new SettingsTabDXVK(), new SettingsTabDalamud(), new SettingsTabAutoStart(), new SettingsTabAbout(), diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDXVK.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDXVK.cs new file mode 100644 index 00000000..0bd72cb8 --- /dev/null +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabDXVK.cs @@ -0,0 +1,66 @@ +using System.Numerics; +using System.Runtime.InteropServices; +using ImGuiNET; +using XIVLauncher.Common.Unix.Compatibility; +using XIVLauncher.Common.Util; + +namespace XIVLauncher.Core.Components.SettingsPage.Tabs; + +public class SettingsTabDXVK : SettingsTab +{ + private SettingsEntry dxvkHudSetting; + + public SettingsTabDXVK() + { + Entries = new SettingsEntry[] + { + new SettingsEntry("DXVK Version", "Choose which version of DXVK to use.", () => Program.Config.DxvkVersion, type => Program.Config.DxvkVersion = type), + new SettingsEntry("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b), + dxvkHudSetting = new SettingsEntry("DXVK Overlay", "DXVK Hud is included. MangoHud must be installed separately.\nFlatpak XIVLauncher needs flatpak MangoHud.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type) + { + CheckValidity = type => + { + if ((type == Dxvk.DxvkHudType.MangoHud || type == Dxvk.DxvkHudType.MangoHudCustom || type == Dxvk.DxvkHudType.MangoHudFull) + && (!File.Exists("/usr/lib/mangohud/libMangoHud.so") && !File.Exists("/usr/lib/extensions/vulkan/MangoHud/lib/x86_64-linux-gnu/libMangoHud.so"))) + return "MangoHud not detected."; + + return null; + } + }, + new SettingsEntry("DXVK Hud Custom String", "Set a custom string for the built in DXVK Hud. Warning: If it's invalid, the game may hang.", () => Program.Config.DxvkHudCustom, s => Program.Config.DxvkHudCustom = s) + { + CheckVisibility = () => dxvkHudSetting.Value == Dxvk.DxvkHudType.Custom, + CheckWarning = s => + { + if(!DxvkSettings.CheckDxvkHudString(s)) + return "That's not a valid hud string"; + return null; + }, + }, + new SettingsEntry("MangoHud Custom Path", "Set a custom path for MangoHud config file.", () => Program.Config.DxvkMangoCustom, s => Program.Config.DxvkMangoCustom = s) + { + CheckVisibility = () => dxvkHudSetting.Value == Dxvk.DxvkHudType.MangoHudCustom, + CheckWarning = s => + { + if(!DxvkSettings.CheckMangoHudPath(s)) + return "That's not a valid file."; + return null; + }, + }, + new NumericSettingsEntry("Frame Rate Limit", "Set a frame rate limit, and DXVK will try not exceed it. Use 0 to leave unset.", () => Program.Config.DxvkFrameRate ?? 0, i => Program.Config.DxvkFrameRate = i, 0, 1000), + }; + } + + public override SettingsEntry[] Entries { get; } + + public override bool IsUnixExclusive => true; + + public override string Title => "DXVK"; + + public override void Save() + { + base.Save(); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + Program.CreateCompatToolsInstance(); + } +} \ No newline at end of file diff --git a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs index dc4fbcfa..9387df3d 100644 --- a/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs +++ b/src/XIVLauncher.Core/Components/SettingsPage/Tabs/SettingsTabWine.cs @@ -36,7 +36,6 @@ public SettingsTabWine() } }, - new SettingsEntry("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b), new SettingsEntry("Enable ESync", "Enable eventfd-based synchronization.", () => Program.Config.ESyncEnabled ?? true, b => Program.Config.ESyncEnabled = b), new SettingsEntry("Enable FSync", "Enable fast user mutex (futex2).", () => Program.Config.FSyncEnabled ?? true, b => Program.Config.FSyncEnabled = b) { @@ -50,7 +49,6 @@ public SettingsTabWine() } }, - new SettingsEntry("DXVK Overlay", "Configure how much of the DXVK overlay is to be shown.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type), new SettingsEntry("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s) }; } diff --git a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs index bd72c4e2..a25536ad 100644 --- a/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs +++ b/src/XIVLauncher.Core/Configuration/ILauncherConfig.cs @@ -66,14 +66,22 @@ public interface ILauncherConfig public bool? GameModeEnabled { get; set; } + public Dxvk.DxvkVersion DxvkVersion { get; set; } + public bool? DxvkAsyncEnabled { get; set; } + public int? DxvkFrameRate { get; set; } + public bool? ESyncEnabled { get; set; } public bool? FSyncEnabled { get; set; } public Dxvk.DxvkHudType DxvkHudType { get; set; } + public string? DxvkHudCustom { get; set; } + + public string? DxvkMangoCustom { get; set; } + public string? WineDebugVars { get; set; } #endregion diff --git a/src/XIVLauncher.Core/Program.cs b/src/XIVLauncher.Core/Program.cs index 11d89809..fe8ef798 100644 --- a/src/XIVLauncher.Core/Program.cs +++ b/src/XIVLauncher.Core/Program.cs @@ -108,8 +108,11 @@ private static void LoadConfig(Storage storage) Config.GameModeEnabled ??= false; Config.DxvkAsyncEnabled ??= true; + Config.DxvkFrameRate ??= 0; Config.ESyncEnabled ??= true; Config.FSyncEnabled ??= false; + Config.DxvkHudCustom ??= "fps,frametimes,gpuload,version"; + Config.DxvkMangoCustom ??= Environment.GetEnvironmentVariable("HOME") + "/.config/MangoHud/MangoHud.conf"; Config.WineStartupType ??= WineStartupType.Managed; Config.WineBinaryPath ??= "/usr/bin"; @@ -275,7 +278,8 @@ public static void CreateCompatToolsInstance() var winePrefix = storage.GetFolder("wineprefix"); var wineSettings = new WineSettings(Config.WineStartupType, Config.WineBinaryPath, Config.WineDebugVars, wineLogFile, winePrefix, Config.ESyncEnabled, Config.FSyncEnabled); var toolsFolder = storage.GetFolder("compatibilitytool"); - CompatibilityTools = new CompatibilityTools(wineSettings, Config.DxvkHudType, Config.GameModeEnabled, Config.DxvkAsyncEnabled, toolsFolder); + var dxvkSettings = new DxvkSettings(Config.DxvkHudType, Config.DxvkHudCustom, Config.DxvkMangoCustom, Config.DxvkAsyncEnabled, Config.DxvkFrameRate, Config.DxvkVersion, storage.Root); + CompatibilityTools = new CompatibilityTools(wineSettings, dxvkSettings, Config.GameModeEnabled, toolsFolder); } public static void ShowWindow()