|
|
@@ -6,18 +6,19 @@ using System.Linq;
|
|
|
namespace Ryujinx.Common.Configuration
|
|
|
{
|
|
|
[Flags]
|
|
|
- public enum DirtyHacks : byte
|
|
|
+ public enum DirtyHack : byte
|
|
|
{
|
|
|
Xc2MenuSoftlockFix = 1,
|
|
|
- ShaderCompilationThreadSleep = 2
|
|
|
+ ShaderTranslationDelay = 2
|
|
|
}
|
|
|
|
|
|
- public record EnabledDirtyHack(DirtyHacks Hack, int Value)
|
|
|
+ public readonly struct EnabledDirtyHack(DirtyHack hack, int value)
|
|
|
{
|
|
|
- public static readonly byte[] PackedFormat = [8, 32];
|
|
|
-
|
|
|
- private uint[] Raw => [(uint)Hack, (uint)Value.CoerceAtLeast(0)];
|
|
|
-
|
|
|
+ public DirtyHack Hack => hack;
|
|
|
+ public int Value => value;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public ulong Pack() => Raw.PackBitFields(PackedFormat);
|
|
|
|
|
|
public static EnabledDirtyHack Unpack(ulong packedHack)
|
|
|
@@ -26,16 +27,20 @@ namespace Ryujinx.Common.Configuration
|
|
|
if (unpackedFields is not [var hack, var value])
|
|
|
throw new ArgumentException(nameof(packedHack));
|
|
|
|
|
|
- return new EnabledDirtyHack((DirtyHacks)hack, (int)value);
|
|
|
+ return new EnabledDirtyHack((DirtyHack)hack, (int)value);
|
|
|
}
|
|
|
+
|
|
|
+ private uint[] Raw => [(uint)Hack, (uint)Value.CoerceAtLeast(0)];
|
|
|
+
|
|
|
+ public static readonly byte[] PackedFormat = [8, 32];
|
|
|
}
|
|
|
|
|
|
- public class DirtyHackCollection : Dictionary<DirtyHacks, int>
|
|
|
+ public class DirtyHacks : Dictionary<DirtyHack, int>
|
|
|
{
|
|
|
- public DirtyHackCollection(IEnumerable<EnabledDirtyHack> hacks)
|
|
|
+ public DirtyHacks(IEnumerable<EnabledDirtyHack> hacks)
|
|
|
=> hacks.ForEach(edh => Add(edh.Hack, edh.Value));
|
|
|
|
|
|
- public DirtyHackCollection(ulong[] packedHacks) : this(packedHacks.Select(EnabledDirtyHack.Unpack)) {}
|
|
|
+ public DirtyHacks(ulong[] packedHacks) : this(packedHacks.Select(EnabledDirtyHack.Unpack)) {}
|
|
|
|
|
|
public ulong[] PackEntries()
|
|
|
=> Entries.Select(it => it.Pack()).ToArray();
|
|
|
@@ -45,11 +50,11 @@ namespace Ryujinx.Common.Configuration
|
|
|
.Select(it => new EnabledDirtyHack(it.Key, it.Value))
|
|
|
.ToArray();
|
|
|
|
|
|
- public static implicit operator DirtyHackCollection(EnabledDirtyHack[] hacks) => new(hacks);
|
|
|
- public static implicit operator DirtyHackCollection(ulong[] packedHacks) => new(packedHacks);
|
|
|
+ public static implicit operator DirtyHacks(EnabledDirtyHack[] hacks) => new(hacks);
|
|
|
+ public static implicit operator DirtyHacks(ulong[] packedHacks) => new(packedHacks);
|
|
|
|
|
|
- public new int this[DirtyHacks hack] => TryGetValue(hack, out var value) ? value : -1;
|
|
|
+ public new int this[DirtyHack hack] => TryGetValue(hack, out var value) ? value : -1;
|
|
|
|
|
|
- public bool IsEnabled(DirtyHacks hack) => ContainsKey(hack);
|
|
|
+ public bool IsEnabled(DirtyHack hack) => ContainsKey(hack);
|
|
|
}
|
|
|
}
|