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

Replace 'Expand DRAM' option with dropdown menu #32

Merged
merged 2 commits into from
Oct 22, 2024
Merged
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
2 changes: 1 addition & 1 deletion src/Ryujinx.Common/Collections/IntervalTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ internal IntervalTreeNode(TKey start, TKey end, TValue value, IntervalTreeNode<T
Start = start;
End = end;
Max = end;
Values = [ new RangeNode<TKey, TValue>(start, end, value) ];
Values = [new RangeNode<TKey, TValue>(start, end, value)];
Parent = parent;
}
}
Expand Down
208 changes: 194 additions & 14 deletions src/Ryujinx.Common/Hash128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
// ReSharper disable InconsistentNaming

namespace Ryujinx.Common
Expand Down Expand Up @@ -67,18 +67,198 @@ public struct Hash128(ulong low, ulong high) : IEquatable<Hash128>

private static ReadOnlySpan<byte> Xxh3KSecret =>
[
0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c,
0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f,
0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21,
0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0x82,
0x5a,
0xd0,
0x7d,
0xcc,
0xff,
0x72,
0x21,
0xb8,
0x08,
0x46,
0x74,
0xf7,
0x43,
0x24,
0x8e,
0xe0,
0x35,
0x90,
0xe6,
0x81,
0x3a,
0x26,
0x4c,
0x3c,
0x28,
0x52,
0xbb,
0x91,
0xc3,
0x00,
0xcb,
0x88,
0xd0,
0x65,
0x8b,
0x1b,
0x53,
0x2e,
0xa3,
0x71,
0x64,
0x48,
0x97,
0xa2,
0x0d,
0xf9,
0x4e,
0x38,
0x19,
0xef,
0x46,
0xa9,
0xde,
0xac,
0xd8,
0xa8,
0xfa,
0x76,
0x3f,
0xe3,
0x9c,
0x34,
0x3f,
0xf9,
0xdc,
0xbb,
0xc7,
0xc7,
0x0b,
0x4f,
0x1d,
0x8a,
0x51,
0xe0,
0x4b,
0xcd,
0xb4,
0x59,
0x31,
0xc8,
0x9f,
0x7e,
0xc9,
0xd9,
0x78,
0x73,
0x64,
0xea,
0xc5,
0xac,
0x83,
0x34,
0xd3,
0xeb,
0xc3,
0xc5,
0x81,
0xa0,
0xff,
0xfa,
0x13,
0x63,
0xeb,
0x17,
0x0d,
0xdd,
0x51,
0xb7,
0xf0,
0xda,
0x49,
0xd3,
0x16,
0x55,
0x26,
0x29,
0xd4,
0x68,
0x9e,
0x2b,
0x16,
0xbe,
0x58,
0x7d,
0x47,
0xa1,
0xfc,
0x8f,
0xf8,
0xb8,
0xd1,
0x7a,
0xd0,
0x31,
0xce,
0x45,
0xcb,
0x3a,
0x8f,
0x95,
0x16,
0x04,
0x28,
0xaf,
0xd7,
0xfb,
0xca,
0xbb,
0x4b,
0x40,
0x7e
];

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -551,6 +731,6 @@ private static Hash128 Xxh3128bitsInternal(ReadOnlySpan<byte> input, ReadOnlySpa
};
}

#endregion
#endregion
}
}
4 changes: 2 additions & 2 deletions src/Ryujinx.Common/Utilities/BitUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public static class BitUtils
public static T AlignUp<T>(T value, T size) where T : IBinaryInteger<T>
=> (value + (size - T.One)) & -size;

public static T AlignDown<T>(T value, T size) where T : IBinaryInteger<T>
public static T AlignDown<T>(T value, T size) where T : IBinaryInteger<T>
=> value & -size;

public static T DivRoundUp<T>(T value, T dividend) where T : IBinaryInteger<T>
public static T DivRoundUp<T>(T value, T dividend) where T : IBinaryInteger<T>
=> (value + (dividend - T.One)) / dividend;

public static int Pow2RoundDown(int value) => BitOperations.IsPow2(value) ? value : Pow2RoundUp(value) >> 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void End()
Flush();
}

public readonly Span<byte> AsSpan()
public readonly Span<byte> AsSpan()
=> new Span<byte>(workBuffer)[.._offset];

public void WriteU(uint value, int valueSize) => WriteBits((int)value, valueSize);
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Texture/OffsetCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public bool LayoutMatches(OffsetCalculator other)
_height == other._height &&
_stride == other._stride &&
_bytesPerPixel == other._bytesPerPixel;


return !other._isLinear && _layoutConverter.LayoutMatches(other._layoutConverter);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Ryujinx.HLE/FileSystem/ContentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,12 @@ public SystemVersion VerifyFirmwarePackage(string firmwarePackage)
// So, we check it early for a better user experience.
if (_virtualFileSystem.KeySet.HeaderKey.IsZeros())
throw new MissingKeyException("HeaderKey is empty. Cannot decrypt NCA headers.");

Dictionary<ulong, List<(NcaContentType type, string path)>> updateNcas = new();

if (Directory.Exists(firmwarePackage))
return VerifyAndGetVersionDirectory(firmwarePackage);

