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

Implement FPS Limiter (DXVK_FRAME_RATE) #1011

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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 @@ -44,6 +44,7 @@ public class CompatibilityTools
public bool IsToolDownloaded => File.Exists(Wine64Path) && Settings.Prefix.Exists;

private readonly Dxvk.DxvkHudType hudType;
private readonly string dxvkFPSLimit;
private readonly bool gamemodeOn;
private readonly string dxvkAsyncOn;

Expand Down Expand Up @@ -183,6 +184,7 @@ private Process RunInPrefix(ProcessStartInfo psi, string workingDirectory, IDict

wineEnviromentVariables.Add("DXVK_HUD", dxvkHud);
wineEnviromentVariables.Add("DXVK_ASYNC", dxvkAsyncOn);
wineEnviromentVariables.Add("DXVK_FRAME_RATE", Settings.DxvkFPSLimit);
wineEnviromentVariables.Add("WINEESYNC", Settings.EsyncOn);
wineEnviromentVariables.Add("WINEFSYNC", Settings.FsyncOn);

Expand Down
5 changes: 4 additions & 1 deletion src/XIVLauncher.Common.Unix/Compatibility/WineSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ public class WineSettings
public string EsyncOn { get; private set; }
public string FsyncOn { get; private set; }

public string DxvkFPSLimit { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to store an fps limit as an integer


public string DebugVars { get; private set; }
public FileInfo LogFile { get; private set; }

public DirectoryInfo Prefix { get; private set; }

public WineSettings(WineStartupType? startupType, string customBinPath, string debugVars, FileInfo logFile, DirectoryInfo prefix, bool? esyncOn, bool? fsyncOn)
public WineSettings(WineStartupType? startupType, string customBinPath, string debugVars, FileInfo logFile, DirectoryInfo prefix, bool? esyncOn, bool? fsyncOn, string dxvkFPSLimit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a wine setting and should probably go into the appropriately named Dxvk class

{
this.StartupType = startupType ?? WineStartupType.Custom;
this.CustomBinPath = customBinPath;
this.DxvkFPSLimit = dxvkFPSLimit;
this.EsyncOn = (esyncOn ?? false) ? "1" : "0";
this.FsyncOn = (fsyncOn ?? false) ? "1" : "0";
this.DebugVars = debugVars;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
using ImGuiNET;
using XIVLauncher.Common.Unix.Compatibility;
Expand Down Expand Up @@ -51,7 +52,10 @@ public SettingsTabWine()
return null;
}
},

new SettingsEntry<string>("DXVK Frame Limit", "Configure how many frames DXVK should be limited to. Set to 0 for unlimited.", () => Program.Config.DxvkFrameRate ?? "0", s => Program.Config.DxvkFrameRate = s)
{
CheckValidity = s => Regex.IsMatch(s, @"^\d{1,3}$") ? null : "Please specify a valid integer below 999."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex is a bit overkill to check for a non-negative integer; afaik dxvk can also limit to more than 999fps

},
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)
};
Expand Down
2 changes: 2 additions & 0 deletions src/XIVLauncher.Core/Configuration/ILauncherConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public interface ILauncherConfig

public bool? FSyncEnabled { get; set; }

public string DxvkFrameRate { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as earlier this does not need to be a string


public Dxvk.DxvkHudType DxvkHudType { get; set; }

public string? WineDebugVars { get; set; }
Expand Down
4 changes: 3 additions & 1 deletion src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private static void LoadConfig(Storage storage)

Config.GameModeEnabled ??= false;
Config.DxvkAsyncEnabled ??= true;
Config.DxvkFrameRate ??= "0";
Config.ESyncEnabled ??= true;
Config.FSyncEnabled ??= false;

Expand Down Expand Up @@ -276,7 +277,8 @@ public static void CreateCompatToolsInstance()
{
var wineLogFile = new FileInfo(Path.Combine(storage.GetFolder("logs").FullName, "wine.log"));
var winePrefix = storage.GetFolder("wineprefix");
var wineSettings = new WineSettings(Config.WineStartupType, Config.WineBinaryPath, Config.WineDebugVars, wineLogFile, winePrefix, Config.ESyncEnabled, Config.FSyncEnabled);
var wineSettings = new WineSettings(Config.WineStartupType, Config.WineBinaryPath, Config.WineDebugVars, wineLogFile, winePrefix, Config.ESyncEnabled, Config.FSyncEnabled,
Config.DxvkFrameRate);
var toolsFolder = storage.GetFolder("compatibilitytool");
CompatibilityTools = new CompatibilityTools(wineSettings, Config.DxvkHudType, Config.GameModeEnabled, Config.DxvkAsyncEnabled, toolsFolder);
}
Expand Down