misc: Overhaul DirtyHacks saving to support storing a value alongside an off/off flag.

This commit is contained in:
Evan Husted
2024-12-29 21:17:01 -06:00
parent f5ce539de9
commit f362bef43d
13 changed files with 190 additions and 27 deletions

View File

@@ -952,7 +952,7 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.Multiplayer.LdnPassphrase,
ConfigurationState.Instance.Multiplayer.LdnServer,
ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value,
ConfigurationState.Instance.Hacks.ShowDirtyHacks ? ConfigurationState.Instance.Hacks.EnabledHacks : DirtyHacks.None));
ConfigurationState.Instance.Hacks.ShowDirtyHacks ? ConfigurationState.Instance.Hacks.EnabledHacks : null));
}
private static IHardwareDeviceDriver InitializeAudio()

View File

@@ -14,9 +14,6 @@ using Ryujinx.Cpu;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu;
using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Graphics.Metal;
using Ryujinx.Graphics.OpenGL;
using Ryujinx.Graphics.Vulkan;
using Ryujinx.Graphics.Vulkan.MoltenVK;
using Ryujinx.HLE;
using Ryujinx.HLE.FileSystem;

View File

@@ -66,6 +66,8 @@ namespace Ryujinx.Ava.UI.ViewModels
private string _ldnServer;
private bool _xc2MenuSoftlockFix = ConfigurationState.Instance.Hacks.Xc2MenuSoftlockFix;
private bool _shaderTranslationThreadSleep = ConfigurationState.Instance.Hacks.EnableShaderCompilationThreadSleep;
private int _shaderTranslationSleepDelay = ConfigurationState.Instance.Hacks.ShaderCompilationThreadSleepDelay;
public int ResolutionScale
{
@@ -287,6 +289,28 @@ namespace Ryujinx.Ava.UI.ViewModels
OnPropertyChanged();
}
}
public bool ShaderTranslationDelayEnabled
{
get => _shaderTranslationThreadSleep;
set
{
_shaderTranslationThreadSleep = value;
OnPropertyChanged();
}
}
public int ShaderTranslationDelay
{
get => _shaderTranslationSleepDelay;
set
{
_shaderTranslationSleepDelay = value;
OnPropertyChanged();
}
}
public int Language { get; set; }
public int Region { get; set; }
@@ -763,6 +787,8 @@ namespace Ryujinx.Ava.UI.ViewModels
// Dirty Hacks
config.Hacks.Xc2MenuSoftlockFix.Value = Xc2MenuSoftlockFixEnabled;
config.Hacks.EnableShaderCompilationThreadSleep.Value = ShaderTranslationDelayEnabled;
config.Hacks.ShaderCompilationThreadSleepDelay.Value = ShaderTranslationDelay;
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
@@ -809,5 +835,11 @@ namespace Ryujinx.Ava.UI.ViewModels
"there is a low chance that the game will softlock, " +
"the submenu won't show up, while background music is still there.");
});
public static string ShaderTranslationDelayTooltip { get; } = Lambda.String(sb =>
{
sb.Append(
"This hack applies the delay you specify every time shaders are attempted to be translated.");
});
}
}

View File

@@ -42,6 +42,33 @@
VerticalAlignment="Center"
Text="Xenoblade Chronicles 2 Menu Softlock Fix" />
</StackPanel>
<Separator/>
<StackPanel
Margin="0,10,0,0"
Orientation="Horizontal"
HorizontalAlignment="Center"
ToolTip.Tip="{Binding ShaderTranslationDelayTooltip}">
<CheckBox
Margin="0"
IsChecked="{Binding ShaderTranslationDelayEnabled}"/>
<TextBlock VerticalAlignment="Center"
Text="Arbitrary Delay on Shader Translation"/>
</StackPanel>
<Slider HorizontalAlignment="Center"
Value="{Binding ShaderTranslationDelay}"
ToolTip.Tip="{Binding ShaderTranslationDelay}"
Width="175"
Margin="0,-3,0,0"
Height="32"
Padding="0,-5"
TickFrequency="1"
IsSnapToTickEnabled="True"
LargeChange="10"
SmallChange="1"
VerticalAlignment="Center"
Minimum="1"
Maximum="1000" />
<Separator/>
</StackPanel>
</Border>
</ScrollViewer>

View File

@@ -17,7 +17,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
/// <summary>
/// The current version of the file format
/// </summary>
public const int CurrentVersion = 58;
public const int CurrentVersion = 59;
/// <summary>
/// Version of the configuration file format
@@ -436,9 +436,9 @@ namespace Ryujinx.Ava.Utilities.Configuration
public bool ShowDirtyHacks { get; set; }
/// <summary>
/// The packed value of the enabled dirty hacks.
/// The packed values of the enabled dirty hacks.
/// </summary>
public int EnabledDirtyHacks { get; set; }
public ulong[] DirtyHacks { get; set; }
/// <summary>
/// Loads a configuration file from disk

