-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[xlcore][feature] Dxvk settings rework #1205
Changes from 13 commits
fe921f6
72bd2e4
001ff3e
7cc2a5a
c0f50f7
8381d03
aad9315
435396e
5dba7dc
e4c4a4b
d3fed4d
665abf2
e31bf46
f7b7aad
bf0fb66
ad34feb
87282c6
f47ddca
84ed999
df1a3be
a4a7b38
c138a3a
f58c2f6
391cc43
b33dc79
d7139c4
90849ae
1b05cda
84b9637
810bcc9
a5f6ffd
26b704c
62fee28
3726cde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly wouldn't bother adding that, it's just unnecessary clutter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine. I was just putting it in so it would still build against unmodified xlcore. Deleting this as well. |
||
: 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<string,string> dxvkVar in DxvkSettings.DxvkVars) | ||
{ | ||
wineEnviromentVariables.Add(dxvkVar.Key, dxvkVar.Value); | ||
} | ||
wineEnviromentVariables.Add("WINEESYNC", Settings.EsyncOn); | ||
wineEnviromentVariables.Add("WINEFSYNC", Settings.FsyncOn); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -49,7 +47,34 @@ 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, | ||
|
||
[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 | ||
{ | ||
[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.")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1.10.3 for sure works with Dalamud + GShade; it's really only 2.0 that is creating trouble |
||
v1_10_3, | ||
|
||
[SettingsDescription("2.0 (might break Dalamud, GShade)", "Newest version of DXVK. Might break Dalamud or GShade.")] | ||
v2_0, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using System; | ||
using System.IO; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace XIVLauncher.Common.Unix.Compatibility; | ||
|
||
public class DxvkSettings | ||
{ | ||
public string DownloadURL { get; private set; } | ||
|
||
public string FolderName { get; private set; } | ||
|
||
public Dictionary<string, string> DxvkVars { get; private set; } | ||
|
||
public Dxvk.DxvkHudType DxvkHud { get; private set; } | ||
|
||
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])+)?)$"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for scale being < 100 ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't know if there were any limits, it just seemed a reasonable high number. Scales over 10 are probably not useful unless you're on an 8K+ display, but it's easy enough to change {0,2} to *. So... changed. |
||
|
||
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<string, string> (); | ||
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 | ||
{ | ||
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(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably should be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, found a couple of examples in the code and mimicked them. It compiles, and, as you said, this shouldn't ever actually happen to a normal user. Changed. |
||
}; | ||
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"); | ||
DxvkVars.Add("MANGOHUD","0"); | ||
break; | ||
case Dxvk.DxvkHudType.Custom: | ||
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 == "") | ||
{ | ||
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 (CheckMangoHudPath(conf1)) | ||
mangoHudPath = conf1; | ||
else if (CheckMangoHudPath(conf2)) | ||
mangoHudPath = conf2; | ||
else if (CheckMangoHudPath(conf3)) | ||
mangoHudPath = conf3; | ||
} | ||
if (CheckMangoHudPath(mangoHudPath)) | ||
DxvkVars.Add("MANGOHUD_CONFIGFILE",mangoHudPath); | ||
else | ||
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: | ||
break; | ||
} | ||
} | ||
|
||
private string VersionOutOfRange() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unneeded with the above change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And deleted. |
||
this.DxvkVersion = Dxvk.DxvkVersion.v1_10_1; | ||
return "1.10.1"; | ||
} | ||
|
||
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(","); | ||
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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems out of scope for this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. It was just in so I could build against unmodified xlcore. Can definitely remove. |
||
{ | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. |
||
: this(steam: null, uniqueIdCache, settings, frontierUrl) | ||
{ | ||
this.steamTicket = steamTicket; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be duplicate code from line 80...
Actually there is no reason to do this at all since wine will create it's prefix folder on first startup anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it is... deleting that. You know how it goes with copy/paste