Skip to content
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

feat: add DXVK settings tab #17

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class SettingsPage : Page
new SettingsTabGame(),
new SettingsTabPatching(),
new SettingsTabWine(),
new SettingsTabDXVK(),
new SettingsTabDalamud(),
new SettingsTabAutoStart(),
new SettingsTabAbout(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.IO;
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<Dxvk.DxvkVersion> dxvkVersionSetting;
private SettingsEntry<Dxvk.DxvkHudType> dxvkHudSetting;

public SettingsTabDXVK()
{
Entries = new SettingsEntry[]
{
dxvkVersionSetting = new SettingsEntry<Dxvk.DxvkVersion>("DXVK Version", "Choose which version of DXVK to use.", () => Program.Config.DxvkVersion ?? Dxvk.DxvkVersion.v1_10_3, type => Program.Config.DxvkVersion = type)
{
CheckWarning = type =>
{
if (new [] {Dxvk.DxvkVersion.v2_1, Dxvk.DxvkVersion.v2_2}.Contains(type))
return "May not work with pre-8.0 or non-proton wine builds. AMD users may need to use env variable RADV_PERFTEST=gpl";
return null;
},
},
new SettingsEntry<bool>("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b)
{
CheckVisibility = () => !(new [] {Dxvk.DxvkVersion.v2_1, Dxvk.DxvkVersion.v2_2}.Contains(dxvkVersionSetting.Value)),
CheckWarning = b =>
{
if (!b && dxvkVersionSetting.Value == Dxvk.DxvkVersion.v2_0)
return "AMD users may need to use env variable RADV_PERFTEST=gpl";
return null;
},
},
dxvkHudSetting = new SettingsEntry<Dxvk.DxvkHudType>("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/lib64/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<string>("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<string>("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(!File.Exists(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 for unlimited.", () => 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public SettingsTabWine()
}
},

new SettingsEntry<bool>("Enable DXVK ASYNC", "Enable DXVK ASYNC patch.", () => Program.Config.DxvkAsyncEnabled ?? true, b => Program.Config.DxvkAsyncEnabled = b),
new SettingsEntry<bool>("Enable ESync", "Enable eventfd-based synchronization.", () => Program.Config.ESyncEnabled ?? true, b => Program.Config.ESyncEnabled = b),
new SettingsEntry<bool>("Enable FSync", "Enable fast user mutex (futex2).", () => Program.Config.FSyncEnabled ?? true, b => Program.Config.FSyncEnabled = b)
{
Expand All @@ -50,8 +49,10 @@ public SettingsTabWine()
}
},

new SettingsEntry<Dxvk.DxvkHudType>("DXVK Overlay", "Configure how much of the DXVK overlay is to be shown.", () => Program.Config.DxvkHudType, type => Program.Config.DxvkHudType = type),
new SettingsEntry<string>("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s)
new SettingsEntry<string>("WINEDEBUG Variables", "Configure debug logging for wine. Useful for troubleshooting.", () => Program.Config.WineDebugVars ?? string.Empty, s => Program.Config.WineDebugVars = s),
new SettingsEntry<bool>("Use WineD3D (Disable DXVK)",
"Don't check this unless you know what you're doing.\nIf you check this, XIVLauncher will try to use WineD3D instead of DXVK, and nothing in the DXVK tab will work.\nCustom wine versions may not work (especially proton-based wine). This will also break GShade.",
() => Program.Config.WineD3DEnabled ?? false, b => Program.Config.WineD3DEnabled = b),
};
}

Expand Down
10 changes: 10 additions & 0 deletions src/XIVLauncher.Core/Configuration/ILauncherConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,24 @@ public interface ILauncherConfig

public bool? GameModeEnabled { get; set; }

public bool? WineD3DEnabled { 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
Expand Down
8 changes: 7 additions & 1 deletion src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ private static void LoadConfig(Storage storage)
Config.GlobalScale ??= 1.0f;

Config.GameModeEnabled ??= false;
Config.WineD3DEnabled ??= false;
Config.DxvkVersion ??= Dxvk.DxvkVersion.v1_10_3;
Config.DxvkAsyncEnabled ??= true;
Config.DxvkFrameRate ??= 0;
Config.ESyncEnabled ??= true;
Config.FSyncEnabled ??= false;
Config.DxvkHudCustom ??= "fps,frametimes,gpuload,version";
Config.DxvkMangoCustom ??= Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config", "MangoHud", "MangoHud.conf");

Config.WineStartupType ??= WineStartupType.Managed;
Config.WineBinaryPath ??= "/usr/bin";
Expand Down Expand Up @@ -278,7 +283,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, storage.Root, Config.DxvkVersion ?? Dxvk.DxvkVersion.v1_10_3, !Config.WineD3DEnabled ?? true, Config.DxvkHudCustom, new FileInfo(Config.DxvkMangoCustom), Config.DxvkAsyncEnabled ?? true, Config.DxvkFrameRate ?? 0);
CompatibilityTools = new CompatibilityTools(wineSettings, dxvkSettings, Config.GameModeEnabled, toolsFolder);
}

public static void ShowWindow()
Expand Down