View File

@@ -9,6 +9,7 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Ryujinx.Ava.Utilities.Configuration
{
@@ -637,6 +638,18 @@ namespace Ryujinx.Ava.Utilities.Configuration
configurationFileUpdated = true;
}
// 58 migration accidentally got skipped but it worked with no issues somehow lol
if (configurationFileFormat.Version < 59)
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 59.");
configurationFileFormat.ShowDirtyHacks = false;
configurationFileFormat.DirtyHacks = [];
configurationFileUpdated = true;
}
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale;
@@ -737,7 +750,16 @@ namespace Ryujinx.Ava.Utilities.Configuration
Multiplayer.LdnServer.Value = configurationFileFormat.LdnServer;
Hacks.ShowDirtyHacks.Value = configurationFileFormat.ShowDirtyHacks;
Hacks.Xc2MenuSoftlockFix.Value = ((DirtyHacks)configurationFileFormat.EnabledDirtyHacks).HasFlag(DirtyHacks.Xc2MenuSoftlockFix);
{
EnabledDirtyHack[] hacks = configurationFileFormat.DirtyHacks.Select(EnabledDirtyHack.FromPacked).ToArray();
Hacks.Xc2MenuSoftlockFix.Value = hacks.Any(it => it.Hack == DirtyHacks.Xc2MenuSoftlockFix);
var shaderCompilationThreadSleep = hacks.FirstOrDefault(it => it.Hack == DirtyHacks.ShaderCompilationThreadSleep);
Hacks.EnableShaderCompilationThreadSleep.Value = shaderCompilationThreadSleep != null;
Hacks.ShaderCompilationThreadSleepDelay.Value = shaderCompilationThreadSleep?.Value ?? 0;
}
if (configurationFileUpdated)
{

View File

@@ -9,6 +9,7 @@ using Ryujinx.Common.Helper;
using Ryujinx.Common.Logging;
using Ryujinx.HLE;
using System.Collections.Generic;
using System.Linq;
namespace Ryujinx.Ava.Utilities.Configuration
{
@@ -626,36 +627,43 @@ namespace Ryujinx.Ava.Utilities.Configuration
public ReactiveObject<bool> ShowDirtyHacks { get; private set; }
public ReactiveObject<bool> Xc2MenuSoftlockFix { get; private set; }
public ReactiveObject<bool> EnableShaderCompilationThreadSleep { get; private set; }
public ReactiveObject<int> ShaderCompilationThreadSleepDelay { get; private set; }
public HacksSection()
{
ShowDirtyHacks = new ReactiveObject<bool>();
Xc2MenuSoftlockFix = new ReactiveObject<bool>();
Xc2MenuSoftlockFix.Event += HackChanged;
EnableShaderCompilationThreadSleep = new ReactiveObject<bool>();
EnableShaderCompilationThreadSleep.Event += HackChanged;
ShaderCompilationThreadSleepDelay = new ReactiveObject<int>();
}
private void HackChanged(object sender, ReactiveEventArgs<bool> rxe)
{
Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"EnabledDirtyHacks set to: {EnabledHacks}", "LogValueChange");
Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"EnabledDirtyHacks set to: [{EnabledHacks.Select(x => x.Hack).JoinToString(", ")}]", "LogValueChange");
}
public DirtyHacks EnabledHacks
public EnabledDirtyHack[] EnabledHacks
{
get
{
DirtyHacks dirtyHacks = DirtyHacks.None;
List<EnabledDirtyHack> enabledHacks = [];
if (Xc2MenuSoftlockFix)
Apply(DirtyHacks.Xc2MenuSoftlockFix);
return dirtyHacks;
if (EnableShaderCompilationThreadSleep)
Apply(DirtyHacks.ShaderCompilationThreadSleep, ShaderCompilationThreadSleepDelay);
return enabledHacks.ToArray();
void Apply(DirtyHacks hack)
void Apply(DirtyHacks hack, int value = 0)
{
if (dirtyHacks is not DirtyHacks.None)
dirtyHacks |= hack;
else
dirtyHacks = hack;
enabledHacks.Add(new EnabledDirtyHack(hack, value));
}
}
}

View File

@@ -7,6 +7,7 @@ using Ryujinx.Common.Configuration.Multiplayer;
using Ryujinx.Graphics.Vulkan;
using Ryujinx.HLE;
using System;
using System.Linq;
namespace Ryujinx.Ava.Utilities.Configuration
{
@@ -139,7 +140,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
MultiplayerLdnPassphrase = Multiplayer.LdnPassphrase,
LdnServer = Multiplayer.LdnServer,
ShowDirtyHacks = Hacks.ShowDirtyHacks,
EnabledDirtyHacks = (int)Hacks.EnabledHacks,
DirtyHacks = Hacks.EnabledHacks.Select(it => it.Pack()).ToArray(),
};
return configurationFile;