From fe921f6ba6828b4cb92d3790178dc37b83624a57 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 5 Dec 2022 15:56:25 -0800 Subject: [PATCH 01/32] fix: Launcher.cs changed to work with xlcore * Change the 4th arg in constructor to have a default value of null * xlcore calls this with only 3 args, so this allows compiling. --- src/XIVLauncher.Common/Game/Launcher.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Common/Game/Launcher.cs b/src/XIVLauncher.Common/Game/Launcher.cs index 7971123c..58b4d7d9 100644 --- a/src/XIVLauncher.Common/Game/Launcher.cs +++ b/src/XIVLauncher.Common/Game/Launcher.cs @@ -40,7 +40,7 @@ public class Launcher private const string FALLBACK_FRONTIER_URL_TEMPLATE = "https://launcher.finalfantasyxiv.com/v620/index.html?rc_lang={0}&time={1}"; - public Launcher(ISteam? steam, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl) + public Launcher(ISteam? steam, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl = null) { this.steam = steam; this.uniqueIdCache = uniqueIdCache; @@ -71,7 +71,7 @@ public Launcher(ISteam? steam, IUniqueIdCache uniqueIdCache, ISettings settings, this.client = new HttpClient(handler); } - public Launcher(byte[] steamTicket, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl) + public Launcher(byte[] steamTicket, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl = null) : this(steam: null, uniqueIdCache, settings, frontierUrl) { this.steamTicket = steamTicket; From 72bd2e44619eb2faaecf8ded84ee76fbc3b88bdf Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 5 Dec 2022 20:38:24 -0800 Subject: [PATCH 02/32] feat: add DxvkSettings & related * Add dxvkVersion * Move dxvkAsync, dxvkHud into DxvkSettings * Set up dictionary for setting env vars. This will allow arbitrary number of vars to be set. * Reworked CompatibilityTools to support new features. --- .../Compatibility/CompatibilityTools.cs | 44 +++++++++------ .../Compatibility/Dxvk.cs | 29 +++++++--- .../Compatibility/DxvkSettings.cs | 54 +++++++++++++++++++ 3 files changed, 102 insertions(+), 25 deletions(-) create mode 100644 src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index 33b6759b..c9215728 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -43,17 +43,15 @@ public class CompatibilityTools public bool IsToolDownloaded => File.Exists(Wine64Path) && Settings.Prefix.Exists; - private readonly Dxvk.DxvkHudType hudType; + public DxvkSettings DxvkSettings { get; private set; } + private readonly bool gamemodeOn; - private readonly string dxvkAsyncOn; - public CompatibilityTools(WineSettings wineSettings, Dxvk.DxvkHudType hudType, bool? gamemodeOn, bool? dxvkAsyncOn, DirectoryInfo toolsFolder) + public CompatibilityTools(WineSettings wineSettings, DxvkSettings dxvkSettings, bool? gamemodeOn, DirectoryInfo toolsFolder) { this.Settings = wineSettings; - this.hudType = hudType; + this.DxvkSettings = dxvkSettings; this.gamemodeOn = gamemodeOn ?? false; - this.dxvkAsyncOn = (dxvkAsyncOn ?? false) ? "1" : "0"; - this.toolDirectory = new DirectoryInfo(Path.Combine(toolsFolder.FullName, "beta")); this.dxvkDirectory = new DirectoryInfo(Path.Combine(toolsFolder.FullName, "dxvk")); @@ -68,10 +66,28 @@ public CompatibilityTools(WineSettings wineSettings, Dxvk.DxvkHudType hudType, b this.dxvkDirectory.Create(); } + if (!wineSettings.Prefix.Exists) + wineSettings.Prefix.Create(); + if (wineSettings.StartupType == WineStartupType.Managed) + { + if (!this.toolDirectory.Exists) + this.toolDirectory.Create(); + + if (!this.dxvkDirectory.Exists) + this.dxvkDirectory.Create(); + } + if (!wineSettings.Prefix.Exists) wineSettings.Prefix.Create(); } + public CompatibilityTools(WineSettings wineSettings, Dxvk.DxvkHudType hudType, bool? gamemodeOn, bool? dxvkAsyncOn, DirectoryInfo toolsFolder) + : this(wineSettings, new DxvkSettings(hudType, dxvkAsyncOn), gamemodeOn, toolsFolder) + { + // Old constructor format. This is for compatibility with XL.Core. Once changes are made + // there, this can be deleted. + } + public async Task EnsureTool(DirectoryInfo tempPath) { if (!File.Exists(Wine64Path)) @@ -81,7 +97,7 @@ public async Task EnsureTool(DirectoryInfo tempPath) } EnsurePrefix(); - await Dxvk.InstallDxvk(Settings.Prefix, dxvkDirectory).ConfigureAwait(false); + await Dxvk.InstallDxvk(Settings.Prefix, dxvkDirectory, DxvkSettings).ConfigureAwait(false); IsToolReady = true; } @@ -168,21 +184,15 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict wineEnviromentVariables.Add("XL_WINEONLINUX", "true"); string ldPreload = Environment.GetEnvironmentVariable("LD_PRELOAD") ?? ""; - string dxvkHud = hudType switch - { - Dxvk.DxvkHudType.None => "0", - Dxvk.DxvkHudType.Fps => "fps", - Dxvk.DxvkHudType.Full => "full", - _ => throw new ArgumentOutOfRangeException() - }; - if (this.gamemodeOn == true && !ldPreload.Contains("libgamemodeauto.so.0")) { ldPreload = ldPreload.Equals("") ? "libgamemodeauto.so.0" : ldPreload + ":libgamemodeauto.so.0"; } - wineEnviromentVariables.Add("DXVK_HUD", dxvkHud); - wineEnviromentVariables.Add("DXVK_ASYNC", dxvkAsyncOn); + foreach(KeyValuePair dxvkVar in DxvkSettings.DxvkVars) + { + wineEnviromentVariables.Add(dxvkVar.Key, dxvkVar.Value); + } wineEnviromentVariables.Add("WINEESYNC", Settings.EsyncOn); wineEnviromentVariables.Add("WINEFSYNC", Settings.FsyncOn); diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index 50fa98d9..69450483 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -8,17 +8,15 @@ namespace XIVLauncher.Common.Unix.Compatibility; public static class Dxvk { - private const string DXVK_DOWNLOAD = "https://github.com/Sporif/dxvk-async/releases/download/1.10.1/dxvk-async-1.10.1.tar.gz"; - private const string DXVK_NAME = "dxvk-async-1.10.1"; - - public static async Task InstallDxvk(DirectoryInfo prefix, DirectoryInfo installDirectory) + public static async Task InstallDxvk(DirectoryInfo prefix, DirectoryInfo installDirectory, DxvkSettings? dxvkSettings = null) { - var dxvkPath = Path.Combine(installDirectory.FullName, DXVK_NAME, "x64"); + dxvkSettings ??= new DxvkSettings(); + var dxvkPath = Path.Combine(installDirectory.FullName, dxvkSettings.FolderName, "x64"); if (!Directory.Exists(dxvkPath)) { Log.Information("DXVK does not exist, downloading"); - await DownloadDxvk(installDirectory).ConfigureAwait(false); + await DownloadDxvk(installDirectory, dxvkSettings.DownloadURL).ConfigureAwait(false); } var system32 = Path.Combine(prefix.FullName, "drive_c", "windows", "system32"); @@ -30,12 +28,12 @@ public static async Task InstallDxvk(DirectoryInfo prefix, DirectoryInfo install } } - private static async Task DownloadDxvk(DirectoryInfo installDirectory) + private static async Task DownloadDxvk(DirectoryInfo installDirectory, string downloadURL) { using var client = new HttpClient(); var tempPath = Path.GetTempFileName(); - File.WriteAllBytes(tempPath, await client.GetByteArrayAsync(DXVK_DOWNLOAD)); + File.WriteAllBytes(tempPath, await client.GetByteArrayAsync(downloadURL)); PlatformHelpers.Untar(tempPath, installDirectory.FullName); File.Delete(tempPath); @@ -52,4 +50,19 @@ public enum DxvkHudType [SettingsDescription("Full", "Show everything")] Full, } + + public enum DxvkVersion + { + [SettingsDescription("1.10.1 (default)", "The default version of DXVK used with XIVLauncher.Core.")] + v1_10_1, + + [SettingsDescription("1.10.2", "Newer version of 1.10 branch of DXVK. Probably works.")] + v1_10_2, + + [SettingsDescription("1.10.3", "Newer version of 1.10 branch of DXVK. Probably works.")] + v1_10_3, + + [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newest version of DXVK. Might break Dalamud or GShade.")] + v2_0, + } } \ No newline at end of file diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs new file mode 100644 index 00000000..8672fd84 --- /dev/null +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace XIVLauncher.Common.Unix.Compatibility; + +public class DxvkSettings +{ + public string DownloadURL { get; private set; } + + public string FolderName { get; private set; } + + public Dictionary DxvkVars { get; private set; } + + public Dxvk.DxvkHudType DxvkHud { get; private set; } + + public Dxvk.DxvkVersion DxvkVersion { get; private set; } + + public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, bool? async = true, + Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) + { + this.DxvkHud = hud; + this.DxvkVars = new Dictionary (); + this.DxvkVars.Add("DXVK_ASYNC", ((async ?? false) ? "1" : "0")); + this.DxvkVersion = version; + string release = this.DxvkVersion switch + { + Dxvk.DxvkVersion.v1_10_1 => "1.10.1", + Dxvk.DxvkVersion.v1_10_2 => "1.10.2", + Dxvk.DxvkVersion.v1_10_3 => "1.10.3", + Dxvk.DxvkVersion.v2_0 => "2.0", + _ => VersionOutOfRange(), + }; + this.DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; + this.FolderName = $"dxvk-async-{release}"; + + switch(this.DxvkHud) + { + case Dxvk.DxvkHudType.Fps: + DxvkVars.Add("DXVK_HUD","fps"); + break; + case Dxvk.DxvkHudType.Full: + DxvkVars.Add("DXVK_HUD","full"); + break; + // If DxvkHudType is None, or undefined, don't set anything. + default: + break; + } + } + + private string VersionOutOfRange() { + this.DxvkVersion = Dxvk.DxvkVersion.v1_10_1; + return "1.10.1"; + } +} \ No newline at end of file From 001ff3e5a146c0bef6207c1e429449bfcfe98f0f Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 5 Dec 2022 20:55:13 -0800 Subject: [PATCH 03/32] feat: add frame rate limit support * uses DXVK_FRAME_RATE, so doesn't work with wineD3D * leave unset instead of 0, since that lets the user script it. --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 8672fd84..95c6416f 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -16,11 +16,13 @@ public class DxvkSettings public Dxvk.DxvkVersion DxvkVersion { get; private set; } public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, bool? async = true, - Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) + int? frameRate = 0, Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) { this.DxvkHud = hud; this.DxvkVars = new Dictionary (); this.DxvkVars.Add("DXVK_ASYNC", ((async ?? false) ? "1" : "0")); + frameRate ??= 0; + if (frameRate > 0) this.DxvkVars.Add("DXVK_FRAME_RATE", (frameRate).ToString()); this.DxvkVersion = version; string release = this.DxvkVersion switch { From 7cc2a5a07afa066caaee59ce811a40ac48471ef4 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 5 Dec 2022 21:02:04 -0800 Subject: [PATCH 04/32] feat: add backend for dxvkhud custom string --- .../Compatibility/CompatibilityTools.cs | 2 +- src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs | 3 +++ src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index c9215728..43652726 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -82,7 +82,7 @@ public CompatibilityTools(WineSettings wineSettings, DxvkSettings dxvkSettings, } public CompatibilityTools(WineSettings wineSettings, Dxvk.DxvkHudType hudType, bool? gamemodeOn, bool? dxvkAsyncOn, DirectoryInfo toolsFolder) - : this(wineSettings, new DxvkSettings(hudType, dxvkAsyncOn), gamemodeOn, toolsFolder) + : this(wineSettings, new DxvkSettings(hudType, "", dxvkAsyncOn), gamemodeOn, toolsFolder) { // Old constructor format. This is for compatibility with XL.Core. Once changes are made // there, this can be deleted. diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index 69450483..f26ca9b5 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -47,6 +47,9 @@ public enum DxvkHudType [SettingsDescription("FPS", "Only show FPS")] Fps, + [SettingsDescription("DXVK Hud Custom", "Use a custom DXVK_HUD string")] + Custom, + [SettingsDescription("Full", "Show everything")] Full, } diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 95c6416f..a7149a76 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -15,7 +15,7 @@ public class DxvkSettings public Dxvk.DxvkVersion DxvkVersion { get; private set; } - public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, bool? async = true, + public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", bool? async = true, int? frameRate = 0, Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) { this.DxvkHud = hud; @@ -40,6 +40,10 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, bool? async = case Dxvk.DxvkHudType.Fps: DxvkVars.Add("DXVK_HUD","fps"); break; + case Dxvk.DxvkHudType.Custom: + if (dxvkHudCustom == "") dxvkHudCustom = "fps,frametimes,gpuload,version"; + DxvkVars.Add("DXVK_HUD",dxvkHudCustom); + break; case Dxvk.DxvkHudType.Full: DxvkVars.Add("DXVK_HUD","full"); break; From c0f50f7c211856e49d1d7ecb4dbc04f01557f94a Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 5 Dec 2022 21:21:57 -0800 Subject: [PATCH 05/32] feat: add support for MangoHud * Default is with no config * Custom will allow custom path to config file Currently uses ~/.config/MangoHud/MangoHud.conf by default. * Full shows almost everything. Very fun on a cpu with lots of cores and threads. --- .../Compatibility/CompatibilityTools.cs | 2 +- .../Compatibility/Dxvk.cs | 9 ++++++++ .../Compatibility/DxvkSettings.cs | 22 +++++++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index 43652726..a0152574 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -82,7 +82,7 @@ public CompatibilityTools(WineSettings wineSettings, DxvkSettings dxvkSettings, } public CompatibilityTools(WineSettings wineSettings, Dxvk.DxvkHudType hudType, bool? gamemodeOn, bool? dxvkAsyncOn, DirectoryInfo toolsFolder) - : this(wineSettings, new DxvkSettings(hudType, "", dxvkAsyncOn), gamemodeOn, toolsFolder) + : this(wineSettings, new DxvkSettings(hudType, "", "", dxvkAsyncOn), gamemodeOn, toolsFolder) { // Old constructor format. This is for compatibility with XL.Core. Once changes are made // there, this can be deleted. diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index f26ca9b5..9c6a6335 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -52,6 +52,15 @@ public enum DxvkHudType [SettingsDescription("Full", "Show everything")] Full, + + [SettingsDescription("MangoHud Default", "Uses no config file.")] + MangoHud, + + [SettingsDescription("MangoHud Custom", "Specify a custom config file")] + MangoHudCustom, + + [SettingsDescription("MangoHud Full", "Show (almost) everything")] + MangoHudFull, } public enum DxvkVersion diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index a7149a76..a928bc2c 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -15,8 +15,9 @@ public class DxvkSettings public Dxvk.DxvkVersion DxvkVersion { get; private set; } - public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", bool? async = true, - int? frameRate = 0, Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) + public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", + string mangoHudPath="", bool? async = true, int? frameRate = 0, + Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) { this.DxvkHud = hud; this.DxvkVars = new Dictionary (); @@ -47,6 +48,23 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud case Dxvk.DxvkHudType.Full: DxvkVars.Add("DXVK_HUD","full"); break; + case Dxvk.DxvkHudType.MangoHud: + DxvkVars.Add("DXVK_HUD","0"); + DxvkVars.Add("MANGOHUD","1"); + DxvkVars.Add("MANGOHUD_CONFIG", ""); + break; + case Dxvk.DxvkHudType.MangoHudCustom: + DxvkVars.Add("DXVK_HUD","0"); + DxvkVars.Add("MANGOHUD","1"); + if (mangoHudPath == "") + mangoHudPath = Environment.GetEnvironmentVariable("HOME") + "/.config/MangoHud/MangoHud.conf"; + DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); + break; + case Dxvk.DxvkHudType.MangoHudFull: + DxvkVars.Add("DXVK_HUD","0"); + DxvkVars.Add("MANGOHUD","1"); + DxvkVars.Add("MANGOHUD_CONFIG","full"); + break; // If DxvkHudType is None, or undefined, don't set anything. default: break; From 8381d030d5c3aa3612e696df78666d8304bf97f1 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Tue, 6 Dec 2022 07:26:06 -0800 Subject: [PATCH 06/32] fix: disable MangoHud when using DXVK Hud --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index a928bc2c..3bd234a5 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -40,13 +40,16 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud { case Dxvk.DxvkHudType.Fps: DxvkVars.Add("DXVK_HUD","fps"); + DxvkVars.Add("MANGOHUD","0"); break; case Dxvk.DxvkHudType.Custom: if (dxvkHudCustom == "") dxvkHudCustom = "fps,frametimes,gpuload,version"; DxvkVars.Add("DXVK_HUD",dxvkHudCustom); + DxvkVars.Add("MANGOHUD","0"); break; case Dxvk.DxvkHudType.Full: DxvkVars.Add("DXVK_HUD","full"); + DxvkVars.Add("MANGOHUD","0"); break; case Dxvk.DxvkHudType.MangoHud: DxvkVars.Add("DXVK_HUD","0"); From aad9315c4861a0c5c22b15c9c31e296496870ab1 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Tue, 6 Dec 2022 20:28:05 -0800 Subject: [PATCH 07/32] fix: use Path.Combine in MangoHud Custom * Use ~/.xlcore/MangoHud.conf as first option for MangoHud Custom * If that doesnt' exist, use ~/.config/MangoHud/wine-ffxiv_dx11.conf * Finally, fall back to ~/.config/MangoHud/MangoHud.conf If it can't find any of those, it'll just present the default. --- .../Compatibility/DxvkSettings.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 3bd234a5..45eab011 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Collections.Generic; namespace XIVLauncher.Common.Unix.Compatibility; @@ -60,7 +61,18 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud DxvkVars.Add("DXVK_HUD","0"); DxvkVars.Add("MANGOHUD","1"); if (mangoHudPath == "") - mangoHudPath = Environment.GetEnvironmentVariable("HOME") + "/.config/MangoHud/MangoHud.conf"; + { + string home = Environment.GetEnvironmentVariable("HOME"); + string conf1 = Path.Combine(home,".xlcore","MangoHud.conf"); + string conf2 = Path.Combine(home,".config","MangoHud","wine-ffxiv_dx11.conf"); + string conf3 = Path.Combine(home,".config","MangoHud","MangoHud.conf"); + if (File.Exists(conf1)) + mangoHudPath = conf1; + else if (File.Exists(conf2)) + mangoHudPath = conf2; + else + mangoHudPath = conf3; + } DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); break; case Dxvk.DxvkHudType.MangoHudFull: From 435396e75a2348a650bfe047952fd66bb5f06ee9 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 8 Dec 2022 15:46:13 -0800 Subject: [PATCH 08/32] fix: make sure mangohud.conf exists --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 45eab011..2a43e3ee 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -73,7 +73,8 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud else mangoHudPath = conf3; } - DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); + // Make absolutely sure the file exists, otherwise the game will hang. + if (File.Exists(mangoHudPath)) DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); break; case Dxvk.DxvkHudType.MangoHudFull: DxvkVars.Add("DXVK_HUD","0"); From 5dba7dc43dff5171a4fefaa993e6c7d3ce51e78f Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 9 Dec 2022 17:38:00 -0800 Subject: [PATCH 09/32] fix: basic validity checking added for custom huds * DXVK Hud will only accept alphanumeric, comma, and = * MangoHud config file must exist --- .../Compatibility/DxvkSettings.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 2a43e3ee..47e2caf4 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Collections.Generic; +using System.Text.RegularExpressions; namespace XIVLauncher.Common.Unix.Compatibility; @@ -44,7 +45,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud DxvkVars.Add("MANGOHUD","0"); break; case Dxvk.DxvkHudType.Custom: - if (dxvkHudCustom == "") dxvkHudCustom = "fps,frametimes,gpuload,version"; + if (!CheckDxvkHudString(dxvkHudCustom)) dxvkHudCustom = "fps,frametimes,gpuload,version"; DxvkVars.Add("DXVK_HUD",dxvkHudCustom); DxvkVars.Add("MANGOHUD","0"); break; @@ -60,21 +61,23 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud case Dxvk.DxvkHudType.MangoHudCustom: DxvkVars.Add("DXVK_HUD","0"); DxvkVars.Add("MANGOHUD","1"); - if (mangoHudPath == "") + if (!CheckMangoHudPath(mangoHudPath)) { string home = Environment.GetEnvironmentVariable("HOME"); string conf1 = Path.Combine(home,".xlcore","MangoHud.conf"); string conf2 = Path.Combine(home,".config","MangoHud","wine-ffxiv_dx11.conf"); string conf3 = Path.Combine(home,".config","MangoHud","MangoHud.conf"); - if (File.Exists(conf1)) + if (CheckMangoHudPath(conf1)) mangoHudPath = conf1; - else if (File.Exists(conf2)) + else if (CheckMangoHudPath(conf2)) mangoHudPath = conf2; - else + else if (CheckMangoHudPath(conf3)) mangoHudPath = conf3; + else + DxvkVars.Add("MANGOHUD_CONFIG",""); + break; } - // Make absolutely sure the file exists, otherwise the game will hang. - if (File.Exists(mangoHudPath)) DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); + DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); break; case Dxvk.DxvkHudType.MangoHudFull: DxvkVars.Add("DXVK_HUD","0"); @@ -91,4 +94,16 @@ private string VersionOutOfRange() { this.DxvkVersion = Dxvk.DxvkVersion.v1_10_1; return "1.10.1"; } + + public static bool CheckDxvkHudString(string customHud) + { + if (string.IsNullOrWhiteSpace(customHud)) return false; + if (!Regex.IsMatch(customHud,"^[0-9a-zA-Z,=]*$")) return false; + return true; + } + + public static bool CheckMangoHudPath(string mangoPath) + { + return (File.Exists(mangoPath)) ? true : false; + } } \ No newline at end of file From e4c4a4b06d569c401754e3695b24c0b94d460c4b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 9 Dec 2022 22:39:28 -0800 Subject: [PATCH 10/32] fix: improve dxvkhud checking with regex. --- .../Compatibility/DxvkSettings.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 47e2caf4..dcdc044e 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -17,6 +17,9 @@ public class DxvkSettings public Dxvk.DxvkVersion DxvkVersion { get; private set; } + private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; + private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9]){0,2}(?:.(?:[0-9])+)?)$"; + public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", string mangoHudPath="", bool? async = true, int? frameRate = 0, Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) @@ -98,7 +101,13 @@ private string VersionOutOfRange() { public static bool CheckDxvkHudString(string customHud) { if (string.IsNullOrWhiteSpace(customHud)) return false; - if (!Regex.IsMatch(customHud,"^[0-9a-zA-Z,=]*$")) return false; + if (!Regex.IsMatch(customHud,ALLOWED_CHARS)) return false; + string[] hudvars = customHud.Split(","); + foreach (var hudvar in hudvars) + { + if (!Regex.IsMatch(hudvar,ALLOWED_WORDS)) + return false; + } return true; } From d3fed4da22a30aab04e0855f389f2bc6df63e712 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Fri, 9 Dec 2022 22:50:31 -0800 Subject: [PATCH 11/32] fix: add "1" as valid value for dxvkhud --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index dcdc044e..16f76f19 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -100,6 +100,7 @@ private string VersionOutOfRange() { public static bool CheckDxvkHudString(string customHud) { + if (customHud == "1") return true; if (string.IsNullOrWhiteSpace(customHud)) return false; if (!Regex.IsMatch(customHud,ALLOWED_CHARS)) return false; string[] hudvars = customHud.Split(","); From 665abf26aa4b7297f9cfdbf5689c40d8eeba74fb Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 08:39:38 -0800 Subject: [PATCH 12/32] fix: mangohud.conf logic was broken, now fixed. * If the file is not found, it will now just not set the file path * This will cause MangoHud to fall back to default locations which is unlikely to work in flatpak, but that's okay. * If the value passed is empty, it'll try to find a few default paths in .xlcore and .config/MangoHud --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 16f76f19..dccc953d 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -64,7 +64,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud case Dxvk.DxvkHudType.MangoHudCustom: DxvkVars.Add("DXVK_HUD","0"); DxvkVars.Add("MANGOHUD","1"); - if (!CheckMangoHudPath(mangoHudPath)) + if (mangoHudPath == "") { string home = Environment.GetEnvironmentVariable("HOME"); string conf1 = Path.Combine(home,".xlcore","MangoHud.conf"); @@ -76,11 +76,9 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud mangoHudPath = conf2; else if (CheckMangoHudPath(conf3)) mangoHudPath = conf3; - else - DxvkVars.Add("MANGOHUD_CONFIG",""); - break; } - DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); + if (CheckMangoHudPath(mangoHudPath)) + DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); break; case Dxvk.DxvkHudType.MangoHudFull: DxvkVars.Add("DXVK_HUD","0"); From e31bf4688611977cfe8f732b803f01916c66c396 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 08:48:27 -0800 Subject: [PATCH 13/32] fix: flatpak breaks using fallback method * set to empty config instead. --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index dccc953d..e2bde433 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -79,6 +79,8 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud } if (CheckMangoHudPath(mangoHudPath)) DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); + else + DxvkVars.Add("MANGOHUD_CONFIG",""); break; case Dxvk.DxvkHudType.MangoHudFull: DxvkVars.Add("DXVK_HUD","0"); From f7b7aad5a59d8a7e208dbb8a58ea4097b439c37d Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:25:26 -0800 Subject: [PATCH 14/32] Update CompatibilityTools.cs --- .../Compatibility/CompatibilityTools.cs | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index a0152574..59f2cf2f 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -65,29 +65,8 @@ public CompatibilityTools(WineSettings wineSettings, DxvkSettings dxvkSettings, if (!this.dxvkDirectory.Exists) this.dxvkDirectory.Create(); } - - if (!wineSettings.Prefix.Exists) - wineSettings.Prefix.Create(); - if (wineSettings.StartupType == WineStartupType.Managed) - { - if (!this.toolDirectory.Exists) - this.toolDirectory.Create(); - - if (!this.dxvkDirectory.Exists) - this.dxvkDirectory.Create(); - } - - if (!wineSettings.Prefix.Exists) - wineSettings.Prefix.Create(); } - public CompatibilityTools(WineSettings wineSettings, Dxvk.DxvkHudType hudType, bool? gamemodeOn, bool? dxvkAsyncOn, DirectoryInfo toolsFolder) - : this(wineSettings, new DxvkSettings(hudType, "", "", dxvkAsyncOn), gamemodeOn, toolsFolder) - { - // Old constructor format. This is for compatibility with XL.Core. Once changes are made - // there, this can be deleted. - } - public async Task EnsureTool(DirectoryInfo tempPath) { if (!File.Exists(Wine64Path)) @@ -300,4 +279,4 @@ public void Kill() Process.Start(psi); } -} \ No newline at end of file +} From bf0fb66c62456aa8b4b55cb7589639f2704e766a Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:30:50 -0800 Subject: [PATCH 15/32] Update Launcher.cs Remove Launcher.cs commit; out of scope. --- src/XIVLauncher.Common/Game/Launcher.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Common/Game/Launcher.cs b/src/XIVLauncher.Common/Game/Launcher.cs index 58b4d7d9..7971123c 100644 --- a/src/XIVLauncher.Common/Game/Launcher.cs +++ b/src/XIVLauncher.Common/Game/Launcher.cs @@ -40,7 +40,7 @@ public class Launcher private const string FALLBACK_FRONTIER_URL_TEMPLATE = "https://launcher.finalfantasyxiv.com/v620/index.html?rc_lang={0}&time={1}"; - public Launcher(ISteam? steam, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl = null) + public Launcher(ISteam? steam, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl) { this.steam = steam; this.uniqueIdCache = uniqueIdCache; @@ -71,7 +71,7 @@ public Launcher(ISteam? steam, IUniqueIdCache uniqueIdCache, ISettings settings, this.client = new HttpClient(handler); } - public Launcher(byte[] steamTicket, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl = null) + public Launcher(byte[] steamTicket, IUniqueIdCache uniqueIdCache, ISettings settings, string? frontierUrl) : this(steam: null, uniqueIdCache, settings, frontierUrl) { this.steamTicket = steamTicket; From ad34feb05a297e47f25848797f7f2115f5fbb421 Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:35:11 -0800 Subject: [PATCH 16/32] Update DxvkSettings.cs Changes per marzent's suggestions. --- .../Compatibility/DxvkSettings.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index e2bde433..16a97f75 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -18,7 +18,7 @@ public class DxvkSettings public Dxvk.DxvkVersion DxvkVersion { get; private set; } private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; - private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9]){0,2}(?:.(?:[0-9])+)?)$"; + private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", string mangoHudPath="", bool? async = true, int? frameRate = 0, @@ -36,7 +36,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud Dxvk.DxvkVersion.v1_10_2 => "1.10.2", Dxvk.DxvkVersion.v1_10_3 => "1.10.3", Dxvk.DxvkVersion.v2_0 => "2.0", - _ => VersionOutOfRange(), + _ => throw new ArgumentOutOfRangeException(), }; this.DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; this.FolderName = $"dxvk-async-{release}"; @@ -93,11 +93,6 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud } } - private string VersionOutOfRange() { - this.DxvkVersion = Dxvk.DxvkVersion.v1_10_1; - return "1.10.1"; - } - public static bool CheckDxvkHudString(string customHud) { if (customHud == "1") return true; @@ -116,4 +111,4 @@ public static bool CheckMangoHudPath(string mangoPath) { return (File.Exists(mangoPath)) ? true : false; } -} \ No newline at end of file +} From 87282c6a7a2806aa8cfb29e5760326ba7951ba7b Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:49:10 -0800 Subject: [PATCH 17/32] Update Dxvk.cs * Change 1.10.2 & .3 to say safe to use. * Change 2.0 to be less redundant. --- src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index 9c6a6335..a61b82b0 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -68,13 +68,13 @@ public enum DxvkVersion [SettingsDescription("1.10.1 (default)", "The default version of DXVK used with XIVLauncher.Core.")] v1_10_1, - [SettingsDescription("1.10.2", "Newer version of 1.10 branch of DXVK. Probably works.")] + [SettingsDescription("1.10.2", "Newer version of 1.10 branch of DXVK. Safe to use.")] v1_10_2, - [SettingsDescription("1.10.3", "Newer version of 1.10 branch of DXVK. Probably works.")] + [SettingsDescription("1.10.3", "Newer version of 1.10 branch of DXVK. Safe to use.")] v1_10_3, - [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newest version of DXVK. Might break Dalamud or GShade.")] + [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newest version of DXVK. May be faster, but not stable yet.")] v2_0, } -} \ No newline at end of file +} From f47ddca3743a75222fde28df3e7f07fdb30a186b Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 12:31:46 -0800 Subject: [PATCH 18/32] feat: Add dxvk log, cache, config --- .../Compatibility/DxvkSettings.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 16a97f75..f95c2a9a 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -22,10 +22,15 @@ public class DxvkSettings public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", string mangoHudPath="", bool? async = true, int? frameRate = 0, - Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1) + Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1, string? corePath = null) { this.DxvkHud = hud; + string home = Environment.GetEnvironmentVariable("HOME"); + corePath ??= Path.Combine(home,".xlcore"); + string dxvkConfigPath = Path.Combine(corePath,".dxvk"); this.DxvkVars = new Dictionary (); + this.DxvkVars.Add("DXVK_LOG_PATH",Path.Combine(corePath,"logs")); + this.DxvkVars.Add("DXVK_CONFIG_FILE",Path.Combine(dxvkConfigPath,"dxvk.conf")); this.DxvkVars.Add("DXVK_ASYNC", ((async ?? false) ? "1" : "0")); frameRate ??= 0; if (frameRate > 0) this.DxvkVars.Add("DXVK_FRAME_RATE", (frameRate).ToString()); @@ -40,7 +45,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud }; this.DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; this.FolderName = $"dxvk-async-{release}"; - + this.DxvkVars.Add("DXVK_STATE_CACHE_PATH",Path.Combine(dxvkConfigPath,release)); switch(this.DxvkHud) { case Dxvk.DxvkHudType.Fps: @@ -66,8 +71,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud DxvkVars.Add("MANGOHUD","1"); if (mangoHudPath == "") { - string home = Environment.GetEnvironmentVariable("HOME"); - string conf1 = Path.Combine(home,".xlcore","MangoHud.conf"); + string conf1 = Path.Combine(corePath,"MangoHud.conf"); string conf2 = Path.Combine(home,".config","MangoHud","wine-ffxiv_dx11.conf"); string conf3 = Path.Combine(home,".config","MangoHud","MangoHud.conf"); if (CheckMangoHudPath(conf1)) From 84ed99999a1404754581913014929c62d2fb1b18 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 12:45:14 -0800 Subject: [PATCH 19/32] fix: Make sure to create .dxvk folder --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index f95c2a9a..dc12605f 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -28,6 +28,8 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud string home = Environment.GetEnvironmentVariable("HOME"); corePath ??= Path.Combine(home,".xlcore"); string dxvkConfigPath = Path.Combine(corePath,".dxvk"); + if (!Directory.Exists(dxvkConfigPath)) + Directory.Create(dxvkConfigPath); this.DxvkVars = new Dictionary (); this.DxvkVars.Add("DXVK_LOG_PATH",Path.Combine(corePath,"logs")); this.DxvkVars.Add("DXVK_CONFIG_FILE",Path.Combine(dxvkConfigPath,"dxvk.conf")); From df1a3be81952204efa843385060c7fc996c192c9 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 12:47:24 -0800 Subject: [PATCH 20/32] fix: Fixed directory create function. --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index dc12605f..c23bcbf4 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -29,7 +29,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud corePath ??= Path.Combine(home,".xlcore"); string dxvkConfigPath = Path.Combine(corePath,".dxvk"); if (!Directory.Exists(dxvkConfigPath)) - Directory.Create(dxvkConfigPath); + Directory.CreateDirectory(dxvkConfigPath); this.DxvkVars = new Dictionary (); this.DxvkVars.Add("DXVK_LOG_PATH",Path.Combine(corePath,"logs")); this.DxvkVars.Add("DXVK_CONFIG_FILE",Path.Combine(dxvkConfigPath,"dxvk.conf")); From a4a7b388e8fb67c6e7b4364c4a65e60d994dea53 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 13:30:47 -0800 Subject: [PATCH 21/32] fix: keep aync/async shader cache separate --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index c23bcbf4..863fece6 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -47,7 +47,8 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud }; this.DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; this.FolderName = $"dxvk-async-{release}"; - this.DxvkVars.Add("DXVK_STATE_CACHE_PATH",Path.Combine(dxvkConfigPath,release)); + string dxvkCacheSync = release + ((async ?? false) ? "-async" : ""); + this.DxvkVars.Add("DXVK_STATE_CACHE_PATH",Path.Combine(dxvkConfigPath,dxvkCacheSync)); switch(this.DxvkHud) { case Dxvk.DxvkHudType.Fps: From c138a3aa7b262c842a96bde76ed03bae800cfbfb Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sat, 10 Dec 2022 15:44:15 -0800 Subject: [PATCH 22/32] fix: use DirectoryInfo for xlcore path --- .../Compatibility/DxvkSettings.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 863fece6..7d77c4fd 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -22,17 +22,17 @@ public class DxvkSettings public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", string mangoHudPath="", bool? async = true, int? frameRate = 0, - Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1, string? corePath = null) + Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1, DirectoryInfo? corePath = null) { this.DxvkHud = hud; string home = Environment.GetEnvironmentVariable("HOME"); - corePath ??= Path.Combine(home,".xlcore"); - string dxvkConfigPath = Path.Combine(corePath,".dxvk"); - if (!Directory.Exists(dxvkConfigPath)) - Directory.CreateDirectory(dxvkConfigPath); + corePath ??= new DirectoryInfo(Path.Combine(home,".xlcore")); + var dxvkConfigPath = new DirectoryInfo(Path.Combine(corePath.FullName,".dxvk")); + if (!dxvkConfigPath.Exists) + dxvkConfigPath.Create(); this.DxvkVars = new Dictionary (); - this.DxvkVars.Add("DXVK_LOG_PATH",Path.Combine(corePath,"logs")); - this.DxvkVars.Add("DXVK_CONFIG_FILE",Path.Combine(dxvkConfigPath,"dxvk.conf")); + this.DxvkVars.Add("DXVK_LOG_PATH",Path.Combine(corePath.FullName,"logs")); + this.DxvkVars.Add("DXVK_CONFIG_FILE",Path.Combine(dxvkConfigPath.FullName,"dxvk.conf")); this.DxvkVars.Add("DXVK_ASYNC", ((async ?? false) ? "1" : "0")); frameRate ??= 0; if (frameRate > 0) this.DxvkVars.Add("DXVK_FRAME_RATE", (frameRate).ToString()); @@ -47,8 +47,8 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud }; this.DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; this.FolderName = $"dxvk-async-{release}"; - string dxvkCacheSync = release + ((async ?? false) ? "-async" : ""); - this.DxvkVars.Add("DXVK_STATE_CACHE_PATH",Path.Combine(dxvkConfigPath,dxvkCacheSync)); + string dxvkCachePath = Path.Combine(dxvkConfigPath.FullName, release + ((async ?? false) ? "-async" : "")); + this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", dxvkCachePath); switch(this.DxvkHud) { case Dxvk.DxvkHudType.Fps: @@ -74,7 +74,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud DxvkVars.Add("MANGOHUD","1"); if (mangoHudPath == "") { - string conf1 = Path.Combine(corePath,"MangoHud.conf"); + string conf1 = Path.Combine(corePath.FullName,"MangoHud.conf"); string conf2 = Path.Combine(home,".config","MangoHud","wine-ffxiv_dx11.conf"); string conf3 = Path.Combine(home,".config","MangoHud","MangoHud.conf"); if (CheckMangoHudPath(conf1)) From f58c2f62e591256f9bdd25cbdc7d621e9061e20c Mon Sep 17 00:00:00 2001 From: Marc-Aurel Zent Date: Sun, 11 Dec 2022 23:51:56 +0100 Subject: [PATCH 23/32] DxvkSettings refactor and formatting --- .../Compatibility/CompatibilityTools.cs | 7 +- .../Compatibility/DxvkSettings.cs | 107 +++++++++--------- 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index 59f2cf2f..8422fcdf 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -163,15 +163,14 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict wineEnviromentVariables.Add("XL_WINEONLINUX", "true"); string ldPreload = Environment.GetEnvironmentVariable("LD_PRELOAD") ?? ""; - if (this.gamemodeOn == true && !ldPreload.Contains("libgamemodeauto.so.0")) + if (gamemodeOn && !ldPreload.Contains("libgamemodeauto.so.0")) { ldPreload = ldPreload.Equals("") ? "libgamemodeauto.so.0" : ldPreload + ":libgamemodeauto.so.0"; } - foreach(KeyValuePair dxvkVar in DxvkSettings.DxvkVars) - { + foreach (KeyValuePair dxvkVar in DxvkSettings.DxvkVars) wineEnviromentVariables.Add(dxvkVar.Key, dxvkVar.Value); - } + wineEnviromentVariables.Add("WINEESYNC", Settings.EsyncOn); wineEnviromentVariables.Add("WINEFSYNC", Settings.FsyncOn); diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 7d77c4fd..0698041e 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -1,43 +1,43 @@ +#nullable enable using System; using System.IO; using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; namespace XIVLauncher.Common.Unix.Compatibility; public class DxvkSettings { - public string DownloadURL { get; private set; } + public string DownloadURL { get; } - public string FolderName { get; private set; } + public string FolderName { get; } - public Dictionary DxvkVars { get; private set; } + public Dictionary DxvkVars { get; } - public Dxvk.DxvkHudType DxvkHud { get; private set; } + public Dxvk.DxvkHudType DxvkHud { get; } - public Dxvk.DxvkVersion DxvkVersion { get; private set; } + public Dxvk.DxvkVersion DxvkVersion { get; } private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; - public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHudCustom="", - string mangoHudPath="", bool? async = true, int? frameRate = 0, - Dxvk.DxvkVersion version = Dxvk.DxvkVersion.v1_10_1, DirectoryInfo? corePath = null) + public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersion version, string? dxvkHudCustom = null, FileInfo? mangoHudConfig = null, bool async = true, + int maxFrameRate = 0) { - this.DxvkHud = hud; - string home = Environment.GetEnvironmentVariable("HOME"); - corePath ??= new DirectoryInfo(Path.Combine(home,".xlcore")); - var dxvkConfigPath = new DirectoryInfo(Path.Combine(corePath.FullName,".dxvk")); + DxvkHud = hud; + var dxvkConfigPath = new DirectoryInfo(Path.Combine(corePath.FullName, "compatibilitytool", "dxvk")); if (!dxvkConfigPath.Exists) dxvkConfigPath.Create(); - this.DxvkVars = new Dictionary (); - this.DxvkVars.Add("DXVK_LOG_PATH",Path.Combine(corePath.FullName,"logs")); - this.DxvkVars.Add("DXVK_CONFIG_FILE",Path.Combine(dxvkConfigPath.FullName,"dxvk.conf")); - this.DxvkVars.Add("DXVK_ASYNC", ((async ?? false) ? "1" : "0")); - frameRate ??= 0; - if (frameRate > 0) this.DxvkVars.Add("DXVK_FRAME_RATE", (frameRate).ToString()); - this.DxvkVersion = version; - string release = this.DxvkVersion switch + DxvkVars = new Dictionary + { + { "DXVK_LOG_PATH", Path.Combine(corePath.FullName, "logs") }, + { "DXVK_CONFIG_FILE", Path.Combine(dxvkConfigPath.FullName, "dxvk.conf") }, + { "DXVK_ASYNC", async ? "1" : "0" }, + { "DXVK_FRAME_RATE", (maxFrameRate).ToString() } + }; + DxvkVersion = version; + var release = DxvkVersion switch { Dxvk.DxvkVersion.v1_10_1 => "1.10.1", Dxvk.DxvkVersion.v1_10_2 => "1.10.2", @@ -45,77 +45,82 @@ public DxvkSettings(Dxvk.DxvkHudType hud = Dxvk.DxvkHudType.None, string dxvkHud Dxvk.DxvkVersion.v2_0 => "2.0", _ => throw new ArgumentOutOfRangeException(), }; - this.DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; - this.FolderName = $"dxvk-async-{release}"; - string dxvkCachePath = Path.Combine(dxvkConfigPath.FullName, release + ((async ?? false) ? "-async" : "")); + DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; + FolderName = $"dxvk-async-{release}"; + string dxvkCachePath = Path.Combine(dxvkConfigPath.FullName, release + (async ? "-async" : "")); this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", dxvkCachePath); + switch(this.DxvkHud) { case Dxvk.DxvkHudType.Fps: DxvkVars.Add("DXVK_HUD","fps"); DxvkVars.Add("MANGOHUD","0"); break; + case Dxvk.DxvkHudType.Custom: - if (!CheckDxvkHudString(dxvkHudCustom)) dxvkHudCustom = "fps,frametimes,gpuload,version"; - DxvkVars.Add("DXVK_HUD",dxvkHudCustom); + if (!CheckDxvkHudString(dxvkHudCustom)) + dxvkHudCustom = "fps,frametimes,gpuload,version"; + DxvkVars.Add("DXVK_HUD", dxvkHudCustom!); DxvkVars.Add("MANGOHUD","0"); break; + case Dxvk.DxvkHudType.Full: DxvkVars.Add("DXVK_HUD","full"); DxvkVars.Add("MANGOHUD","0"); break; + case Dxvk.DxvkHudType.MangoHud: DxvkVars.Add("DXVK_HUD","0"); DxvkVars.Add("MANGOHUD","1"); DxvkVars.Add("MANGOHUD_CONFIG", ""); break; + case Dxvk.DxvkHudType.MangoHudCustom: DxvkVars.Add("DXVK_HUD","0"); DxvkVars.Add("MANGOHUD","1"); - if (mangoHudPath == "") + + if (mangoHudConfig is null) { - string conf1 = Path.Combine(corePath.FullName,"MangoHud.conf"); - string conf2 = Path.Combine(home,".config","MangoHud","wine-ffxiv_dx11.conf"); - string conf3 = Path.Combine(home,".config","MangoHud","MangoHud.conf"); - if (CheckMangoHudPath(conf1)) - mangoHudPath = conf1; - else if (CheckMangoHudPath(conf2)) - mangoHudPath = conf2; - else if (CheckMangoHudPath(conf3)) - mangoHudPath = conf3; + var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + var conf1 = Path.Combine(corePath.FullName, "MangoHud.conf"); + var conf2 = Path.Combine(home, ".config", "MangoHud", "wine-ffxiv_dx11.conf"); + var conf3 = Path.Combine(home, ".config", "MangoHud", "MangoHud.conf"); + if (File.Exists(conf1)) + mangoHudConfig = new FileInfo(conf1); + else if (File.Exists(conf2)) + mangoHudConfig = new FileInfo(conf2); + else if (File.Exists(conf3)) + mangoHudConfig = new FileInfo(conf3); } - if (CheckMangoHudPath(mangoHudPath)) - DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); + + if (mangoHudConfig != null && mangoHudConfig.Exists) + DxvkVars.Add("MANGOHUD_CONFIGFILE", mangoHudConfig.FullName); else - DxvkVars.Add("MANGOHUD_CONFIG",""); + DxvkVars.Add("MANGOHUD_CONFIG", ""); break; + case Dxvk.DxvkHudType.MangoHudFull: DxvkVars.Add("DXVK_HUD","0"); DxvkVars.Add("MANGOHUD","1"); DxvkVars.Add("MANGOHUD_CONFIG","full"); break; - // If DxvkHudType is None, or undefined, don't set anything. - default: + + case Dxvk.DxvkHudType.None: break; + + default: + throw new ArgumentOutOfRangeException(); } } - public static bool CheckDxvkHudString(string customHud) + private static bool CheckDxvkHudString(string? customHud) { if (customHud == "1") return true; if (string.IsNullOrWhiteSpace(customHud)) return false; if (!Regex.IsMatch(customHud,ALLOWED_CHARS)) return false; + string[] hudvars = customHud.Split(","); - foreach (var hudvar in hudvars) - { - if (!Regex.IsMatch(hudvar,ALLOWED_WORDS)) - return false; - } - return true; - } - public static bool CheckMangoHudPath(string mangoPath) - { - return (File.Exists(mangoPath)) ? true : false; + return hudvars.All(hudvar => Regex.IsMatch(hudvar, ALLOWED_WORDS)); } } From b33dc793b682c96c3e9b023dee4667098f9875d3 Mon Sep 17 00:00:00 2001 From: Marc-Aurel Zent Date: Mon, 12 Dec 2022 00:01:57 +0100 Subject: [PATCH 24/32] add DXVK enabled switch --- .../Compatibility/CompatibilityTools.cs | 2 +- src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs | 3 +-- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index 5f56c543..04f61a3b 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -153,7 +153,7 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict var wineEnviromentVariables = new Dictionary(); wineEnviromentVariables.Add("WINEPREFIX", Settings.Prefix.FullName); - wineEnviromentVariables.Add("WINEDLLOVERRIDES", $"msquic=,mscoree=n,b;d3d9,d3d11,d3d10core,dxgi={(wineD3D ? "b" : "n")}"); + wineEnviromentVariables.Add("WINEDLLOVERRIDES", $"msquic=,mscoree=n,b;d3d9,d3d11,d3d10core,dxgi={(DxvkSettings.Enabled && !wineD3D ? "n" : "b")}"); if (!string.IsNullOrEmpty(Settings.DebugVars)) { diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index a61b82b0..36326328 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -8,9 +8,8 @@ namespace XIVLauncher.Common.Unix.Compatibility; public static class Dxvk { - public static async Task InstallDxvk(DirectoryInfo prefix, DirectoryInfo installDirectory, DxvkSettings? dxvkSettings = null) + public static async Task InstallDxvk(DirectoryInfo prefix, DirectoryInfo installDirectory, DxvkSettings dxvkSettings) { - dxvkSettings ??= new DxvkSettings(); var dxvkPath = Path.Combine(installDirectory.FullName, dxvkSettings.FolderName, "x64"); if (!Directory.Exists(dxvkPath)) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 0698041e..52be7d8c 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -9,6 +9,7 @@ namespace XIVLauncher.Common.Unix.Compatibility; public class DxvkSettings { + public bool Enabled { get; }; public string DownloadURL { get; } public string FolderName { get; } @@ -22,9 +23,10 @@ public class DxvkSettings private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; - public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersion version, string? dxvkHudCustom = null, FileInfo? mangoHudConfig = null, bool async = true, + public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersion version, bool enabled = true, string? dxvkHudCustom = null, FileInfo? mangoHudConfig = null, bool async = true, int maxFrameRate = 0) { + Enabled = enabled; DxvkHud = hud; var dxvkConfigPath = new DirectoryInfo(Path.Combine(corePath.FullName, "compatibilitytool", "dxvk")); if (!dxvkConfigPath.Exists) From d7139c437c8481ecb1b295744ed288a6f8390059 Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sun, 11 Dec 2022 18:34:22 -0800 Subject: [PATCH 25/32] Apply suggestions from code review --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 52be7d8c..f1c58bd6 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -115,10 +115,10 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi } } - private static bool CheckDxvkHudString(string? customHud) + public static bool CheckDxvkHudString(string? customHud) { - if (customHud == "1") return true; if (string.IsNullOrWhiteSpace(customHud)) return false; + if (customHud == "1") return true; if (!Regex.IsMatch(customHud,ALLOWED_CHARS)) return false; string[] hudvars = customHud.Split(","); From 90849aeb3462419b99d141d75667fdba43d0d228 Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sun, 11 Dec 2022 20:34:39 -0800 Subject: [PATCH 26/32] Update src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index f1c58bd6..c0c19688 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -125,4 +125,8 @@ public static bool CheckDxvkHudString(string? customHud) return hudvars.All(hudvar => Regex.IsMatch(hudvar, ALLOWED_WORDS)); } + + public static bool CheckMangoHudPath(string mangoPath) + { + return (File.Exists(mangoPath)) ? true : false; } From 1b05cdadc422d6cc681273145342716ebcb2e2fa Mon Sep 17 00:00:00 2001 From: Rankyn Bass <109918887+rankynbass@users.noreply.github.com> Date: Sun, 11 Dec 2022 21:01:26 -0800 Subject: [PATCH 27/32] Apply suggestions from code review --- .../Compatibility/DxvkSettings.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index c0c19688..9a1540f8 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -9,7 +9,7 @@ namespace XIVLauncher.Common.Unix.Compatibility; public class DxvkSettings { - public bool Enabled { get; }; + public bool Enabled { get; } public string DownloadURL { get; } public string FolderName { get; } @@ -49,8 +49,9 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi }; DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; FolderName = $"dxvk-async-{release}"; - string dxvkCachePath = Path.Combine(dxvkConfigPath.FullName, release + (async ? "-async" : "")); - this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", dxvkCachePath); + DirectoryInfo dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkConfigPath.FullName, "cache")); + if (!dxvkCachePath.Exists) dxvkCachePath.Create(); + this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, release + (async ? "-async" : ""))); switch(this.DxvkHud) { @@ -128,5 +129,6 @@ public static bool CheckDxvkHudString(string? customHud) public static bool CheckMangoHudPath(string mangoPath) { - return (File.Exists(mangoPath)) ? true : false; + return (File.Exists(mangoPath)) ? true : false; + } } From 810bcc95771fa9657021c47549eb950825dad506 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Mon, 12 Dec 2022 16:40:16 -0800 Subject: [PATCH 28/32] fix: get rid of useless function --- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 9a1540f8..4dd18346 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -10,6 +10,7 @@ namespace XIVLauncher.Common.Unix.Compatibility; public class DxvkSettings { public bool Enabled { get; } + public string DownloadURL { get; } public string FolderName { get; } @@ -21,6 +22,7 @@ public class DxvkSettings public Dxvk.DxvkVersion DxvkVersion { get; } private const string ALLOWED_CHARS = "^[0-9a-zA-Z,=.]+$"; + private const string ALLOWED_WORDS = "^(?:devinfo|fps|frametimes|submissions|drawcalls|pipelines|descriptors|memory|gpuload|version|api|cs|compiler|samplers|scale=(?:[0-9])*(?:.(?:[0-9])+)?)$"; public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersion version, bool enabled = true, string? dxvkHudCustom = null, FileInfo? mangoHudConfig = null, bool async = true, @@ -126,9 +128,4 @@ public static bool CheckDxvkHudString(string? customHud) return hudvars.All(hudvar => Regex.IsMatch(hudvar, ALLOWED_WORDS)); } - - public static bool CheckMangoHudPath(string mangoPath) - { - return (File.Exists(mangoPath)) ? true : false; - } } From a5f6ffd5cfc95face18934c0f8d18c4f52667477 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Wed, 4 Jan 2023 18:20:20 -0800 Subject: [PATCH 29/32] update: dxvk version to 1.10.3 --- src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index 36326328..1b7e380d 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -64,13 +64,13 @@ public enum DxvkHudType public enum DxvkVersion { - [SettingsDescription("1.10.1 (default)", "The default version of DXVK used with XIVLauncher.Core.")] + [SettingsDescription("1.10.1", "The version of DXVK used with XIVLauncher.Core 1.0.2. Safe to use.")] v1_10_1, - [SettingsDescription("1.10.2", "Newer version of 1.10 branch of DXVK. Safe to use.")] + [SettingsDescription("1.10.2", "Older version of 1.10 branch of DXVK. Safe to use.")] v1_10_2, - [SettingsDescription("1.10.3", "Newer version of 1.10 branch of DXVK. Safe to use.")] + [SettingsDescription("1.10.3 (default)", "Current version of 1.10 branch of DXVK.")] v1_10_3, [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newest version of DXVK. May be faster, but not stable yet.")] From 26b704cd828033c77bac08aae315f8fa028b306f Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 26 Jan 2023 16:59:35 -0800 Subject: [PATCH 30/32] Add dxvk 2.1 support (no async) --- src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs | 5 ++++- .../Compatibility/DxvkSettings.cs | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index 1b7e380d..a2417524 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -73,7 +73,10 @@ public enum DxvkVersion [SettingsDescription("1.10.3 (default)", "Current version of 1.10 branch of DXVK.")] v1_10_3, - [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newest version of DXVK. May be faster, but not stable yet.")] + [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newer version of DXVK. May be faster, but not stable yet.")] v2_0, + + [SettingsDescription("2.1 (might break Dalamud, GShade. No Async)", "Newest version of DXVK. No Async patch.")] + v2_1, } } diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 4dd18346..0c925948 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -37,7 +37,6 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi { { "DXVK_LOG_PATH", Path.Combine(corePath.FullName, "logs") }, { "DXVK_CONFIG_FILE", Path.Combine(dxvkConfigPath.FullName, "dxvk.conf") }, - { "DXVK_ASYNC", async ? "1" : "0" }, { "DXVK_FRAME_RATE", (maxFrameRate).ToString() } }; DxvkVersion = version; @@ -47,10 +46,20 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi Dxvk.DxvkVersion.v1_10_2 => "1.10.2", Dxvk.DxvkVersion.v1_10_3 => "1.10.3", Dxvk.DxvkVersion.v2_0 => "2.0", + Dxvk.DxvkVersion.v2_1 => "2.1", _ => throw new ArgumentOutOfRangeException(), }; - DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; - FolderName = $"dxvk-async-{release}"; + if (release != "2.1") + { + DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; + FolderName = $"dxvk-async-{release}"; + DxvkVars.Add("DXVK_ASYNC", async ? "1" : "0"); + } + else + { + DownloadURL = $"https://github.com/doitsujin/dxvk/releases/download/v{release}/dxvk-{release}.tar.gz"; + FolderName = $"dxvk-{release}"; + } DirectoryInfo dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkConfigPath.FullName, "cache")); if (!dxvkCachePath.Exists) dxvkCachePath.Create(); this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, release + (async ? "-async" : ""))); From 62fee287329fe27cdf17106f562b2bf1ea3809c0 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 1 Jun 2023 21:28:50 -0700 Subject: [PATCH 31/32] Update for Dxvk 2.2 --- src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs | 9 ++++++--- .../Compatibility/DxvkSettings.cs | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs index a2417524..95d7ba74 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/Dxvk.cs @@ -64,7 +64,7 @@ public enum DxvkHudType public enum DxvkVersion { - [SettingsDescription("1.10.1", "The version of DXVK used with XIVLauncher.Core 1.0.2. Safe to use.")] + [SettingsDescription("1.10.1", "The version of DXVK originally used with XIVLauncher.Core 1.0.3. Safe to use.")] v1_10_1, [SettingsDescription("1.10.2", "Older version of 1.10 branch of DXVK. Safe to use.")] @@ -73,10 +73,13 @@ public enum DxvkVersion [SettingsDescription("1.10.3 (default)", "Current version of 1.10 branch of DXVK.")] v1_10_3, - [SettingsDescription("2.0 (might break Dalamud, GShade)", "Newer version of DXVK. May be faster, but not stable yet.")] + [SettingsDescription("2.0", "Newer version of DXVK. Last version with Async patch")] v2_0, - [SettingsDescription("2.1 (might break Dalamud, GShade. No Async)", "Newest version of DXVK. No Async patch.")] + [SettingsDescription("2.1 (No Async)", "Newer version of DXVK, using graphics pipeline library. No Async patch.")] v2_1, + + [SettingsDescription("2.2 (No Async)", "Newest version of DXVK, using graphics pipeline library. No Async patch.")] + v2_2, } } diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index 0c925948..a1c1f4b4 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -47,9 +47,10 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi Dxvk.DxvkVersion.v1_10_3 => "1.10.3", Dxvk.DxvkVersion.v2_0 => "2.0", Dxvk.DxvkVersion.v2_1 => "2.1", + Dxvk.DxvkVersion.v2_2 => "2.2", _ => throw new ArgumentOutOfRangeException(), }; - if (release != "2.1") + if (new[] {"1.10.1", "1.10.2", "1.10.3", "2.0"}.Contains(release)) { DownloadURL = $"https://github.com/Sporif/dxvk-async/releases/download/{release}/dxvk-async-{release}.tar.gz"; FolderName = $"dxvk-async-{release}"; @@ -60,6 +61,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi DownloadURL = $"https://github.com/doitsujin/dxvk/releases/download/v{release}/dxvk-{release}.tar.gz"; FolderName = $"dxvk-{release}"; } + DirectoryInfo dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkConfigPath.FullName, "cache")); if (!dxvkCachePath.Exists) dxvkCachePath.Create(); this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, release + (async ? "-async" : ""))); From 3726cde4fab25fadc54557435529b3f0600f7f5f Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Thu, 15 Jun 2023 20:03:12 -0700 Subject: [PATCH 32/32] Fix a couple of minor style issues in code --- src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs | 2 +- src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs index 04f61a3b..3e1f1aa6 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/CompatibilityTools.cs @@ -168,7 +168,7 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict ldPreload = ldPreload.Equals("") ? "libgamemodeauto.so.0" : ldPreload + ":libgamemodeauto.so.0"; } - foreach (KeyValuePair dxvkVar in DxvkSettings.DxvkVars) + foreach (var dxvkVar in DxvkSettings.DxvkVars) wineEnviromentVariables.Add(dxvkVar.Key, dxvkVar.Value); wineEnviromentVariables.Add("WINEESYNC", Settings.EsyncOn); diff --git a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs index a1c1f4b4..58929042 100644 --- a/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs +++ b/src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs @@ -62,7 +62,7 @@ public DxvkSettings(Dxvk.DxvkHudType hud, DirectoryInfo corePath, Dxvk.DxvkVersi FolderName = $"dxvk-{release}"; } - DirectoryInfo dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkConfigPath.FullName, "cache")); + var dxvkCachePath = new DirectoryInfo(Path.Combine(dxvkConfigPath.FullName, "cache")); if (!dxvkCachePath.Exists) dxvkCachePath.Create(); this.DxvkVars.Add("DXVK_STATE_CACHE_PATH", Path.Combine(dxvkCachePath.FullName, release + (async ? "-async" : "")));