Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
41b104d0fb | |||
bc44b85b0b | |||
01c2b8097c | |||
4bd2ca3f0d | |||
e63157cc33 | |||
7f2fb049f5 | |||
4744bde0e5 | |||
4a835bb2b9 | |||
ddc9ae2a83 | |||
d6d3cdd573 | |||
53bd4c9f60 |
@ -3,18 +3,18 @@
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Avalonia" Version="11.0.3" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.0.3" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.3" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.3" />
|
||||
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.0.3" />
|
||||
<PackageVersion Include="Avalonia.Svg" Version="11.0.0" />
|
||||
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0" />
|
||||
<PackageVersion Include="Avalonia" Version="11.0.4" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.0.4" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.4" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.4" />
|
||||
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.0.4" />
|
||||
<PackageVersion Include="Avalonia.Svg" Version="11.0.0.2" />
|
||||
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0.2" />
|
||||
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageVersion Include="Concentus" Version="1.1.7" />
|
||||
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
|
||||
<PackageVersion Include="DynamicData" Version="7.14.2" />
|
||||
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.1" />
|
||||
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.4" />
|
||||
<PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" />
|
||||
<PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" />
|
||||
<PackageVersion Include="jp2masa.Avalonia.Flexbox" Version="0.3.0-beta.4" />
|
||||
@ -44,7 +44,7 @@
|
||||
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
|
||||
<PackageVersion Include="SPB" Version="0.0.4-build28" />
|
||||
<PackageVersion Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.31.0" />
|
||||
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="7.0.0" />
|
||||
<PackageVersion Include="System.IO.Hashing" Version="7.0.0" />
|
||||
<PackageVersion Include="System.Management" Version="7.0.2" />
|
||||
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
|
||||
|
@ -189,7 +189,7 @@ namespace ARMeilleure.Translation
|
||||
{
|
||||
if (start.CompareTo(node.End) < 0)
|
||||
{
|
||||
if (overlaps.Length >= overlapCount)
|
||||
if (overlaps.Length <= overlapCount)
|
||||
{
|
||||
Array.Resize(ref overlaps, overlapCount + ArrayGrowthSize);
|
||||
}
|
||||
|
@ -31,9 +31,18 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
public bool IsEffectEnabled { get; }
|
||||
|
||||
public AuxiliaryBufferCommand(uint bufferOffset, byte inputBufferOffset, byte outputBufferOffset,
|
||||
ref AuxiliaryBufferAddresses sendBufferInfo, bool isEnabled, uint countMax,
|
||||
CpuAddress outputBuffer, CpuAddress inputBuffer, uint updateCount, uint writeOffset, int nodeId)
|
||||
public AuxiliaryBufferCommand(
|
||||
uint bufferOffset,
|
||||
byte inputBufferOffset,
|
||||
byte outputBufferOffset,
|
||||
ref AuxiliaryBufferAddresses sendBufferInfo,
|
||||
bool isEnabled,
|
||||
uint countMax,
|
||||
CpuAddress outputBuffer,
|
||||
CpuAddress inputBuffer,
|
||||
uint updateCount,
|
||||
uint writeOffset,
|
||||
int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
@ -21,7 +21,14 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
private BiquadFilterParameter _parameter;
|
||||
|
||||
public BiquadFilterCommand(int baseIndex, ref BiquadFilterParameter filter, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
|
||||
public BiquadFilterCommand(
|
||||
int baseIndex,
|
||||
ref BiquadFilterParameter filter,
|
||||
Memory<BiquadFilterState> biquadFilterStateMemory,
|
||||
int inputBufferOffset,
|
||||
int outputBufferOffset,
|
||||
bool needInitialization,
|
||||
int nodeId)
|
||||
{
|
||||
_parameter = filter;
|
||||
BiquadFilterState = biquadFilterStateMemory;
|
||||
|
@ -77,7 +77,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void ClearBuffer(int index)
|
||||
{
|
||||
Unsafe.InitBlock((void*)GetBufferPointer(index), 0, SampleCount);
|
||||
Unsafe.InitBlock((void*)GetBufferPointer(index), 0, SampleCount * sizeof(float));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -89,7 +89,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void CopyBuffer(int outputBufferIndex, int inputBufferIndex)
|
||||
{
|
||||
Unsafe.CopyBlock((void*)GetBufferPointer(outputBufferIndex), (void*)GetBufferPointer(inputBufferIndex), SampleCount);
|
||||
Unsafe.CopyBlock((void*)GetBufferPointer(outputBufferIndex), (void*)GetBufferPointer(inputBufferIndex), SampleCount * sizeof(float));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
@ -94,18 +94,18 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
float newMean = inputMovingAverage.Update(FloatingPointHelper.MeanSquare(channelInput), _parameter.InputGain);
|
||||
float y = FloatingPointHelper.Log10(newMean) * 10.0f;
|
||||
float z = 0.0f;
|
||||
float z = 1.0f;
|
||||
|
||||
bool unknown10OutOfRange = false;
|
||||
bool unknown10OutOfRange = y >= state.Unknown10;
|
||||
|
||||
if (newMean < 1.0e-10f)
|
||||
{
|
||||
z = 1.0f;
|
||||
y = -100.0f;
|
||||
|
||||
unknown10OutOfRange = state.Unknown10 < -100.0f;
|
||||
unknown10OutOfRange = state.Unknown10 <= -100.0f;
|
||||
}
|
||||
|
||||
if (y >= state.Unknown10 || unknown10OutOfRange)
|
||||
if (unknown10OutOfRange)
|
||||
{
|
||||
float tmpGain;
|
||||
|
||||
@ -118,7 +118,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
tmpGain = (y - state.Unknown10) * ((y - state.Unknown10) * -state.CompressorGainReduction);
|
||||
}
|
||||
|
||||
z = FloatingPointHelper.DecibelToLinearExtended(tmpGain);
|
||||
z = FloatingPointHelper.DecibelToLinear(tmpGain);
|
||||
}
|
||||
|
||||
float unknown4New = z;
|
||||
|
@ -28,7 +28,14 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
private LimiterParameter _parameter;
|
||||
|
||||
public LimiterCommandVersion2(uint bufferOffset, LimiterParameter parameter, Memory<LimiterState> state, Memory<EffectResultState> resultState, bool isEnabled, ulong workBuffer, int nodeId)
|
||||
public LimiterCommandVersion2(
|
||||
uint bufferOffset,
|
||||
LimiterParameter parameter,
|
||||
Memory<LimiterState> state,
|
||||
Memory<EffectResultState> resultState,
|
||||
bool isEnabled,
|
||||
ulong workBuffer,
|
||||
int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
@ -79,7 +79,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void ProcessReverbMono(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||
{
|
||||
ProcessReverbGeneric(ref state,
|
||||
ProcessReverbGeneric(
|
||||
ref state,
|
||||
outputBuffers,
|
||||
inputBuffers,
|
||||
sampleCount,
|
||||
@ -92,7 +93,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void ProcessReverbStereo(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||
{
|
||||
ProcessReverbGeneric(ref state,
|
||||
ProcessReverbGeneric(
|
||||
ref state,
|
||||
outputBuffers,
|
||||
inputBuffers,
|
||||
sampleCount,
|
||||
@ -105,7 +107,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void ProcessReverbQuadraphonic(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||
{
|
||||
ProcessReverbGeneric(ref state,
|
||||
ProcessReverbGeneric(
|
||||
ref state,
|
||||
outputBuffers,
|
||||
inputBuffers,
|
||||
sampleCount,
|
||||
@ -118,7 +121,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void ProcessReverbSurround(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
||||
{
|
||||
ProcessReverbGeneric(ref state,
|
||||
ProcessReverbGeneric(
|
||||
ref state,
|
||||
outputBuffers,
|
||||
inputBuffers,
|
||||
sampleCount,
|
||||
|
@ -52,7 +52,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||
{
|
||||
// NOTE: Nintendo uses an approximation of log10, we don't.
|
||||
// As such, we support the same ranges as Nintendo to avoid unexpected behaviours.
|
||||
return MathF.Pow(10, MathF.Max(x, 1.0e-10f));
|
||||
return MathF.Log10(MathF.Max(x, 1.0e-10f));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -62,7 +62,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||
|
||||
foreach (float input in inputs)
|
||||
{
|
||||
res += (input * input);
|
||||
float normInput = input * (1f / 32768f);
|
||||
res += normInput * normInput;
|
||||
}
|
||||
|
||||
res /= inputs.Length;
|
||||
@ -81,19 +82,6 @@ namespace Ryujinx.Audio.Renderer.Dsp
|
||||
return MathF.Pow(10.0f, db / 20.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Map decibel to linear in [0, 2] range.
|
||||
/// </summary>
|
||||
/// <param name="db">The decibel value to convert</param>
|
||||
/// <returns>Converted linear value in [0, 2] range</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float DecibelToLinearExtended(float db)
|
||||
{
|
||||
float tmp = MathF.Log2(DecibelToLinear(db));
|
||||
|
||||
return MathF.Truncate(tmp) + MathF.Pow(2.0f, tmp - MathF.Truncate(tmp));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float DegreesToRadians(float degrees)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ using Ryujinx.Audio.Renderer.Parameter.Effect;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
{
|
||||
public class CompressorState
|
||||
public struct CompressorState
|
||||
{
|
||||
public ExponentialMovingAverage InputMovingAverage;
|
||||
public float Unknown4;
|
||||
@ -45,7 +45,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
CompressorGainReduction = (1.0f - ratio) / Constants.ChannelCountMax;
|
||||
Unknown10 = threshold - 1.5f;
|
||||
Unknown14 = threshold + 1.5f;
|
||||
OutputGain = FloatingPointHelper.DecibelToLinearExtended(parameter.OutputGain + makeupGain);
|
||||
OutputGain = FloatingPointHelper.DecibelToLinear(parameter.OutputGain + makeupGain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
{
|
||||
public class DelayState
|
||||
public struct DelayState
|
||||
{
|
||||
public DelayLine[] DelayLines { get; }
|
||||
public float[] LowPassZ { get; set; }
|
||||
@ -53,7 +53,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
LowPassBaseGain = 1.0f - LowPassFeedbackGain;
|
||||
}
|
||||
|
||||
public void UpdateLowPassFilter(ref float tempRawRef, uint channelCount)
|
||||
public readonly void UpdateLowPassFilter(ref float tempRawRef, uint channelCount)
|
||||
{
|
||||
for (int i = 0; i < channelCount; i++)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
{
|
||||
public class LimiterState
|
||||
public struct LimiterState
|
||||
{
|
||||
public ExponentialMovingAverage[] DetectorAverage;
|
||||
public ExponentialMovingAverage[] CompressionGainAverage;
|
||||
|
@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
{
|
||||
public class Reverb3dState
|
||||
public struct Reverb3dState
|
||||
{
|
||||
private readonly float[] _fdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
|
||||
private readonly float[] _fdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
{
|
||||
public class ReverbState
|
||||
public struct ReverbState
|
||||
{
|
||||
private static readonly float[] _fdnDelayTimes = new float[20]
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ namespace Ryujinx.Ava
|
||||
{
|
||||
"Light" => ThemeVariant.Light,
|
||||
"Dark" => ThemeVariant.Dark,
|
||||
_ => ThemeVariant.Default
|
||||
_ => ThemeVariant.Default,
|
||||
};
|
||||
|
||||
if (enableCustomTheme)
|
||||
|
@ -3,7 +3,6 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Rendering;
|
||||
using Avalonia.Threading;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Audio.Backends.Dummy;
|
||||
@ -21,6 +20,7 @@ using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Multiplayer;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.SystemInterop;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
@ -191,6 +191,7 @@ namespace Ryujinx.Ava
|
||||
ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Event += UpdateColorSpacePassthrough;
|
||||
|
||||
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState;
|
||||
ConfigurationState.Instance.Multiplayer.Mode.Event += UpdateMultiplayerModeState;
|
||||
|
||||
_gpuCancellationTokenSource = new CancellationTokenSource();
|
||||
_gpuDoneEvent = new ManualResetEvent(false);
|
||||
@ -412,6 +413,11 @@ namespace Ryujinx.Ava
|
||||
Device.Configuration.MultiplayerLanInterfaceId = e.NewValue;
|
||||
}
|
||||
|
||||
private void UpdateMultiplayerModeState(object sender, ReactiveEventArgs<MultiplayerMode> e)
|
||||
{
|
||||
Device.Configuration.MultiplayerMode = e.NewValue;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_isActive = false;
|
||||
@ -782,7 +788,8 @@ namespace Ryujinx.Ava
|
||||
ConfigurationState.Instance.Graphics.AspectRatio,
|
||||
ConfigurationState.Instance.System.AudioVolume,
|
||||
ConfigurationState.Instance.System.UseHypervisor,
|
||||
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value);
|
||||
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
|
||||
ConfigurationState.Instance.Multiplayer.Mode);
|
||||
|
||||
Device = new Switch(configuration);
|
||||
}
|
||||
|
@ -652,5 +652,8 @@
|
||||
"NetworkInterfaceDefault": "Default",
|
||||
"PackagingShaders": "Packaging Shaders",
|
||||
"AboutChangelogButton": "View Changelog on GitHub",
|
||||
"AboutChangelogButtonTooltipMessage": "Click to open the changelog for this version in your default browser."
|
||||
"AboutChangelogButtonTooltipMessage": "Click to open the changelog for this version in your default browser.",
|
||||
"SettingsTabNetworkMultiplayer": "Multiplayer",
|
||||
"MultiplayerMode": "Mode:",
|
||||
"MultiplayerModeTooltip": "Change multiplayer mode"
|
||||
}
|
@ -15,7 +15,6 @@ using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Controls;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
@ -36,11 +35,9 @@ namespace Ryujinx.Ava.Common
|
||||
private static HorizonClient _horizonClient;
|
||||
private static AccountManager _accountManager;
|
||||
private static VirtualFileSystem _virtualFileSystem;
|
||||
private static StyleableWindow _owner;
|
||||
|
||||
public static void Initialize(VirtualFileSystem virtualFileSystem, AccountManager accountManager, HorizonClient horizonClient, StyleableWindow owner)
|
||||
public static void Initialize(VirtualFileSystem virtualFileSystem, AccountManager accountManager, HorizonClient horizonClient)
|
||||
{
|
||||
_owner = owner;
|
||||
_virtualFileSystem = virtualFileSystem;
|
||||
_horizonClient = horizonClient;
|
||||
_accountManager = accountManager;
|
||||
@ -148,7 +145,7 @@ namespace Ryujinx.Ava.Common
|
||||
var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.FolderDialogExtractTitle],
|
||||
AllowMultiple = false
|
||||
AllowMultiple = false,
|
||||
});
|
||||
|
||||
if (result.Count == 0)
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Input;
|
||||
using System;
|
||||
|
@ -82,12 +82,9 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, "Failed to convert the current Ryujinx version!");
|
||||
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]);
|
||||
});
|
||||
|
||||
_running = false;
|
||||
|
||||
@ -114,10 +111,9 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (showVersionUpToDate)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateUpdaterInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage], "");
|
||||
});
|
||||
await ContentDialogHelper.CreateUpdaterInfoDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage],
|
||||
"");
|
||||
}
|
||||
|
||||
_running = false;
|
||||
@ -134,10 +130,9 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (showVersionUpToDate)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateUpdaterInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage], "");
|
||||
});
|
||||
await ContentDialogHelper.CreateUpdaterInfoDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage],
|
||||
"");
|
||||
}
|
||||
|
||||
_running = false;
|
||||
@ -149,10 +144,8 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, exception.Message);
|
||||
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUpdaterFailedToGetVersionMessage]);
|
||||
});
|
||||
await ContentDialogHelper.CreateErrorDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterFailedToGetVersionMessage]);
|
||||
|
||||
_running = false;
|
||||
|
||||
@ -167,12 +160,9 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, "Failed to convert the received Ryujinx version from Github!");
|
||||
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterConvertFailedGithubMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterCancelUpdateMessage]);
|
||||
});
|
||||
|
||||
_running = false;
|
||||
|
||||
@ -183,10 +173,9 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (showVersionUpToDate)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateUpdaterInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage], "");
|
||||
});
|
||||
await ContentDialogHelper.CreateUpdaterInfoDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterAlreadyOnLatestVersionMessage],
|
||||
"");
|
||||
}
|
||||
|
||||
_running = false;
|
||||
@ -212,7 +201,7 @@ namespace Ryujinx.Modules
|
||||
_buildSize = -1;
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
await Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
// Show a message asking the user if they want to update
|
||||
var shouldUpdate = await ContentDialogHelper.CreateChoiceDialog(
|
||||
@ -222,7 +211,7 @@ namespace Ryujinx.Modules
|
||||
|
||||
if (shouldUpdate)
|
||||
{
|
||||
UpdateRyujinx(mainWindow, _buildUrl);
|
||||
await UpdateRyujinx(mainWindow, _buildUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -241,7 +230,7 @@ namespace Ryujinx.Modules
|
||||
return result;
|
||||
}
|
||||
|
||||
private static async void UpdateRyujinx(Window parent, string downloadUrl)
|
||||
private static async Task UpdateRyujinx(Window parent, string downloadUrl)
|
||||
{
|
||||
_updateSuccessful = false;
|
||||
|
||||
@ -579,14 +568,12 @@ namespace Ryujinx.Modules
|
||||
}
|
||||
}
|
||||
|
||||
private static async void InstallUpdate(TaskDialog taskDialog, string updateFile)
|
||||
private static void InstallUpdate(TaskDialog taskDialog, string updateFile)
|
||||
{
|
||||
// Extract Update
|
||||
taskDialog.SubHeader = LocaleManager.Instance[LocaleKeys.UpdaterExtracting];
|
||||
taskDialog.SetProgressBarState(0, TaskDialogProgressState.Normal);
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
|
||||
{
|
||||
ExtractTarGzipFile(taskDialog, updateFile, _updateDir);
|
||||
@ -599,7 +586,6 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
});
|
||||
|
||||
// Delete downloaded zip
|
||||
File.Delete(updateFile);
|
||||
@ -613,8 +599,6 @@ namespace Ryujinx.Modules
|
||||
if (!OperatingSystem.IsMacOS())
|
||||
{
|
||||
// Replace old files
|
||||
await Task.Run(() =>
|
||||
{
|
||||
double count = 0;
|
||||
foreach (string file in allFiles)
|
||||
{
|
||||
@ -623,7 +607,7 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
File.Move(file, file + ".ryuold");
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
taskDialog.SetProgressBarState(GetPercentage(count, allFiles.Count), TaskDialogProgressState.Normal);
|
||||
});
|
||||
@ -634,14 +618,13 @@ namespace Ryujinx.Modules
|
||||
}
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
taskDialog.SubHeader = LocaleManager.Instance[LocaleKeys.UpdaterAddingFiles];
|
||||
taskDialog.SetProgressBarState(0, TaskDialogProgressState.Normal);
|
||||
});
|
||||
|
||||
MoveAllFilesOver(_updatePublishDir, _homeDir, taskDialog);
|
||||
});
|
||||
|
||||
Directory.Delete(_updateDir, true);
|
||||
}
|
||||
@ -658,12 +641,11 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (showWarnings)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterArchNotSupportedMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterArchNotSupportedSubMessage]);
|
||||
});
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterArchNotSupportedSubMessage])
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -673,12 +655,11 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (showWarnings)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterNoInternetMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterNoInternetSubMessage]);
|
||||
});
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterNoInternetSubMessage])
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -688,12 +669,11 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (showWarnings)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterDirtyBuildMessage],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterDirtyBuildSubMessage]);
|
||||
});
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterDirtyBuildSubMessage])
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -705,21 +685,19 @@ namespace Ryujinx.Modules
|
||||
{
|
||||
if (ReleaseInformation.IsFlatHubBuild())
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.UpdaterDisabledWarningTitle],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterFlatpakNotSupportedMessage]);
|
||||
});
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterFlatpakNotSupportedMessage])
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateWarningDialog(
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateWarningDialog(
|
||||
LocaleManager.Instance[LocaleKeys.UpdaterDisabledWarningTitle],
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterDirtyBuildSubMessage]);
|
||||
});
|
||||
LocaleManager.Instance[LocaleKeys.DialogUpdaterDirtyBuildSubMessage])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||
bool error = false;
|
||||
string inputText = args.InitialText ?? "";
|
||||
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -149,7 +149,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||
|
||||
bool showDetails = false;
|
||||
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
{
|
||||
if (sender is MenuItem { DataContext: MainWindowViewModel viewModel })
|
||||
{
|
||||
OpenSaveDirectory(viewModel, SaveDataType.Account, userId: new UserId((ulong)viewModel.AccountManager.LastOpenedUser.UserId.High, (ulong)viewModel.AccountManager.LastOpenedUser.UserId.Low));
|
||||
OpenSaveDirectory(viewModel, SaveDataType.Account, new UserId((ulong)viewModel.AccountManager.LastOpenedUser.UserId.High, (ulong)viewModel.AccountManager.LastOpenedUser.UserId.Low));
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,14 +62,14 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
{
|
||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||
|
||||
OpenSaveDirectory(viewModel, SaveDataType.Device, userId: default);
|
||||
OpenSaveDirectory(viewModel, SaveDataType.Device, default);
|
||||
}
|
||||
|
||||
public void OpenBcatSaveDirectory_Click(object sender, RoutedEventArgs args)
|
||||
{
|
||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||
|
||||
OpenSaveDirectory(viewModel, SaveDataType.Bcat, userId: default);
|
||||
OpenSaveDirectory(viewModel, SaveDataType.Bcat, default);
|
||||
}
|
||||
|
||||
private static void OpenSaveDirectory(MainWindowViewModel viewModel, SaveDataType saveDataType, UserId userId)
|
||||
@ -158,7 +158,8 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
|
||||
if (viewModel?.SelectedApplication != null)
|
||||
{
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogPPTCDeletionMessage, viewModel.SelectedApplication.TitleName),
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
@ -205,7 +206,8 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
|
||||
if (viewModel?.SelectedApplication != null)
|
||||
{
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogShaderDeletionMessage, viewModel.SelectedApplication.TitleName),
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
@ -335,13 +337,13 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public void RunApplication_Click(object sender, RoutedEventArgs args)
|
||||
public async void RunApplication_Click(object sender, RoutedEventArgs args)
|
||||
{
|
||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||
|
||||
if (viewModel?.SelectedApplication != null)
|
||||
{
|
||||
viewModel.LoadApplication(viewModel.SelectedApplication.Path);
|
||||
await viewModel.LoadApplication(viewModel.SelectedApplication.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,9 +212,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Patterns = new[] { "*.nsp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
|
||||
MimeTypes = new[] { "application/x-nx-nsp" }
|
||||
}
|
||||
}
|
||||
MimeTypes = new[] { "application/x-nx-nsp" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
foreach (var file in result)
|
||||
|
@ -26,6 +26,7 @@ using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.HLE.Ui;
|
||||
using Ryujinx.Input.HLE;
|
||||
using Ryujinx.Modules;
|
||||
using Ryujinx.Ui.App.Common;
|
||||
using Ryujinx.Ui.Common;
|
||||
@ -39,7 +40,6 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Image = SixLabors.ImageSharp.Image;
|
||||
using InputManager = Ryujinx.Input.HLE.InputManager;
|
||||
using Key = Ryujinx.Input.Key;
|
||||
using MissingKeyException = LibHac.Common.Keys.MissingKeyException;
|
||||
using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
|
||||
@ -1068,9 +1068,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, ex.ToString());
|
||||
|
||||
static async void Action() => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys);
|
||||
|
||||
Dispatcher.UIThread.Post(Action);
|
||||
await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1163,16 +1161,13 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
AppHost?.DisposeContext();
|
||||
}
|
||||
|
||||
private void HandleRelaunch()
|
||||
private async Task HandleRelaunch()
|
||||
{
|
||||
if (UserChannelPersistence.PreviousIndex != -1 && UserChannelPersistence.ShouldRestart)
|
||||
{
|
||||
UserChannelPersistence.ShouldRestart = false;
|
||||
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
LoadApplication(_currentEmulatedGamePath);
|
||||
});
|
||||
await LoadApplication(_currentEmulatedGamePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1191,7 +1186,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
Application.Current.Styles.TryGetResource(args.VSyncEnabled
|
||||
? "VsyncEnabled"
|
||||
: "VsyncDisabled",
|
||||
Avalonia.Application.Current.ActualThemeVariant,
|
||||
Application.Current.ActualThemeVariant,
|
||||
out object color);
|
||||
|
||||
if (color is not null)
|
||||
@ -1283,7 +1278,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
Glyph = Glyph.Grid;
|
||||
}
|
||||
|
||||
public async void InstallFirmwareFromFile()
|
||||
public async Task InstallFirmwareFromFile()
|
||||
{
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
@ -1294,21 +1289,21 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Patterns = new[] { "*.xci", "*.zip" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" },
|
||||
MimeTypes = new[] { "application/x-nx-xci", "application/zip" }
|
||||
MimeTypes = new[] { "application/x-nx-xci", "application/zip" },
|
||||
},
|
||||
new("XCI")
|
||||
{
|
||||
Patterns = new[] { "*.xci" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
|
||||
MimeTypes = new[] { "application/x-nx-xci" }
|
||||
MimeTypes = new[] { "application/x-nx-xci" },
|
||||
},
|
||||
new("ZIP")
|
||||
{
|
||||
Patterns = new[] { "*.zip" },
|
||||
AppleUniformTypeIdentifiers = new[] { "public.zip-archive" },
|
||||
MimeTypes = new[] { "application/zip" }
|
||||
MimeTypes = new[] { "application/zip" },
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
@ -1317,11 +1312,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async void InstallFirmwareFromFolder()
|
||||
public async Task InstallFirmwareFromFolder()
|
||||
{
|
||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false
|
||||
AllowMultiple = false,
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
@ -1352,7 +1347,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async void ExitCurrentState()
|
||||
public async Task ExitCurrentState()
|
||||
{
|
||||
if (WindowState == WindowState.FullScreen)
|
||||
{
|
||||
@ -1377,7 +1372,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async void ManageProfiles()
|
||||
public async Task ManageProfiles()
|
||||
{
|
||||
await NavigationDialogHost.Show(AccountManager, ContentManager, VirtualFileSystem, LibHacHorizonManager.RyujinxClient);
|
||||
}
|
||||
@ -1387,7 +1382,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
AppHost.Device.System.SimulateWakeUpMessage();
|
||||
}
|
||||
|
||||
public async void OpenFile()
|
||||
public async Task OpenFile()
|
||||
{
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
@ -1404,7 +1399,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
"com.ryujinx.xci",
|
||||
"com.ryujinx.nca",
|
||||
"com.ryujinx.nro",
|
||||
"com.ryujinx.nso"
|
||||
"com.ryujinx.nso",
|
||||
},
|
||||
MimeTypes = new[]
|
||||
{
|
||||
@ -1412,63 +1407,63 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
"application/x-nx-xci",
|
||||
"application/x-nx-nca",
|
||||
"application/x-nx-nro",
|
||||
"application/x-nx-nso"
|
||||
}
|
||||
"application/x-nx-nso",
|
||||
},
|
||||
},
|
||||
new("NSP")
|
||||
{
|
||||
Patterns = new[] { "*.nsp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
|
||||
MimeTypes = new[] { "application/x-nx-nsp" }
|
||||
MimeTypes = new[] { "application/x-nx-nsp" },
|
||||
},
|
||||
new("XCI")
|
||||
{
|
||||
Patterns = new[] { "*.xci" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" },
|
||||
MimeTypes = new[] { "application/x-nx-xci" }
|
||||
MimeTypes = new[] { "application/x-nx-xci" },
|
||||
},
|
||||
new("NCA")
|
||||
{
|
||||
Patterns = new[] { "*.nca" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nca" },
|
||||
MimeTypes = new[] { "application/x-nx-nca" }
|
||||
MimeTypes = new[] { "application/x-nx-nca" },
|
||||
},
|
||||
new("NRO")
|
||||
{
|
||||
Patterns = new[] { "*.nro" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nro" },
|
||||
MimeTypes = new[] { "application/x-nx-nro" }
|
||||
MimeTypes = new[] { "application/x-nx-nro" },
|
||||
},
|
||||
new("NSO")
|
||||
{
|
||||
Patterns = new[] { "*.nso" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nso" },
|
||||
MimeTypes = new[] { "application/x-nx-nso" }
|
||||
MimeTypes = new[] { "application/x-nx-nso" },
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
LoadApplication(result[0].Path.LocalPath);
|
||||
await LoadApplication(result[0].Path.LocalPath);
|
||||
}
|
||||
}
|
||||
|
||||
public async void OpenFolder()
|
||||
public async Task OpenFolder()
|
||||
{
|
||||
var result = await StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.OpenFolderDialogTitle],
|
||||
AllowMultiple = false
|
||||
AllowMultiple = false,
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
LoadApplication(result[0].Path.LocalPath);
|
||||
await LoadApplication(result[0].Path.LocalPath);
|
||||
}
|
||||
}
|
||||
|
||||
public async void LoadApplication(string path, bool startFullscreen = false, string titleName = "")
|
||||
public async Task LoadApplication(string path, bool startFullscreen = false, string titleName = "")
|
||||
{
|
||||
if (AppHost != null)
|
||||
{
|
||||
@ -1505,8 +1500,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
this,
|
||||
TopLevel);
|
||||
|
||||
async void Action()
|
||||
{
|
||||
if (!await AppHost.LoadGuestApplication())
|
||||
{
|
||||
AppHost.DisposeContext();
|
||||
@ -1533,9 +1526,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
gameThread.Start();
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Post(Action);
|
||||
}
|
||||
|
||||
public void SwitchToRenderer(bool startFullscreen)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
@ -1596,7 +1586,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
IsGameRunning = false;
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
ShowMenuAndStatusBar = true;
|
||||
ShowContent = true;
|
||||
@ -1609,7 +1599,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
AppHost = null;
|
||||
|
||||
HandleRelaunch();
|
||||
await HandleRelaunch();
|
||||
});
|
||||
|
||||
RendererHostControl.WindowCreated -= RendererHost_Created;
|
||||
|
@ -10,6 +10,7 @@ using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Common.Configuration.Multiplayer;
|
||||
using Ryujinx.Common.GraphicsDriver;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
@ -54,6 +55,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
public event Action CloseWindow;
|
||||
public event Action SaveSettingsEvent;
|
||||
private int _networkInterfaceIndex;
|
||||
private int _multiplayerModeIndex;
|
||||
|
||||
public int ResolutionScale
|
||||
{
|
||||
@ -76,14 +78,13 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
if (_graphicsBackendMultithreadingIndex != (int)ConfigurationState.Instance.Graphics.BackendThreading.Value)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogSettingsBackendThreadingWarningMessage],
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogSettingsBackendThreadingWarningMessage],
|
||||
"",
|
||||
"",
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogOk],
|
||||
LocaleManager.Instance[LocaleKeys.DialogSettingsBackendThreadingWarningTitle]);
|
||||
});
|
||||
LocaleManager.Instance[LocaleKeys.DialogSettingsBackendThreadingWarningTitle])
|
||||
);
|
||||
}
|
||||
|
||||
OnPropertyChanged();
|
||||
@ -251,6 +252,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
get => new(_networkInterfaces.Keys);
|
||||
}
|
||||
|
||||
public AvaloniaList<string> MultiplayerModes
|
||||
{
|
||||
get => new(Enum.GetNames<MultiplayerMode>());
|
||||
}
|
||||
|
||||
public KeyboardHotkeys KeyboardHotkeys
|
||||
{
|
||||
get => _keyboardHotkeys;
|
||||
@ -272,6 +278,16 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public int MultiplayerModeIndex
|
||||
{
|
||||
get => _multiplayerModeIndex;
|
||||
set
|
||||
{
|
||||
_multiplayerModeIndex = value;
|
||||
ConfigurationState.Instance.Multiplayer.Mode.Value = (MultiplayerMode)_multiplayerModeIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsViewModel(VirtualFileSystem virtualFileSystem, ContentManager contentManager) : this()
|
||||
{
|
||||
_virtualFileSystem = virtualFileSystem;
|
||||
@ -478,6 +494,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
EnableFsAccessLog = config.Logger.EnableFsAccessLog;
|
||||
FsGlobalAccessLogMode = config.System.FsGlobalAccessLogMode;
|
||||
OpenglDebugLevel = (int)config.Logger.GraphicsDebugLevel.Value;
|
||||
|
||||
MultiplayerModeIndex = (int)config.Multiplayer.Mode.Value;
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
@ -579,6 +597,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
config.Logger.GraphicsDebugLevel.Value = (GraphicsDebugLevel)OpenglDebugLevel;
|
||||
|
||||
config.Multiplayer.LanInterfaceId.Value = _networkInterfaces[NetworkInterfaceList[NetworkInterfaceIndex]];
|
||||
config.Multiplayer.Mode.Value = (MultiplayerMode)MultiplayerModeIndex;
|
||||
|
||||
config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
|
||||
|
||||
|
@ -22,6 +22,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Path = System.IO.Path;
|
||||
using SpanHelpers = LibHac.Common.SpanHelpers;
|
||||
|
||||
@ -184,18 +185,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUpdateAddUpdateErrorMessage]);
|
||||
});
|
||||
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogUpdateAddUpdateErrorMessage]));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadNcaErrorMessage, ex.Message, path));
|
||||
});
|
||||
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadNcaErrorMessage, ex.Message, path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,7 +202,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
SortUpdates();
|
||||
}
|
||||
|
||||
public async void Add()
|
||||
public async Task Add()
|
||||
{
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
@ -218,9 +213,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Patterns = new[] { "*.nsp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" },
|
||||
MimeTypes = new[] { "application/x-nx-nsp" }
|
||||
}
|
||||
}
|
||||
MimeTypes = new[] { "application/x-nx-nsp" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
foreach (var file in result)
|
||||
|
@ -17,7 +17,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.Main
|
||||
{
|
||||
@ -107,20 +106,14 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||
await Window.ViewModel.AppHost?.ShowExitPrompt();
|
||||
}
|
||||
|
||||
private async void PauseEmulation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
private void PauseEmulation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Window.ViewModel.AppHost?.Pause();
|
||||
});
|
||||
}
|
||||
|
||||
private async void ResumeEmulation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
private void ResumeEmulation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Window.ViewModel.AppHost?.Resume();
|
||||
});
|
||||
}
|
||||
|
||||
public async void OpenSettings(object sender, RoutedEventArgs e)
|
||||
@ -132,13 +125,13 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||
ViewModel.LoadConfigurableHotKeys();
|
||||
}
|
||||
|
||||
public void OpenMiiApplet(object sender, RoutedEventArgs e)
|
||||
public async void OpenMiiApplet(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string contentPath = ViewModel.ContentManager.GetInstalledContentPath(0x0100000000001009, StorageId.BuiltInSystem, NcaContentType.Program);
|
||||
|
||||
if (!string.IsNullOrEmpty(contentPath))
|
||||
{
|
||||
ViewModel.LoadApplication(contentPath, false, "Mii Applet");
|
||||
await ViewModel.LoadApplication(contentPath, false, "Mii Applet");
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,8 +189,7 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||
{
|
||||
if (FileAssociationHelper.Install())
|
||||
{
|
||||
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage],
|
||||
string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty);
|
||||
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -209,8 +201,7 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||
{
|
||||
if (FileAssociationHelper.Uninstall())
|
||||
{
|
||||
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUninstallFileTypesSuccessMessage],
|
||||
string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty);
|
||||
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogUninstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -23,6 +23,19 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
Orientation="Vertical"
|
||||
Spacing="10">
|
||||
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabNetworkMultiplayer}" />
|
||||
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{locale:Locale MultiplayerMode}"
|
||||
ToolTip.Tip="{locale:Locale MultiplayerModeTooltip}"
|
||||
Width="200" />
|
||||
<ComboBox SelectedIndex="{Binding MultiplayerModeIndex}"
|
||||
ToolTip.Tip="{locale:Locale MultiplayerModeTooltip}"
|
||||
HorizontalContentAlignment="Left"
|
||||
ItemsSource="{Binding MultiplayerModes}"
|
||||
Width="250" />
|
||||
</StackPanel>
|
||||
<Separator Height="1" />
|
||||
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabNetworkConnection}" />
|
||||
<CheckBox Margin="10,0,0,0" IsChecked="{Binding EnableInternetAccess}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabSystemEnableInternetAccess}"
|
||||
|
@ -34,7 +34,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||
{
|
||||
var result = await window.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false
|
||||
AllowMultiple = false,
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
@ -75,9 +75,9 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||
{
|
||||
Patterns = new[] { "*.xaml" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xaml" },
|
||||
MimeTypes = new[] { "application/xaml+xml" }
|
||||
}
|
||||
}
|
||||
MimeTypes = new[] { "application/xaml+xml" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
|
@ -75,9 +75,9 @@ namespace Ryujinx.Ava.UI.Views.User
|
||||
{
|
||||
Patterns = new[] { "*.jpg", "*.jpeg", "*.png", "*.bmp" },
|
||||
AppleUniformTypeIdentifiers = new[] { "public.jpeg", "public.png", "com.microsoft.bmp" },
|
||||
MimeTypes = new[] { "image/jpeg", "image/png", "image/bmp" }
|
||||
}
|
||||
}
|
||||
MimeTypes = new[] { "image/jpeg", "image/png", "image/bmp" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
|
@ -15,6 +15,7 @@ using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.Input.HLE;
|
||||
using Ryujinx.Input.SDL2;
|
||||
using Ryujinx.Modules;
|
||||
using Ryujinx.Ui.App.Common;
|
||||
@ -24,8 +25,8 @@ using Ryujinx.Ui.Common.Helper;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using InputManager = Ryujinx.Input.HLE.InputManager;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Windows
|
||||
{
|
||||
@ -79,35 +80,11 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
Initialize();
|
||||
|
||||
InputManager = new InputManager(new AvaloniaKeyboardDriver(this), new SDL2GamepadDriver());
|
||||
|
||||
ViewModel.Initialize(
|
||||
ContentManager,
|
||||
StorageProvider,
|
||||
ApplicationLibrary,
|
||||
VirtualFileSystem,
|
||||
AccountManager,
|
||||
InputManager,
|
||||
_userChannelPersistence,
|
||||
LibHacHorizonManager,
|
||||
UiHandler,
|
||||
ShowLoading,
|
||||
SwitchToGameControl,
|
||||
SetMainContent,
|
||||
this);
|
||||
|
||||
ViewModel.RefreshFirmwareStatus();
|
||||
|
||||
LoadGameList();
|
||||
|
||||
this.GetObservable(IsActiveProperty).Subscribe(IsActiveChanged);
|
||||
this.ScalingChanged += OnScalingChanged;
|
||||
}
|
||||
|
||||
ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated;
|
||||
ApplicationLibrary.ApplicationAdded += ApplicationLibrary_ApplicationAdded;
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
@ -122,36 +99,17 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
ViewModel.IsActive = obj;
|
||||
}
|
||||
|
||||
public void LoadGameList()
|
||||
{
|
||||
if (_isLoading)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isLoading = true;
|
||||
|
||||
LoadApplications();
|
||||
|
||||
_isLoading = false;
|
||||
}
|
||||
|
||||
private void OnScalingChanged(object sender, EventArgs e)
|
||||
{
|
||||
Program.DesktopScaleFactor = this.RenderScaling;
|
||||
}
|
||||
|
||||
public void AddApplication(ApplicationData applicationData)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
ViewModel.Applications.Add(applicationData);
|
||||
});
|
||||
}
|
||||
|
||||
private void ApplicationLibrary_ApplicationAdded(object sender, ApplicationAddedEventArgs e)
|
||||
{
|
||||
AddApplication(e.AppData);
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
ViewModel.Applications.Add(e.AppData);
|
||||
});
|
||||
}
|
||||
|
||||
private void ApplicationLibrary_ApplicationCountUpdated(object sender, ApplicationCountUpdatedEventArgs e)
|
||||
@ -183,7 +141,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
string path = new FileInfo(args.Application.Path).FullName;
|
||||
|
||||
ViewModel.LoadApplication(path);
|
||||
ViewModel.LoadApplication(path).Wait();
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
@ -202,13 +160,10 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
ViewModel.ShowContent = true;
|
||||
ViewModel.IsLoadingIndeterminate = false;
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (startFullscreen && ViewModel.WindowState != WindowState.FullScreen)
|
||||
{
|
||||
ViewModel.ToggleFullscreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void ShowLoading(bool startFullscreen = false)
|
||||
@ -217,13 +172,10 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
ViewModel.ShowLoadProgress = true;
|
||||
ViewModel.IsLoadingIndeterminate = true;
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (startFullscreen && ViewModel.WindowState != WindowState.FullScreen)
|
||||
{
|
||||
ViewModel.ToggleFullscreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
@ -251,11 +203,11 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
VirtualFileSystem.ReloadKeySet();
|
||||
|
||||
ApplicationHelper.Initialize(VirtualFileSystem, AccountManager, LibHacHorizonManager.RyujinxClient, this);
|
||||
ApplicationHelper.Initialize(VirtualFileSystem, AccountManager, LibHacHorizonManager.RyujinxClient);
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("linux")]
|
||||
private static async void ShowVmMaxMapCountWarning()
|
||||
private static async Task ShowVmMaxMapCountWarning()
|
||||
{
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LinuxVmMaxMapCountWarningTextSecondary,
|
||||
LinuxHelper.VmMaxMapCount, LinuxHelper.RecommendedVmMaxMapCount);
|
||||
@ -267,7 +219,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("linux")]
|
||||
private static async void ShowVmMaxMapCountDialog()
|
||||
private static async Task ShowVmMaxMapCountDialog()
|
||||
{
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.LinuxVmMaxMapCountDialogTextPrimary,
|
||||
LinuxHelper.RecommendedVmMaxMapCount);
|
||||
@ -313,33 +265,46 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
private void CheckLaunchState()
|
||||
{
|
||||
if (ShowKeyErrorOnLoad)
|
||||
{
|
||||
ShowKeyErrorOnLoad = false;
|
||||
|
||||
Dispatcher.UIThread.Post(async () => await
|
||||
UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
|
||||
}
|
||||
|
||||
if (OperatingSystem.IsLinux() && LinuxHelper.VmMaxMapCount < LinuxHelper.RecommendedVmMaxMapCount)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The value of vm.max_map_count is lower than {LinuxHelper.RecommendedVmMaxMapCount}. ({LinuxHelper.VmMaxMapCount})");
|
||||
|
||||
if (LinuxHelper.PkExecPath is not null)
|
||||
{
|
||||
Dispatcher.UIThread.Post(ShowVmMaxMapCountDialog);
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
await ShowVmMaxMapCountDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.UIThread.Post(ShowVmMaxMapCountWarning);
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
await ShowVmMaxMapCountWarning();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!ShowKeyErrorOnLoad)
|
||||
{
|
||||
if (_deferLoad)
|
||||
{
|
||||
_deferLoad = false;
|
||||
|
||||
ViewModel.LoadApplication(_launchPath, _startFullscreen);
|
||||
ViewModel.LoadApplication(_launchPath, _startFullscreen).Wait();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowKeyErrorOnLoad = false;
|
||||
|
||||
Dispatcher.UIThread.Post(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
|
||||
}
|
||||
|
||||
if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
|
||||
@ -372,7 +337,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
ViewModel.WindowHeight = ConfigurationState.Instance.Ui.WindowStartup.WindowSizeHeight * Program.WindowScaleFactor;
|
||||
ViewModel.WindowWidth = ConfigurationState.Instance.Ui.WindowStartup.WindowSizeWidth * Program.WindowScaleFactor;
|
||||
|
||||
ViewModel.WindowState = ConfigurationState.Instance.Ui.WindowStartup.WindowMaximized.Value is true ? WindowState.Maximized : WindowState.Normal;
|
||||
ViewModel.WindowState = ConfigurationState.Instance.Ui.WindowStartup.WindowMaximized.Value ? WindowState.Maximized : WindowState.Normal;
|
||||
|
||||
if (CheckScreenBounds(savedPoint))
|
||||
{
|
||||
@ -415,6 +380,30 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
{
|
||||
base.OnOpened(e);
|
||||
|
||||
Initialize();
|
||||
|
||||
ViewModel.Initialize(
|
||||
ContentManager,
|
||||
StorageProvider,
|
||||
ApplicationLibrary,
|
||||
VirtualFileSystem,
|
||||
AccountManager,
|
||||
InputManager,
|
||||
_userChannelPersistence,
|
||||
LibHacHorizonManager,
|
||||
UiHandler,
|
||||
ShowLoading,
|
||||
SwitchToGameControl,
|
||||
SetMainContent,
|
||||
this);
|
||||
|
||||
ApplicationLibrary.ApplicationCountUpdated += ApplicationLibrary_ApplicationCountUpdated;
|
||||
ApplicationLibrary.ApplicationAdded += ApplicationLibrary_ApplicationAdded;
|
||||
|
||||
ViewModel.RefreshFirmwareStatus();
|
||||
|
||||
LoadApplications();
|
||||
|
||||
CheckLaunchState();
|
||||
}
|
||||
|
||||
@ -514,9 +503,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
});
|
||||
}
|
||||
|
||||
public async void LoadApplications()
|
||||
{
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
public void LoadApplications()
|
||||
{
|
||||
ViewModel.Applications.Clear();
|
||||
|
||||
@ -525,7 +512,6 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
ViewModel.StatusBarProgressValue = 0;
|
||||
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.StatusBarGamesLoaded, 0, 0);
|
||||
});
|
||||
|
||||
ReloadGameList();
|
||||
}
|
||||
@ -558,9 +544,17 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
_isLoading = true;
|
||||
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs.Value, ConfigurationState.Instance.System.Language);
|
||||
Thread applicationLibraryThread = new(() =>
|
||||
{
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.Ui.GameDirs, ConfigurationState.Instance.System.Language);
|
||||
|
||||
_isLoading = false;
|
||||
})
|
||||
{
|
||||
Name = "GUI.ApplicationLibraryThread",
|
||||
IsBackground = true,
|
||||
};
|
||||
applicationLibraryThread.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
@ -25,11 +24,6 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
IconImage = new Bitmap(stream);
|
||||
}
|
||||
|
||||
protected override void OnOpened(EventArgs e)
|
||||
{
|
||||
base.OnOpened(e);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||
{
|
||||
base.OnApplyTemplate(e);
|
||||
|
@ -192,7 +192,7 @@ namespace Ryujinx.Common.Collections
|
||||
{
|
||||
if (start.CompareTo(overlap.End) < 0)
|
||||
{
|
||||
if (overlaps.Length >= overlapCount)
|
||||
if (overlaps.Length <= overlapCount)
|
||||
{
|
||||
Array.Resize(ref overlaps, overlapCount + ArrayGrowthSize);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
namespace Ryujinx.Common.Configuration.Multiplayer
|
||||
{
|
||||
public enum MultiplayerMode
|
||||
{
|
||||
Disabled,
|
||||
}
|
||||
}
|
@ -791,5 +791,34 @@ namespace Ryujinx.Common.Memory
|
||||
[Pure]
|
||||
public Span<T> AsSpan() => MemoryMarshal.CreateSpan(ref _e0, Length);
|
||||
}
|
||||
|
||||
public struct Array140<T> : IArray<T> where T : unmanaged
|
||||
{
|
||||
T _e0;
|
||||
Array64<T> _other;
|
||||
Array64<T> _other2;
|
||||
Array11<T> _other3;
|
||||
public readonly int Length => 140;
|
||||
public ref T this[int index] => ref AsSpan()[index];
|
||||
|
||||
[Pure]
|
||||
public Span<T> AsSpan() => MemoryMarshal.CreateSpan(ref _e0, Length);
|
||||
}
|
||||
|
||||
public struct Array384<T> : IArray<T> where T : unmanaged
|
||||
{
|
||||
T _e0;
|
||||
Array64<T> _other;
|
||||
Array64<T> _other2;
|
||||
Array64<T> _other3;
|
||||
Array64<T> _other4;
|
||||
Array64<T> _other5;
|
||||
Array63<T> _other6;
|
||||
public readonly int Length => 384;
|
||||
public ref T this[int index] => ref AsSpan()[index];
|
||||
|
||||
[Pure]
|
||||
public Span<T> AsSpan() => MemoryMarshal.CreateSpan(ref _e0, Length);
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0169, IDE0051
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Buffers.Binary;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
@ -62,5 +64,15 @@ namespace Ryujinx.Common.Utilities
|
||||
|
||||
return (targetProperties, targetAddressInfo);
|
||||
}
|
||||
|
||||
public static uint ConvertIpv4Address(IPAddress ipAddress)
|
||||
{
|
||||
return BinaryPrimitives.ReadUInt32BigEndian(ipAddress.GetAddressBytes());
|
||||
}
|
||||
|
||||
public static uint ConvertIpv4Address(string ipAddress)
|
||||
{
|
||||
return ConvertIpv4Address(IPAddress.Parse(ipAddress));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
using Ryujinx.Cpu.AppleHv.Arm;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvAddressSpace : IDisposable
|
||||
{
|
||||
private const ulong KernelRegionBase = unchecked((ulong)-(1L << 39));
|
||||
|
@ -2,10 +2,12 @@ using Ryujinx.Cpu.AppleHv.Arm;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvAddressSpaceRange : IDisposable
|
||||
{
|
||||
private const ulong AllocationGranule = 1UL << 14;
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
@ -12,10 +13,18 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
#pragma warning restore CS0649
|
||||
}
|
||||
|
||||
enum HvExitReason : uint
|
||||
{
|
||||
Canceled,
|
||||
Exception,
|
||||
VTimerActivated,
|
||||
Unknown,
|
||||
}
|
||||
|
||||
struct HvVcpuExit
|
||||
{
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public uint Reason;
|
||||
public HvExitReason Reason;
|
||||
public HvVcpuExitException Exception;
|
||||
#pragma warning restore CS0649
|
||||
}
|
||||
@ -255,6 +264,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
}
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("macos")]
|
||||
static partial class HvApi
|
||||
{
|
||||
public const string LibraryName = "/System/Library/Frameworks/Hypervisor.framework/Hypervisor";
|
||||
|
@ -1,7 +1,9 @@
|
||||
using ARMeilleure.Memory;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvCpuContext : ICpuContext
|
||||
{
|
||||
private readonly ITickSource _tickSource;
|
||||
|
@ -1,7 +1,9 @@
|
||||
using ARMeilleure.Memory;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
public class HvEngine : ICpuEngine
|
||||
{
|
||||
private readonly ITickSource _tickSource;
|
||||
|
@ -2,9 +2,12 @@ using ARMeilleure.State;
|
||||
using Ryujinx.Cpu.AppleHv.Arm;
|
||||
using Ryujinx.Memory.Tracking;
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvExecutionContext : IExecutionContext
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
@ -67,6 +70,8 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
|
||||
private readonly ExceptionCallbacks _exceptionCallbacks;
|
||||
|
||||
private int _interruptRequested;
|
||||
|
||||
public HvExecutionContext(ICounter counter, ExceptionCallbacks exceptionCallbacks)
|
||||
{
|
||||
_counter = counter;
|
||||
@ -111,7 +116,15 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
/// <inheritdoc/>
|
||||
public void RequestInterrupt()
|
||||
{
|
||||
_impl.RequestInterrupt();
|
||||
if (Interlocked.Exchange(ref _interruptRequested, 1) == 0 && _impl is HvExecutionContextVcpu impl)
|
||||
{
|
||||
impl.RequestInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private bool GetAndClearInterruptRequested()
|
||||
{
|
||||
return Interlocked.Exchange(ref _interruptRequested, 0) != 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@ -131,9 +144,9 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
HvApi.hv_vcpu_run(vcpu.Handle).ThrowOnError();
|
||||
|
||||
uint reason = vcpu.ExitInfo->Reason;
|
||||
HvExitReason reason = vcpu.ExitInfo->Reason;
|
||||
|
||||
if (reason == 1)
|
||||
if (reason == HvExitReason.Exception)
|
||||
{
|
||||
uint hvEsr = (uint)vcpu.ExitInfo->Exception.Syndrome;
|
||||
ExceptionClass hvEc = (ExceptionClass)(hvEsr >> 26);
|
||||
@ -146,14 +159,22 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
address = SynchronousException(memoryManager, ref vcpu);
|
||||
HvApi.hv_vcpu_set_reg(vcpu.Handle, HvReg.PC, address).ThrowOnError();
|
||||
}
|
||||
else if (reason == 0)
|
||||
else if (reason == HvExitReason.Canceled || reason == HvExitReason.VTimerActivated)
|
||||
{
|
||||
if (_impl.GetAndClearInterruptRequested())
|
||||
if (GetAndClearInterruptRequested())
|
||||
{
|
||||
ReturnToPool(vcpu);
|
||||
InterruptHandler();
|
||||
vcpu = RentFromPool(memoryManager.AddressSpace, vcpu);
|
||||
}
|
||||
|
||||
if (reason == HvExitReason.VTimerActivated)
|
||||
{
|
||||
vcpu.EnableAndUpdateVTimer();
|
||||
|
||||
// Unmask VTimer interrupts.
|
||||
HvApi.hv_vcpu_set_vtimer_mask(vcpu.Handle, false).ThrowOnError();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -46,14 +46,5 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
_v[index] = value;
|
||||
}
|
||||
|
||||
public void RequestInterrupt()
|
||||
{
|
||||
}
|
||||
|
||||
public bool GetAndClearInterruptRequested()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,11 @@ using ARMeilleure.State;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvExecutionContextVcpu : IHvExecutionContext
|
||||
{
|
||||
private static readonly MemoryBlock _setSimdFpRegFuncMem;
|
||||
@ -135,7 +136,6 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
}
|
||||
|
||||
private readonly ulong _vcpu;
|
||||
private int _interruptRequested;
|
||||
|
||||
public HvExecutionContextVcpu(ulong vcpu)
|
||||
{
|
||||
@ -180,17 +180,9 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
}
|
||||
|
||||
public void RequestInterrupt()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _interruptRequested, 1) == 0)
|
||||
{
|
||||
ulong vcpu = _vcpu;
|
||||
HvApi.hv_vcpus_exit(ref vcpu, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetAndClearInterruptRequested()
|
||||
{
|
||||
return Interlocked.Exchange(ref _interruptRequested, 0) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
readonly struct HvMemoryBlockAllocation : IDisposable
|
||||
{
|
||||
private readonly HvMemoryBlockAllocator _owner;
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Ryujinx.Memory;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvMemoryBlockAllocator : PrivateMemoryAllocatorImpl<HvMemoryBlockAllocator.Block>
|
||||
{
|
||||
public class Block : PrivateMemoryAllocator.Block
|
||||
|
@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
@ -14,6 +15,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
/// <summary>
|
||||
/// Represents a CPU memory manager which maps guest virtual memory directly onto the Hypervisor page table.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("macos")]
|
||||
public class HvMemoryManager : MemoryManagerBase, IMemoryManager, IVirtualMemoryManagerTracked, IWritableBlock
|
||||
{
|
||||
public const int PageBits = 12;
|
||||
|
@ -1,7 +1,15 @@
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
unsafe class HvVcpu
|
||||
{
|
||||
private const ulong InterruptIntervalNs = 16 * 1000000; // 16 ms
|
||||
|
||||
private static ulong _interruptTimeDeltaTicks = 0;
|
||||
|
||||
public readonly ulong Handle;
|
||||
public readonly HvVcpuExit* ExitInfo;
|
||||
public readonly IHvExecutionContext ShadowContext;
|
||||
@ -21,5 +29,28 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
NativeContext = nativeContext;
|
||||
IsEphemeral = isEphemeral;
|
||||
}
|
||||
|
||||
public void EnableAndUpdateVTimer()
|
||||
{
|
||||
// We need to ensure interrupts will be serviced,
|
||||
// and for that we set up the VTime to trigger an interrupt at fixed intervals.
|
||||
|
||||
ulong deltaTicks = _interruptTimeDeltaTicks;
|
||||
|
||||
if (deltaTicks == 0)
|
||||
{
|
||||
// Calculate our time delta in ticks based on the current clock frequency.
|
||||
|
||||
int result = TimeApi.mach_timebase_info(out var timeBaseInfo);
|
||||
|
||||
Debug.Assert(result == 0);
|
||||
|
||||
deltaTicks = ((InterruptIntervalNs * timeBaseInfo.Denom) + (timeBaseInfo.Numer - 1)) / timeBaseInfo.Numer;
|
||||
_interruptTimeDeltaTicks = deltaTicks;
|
||||
}
|
||||
|
||||
HvApi.hv_vcpu_set_sys_reg(Handle, HvSysReg.CNTV_CTL_EL0, 1).ThrowOnError();
|
||||
HvApi.hv_vcpu_set_sys_reg(Handle, HvSysReg.CNTV_CVAL_EL0, TimeApi.mach_absolute_time() + deltaTicks).ThrowOnError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
class HvVcpuPool
|
||||
{
|
||||
// Since there's a limit on the number of VCPUs we can create,
|
||||
@ -81,6 +83,8 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
|
||||
HvVcpu vcpu = new(vcpuHandle, exitInfo, shadowContext, nativeContext, isEphemeral);
|
||||
|
||||
vcpu.EnableAndUpdateVTimer();
|
||||
|
||||
return vcpu;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
[SupportedOSPlatform("macos")]
|
||||
static class HvVm
|
||||
{
|
||||
// This alignment allows us to use larger blocks on the page table.
|
||||
|
@ -2,7 +2,7 @@ using ARMeilleure.State;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
public interface IHvExecutionContext
|
||||
interface IHvExecutionContext
|
||||
{
|
||||
ulong Pc { get; set; }
|
||||
ulong ElrEl1 { get; set; }
|
||||
@ -39,8 +39,5 @@ namespace Ryujinx.Cpu.AppleHv
|
||||
SetV(i, context.GetV(i));
|
||||
}
|
||||
}
|
||||
|
||||
void RequestInterrupt();
|
||||
bool GetAndClearInterruptRequested();
|
||||
}
|
||||
}
|
||||
|
21
src/Ryujinx.Cpu/AppleHv/TimeApi.cs
Normal file
21
src/Ryujinx.Cpu/AppleHv/TimeApi.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Cpu.AppleHv
|
||||
{
|
||||
struct MachTimebaseInfo
|
||||
{
|
||||
public uint Numer;
|
||||
public uint Denom;
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("macos")]
|
||||
static partial class TimeApi
|
||||
{
|
||||
[LibraryImport("libc", SetLastError = true)]
|
||||
public static partial ulong mach_absolute_time();
|
||||
|
||||
[LibraryImport("libc", SetLastError = true)]
|
||||
public static partial int mach_timebase_info(out MachTimebaseInfo info);
|
||||
}
|
||||
}
|
@ -696,12 +696,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
}
|
||||
|
||||
// Find view compatible matches.
|
||||
int overlapsCount;
|
||||
int overlapsCount = 0;
|
||||
|
||||
if (info.Target != Target.TextureBuffer)
|
||||
{
|
||||
lock (_textures)
|
||||
{
|
||||
overlapsCount = _textures.FindOverlaps(range.Value, ref _textureOverlaps);
|
||||
}
|
||||
}
|
||||
|
||||
if (_overlapInfo.Length != _textureOverlaps.Length)
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
private int[] _allOffsets;
|
||||
private int[] _sliceSizes;
|
||||
private readonly bool _is3D;
|
||||
private readonly bool _isBuffer;
|
||||
private bool _hasMipViews;
|
||||
private bool _hasLayerViews;
|
||||
private readonly int _layers;
|
||||
@ -118,6 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
_physicalMemory = physicalMemory;
|
||||
|
||||
_is3D = storage.Info.Target == Target.Texture3D;
|
||||
_isBuffer = storage.Info.Target == Target.TextureBuffer;
|
||||
_layers = storage.Info.GetSlices();
|
||||
_levels = storage.Info.Levels;
|
||||
|
||||
@ -794,7 +796,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
int targetLayerHandles = _hasLayerViews ? slices : 1;
|
||||
int targetLevelHandles = _hasMipViews ? levels : 1;
|
||||
|
||||
if (_is3D)
|
||||
if (_isBuffer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (_is3D)
|
||||
{
|
||||
// Future mip levels come after all layers of the last mip level. Each mipmap has less layers (depth) than the last.
|
||||
|
||||
@ -1327,7 +1333,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
TextureGroupHandle[] handles;
|
||||
|
||||
if (!(_hasMipViews || _hasLayerViews))
|
||||
if (_isBuffer)
|
||||
{
|
||||
handles = Array.Empty<TextureGroupHandle>();
|
||||
}
|
||||
else if (!(_hasMipViews || _hasLayerViews))
|
||||
{
|
||||
// Single dirty region.
|
||||
var cpuRegionHandles = new RegionHandle[TextureRange.Count];
|
||||
|
@ -27,6 +27,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
public bool InUse;
|
||||
public bool InConsumption;
|
||||
public int SubmissionCount;
|
||||
public CommandBuffer CommandBuffer;
|
||||
public FenceHolder Fence;
|
||||
public SemaphoreHolder Semaphore;
|
||||
@ -193,6 +194,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return _commandBuffers[cbIndex].Fence;
|
||||
}
|
||||
|
||||
public int GetSubmissionCount(int cbIndex)
|
||||
{
|
||||
return _commandBuffers[cbIndex].SubmissionCount;
|
||||
}
|
||||
|
||||
private int FreeConsumed(bool wait)
|
||||
{
|
||||
int freeEntry = 0;
|
||||
@ -282,6 +288,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Debug.Assert(entry.CommandBuffer.Handle == cbs.CommandBuffer.Handle);
|
||||
entry.InUse = false;
|
||||
entry.InConsumption = true;
|
||||
entry.SubmissionCount++;
|
||||
_inUseCount--;
|
||||
|
||||
var commandBuffer = entry.CommandBuffer;
|
||||
|
@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
class DescriptorSetManager : IDisposable
|
||||
{
|
||||
private const uint DescriptorPoolMultiplier = 16;
|
||||
public const uint MaxSets = 16;
|
||||
|
||||
public class DescriptorPoolHolder : IDisposable
|
||||
{
|
||||
@ -14,36 +14,28 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public Device Device { get; }
|
||||
|
||||
private readonly DescriptorPool _pool;
|
||||
private readonly uint _capacity;
|
||||
private int _freeDescriptors;
|
||||
private int _totalSets;
|
||||
private int _setsInUse;
|
||||
private bool _done;
|
||||
|
||||
public unsafe DescriptorPoolHolder(Vk api, Device device)
|
||||
public unsafe DescriptorPoolHolder(Vk api, Device device, ReadOnlySpan<DescriptorPoolSize> poolSizes, bool updateAfterBind)
|
||||
{
|
||||
Api = api;
|
||||
Device = device;
|
||||
|
||||
var poolSizes = new[]
|
||||
foreach (var poolSize in poolSizes)
|
||||
{
|
||||
new DescriptorPoolSize(DescriptorType.UniformBuffer, (1 + Constants.MaxUniformBufferBindings) * DescriptorPoolMultiplier),
|
||||
new DescriptorPoolSize(DescriptorType.StorageBuffer, Constants.MaxStorageBufferBindings * DescriptorPoolMultiplier),
|
||||
new DescriptorPoolSize(DescriptorType.CombinedImageSampler, Constants.MaxTextureBindings * DescriptorPoolMultiplier),
|
||||
new DescriptorPoolSize(DescriptorType.StorageImage, Constants.MaxImageBindings * DescriptorPoolMultiplier),
|
||||
new DescriptorPoolSize(DescriptorType.UniformTexelBuffer, Constants.MaxTextureBindings * DescriptorPoolMultiplier),
|
||||
new DescriptorPoolSize(DescriptorType.StorageTexelBuffer, Constants.MaxImageBindings * DescriptorPoolMultiplier),
|
||||
};
|
||||
|
||||
uint maxSets = (uint)poolSizes.Length * DescriptorPoolMultiplier;
|
||||
|
||||
_capacity = maxSets;
|
||||
_freeDescriptors += (int)poolSize.DescriptorCount;
|
||||
}
|
||||
|
||||
fixed (DescriptorPoolSize* pPoolsSize = poolSizes)
|
||||
{
|
||||
var descriptorPoolCreateInfo = new DescriptorPoolCreateInfo
|
||||
{
|
||||
SType = StructureType.DescriptorPoolCreateInfo,
|
||||
MaxSets = maxSets,
|
||||
Flags = updateAfterBind ? DescriptorPoolCreateFlags.UpdateAfterBindBit : DescriptorPoolCreateFlags.None,
|
||||
MaxSets = MaxSets,
|
||||
PoolSizeCount = (uint)poolSizes.Length,
|
||||
PPoolSizes = pPoolsSize,
|
||||
};
|
||||
@ -52,18 +44,22 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
public DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts)
|
||||
public unsafe DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts, int consumedDescriptors)
|
||||
{
|
||||
TryAllocateDescriptorSets(layouts, isTry: false, out var dsc);
|
||||
TryAllocateDescriptorSets(layouts, consumedDescriptors, isTry: false, out var dsc);
|
||||
return dsc;
|
||||
}
|
||||
|
||||
public bool TryAllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts, out DescriptorSetCollection dsc)
|
||||
public bool TryAllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts, int consumedDescriptors, out DescriptorSetCollection dsc)
|
||||
{
|
||||
return TryAllocateDescriptorSets(layouts, isTry: true, out dsc);
|
||||
return TryAllocateDescriptorSets(layouts, consumedDescriptors, isTry: true, out dsc);
|
||||
}
|
||||
|
||||
private unsafe bool TryAllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts, bool isTry, out DescriptorSetCollection dsc)
|
||||
private unsafe bool TryAllocateDescriptorSets(
|
||||
ReadOnlySpan<DescriptorSetLayout> layouts,
|
||||
int consumedDescriptors,
|
||||
bool isTry,
|
||||
out DescriptorSetCollection dsc)
|
||||
{
|
||||
Debug.Assert(!_done);
|
||||
|
||||
@ -84,7 +80,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var result = Api.AllocateDescriptorSets(Device, &descriptorSetAllocateInfo, pDescriptorSets);
|
||||
if (isTry && result == Result.ErrorOutOfPoolMemory)
|
||||
{
|
||||
_totalSets = (int)_capacity;
|
||||
_totalSets = (int)MaxSets;
|
||||
_done = true;
|
||||
DestroyIfDone();
|
||||
dsc = default;
|
||||
@ -95,6 +91,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
_freeDescriptors -= consumedDescriptors;
|
||||
_totalSets += layouts.Length;
|
||||
_setsInUse += layouts.Length;
|
||||
|
||||
@ -109,9 +106,15 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
DestroyIfDone();
|
||||
}
|
||||
|
||||
public bool CanFit(int count)
|
||||
public bool CanFit(int setsCount, int descriptorsCount)
|
||||
{
|
||||
if (_totalSets + count <= _capacity)
|
||||
// Try to determine if an allocation with the given parameters will succeed.
|
||||
// An allocation may fail if the sets count or descriptors count exceeds the available counts
|
||||
// of the pool.
|
||||
// Not getting that right is not fatal, it will just create a new pool and try again,
|
||||
// but it is less efficient.
|
||||
|
||||
if (_totalSets + setsCount <= MaxSets && _freeDescriptors >= descriptorsCount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -148,46 +151,74 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
private readonly Device _device;
|
||||
private DescriptorPoolHolder _currentPool;
|
||||
private readonly DescriptorPoolHolder[] _currentPools;
|
||||
|
||||
public DescriptorSetManager(Device device)
|
||||
public DescriptorSetManager(Device device, int poolCount)
|
||||
{
|
||||
_device = device;
|
||||
_currentPools = new DescriptorPoolHolder[poolCount];
|
||||
}
|
||||
|
||||
public Auto<DescriptorSetCollection> AllocateDescriptorSet(Vk api, DescriptorSetLayout layout)
|
||||
public Auto<DescriptorSetCollection> AllocateDescriptorSet(
|
||||
Vk api,
|
||||
DescriptorSetLayout layout,
|
||||
ReadOnlySpan<DescriptorPoolSize> poolSizes,
|
||||
int poolIndex,
|
||||
int consumedDescriptors,
|
||||
bool updateAfterBind)
|
||||
{
|
||||
Span<DescriptorSetLayout> layouts = stackalloc DescriptorSetLayout[1];
|
||||
layouts[0] = layout;
|
||||
return AllocateDescriptorSets(api, layouts);
|
||||
return AllocateDescriptorSets(api, layouts, poolSizes, poolIndex, consumedDescriptors, updateAfterBind);
|
||||
}
|
||||
|
||||
public Auto<DescriptorSetCollection> AllocateDescriptorSets(Vk api, ReadOnlySpan<DescriptorSetLayout> layouts)
|
||||
public Auto<DescriptorSetCollection> AllocateDescriptorSets(
|
||||
Vk api,
|
||||
ReadOnlySpan<DescriptorSetLayout> layouts,
|
||||
ReadOnlySpan<DescriptorPoolSize> poolSizes,
|
||||
int poolIndex,
|
||||
int consumedDescriptors,
|
||||
bool updateAfterBind)
|
||||
{
|
||||
// If we fail the first time, just create a new pool and try again.
|
||||
if (!GetPool(api, layouts.Length).TryAllocateDescriptorSets(layouts, out var dsc))
|
||||
|
||||
var pool = GetPool(api, poolSizes, poolIndex, layouts.Length, consumedDescriptors, updateAfterBind);
|
||||
if (!pool.TryAllocateDescriptorSets(layouts, consumedDescriptors, out var dsc))
|
||||
{
|
||||
dsc = GetPool(api, layouts.Length).AllocateDescriptorSets(layouts);
|
||||
pool = GetPool(api, poolSizes, poolIndex, layouts.Length, consumedDescriptors, updateAfterBind);
|
||||
dsc = pool.AllocateDescriptorSets(layouts, consumedDescriptors);
|
||||
}
|
||||
|
||||
return new Auto<DescriptorSetCollection>(dsc);
|
||||
}
|
||||
|
||||
private DescriptorPoolHolder GetPool(Vk api, int requiredCount)
|
||||
private DescriptorPoolHolder GetPool(
|
||||
Vk api,
|
||||
ReadOnlySpan<DescriptorPoolSize> poolSizes,
|
||||
int poolIndex,
|
||||
int setsCount,
|
||||
int descriptorsCount,
|
||||
bool updateAfterBind)
|
||||
{
|
||||
if (_currentPool == null || !_currentPool.CanFit(requiredCount))
|
||||
ref DescriptorPoolHolder currentPool = ref _currentPools[poolIndex];
|
||||
|
||||
if (currentPool == null || !currentPool.CanFit(setsCount, descriptorsCount))
|
||||
{
|
||||
_currentPool = new DescriptorPoolHolder(api, _device);
|
||||
currentPool = new DescriptorPoolHolder(api, _device, poolSizes, updateAfterBind);
|
||||
}
|
||||
|
||||
return _currentPool;
|
||||
return currentPool;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_currentPool?.Dispose();
|
||||
for (int index = 0; index < _currentPools.Length; index++)
|
||||
{
|
||||
_currentPools[index]?.Dispose();
|
||||
_currentPools[index] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
private BitMapStruct<Array2<long>> _uniformMirrored;
|
||||
private BitMapStruct<Array2<long>> _storageMirrored;
|
||||
|
||||
private bool _updateDescriptorCacheCbIndex;
|
||||
|
||||
[Flags]
|
||||
private enum DirtyFlags
|
||||
{
|
||||
@ -218,6 +220,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public void SetProgram(ShaderCollection program)
|
||||
{
|
||||
_program = program;
|
||||
_updateDescriptorCacheCbIndex = true;
|
||||
_dirty = DirtyFlags.All;
|
||||
}
|
||||
|
||||
@ -490,7 +493,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
var dummyBuffer = _dummyBuffer?.GetBuffer();
|
||||
|
||||
var dsc = program.GetNewDescriptorSetCollection(_gd, cbs.CommandBufferIndex, setIndex, out var isNew).Get(cbs);
|
||||
if (_updateDescriptorCacheCbIndex)
|
||||
{
|
||||
_updateDescriptorCacheCbIndex = false;
|
||||
program.UpdateDescriptorCacheCommandBufferIndex(cbs.CommandBufferIndex);
|
||||
}
|
||||
|
||||
var dsc = program.GetNewDescriptorSetCollection(setIndex, out var isNew).Get(cbs);
|
||||
|
||||
if (!program.HasMinimalLayout)
|
||||
{
|
||||
@ -697,6 +706,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void SignalCommandBufferChange()
|
||||
{
|
||||
_updateDescriptorCacheCbIndex = true;
|
||||
_dirty = DirtyFlags.All;
|
||||
|
||||
_uniformSet.Clear();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
@ -13,6 +14,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
private readonly Device _device;
|
||||
private readonly List<MemoryAllocatorBlockList> _blockLists;
|
||||
private readonly int _blockAlignment;
|
||||
private readonly ReaderWriterLockSlim _lock;
|
||||
|
||||
public MemoryAllocator(Vk api, VulkanPhysicalDevice physicalDevice, Device device)
|
||||
{
|
||||
@ -21,6 +23,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_device = device;
|
||||
_blockLists = new List<MemoryAllocatorBlockList>();
|
||||
_blockAlignment = (int)Math.Min(int.MaxValue, MaxDeviceMemoryUsageEstimate / _physicalDevice.PhysicalDeviceProperties.Limits.MaxMemoryAllocationCount);
|
||||
_lock = new(LockRecursionPolicy.NoRecursion);
|
||||
}
|
||||
|
||||
public MemoryAllocation AllocateDeviceMemory(
|
||||
@ -39,23 +42,39 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
private MemoryAllocation Allocate(int memoryTypeIndex, ulong size, ulong alignment, bool map, bool isBuffer)
|
||||
{
|
||||
_lock.EnterReadLock();
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < _blockLists.Count; i++)
|
||||
{
|
||||
var bl = _blockLists[i];
|
||||
if (bl.MemoryTypeIndex == memoryTypeIndex && bl.ForBuffer == isBuffer)
|
||||
{
|
||||
lock (bl)
|
||||
{
|
||||
return bl.Allocate(size, alignment, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitReadLock();
|
||||
}
|
||||
|
||||
_lock.EnterWriteLock();
|
||||
|
||||
try
|
||||
{
|
||||
var newBl = new MemoryAllocatorBlockList(_api, _device, memoryTypeIndex, _blockAlignment, isBuffer);
|
||||
_blockLists.Add(newBl);
|
||||
|
||||
return newBl.Allocate(size, alignment, map);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
internal int FindSuitableMemoryTypeIndex(
|
||||
uint memoryTypeBits,
|
||||
|
@ -3,6 +3,7 @@ using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
@ -166,6 +167,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
private readonly int _blockAlignment;
|
||||
|
||||
private readonly ReaderWriterLockSlim _lock;
|
||||
|
||||
public MemoryAllocatorBlockList(Vk api, Device device, int memoryTypeIndex, int blockAlignment, bool forBuffer)
|
||||
{
|
||||
_blocks = new List<Block>();
|
||||
@ -174,6 +177,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
MemoryTypeIndex = memoryTypeIndex;
|
||||
ForBuffer = forBuffer;
|
||||
_blockAlignment = blockAlignment;
|
||||
_lock = new(LockRecursionPolicy.NoRecursion);
|
||||
}
|
||||
|
||||
public unsafe MemoryAllocation Allocate(ulong size, ulong alignment, bool map)
|
||||
@ -184,6 +188,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
throw new ArgumentOutOfRangeException(nameof(alignment), $"Invalid alignment 0x{alignment:X}.");
|
||||
}
|
||||
|
||||
_lock.EnterReadLock();
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < _blocks.Count; i++)
|
||||
{
|
||||
var block = _blocks[i];
|
||||
@ -197,6 +205,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitReadLock();
|
||||
}
|
||||
|
||||
ulong blockAlignedSize = BitUtils.AlignUp(size, (ulong)_blockAlignment);
|
||||
|
||||
@ -243,6 +256,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
block.Free(offset, size);
|
||||
|
||||
if (block.IsTotallyFree())
|
||||
{
|
||||
_lock.EnterWriteLock();
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < _blocks.Count; i++)
|
||||
{
|
||||
@ -252,12 +269,21 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
|
||||
block.Destroy(_api, _device);
|
||||
}
|
||||
}
|
||||
|
||||
private void InsertBlock(Block block)
|
||||
{
|
||||
_lock.EnterWriteLock();
|
||||
|
||||
try
|
||||
{
|
||||
int index = _blocks.BinarySearch(block);
|
||||
if (index < 0)
|
||||
@ -267,6 +293,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
_blocks.Insert(index, block);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
@ -7,15 +8,28 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
class PipelineLayoutCacheEntry
|
||||
{
|
||||
// Those were adjusted based on current descriptor usage and the descriptor counts usually used on pipeline layouts.
|
||||
// It might be a good idea to tweak them again if those change, or maybe find a way to calculate an optimal value dynamically.
|
||||
private const uint DefaultUniformBufferPoolCapacity = 19 * DescriptorSetManager.MaxSets;
|
||||
private const uint DefaultStorageBufferPoolCapacity = 16 * DescriptorSetManager.MaxSets;
|
||||
private const uint DefaultTexturePoolCapacity = 128 * DescriptorSetManager.MaxSets;
|
||||
private const uint DefaultImagePoolCapacity = 8 * DescriptorSetManager.MaxSets;
|
||||
|
||||
private const int MaxPoolSizesPerSet = 2;
|
||||
|
||||
private readonly VulkanRenderer _gd;
|
||||
private readonly Device _device;
|
||||
|
||||
public DescriptorSetLayout[] DescriptorSetLayouts { get; }
|
||||
public PipelineLayout PipelineLayout { get; }
|
||||
|
||||
private readonly int[] _consumedDescriptorsPerSet;
|
||||
|
||||
private readonly List<Auto<DescriptorSetCollection>>[][] _dsCache;
|
||||
private List<Auto<DescriptorSetCollection>>[] _currentDsCache;
|
||||
private readonly int[] _dsCacheCursor;
|
||||
private int _dsLastCbIndex;
|
||||
private int _dsLastSubmissionCount;
|
||||
|
||||
private PipelineLayoutCacheEntry(VulkanRenderer gd, Device device, int setsCount)
|
||||
{
|
||||
@ -44,29 +58,55 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
bool usePushDescriptors) : this(gd, device, setDescriptors.Count)
|
||||
{
|
||||
(DescriptorSetLayouts, PipelineLayout) = PipelineLayoutFactory.Create(gd, device, setDescriptors, usePushDescriptors);
|
||||
|
||||
_consumedDescriptorsPerSet = new int[setDescriptors.Count];
|
||||
|
||||
for (int setIndex = 0; setIndex < setDescriptors.Count; setIndex++)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
foreach (var descriptor in setDescriptors[setIndex].Descriptors)
|
||||
{
|
||||
count += descriptor.Count;
|
||||
}
|
||||
|
||||
public Auto<DescriptorSetCollection> GetNewDescriptorSetCollection(
|
||||
VulkanRenderer gd,
|
||||
int commandBufferIndex,
|
||||
int setIndex,
|
||||
out bool isNew)
|
||||
_consumedDescriptorsPerSet[setIndex] = count;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCommandBufferIndex(int commandBufferIndex)
|
||||
{
|
||||
if (_dsLastCbIndex != commandBufferIndex)
|
||||
int submissionCount = _gd.CommandBufferPool.GetSubmissionCount(commandBufferIndex);
|
||||
|
||||
if (_dsLastCbIndex != commandBufferIndex || _dsLastSubmissionCount != submissionCount)
|
||||
{
|
||||
_dsLastCbIndex = commandBufferIndex;
|
||||
_dsLastSubmissionCount = submissionCount;
|
||||
Array.Clear(_dsCacheCursor);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _dsCacheCursor.Length; i++)
|
||||
_currentDsCache = _dsCache[commandBufferIndex];
|
||||
}
|
||||
|
||||
public Auto<DescriptorSetCollection> GetNewDescriptorSetCollection(int setIndex, out bool isNew)
|
||||
{
|
||||
_dsCacheCursor[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var list = _dsCache[commandBufferIndex][setIndex];
|
||||
var list = _currentDsCache[setIndex];
|
||||
int index = _dsCacheCursor[setIndex]++;
|
||||
if (index == list.Count)
|
||||
{
|
||||
var dsc = gd.DescriptorSetManager.AllocateDescriptorSet(gd.Api, DescriptorSetLayouts[setIndex]);
|
||||
Span<DescriptorPoolSize> poolSizes = stackalloc DescriptorPoolSize[MaxPoolSizesPerSet];
|
||||
poolSizes = GetDescriptorPoolSizes(poolSizes, setIndex);
|
||||
|
||||
int consumedDescriptors = _consumedDescriptorsPerSet[setIndex];
|
||||
|
||||
var dsc = _gd.DescriptorSetManager.AllocateDescriptorSet(
|
||||
_gd.Api,
|
||||
DescriptorSetLayouts[setIndex],
|
||||
poolSizes,
|
||||
setIndex,
|
||||
consumedDescriptors,
|
||||
false);
|
||||
|
||||
list.Add(dsc);
|
||||
isNew = true;
|
||||
return dsc;
|
||||
@ -76,6 +116,33 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return list[index];
|
||||
}
|
||||
|
||||
private static Span<DescriptorPoolSize> GetDescriptorPoolSizes(Span<DescriptorPoolSize> output, int setIndex)
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
switch (setIndex)
|
||||
{
|
||||
case PipelineBase.UniformSetIndex:
|
||||
output[0] = new(DescriptorType.UniformBuffer, DefaultUniformBufferPoolCapacity);
|
||||
break;
|
||||
case PipelineBase.StorageSetIndex:
|
||||
output[0] = new(DescriptorType.StorageBuffer, DefaultStorageBufferPoolCapacity);
|
||||
break;
|
||||
case PipelineBase.TextureSetIndex:
|
||||
output[0] = new(DescriptorType.CombinedImageSampler, DefaultTexturePoolCapacity);
|
||||
output[1] = new(DescriptorType.UniformTexelBuffer, DefaultTexturePoolCapacity);
|
||||
count = 2;
|
||||
break;
|
||||
case PipelineBase.ImageSetIndex:
|
||||
output[0] = new(DescriptorType.StorageImage, DefaultImagePoolCapacity);
|
||||
output[1] = new(DescriptorType.StorageTexelBuffer, DefaultImagePoolCapacity);
|
||||
count = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
return output[..count];
|
||||
}
|
||||
|
||||
protected virtual unsafe void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
|
@ -464,13 +464,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return true;
|
||||
}
|
||||
|
||||
public Auto<DescriptorSetCollection> GetNewDescriptorSetCollection(
|
||||
VulkanRenderer gd,
|
||||
int commandBufferIndex,
|
||||
int setIndex,
|
||||
out bool isNew)
|
||||
public void UpdateDescriptorCacheCommandBufferIndex(int commandBufferIndex)
|
||||
{
|
||||
return _plce.GetNewDescriptorSetCollection(gd, commandBufferIndex, setIndex, out isNew);
|
||||
_plce.UpdateCommandBufferIndex(commandBufferIndex);
|
||||
}
|
||||
|
||||
public Auto<DescriptorSetCollection> GetNewDescriptorSetCollection(int setIndex, out bool isNew)
|
||||
{
|
||||
return _plce.GetNewDescriptorSetCollection(setIndex, out isNew);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
@ -347,7 +347,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
CommandBufferPool = new CommandBufferPool(Api, _device, Queue, QueueLock, queueFamilyIndex);
|
||||
|
||||
DescriptorSetManager = new DescriptorSetManager(_device);
|
||||
DescriptorSetManager = new DescriptorSetManager(_device, PipelineBase.DescriptorSetLayouts);
|
||||
|
||||
PipelineLayoutCache = new PipelineLayoutCache();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Audio.Integration;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Multiplayer;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
@ -158,6 +159,11 @@ namespace Ryujinx.HLE
|
||||
/// </summary>
|
||||
public string MultiplayerLanInterfaceId { internal get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Multiplayer Mode
|
||||
/// </summary>
|
||||
public MultiplayerMode MultiplayerMode { internal get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An action called when HLE force a refresh of output after docked mode changed.
|
||||
/// </summary>
|
||||
@ -187,7 +193,8 @@ namespace Ryujinx.HLE
|
||||
AspectRatio aspectRatio,
|
||||
float audioVolume,
|
||||
bool useHypervisor,
|
||||
string multiplayerLanInterfaceId)
|
||||
string multiplayerLanInterfaceId,
|
||||
MultiplayerMode multiplayerMode)
|
||||
{
|
||||
VirtualFileSystem = virtualFileSystem;
|
||||
LibHacHorizonManager = libHacHorizonManager;
|
||||
@ -214,6 +221,7 @@ namespace Ryujinx.HLE
|
||||
AudioVolume = audioVolume;
|
||||
UseHypervisor = useHypervisor;
|
||||
MultiplayerLanInterfaceId = multiplayerLanInterfaceId;
|
||||
MultiplayerMode = multiplayerMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ namespace Ryujinx.HLE.HOS
|
||||
internal ServerBase ViServer { get; private set; }
|
||||
internal ServerBase ViServerM { get; private set; }
|
||||
internal ServerBase ViServerS { get; private set; }
|
||||
internal ServerBase LdnServer { get; private set; }
|
||||
|
||||
internal KSharedMemory HidSharedMem { get; private set; }
|
||||
internal KSharedMemory FontSharedMem { get; private set; }
|
||||
@ -319,14 +320,17 @@ namespace Ryujinx.HLE.HOS
|
||||
ViServer = new ServerBase(KernelContext, "ViServerU");
|
||||
ViServerM = new ServerBase(KernelContext, "ViServerM");
|
||||
ViServerS = new ServerBase(KernelContext, "ViServerS");
|
||||
LdnServer = new ServerBase(KernelContext, "LdnServer");
|
||||
|
||||
StartNewServices();
|
||||
}
|
||||
|
||||
private void StartNewServices()
|
||||
{
|
||||
HorizonFsClient fsClient = new(this);
|
||||
|
||||
ServiceTable = new ServiceTable();
|
||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient));
|
||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient, fsClient));
|
||||
|
||||
foreach (var service in services)
|
||||
{
|
||||
|
119
src/Ryujinx.HLE/HOS/HorizonFsClient.cs
Normal file
119
src/Ryujinx.HLE/HOS/HorizonFsClient.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.Horizon;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using Ryujinx.Horizon.Sdk.Fs;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
class HorizonFsClient : IFsClient
|
||||
{
|
||||
private readonly Horizon _system;
|
||||
private readonly LibHac.Fs.FileSystemClient _fsClient;
|
||||
private readonly ConcurrentDictionary<string, LocalStorage> _mountedStorages;
|
||||
|
||||
public HorizonFsClient(Horizon system)
|
||||
{
|
||||
_system = system;
|
||||
_fsClient = _system.LibHacHorizonManager.FsClient.Fs;
|
||||
_mountedStorages = new();
|
||||
}
|
||||
|
||||
public void CloseFile(FileHandle handle)
|
||||
{
|
||||
_fsClient.CloseFile((LibHac.Fs.FileHandle)handle.Value);
|
||||
}
|
||||
|
||||
public Result GetFileSize(out long size, FileHandle handle)
|
||||
{
|
||||
return _fsClient.GetFileSize(out size, (LibHac.Fs.FileHandle)handle.Value).ToHorizonResult();
|
||||
}
|
||||
|
||||
public Result MountSystemData(string mountName, ulong dataId)
|
||||
{
|
||||
string contentPath = _system.ContentManager.GetInstalledContentPath(dataId, StorageId.BuiltInSystem, NcaContentType.PublicData);
|
||||
string installPath = VirtualFileSystem.SwitchPathToSystemPath(contentPath);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(installPath))
|
||||
{
|
||||
string ncaPath = installPath;
|
||||
|
||||
if (File.Exists(ncaPath))
|
||||
{
|
||||
LocalStorage ncaStorage = null;
|
||||
|
||||
try
|
||||
{
|
||||
ncaStorage = new LocalStorage(ncaPath, FileAccess.Read, FileMode.Open);
|
||||
|
||||
Nca nca = new(_system.KeySet, ncaStorage);
|
||||
|
||||
using var ncaFileSystem = nca.OpenFileSystem(NcaSectionType.Data, _system.FsIntegrityCheckLevel);
|
||||
using var ncaFsRef = new UniqueRef<IFileSystem>(ncaFileSystem);
|
||||
|
||||
Result result = _fsClient.Register(mountName.ToU8Span(), ref ncaFsRef.Ref).ToHorizonResult();
|
||||
if (result.IsFailure)
|
||||
{
|
||||
ncaStorage.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
_mountedStorages.TryAdd(mountName, ncaStorage);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (HorizonResultException ex)
|
||||
{
|
||||
ncaStorage?.Dispose();
|
||||
|
||||
return ex.ResultValue.ToHorizonResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Return correct result here, this is likely wrong.
|
||||
|
||||
return LibHac.Fs.ResultFs.TargetNotFound.Handle().ToHorizonResult();
|
||||
}
|
||||
|
||||
public Result OpenFile(out FileHandle handle, string path, OpenMode openMode)
|
||||
{
|
||||
var result = _fsClient.OpenFile(out var libhacHandle, path.ToU8Span(), (LibHac.Fs.OpenMode)openMode);
|
||||
handle = new(libhacHandle);
|
||||
|
||||
return result.ToHorizonResult();
|
||||
}
|
||||
|
||||
public Result QueryMountSystemDataCacheSize(out long size, ulong dataId)
|
||||
{
|
||||
// TODO.
|
||||
|
||||
size = 0;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
public Result ReadFile(FileHandle handle, long offset, Span<byte> destination)
|
||||
{
|
||||
return _fsClient.ReadFile((LibHac.Fs.FileHandle)handle.Value, offset, destination).ToHorizonResult();
|
||||
}
|
||||
|
||||
public void Unmount(string mountName)
|
||||
{
|
||||
if (_mountedStorages.TryRemove(mountName, out LocalStorage ncaStorage))
|
||||
{
|
||||
ncaStorage.Dispose();
|
||||
}
|
||||
|
||||
_fsClient.Unmount(mountName.ToU8Span());
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn
|
||||
[Service("ldn:u")]
|
||||
class IUserServiceCreator : IpcService
|
||||
{
|
||||
public IUserServiceCreator(ServiceCtx context) { }
|
||||
public IUserServiceCreator(ServiceCtx context) : base(context.Device.System.LdnServer) { }
|
||||
|
||||
[CommandCmif(0)]
|
||||
// CreateUserLocalCommunicationService() -> object<nn::ldn::detail::IUserLocalCommunicationService>
|
||||
|
@ -7,10 +7,18 @@ namespace Ryujinx.HLE.HOS.Services.Ldn
|
||||
|
||||
Success = 0,
|
||||
|
||||
DeviceNotAvailable = (16 << ErrorCodeShift) | ModuleId,
|
||||
DeviceDisabled = (22 << ErrorCodeShift) | ModuleId,
|
||||
InvalidState = (32 << ErrorCodeShift) | ModuleId,
|
||||
Unknown1 = (48 << ErrorCodeShift) | ModuleId,
|
||||
NodeNotFound = (48 << ErrorCodeShift) | ModuleId,
|
||||
ConnectFailure = (64 << ErrorCodeShift) | ModuleId,
|
||||
ConnectNotFound = (65 << ErrorCodeShift) | ModuleId,
|
||||
ConnectTimeout = (66 << ErrorCodeShift) | ModuleId,
|
||||
ConnectRejected = (67 << ErrorCodeShift) | ModuleId,
|
||||
InvalidArgument = (96 << ErrorCodeShift) | ModuleId,
|
||||
InvalidObject = (97 << ErrorCodeShift) | ModuleId,
|
||||
VersionTooLow = (113 << ErrorCodeShift) | ModuleId,
|
||||
VersionTooHigh = (114 << ErrorCodeShift) | ModuleId,
|
||||
TooManyPlayers = (144 << ErrorCodeShift) | ModuleId,
|
||||
}
|
||||
}
|
||||
|
10
src/Ryujinx.HLE/HOS/Services/Ldn/Types/AcceptPolicy.cs
Normal file
10
src/Ryujinx.HLE/HOS/Services/Ldn/Types/AcceptPolicy.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
enum AcceptPolicy : byte
|
||||
{
|
||||
AcceptAll,
|
||||
RejectAll,
|
||||
BlackList,
|
||||
WhiteList,
|
||||
}
|
||||
}
|
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/AddressEntry.cs
Normal file
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/AddressEntry.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0xC)]
|
||||
struct AddressEntry
|
||||
{
|
||||
public uint Ipv4Address;
|
||||
public Array6<byte> MacAddress;
|
||||
public ushort Reserved;
|
||||
}
|
||||
}
|
11
src/Ryujinx.HLE/HOS/Services/Ldn/Types/AddressList.cs
Normal file
11
src/Ryujinx.HLE/HOS/Services/Ldn/Types/AddressList.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x60)]
|
||||
struct AddressList
|
||||
{
|
||||
public Array8<AddressEntry> Addresses;
|
||||
}
|
||||
}
|
16
src/Ryujinx.HLE/HOS/Services/Ldn/Types/CommonNetworkInfo.cs
Normal file
16
src/Ryujinx.HLE/HOS/Services/Ldn/Types/CommonNetworkInfo.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x30)]
|
||||
struct CommonNetworkInfo
|
||||
{
|
||||
public Array6<byte> MacAddress;
|
||||
public Ssid Ssid;
|
||||
public ushort Channel;
|
||||
public byte LinkLevel;
|
||||
public byte NetworkType;
|
||||
public uint Reserved;
|
||||
}
|
||||
}
|
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/DisconnectReason.cs
Normal file
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/DisconnectReason.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
enum DisconnectReason : uint
|
||||
{
|
||||
None,
|
||||
DisconnectedByUser,
|
||||
DisconnectedBySystem,
|
||||
DestroyedByUser,
|
||||
DestroyedBySystem,
|
||||
Rejected,
|
||||
SignalLost,
|
||||
}
|
||||
}
|
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/IntentId.cs
Normal file
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/IntentId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
struct IntentId
|
||||
{
|
||||
public long LocalCommunicationId;
|
||||
public ushort Reserved1;
|
||||
public ushort SceneId;
|
||||
public uint Reserved2;
|
||||
}
|
||||
}
|
23
src/Ryujinx.HLE/HOS/Services/Ldn/Types/LdnNetworkInfo.cs
Normal file
23
src/Ryujinx.HLE/HOS/Services/Ldn/Types/LdnNetworkInfo.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x430)]
|
||||
struct LdnNetworkInfo
|
||||
{
|
||||
public Array16<byte> SecurityParameter;
|
||||
public ushort SecurityMode;
|
||||
public AcceptPolicy StationAcceptPolicy;
|
||||
public byte Reserved1;
|
||||
public ushort Reserved2;
|
||||
public byte NodeCountMax;
|
||||
public byte NodeCount;
|
||||
public Array8<NodeInfo> Nodes;
|
||||
public ushort Reserved3;
|
||||
public ushort AdvertiseDataSize;
|
||||
public Array384<byte> AdvertiseData;
|
||||
public Array140<byte> Reserved4;
|
||||
public ulong AuthenticationId;
|
||||
}
|
||||
}
|
16
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkConfig.cs
Normal file
16
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkConfig.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
struct NetworkConfig
|
||||
{
|
||||
public IntentId IntentId;
|
||||
public ushort Channel;
|
||||
public byte NodeCountMax;
|
||||
public byte Reserved1;
|
||||
public ushort LocalCommunicationVersion;
|
||||
public Array10<byte> Reserved2;
|
||||
}
|
||||
}
|
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkId.cs
Normal file
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkId.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
struct NetworkId
|
||||
{
|
||||
public IntentId IntentId;
|
||||
public Array16<byte> SessionId;
|
||||
}
|
||||
}
|
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkInfo.cs
Normal file
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkInfo.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x480)]
|
||||
struct NetworkInfo
|
||||
{
|
||||
public NetworkId NetworkId;
|
||||
public CommonNetworkInfo Common;
|
||||
public LdnNetworkInfo Ldn;
|
||||
}
|
||||
}
|
10
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkType.cs
Normal file
10
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NetworkType.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
enum NetworkType : uint
|
||||
{
|
||||
None,
|
||||
General,
|
||||
Ldn,
|
||||
All,
|
||||
}
|
||||
}
|
18
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeInfo.cs
Normal file
18
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeInfo.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x40)]
|
||||
struct NodeInfo
|
||||
{
|
||||
public uint Ipv4Address;
|
||||
public Array6<byte> MacAddress;
|
||||
public byte NodeId;
|
||||
public byte IsConnected;
|
||||
public Array33<byte> UserName;
|
||||
public byte Reserved1;
|
||||
public ushort LocalCommunicationVersion;
|
||||
public Array16<byte> Reserved2;
|
||||
}
|
||||
}
|
62
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeLatestUpdate.cs
Normal file
62
src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeLatestUpdate.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 8)]
|
||||
struct NodeLatestUpdate
|
||||
{
|
||||
public NodeLatestUpdateFlags State;
|
||||
public Array7<byte> Reserved;
|
||||
}
|
||||
|
||||
static class NodeLatestUpdateHelper
|
||||
{
|
||||
private static readonly object _lock = new();
|
||||
|
||||
public static void CalculateLatestUpdate(this Array8<NodeLatestUpdate> array, Array8<NodeInfo> beforeNodes, Array8<NodeInfo> afterNodes)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (beforeNodes[i].IsConnected == 0)
|
||||
{
|
||||
if (afterNodes[i].IsConnected != 0)
|
||||
{
|
||||
array[i].State |= NodeLatestUpdateFlags.Connect;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (afterNodes[i].IsConnected == 0)
|
||||
{
|
||||
array[i].State |= NodeLatestUpdateFlags.Disconnect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static NodeLatestUpdate[] ConsumeLatestUpdate(this Array8<NodeLatestUpdate> array, int number)
|
||||
{
|
||||
NodeLatestUpdate[] result = new NodeLatestUpdate[number];
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
for (int i = 0; i < number; i++)
|
||||
{
|
||||
result[i].Reserved = new Array7<byte>();
|
||||
|
||||
if (i < 8)
|
||||
{
|
||||
result[i].State = array[i].State;
|
||||
array[i].State = NodeLatestUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[Flags]
|
||||
enum NodeLatestUpdateFlags : byte
|
||||
{
|
||||
None = 0,
|
||||
Connect = 1 << 0,
|
||||
Disconnect = 1 << 1,
|
||||
}
|
||||
}
|
16
src/Ryujinx.HLE/HOS/Services/Ldn/Types/ScanFilter.cs
Normal file
16
src/Ryujinx.HLE/HOS/Services/Ldn/Types/ScanFilter.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x60)]
|
||||
struct ScanFilter
|
||||
{
|
||||
public NetworkId NetworkId;
|
||||
public NetworkType NetworkType;
|
||||
public Array6<byte> MacAddress;
|
||||
public Ssid Ssid;
|
||||
public Array16<byte> Reserved;
|
||||
public ScanFilterFlag Flag;
|
||||
}
|
||||
}
|
18
src/Ryujinx.HLE/HOS/Services/Ldn/Types/ScanFilterFlag.cs
Normal file
18
src/Ryujinx.HLE/HOS/Services/Ldn/Types/ScanFilterFlag.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[Flags]
|
||||
enum ScanFilterFlag : byte
|
||||
{
|
||||
LocalCommunicationId = 1 << 0,
|
||||
SessionId = 1 << 1,
|
||||
NetworkType = 1 << 2,
|
||||
MacAddress = 1 << 3,
|
||||
Ssid = 1 << 4,
|
||||
SceneId = 1 << 5,
|
||||
IntentId = LocalCommunicationId | SceneId,
|
||||
NetworkId = IntentId | SessionId,
|
||||
All = NetworkType | IntentId | SessionId | MacAddress | Ssid,
|
||||
}
|
||||
}
|
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/SecurityConfig.cs
Normal file
13
src/Ryujinx.HLE/HOS/Services/Ldn/Types/SecurityConfig.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x44)]
|
||||
struct SecurityConfig
|
||||
{
|
||||
public SecurityMode SecurityMode;
|
||||
public ushort PassphraseSize;
|
||||
public Array64<byte> Passphrase;
|
||||
}
|
||||
}
|
9
src/Ryujinx.HLE/HOS/Services/Ldn/Types/SecurityMode.cs
Normal file
9
src/Ryujinx.HLE/HOS/Services/Ldn/Types/SecurityMode.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
enum SecurityMode : ushort
|
||||
{
|
||||
All,
|
||||
Retail,
|
||||
Debug,
|
||||
}
|
||||
}
|
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/SecurityParameter.cs
Normal file
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/SecurityParameter.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x20)]
|
||||
struct SecurityParameter
|
||||
{
|
||||
public Array16<byte> Data;
|
||||
public Array16<byte> SessionId;
|
||||
}
|
||||
}
|
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/Ssid.cs
Normal file
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/Ssid.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x22)]
|
||||
struct Ssid
|
||||
{
|
||||
public byte Length;
|
||||
public Array33<byte> Name;
|
||||
}
|
||||
}
|
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/UserConfig.cs
Normal file
12
src/Ryujinx.HLE/HOS/Services/Ldn/Types/UserConfig.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x30)]
|
||||
struct UserConfig
|
||||
{
|
||||
public Array33<byte> UserName;
|
||||
public Array15<byte> Unknown1;
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.Network.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
{
|
||||
class AccessPoint : IDisposable
|
||||
{
|
||||
private byte[] _advertiseData;
|
||||
|
||||
private readonly IUserLocalCommunicationService _parent;
|
||||
|
||||
public NetworkInfo NetworkInfo;
|
||||
public Array8<NodeLatestUpdate> LatestUpdates = new();
|
||||
public bool Connected { get; private set; }
|
||||
|
||||
public AccessPoint(IUserLocalCommunicationService parent)
|
||||
{
|
||||
_parent = parent;
|
||||
|
||||
_parent.NetworkClient.NetworkChange += NetworkChanged;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_parent.NetworkClient.DisconnectNetwork();
|
||||
|
||||
_parent.NetworkClient.NetworkChange -= NetworkChanged;
|
||||
}
|
||||
|
||||
private void NetworkChanged(object sender, RyuLdn.NetworkChangeEventArgs e)
|
||||
{
|
||||
LatestUpdates.CalculateLatestUpdate(NetworkInfo.Ldn.Nodes, e.Info.Ldn.Nodes);
|
||||
|
||||
NetworkInfo = e.Info;
|
||||
|
||||
if (Connected != e.Connected)
|
||||
{
|
||||
Connected = e.Connected;
|
||||
|
||||
if (Connected)
|
||||
{
|
||||
_parent.SetState(NetworkState.AccessPointCreated);
|
||||
}
|
||||
else
|
||||
{
|
||||
_parent.SetDisconnectReason(e.DisconnectReasonOrDefault(DisconnectReason.DestroyedBySystem));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_parent.SetState();
|
||||
}
|
||||
}
|
||||
|
||||
public ResultCode SetAdvertiseData(byte[] advertiseData)
|
||||
{
|
||||
_advertiseData = advertiseData;
|
||||
|
||||
_parent.NetworkClient.SetAdvertiseData(_advertiseData);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public ResultCode SetStationAcceptPolicy(AcceptPolicy acceptPolicy)
|
||||
{
|
||||
_parent.NetworkClient.SetStationAcceptPolicy(acceptPolicy);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public ResultCode CreateNetwork(SecurityConfig securityConfig, UserConfig userConfig, NetworkConfig networkConfig)
|
||||
{
|
||||
CreateAccessPointRequest request = new()
|
||||
{
|
||||
SecurityConfig = securityConfig,
|
||||
UserConfig = userConfig,
|
||||
NetworkConfig = networkConfig,
|
||||
};
|
||||
|
||||
bool success = _parent.NetworkClient.CreateNetwork(request, _advertiseData ?? Array.Empty<byte>());
|
||||
|
||||
return success ? ResultCode.Success : ResultCode.InvalidState;
|
||||
}
|
||||
|
||||
public ResultCode CreateNetworkPrivate(SecurityConfig securityConfig, SecurityParameter securityParameter, UserConfig userConfig, NetworkConfig networkConfig, AddressList addressList)
|
||||
{
|
||||
CreateAccessPointPrivateRequest request = new()
|
||||
{
|
||||
SecurityConfig = securityConfig,
|
||||
SecurityParameter = securityParameter,
|
||||
UserConfig = userConfig,
|
||||
NetworkConfig = networkConfig,
|
||||
AddressList = addressList,
|
||||
};
|
||||
|
||||
bool success = _parent.NetworkClient.CreateNetworkPrivate(request, _advertiseData);
|
||||
|
||||
return success ? ResultCode.Success : ResultCode.InvalidState;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.Network.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x4FC)]
|
||||
struct ConnectRequest
|
||||
{
|
||||
public SecurityConfig SecurityConfig;
|
||||
public UserConfig UserConfig;
|
||||
public uint LocalCommunicationVersion;
|
||||
public uint OptionUnknown;
|
||||
public NetworkInfo NetworkInfo;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.Network.Types
|
||||
{
|
||||
/// <remarks>
|
||||
/// Advertise data is appended separately (remaining data in the buffer).
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x94, CharSet = CharSet.Ansi)]
|
||||
struct CreateAccessPointRequest
|
||||
{
|
||||
public SecurityConfig SecurityConfig;
|
||||
public UserConfig UserConfig;
|
||||
public NetworkConfig NetworkConfig;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.Network.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn
|
||||
{
|
||||
class DisabledLdnClient : INetworkClient
|
||||
{
|
||||
public event EventHandler<NetworkChangeEventArgs> NetworkChange;
|
||||
|
||||
public NetworkError Connect(ConnectRequest request)
|
||||
{
|
||||
NetworkChange?.Invoke(this, new NetworkChangeEventArgs(new NetworkInfo(), false));
|
||||
|
||||
return NetworkError.None;
|
||||
}
|
||||
|
||||
public NetworkError ConnectPrivate(ConnectPrivateRequest request)
|
||||
{
|
||||
NetworkChange?.Invoke(this, new NetworkChangeEventArgs(new NetworkInfo(), false));
|
||||
|
||||
return NetworkError.None;
|
||||
}
|
||||
|
||||
public bool CreateNetwork(CreateAccessPointRequest request, byte[] advertiseData)
|
||||
{
|
||||
NetworkChange?.Invoke(this, new NetworkChangeEventArgs(new NetworkInfo(), false));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateNetworkPrivate(CreateAccessPointPrivateRequest request, byte[] advertiseData)
|
||||
{
|
||||
NetworkChange?.Invoke(this, new NetworkChangeEventArgs(new NetworkInfo(), false));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DisconnectAndStop() { }
|
||||
|
||||
public void DisconnectNetwork() { }
|
||||
|
||||
public ResultCode Reject(DisconnectReason disconnectReason, uint nodeId)
|
||||
{
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public NetworkInfo[] Scan(ushort channel, ScanFilter scanFilter)
|
||||
{
|
||||
return Array.Empty<NetworkInfo>();
|
||||
}
|
||||
|
||||
public void SetAdvertiseData(byte[] data) { }
|
||||
|
||||
public void SetGameVersion(byte[] versionString) { }
|
||||
|
||||
public void SetStationAcceptPolicy(AcceptPolicy acceptPolicy) { }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.Network.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn
|
||||
{
|
||||
interface INetworkClient : IDisposable
|
||||
{
|
||||
event EventHandler<NetworkChangeEventArgs> NetworkChange;
|
||||
|
||||
void DisconnectNetwork();
|
||||
void DisconnectAndStop();
|
||||
NetworkError Connect(ConnectRequest request);
|
||||
NetworkError ConnectPrivate(ConnectPrivateRequest request);
|
||||
ResultCode Reject(DisconnectReason disconnectReason, uint nodeId);
|
||||
NetworkInfo[] Scan(ushort channel, ScanFilter scanFilter);
|
||||
void SetGameVersion(byte[] versionString);
|
||||
void SetStationAcceptPolicy(AcceptPolicy acceptPolicy);
|
||||
void SetAdvertiseData(byte[] data);
|
||||
bool CreateNetwork(CreateAccessPointRequest request, byte[] advertiseData);
|
||||
bool CreateNetworkPrivate(CreateAccessPointPrivateRequest request, byte[] advertiseData);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn
|
||||
{
|
||||
class NetworkChangeEventArgs : EventArgs
|
||||
{
|
||||
public NetworkInfo Info;
|
||||
public bool Connected;
|
||||
public DisconnectReason DisconnectReason;
|
||||
|
||||
public NetworkChangeEventArgs(NetworkInfo info, bool connected, DisconnectReason disconnectReason = DisconnectReason.None)
|
||||
{
|
||||
Info = info;
|
||||
Connected = connected;
|
||||
DisconnectReason = disconnectReason;
|
||||
}
|
||||
|
||||
public DisconnectReason DisconnectReasonOrDefault(DisconnectReason defaultReason)
|
||||
{
|
||||
return DisconnectReason == DisconnectReason.None ? defaultReason : DisconnectReason;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0xBC)]
|
||||
struct ConnectPrivateRequest
|
||||
{
|
||||
public SecurityConfig SecurityConfig;
|
||||
public SecurityParameter SecurityParameter;
|
||||
public UserConfig UserConfig;
|
||||
public uint LocalCommunicationVersion;
|
||||
public uint OptionUnknown;
|
||||
public NetworkConfig NetworkConfig;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types
|
||||
{
|
||||
/// <remarks>
|
||||
/// Advertise data is appended separately (remaining data in the buffer).
|
||||
/// </remarks>
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x13C, Pack = 1)]
|
||||
struct CreateAccessPointPrivateRequest
|
||||
{
|
||||
public SecurityConfig SecurityConfig;
|
||||
public SecurityParameter SecurityParameter;
|
||||
public UserConfig UserConfig;
|
||||
public NetworkConfig NetworkConfig;
|
||||
public AddressList AddressList;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types
|
||||
{
|
||||
enum NetworkError : int
|
||||
{
|
||||
None,
|
||||
|
||||
PortUnreachable,
|
||||
|
||||
TooManyPlayers,
|
||||
VersionTooLow,
|
||||
VersionTooHigh,
|
||||
|
||||
ConnectFailure,
|
||||
ConnectNotFound,
|
||||
ConnectTimeout,
|
||||
ConnectRejected,
|
||||
|
||||
RejectFailed,
|
||||
|
||||
Unknown = -1,
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x4)]
|
||||
struct NetworkErrorMessage
|
||||
{
|
||||
public NetworkError Error;
|
||||
}
|
||||
}
|
115
src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/Station.cs
Normal file
115
src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/Station.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.Network.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.RyuLdn.Types;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
{
|
||||
class Station : IDisposable
|
||||
{
|
||||
public NetworkInfo NetworkInfo;
|
||||
public Array8<NodeLatestUpdate> LatestUpdates = new();
|
||||
|
||||
private readonly IUserLocalCommunicationService _parent;
|
||||
|
||||
public bool Connected { get; private set; }
|
||||
|
||||
public Station(IUserLocalCommunicationService parent)
|
||||
{
|
||||
_parent = parent;
|
||||
|
||||
_parent.NetworkClient.NetworkChange += NetworkChanged;
|
||||
}
|
||||
|
||||
private void NetworkChanged(object sender, RyuLdn.NetworkChangeEventArgs e)
|
||||
{
|
||||
LatestUpdates.CalculateLatestUpdate(NetworkInfo.Ldn.Nodes, e.Info.Ldn.Nodes);
|
||||
|
||||
NetworkInfo = e.Info;
|
||||
|
||||
if (Connected != e.Connected)
|
||||
{
|
||||
Connected = e.Connected;
|
||||
|
||||
if (Connected)
|
||||
{
|
||||
_parent.SetState(NetworkState.StationConnected);
|
||||
}
|
||||
else
|
||||
{
|
||||
_parent.SetDisconnectReason(e.DisconnectReasonOrDefault(DisconnectReason.DestroyedByUser));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_parent.SetState();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_parent.NetworkClient.DisconnectNetwork();
|
||||
|
||||
_parent.NetworkClient.NetworkChange -= NetworkChanged;
|
||||
}
|
||||
|
||||
private ResultCode NetworkErrorToResult(NetworkError error)
|
||||
{
|
||||
return error switch
|
||||
{
|
||||
NetworkError.None => ResultCode.Success,
|
||||
NetworkError.VersionTooLow => ResultCode.VersionTooLow,
|
||||
NetworkError.VersionTooHigh => ResultCode.VersionTooHigh,
|
||||
NetworkError.TooManyPlayers => ResultCode.TooManyPlayers,
|
||||
|
||||
NetworkError.ConnectFailure => ResultCode.ConnectFailure,
|
||||
NetworkError.ConnectNotFound => ResultCode.ConnectNotFound,
|
||||
NetworkError.ConnectTimeout => ResultCode.ConnectTimeout,
|
||||
NetworkError.ConnectRejected => ResultCode.ConnectRejected,
|
||||
|
||||
_ => ResultCode.DeviceNotAvailable,
|
||||
};
|
||||
}
|
||||
|
||||
public ResultCode Connect(
|
||||
SecurityConfig securityConfig,
|
||||
UserConfig userConfig,
|
||||
uint localCommunicationVersion,
|
||||
uint optionUnknown,
|
||||
NetworkInfo networkInfo)
|
||||
{
|
||||
ConnectRequest request = new()
|
||||
{
|
||||
SecurityConfig = securityConfig,
|
||||
UserConfig = userConfig,
|
||||
LocalCommunicationVersion = localCommunicationVersion,
|
||||
OptionUnknown = optionUnknown,
|
||||
NetworkInfo = networkInfo,
|
||||
};
|
||||
|
||||
return NetworkErrorToResult(_parent.NetworkClient.Connect(request));
|
||||
}
|
||||
|
||||
public ResultCode ConnectPrivate(
|
||||
SecurityConfig securityConfig,
|
||||
SecurityParameter securityParameter,
|
||||
UserConfig userConfig,
|
||||
uint localCommunicationVersion,
|
||||
uint optionUnknown,
|
||||
NetworkConfig networkConfig)
|
||||
{
|
||||
ConnectPrivateRequest request = new()
|
||||
{
|
||||
SecurityConfig = securityConfig,
|
||||
SecurityParameter = securityParameter,
|
||||
UserConfig = userConfig,
|
||||
LocalCommunicationVersion = localCommunicationVersion,
|
||||
OptionUnknown = optionUnknown,
|
||||
NetworkConfig = networkConfig,
|
||||
};
|
||||
|
||||
return NetworkErrorToResult(_parent.NetworkClient.ConnectPrivate(request));
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user