-
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
Closed
Closed
Changes from 21 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
fe921f6
fix: Launcher.cs changed to work with xlcore
rankynbass 72bd2e4
feat: add DxvkSettings & related
rankynbass 001ff3e
feat: add frame rate limit support
rankynbass 7cc2a5a
feat: add backend for dxvkhud custom string
rankynbass c0f50f7
feat: add support for MangoHud
rankynbass 8381d03
fix: disable MangoHud when using DXVK Hud
rankynbass aad9315
fix: use Path.Combine in MangoHud Custom
rankynbass 435396e
fix: make sure mangohud.conf exists
rankynbass 5dba7dc
fix: basic validity checking added for custom huds
rankynbass e4c4a4b
fix: improve dxvkhud checking with regex.
rankynbass d3fed4d
fix: add "1" as valid value for dxvkhud
rankynbass 665abf2
fix: mangohud.conf logic was broken, now fixed.
rankynbass e31bf46
fix: flatpak breaks using fallback method
rankynbass f7b7aad
Update CompatibilityTools.cs
rankynbass bf0fb66
Update Launcher.cs
rankynbass ad34feb
Update DxvkSettings.cs
rankynbass 87282c6
Update Dxvk.cs
rankynbass f47ddca
feat: Add dxvk log, cache, config
rankynbass 84ed999
fix: Make sure to create .dxvk folder
rankynbass df1a3be
fix: Fixed directory create function.
rankynbass a4a7b38
fix: keep aync/async shader cache separate
rankynbass c138a3a
fix: use DirectoryInfo for xlcore path
rankynbass f58c2f6
DxvkSettings refactor and formatting
marzent 391cc43
Merge remote-tracking branch 'goat_origin/master' into dxvk-settings-…
marzent b33dc79
add DXVK enabled switch
marzent d7139c4
Apply suggestions from code review
rankynbass 90849ae
Update src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs
rankynbass 1b05cda
Apply suggestions from code review
rankynbass 84b9637
Merge pull request #13 from marzent/dxvk-settings-rework2
rankynbass 810bcc9
fix: get rid of useless function
rankynbass a5f6ffd
update: dxvk version to 1.10.3
rankynbass 26b704c
Add dxvk 2.1 support (no async)
rankynbass 62fee28
Update for Dxvk 2.2
rankynbass 3726cde
Fix a couple of minor style issues in code
rankynbass File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/XIVLauncher.Common.Unix/Compatibility/DxvkSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
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-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, string? 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); | ||
this.DxvkVars = new Dictionary<string, string> (); | ||
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()); | ||
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", | ||
_ => 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 dxvkCacheSync = release + ((async ?? false) ? "-async" : ""); | ||
this.DxvkVars.Add("DXVK_STATE_CACHE_PATH",Path.Combine(dxvkConfigPath,dxvkCacheSync)); | ||
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 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)) | ||
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; | ||
} | ||
} | ||
|
||
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; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe it is cleaner to pass a DirectoryInfo into the cctor here as well, just in case the base xlcore storage path will change
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.
That's just the default. You can pass in the correct path to the constructor; it just defaults to null and sets the default to ~/.xlcore in that case. XL Core's Program.cs creates a DxvkSettings object, and I've passed it in there. But I could change it to pass in a DirectoryInfo. It's probably more "correct". So now the storage.Root object can be passed in from XL Core, instead of the string storage.Root.FullName.