Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bddb2a1483 | ||
|
e3bacfa774 | ||
|
7c2f07d124 | ||
|
ede5b3c324 | ||
|
df5be5812f | ||
|
bc392e55df |
@@ -39,10 +39,15 @@
|
|||||||
<key>CSResourcesFileMapped</key>
|
<key>CSResourcesFileMapped</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2018 - 2022 Ryujinx Team and Contributors.</string>
|
<string>Copyright © 2018 - 2023 Ryujinx Team and Contributors.</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.games</string>
|
<string>public.app-category.games</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>11.0</string>
|
<string>11.0</string>
|
||||||
|
<key>LSEnvironment</key>
|
||||||
|
<dict>
|
||||||
|
<key>COMPlus_DefaultStackSize</key>
|
||||||
|
<string>200000</string>
|
||||||
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@@ -228,7 +228,6 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
@@ -248,6 +247,9 @@ namespace ARMeilleure.Instructions
|
|||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
@@ -412,7 +414,6 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
@@ -432,6 +433,9 @@ namespace ARMeilleure.Instructions
|
|||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
@@ -585,7 +589,6 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
@@ -605,6 +608,9 @@ namespace ARMeilleure.Instructions
|
|||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
@@ -1433,11 +1439,24 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (fpcr.GetRoundingMode())
|
switch (fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
|
case FPRoundingMode.ToNearest:
|
||||||
|
overflowToInf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsPlusInfinity:
|
||||||
|
overflowToInf = !sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsMinusInfinity:
|
||||||
|
overflowToInf = sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsZero:
|
||||||
|
overflowToInf = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
|
||||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
|
||||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||||
@@ -2845,11 +2864,24 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (fpcr.GetRoundingMode())
|
switch (fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
|
case FPRoundingMode.ToNearest:
|
||||||
|
overflowToInf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsPlusInfinity:
|
||||||
|
overflowToInf = !sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsMinusInfinity:
|
||||||
|
overflowToInf = sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsZero:
|
||||||
|
overflowToInf = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
|
||||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
|
||||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||||
|
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEvent _pauseEvent;
|
||||||
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
||||||
private bool _stillRunning;
|
private bool _stillRunning;
|
||||||
private Thread _updaterThread;
|
private readonly Thread _updaterThread;
|
||||||
|
|
||||||
public OpenALHardwareDeviceDriver()
|
public OpenALHardwareDeviceDriver()
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
throw new ArgumentException($"{channelCount}");
|
throw new ArgumentException($"{channelCount}");
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenALHardwareDeviceSession session = new OpenALHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
OpenALHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||||
|
|
||||||
_sessions.TryAdd(session, 0);
|
_sessions.TryAdd(session, 0);
|
||||||
|
|
||||||
@@ -123,6 +123,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,11 +10,11 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
{
|
{
|
||||||
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private OpenALHardwareDeviceDriver _driver;
|
private readonly OpenALHardwareDeviceDriver _driver;
|
||||||
private int _sourceId;
|
private readonly int _sourceId;
|
||||||
private ALFormat _targetFormat;
|
private readonly ALFormat _targetFormat;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private Queue<OpenALAudioBuffer> _queuedBuffers;
|
private readonly Queue<OpenALAudioBuffer> _queuedBuffers;
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
|
|
||||||
private readonly object _lock = new();
|
private readonly object _lock = new();
|
||||||
@@ -32,23 +32,17 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
|
|
||||||
private ALFormat GetALFormat()
|
private ALFormat GetALFormat()
|
||||||
{
|
{
|
||||||
switch (RequestedSampleFormat)
|
return RequestedSampleFormat switch
|
||||||
{
|
{
|
||||||
case SampleFormat.PcmInt16:
|
SampleFormat.PcmInt16 => RequestedChannelCount switch
|
||||||
switch (RequestedChannelCount)
|
{
|
||||||
{
|
1 => ALFormat.Mono16,
|
||||||
case 1:
|
2 => ALFormat.Stereo16,
|
||||||
return ALFormat.Mono16;
|
6 => ALFormat.Multi51Chn16Ext,
|
||||||
case 2:
|
_ => throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}"),
|
||||||
return ALFormat.Stereo16;
|
},
|
||||||
case 6:
|
_ => throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}"),
|
||||||
return ALFormat.Multi51Chn16Ext;
|
};
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}");
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PrepareToClose() { }
|
public override void PrepareToClose() { }
|
||||||
@@ -69,7 +63,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
OpenALAudioBuffer driverBuffer = new OpenALAudioBuffer
|
OpenALAudioBuffer driverBuffer = new()
|
||||||
{
|
{
|
||||||
DriverIdentifier = buffer.DataPointer,
|
DriverIdentifier = buffer.DataPointer,
|
||||||
BufferId = AL.GenBuffer(),
|
BufferId = AL.GenBuffer(),
|
||||||
|
@@ -10,19 +10,19 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||||||
private const string LibraryName = "libsoundio";
|
private const string LibraryName = "libsoundio";
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
public delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
public delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void OnEventsSignalDelegate(IntPtr ctx);
|
public delegate void OnEventsSignalDelegate(IntPtr ctx);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void EmitRtPrioWarningDelegate();
|
public delegate void EmitRtPrioWarningDelegate();
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void JackCallbackDelegate(IntPtr msg);
|
public delegate void JackCallbackDelegate(IntPtr msg);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SoundIoStruct
|
public struct SoundIoStruct
|
||||||
@@ -110,69 +110,69 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||||||
}
|
}
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_create();
|
internal static partial IntPtr soundio_create();
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_connect(IntPtr ctx);
|
internal static partial SoundIoError soundio_connect(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_disconnect(IntPtr ctx);
|
internal static partial void soundio_disconnect(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_flush_events(IntPtr ctx);
|
internal static partial void soundio_flush_events(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial int soundio_output_device_count(IntPtr ctx);
|
internal static partial int soundio_output_device_count(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial int soundio_default_output_device_index(IntPtr ctx);
|
internal static partial int soundio_default_output_device_index(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
internal static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
internal static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
internal static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
internal static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
internal static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
internal static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
internal static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
internal static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
internal static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_destroy(IntPtr ctx);
|
internal static partial void soundio_destroy(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
internal static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_strerror(SoundIoError err);
|
internal static partial IntPtr soundio_strerror(SoundIoError err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@@ -141,7 +141,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
throw new NotImplementedException("Input direction is currently not implemented on SoundIO backend!");
|
throw new NotImplementedException("Input direction is currently not implemented on SoundIO backend!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundIoHardwareDeviceSession session = new SoundIoHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
SoundIoHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||||
|
|
||||||
_sessions.TryAdd(session, 0);
|
_sessions.TryAdd(session, 0);
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
SampleFormat.PcmInt24 => SoundIoFormat.S24LE,
|
SampleFormat.PcmInt24 => SoundIoFormat.S24LE,
|
||||||
SampleFormat.PcmInt32 => SoundIoFormat.S32LE,
|
SampleFormat.PcmInt32 => SoundIoFormat.S32LE,
|
||||||
SampleFormat.PcmFloat => SoundIoFormat.Float32LE,
|
SampleFormat.PcmFloat => SoundIoFormat.Float32LE,
|
||||||
_ => throw new ArgumentException ($"Unsupported sample format {format}"),
|
_ => throw new ArgumentException($"Unsupported sample format {format}"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +202,8 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@@ -12,12 +12,12 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
{
|
{
|
||||||
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private SoundIoHardwareDeviceDriver _driver;
|
private readonly SoundIoHardwareDeviceDriver _driver;
|
||||||
private ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
private readonly ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
||||||
private SoundIoOutStreamContext _outputStream;
|
private SoundIoOutStreamContext _outputStream;
|
||||||
private DynamicRingBuffer _ringBuffer;
|
private readonly DynamicRingBuffer _ringBuffer;
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
private ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEvent _updateRequiredEvent;
|
||||||
private int _disposeState;
|
private int _disposeState;
|
||||||
|
|
||||||
public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
||||||
@@ -54,7 +54,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
|
|
||||||
public override void QueueBuffer(AudioBuffer buffer)
|
public override void QueueBuffer(AudioBuffer buffer)
|
||||||
{
|
{
|
||||||
SoundIoAudioBuffer driverBuffer = new SoundIoAudioBuffer(buffer.DataPointer, GetSampleCount(buffer));
|
SoundIoAudioBuffer driverBuffer = new(buffer.DataPointer, GetSampleCount(buffer));
|
||||||
|
|
||||||
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
_driver.FlushContextEvents();
|
_driver.FlushContextEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UnregisterBuffer(AudioBuffer buffer) {}
|
public override void UnregisterBuffer(AudioBuffer buffer) { }
|
||||||
|
|
||||||
public override bool WasBufferFullyConsumed(AudioBuffer buffer)
|
public override bool WasBufferFullyConsumed(AudioBuffer buffer)
|
||||||
{
|
{
|
||||||
|
@@ -134,7 +134,7 @@ namespace Ryujinx.Ava
|
|||||||
_inputManager = inputManager;
|
_inputManager = inputManager;
|
||||||
_accountManager = accountManager;
|
_accountManager = accountManager;
|
||||||
_userChannelPersistence = userChannelPersistence;
|
_userChannelPersistence = userChannelPersistence;
|
||||||
_renderingThread = new Thread(RenderLoop, 1 * 1024 * 1024) { Name = "GUI.RenderThread" };
|
_renderingThread = new Thread(RenderLoop) { Name = "GUI.RenderThread" };
|
||||||
_lastCursorMoveTime = Stopwatch.GetTimestamp();
|
_lastCursorMoveTime = Stopwatch.GetTimestamp();
|
||||||
_glLogLevel = ConfigurationState.Instance.Logger.GraphicsDebugLevel;
|
_glLogLevel = ConfigurationState.Instance.Logger.GraphicsDebugLevel;
|
||||||
_topLevel = topLevel;
|
_topLevel = topLevel;
|
||||||
|
@@ -4,36 +4,36 @@
|
|||||||
{
|
{
|
||||||
private const int ModuleId = 1;
|
private const int ModuleId = 1;
|
||||||
|
|
||||||
public static Result SessionCountExceeded => new Result(ModuleId, 7);
|
public static Result SessionCountExceeded => new(ModuleId, 7);
|
||||||
public static Result InvalidCapability => new Result(ModuleId, 14);
|
public static Result InvalidCapability => new(ModuleId, 14);
|
||||||
public static Result ThreadNotStarted => new Result(ModuleId, 57);
|
public static Result ThreadNotStarted => new(ModuleId, 57);
|
||||||
public static Result ThreadTerminating => new Result(ModuleId, 59);
|
public static Result ThreadTerminating => new(ModuleId, 59);
|
||||||
public static Result InvalidSize => new Result(ModuleId, 101);
|
public static Result InvalidSize => new(ModuleId, 101);
|
||||||
public static Result InvalidAddress => new Result(ModuleId, 102);
|
public static Result InvalidAddress => new(ModuleId, 102);
|
||||||
public static Result OutOfResource => new Result(ModuleId, 103);
|
public static Result OutOfResource => new(ModuleId, 103);
|
||||||
public static Result OutOfMemory => new Result(ModuleId, 104);
|
public static Result OutOfMemory => new(ModuleId, 104);
|
||||||
public static Result HandleTableFull => new Result(ModuleId, 105);
|
public static Result HandleTableFull => new(ModuleId, 105);
|
||||||
public static Result InvalidMemState => new Result(ModuleId, 106);
|
public static Result InvalidMemState => new(ModuleId, 106);
|
||||||
public static Result InvalidPermission => new Result(ModuleId, 108);
|
public static Result InvalidPermission => new(ModuleId, 108);
|
||||||
public static Result InvalidMemRange => new Result(ModuleId, 110);
|
public static Result InvalidMemRange => new(ModuleId, 110);
|
||||||
public static Result InvalidPriority => new Result(ModuleId, 112);
|
public static Result InvalidPriority => new(ModuleId, 112);
|
||||||
public static Result InvalidCpuCore => new Result(ModuleId, 113);
|
public static Result InvalidCpuCore => new(ModuleId, 113);
|
||||||
public static Result InvalidHandle => new Result(ModuleId, 114);
|
public static Result InvalidHandle => new(ModuleId, 114);
|
||||||
public static Result UserCopyFailed => new Result(ModuleId, 115);
|
public static Result UserCopyFailed => new(ModuleId, 115);
|
||||||
public static Result InvalidCombination => new Result(ModuleId, 116);
|
public static Result InvalidCombination => new(ModuleId, 116);
|
||||||
public static Result TimedOut => new Result(ModuleId, 117);
|
public static Result TimedOut => new(ModuleId, 117);
|
||||||
public static Result Cancelled => new Result(ModuleId, 118);
|
public static Result Cancelled => new(ModuleId, 118);
|
||||||
public static Result MaximumExceeded => new Result(ModuleId, 119);
|
public static Result MaximumExceeded => new(ModuleId, 119);
|
||||||
public static Result InvalidEnumValue => new Result(ModuleId, 120);
|
public static Result InvalidEnumValue => new(ModuleId, 120);
|
||||||
public static Result NotFound => new Result(ModuleId, 121);
|
public static Result NotFound => new(ModuleId, 121);
|
||||||
public static Result InvalidThread => new Result(ModuleId, 122);
|
public static Result InvalidThread => new(ModuleId, 122);
|
||||||
public static Result PortRemoteClosed => new Result(ModuleId, 123);
|
public static Result PortRemoteClosed => new(ModuleId, 123);
|
||||||
public static Result InvalidState => new Result(ModuleId, 125);
|
public static Result InvalidState => new(ModuleId, 125);
|
||||||
public static Result ReservedValue => new Result(ModuleId, 126);
|
public static Result ReservedValue => new(ModuleId, 126);
|
||||||
public static Result PortClosed => new Result(ModuleId, 131);
|
public static Result PortClosed => new(ModuleId, 131);
|
||||||
public static Result ResLimitExceeded => new Result(ModuleId, 132);
|
public static Result ResLimitExceeded => new(ModuleId, 132);
|
||||||
public static Result ReceiveListBroken => new Result(ModuleId, 258);
|
public static Result ReceiveListBroken => new(ModuleId, 258);
|
||||||
public static Result OutOfVaSpace => new Result(ModuleId, 259);
|
public static Result OutOfVaSpace => new(ModuleId, 259);
|
||||||
public static Result CmdBufferTooSmall => new Result(ModuleId, 260);
|
public static Result CmdBufferTooSmall => new(ModuleId, 260);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Ryujinx.Horizon.Common
|
namespace Ryujinx.Horizon.Common
|
||||||
{
|
{
|
||||||
public struct OnScopeExit : IDisposable
|
public readonly struct OnScopeExit : IDisposable
|
||||||
{
|
{
|
||||||
private readonly Action _action;
|
private readonly Action _action;
|
||||||
|
|
||||||
|
@@ -13,13 +13,13 @@ namespace Ryujinx.Horizon.Common
|
|||||||
|
|
||||||
public int ErrorCode { get; }
|
public int ErrorCode { get; }
|
||||||
|
|
||||||
public bool IsSuccess => ErrorCode == 0;
|
public readonly bool IsSuccess => ErrorCode == 0;
|
||||||
public bool IsFailure => ErrorCode != 0;
|
public readonly bool IsFailure => ErrorCode != 0;
|
||||||
|
|
||||||
public int Module => ErrorCode & (ModuleMax - 1);
|
public readonly int Module => ErrorCode & (ModuleMax - 1);
|
||||||
public int Description => (ErrorCode >> ModuleBits) & (DescriptionMax - 1);
|
public readonly int Description => (ErrorCode >> ModuleBits) & (DescriptionMax - 1);
|
||||||
|
|
||||||
public string PrintableResult => $"{2000 + Module:D4}-{Description:D4}";
|
public readonly string PrintableResult => $"{2000 + Module:D4}-{Description:D4}";
|
||||||
|
|
||||||
public Result(int module, int description)
|
public Result(int module, int description)
|
||||||
{
|
{
|
||||||
@@ -36,17 +36,17 @@ namespace Ryujinx.Horizon.Common
|
|||||||
ErrorCode = module | (description << ModuleBits);
|
ErrorCode = module | (description << ModuleBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
public readonly override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
return obj is Result result && result.Equals(this);
|
return obj is Result result && result.Equals(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(Result other)
|
public readonly bool Equals(Result other)
|
||||||
{
|
{
|
||||||
return other.ErrorCode == ErrorCode;
|
return other.ErrorCode == ErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public readonly override int GetHashCode()
|
||||||
{
|
{
|
||||||
return ErrorCode;
|
return ErrorCode;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ namespace Ryujinx.Horizon.Common
|
|||||||
return !lhs.Equals(rhs);
|
return !lhs.Equals(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InRange(int minInclusive, int maxInclusive)
|
public readonly bool InRange(int minInclusive, int maxInclusive)
|
||||||
{
|
{
|
||||||
return (uint)(Description - minInclusive) <= (uint)(maxInclusive - minInclusive);
|
return (uint)(Description - minInclusive) <= (uint)(maxInclusive - minInclusive);
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ namespace Ryujinx.Horizon.Common
|
|||||||
throw new InvalidResultException(this);
|
throw new InvalidResultException(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public readonly override string ToString()
|
||||||
{
|
{
|
||||||
if (ResultNames.TryGet(ErrorCode, out string name))
|
if (ResultNames.TryGet(ErrorCode, out string name))
|
||||||
{
|
{
|
||||||
@@ -115,4 +115,4 @@ namespace Ryujinx.Horizon.Common
|
|||||||
return PrintableResult;
|
return PrintableResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1698,4 +1698,4 @@ namespace Ryujinx.Horizon.Common
|
|||||||
return _names.TryGetValue(errorCode, out name);
|
return _names.TryGetValue(errorCode, out name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,12 +4,12 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
public class IndexedProperty<TIndex, TValue>
|
public class IndexedProperty<TIndex, TValue>
|
||||||
{
|
{
|
||||||
private Func<TIndex, TValue> _getFunc;
|
private readonly Func<TIndex, TValue> _getFunc;
|
||||||
private Action<TIndex, TValue> _setAction;
|
private readonly Action<TIndex, TValue> _setAction;
|
||||||
|
|
||||||
public IndexedProperty(Func<TIndex, TValue> getFunc, Action<TIndex, TValue> setAction)
|
public IndexedProperty(Func<TIndex, TValue> getFunc, Action<TIndex, TValue> setAction)
|
||||||
{
|
{
|
||||||
_getFunc = getFunc;
|
_getFunc = getFunc;
|
||||||
_setAction = setAction;
|
_setAction = setAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,4 +11,4 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
Exec = 4,
|
Exec = 4,
|
||||||
All = 7,
|
All = 7,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ using System;
|
|||||||
|
|
||||||
namespace Ryujinx.Tests.Unicorn
|
namespace Ryujinx.Tests.Unicorn
|
||||||
{
|
{
|
||||||
public struct SimdValue : IEquatable<SimdValue>
|
public readonly struct SimdValue : IEquatable<SimdValue>
|
||||||
{
|
{
|
||||||
private readonly ulong _e0;
|
private readonly ulong _e0;
|
||||||
private readonly ulong _e1;
|
private readonly ulong _e1;
|
||||||
@@ -39,31 +39,29 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
return BitConverter.Int64BitsToDouble(GetInt64(index));
|
return BitConverter.Int64BitsToDouble(GetInt64(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetInt32(int index) => (int)GetUInt32(index);
|
public int GetInt32(int index) => (int)GetUInt32(index);
|
||||||
public long GetInt64(int index) => (long)GetUInt64(index);
|
public long GetInt64(int index) => (long)GetUInt64(index);
|
||||||
|
|
||||||
public uint GetUInt32(int index)
|
public uint GetUInt32(int index)
|
||||||
{
|
{
|
||||||
switch (index)
|
return index switch
|
||||||
{
|
{
|
||||||
case 0: return (uint)(_e0 >> 0);
|
0 => (uint)(_e0 >> 0),
|
||||||
case 1: return (uint)(_e0 >> 32);
|
1 => (uint)(_e0 >> 32),
|
||||||
case 2: return (uint)(_e1 >> 0);
|
2 => (uint)(_e1 >> 0),
|
||||||
case 3: return (uint)(_e1 >> 32);
|
3 => (uint)(_e1 >> 32),
|
||||||
}
|
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
||||||
|
};
|
||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong GetUInt64(int index)
|
public ulong GetUInt64(int index)
|
||||||
{
|
{
|
||||||
switch (index)
|
return index switch
|
||||||
{
|
{
|
||||||
case 0: return _e0;
|
0 => _e0,
|
||||||
case 1: return _e1;
|
1 => _e1,
|
||||||
}
|
_ => throw new ArgumentOutOfRangeException(nameof(index)),
|
||||||
|
};
|
||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] ToArray()
|
public byte[] ToArray()
|
||||||
@@ -109,4 +107,4 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
return $"0x{_e1:X16}{_e0:X16}";
|
return $"0x{_e1:X16}{_e0:X16}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
public class UnicornAArch32 : IDisposable
|
public class UnicornAArch32 : IDisposable
|
||||||
{
|
{
|
||||||
internal readonly UnicornEngine.Unicorn uc;
|
internal readonly UnicornEngine.Unicorn Uc;
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
||||||
public IndexedProperty<int, uint> R => new(GetX, SetX);
|
public IndexedProperty<int, uint> R => new(GetX, SetX);
|
||||||
@@ -84,7 +84,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
|
|
||||||
public UnicornAArch32()
|
public UnicornAArch32()
|
||||||
{
|
{
|
||||||
uc = new UnicornEngine.Unicorn(Common.UC_ARCH_ARM, Common.UC_MODE_LITTLE_ENDIAN);
|
Uc = new UnicornEngine.Unicorn(Common.UC_ARCH_ARM, Common.UC_MODE_LITTLE_ENDIAN);
|
||||||
|
|
||||||
SetRegister(Arm.UC_ARM_REG_C1_C0_2, GetRegister(Arm.UC_ARM_REG_C1_C0_2) | 0xf00000);
|
SetRegister(Arm.UC_ARM_REG_C1_C0_2, GetRegister(Arm.UC_ARM_REG_C1_C0_2) | 0xf00000);
|
||||||
SetRegister(Arm.UC_ARM_REG_FPEXC, 0x40000000);
|
SetRegister(Arm.UC_ARM_REG_FPEXC, 0x40000000);
|
||||||
@@ -105,7 +105,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
if (!_isDisposed)
|
if (!_isDisposed)
|
||||||
{
|
{
|
||||||
uc.Close();
|
Uc.Close();
|
||||||
_isDisposed = true;
|
_isDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
public void RunForCount(ulong count)
|
public void RunForCount(ulong count)
|
||||||
{
|
{
|
||||||
// FIXME: untilAddr should be 0xFFFFFFFFFFFFFFFFu
|
// FIXME: untilAddr should be 0xFFFFFFFFFFFFFFFFu
|
||||||
uc.EmuStart(this.PC, -1, 0, (long)count);
|
Uc.EmuStart(this.PC, -1, 0, (long)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Step()
|
public void Step()
|
||||||
@@ -121,7 +121,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
RunForCount(1);
|
RunForCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] XRegisters =
|
private static readonly int[] _xRegisters =
|
||||||
{
|
{
|
||||||
Arm.UC_ARM_REG_R0,
|
Arm.UC_ARM_REG_R0,
|
||||||
Arm.UC_ARM_REG_R1,
|
Arm.UC_ARM_REG_R1,
|
||||||
@@ -141,7 +141,8 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
Arm.UC_ARM_REG_R15,
|
Arm.UC_ARM_REG_R15,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static int[] QRegisters =
|
#pragma warning disable IDE0051, IDE0052 // Remove unused private member
|
||||||
|
private static readonly int[] _qRegisters =
|
||||||
{
|
{
|
||||||
Arm.UC_ARM_REG_Q0,
|
Arm.UC_ARM_REG_Q0,
|
||||||
Arm.UC_ARM_REG_Q1,
|
Arm.UC_ARM_REG_Q1,
|
||||||
@@ -160,6 +161,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
Arm.UC_ARM_REG_Q14,
|
Arm.UC_ARM_REG_Q14,
|
||||||
Arm.UC_ARM_REG_Q15
|
Arm.UC_ARM_REG_Q15
|
||||||
};
|
};
|
||||||
|
#pragma warning restore IDE0051, IDE0052
|
||||||
|
|
||||||
public uint GetX(int index)
|
public uint GetX(int index)
|
||||||
{
|
{
|
||||||
@@ -168,7 +170,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetRegister(XRegisters[index]);
|
return GetRegister(_xRegisters[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetX(int index, uint value)
|
public void SetX(int index, uint value)
|
||||||
@@ -178,7 +180,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetRegister(XRegisters[index], value);
|
SetRegister(_xRegisters[index], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimdValue GetQ(int index)
|
public SimdValue GetQ(int index)
|
||||||
@@ -206,7 +208,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
byte[] data = new byte[4];
|
byte[] data = new byte[4];
|
||||||
|
|
||||||
uc.RegRead(register, data);
|
Uc.RegRead(register, data);
|
||||||
|
|
||||||
return BitConverter.ToUInt32(data, 0);
|
return BitConverter.ToUInt32(data, 0);
|
||||||
}
|
}
|
||||||
@@ -215,16 +217,16 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
byte[] data = BitConverter.GetBytes(value);
|
byte[] data = BitConverter.GetBytes(value);
|
||||||
|
|
||||||
uc.RegWrite(register, data);
|
Uc.RegWrite(register, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimdValue GetVector(int register)
|
public SimdValue GetVector(int register)
|
||||||
{
|
{
|
||||||
byte[] data = new byte[8];
|
byte[] data = new byte[8];
|
||||||
|
|
||||||
uc.RegRead(register, data);
|
Uc.RegRead(register, data);
|
||||||
ulong lo = BitConverter.ToUInt64(data, 0);
|
ulong lo = BitConverter.ToUInt64(data, 0);
|
||||||
uc.RegRead(register + 1, data);
|
Uc.RegRead(register + 1, data);
|
||||||
ulong hi = BitConverter.ToUInt64(data, 0);
|
ulong hi = BitConverter.ToUInt64(data, 0);
|
||||||
|
|
||||||
return new SimdValue(lo, hi);
|
return new SimdValue(lo, hi);
|
||||||
@@ -233,16 +235,16 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
private void SetVector(int register, SimdValue value)
|
private void SetVector(int register, SimdValue value)
|
||||||
{
|
{
|
||||||
byte[] data = BitConverter.GetBytes(value.GetUInt64(0));
|
byte[] data = BitConverter.GetBytes(value.GetUInt64(0));
|
||||||
uc.RegWrite(register, data);
|
Uc.RegWrite(register, data);
|
||||||
data = BitConverter.GetBytes(value.GetUInt64(1));
|
data = BitConverter.GetBytes(value.GetUInt64(1));
|
||||||
uc.RegWrite(register + 1, data);
|
Uc.RegWrite(register + 1, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] MemoryRead(ulong address, ulong size)
|
public byte[] MemoryRead(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
byte[] value = new byte[size];
|
byte[] value = new byte[size];
|
||||||
|
|
||||||
uc.MemRead((long)address, value);
|
Uc.MemRead((long)address, value);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -254,7 +256,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
|
|
||||||
public void MemoryWrite(ulong address, byte[] value)
|
public void MemoryWrite(ulong address, byte[] value)
|
||||||
{
|
{
|
||||||
uc.MemWrite((long)address, value);
|
Uc.MemWrite((long)address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MemoryWrite8(ulong address, byte value) => MemoryWrite(address, new[] { value });
|
public void MemoryWrite8(ulong address, byte value) => MemoryWrite(address, new[] { value });
|
||||||
@@ -267,17 +269,17 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
|
|
||||||
public void MemoryMap(ulong address, ulong size, MemoryPermission permissions)
|
public void MemoryMap(ulong address, ulong size, MemoryPermission permissions)
|
||||||
{
|
{
|
||||||
uc.MemMap((long)address, (long)size, (int)permissions);
|
Uc.MemMap((long)address, (long)size, (int)permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MemoryUnmap(ulong address, ulong size)
|
public void MemoryUnmap(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
uc.MemUnmap((long)address, (long)size);
|
Uc.MemUnmap((long)address, (long)size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MemoryProtect(ulong address, ulong size, MemoryPermission permissions)
|
public void MemoryProtect(ulong address, ulong size, MemoryPermission permissions)
|
||||||
{
|
{
|
||||||
uc.MemProtect((long)address, (long)size, (int)permissions);
|
Uc.MemProtect((long)address, (long)size, (int)permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
public class UnicornAArch64 : IDisposable
|
public class UnicornAArch64 : IDisposable
|
||||||
{
|
{
|
||||||
internal readonly UnicornEngine.Unicorn uc;
|
internal readonly UnicornEngine.Unicorn Uc;
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
||||||
public IndexedProperty<int, ulong> X => new(GetX, SetX);
|
public IndexedProperty<int, ulong> X => new(GetX, SetX);
|
||||||
@@ -33,48 +33,48 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
public uint Pstate
|
public uint Pstate
|
||||||
{
|
{
|
||||||
get => (uint)GetRegister(Arm64.UC_ARM64_REG_PSTATE);
|
get => (uint)GetRegister(Arm64.UC_ARM64_REG_PSTATE);
|
||||||
set => SetRegister(Arm64.UC_ARM64_REG_PSTATE, value);
|
set => SetRegister(Arm64.UC_ARM64_REG_PSTATE, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Fpcr
|
public int Fpcr
|
||||||
{
|
{
|
||||||
get => (int)GetRegister(Arm64.UC_ARM64_REG_FPCR);
|
get => (int)GetRegister(Arm64.UC_ARM64_REG_FPCR);
|
||||||
set => SetRegister(Arm64.UC_ARM64_REG_FPCR, (uint)value);
|
set => SetRegister(Arm64.UC_ARM64_REG_FPCR, (uint)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Fpsr
|
public int Fpsr
|
||||||
{
|
{
|
||||||
get => (int)GetRegister(Arm64.UC_ARM64_REG_FPSR);
|
get => (int)GetRegister(Arm64.UC_ARM64_REG_FPSR);
|
||||||
set => SetRegister(Arm64.UC_ARM64_REG_FPSR, (uint)value);
|
set => SetRegister(Arm64.UC_ARM64_REG_FPSR, (uint)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OverflowFlag
|
public bool OverflowFlag
|
||||||
{
|
{
|
||||||
get => (Pstate & 0x10000000u) != 0;
|
get => (Pstate & 0x10000000u) != 0;
|
||||||
set => Pstate = (Pstate & ~0x10000000u) | (value ? 0x10000000u : 0u);
|
set => Pstate = (Pstate & ~0x10000000u) | (value ? 0x10000000u : 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CarryFlag
|
public bool CarryFlag
|
||||||
{
|
{
|
||||||
get => (Pstate & 0x20000000u) != 0;
|
get => (Pstate & 0x20000000u) != 0;
|
||||||
set => Pstate = (Pstate & ~0x20000000u) | (value ? 0x20000000u : 0u);
|
set => Pstate = (Pstate & ~0x20000000u) | (value ? 0x20000000u : 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ZeroFlag
|
public bool ZeroFlag
|
||||||
{
|
{
|
||||||
get => (Pstate & 0x40000000u) != 0;
|
get => (Pstate & 0x40000000u) != 0;
|
||||||
set => Pstate = (Pstate & ~0x40000000u) | (value ? 0x40000000u : 0u);
|
set => Pstate = (Pstate & ~0x40000000u) | (value ? 0x40000000u : 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool NegativeFlag
|
public bool NegativeFlag
|
||||||
{
|
{
|
||||||
get => (Pstate & 0x80000000u) != 0;
|
get => (Pstate & 0x80000000u) != 0;
|
||||||
set => Pstate = (Pstate & ~0x80000000u) | (value ? 0x80000000u : 0u);
|
set => Pstate = (Pstate & ~0x80000000u) | (value ? 0x80000000u : 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnicornAArch64()
|
public UnicornAArch64()
|
||||||
{
|
{
|
||||||
uc = new UnicornEngine.Unicorn(Common.UC_ARCH_ARM64, Common.UC_MODE_LITTLE_ENDIAN);
|
Uc = new UnicornEngine.Unicorn(Common.UC_ARCH_ARM64, Common.UC_MODE_LITTLE_ENDIAN);
|
||||||
|
|
||||||
SetRegister(Arm64.UC_ARM64_REG_CPACR_EL1, 0x00300000);
|
SetRegister(Arm64.UC_ARM64_REG_CPACR_EL1, 0x00300000);
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
if (!_isDisposed)
|
if (!_isDisposed)
|
||||||
{
|
{
|
||||||
uc.Close();
|
Uc.Close();
|
||||||
_isDisposed = true;
|
_isDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
public void RunForCount(ulong count)
|
public void RunForCount(ulong count)
|
||||||
{
|
{
|
||||||
// FIXME: untilAddr should be 0xFFFFFFFFFFFFFFFFul
|
// FIXME: untilAddr should be 0xFFFFFFFFFFFFFFFFul
|
||||||
uc.EmuStart((long)this.PC, -1, 0, (long)count);
|
Uc.EmuStart((long)this.PC, -1, 0, (long)count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Step()
|
public void Step()
|
||||||
@@ -110,7 +110,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
RunForCount(1);
|
RunForCount(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] XRegisters =
|
private static readonly int[] _xRegisters =
|
||||||
{
|
{
|
||||||
Arm64.UC_ARM64_REG_X0,
|
Arm64.UC_ARM64_REG_X0,
|
||||||
Arm64.UC_ARM64_REG_X1,
|
Arm64.UC_ARM64_REG_X1,
|
||||||
@@ -145,7 +145,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
Arm64.UC_ARM64_REG_X30,
|
Arm64.UC_ARM64_REG_X30,
|
||||||
};
|
};
|
||||||
|
|
||||||
private static int[] QRegisters =
|
private static readonly int[] _qRegisters =
|
||||||
{
|
{
|
||||||
Arm64.UC_ARM64_REG_Q0,
|
Arm64.UC_ARM64_REG_Q0,
|
||||||
Arm64.UC_ARM64_REG_Q1,
|
Arm64.UC_ARM64_REG_Q1,
|
||||||
@@ -188,7 +188,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetRegister(XRegisters[index]);
|
return GetRegister(_xRegisters[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetX(int index, ulong value)
|
public void SetX(int index, ulong value)
|
||||||
@@ -198,7 +198,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetRegister(XRegisters[index], value);
|
SetRegister(_xRegisters[index], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimdValue GetQ(int index)
|
public SimdValue GetQ(int index)
|
||||||
@@ -208,7 +208,7 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetVector(QRegisters[index]);
|
return GetVector(_qRegisters[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetQ(int index, SimdValue value)
|
public void SetQ(int index, SimdValue value)
|
||||||
@@ -218,14 +218,14 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetVector(QRegisters[index], value);
|
SetVector(_qRegisters[index], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong GetRegister(int register)
|
private ulong GetRegister(int register)
|
||||||
{
|
{
|
||||||
byte[] data = new byte[8];
|
byte[] data = new byte[8];
|
||||||
|
|
||||||
uc.RegRead(register, data);
|
Uc.RegRead(register, data);
|
||||||
|
|
||||||
return BitConverter.ToUInt64(data, 0);
|
return BitConverter.ToUInt64(data, 0);
|
||||||
}
|
}
|
||||||
@@ -234,14 +234,14 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
byte[] data = BitConverter.GetBytes(value);
|
byte[] data = BitConverter.GetBytes(value);
|
||||||
|
|
||||||
uc.RegWrite(register, data);
|
Uc.RegWrite(register, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SimdValue GetVector(int register)
|
private SimdValue GetVector(int register)
|
||||||
{
|
{
|
||||||
byte[] data = new byte[16];
|
byte[] data = new byte[16];
|
||||||
|
|
||||||
uc.RegRead(register, data);
|
Uc.RegRead(register, data);
|
||||||
|
|
||||||
return new SimdValue(data);
|
return new SimdValue(data);
|
||||||
}
|
}
|
||||||
@@ -250,49 +250,49 @@ namespace Ryujinx.Tests.Unicorn
|
|||||||
{
|
{
|
||||||
byte[] data = value.ToArray();
|
byte[] data = value.ToArray();
|
||||||
|
|
||||||
uc.RegWrite(register, data);
|
Uc.RegWrite(register, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] MemoryRead(ulong address, ulong size)
|
public byte[] MemoryRead(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
byte[] value = new byte[size];
|
byte[] value = new byte[size];
|
||||||
|
|
||||||
uc.MemRead((long)address, value);
|
Uc.MemRead((long)address, value);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte MemoryRead8 (ulong address) => MemoryRead(address, 1)[0];
|
public byte MemoryRead8(ulong address) => MemoryRead(address, 1)[0];
|
||||||
public ushort MemoryRead16(ulong address) => BitConverter.ToUInt16(MemoryRead(address, 2), 0);
|
public ushort MemoryRead16(ulong address) => BitConverter.ToUInt16(MemoryRead(address, 2), 0);
|
||||||
public uint MemoryRead32(ulong address) => BitConverter.ToUInt32(MemoryRead(address, 4), 0);
|
public uint MemoryRead32(ulong address) => BitConverter.ToUInt32(MemoryRead(address, 4), 0);
|
||||||
public ulong MemoryRead64(ulong address) => BitConverter.ToUInt64(MemoryRead(address, 8), 0);
|
public ulong MemoryRead64(ulong address) => BitConverter.ToUInt64(MemoryRead(address, 8), 0);
|
||||||
|
|
||||||
public void MemoryWrite(ulong address, byte[] value)
|
public void MemoryWrite(ulong address, byte[] value)
|
||||||
{
|
{
|
||||||
uc.MemWrite((long)address, value);
|
Uc.MemWrite((long)address, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MemoryWrite8 (ulong address, byte value) => MemoryWrite(address, new[]{ value });
|
public void MemoryWrite8(ulong address, byte value) => MemoryWrite(address, new[] { value });
|
||||||
public void MemoryWrite16(ulong address, short value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
public void MemoryWrite16(ulong address, short value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
||||||
public void MemoryWrite16(ulong address, ushort value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
public void MemoryWrite16(ulong address, ushort value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
||||||
public void MemoryWrite32(ulong address, int value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
public void MemoryWrite32(ulong address, int value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
||||||
public void MemoryWrite32(ulong address, uint value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
public void MemoryWrite32(ulong address, uint value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
||||||
public void MemoryWrite64(ulong address, long value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
public void MemoryWrite64(ulong address, long value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
||||||
public void MemoryWrite64(ulong address, ulong value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
public void MemoryWrite64(ulong address, ulong value) => MemoryWrite(address, BitConverter.GetBytes(value));
|
||||||
|
|
||||||
public void MemoryMap(ulong address, ulong size, MemoryPermission permissions)
|
public void MemoryMap(ulong address, ulong size, MemoryPermission permissions)
|
||||||
{
|
{
|
||||||
uc.MemMap((long)address, (long)size, (int)permissions);
|
Uc.MemMap((long)address, (long)size, (int)permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MemoryUnmap(ulong address, ulong size)
|
public void MemoryUnmap(ulong address, ulong size)
|
||||||
{
|
{
|
||||||
uc.MemUnmap((long)address, (long)size);
|
Uc.MemUnmap((long)address, (long)size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MemoryProtect(ulong address, ulong size, MemoryPermission permissions)
|
public void MemoryProtect(ulong address, ulong size, MemoryPermission permissions)
|
||||||
{
|
{
|
||||||
uc.MemProtect((long)address, (long)size, (int)permissions);
|
Uc.MemProtect((long)address, (long)size, (int)permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user