if (!File.Exists(firmwarePackage))
throw new FileNotFoundException("Firmware file does not exist.");

Expand All @@ -620,7 +620,7 @@ public SystemVersion VerifyFirmwarePackage(string firmwarePackage)

return null;

SystemVersion VerifyAndGetVersionDirectory(string firmwareDirectory)
SystemVersion VerifyAndGetVersionDirectory(string firmwareDirectory)
=> VerifyAndGetVersion(new LocalFileSystem(firmwareDirectory));

SystemVersion VerifyAndGetVersionZip(ZipArchive archive)
Expand Down
5 changes: 4 additions & 1 deletion src/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ MemoryArrange.MemoryArrange4GiBSystemDev or
MemoryArrange.MemoryArrange4GiBAppletDev => 2048 * MiB,
MemoryArrange.MemoryArrange6GiB => 4916 * MiB,
MemoryArrange.MemoryArrange8GiB => 6964 * MiB,
MemoryArrange.MemoryArrange12GiB => 11060 * MiB,
_ => throw new ArgumentException($"Invalid memory arrange \"{arrange}\"."),
};
}
Expand All @@ -43,7 +44,8 @@ public static ulong GetAppletPoolSize(MemoryArrange arrange)
MemoryArrange.MemoryArrange4GiBSystemDev => 448 * MiB,
MemoryArrange.MemoryArrange6GiB => 562 * MiB,
MemoryArrange.MemoryArrange6GiBAppletDev => 2193 * MiB,
MemoryArrange.MemoryArrange8GiB => 562 * MiB,
MemoryArrange.MemoryArrange8GiB or
MemoryArrange.MemoryArrange12GiB => 562 * MiB,
_ => throw new ArgumentException($"Invalid memory arrange \"{arrange}\"."),
};
}
Expand Down Expand Up @@ -71,6 +73,7 @@ public static ulong GetDramSize(MemorySize size)
MemorySize.MemorySize4GiB => 4 * GiB,
MemorySize.MemorySize6GiB => 6 * GiB,
MemorySize.MemorySize8GiB => 8 * GiB,
MemorySize.MemorySize12GiB => 12 * GiB,
_ => throw new ArgumentException($"Invalid memory size \"{size}\"."),
};
}
Expand Down
1 change: 1 addition & 0 deletions src/Ryujinx.HLE/HOS/Kernel/Common/MemoryArrange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ enum MemoryArrange : byte
MemoryArrange6GiB,
MemoryArrange6GiBAppletDev,
MemoryArrange8GiB,
MemoryArrange12GiB,
}
}
1 change: 1 addition & 0 deletions src/Ryujinx.HLE/HOS/Kernel/Common/MemorySize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ enum MemorySize : byte
MemorySize4GiB = 0,
MemorySize6GiB = 1,
MemorySize8GiB = 2,
MemorySize12GiB = 3,
}
}
14 changes: 9 additions & 5 deletions src/Ryujinx.HLE/MemoryConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ namespace Ryujinx.HLE
public enum MemoryConfiguration
{
MemoryConfiguration4GiB = 0,
MemoryConfiguration4GiBAppletDev = 1,
MemoryConfiguration4GiBSystemDev = 2,
MemoryConfiguration6GiB = 3,
MemoryConfiguration6GiBAppletDev = 4,
MemoryConfiguration8GiB = 5,
MemoryConfiguration6GiB = 1,
MemoryConfiguration8GiB = 2,
MemoryConfiguration12GiB = 3,
MemoryConfiguration4GiBAppletDev = 4,
MemoryConfiguration4GiBSystemDev = 5,
MemoryConfiguration6GiBAppletDev = 6,
}

static class MemoryConfigurationExtensions
Expand All @@ -28,6 +29,7 @@ public static MemoryArrange ToKernelMemoryArrange(this MemoryConfiguration confi
MemoryConfiguration.MemoryConfiguration6GiB => MemoryArrange.MemoryArrange6GiB,
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => MemoryArrange.MemoryArrange6GiBAppletDev,
MemoryConfiguration.MemoryConfiguration8GiB => MemoryArrange.MemoryArrange8GiB,
MemoryConfiguration.MemoryConfiguration12GiB => MemoryArrange.MemoryArrange12GiB,
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\"."),
};
}
Expand All @@ -42,6 +44,7 @@ MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
MemoryConfiguration.MemoryConfiguration6GiB or
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => MemorySize.MemorySize6GiB,
MemoryConfiguration.MemoryConfiguration8GiB => MemorySize.MemorySize8GiB,
MemoryConfiguration.MemoryConfiguration12GiB => MemorySize.MemorySize12GiB,
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\"."),
};
}
Expand All @@ -56,6 +59,7 @@ MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
MemoryConfiguration.MemoryConfiguration6GiB or
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => 6 * GiB,
MemoryConfiguration.MemoryConfiguration8GiB => 8 * GiB,
MemoryConfiguration.MemoryConfiguration12GiB => 12 * GiB,
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\"."),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public event KeyReleasedHandler KeyReleasedEvent { add { } remove { } }
public bool TextProcessingEnabled
{
get => Volatile.Read(ref _canProcessInput);

set
{
Volatile.Write(ref _canProcessInput, value);
Expand Down
Loading
Loading