mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-11-24 10:46:54 +01:00
misc: Collapse XXHash128 into Hash128.
This commit is contained in:
parent
290e7c5ec8
commit
cb31d79164
6 changed files with 21 additions and 21 deletions
|
@ -309,7 +309,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
ReadOnlySpan<byte> infosBytes = new(stream.PositionPointer, innerHeader.InfosLength);
|
||||
stream.Seek(innerHeader.InfosLength, SeekOrigin.Current);
|
||||
|
||||
Hash128 infosHash = XXHash128.ComputeHash(infosBytes);
|
||||
Hash128 infosHash = Hash128.ComputeHash(infosBytes);
|
||||
|
||||
if (innerHeader.InfosHash != infosHash)
|
||||
{
|
||||
|
@ -321,7 +321,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
ReadOnlySpan<byte> codesBytes = (int)innerHeader.CodesLength > 0 ? new(stream.PositionPointer, (int)innerHeader.CodesLength) : ReadOnlySpan<byte>.Empty;
|
||||
stream.Seek(innerHeader.CodesLength, SeekOrigin.Current);
|
||||
|
||||
Hash128 codesHash = XXHash128.ComputeHash(codesBytes);
|
||||
Hash128 codesHash = Hash128.ComputeHash(codesBytes);
|
||||
|
||||
if (innerHeader.CodesHash != codesHash)
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
ReadOnlySpan<byte> relocsBytes = new(stream.PositionPointer, innerHeader.RelocsLength);
|
||||
stream.Seek(innerHeader.RelocsLength, SeekOrigin.Current);
|
||||
|
||||
Hash128 relocsHash = XXHash128.ComputeHash(relocsBytes);
|
||||
Hash128 relocsHash = Hash128.ComputeHash(relocsBytes);
|
||||
|
||||
if (innerHeader.RelocsHash != relocsHash)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
ReadOnlySpan<byte> unwindInfosBytes = new(stream.PositionPointer, innerHeader.UnwindInfosLength);
|
||||
stream.Seek(innerHeader.UnwindInfosLength, SeekOrigin.Current);
|
||||
|
||||
Hash128 unwindInfosHash = XXHash128.ComputeHash(unwindInfosBytes);
|
||||
Hash128 unwindInfosHash = Hash128.ComputeHash(unwindInfosBytes);
|
||||
|
||||
if (innerHeader.UnwindInfosHash != unwindInfosHash)
|
||||
{
|
||||
|
@ -478,10 +478,10 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
Debug.Assert(stream.Position == stream.Length);
|
||||
|
||||
innerHeader.InfosHash = XXHash128.ComputeHash(infosBytes);
|
||||
innerHeader.CodesHash = XXHash128.ComputeHash(codesBytes);
|
||||
innerHeader.RelocsHash = XXHash128.ComputeHash(relocsBytes);
|
||||
innerHeader.UnwindInfosHash = XXHash128.ComputeHash(unwindInfosBytes);
|
||||
innerHeader.InfosHash = Hash128.ComputeHash(infosBytes);
|
||||
innerHeader.CodesHash = Hash128.ComputeHash(codesBytes);
|
||||
innerHeader.RelocsHash = Hash128.ComputeHash(relocsBytes);
|
||||
innerHeader.UnwindInfosHash = Hash128.ComputeHash(unwindInfosBytes);
|
||||
|
||||
innerHeader.SetHeaderHash();
|
||||
|
||||
|
@ -907,7 +907,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
public static Hash128 ComputeHash(IMemoryManager memory, ulong address, ulong guestSize)
|
||||
{
|
||||
return XXHash128.ComputeHash(memory.GetSpan(address, checked((int)(guestSize))));
|
||||
return Hash128.ComputeHash(memory.GetSpan(address, checked((int)(guestSize))));
|
||||
}
|
||||
|
||||
public void WriteCompiledFunction(ulong address, ulong guestSize, Hash128 hash, bool highCq, CompiledFunction compiledFunc)
|
||||
|
@ -1036,14 +1036,14 @@ namespace ARMeilleure.Translation.PTC
|
|||
{
|
||||
Span<OuterHeader> spanHeader = MemoryMarshal.CreateSpan(ref this, 1);
|
||||
|
||||
HeaderHash = XXHash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]);
|
||||
HeaderHash = Hash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]);
|
||||
}
|
||||
|
||||
public bool IsHeaderValid()
|
||||
{
|
||||
Span<OuterHeader> spanHeader = MemoryMarshal.CreateSpan(ref this, 1);
|
||||
|
||||
return XXHash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]) == HeaderHash;
|
||||
return Hash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]) == HeaderHash;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1071,14 +1071,14 @@ namespace ARMeilleure.Translation.PTC
|
|||
{
|
||||
Span<InnerHeader> spanHeader = MemoryMarshal.CreateSpan(ref this, 1);
|
||||
|
||||
HeaderHash = XXHash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<InnerHeader>() - Unsafe.SizeOf<Hash128>())]);
|
||||
HeaderHash = Hash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<InnerHeader>() - Unsafe.SizeOf<Hash128>())]);
|
||||
}
|
||||
|
||||
public bool IsHeaderValid()
|
||||
{
|
||||
Span<InnerHeader> spanHeader = MemoryMarshal.CreateSpan(ref this, 1);
|
||||
|
||||
return XXHash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<InnerHeader>() - Unsafe.SizeOf<Hash128>())]) == HeaderHash;
|
||||
return Hash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<InnerHeader>() - Unsafe.SizeOf<Hash128>())]) == HeaderHash;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
Hash128 expectedHash = DeserializeStructure<Hash128>(stream);
|
||||
|
||||
Hash128 actualHash = XXHash128.ComputeHash(GetReadOnlySpan(stream));
|
||||
Hash128 actualHash = Hash128.ComputeHash(GetReadOnlySpan(stream));
|
||||
|
||||
if (actualHash != expectedHash)
|
||||
{
|
||||
|
@ -313,7 +313,7 @@ namespace ARMeilleure.Translation.PTC
|
|||
Debug.Assert(stream.Position == stream.Length);
|
||||
|
||||
stream.Seek(Unsafe.SizeOf<Hash128>(), SeekOrigin.Begin);
|
||||
Hash128 hash = XXHash128.ComputeHash(GetReadOnlySpan(stream));
|
||||
Hash128 hash = Hash128.ComputeHash(GetReadOnlySpan(stream));
|
||||
|
||||
stream.Seek(0L, SeekOrigin.Begin);
|
||||
SerializeStructure(stream, hash);
|
||||
|
@ -374,14 +374,14 @@ namespace ARMeilleure.Translation.PTC
|
|||
{
|
||||
Span<OuterHeader> spanHeader = MemoryMarshal.CreateSpan(ref this, 1);
|
||||
|
||||
HeaderHash = XXHash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]);
|
||||
HeaderHash = Hash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]);
|
||||
}
|
||||
|
||||
public bool IsHeaderValid()
|
||||
{
|
||||
Span<OuterHeader> spanHeader = MemoryMarshal.CreateSpan(ref this, 1);
|
||||
|
||||
return XXHash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]) == HeaderHash;
|
||||
return Hash128.ComputeHash(MemoryMarshal.AsBytes(spanHeader)[..(Unsafe.SizeOf<OuterHeader>() - Unsafe.SizeOf<Hash128>())]) == HeaderHash;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||
{
|
||||
ref var entry = ref _table[i];
|
||||
|
||||
var hash = XXHash128.ComputeHash(mc[..entry.Length]);
|
||||
var hash = Hash128.ComputeHash(mc[..entry.Length]);
|
||||
if (hash == entry.Hash)
|
||||
{
|
||||
if (IsMacroHLESupported(caps, entry.Name))
|
||||
|
|
|
@ -223,7 +223,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
|
|||
|
||||
foreach (var entry in Table)
|
||||
{
|
||||
Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(entry.Code));
|
||||
Hash128 hash = Hash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(entry.Code));
|
||||
|
||||
string[] constants = new string[entry.Constants != null ? entry.Constants.Length : 0];
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
|
|||
currentCode = currentCode[..codeLength];
|
||||
}
|
||||
|
||||
Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(currentCode));
|
||||
Hash128 hash = Hash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(currentCode));
|
||||
|
||||
descriptor = default;
|
||||
|
||||
|
|
|
@ -453,7 +453,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
/// <returns>Hash of the data</returns>
|
||||
private static uint CalcHash(ReadOnlySpan<byte> data)
|
||||
{
|
||||
return (uint)XXHash128.ComputeHash(data).Low;
|
||||
return (uint)Hash128.ComputeHash(data).Low;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue