Compare commits

...

8 Commits

Author SHA1 Message Date
TSRBerry
c09c0c002d [Flatpak] Beautify multiline strings again & Add full git commit hash (#4535)
* Don't destroy multiline strings

* Use full git commit hash
2023-03-12 10:42:33 +01:00
Mary
d56d335c0b misc: Some dependencies cleanup (#4507)
* Remove dependencies on libraries provided by .NET standard library

* Use System.IO.Hashing instead of Crc32.NET
2023-03-12 03:24:11 +01:00
jhorv
23c844b2aa Misc performance tweaks (#4509)
* use Array.Empty() where instead of allocating new zero-length arrays

* structure for loops in a way that the JIT will elide array/Span bounds checking

* avoiding function calls in for loop condition tests

* avoid LINQ in a hot path

* conform with code style

* fix mistake in GetNextWaitingObject()

* fix GetNextWaitingObject() possibility of returning null if all list items have TimePoint == long.MaxValue

* make GetNextWaitingObject() behave FIFO behavior for multiple items with the same TimePoint
2023-03-11 17:05:48 -03:00
Mary
81691b9e37 gha(release): Attempt to fix flathub pusher 2023-03-11 20:11:09 +01:00
Mary
2dc422bc14 gha(release): Hopefully fixes it 2023-03-11 19:16:08 +01:00
Mary
a80fa5e33f gha(release): Makes environment variables global 2023-03-11 19:09:48 +01:00
Mary
954e995321 Attempt to fix syntax error of previous merge 2023-03-11 19:06:42 +01:00
TSRBerry
dad9ab6bb6 [Flatpak] Add release github workflow (#4529)
* Add flatpak release workflow

Co-authored-by: Mary <mary@mary.zone>

* infra: Update required SDK version to 7.0.200

---------

Co-authored-by: Mary <mary@mary.zone>
2023-03-11 19:04:13 +01:00
23 changed files with 250 additions and 62 deletions

171
.github/workflows/flatpak.yml vendored Normal file
View File

@@ -0,0 +1,171 @@
name: Flatpak release job
on:
workflow_call:
inputs:
ryujinx_version:
required: true
type: string
concurrency: flatpak-release
jobs:
release:
runs-on: ubuntu-latest
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
GIT_COMMITTER_NAME: "RyujinxBot"
GIT_COMMITTER_EMAIL: "61127645+RyujinxBot@users.noreply.github.com"
RYUJINX_PROJECT_FILE: "Ryujinx/Ryujinx.csproj"
NUGET_SOURCES_DESTDIR: "nuget-sources"
RYUJINX_VERSION: "${{ inputs.ryujinx_version }}"
steps:
- uses: actions/checkout@v3
with:
path: Ryujinx
- uses: actions/setup-dotnet@v3
with:
global-json-file: Ryujinx/global.json
- name: Get version info
id: version_info
working-directory: Ryujinx
run: |
echo "git_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
with:
repository: flathub/org.ryujinx.Ryujinx
token: ${{ secrets.RYUJINX_BOT_PAT }}
submodules: recursive
path: flathub
- name: Install dependencies
run: python -m pip install PyYAML lxml
- name: Restore Nuget packages
run: dotnet restore Ryujinx/${{ env.RYUJINX_PROJECT_FILE }}
- name: Generate nuget_sources.json
shell: python
run: |
from pathlib import Path
import base64
import binascii
import json
import os
sources = []
for path in Path(os.environ['NUGET_PACKAGES']).glob('**/*.nupkg.sha512'):
name = path.parent.parent.name
version = path.parent.name
filename = '{}.{}.nupkg'.format(name, version)
url = 'https://api.nuget.org/v3-flatcontainer/{}/{}/{}'.format(name, version, filename)
with path.open() as fp:
sha512 = binascii.hexlify(base64.b64decode(fp.read())).decode('ascii')
sources.append({
'type': 'file',
'url': url,
'sha512': sha512,
'dest': os.environ['NUGET_SOURCES_DESTDIR'],
'dest-filename': filename,
})
with open('flathub/nuget_sources.json', 'w') as fp:
json.dump(sources, fp, indent=4)
- name: Update flatpak metadata
id: metadata
env:
RYUJINX_GIT_HASH: ${{ steps.version_info.outputs.git_hash }}
shell: python
run: |
import hashlib
import hmac
import json
import os
import yaml
from datetime import datetime
from lxml import etree
# Ensure we don't destroy multiline strings
def str_presenter(dumper, data):
if len(data.splitlines()) > 1:
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")
return dumper.represent_scalar("tag:yaml.org,2002:str", data)
yaml.representer.SafeRepresenter.add_representer(str, str_presenter)
yaml_file = "flathub/org.ryujinx.Ryujinx.yml"
xml_file = "flathub/org.ryujinx.Ryujinx.appdata.xml"
with open(yaml_file, "r") as f:
data = yaml.safe_load(f)
for source in data["modules"][0]["sources"]:
if type(source) is str:
continue
if (
source["type"] == "git"
and source["url"] == "https://github.com/Ryujinx/Ryujinx.git"
):
source["commit"] = os.environ['RYUJINX_GIT_HASH']
is_same_version = data["modules"][0]["build-options"]["env"]["RYUJINX_VERSION"] == os.environ['RYUJINX_VERSION']
with open(os.environ['GITHUB_OUTPUT'], "a") as gh_out:
if is_same_version:
gh_out.write(f"commit_message=Retry update to {os.environ['RYUJINX_VERSION']}")
else:
gh_out.write(f"commit_message=Update to {os.environ['RYUJINX_VERSION']}")
if not is_same_version:
data["modules"][0]["build-options"]["env"]["RYUJINX_VERSION"] = os.environ['RYUJINX_VERSION']
with open(yaml_file, "w") as f:
yaml.safe_dump(data, f, sort_keys=False)
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(xml_file, parser)
root = tree.getroot()
releases = root.find("releases")
element = etree.Element("release")
element.set("version", os.environ['RYUJINX_VERSION'])
element.set("date", datetime.now().date().isoformat())
releases.insert(0, element)
# Ensure 4 spaces
etree.indent(root, space=" ")
with open(xml_file, "wb") as f:
f.write(
etree.tostring(
tree,
pretty_print=True,
encoding="UTF-8",
doctype='<?xml version="1.0" encoding="UTF-8"?>',
)
)
- name: Push flatpak update
working-directory: flathub
env:
COMMIT_MESSAGE: ${{ steps.metadata.outputs.commit_message }}
run: |
git config user.name "${{ env.GIT_COMMITTER_NAME }}"
git config user.email "${{ env.GIT_COMMITTER_EMAIL }}"
git add .
git commit -m "$COMMIT_MESSAGE"
git push origin master

View File

@@ -13,23 +13,22 @@ on:
concurrency: release concurrency: release
env:
POWERSHELL_TELEMETRY_OPTOUT: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
RYUJINX_BASE_VERSION: "1.1"
RYUJINX_TARGET_RELEASE_CHANNEL_NAME: "master"
RYUJINX_TARGET_RELEASE_CHANNEL_OWNER: "Ryujinx"
RYUJINX_TARGET_RELEASE_CHANNEL_REPO: "release-channel-master"
jobs: jobs:
release: release:
runs-on: windows-latest runs-on: windows-latest
env:
POWERSHELL_TELEMETRY_OPTOUT: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
RYUJINX_BASE_VERSION: "1.1"
RYUJINX_TARGET_RELEASE_CHANNEL_NAME: "master"
RYUJINX_TARGET_RELEASE_CHANNEL_OWNER: "Ryujinx"
RYUJINX_TARGET_RELEASE_CHANNEL_REPO: "release-channel-master"
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3 - uses: actions/setup-dotnet@v3
with: with:
dotnet-version: 7.0.x global-json-file: global.json
- name: Get version info - name: Get version info
id: version_info id: version_info
run: | run: |
@@ -112,3 +111,10 @@ jobs:
owner: ${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_OWNER }} owner: ${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_OWNER }}
repo: ${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_REPO }} repo: ${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_REPO }}
token: ${{ secrets.RELEASE_TOKEN }} token: ${{ secrets.RELEASE_TOKEN }}
flatpak_release:
uses: ./.github/workflows/flatpak.yml
needs: release
with:
ryujinx_version: "1.1.${{ github.run_number }}"
secrets: inherit

View File

@@ -265,7 +265,7 @@ namespace ARMeilleure.CodeGen.Arm64
} }
else else
{ {
relocInfo = new RelocInfo(new RelocEntry[0]); relocInfo = new RelocInfo(Array.Empty<RelocEntry>());
} }
return (code, relocInfo); return (code, relocInfo);

View File

@@ -433,16 +433,11 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
private static int GetHighestValueIndex(Span<int> span) private static int GetHighestValueIndex(Span<int> span)
{ {
int highest = span[0]; int highest = int.MinValue;
if (highest == int.MaxValue)
{
return 0;
}
int selected = 0; int selected = 0;
for (int index = 1; index < span.Length; index++) for (int index = 0; index < span.Length; index++)
{ {
int current = span[index]; int current = span[index];

View File

@@ -17,7 +17,7 @@ namespace ARMeilleure.Decoders
{ {
uint[] tbl = new uint[256]; uint[] tbl = new uint[256];
for (int idx = 0; idx < 256; idx++) for (int idx = 0; idx < tbl.Length; idx++)
{ {
tbl[idx] = ExpandImm8ToFP32((uint)idx); tbl[idx] = ExpandImm8ToFP32((uint)idx);
} }
@@ -29,7 +29,7 @@ namespace ARMeilleure.Decoders
{ {
ulong[] tbl = new ulong[256]; ulong[] tbl = new ulong[256];
for (int idx = 0; idx < 256; idx++) for (int idx = 0; idx < tbl.Length; idx++)
{ {
tbl[idx] = ExpandImm8ToFP64((ulong)idx); tbl[idx] = ExpandImm8ToFP64((ulong)idx);
} }

View File

@@ -1301,7 +1301,7 @@ namespace ARMeilleure.Decoders
{ {
List<InstInfo>[] temp = new List<InstInfo>[FastLookupSize]; List<InstInfo>[] temp = new List<InstInfo>[FastLookupSize];
for (int index = 0; index < FastLookupSize; index++) for (int index = 0; index < temp.Length; index++)
{ {
temp[index] = new List<InstInfo>(); temp[index] = new List<InstInfo>();
} }
@@ -1311,7 +1311,7 @@ namespace ARMeilleure.Decoders
int mask = ToFastLookupIndex(inst.Mask); int mask = ToFastLookupIndex(inst.Mask);
int value = ToFastLookupIndex(inst.Value); int value = ToFastLookupIndex(inst.Value);
for (int index = 0; index < FastLookupSize; index++) for (int index = 0; index < temp.Length; index++)
{ {
if ((index & mask) == value) if ((index & mask) == value)
{ {
@@ -1320,7 +1320,7 @@ namespace ARMeilleure.Decoders
} }
} }
for (int index = 0; index < FastLookupSize; index++) for (int index = 0; index < temp.Length; index++)
{ {
table[index] = temp[index].ToArray(); table[index] = temp[index].ToArray();
} }

View File

@@ -12,7 +12,6 @@
<PackageVersion Include="Avalonia.Svg.Skia" Version="0.10.18" /> <PackageVersion Include="Avalonia.Svg.Skia" Version="0.10.18" />
<PackageVersion Include="CommandLineParser" Version="2.9.1" /> <PackageVersion Include="CommandLineParser" Version="2.9.1" />
<PackageVersion Include="Concentus" Version="1.1.7" /> <PackageVersion Include="Concentus" Version="1.1.7" />
<PackageVersion Include="Crc32.NET" Version="1.2.0" />
<PackageVersion Include="DiscordRichPresence" Version="1.1.3.18" /> <PackageVersion Include="DiscordRichPresence" Version="1.1.3.18" />
<PackageVersion Include="DynamicData" Version="7.12.11" /> <PackageVersion Include="DynamicData" Version="7.12.11" />
<PackageVersion Include="FluentAvaloniaUI" Version="1.4.5" /> <PackageVersion Include="FluentAvaloniaUI" Version="1.4.5" />
@@ -45,10 +44,8 @@
<PackageVersion Include="SPB" Version="0.0.4-build28" /> <PackageVersion Include="SPB" Version="0.0.4-build28" />
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" /> <PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.27.0" /> <PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.27.0" />
<PackageVersion Include="System.IO.FileSystem.Primitives" Version="4.3.0" /> <PackageVersion Include="System.IO.Hashing" Version="7.0.0" />
<PackageVersion Include="System.Management" Version="7.0.0" /> <PackageVersion Include="System.Management" Version="7.0.0" />
<PackageVersion Include="System.Net.NameResolution" Version="4.3.0" />
<PackageVersion Include="System.Threading.ThreadPool" Version="4.3.0" />
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-f7c841d" /> <PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-f7c841d" />
<PackageVersion Include="XamlNameReferenceGenerator" Version="1.5.1" /> <PackageVersion Include="XamlNameReferenceGenerator" Version="1.5.1" />
</ItemGroup> </ItemGroup>

View File

@@ -400,7 +400,9 @@ namespace Ryujinx.Audio.Common
{ {
uint bufferIndex = (_releasedBufferIndex - _bufferReleasedCount) % Constants.AudioDeviceBufferCountMax; uint bufferIndex = (_releasedBufferIndex - _bufferReleasedCount) % Constants.AudioDeviceBufferCountMax;
for (int i = 0; i < GetTotalBufferCount(); i++) uint totalBufferCount = GetTotalBufferCount();
for (int i = 0; i < totalBufferCount; i++)
{ {
if (_buffers[bufferIndex].BufferTag == bufferTag) if (_buffers[bufferIndex].BufferTag == bufferTag)
{ {

View File

@@ -125,7 +125,7 @@ namespace Ryujinx.Ava.UI.Windows
public static Bgra32[] GetBuffer(Image<Bgra32> image) public static Bgra32[] GetBuffer(Image<Bgra32> image)
{ {
return image.TryGetSinglePixelSpan(out var data) ? data.ToArray() : new Bgra32[0]; return image.TryGetSinglePixelSpan(out var data) ? data.ToArray() : Array.Empty<Bgra32>();
} }
private static int GetColorScore(Dictionary<int, int> dominantColorBin, int maxHitCount, PaletteColor color) private static int GetColorScore(Dictionary<int, int> dominantColorBin, int maxHitCount, PaletteColor color)

View File

@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
_counterQueues = new CounterQueue[count]; _counterQueues = new CounterQueue[count];
for (int index = 0; index < count; index++) for (int index = 0; index < _counterQueues.Length; index++)
{ {
CounterType type = (CounterType)index; CounterType type = (CounterType)index;
_counterQueues[index] = new CounterQueue(gd, device, pipeline, type); _counterQueues[index] = new CounterQueue(gd, device, pipeline, type);

View File

@@ -29,9 +29,6 @@
<PackageReference Include="Silk.NET.Vulkan" /> <PackageReference Include="Silk.NET.Vulkan" />
<PackageReference Include="Silk.NET.Vulkan.Extensions.EXT" /> <PackageReference Include="Silk.NET.Vulkan.Extensions.EXT" />
<PackageReference Include="Silk.NET.Vulkan.Extensions.KHR" /> <PackageReference Include="Silk.NET.Vulkan.Extensions.KHR" />
<PackageReference Include="System.IO.FileSystem.Primitives" />
<PackageReference Include="System.Net.NameResolution" />
<PackageReference Include="System.Threading.ThreadPool" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Vulkan
uint structSize = 0; uint structSize = 0;
for (int i = 0; i < count; ++i) for (int i = 0; i < Map.Length; ++i)
{ {
var typeSize = SizeOf(description[i].Type); var typeSize = SizeOf(description[i].Type);
Map[i] = new SpecializationMapEntry(description[i].Id, structSize, typeSize); Map[i] = new SpecializationMapEntry(description[i].Id, structSize, typeSize);
@@ -46,11 +46,10 @@ namespace Ryujinx.Graphics.Vulkan
// For advanced mapping with overlapping or staggered fields // For advanced mapping with overlapping or staggered fields
public SpecDescription(SpecializationMapEntry[] map) public SpecDescription(SpecializationMapEntry[] map)
{ {
int count = map.Length;
Map = map; Map = map;
uint structSize = 0; uint structSize = 0;
for (int i = 0; i < count; ++i) for (int i = 0; i < map.Length; ++i)
{ {
structSize = Math.Max(structSize, map[i].Offset + (uint)map[i].Size); structSize = Math.Max(structSize, map[i].Offset + (uint)map[i].Size);
} }

View File

@@ -60,10 +60,9 @@ namespace Ryujinx.Graphics.Vulkan
private void RecreateSwapchain() private void RecreateSwapchain()
{ {
var oldSwapchain = _swapchain; var oldSwapchain = _swapchain;
int imageCount = _swapchainImageViews.Length;
_vsyncModeChanged = false; _vsyncModeChanged = false;
for (int i = 0; i < imageCount; i++) for (int i = 0; i < _swapchainImageViews.Length; i++)
{ {
_swapchainImageViews[i].Dispose(); _swapchainImageViews[i].Dispose();
} }
@@ -147,7 +146,7 @@ namespace Ryujinx.Graphics.Vulkan
_swapchainImageViews = new Auto<DisposableImageView>[imageCount]; _swapchainImageViews = new Auto<DisposableImageView>[imageCount];
for (int i = 0; i < imageCount; i++) for (int i = 0; i < _swapchainImageViews.Length; i++)
{ {
_swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format); _swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format);
} }

View File

@@ -49,12 +49,12 @@ namespace Ryujinx.HLE.HOS.Ipc
public static IpcHandleDesc MakeCopy(params int[] handles) public static IpcHandleDesc MakeCopy(params int[] handles)
{ {
return new IpcHandleDesc(handles, new int[0]); return new IpcHandleDesc(handles, Array.Empty<int>());
} }
public static IpcHandleDesc MakeMove(params int[] handles) public static IpcHandleDesc MakeMove(params int[] handles)
{ {
return new IpcHandleDesc(new int[0], handles); return new IpcHandleDesc(Array.Empty<int>(), handles);
} }
public byte[] GetBytes() public byte[] GetBytes()

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -132,7 +133,7 @@ namespace Ryujinx.HLE.HOS.Ipc
word0 |= (ReceiveBuff.Count & 0xf) << 24; word0 |= (ReceiveBuff.Count & 0xf) << 24;
word0 |= (ExchangeBuff.Count & 0xf) << 28; word0 |= (ExchangeBuff.Count & 0xf) << 28;
byte[] handleData = new byte[0]; byte[] handleData = Array.Empty<byte>();
if (HandleDesc != null) if (HandleDesc != null)
{ {
@@ -202,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Ipc
word0 |= (ReceiveBuff.Count & 0xf) << 24; word0 |= (ReceiveBuff.Count & 0xf) << 24;
word0 |= (ExchangeBuff.Count & 0xf) << 28; word0 |= (ExchangeBuff.Count & 0xf) << 28;
byte[] handleData = new byte[0]; byte[] handleData = Array.Empty<byte>();
if (HandleDesc != null) if (HandleDesc != null)
{ {

View File

@@ -1,7 +1,6 @@
using Ryujinx.Common; using Ryujinx.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.Common namespace Ryujinx.HLE.HOS.Kernel.Common
@@ -86,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
{ {
Interlocked.Exchange(ref _enforceWakeupFromSpinWait, 0); Interlocked.Exchange(ref _enforceWakeupFromSpinWait, 0);
next = _waitingObjects.OrderBy(x => x.TimePoint).FirstOrDefault(); next = GetNextWaitingObject();
} }
if (next != null) if (next != null)
@@ -140,6 +139,26 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
} }
} }
private WaitingObject GetNextWaitingObject()
{
WaitingObject selected = null;
long lowestTimePoint = long.MaxValue;
for (int index = _waitingObjects.Count - 1; index >= 0; index--)
{
WaitingObject current = _waitingObjects[index];
if (current.TimePoint <= lowestTimePoint)
{
selected = current;
lowestTimePoint = current.TimePoint;
}
}
return selected;
}
public static long ConvertNanosecondsToMilliseconds(long time) public static long ConvertNanosecondsToMilliseconds(long time)
{ {
time /= 1000000; time /= 1000000;

View File

@@ -233,7 +233,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
// If the location name is too long, error out. // If the location name is too long, error out.
if (locationName.Length > 0x24) if (locationName.Length > 0x24)
{ {
outLocationNameArray = new string[0]; outLocationNameArray = Array.Empty<string>();
return ResultCode.LocationNameTooLong; return ResultCode.LocationNameTooLong;
} }

View File

@@ -27,7 +27,9 @@ namespace Ryujinx.Input.SDL2
SDL2Driver.Instance.OnJoystickDisconnected += HandleJoyStickDisconnected; SDL2Driver.Instance.OnJoystickDisconnected += HandleJoyStickDisconnected;
// Add already connected gamepads // Add already connected gamepads
for (int joystickIndex = 0; joystickIndex < SDL_NumJoysticks(); joystickIndex++) int numJoysticks = SDL_NumJoysticks();
for (int joystickIndex = 0; joystickIndex < numJoysticks; joystickIndex++)
{ {
HandleJoyStickConnected(joystickIndex, SDL_JoystickGetDeviceInstanceID(joystickIndex)); HandleJoyStickConnected(joystickIndex, SDL_JoystickGetDeviceInstanceID(joystickIndex));
} }

View File

@@ -1,5 +1,4 @@
using Force.Crc32; using Ryujinx.Common;
using Ryujinx.Common;
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller; using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Configuration.Hid.Controller.Motion; using Ryujinx.Common.Configuration.Hid.Controller.Motion;
@@ -9,6 +8,7 @@ using Ryujinx.Input.Motion.CemuHook.Protocol;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Hashing;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Numerics; using System.Numerics;
@@ -401,10 +401,10 @@ namespace Ryujinx.Input.Motion.CemuHook
writer.Seek(6, SeekOrigin.Begin); writer.Seek(6, SeekOrigin.Begin);
writer.Write(header.Length); writer.Write(header.Length);
header.Crc32 = Crc32Algorithm.Compute(stream.ToArray()); Crc32.Hash(stream.ToArray(), header.Crc32.AsSpan());
writer.Seek(8, SeekOrigin.Begin); writer.Seek(8, SeekOrigin.Begin);
writer.Write(header.Crc32); writer.Write(header.Crc32.AsSpan());
byte[] data = stream.ToArray(); byte[] data = stream.ToArray();
@@ -440,10 +440,10 @@ namespace Ryujinx.Input.Motion.CemuHook
writer.Seek(6, SeekOrigin.Begin); writer.Seek(6, SeekOrigin.Begin);
writer.Write(header.Length); writer.Write(header.Length);
header.Crc32 = Crc32Algorithm.Compute(stream.ToArray()); Crc32.Hash(stream.ToArray(), header.Crc32.AsSpan());
writer.Seek(8, SeekOrigin.Begin); writer.Seek(8, SeekOrigin.Begin);
writer.Write(header.Crc32); writer.Write(header.Crc32.AsSpan());
byte[] data = stream.ToArray(); byte[] data = stream.ToArray();
@@ -458,8 +458,7 @@ namespace Ryujinx.Input.Motion.CemuHook
Id = (uint)clientId, Id = (uint)clientId,
MagicString = Magic, MagicString = Magic,
Version = Version, Version = Version,
Length = 0, Length = 0
Crc32 = 0
}; };
return header; return header;

View File

@@ -1,14 +1,15 @@
using System.Runtime.InteropServices; using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.Input.Motion.CemuHook.Protocol namespace Ryujinx.Input.Motion.CemuHook.Protocol
{ {
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Header public struct Header
{ {
public uint MagicString; public uint MagicString;
public ushort Version; public ushort Version;
public ushort Length; public ushort Length;
public uint Crc32; public Array4<byte> Crc32;
public uint Id; public uint Id;
} }
} }

View File

@@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Crc32.NET" /> <PackageReference Include="System.IO.Hashing" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -78,7 +78,7 @@ namespace Ryujinx.Memory.Tests
IEnumerable<MemoryRange> IVirtualMemoryManager.GetPhysicalRegions(ulong va, ulong size) IEnumerable<MemoryRange> IVirtualMemoryManager.GetPhysicalRegions(ulong va, ulong size)
{ {
return NoMappings ? new MemoryRange[0] : new MemoryRange[] { new MemoryRange(va, size) }; return NoMappings ? Array.Empty<MemoryRange>() : new MemoryRange[] { new MemoryRange(va, size) };
} }
public bool IsMapped(ulong va) public bool IsMapped(ulong va)

View File

@@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "7.0.100", "version": "7.0.200",
"rollForward": "latestFeature" "rollForward": "latestFeature"
} }
} }