mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-22 23:55:47 +00:00
misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.
This commit is contained in:
parent
a09d314817
commit
dfb4854d19
172 changed files with 902 additions and 914 deletions
|
@ -127,13 +127,13 @@ namespace ARMeilleure.CodeGen.Arm64
|
||||||
#region macOS
|
#region macOS
|
||||||
|
|
||||||
[LibraryImport("libSystem.dylib", SetLastError = true)]
|
[LibraryImport("libSystem.dylib", SetLastError = true)]
|
||||||
private static unsafe partial int sysctlbyname([MarshalAs(UnmanagedType.LPStr)] string name, out int oldValue, ref ulong oldSize, IntPtr newValue, ulong newValueSize);
|
private static unsafe partial int sysctlbyname([MarshalAs(UnmanagedType.LPStr)] string name, out int oldValue, ref ulong oldSize, nint newValue, ulong newValueSize);
|
||||||
|
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
private static bool CheckSysctlName(string name)
|
private static bool CheckSysctlName(string name)
|
||||||
{
|
{
|
||||||
ulong size = sizeof(int);
|
ulong size = sizeof(int);
|
||||||
if (sysctlbyname(name, out int val, ref size, IntPtr.Zero, 0) == 0 && size == sizeof(int))
|
if (sysctlbyname(name, out int val, ref size, nint.Zero, 0) == 0 && size == sizeof(int))
|
||||||
{
|
{
|
||||||
return val != 0;
|
return val != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace ARMeilleure.CodeGen
|
||||||
/// <typeparam name="T">Type of delegate</typeparam>
|
/// <typeparam name="T">Type of delegate</typeparam>
|
||||||
/// <param name="codePointer">Pointer to the function code in memory</param>
|
/// <param name="codePointer">Pointer to the function code in memory</param>
|
||||||
/// <returns>A delegate of type <typeparamref name="T"/> pointing to the mapped function</returns>
|
/// <returns>A delegate of type <typeparamref name="T"/> pointing to the mapped function</returns>
|
||||||
public T MapWithPointer<T>(out IntPtr codePointer)
|
public T MapWithPointer<T>(out nint codePointer)
|
||||||
{
|
{
|
||||||
codePointer = JitCache.Map(this);
|
codePointer = JitCache.Map(this);
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine((IntPtr)_data);
|
return HashCode.Combine((nint)_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine((IntPtr)_data);
|
return HashCode.Combine((nint)_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace ARMeilleure.Common
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
private TEntry** _table;
|
private TEntry** _table;
|
||||||
private readonly List<IntPtr> _pages;
|
private readonly List<nint> _pages;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the bits used by the <see cref="Levels"/> of the <see cref="AddressTable{TEntry}"/> instance.
|
/// Gets the bits used by the <see cref="Levels"/> of the <see cref="AddressTable{TEntry}"/> instance.
|
||||||
|
@ -76,7 +76,7 @@ namespace ARMeilleure.Common
|
||||||
/// Gets the base address of the <see cref="EntryTable{TEntry}"/>.
|
/// Gets the base address of the <see cref="EntryTable{TEntry}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="EntryTable{TEntry}"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="EntryTable{TEntry}"/> instance was disposed</exception>
|
||||||
public IntPtr Base
|
public nint Base
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ namespace ARMeilleure.Common
|
||||||
|
|
||||||
lock (_pages)
|
lock (_pages)
|
||||||
{
|
{
|
||||||
return (IntPtr)GetRootPage();
|
return (nint)GetRootPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace ARMeilleure.Common
|
||||||
throw new ArgumentException("Table must be at least 2 levels deep.", nameof(levels));
|
throw new ArgumentException("Table must be at least 2 levels deep.", nameof(levels));
|
||||||
}
|
}
|
||||||
|
|
||||||
_pages = new List<IntPtr>(capacity: 16);
|
_pages = new List<nint>(capacity: 16);
|
||||||
|
|
||||||
Levels = levels;
|
Levels = levels;
|
||||||
Mask = 0;
|
Mask = 0;
|
||||||
|
@ -168,7 +168,7 @@ namespace ARMeilleure.Common
|
||||||
|
|
||||||
nextPage = i == Levels.Length - 2 ?
|
nextPage = i == Levels.Length - 2 ?
|
||||||
(TEntry*)Allocate(1 << nextLevel.Length, Fill, leaf: true) :
|
(TEntry*)Allocate(1 << nextLevel.Length, Fill, leaf: true) :
|
||||||
(TEntry*)Allocate(1 << nextLevel.Length, IntPtr.Zero, leaf: false);
|
(TEntry*)Allocate(1 << nextLevel.Length, nint.Zero, leaf: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
page = (TEntry**)nextPage;
|
page = (TEntry**)nextPage;
|
||||||
|
@ -185,7 +185,7 @@ namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
if (_table == null)
|
if (_table == null)
|
||||||
{
|
{
|
||||||
_table = (TEntry**)Allocate(1 << Levels[0].Length, fill: IntPtr.Zero, leaf: false);
|
_table = (TEntry**)Allocate(1 << Levels[0].Length, fill: nint.Zero, leaf: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _table;
|
return _table;
|
||||||
|
@ -199,10 +199,10 @@ namespace ARMeilleure.Common
|
||||||
/// <param name="fill">Fill value</param>
|
/// <param name="fill">Fill value</param>
|
||||||
/// <param name="leaf"><see langword="true"/> if leaf; otherwise <see langword="false"/></param>
|
/// <param name="leaf"><see langword="true"/> if leaf; otherwise <see langword="false"/></param>
|
||||||
/// <returns>Allocated block</returns>
|
/// <returns>Allocated block</returns>
|
||||||
private IntPtr Allocate<T>(int length, T fill, bool leaf) where T : unmanaged
|
private nint Allocate<T>(int length, T fill, bool leaf) where T : unmanaged
|
||||||
{
|
{
|
||||||
var size = sizeof(T) * length;
|
var size = sizeof(T) * length;
|
||||||
var page = (IntPtr)NativeAllocator.Instance.Allocate((uint)size);
|
var page = (nint)NativeAllocator.Instance.Allocate((uint)size);
|
||||||
var span = new Span<T>((void*)page, length);
|
var span = new Span<T>((void*)page, length);
|
||||||
|
|
||||||
span.Fill(fill);
|
span.Fill(fill);
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace ARMeilleure.Common
|
||||||
private List<PageInfo> _pages;
|
private List<PageInfo> _pages;
|
||||||
private readonly ulong _pageSize;
|
private readonly ulong _pageSize;
|
||||||
private readonly uint _pageCount;
|
private readonly uint _pageCount;
|
||||||
private readonly List<IntPtr> _extras;
|
private readonly List<nint> _extras;
|
||||||
|
|
||||||
public ArenaAllocator(uint pageSize, uint pageCount)
|
public ArenaAllocator(uint pageSize, uint pageCount)
|
||||||
{
|
{
|
||||||
|
@ -31,11 +31,11 @@ namespace ARMeilleure.Common
|
||||||
_pageIndex = -1;
|
_pageIndex = -1;
|
||||||
|
|
||||||
_page = null;
|
_page = null;
|
||||||
_pages = new List<PageInfo>();
|
_pages = [];
|
||||||
_pageSize = pageSize;
|
_pageSize = pageSize;
|
||||||
_pageCount = pageCount;
|
_pageCount = pageCount;
|
||||||
|
|
||||||
_extras = new List<IntPtr>();
|
_extras = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Span<T> AllocateSpan<T>(ulong count) where T : unmanaged
|
public Span<T> AllocateSpan<T>(ulong count) where T : unmanaged
|
||||||
|
@ -64,7 +64,7 @@ namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
void* extra = NativeAllocator.Instance.Allocate(size);
|
void* extra = NativeAllocator.Instance.Allocate(size);
|
||||||
|
|
||||||
_extras.Add((IntPtr)extra);
|
_extras.Add((nint)extra);
|
||||||
|
|
||||||
return extra;
|
return extra;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
_page = new PageInfo
|
_page = new PageInfo
|
||||||
{
|
{
|
||||||
Pointer = (byte*)NativeAllocator.Instance.Allocate(_pageSize),
|
Pointer = (byte*)NativeAllocator.Instance.Allocate(_pageSize)
|
||||||
};
|
};
|
||||||
|
|
||||||
_pages.Add(_page);
|
_pages.Add(_page);
|
||||||
|
@ -114,7 +114,7 @@ namespace ARMeilleure.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free extra blocks that are not page-sized
|
// Free extra blocks that are not page-sized
|
||||||
foreach (IntPtr ptr in _extras)
|
foreach (nint ptr in _extras)
|
||||||
{
|
{
|
||||||
NativeAllocator.Instance.Free((void*)ptr);
|
NativeAllocator.Instance.Free((void*)ptr);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ namespace ARMeilleure.Common
|
||||||
NativeAllocator.Instance.Free(info.Pointer);
|
NativeAllocator.Instance.Free(info.Pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (IntPtr ptr in _extras)
|
foreach (nint ptr in _extras)
|
||||||
{
|
{
|
||||||
NativeAllocator.Instance.Free((void*)ptr);
|
NativeAllocator.Instance.Free((void*)ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace ARMeilleure.Common
|
||||||
private int _freeHint;
|
private int _freeHint;
|
||||||
private readonly int _pageCapacity; // Number of entries per page.
|
private readonly int _pageCapacity; // Number of entries per page.
|
||||||
private readonly int _pageLogCapacity;
|
private readonly int _pageLogCapacity;
|
||||||
private readonly Dictionary<int, IntPtr> _pages;
|
private readonly Dictionary<int, nint> _pages;
|
||||||
private readonly BitMap _allocated;
|
private readonly BitMap _allocated;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -41,7 +41,7 @@ namespace ARMeilleure.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
_allocated = new BitMap(NativeAllocator.Instance);
|
_allocated = new BitMap(NativeAllocator.Instance);
|
||||||
_pages = new Dictionary<int, IntPtr>();
|
_pages = new Dictionary<int, nint>();
|
||||||
_pageLogCapacity = BitOperations.Log2((uint)(pageSize / sizeof(TEntry)));
|
_pageLogCapacity = BitOperations.Log2((uint)(pageSize / sizeof(TEntry)));
|
||||||
_pageCapacity = 1 << _pageLogCapacity;
|
_pageCapacity = 1 << _pageLogCapacity;
|
||||||
}
|
}
|
||||||
|
@ -138,9 +138,9 @@ namespace ARMeilleure.Common
|
||||||
{
|
{
|
||||||
var pageIndex = (int)((uint)(index & ~(_pageCapacity - 1)) >> _pageLogCapacity);
|
var pageIndex = (int)((uint)(index & ~(_pageCapacity - 1)) >> _pageLogCapacity);
|
||||||
|
|
||||||
if (!_pages.TryGetValue(pageIndex, out IntPtr page))
|
if (!_pages.TryGetValue(pageIndex, out nint page))
|
||||||
{
|
{
|
||||||
page = (IntPtr)NativeAllocator.Instance.Allocate((uint)sizeof(TEntry) * (uint)_pageCapacity);
|
page = (nint)NativeAllocator.Instance.Allocate((uint)sizeof(TEntry) * (uint)_pageCapacity);
|
||||||
|
|
||||||
_pages.Add(pageIndex, page);
|
_pages.Add(pageIndex, page);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ARMeilleure.Common
|
||||||
|
|
||||||
public override void* Allocate(ulong size)
|
public override void* Allocate(ulong size)
|
||||||
{
|
{
|
||||||
void* result = (void*)Marshal.AllocHGlobal((IntPtr)size);
|
void* result = (void*)Marshal.AllocHGlobal((nint)size);
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ namespace ARMeilleure.Common
|
||||||
|
|
||||||
public override void Free(void* block)
|
public override void Free(void* block)
|
||||||
{
|
{
|
||||||
Marshal.FreeHGlobal((IntPtr)block);
|
Marshal.FreeHGlobal((nint)block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
||||||
/// <exception cref="ArgumentException"><typeparamref name="T"/> is not pointer sized.</exception>
|
/// <exception cref="ArgumentException"><typeparamref name="T"/> is not pointer sized.</exception>
|
||||||
public IntrusiveList()
|
public IntrusiveList()
|
||||||
{
|
{
|
||||||
if (Unsafe.SizeOf<T>() != IntPtr.Size)
|
if (Unsafe.SizeOf<T>() != nint.Size)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("T must be a reference type or a pointer sized struct.");
|
throw new ArgumentException("T must be a reference type or a pointer sized struct.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
||||||
{
|
{
|
||||||
Debug.Assert(operand.Kind == OperandKind.Memory);
|
Debug.Assert(operand.Kind == OperandKind.Memory);
|
||||||
|
|
||||||
_data = (Data*)Unsafe.As<Operand, IntPtr>(ref operand);
|
_data = (Data*)Unsafe.As<Operand, nint>(ref operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Operand BaseAddress
|
public Operand BaseAddress
|
||||||
|
|
|
@ -228,7 +228,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
||||||
|
|
||||||
public readonly override int GetHashCode()
|
public readonly override int GetHashCode()
|
||||||
{
|
{
|
||||||
return HashCode.Combine((IntPtr)_data);
|
return HashCode.Combine((nint)_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(Operation a, Operation b)
|
public static bool operator ==(Operation a, Operation b)
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace ARMeilleure.Memory
|
||||||
{
|
{
|
||||||
public interface IJitMemoryBlock : IDisposable
|
public interface IJitMemoryBlock : IDisposable
|
||||||
{
|
{
|
||||||
IntPtr Pointer { get; }
|
nint Pointer { get; }
|
||||||
|
|
||||||
void Commit(ulong offset, ulong size);
|
void Commit(ulong offset, ulong size);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ARMeilleure.Memory
|
||||||
{
|
{
|
||||||
int AddressSpaceBits { get; }
|
int AddressSpaceBits { get; }
|
||||||
|
|
||||||
IntPtr PageTablePointer { get; }
|
nint PageTablePointer { get; }
|
||||||
|
|
||||||
MemoryManagerType Type { get; }
|
MemoryManagerType Type { get; }
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ARMeilleure.Memory
|
||||||
|
|
||||||
public IJitMemoryBlock Block { get; }
|
public IJitMemoryBlock Block { get; }
|
||||||
|
|
||||||
public IntPtr Pointer => Block.Pointer;
|
public nint Pointer => Block.Pointer;
|
||||||
|
|
||||||
private readonly ulong _maxSize;
|
private readonly ulong _maxSize;
|
||||||
private readonly ulong _sizeGranularity;
|
private readonly ulong _sizeGranularity;
|
||||||
|
|
|
@ -8,6 +8,6 @@ namespace ARMeilleure.Native
|
||||||
static partial class JitSupportDarwin
|
static partial class JitSupportDarwin
|
||||||
{
|
{
|
||||||
[LibraryImport("libarmeilleure-jitsupport", EntryPoint = "armeilleure_jit_memcpy")]
|
[LibraryImport("libarmeilleure-jitsupport", EntryPoint = "armeilleure_jit_memcpy")]
|
||||||
public static partial void Copy(IntPtr dst, IntPtr src, ulong n);
|
public static partial void Copy(nint dst, nint src, ulong n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace ARMeilleure.Signal
|
||||||
|
|
||||||
private const uint EXCEPTION_ACCESS_VIOLATION = 0xc0000005;
|
private const uint EXCEPTION_ACCESS_VIOLATION = 0xc0000005;
|
||||||
|
|
||||||
private static Operand EmitGenericRegionCheck(EmitterContext context, IntPtr signalStructPtr, Operand faultAddress, Operand isWrite, int rangeStructSize)
|
private static Operand EmitGenericRegionCheck(EmitterContext context, nint signalStructPtr, Operand faultAddress, Operand isWrite, int rangeStructSize)
|
||||||
{
|
{
|
||||||
Operand inRegionLocal = context.AllocateLocal(OperandType.I32);
|
Operand inRegionLocal = context.AllocateLocal(OperandType.I32);
|
||||||
context.Copy(inRegionLocal, Const(0));
|
context.Copy(inRegionLocal, Const(0));
|
||||||
|
@ -155,7 +155,7 @@ namespace ARMeilleure.Signal
|
||||||
throw new PlatformNotSupportedException();
|
throw new PlatformNotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] GenerateUnixSignalHandler(IntPtr signalStructPtr, int rangeStructSize)
|
public static byte[] GenerateUnixSignalHandler(nint signalStructPtr, int rangeStructSize)
|
||||||
{
|
{
|
||||||
EmitterContext context = new();
|
EmitterContext context = new();
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ namespace ARMeilleure.Signal
|
||||||
return Compiler.Compile(cfg, argTypes, OperandType.None, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Code;
|
return Compiler.Compile(cfg, argTypes, OperandType.None, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] GenerateWindowsSignalHandler(IntPtr signalStructPtr, int rangeStructSize)
|
public static byte[] GenerateWindowsSignalHandler(nint signalStructPtr, int rangeStructSize)
|
||||||
{
|
{
|
||||||
EmitterContext context = new();
|
EmitterContext context = new();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ARMeilleure.Signal
|
||||||
{
|
{
|
||||||
public delegate bool DebugPartialUnmap();
|
public delegate bool DebugPartialUnmap();
|
||||||
public delegate int DebugThreadLocalMapGetOrReserve(int threadId, int initialState);
|
public delegate int DebugThreadLocalMapGetOrReserve(int threadId, int initialState);
|
||||||
public delegate void DebugNativeWriteLoop(IntPtr nativeWriteLoopPtr, IntPtr writePtr);
|
public delegate void DebugNativeWriteLoop(nint nativeWriteLoopPtr, nint writePtr);
|
||||||
|
|
||||||
public static DebugPartialUnmap GenerateDebugPartialUnmap()
|
public static DebugPartialUnmap GenerateDebugPartialUnmap()
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ namespace ARMeilleure.Signal
|
||||||
return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<DebugPartialUnmap>();
|
return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<DebugPartialUnmap>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DebugThreadLocalMapGetOrReserve GenerateDebugThreadLocalMapGetOrReserve(IntPtr structPtr)
|
public static DebugThreadLocalMapGetOrReserve GenerateDebugThreadLocalMapGetOrReserve(nint structPtr)
|
||||||
{
|
{
|
||||||
EmitterContext context = new();
|
EmitterContext context = new();
|
||||||
|
|
||||||
|
|
|
@ -13,18 +13,18 @@ namespace ARMeilleure.Signal
|
||||||
internal static partial class WindowsPartialUnmapHandler
|
internal static partial class WindowsPartialUnmapHandler
|
||||||
{
|
{
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true, EntryPoint = "LoadLibraryA")]
|
[LibraryImport("kernel32.dll", SetLastError = true, EntryPoint = "LoadLibraryA")]
|
||||||
private static partial IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
|
private static partial nint LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
|
||||||
|
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
private static partial IntPtr GetProcAddress(IntPtr hModule, [MarshalAs(UnmanagedType.LPStr)] string procName);
|
private static partial nint GetProcAddress(nint hModule, [MarshalAs(UnmanagedType.LPStr)] string procName);
|
||||||
|
|
||||||
private static IntPtr _getCurrentThreadIdPtr;
|
private static nint _getCurrentThreadIdPtr;
|
||||||
|
|
||||||
public static IntPtr GetCurrentThreadIdFunc()
|
public static nint GetCurrentThreadIdFunc()
|
||||||
{
|
{
|
||||||
if (_getCurrentThreadIdPtr == IntPtr.Zero)
|
if (_getCurrentThreadIdPtr == nint.Zero)
|
||||||
{
|
{
|
||||||
IntPtr handle = LoadLibrary("kernel32.dll");
|
nint handle = LoadLibrary("kernel32.dll");
|
||||||
|
|
||||||
_getCurrentThreadIdPtr = GetProcAddress(handle, "GetCurrentThreadId");
|
_getCurrentThreadIdPtr = GetProcAddress(handle, "GetCurrentThreadId");
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,13 @@ namespace ARMeilleure.Signal
|
||||||
|
|
||||||
public static Operand EmitRetryFromAccessViolation(EmitterContext context)
|
public static Operand EmitRetryFromAccessViolation(EmitterContext context)
|
||||||
{
|
{
|
||||||
IntPtr partialRemapStatePtr = PartialUnmapState.GlobalState;
|
nint partialRemapStatePtr = PartialUnmapState.GlobalState;
|
||||||
IntPtr localCountsPtr = IntPtr.Add(partialRemapStatePtr, PartialUnmapState.LocalCountsOffset);
|
nint localCountsPtr = nint.Add(partialRemapStatePtr, PartialUnmapState.LocalCountsOffset);
|
||||||
|
|
||||||
// Get the lock first.
|
// Get the lock first.
|
||||||
EmitNativeReaderLockAcquire(context, IntPtr.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapLockOffset));
|
EmitNativeReaderLockAcquire(context, nint.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapLockOffset));
|
||||||
|
|
||||||
IntPtr getCurrentThreadId = GetCurrentThreadIdFunc();
|
nint getCurrentThreadId = GetCurrentThreadIdFunc();
|
||||||
Operand threadId = context.Call(Const((ulong)getCurrentThreadId), OperandType.I32);
|
Operand threadId = context.Call(Const((ulong)getCurrentThreadId), OperandType.I32);
|
||||||
Operand threadIndex = EmitThreadLocalMapIntGetOrReserve(context, localCountsPtr, threadId, Const(0));
|
Operand threadIndex = EmitThreadLocalMapIntGetOrReserve(context, localCountsPtr, threadId, Const(0));
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace ARMeilleure.Signal
|
||||||
|
|
||||||
Operand threadLocalPartialUnmapsPtr = EmitThreadLocalMapIntGetValuePtr(context, localCountsPtr, threadIndex);
|
Operand threadLocalPartialUnmapsPtr = EmitThreadLocalMapIntGetValuePtr(context, localCountsPtr, threadIndex);
|
||||||
Operand threadLocalPartialUnmaps = context.Load(OperandType.I32, threadLocalPartialUnmapsPtr);
|
Operand threadLocalPartialUnmaps = context.Load(OperandType.I32, threadLocalPartialUnmapsPtr);
|
||||||
Operand partialUnmapsCount = context.Load(OperandType.I32, Const((ulong)IntPtr.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapsCountOffset)));
|
Operand partialUnmapsCount = context.Load(OperandType.I32, Const((ulong)nint.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapsCountOffset)));
|
||||||
|
|
||||||
context.Copy(retry, context.ICompareNotEqual(threadLocalPartialUnmaps, partialUnmapsCount));
|
context.Copy(retry, context.ICompareNotEqual(threadLocalPartialUnmaps, partialUnmapsCount));
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ namespace ARMeilleure.Signal
|
||||||
context.MarkLabel(endLabel);
|
context.MarkLabel(endLabel);
|
||||||
|
|
||||||
// Finally, release the lock and return the retry value.
|
// Finally, release the lock and return the retry value.
|
||||||
EmitNativeReaderLockRelease(context, IntPtr.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapLockOffset));
|
EmitNativeReaderLockRelease(context, nint.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapLockOffset));
|
||||||
|
|
||||||
return retry;
|
return retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Operand EmitThreadLocalMapIntGetOrReserve(EmitterContext context, IntPtr threadLocalMapPtr, Operand threadId, Operand initialState)
|
public static Operand EmitThreadLocalMapIntGetOrReserve(EmitterContext context, nint threadLocalMapPtr, Operand threadId, Operand initialState)
|
||||||
{
|
{
|
||||||
Operand idsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.ThreadIdsOffset));
|
Operand idsPtr = Const((ulong)nint.Add(threadLocalMapPtr, ThreadLocalMap<int>.ThreadIdsOffset));
|
||||||
|
|
||||||
Operand i = context.AllocateLocal(OperandType.I32);
|
Operand i = context.AllocateLocal(OperandType.I32);
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ namespace ARMeilleure.Signal
|
||||||
// If it was 0, then we need to initialize the struct entry and return i.
|
// If it was 0, then we need to initialize the struct entry and return i.
|
||||||
context.BranchIfFalse(idNot0Label, context.ICompareEqual(existingId2, Const(0)));
|
context.BranchIfFalse(idNot0Label, context.ICompareEqual(existingId2, Const(0)));
|
||||||
|
|
||||||
Operand structsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.StructsOffset));
|
Operand structsPtr = Const((ulong)nint.Add(threadLocalMapPtr, ThreadLocalMap<int>.StructsOffset));
|
||||||
Operand structPtr = context.Add(structsPtr, context.SignExtend32(OperandType.I64, offset2));
|
Operand structPtr = context.Add(structsPtr, context.SignExtend32(OperandType.I64, offset2));
|
||||||
context.Store(structPtr, initialState);
|
context.Store(structPtr, initialState);
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ namespace ARMeilleure.Signal
|
||||||
return context.Copy(i);
|
return context.Copy(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Operand EmitThreadLocalMapIntGetValuePtr(EmitterContext context, IntPtr threadLocalMapPtr, Operand index)
|
private static Operand EmitThreadLocalMapIntGetValuePtr(EmitterContext context, nint threadLocalMapPtr, Operand index)
|
||||||
{
|
{
|
||||||
Operand offset = context.Multiply(index, Const(sizeof(int)));
|
Operand offset = context.Multiply(index, Const(sizeof(int)));
|
||||||
Operand structsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.StructsOffset));
|
Operand structsPtr = Const((ulong)nint.Add(threadLocalMapPtr, ThreadLocalMap<int>.StructsOffset));
|
||||||
|
|
||||||
return context.Add(structsPtr, context.SignExtend32(OperandType.I64, offset));
|
return context.Add(structsPtr, context.SignExtend32(OperandType.I64, offset));
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,9 @@ namespace ARMeilleure.Signal
|
||||||
context.BranchIfFalse(loop, context.ICompareEqual(initial, replaced));
|
context.BranchIfFalse(loop, context.ICompareEqual(initial, replaced));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EmitNativeReaderLockAcquire(EmitterContext context, IntPtr nativeReaderLockPtr)
|
private static void EmitNativeReaderLockAcquire(EmitterContext context, nint nativeReaderLockPtr)
|
||||||
{
|
{
|
||||||
Operand writeLockPtr = Const((ulong)IntPtr.Add(nativeReaderLockPtr, NativeReaderWriterLock.WriteLockOffset));
|
Operand writeLockPtr = Const((ulong)nint.Add(nativeReaderLockPtr, NativeReaderWriterLock.WriteLockOffset));
|
||||||
|
|
||||||
// Spin until we can acquire the write lock.
|
// Spin until we can acquire the write lock.
|
||||||
Operand spinLabel = Label();
|
Operand spinLabel = Label();
|
||||||
|
@ -182,16 +182,16 @@ namespace ARMeilleure.Signal
|
||||||
context.BranchIfTrue(spinLabel, context.CompareAndSwap(writeLockPtr, Const(0), Const(1)));
|
context.BranchIfTrue(spinLabel, context.CompareAndSwap(writeLockPtr, Const(0), Const(1)));
|
||||||
|
|
||||||
// Increment reader count.
|
// Increment reader count.
|
||||||
EmitAtomicAddI32(context, Const((ulong)IntPtr.Add(nativeReaderLockPtr, NativeReaderWriterLock.ReaderCountOffset)), Const(1));
|
EmitAtomicAddI32(context, Const((ulong)nint.Add(nativeReaderLockPtr, NativeReaderWriterLock.ReaderCountOffset)), Const(1));
|
||||||
|
|
||||||
// Release write lock.
|
// Release write lock.
|
||||||
context.CompareAndSwap(writeLockPtr, Const(1), Const(0));
|
context.CompareAndSwap(writeLockPtr, Const(1), Const(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EmitNativeReaderLockRelease(EmitterContext context, IntPtr nativeReaderLockPtr)
|
private static void EmitNativeReaderLockRelease(EmitterContext context, nint nativeReaderLockPtr)
|
||||||
{
|
{
|
||||||
// Decrement reader count.
|
// Decrement reader count.
|
||||||
EmitAtomicAddI32(context, Const((ulong)IntPtr.Add(nativeReaderLockPtr, NativeReaderWriterLock.ReaderCountOffset)), Const(-1));
|
EmitAtomicAddI32(context, Const((ulong)nint.Add(nativeReaderLockPtr, NativeReaderWriterLock.ReaderCountOffset)), Const(-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ARMeilleure.State
|
||||||
|
|
||||||
private readonly NativeContext _nativeContext;
|
private readonly NativeContext _nativeContext;
|
||||||
|
|
||||||
internal IntPtr NativeContextPtr => _nativeContext.BasePtr;
|
internal nint NativeContextPtr => _nativeContext.BasePtr;
|
||||||
|
|
||||||
private bool _interrupted;
|
private bool _interrupted;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace ARMeilleure.State
|
||||||
|
|
||||||
private readonly IJitMemoryBlock _block;
|
private readonly IJitMemoryBlock _block;
|
||||||
|
|
||||||
public IntPtr BasePtr => _block.Pointer;
|
public nint BasePtr => _block.Pointer;
|
||||||
|
|
||||||
public NativeContext(IJitMemoryAllocator allocator)
|
public NativeContext(IJitMemoryAllocator allocator)
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace ARMeilleure.Translation
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int index = Delegates.GetDelegateIndex(info);
|
int index = Delegates.GetDelegateIndex(info);
|
||||||
IntPtr funcPtr = Delegates.GetDelegateFuncPtrByIndex(index);
|
nint funcPtr = Delegates.GetDelegateFuncPtrByIndex(index);
|
||||||
|
|
||||||
OperandType returnType = GetOperandType(info.ReturnType);
|
OperandType returnType = GetOperandType(info.ReturnType);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
public static partial IntPtr FlushInstructionCache(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize);
|
public static partial nint FlushInstructionCache(nint hProcess, nint lpAddress, nuint dwSize);
|
||||||
|
|
||||||
public static void Initialize(IJitMemoryAllocator allocator)
|
public static void Initialize(IJitMemoryAllocator allocator)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr Map(CompiledFunction func)
|
public static nint Map(CompiledFunction func)
|
||||||
{
|
{
|
||||||
byte[] code = func.Code;
|
byte[] code = func.Code;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
|
|
||||||
int funcOffset = Allocate(code.Length);
|
int funcOffset = Allocate(code.Length);
|
||||||
|
|
||||||
IntPtr funcPtr = _jitRegion.Pointer + funcOffset;
|
nint funcPtr = _jitRegion.Pointer + funcOffset;
|
||||||
|
|
||||||
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
{
|
{
|
||||||
fixed (byte* codePtr = code)
|
fixed (byte* codePtr = code)
|
||||||
{
|
{
|
||||||
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length);
|
JitSupportDarwin.Copy(funcPtr, (nint)codePtr, (ulong)code.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||||
{
|
{
|
||||||
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (UIntPtr)code.Length);
|
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (nuint)code.Length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Unmap(IntPtr pointer)
|
public static void Unmap(nint pointer)
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invalidate(IntPtr basePointer, ulong size)
|
public void Invalidate(nint basePointer, ulong size)
|
||||||
{
|
{
|
||||||
if (_needsInvalidation)
|
if (_needsInvalidation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
PushMachframe = 10,
|
PushMachframe = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe delegate RuntimeFunction* GetRuntimeFunctionCallback(ulong controlPc, IntPtr context);
|
private unsafe delegate RuntimeFunction* GetRuntimeFunctionCallback(ulong controlPc, nint context);
|
||||||
|
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
@ -49,7 +49,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
ulong baseAddress,
|
ulong baseAddress,
|
||||||
uint length,
|
uint length,
|
||||||
GetRuntimeFunctionCallback callback,
|
GetRuntimeFunctionCallback callback,
|
||||||
IntPtr context,
|
nint context,
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string outOfProcessCallbackDll);
|
[MarshalAs(UnmanagedType.LPWStr)] string outOfProcessCallbackDll);
|
||||||
|
|
||||||
private static GetRuntimeFunctionCallback _getRuntimeFunctionCallback;
|
private static GetRuntimeFunctionCallback _getRuntimeFunctionCallback;
|
||||||
|
@ -60,7 +60,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
|
|
||||||
private unsafe static UnwindInfo* _unwindInfo;
|
private unsafe static UnwindInfo* _unwindInfo;
|
||||||
|
|
||||||
public static void InstallFunctionTableHandler(IntPtr codeCachePointer, uint codeCacheLength, IntPtr workBufferPtr)
|
public static void InstallFunctionTableHandler(nint codeCachePointer, uint codeCacheLength, nint workBufferPtr)
|
||||||
{
|
{
|
||||||
ulong codeCachePtr = (ulong)codeCachePointer.ToInt64();
|
ulong codeCachePtr = (ulong)codeCachePointer.ToInt64();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static unsafe RuntimeFunction* FunctionTableHandler(ulong controlPc, IntPtr context)
|
private static unsafe RuntimeFunction* FunctionTableHandler(ulong controlPc, nint context)
|
||||||
{
|
{
|
||||||
int offset = (int)((long)controlPc - context.ToInt64());
|
int offset = (int)((long)controlPc - context.ToInt64());
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@ namespace ARMeilleure.Translation
|
||||||
private readonly Delegate _dlg; // Ensure that this delegate will not be garbage collected.
|
private readonly Delegate _dlg; // Ensure that this delegate will not be garbage collected.
|
||||||
#pragma warning restore IDE0052
|
#pragma warning restore IDE0052
|
||||||
|
|
||||||
public IntPtr FuncPtr { get; }
|
public nint FuncPtr { get; }
|
||||||
|
|
||||||
public DelegateInfo(Delegate dlg, IntPtr funcPtr)
|
public DelegateInfo(Delegate dlg, nint funcPtr)
|
||||||
{
|
{
|
||||||
_dlg = dlg;
|
_dlg = dlg;
|
||||||
FuncPtr = funcPtr;
|
FuncPtr = funcPtr;
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
static class Delegates
|
static class Delegates
|
||||||
{
|
{
|
||||||
public static bool TryGetDelegateFuncPtrByIndex(int index, out IntPtr funcPtr)
|
public static bool TryGetDelegateFuncPtrByIndex(int index, out nint funcPtr)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < _delegates.Count)
|
if (index >= 0 && index < _delegates.Count)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ namespace ARMeilleure.Translation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr GetDelegateFuncPtrByIndex(int index)
|
public static nint GetDelegateFuncPtrByIndex(int index)
|
||||||
{
|
{
|
||||||
if (index < 0 || index >= _delegates.Count)
|
if (index < 0 || index >= _delegates.Count)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ namespace ARMeilleure.Translation
|
||||||
return _delegates.Values[index].FuncPtr; // O(1).
|
return _delegates.Values[index].FuncPtr; // O(1).
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr GetDelegateFuncPtr(MethodInfo info)
|
public static nint GetDelegateFuncPtr(MethodInfo info)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(info);
|
ArgumentNullException.ThrowIfNull(info);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace ARMeilleure.Translation
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetDelegateInfo(Delegate dlg, IntPtr funcPtr)
|
private static void SetDelegateInfo(Delegate dlg, nint funcPtr)
|
||||||
{
|
{
|
||||||
string key = GetKey(dlg.Method);
|
string key = GetKey(dlg.Method);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,6 @@ using System;
|
||||||
|
|
||||||
namespace ARMeilleure.Translation
|
namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
delegate void DispatcherFunction(IntPtr nativeContext, ulong startAddress);
|
delegate void DispatcherFunction(nint nativeContext, ulong startAddress);
|
||||||
delegate ulong WrapperFunction(IntPtr nativeContext, ulong startAddress);
|
delegate ulong WrapperFunction(nint nativeContext, ulong startAddress);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace ARMeilleure.Translation
|
||||||
|
|
||||||
public virtual Operand Call(MethodInfo info, params Operand[] callArgs)
|
public virtual Operand Call(MethodInfo info, params Operand[] callArgs)
|
||||||
{
|
{
|
||||||
IntPtr funcPtr = Delegates.GetDelegateFuncPtr(info);
|
nint funcPtr = Delegates.GetDelegateFuncPtr(info);
|
||||||
|
|
||||||
OperandType returnType = GetOperandType(info.ReturnType);
|
OperandType returnType = GetOperandType(info.ReturnType);
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@ using System;
|
||||||
|
|
||||||
namespace ARMeilleure.Translation
|
namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
delegate ulong GuestFunction(IntPtr nativeContextPtr);
|
delegate ulong GuestFunction(nint nativeContextPtr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,11 +268,11 @@ namespace ARMeilleure.Translation.PTC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr intPtr = IntPtr.Zero;
|
nint intPtr = nint.Zero;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
intPtr = Marshal.AllocHGlobal(new IntPtr(outerHeader.UncompressedStreamSize));
|
intPtr = Marshal.AllocHGlobal(new nint(outerHeader.UncompressedStreamSize));
|
||||||
|
|
||||||
using UnmanagedMemoryStream stream = new((byte*)intPtr.ToPointer(), outerHeader.UncompressedStreamSize, outerHeader.UncompressedStreamSize, FileAccess.ReadWrite);
|
using UnmanagedMemoryStream stream = new((byte*)intPtr.ToPointer(), outerHeader.UncompressedStreamSize, outerHeader.UncompressedStreamSize, FileAccess.ReadWrite);
|
||||||
try
|
try
|
||||||
|
@ -373,7 +373,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (intPtr != IntPtr.Zero)
|
if (intPtr != nint.Zero)
|
||||||
{
|
{
|
||||||
Marshal.FreeHGlobal(intPtr);
|
Marshal.FreeHGlobal(intPtr);
|
||||||
}
|
}
|
||||||
|
@ -455,11 +455,11 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
outerHeader.SetHeaderHash();
|
outerHeader.SetHeaderHash();
|
||||||
|
|
||||||
IntPtr intPtr = IntPtr.Zero;
|
nint intPtr = nint.Zero;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
intPtr = Marshal.AllocHGlobal(new IntPtr(outerHeader.UncompressedStreamSize));
|
intPtr = Marshal.AllocHGlobal(new nint(outerHeader.UncompressedStreamSize));
|
||||||
|
|
||||||
using UnmanagedMemoryStream stream = new((byte*)intPtr.ToPointer(), outerHeader.UncompressedStreamSize, outerHeader.UncompressedStreamSize, FileAccess.ReadWrite);
|
using UnmanagedMemoryStream stream = new((byte*)intPtr.ToPointer(), outerHeader.UncompressedStreamSize, outerHeader.UncompressedStreamSize, FileAccess.ReadWrite);
|
||||||
stream.Seek((long)Unsafe.SizeOf<InnerHeader>(), SeekOrigin.Begin);
|
stream.Seek((long)Unsafe.SizeOf<InnerHeader>(), SeekOrigin.Begin);
|
||||||
|
@ -513,7 +513,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (intPtr != IntPtr.Zero)
|
if (intPtr != nint.Zero)
|
||||||
{
|
{
|
||||||
Marshal.FreeHGlobal(intPtr);
|
Marshal.FreeHGlobal(intPtr);
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
foreach (RelocEntry relocEntry in relocEntries)
|
foreach (RelocEntry relocEntry in relocEntries)
|
||||||
{
|
{
|
||||||
IntPtr? imm = null;
|
nint? imm = null;
|
||||||
Symbol symbol = relocEntry.Symbol;
|
Symbol symbol = relocEntry.Symbol;
|
||||||
|
|
||||||
if (symbol.Type == SymbolType.FunctionTable)
|
if (symbol.Type == SymbolType.FunctionTable)
|
||||||
|
@ -675,7 +675,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
imm = (IntPtr)Unsafe.AsPointer(ref translator.FunctionTable.GetValue(guestAddress));
|
imm = (nint)Unsafe.AsPointer(ref translator.FunctionTable.GetValue(guestAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
{
|
{
|
||||||
int index = (int)symbol.Value;
|
int index = (int)symbol.Value;
|
||||||
|
|
||||||
if (Delegates.TryGetDelegateFuncPtrByIndex(index, out IntPtr funcPtr))
|
if (Delegates.TryGetDelegateFuncPtrByIndex(index, out nint funcPtr))
|
||||||
{
|
{
|
||||||
imm = funcPtr;
|
imm = funcPtr;
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
imm = (IntPtr)Unsafe.AsPointer(ref callCounter.Value);
|
imm = (nint)Unsafe.AsPointer(ref callCounter.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (symbol == DispatchStubSymbol)
|
else if (symbol == DispatchStubSymbol)
|
||||||
|
@ -744,7 +744,7 @@ namespace ARMeilleure.Translation.PTC
|
||||||
bool highCq)
|
bool highCq)
|
||||||
{
|
{
|
||||||
var cFunc = new CompiledFunction(code, unwindInfo, RelocInfo.Empty);
|
var cFunc = new CompiledFunction(code, unwindInfo, RelocInfo.Empty);
|
||||||
var gFunc = cFunc.MapWithPointer<GuestFunction>(out IntPtr gFuncPointer);
|
var gFunc = cFunc.MapWithPointer<GuestFunction>(out nint gFuncPointer);
|
||||||
|
|
||||||
return new TranslatedFunction(gFunc, gFuncPointer, callCounter, guestSize, highCq);
|
return new TranslatedFunction(gFunc, gFuncPointer, callCounter, guestSize, highCq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
private readonly GuestFunction _func; // Ensure that this delegate will not be garbage collected.
|
private readonly GuestFunction _func; // Ensure that this delegate will not be garbage collected.
|
||||||
|
|
||||||
public IntPtr FuncPointer { get; }
|
public nint FuncPointer { get; }
|
||||||
public Counter<uint> CallCounter { get; }
|
public Counter<uint> CallCounter { get; }
|
||||||
public ulong GuestSize { get; }
|
public ulong GuestSize { get; }
|
||||||
public bool HighCq { get; }
|
public bool HighCq { get; }
|
||||||
|
|
||||||
public TranslatedFunction(GuestFunction func, IntPtr funcPointer, Counter<uint> callCounter, ulong guestSize, bool highCq)
|
public TranslatedFunction(GuestFunction func, nint funcPointer, Counter<uint> callCounter, ulong guestSize, bool highCq)
|
||||||
{
|
{
|
||||||
_func = func;
|
_func = func;
|
||||||
FuncPointer = funcPointer;
|
FuncPointer = funcPointer;
|
||||||
|
|
|
@ -298,7 +298,7 @@ namespace ARMeilleure.Translation
|
||||||
_ptc.WriteCompiledFunction(address, funcSize, hash, highCq, compiledFunc);
|
_ptc.WriteCompiledFunction(address, funcSize, hash, highCq, compiledFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
GuestFunction func = compiledFunc.MapWithPointer<GuestFunction>(out IntPtr funcPointer);
|
GuestFunction func = compiledFunc.MapWithPointer<GuestFunction>(out nint funcPointer);
|
||||||
|
|
||||||
Allocators.ResetAll();
|
Allocators.ResetAll();
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,12 @@ namespace ARMeilleure.Translation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class TranslatorStubs : IDisposable
|
class TranslatorStubs : IDisposable
|
||||||
{
|
{
|
||||||
private readonly Lazy<IntPtr> _slowDispatchStub;
|
private readonly Lazy<nint> _slowDispatchStub;
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
private readonly AddressTable<ulong> _functionTable;
|
private readonly AddressTable<ulong> _functionTable;
|
||||||
private readonly Lazy<IntPtr> _dispatchStub;
|
private readonly Lazy<nint> _dispatchStub;
|
||||||
private readonly Lazy<DispatcherFunction> _dispatchLoop;
|
private readonly Lazy<DispatcherFunction> _dispatchLoop;
|
||||||
private readonly Lazy<WrapperFunction> _contextWrapper;
|
private readonly Lazy<WrapperFunction> _contextWrapper;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace ARMeilleure.Translation
|
||||||
/// Gets the dispatch stub.
|
/// Gets the dispatch stub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
||||||
public IntPtr DispatchStub
|
public nint DispatchStub
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ namespace ARMeilleure.Translation
|
||||||
/// Gets the slow dispatch stub.
|
/// Gets the slow dispatch stub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
||||||
public IntPtr SlowDispatchStub
|
public nint SlowDispatchStub
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,7 @@ namespace ARMeilleure.Translation
|
||||||
/// Generates a <see cref="DispatchStub"/>.
|
/// Generates a <see cref="DispatchStub"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Generated <see cref="DispatchStub"/></returns>
|
/// <returns>Generated <see cref="DispatchStub"/></returns>
|
||||||
private IntPtr GenerateDispatchStub()
|
private nint GenerateDispatchStub()
|
||||||
{
|
{
|
||||||
var context = new EmitterContext();
|
var context = new EmitterContext();
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ namespace ARMeilleure.Translation
|
||||||
/// Generates a <see cref="SlowDispatchStub"/>.
|
/// Generates a <see cref="SlowDispatchStub"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Generated <see cref="SlowDispatchStub"/></returns>
|
/// <returns>Generated <see cref="SlowDispatchStub"/></returns>
|
||||||
private IntPtr GenerateSlowDispatchStub()
|
private nint GenerateSlowDispatchStub()
|
||||||
{
|
{
|
||||||
var context = new EmitterContext();
|
var context = new EmitterContext();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
public static class TranslatorTestMethods
|
public static class TranslatorTestMethods
|
||||||
{
|
{
|
||||||
public delegate int FpFlagsPInvokeTest(IntPtr managedMethod);
|
public delegate int FpFlagsPInvokeTest(nint managedMethod);
|
||||||
|
|
||||||
private static bool SetPlatformFtz(EmitterContext context, bool ftz)
|
private static bool SetPlatformFtz(EmitterContext context, bool ftz)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
// NOTE: We use a DllImport here because of marshaling issue for spec.
|
// NOTE: We use a DllImport here because of marshaling issue for spec.
|
||||||
#pragma warning disable SYSLIB1054
|
#pragma warning disable SYSLIB1054
|
||||||
[DllImport("SDL2")]
|
[DllImport("SDL2")]
|
||||||
private static extern int SDL_GetDefaultAudioInfo(IntPtr name, out SDL_AudioSpec spec, int isCapture);
|
private static extern int SDL_GetDefaultAudioInfo(nint name, out SDL_AudioSpec spec, int isCapture);
|
||||||
#pragma warning restore SYSLIB1054
|
#pragma warning restore SYSLIB1054
|
||||||
|
|
||||||
public SDL2HardwareDeviceDriver()
|
public SDL2HardwareDeviceDriver()
|
||||||
|
@ -37,7 +37,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
|
|
||||||
SDL2Driver.Instance.Initialize();
|
SDL2Driver.Instance.Initialize();
|
||||||
|
|
||||||
int res = SDL_GetDefaultAudioInfo(IntPtr.Zero, out var spec, 0);
|
int res = SDL_GetDefaultAudioInfo(nint.Zero, out var spec, 0);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
|
|
||||||
desired.callback = callback;
|
desired.callback = callback;
|
||||||
|
|
||||||
uint device = SDL_OpenAudioDevice(IntPtr.Zero, 0, ref desired, out SDL_AudioSpec got, 0);
|
uint device = SDL_OpenAudioDevice(nint.Zero, 0, ref desired, out SDL_AudioSpec got, 0);
|
||||||
|
|
||||||
if (device == 0)
|
if (device == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void Update(IntPtr userdata, IntPtr stream, int streamLength)
|
private unsafe void Update(nint userdata, nint stream, int streamLength)
|
||||||
{
|
{
|
||||||
Span<byte> streamSpan = new((void*)stream, streamLength);
|
Span<byte> streamSpan = new((void*)stream, streamLength);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||||
|
|
||||||
fixed (byte* p = samples)
|
fixed (byte* p = samples)
|
||||||
{
|
{
|
||||||
IntPtr pStreamSrc = (IntPtr)p;
|
nint pStreamSrc = (nint)p;
|
||||||
|
|
||||||
// Zero the dest buffer
|
// Zero the dest buffer
|
||||||
streamSpan.Clear();
|
streamSpan.Clear();
|
||||||
|
|
|
@ -10,41 +10,41 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
private const string LibraryName = "libsoundio";
|
private const string LibraryName = "libsoundio";
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
public delegate void OnDeviceChangeNativeDelegate(nint ctx);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
public delegate void OnBackendDisconnectedDelegate(nint ctx, SoundIoError err);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void OnEventsSignalDelegate(IntPtr ctx);
|
public delegate void OnEventsSignalDelegate(nint ctx);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void EmitRtPrioWarningDelegate();
|
public delegate void EmitRtPrioWarningDelegate();
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public delegate void JackCallbackDelegate(IntPtr msg);
|
public delegate void JackCallbackDelegate(nint msg);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SoundIoStruct
|
public struct SoundIoStruct
|
||||||
{
|
{
|
||||||
public IntPtr UserData;
|
public nint UserData;
|
||||||
public IntPtr OnDeviceChange;
|
public nint OnDeviceChange;
|
||||||
public IntPtr OnBackendDisconnected;
|
public nint OnBackendDisconnected;
|
||||||
public IntPtr OnEventsSignal;
|
public nint OnEventsSignal;
|
||||||
public SoundIoBackend CurrentBackend;
|
public SoundIoBackend CurrentBackend;
|
||||||
public IntPtr ApplicationName;
|
public nint ApplicationName;
|
||||||
public IntPtr EmitRtPrioWarning;
|
public nint EmitRtPrioWarning;
|
||||||
public IntPtr JackInfoCallback;
|
public nint JackInfoCallback;
|
||||||
public IntPtr JackErrorCallback;
|
public nint JackErrorCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct SoundIoChannelLayout
|
public struct SoundIoChannelLayout
|
||||||
{
|
{
|
||||||
public IntPtr Name;
|
public nint Name;
|
||||||
public int ChannelCount;
|
public int ChannelCount;
|
||||||
public Array24<SoundIoChannelId> Channels;
|
public Array24<SoundIoChannelId> Channels;
|
||||||
|
|
||||||
public static IntPtr GetDefault(int channelCount)
|
public static nint GetDefault(int channelCount)
|
||||||
{
|
{
|
||||||
return soundio_channel_layout_get_default(channelCount);
|
return soundio_channel_layout_get_default(channelCount);
|
||||||
}
|
}
|
||||||
|
@ -63,17 +63,17 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public struct SoundIoDevice
|
public struct SoundIoDevice
|
||||||
{
|
{
|
||||||
public IntPtr SoundIo;
|
public nint SoundIo;
|
||||||
public IntPtr Id;
|
public nint Id;
|
||||||
public IntPtr Name;
|
public nint Name;
|
||||||
public SoundIoDeviceAim Aim;
|
public SoundIoDeviceAim Aim;
|
||||||
public IntPtr Layouts;
|
public nint Layouts;
|
||||||
public int LayoutCount;
|
public int LayoutCount;
|
||||||
public SoundIoChannelLayout CurrentLayout;
|
public SoundIoChannelLayout CurrentLayout;
|
||||||
public IntPtr Formats;
|
public nint Formats;
|
||||||
public int FormatCount;
|
public int FormatCount;
|
||||||
public SoundIoFormat CurrentFormat;
|
public SoundIoFormat CurrentFormat;
|
||||||
public IntPtr SampleRates;
|
public nint SampleRates;
|
||||||
public int SampleRateCount;
|
public int SampleRateCount;
|
||||||
public int SampleRateCurrent;
|
public int SampleRateCurrent;
|
||||||
public double SoftwareLatencyMin;
|
public double SoftwareLatencyMin;
|
||||||
|
@ -86,17 +86,17 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public struct SoundIoOutStream
|
public struct SoundIoOutStream
|
||||||
{
|
{
|
||||||
public IntPtr Device;
|
public nint Device;
|
||||||
public SoundIoFormat Format;
|
public SoundIoFormat Format;
|
||||||
public int SampleRate;
|
public int SampleRate;
|
||||||
public SoundIoChannelLayout Layout;
|
public SoundIoChannelLayout Layout;
|
||||||
public double SoftwareLatency;
|
public double SoftwareLatency;
|
||||||
public float Volume;
|
public float Volume;
|
||||||
public IntPtr UserData;
|
public nint UserData;
|
||||||
public IntPtr WriteCallback;
|
public nint WriteCallback;
|
||||||
public IntPtr UnderflowCallback;
|
public nint UnderflowCallback;
|
||||||
public IntPtr ErrorCallback;
|
public nint ErrorCallback;
|
||||||
public IntPtr Name;
|
public nint Name;
|
||||||
public bool NonTerminalHint;
|
public bool NonTerminalHint;
|
||||||
public int BytesPerFrame;
|
public int BytesPerFrame;
|
||||||
public int BytesPerSample;
|
public int BytesPerSample;
|
||||||
|
@ -105,74 +105,74 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public struct SoundIoChannelArea
|
public struct SoundIoChannelArea
|
||||||
{
|
{
|
||||||
public IntPtr Pointer;
|
public nint Pointer;
|
||||||
public int Step;
|
public int Step;
|
||||||
}
|
}
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial IntPtr soundio_create();
|
internal static partial nint soundio_create();
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_connect(IntPtr ctx);
|
internal static partial SoundIoError soundio_connect(nint ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial void soundio_disconnect(IntPtr ctx);
|
internal static partial void soundio_disconnect(nint ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial void soundio_flush_events(IntPtr ctx);
|
internal static partial void soundio_flush_events(nint ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial int soundio_output_device_count(IntPtr ctx);
|
internal static partial int soundio_output_device_count(nint ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial int soundio_default_output_device_index(IntPtr ctx);
|
internal static partial int soundio_default_output_device_index(nint ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
internal static partial nint soundio_get_output_device(nint ctx, int index);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
internal static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
internal static partial bool soundio_device_supports_format(nint devCtx, SoundIoFormat format);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
internal static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
internal static partial bool soundio_device_supports_layout(nint devCtx, nint layout);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
internal static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
internal static partial bool soundio_device_supports_sample_rate(nint devCtx, int sampleRate);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
internal static partial nint soundio_outstream_create(nint devCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_open(nint outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_start(nint outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
internal static partial SoundIoError soundio_outstream_begin_write(nint outStreamCtx, nint areas, nint frameCount);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_end_write(nint outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
internal static partial SoundIoError soundio_outstream_pause(nint devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
internal static partial SoundIoError soundio_outstream_set_volume(nint devCtx, double volume);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
internal static partial void soundio_outstream_destroy(nint streamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial void soundio_destroy(IntPtr ctx);
|
internal static partial void soundio_destroy(nint ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
internal static partial nint soundio_channel_layout_get_default(int channelCount);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
internal static partial IntPtr soundio_strerror(SoundIoError err);
|
internal static partial nint soundio_strerror(SoundIoError err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
{
|
{
|
||||||
public class SoundIoContext : IDisposable
|
public class SoundIoContext : IDisposable
|
||||||
{
|
{
|
||||||
private IntPtr _context;
|
private nint _context;
|
||||||
private Action<SoundIoError> _onBackendDisconnect;
|
private Action<SoundIoError> _onBackendDisconnect;
|
||||||
private OnBackendDisconnectedDelegate _onBackendDisconnectNative;
|
private OnBackendDisconnectedDelegate _onBackendDisconnectNative;
|
||||||
|
|
||||||
public IntPtr Context => _context;
|
public nint Context => _context;
|
||||||
|
|
||||||
internal SoundIoContext(IntPtr context)
|
internal SoundIoContext(nint context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_onBackendDisconnect = null;
|
_onBackendDisconnect = null;
|
||||||
|
@ -60,9 +60,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public SoundIoDeviceContext GetOutputDevice(int index)
|
public SoundIoDeviceContext GetOutputDevice(int index)
|
||||||
{
|
{
|
||||||
IntPtr deviceContext = soundio_get_output_device(_context, index);
|
nint deviceContext = soundio_get_output_device(_context, index);
|
||||||
|
|
||||||
if (deviceContext == IntPtr.Zero)
|
if (deviceContext == nint.Zero)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public static SoundIoContext Create()
|
public static SoundIoContext Create()
|
||||||
{
|
{
|
||||||
IntPtr context = soundio_create();
|
nint context = soundio_create();
|
||||||
|
|
||||||
if (context == IntPtr.Zero)
|
if (context == nint.Zero)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
IntPtr currentContext = Interlocked.Exchange(ref _context, IntPtr.Zero);
|
nint currentContext = Interlocked.Exchange(ref _context, nint.Zero);
|
||||||
|
|
||||||
if (currentContext != IntPtr.Zero)
|
if (currentContext != nint.Zero)
|
||||||
{
|
{
|
||||||
soundio_destroy(currentContext);
|
soundio_destroy(currentContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
{
|
{
|
||||||
public class SoundIoDeviceContext
|
public class SoundIoDeviceContext
|
||||||
{
|
{
|
||||||
private readonly IntPtr _context;
|
private readonly nint _context;
|
||||||
|
|
||||||
public IntPtr Context => _context;
|
public nint Context => _context;
|
||||||
|
|
||||||
internal SoundIoDeviceContext(IntPtr context)
|
internal SoundIoDeviceContext(nint context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public SoundIoOutStreamContext CreateOutStream()
|
public SoundIoOutStreamContext CreateOutStream()
|
||||||
{
|
{
|
||||||
IntPtr context = soundio_outstream_create(_context);
|
nint context = soundio_outstream_create(_context);
|
||||||
|
|
||||||
if (context == IntPtr.Zero)
|
if (context == nint.Zero)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,19 +8,19 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
public class SoundIoOutStreamContext : IDisposable
|
public class SoundIoOutStreamContext : IDisposable
|
||||||
{
|
{
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private unsafe delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax);
|
private unsafe delegate void WriteCallbackDelegate(nint ctx, int frameCountMin, int frameCountMax);
|
||||||
|
|
||||||
private IntPtr _context;
|
private nint _context;
|
||||||
private IntPtr _nameStored;
|
private nint _nameStored;
|
||||||
private Action<int, int> _writeCallback;
|
private Action<int, int> _writeCallback;
|
||||||
private WriteCallbackDelegate _writeCallbackNative;
|
private WriteCallbackDelegate _writeCallbackNative;
|
||||||
|
|
||||||
public IntPtr Context => _context;
|
public nint Context => _context;
|
||||||
|
|
||||||
internal SoundIoOutStreamContext(IntPtr context)
|
internal SoundIoOutStreamContext(nint context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_nameStored = IntPtr.Zero;
|
_nameStored = nint.Zero;
|
||||||
_writeCallback = null;
|
_writeCallback = null;
|
||||||
_writeCallbackNative = null;
|
_writeCallbackNative = null;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
{
|
{
|
||||||
var context = GetOutContext();
|
var context = GetOutContext();
|
||||||
|
|
||||||
if (_nameStored != IntPtr.Zero && context.Name == _nameStored)
|
if (_nameStored != nint.Zero && context.Name == _nameStored)
|
||||||
{
|
{
|
||||||
Marshal.FreeHGlobal(_nameStored);
|
Marshal.FreeHGlobal(_nameStored);
|
||||||
}
|
}
|
||||||
|
@ -124,14 +124,14 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
public Span<SoundIoChannelArea> BeginWrite(ref int frameCount)
|
public Span<SoundIoChannelArea> BeginWrite(ref int frameCount)
|
||||||
{
|
{
|
||||||
IntPtr arenas = default;
|
nint arenas = default;
|
||||||
int nativeFrameCount = frameCount;
|
int nativeFrameCount = frameCount;
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
var frameCountPtr = &nativeFrameCount;
|
var frameCountPtr = &nativeFrameCount;
|
||||||
var arenasPtr = &arenas;
|
var arenasPtr = &arenas;
|
||||||
CheckError(soundio_outstream_begin_write(_context, (IntPtr)arenasPtr, (IntPtr)frameCountPtr));
|
CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr));
|
||||||
|
|
||||||
frameCount = *frameCountPtr;
|
frameCount = *frameCountPtr;
|
||||||
|
|
||||||
|
@ -143,10 +143,10 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (_context != IntPtr.Zero)
|
if (_context != nint.Zero)
|
||||||
{
|
{
|
||||||
soundio_outstream_destroy(_context);
|
soundio_outstream_destroy(_context);
|
||||||
_context = IntPtr.Zero;
|
_context = nint.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,11 +64,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public unsafe IntPtr GetBufferPointer(int index)
|
public unsafe nint GetBufferPointer(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < _buffersEntryCount)
|
if (index >= 0 && index < _buffersEntryCount)
|
||||||
{
|
{
|
||||||
return (IntPtr)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
|
return (nint)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(index), index, null);
|
throw new ArgumentOutOfRangeException(nameof(index), index, null);
|
||||||
|
|
|
@ -82,8 +82,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
statistics.Reset(_parameter.ChannelCount);
|
statistics.Reset(_parameter.ChannelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Span<IntPtr> inputBuffers = stackalloc IntPtr[_parameter.ChannelCount];
|
Span<nint> inputBuffers = stackalloc nint[_parameter.ChannelCount];
|
||||||
Span<IntPtr> outputBuffers = stackalloc IntPtr[_parameter.ChannelCount];
|
Span<nint> outputBuffers = stackalloc nint[_parameter.ChannelCount];
|
||||||
Span<float> channelInput = stackalloc float[_parameter.ChannelCount];
|
Span<float> channelInput = stackalloc float[_parameter.ChannelCount];
|
||||||
ExponentialMovingAverage inputMovingAverage = state.InputMovingAverage;
|
ExponentialMovingAverage inputMovingAverage = state.InputMovingAverage;
|
||||||
float unknown4 = state.Unknown4;
|
float unknown4 = state.Unknown4;
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
private unsafe void ProcessDelayStereo(ref DelayState state, Span<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private unsafe void ProcessDelayStereo(ref DelayState state, Span<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
const ushort ChannelCount = 2;
|
const ushort ChannelCount = 2;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
private unsafe void ProcessDelayQuadraphonic(ref DelayState state, Span<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private unsafe void ProcessDelayQuadraphonic(ref DelayState state, Span<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
const ushort ChannelCount = 4;
|
const ushort ChannelCount = 4;
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
private unsafe void ProcessDelaySurround(ref DelayState state, Span<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private unsafe void ProcessDelaySurround(ref DelayState state, Span<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
const ushort ChannelCount = 6;
|
const ushort ChannelCount = 6;
|
||||||
|
|
||||||
|
@ -219,8 +219,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled && Parameter.IsChannelCountValid())
|
if (IsEffectEnabled && Parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
Span<IntPtr> inputBuffers = stackalloc IntPtr[Parameter.ChannelCount];
|
Span<nint> inputBuffers = stackalloc nint[Parameter.ChannelCount];
|
||||||
Span<IntPtr> outputBuffers = stackalloc IntPtr[Parameter.ChannelCount];
|
Span<nint> outputBuffers = stackalloc nint[Parameter.ChannelCount];
|
||||||
|
|
||||||
for (int i = 0; i < Parameter.ChannelCount; i++)
|
for (int i = 0; i < Parameter.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,8 +70,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled && _parameter.IsChannelCountValid())
|
if (IsEffectEnabled && _parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
Span<IntPtr> inputBuffers = stackalloc IntPtr[_parameter.ChannelCount];
|
Span<nint> inputBuffers = stackalloc nint[_parameter.ChannelCount];
|
||||||
Span<IntPtr> outputBuffers = stackalloc IntPtr[_parameter.ChannelCount];
|
Span<nint> outputBuffers = stackalloc nint[_parameter.ChannelCount];
|
||||||
|
|
||||||
for (int i = 0; i < _parameter.ChannelCount; i++)
|
for (int i = 0; i < _parameter.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,8 +88,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
statistics.Reset();
|
statistics.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Span<IntPtr> inputBuffers = stackalloc IntPtr[_parameter.ChannelCount];
|
Span<nint> inputBuffers = stackalloc nint[_parameter.ChannelCount];
|
||||||
Span<IntPtr> outputBuffers = stackalloc IntPtr[_parameter.ChannelCount];
|
Span<nint> outputBuffers = stackalloc nint[_parameter.ChannelCount];
|
||||||
|
|
||||||
for (int i = 0; i < _parameter.ChannelCount; i++)
|
for (int i = 0; i < _parameter.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,30 +71,30 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dMono(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dMono(ref Reverb3dState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableMono, _targetEarlyDelayLineIndicesTableMono, _targetOutputFeedbackIndicesTableMono);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableMono, _targetEarlyDelayLineIndicesTableMono, _targetOutputFeedbackIndicesTableMono);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dStereo(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dStereo(ref Reverb3dState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableStereo, _targetEarlyDelayLineIndicesTableStereo, _targetOutputFeedbackIndicesTableStereo);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableStereo, _targetEarlyDelayLineIndicesTableStereo, _targetOutputFeedbackIndicesTableStereo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dQuadraphonic(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dQuadraphonic(ref Reverb3dState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableQuadraphonic, _targetEarlyDelayLineIndicesTableQuadraphonic, _targetOutputFeedbackIndicesTableQuadraphonic);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableQuadraphonic, _targetEarlyDelayLineIndicesTableQuadraphonic, _targetOutputFeedbackIndicesTableQuadraphonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverb3dSurround(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverb3dSurround(ref Reverb3dState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableSurround, _targetEarlyDelayLineIndicesTableSurround, _targetOutputFeedbackIndicesTableSurround);
|
ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableSurround, _targetEarlyDelayLineIndicesTableSurround, _targetOutputFeedbackIndicesTableSurround);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable)
|
private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable)
|
||||||
{
|
{
|
||||||
const int DelayLineSampleIndexOffset = 1;
|
const int DelayLineSampleIndexOffset = 1;
|
||||||
|
|
||||||
|
@ -193,8 +193,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled && Parameter.IsChannelCountValid())
|
if (IsEffectEnabled && Parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
Span<IntPtr> inputBuffers = stackalloc IntPtr[Parameter.ChannelCount];
|
Span<nint> inputBuffers = stackalloc nint[Parameter.ChannelCount];
|
||||||
Span<IntPtr> outputBuffers = stackalloc IntPtr[Parameter.ChannelCount];
|
Span<nint> outputBuffers = stackalloc nint[Parameter.ChannelCount];
|
||||||
|
|
||||||
for (int i = 0; i < Parameter.ChannelCount; i++)
|
for (int i = 0; i < Parameter.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverbMono(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverbMono(ref ReverbState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverbGeneric(
|
ProcessReverbGeneric(
|
||||||
ref state,
|
ref state,
|
||||||
|
@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverbStereo(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverbStereo(ref ReverbState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverbGeneric(
|
ProcessReverbGeneric(
|
||||||
ref state,
|
ref state,
|
||||||
|
@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverbQuadraphonic(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverbQuadraphonic(ref ReverbState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverbGeneric(
|
ProcessReverbGeneric(
|
||||||
ref state,
|
ref state,
|
||||||
|
@ -119,7 +119,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ProcessReverbSurround(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
|
private void ProcessReverbSurround(ref ReverbState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount)
|
||||||
{
|
{
|
||||||
ProcessReverbGeneric(
|
ProcessReverbGeneric(
|
||||||
ref state,
|
ref state,
|
||||||
|
@ -132,7 +132,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
_outputIndicesTableSurround);
|
_outputIndicesTableSurround);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ProcessReverbGeneric(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable, ReadOnlySpan<int> outputIndicesTable)
|
private unsafe void ProcessReverbGeneric(ref ReverbState state, ReadOnlySpan<nint> outputBuffers, ReadOnlySpan<nint> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable, ReadOnlySpan<int> outputIndicesTable)
|
||||||
{
|
{
|
||||||
bool isSurround = Parameter.ChannelCount == 6;
|
bool isSurround = Parameter.ChannelCount == 6;
|
||||||
|
|
||||||
|
@ -223,8 +223,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||||
|
|
||||||
if (IsEffectEnabled && Parameter.IsChannelCountValid())
|
if (IsEffectEnabled && Parameter.IsChannelCountValid())
|
||||||
{
|
{
|
||||||
Span<IntPtr> inputBuffers = stackalloc IntPtr[Parameter.ChannelCount];
|
Span<nint> inputBuffers = stackalloc nint[Parameter.ChannelCount];
|
||||||
Span<IntPtr> outputBuffers = stackalloc IntPtr[Parameter.ChannelCount];
|
Span<nint> outputBuffers = stackalloc nint[Parameter.ChannelCount];
|
||||||
|
|
||||||
for (int i = 0; i < Parameter.ChannelCount; i++)
|
for (int i = 0; i < Parameter.ChannelCount; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||||
|
|
||||||
private readonly unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
|
private readonly unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
|
||||||
|
|
||||||
public readonly unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
|
public readonly unsafe bool HasMemoryPoolState => (nint)_memoryPools != nint.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create an new empty <see cref="AddressInfo"/>.
|
/// Create an new empty <see cref="AddressInfo"/>.
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||||
[MarshalAs(UnmanagedType.I1)]
|
[MarshalAs(UnmanagedType.I1)]
|
||||||
public bool IsUsed;
|
public bool IsUsed;
|
||||||
|
|
||||||
public static unsafe MemoryPoolState* Null => (MemoryPoolState*)IntPtr.Zero.ToPointer();
|
public static unsafe MemoryPoolState* Null => (MemoryPoolState*)nint.Zero.ToPointer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="MemoryPoolState"/> with the given <see cref="LocationType"/>.
|
/// Create a new <see cref="MemoryPoolState"/> with the given <see cref="LocationType"/>.
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The effect processing order storage.
|
/// The effect processing order storage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IntPtr _effectProcessingOrderArrayPointer;
|
private readonly nint _effectProcessingOrderArrayPointer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The max element count that can be found in the effect processing order storage.
|
/// The max element count that can be found in the effect processing order storage.
|
||||||
|
@ -123,7 +123,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_effectProcessingOrderArrayPointer == IntPtr.Zero)
|
if (_effectProcessingOrderArrayPointer == nint.Zero)
|
||||||
{
|
{
|
||||||
return Span<int>.Empty;
|
return Span<int>.Empty;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
// SAFETY: safe as effectProcessingOrderArray comes from the work buffer memory that is pinned.
|
// SAFETY: safe as effectProcessingOrderArray comes from the work buffer memory that is pinned.
|
||||||
_effectProcessingOrderArrayPointer = (IntPtr)Unsafe.AsPointer(ref MemoryMarshal.GetReference(effectProcessingOrderArray.Span));
|
_effectProcessingOrderArrayPointer = (nint)Unsafe.AsPointer(ref MemoryMarshal.GetReference(effectProcessingOrderArray.Span));
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectProcessingOrderArrayMaxCount = (uint)effectProcessingOrderArray.Length;
|
EffectProcessingOrderArrayMaxCount = (uint)effectProcessingOrderArray.Length;
|
||||||
|
|
|
@ -21,33 +21,33 @@ namespace Ryujinx.Common.GraphicsDriver
|
||||||
private const uint NvAPI_DRS_DestroySession_ID = 0x0DAD9CFF8;
|
private const uint NvAPI_DRS_DestroySession_ID = 0x0DAD9CFF8;
|
||||||
|
|
||||||
[LibraryImport("nvapi64")]
|
[LibraryImport("nvapi64")]
|
||||||
private static partial IntPtr nvapi_QueryInterface(uint id);
|
private static partial nint nvapi_QueryInterface(uint id);
|
||||||
|
|
||||||
private delegate int NvAPI_InitializeDelegate();
|
private delegate int NvAPI_InitializeDelegate();
|
||||||
private static NvAPI_InitializeDelegate NvAPI_Initialize;
|
private static NvAPI_InitializeDelegate NvAPI_Initialize;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_CreateSessionDelegate(out IntPtr handle);
|
private delegate int NvAPI_DRS_CreateSessionDelegate(out nint handle);
|
||||||
private static NvAPI_DRS_CreateSessionDelegate NvAPI_DRS_CreateSession;
|
private static NvAPI_DRS_CreateSessionDelegate NvAPI_DRS_CreateSession;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_LoadSettingsDelegate(IntPtr handle);
|
private delegate int NvAPI_DRS_LoadSettingsDelegate(nint handle);
|
||||||
private static NvAPI_DRS_LoadSettingsDelegate NvAPI_DRS_LoadSettings;
|
private static NvAPI_DRS_LoadSettingsDelegate NvAPI_DRS_LoadSettings;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_FindProfileByNameDelegate(IntPtr handle, NvapiUnicodeString profileName, out IntPtr profileHandle);
|
private delegate int NvAPI_DRS_FindProfileByNameDelegate(nint handle, NvapiUnicodeString profileName, out nint profileHandle);
|
||||||
private static NvAPI_DRS_FindProfileByNameDelegate NvAPI_DRS_FindProfileByName;
|
private static NvAPI_DRS_FindProfileByNameDelegate NvAPI_DRS_FindProfileByName;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_CreateProfileDelegate(IntPtr handle, ref NvdrsProfile profileInfo, out IntPtr profileHandle);
|
private delegate int NvAPI_DRS_CreateProfileDelegate(nint handle, ref NvdrsProfile profileInfo, out nint profileHandle);
|
||||||
private static NvAPI_DRS_CreateProfileDelegate NvAPI_DRS_CreateProfile;
|
private static NvAPI_DRS_CreateProfileDelegate NvAPI_DRS_CreateProfile;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_CreateApplicationDelegate(IntPtr handle, IntPtr profileHandle, ref NvdrsApplicationV4 app);
|
private delegate int NvAPI_DRS_CreateApplicationDelegate(nint handle, nint profileHandle, ref NvdrsApplicationV4 app);
|
||||||
private static NvAPI_DRS_CreateApplicationDelegate NvAPI_DRS_CreateApplication;
|
private static NvAPI_DRS_CreateApplicationDelegate NvAPI_DRS_CreateApplication;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_SetSettingDelegate(IntPtr handle, IntPtr profileHandle, ref NvdrsSetting setting);
|
private delegate int NvAPI_DRS_SetSettingDelegate(nint handle, nint profileHandle, ref NvdrsSetting setting);
|
||||||
private static NvAPI_DRS_SetSettingDelegate NvAPI_DRS_SetSetting;
|
private static NvAPI_DRS_SetSettingDelegate NvAPI_DRS_SetSetting;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_SaveSettingsDelegate(IntPtr handle);
|
private delegate int NvAPI_DRS_SaveSettingsDelegate(nint handle);
|
||||||
private static NvAPI_DRS_SaveSettingsDelegate NvAPI_DRS_SaveSettings;
|
private static NvAPI_DRS_SaveSettingsDelegate NvAPI_DRS_SaveSettings;
|
||||||
|
|
||||||
private delegate int NvAPI_DRS_DestroySessionDelegate(IntPtr handle);
|
private delegate int NvAPI_DRS_DestroySessionDelegate(nint handle);
|
||||||
private static NvAPI_DRS_DestroySessionDelegate NvAPI_DRS_DestroySession;
|
private static NvAPI_DRS_DestroySessionDelegate NvAPI_DRS_DestroySession;
|
||||||
|
|
||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
|
@ -94,7 +94,7 @@ namespace Ryujinx.Common.GraphicsDriver
|
||||||
|
|
||||||
Check(NvAPI_Initialize());
|
Check(NvAPI_Initialize());
|
||||||
|
|
||||||
Check(NvAPI_DRS_CreateSession(out IntPtr handle));
|
Check(NvAPI_DRS_CreateSession(out nint handle));
|
||||||
|
|
||||||
Check(NvAPI_DRS_LoadSettings(handle));
|
Check(NvAPI_DRS_LoadSettings(handle));
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ namespace Ryujinx.Common.GraphicsDriver
|
||||||
|
|
||||||
private static T NvAPI_Delegate<T>(uint id) where T : class
|
private static T NvAPI_Delegate<T>(uint id) where T : class
|
||||||
{
|
{
|
||||||
IntPtr ptr = nvapi_QueryInterface(id);
|
nint ptr = nvapi_QueryInterface(id);
|
||||||
|
|
||||||
if (ptr != IntPtr.Zero)
|
if (ptr != nint.Zero)
|
||||||
{
|
{
|
||||||
return Marshal.GetDelegateForFunctionPointer<T>(ptr);
|
return Marshal.GetDelegateForFunctionPointer<T>(ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,17 @@ namespace Ryujinx.Common.Memory
|
||||||
/// <typeparam name="T">Array element type</typeparam>
|
/// <typeparam name="T">Array element type</typeparam>
|
||||||
public unsafe struct ArrayPtr<T> : IEquatable<ArrayPtr<T>>, IArray<T> where T : unmanaged
|
public unsafe struct ArrayPtr<T> : IEquatable<ArrayPtr<T>>, IArray<T> where T : unmanaged
|
||||||
{
|
{
|
||||||
private IntPtr _ptr;
|
private nint _ptr;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Null pointer.
|
/// Null pointer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ArrayPtr<T> Null => new() { _ptr = IntPtr.Zero };
|
public static ArrayPtr<T> Null => new() { _ptr = nint.Zero };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if the pointer is null, false otherwise.
|
/// True if the pointer is null, false otherwise.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly bool IsNull => _ptr == IntPtr.Zero;
|
public readonly bool IsNull => _ptr == nint.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of elements on the array.
|
/// Number of elements on the array.
|
||||||
|
@ -50,7 +50,7 @@ namespace Ryujinx.Common.Memory
|
||||||
/// <param name="length">Number of elements on the array</param>
|
/// <param name="length">Number of elements on the array</param>
|
||||||
public ArrayPtr(ref T value, int length)
|
public ArrayPtr(ref T value, int length)
|
||||||
{
|
{
|
||||||
_ptr = (IntPtr)Unsafe.AsPointer(ref value);
|
_ptr = (nint)Unsafe.AsPointer(ref value);
|
||||||
Length = length;
|
Length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.Common.Memory
|
||||||
/// <param name="length">Number of elements on the array</param>
|
/// <param name="length">Number of elements on the array</param>
|
||||||
public ArrayPtr(T* ptr, int length)
|
public ArrayPtr(T* ptr, int length)
|
||||||
{
|
{
|
||||||
_ptr = (IntPtr)ptr;
|
_ptr = (nint)ptr;
|
||||||
Length = length;
|
Length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace Ryujinx.Common.Memory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ptr">Array base pointer</param>
|
/// <param name="ptr">Array base pointer</param>
|
||||||
/// <param name="length">Number of elements on the array</param>
|
/// <param name="length">Number of elements on the array</param>
|
||||||
public ArrayPtr(IntPtr ptr, int length)
|
public ArrayPtr(nint ptr, int length)
|
||||||
{
|
{
|
||||||
_ptr = ptr;
|
_ptr = ptr;
|
||||||
Length = length;
|
Length = length;
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||||
public readonly static int PartialUnmapsCountOffset;
|
public readonly static int PartialUnmapsCountOffset;
|
||||||
public readonly static int LocalCountsOffset;
|
public readonly static int LocalCountsOffset;
|
||||||
|
|
||||||
public readonly static IntPtr GlobalState;
|
public readonly static nint GlobalState;
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
|
@ -29,17 +29,17 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
private static partial IntPtr OpenThread(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwThreadId);
|
private static partial nint OpenThread(int dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwThreadId);
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static partial bool CloseHandle(IntPtr hObject);
|
private static partial bool CloseHandle(nint hObject);
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static partial bool GetExitCodeThread(IntPtr hThread, out uint lpExitCode);
|
private static partial bool GetExitCodeThread(nint hThread, out uint lpExitCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a global static PartialUnmapState and populates the field offsets.
|
/// Creates a global static PartialUnmapState and populates the field offsets.
|
||||||
|
@ -137,9 +137,9 @@ namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||||
|
|
||||||
if (id != 0)
|
if (id != 0)
|
||||||
{
|
{
|
||||||
IntPtr handle = OpenThread(ThreadQueryInformation, false, (uint)id);
|
nint handle = OpenThread(ThreadQueryInformation, false, (uint)id);
|
||||||
|
|
||||||
if (handle == IntPtr.Zero)
|
if (handle == nint.Zero)
|
||||||
{
|
{
|
||||||
Interlocked.CompareExchange(ref ids[i], 0, id);
|
Interlocked.CompareExchange(ref ids[i], 0, id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,17 @@ namespace Ryujinx.Common.Memory
|
||||||
/// <typeparam name="T">Type of the unmanaged resource</typeparam>
|
/// <typeparam name="T">Type of the unmanaged resource</typeparam>
|
||||||
public unsafe struct Ptr<T> : IEquatable<Ptr<T>> where T : unmanaged
|
public unsafe struct Ptr<T> : IEquatable<Ptr<T>> where T : unmanaged
|
||||||
{
|
{
|
||||||
private IntPtr _ptr;
|
private nint _ptr;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Null pointer.
|
/// Null pointer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static Ptr<T> Null => new() { _ptr = IntPtr.Zero };
|
public static Ptr<T> Null => new() { _ptr = nint.Zero };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if the pointer is null, false otherwise.
|
/// True if the pointer is null, false otherwise.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly bool IsNull => _ptr == IntPtr.Zero;
|
public readonly bool IsNull => _ptr == nint.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a reference to the value.
|
/// Gets a reference to the value.
|
||||||
|
@ -37,7 +37,7 @@ namespace Ryujinx.Common.Memory
|
||||||
/// <param name="value">Reference to the unmanaged resource</param>
|
/// <param name="value">Reference to the unmanaged resource</param>
|
||||||
public Ptr(ref T value)
|
public Ptr(ref T value)
|
||||||
{
|
{
|
||||||
_ptr = (IntPtr)Unsafe.AsPointer(ref value);
|
_ptr = (nint)Unsafe.AsPointer(ref value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly override bool Equals(object obj)
|
public readonly override bool Equals(object obj)
|
||||||
|
|
|
@ -14,19 +14,19 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
private const string X11LibraryName = "libX11.so.6";
|
private const string X11LibraryName = "libX11.so.6";
|
||||||
|
|
||||||
[LibraryImport(X11LibraryName)]
|
[LibraryImport(X11LibraryName)]
|
||||||
private static partial IntPtr XOpenDisplay([MarshalAs(UnmanagedType.LPStr)] string display);
|
private static partial nint XOpenDisplay([MarshalAs(UnmanagedType.LPStr)] string display);
|
||||||
|
|
||||||
[LibraryImport(X11LibraryName)]
|
[LibraryImport(X11LibraryName)]
|
||||||
private static partial IntPtr XGetDefault(IntPtr display, [MarshalAs(UnmanagedType.LPStr)] string program, [MarshalAs(UnmanagedType.LPStr)] string option);
|
private static partial nint XGetDefault(nint display, [MarshalAs(UnmanagedType.LPStr)] string program, [MarshalAs(UnmanagedType.LPStr)] string option);
|
||||||
|
|
||||||
[LibraryImport(X11LibraryName)]
|
[LibraryImport(X11LibraryName)]
|
||||||
private static partial int XDisplayWidth(IntPtr display, int screenNumber);
|
private static partial int XDisplayWidth(nint display, int screenNumber);
|
||||||
|
|
||||||
[LibraryImport(X11LibraryName)]
|
[LibraryImport(X11LibraryName)]
|
||||||
private static partial int XDisplayWidthMM(IntPtr display, int screenNumber);
|
private static partial int XDisplayWidthMM(nint display, int screenNumber);
|
||||||
|
|
||||||
[LibraryImport(X11LibraryName)]
|
[LibraryImport(X11LibraryName)]
|
||||||
private static partial int XCloseDisplay(IntPtr display);
|
private static partial int XCloseDisplay(nint display);
|
||||||
|
|
||||||
private const double StandardDpiScale = 96.0;
|
private const double StandardDpiScale = 96.0;
|
||||||
private const double MaxScaleFactor = 1.25;
|
private const double MaxScaleFactor = 1.25;
|
||||||
|
@ -51,7 +51,7 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
userDpiScale = GdiPlusHelper.GetDpiX(IntPtr.Zero);
|
userDpiScale = GdiPlusHelper.GetDpiX(nint.Zero);
|
||||||
}
|
}
|
||||||
else if (OperatingSystem.IsLinux())
|
else if (OperatingSystem.IsLinux())
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
|
|
||||||
if (xdgSessionType == null || xdgSessionType == "x11")
|
if (xdgSessionType == null || xdgSessionType == "x11")
|
||||||
{
|
{
|
||||||
IntPtr display = XOpenDisplay(null);
|
nint display = XOpenDisplay(null);
|
||||||
string dpiString = Marshal.PtrToStringAnsi(XGetDefault(display, "Xft", "dpi"));
|
string dpiString = Marshal.PtrToStringAnsi(XGetDefault(display, "Xft", "dpi"));
|
||||||
if (dpiString == null || !double.TryParse(dpiString, NumberStyles.Any, CultureInfo.InvariantCulture, out userDpiScale))
|
if (dpiString == null || !double.TryParse(dpiString, NumberStyles.Any, CultureInfo.InvariantCulture, out userDpiScale))
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
{
|
{
|
||||||
private const string LibraryName = "gdiplus.dll";
|
private const string LibraryName = "gdiplus.dll";
|
||||||
|
|
||||||
private static readonly IntPtr _initToken;
|
private static readonly nint _initToken;
|
||||||
|
|
||||||
static GdiPlusHelper()
|
static GdiPlusHelper()
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
public int GdiplusVersion;
|
public int GdiplusVersion;
|
||||||
|
|
||||||
#pragma warning disable CS0649 // Field is never assigned to
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public IntPtr DebugEventCallback;
|
public nint DebugEventCallback;
|
||||||
public int SuppressBackgroundThread;
|
public int SuppressBackgroundThread;
|
||||||
public int SuppressExternalCodecs;
|
public int SuppressExternalCodecs;
|
||||||
public int StartupParameters;
|
public int StartupParameters;
|
||||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
{
|
{
|
||||||
// We assume Windows 8 and upper
|
// We assume Windows 8 and upper
|
||||||
GdiplusVersion = 2,
|
GdiplusVersion = 2,
|
||||||
DebugEventCallback = IntPtr.Zero,
|
DebugEventCallback = nint.Zero,
|
||||||
SuppressBackgroundThread = 0,
|
SuppressBackgroundThread = 0,
|
||||||
SuppressExternalCodecs = 0,
|
SuppressExternalCodecs = 0,
|
||||||
StartupParameters = 0,
|
StartupParameters = 0,
|
||||||
|
@ -48,25 +48,25 @@ namespace Ryujinx.Common.SystemInterop
|
||||||
|
|
||||||
private struct StartupOutput
|
private struct StartupOutput
|
||||||
{
|
{
|
||||||
public IntPtr NotificationHook;
|
public nint NotificationHook;
|
||||||
public IntPtr NotificationUnhook;
|
public nint NotificationUnhook;
|
||||||
}
|
}
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
private static partial int GdiplusStartup(out IntPtr token, in StartupInputEx input, out StartupOutput output);
|
private static partial int GdiplusStartup(out nint token, in StartupInputEx input, out StartupOutput output);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
private static partial int GdipCreateFromHWND(IntPtr hwnd, out IntPtr graphics);
|
private static partial int GdipCreateFromHWND(nint hwnd, out nint graphics);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
private static partial int GdipDeleteGraphics(IntPtr graphics);
|
private static partial int GdipDeleteGraphics(nint graphics);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
private static partial int GdipGetDpiX(IntPtr graphics, out float dpi);
|
private static partial int GdipGetDpiX(nint graphics, out float dpi);
|
||||||
|
|
||||||
public static float GetDpiX(IntPtr hwnd)
|
public static float GetDpiX(nint hwnd)
|
||||||
{
|
{
|
||||||
CheckStatus(GdipCreateFromHWND(hwnd, out IntPtr graphicsHandle));
|
CheckStatus(GdipCreateFromHWND(hwnd, out nint graphicsHandle));
|
||||||
CheckStatus(GdipGetDpiX(graphicsHandle, out float result));
|
CheckStatus(GdipGetDpiX(graphicsHandle, out float result));
|
||||||
CheckStatus(GdipDeleteGraphics(graphicsHandle));
|
CheckStatus(GdipDeleteGraphics(graphicsHandle));
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
public static partial HvResult hv_vm_get_max_vcpu_count(out uint max_vcpu_count);
|
public static partial HvResult hv_vm_get_max_vcpu_count(out uint max_vcpu_count);
|
||||||
|
|
||||||
[LibraryImport(LibraryName, SetLastError = true)]
|
[LibraryImport(LibraryName, SetLastError = true)]
|
||||||
public static partial HvResult hv_vm_create(IntPtr config);
|
public static partial HvResult hv_vm_create(nint config);
|
||||||
|
|
||||||
[LibraryImport(LibraryName, SetLastError = true)]
|
[LibraryImport(LibraryName, SetLastError = true)]
|
||||||
public static partial HvResult hv_vm_destroy();
|
public static partial HvResult hv_vm_destroy();
|
||||||
|
@ -288,7 +288,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
public static partial HvResult hv_vm_protect(ulong ipa, ulong size, HvMemoryFlags flags);
|
public static partial HvResult hv_vm_protect(ulong ipa, ulong size, HvMemoryFlags flags);
|
||||||
|
|
||||||
[LibraryImport(LibraryName, SetLastError = true)]
|
[LibraryImport(LibraryName, SetLastError = true)]
|
||||||
public unsafe static partial HvResult hv_vcpu_create(out ulong vcpu, ref HvVcpuExit* exit, IntPtr config);
|
public unsafe static partial HvResult hv_vcpu_create(out ulong vcpu, ref HvVcpuExit* exit, nint config);
|
||||||
|
|
||||||
[LibraryImport(LibraryName, SetLastError = true)]
|
[LibraryImport(LibraryName, SetLastError = true)]
|
||||||
public unsafe static partial HvResult hv_vcpu_destroy(ulong vcpu);
|
public unsafe static partial HvResult hv_vcpu_destroy(ulong vcpu);
|
||||||
|
|
|
@ -10,9 +10,9 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
class HvExecutionContextVcpu : IHvExecutionContext
|
class HvExecutionContextVcpu : IHvExecutionContext
|
||||||
{
|
{
|
||||||
private static readonly MemoryBlock _setSimdFpRegFuncMem;
|
private static readonly MemoryBlock _setSimdFpRegFuncMem;
|
||||||
private delegate HvResult SetSimdFpReg(ulong vcpu, HvSimdFPReg reg, in V128 value, IntPtr funcPtr);
|
private delegate HvResult SetSimdFpReg(ulong vcpu, HvSimdFPReg reg, in V128 value, nint funcPtr);
|
||||||
private static readonly SetSimdFpReg _setSimdFpReg;
|
private static readonly SetSimdFpReg _setSimdFpReg;
|
||||||
private static readonly IntPtr _setSimdFpRegNativePtr;
|
private static readonly nint _setSimdFpRegNativePtr;
|
||||||
|
|
||||||
static HvExecutionContextVcpu()
|
static HvExecutionContextVcpu()
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
|
|
||||||
_setSimdFpReg = Marshal.GetDelegateForFunctionPointer<SetSimdFpReg>(_setSimdFpRegFuncMem.Pointer);
|
_setSimdFpReg = Marshal.GetDelegateForFunctionPointer<SetSimdFpReg>(_setSimdFpRegFuncMem.Pointer);
|
||||||
|
|
||||||
if (NativeLibrary.TryLoad(HvApi.LibraryName, out IntPtr hvLibHandle))
|
if (NativeLibrary.TryLoad(HvApi.LibraryName, out nint hvLibHandle))
|
||||||
{
|
{
|
||||||
_setSimdFpRegNativePtr = NativeLibrary.GetExport(hvLibHandle, nameof(HvApi.hv_vcpu_set_simd_fp_reg));
|
_setSimdFpRegNativePtr = NativeLibrary.GetExport(hvLibHandle, nameof(HvApi.hv_vcpu_set_simd_fp_reg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
|
|
||||||
public int AddressSpaceBits { get; }
|
public int AddressSpaceBits { get; }
|
||||||
|
|
||||||
public IntPtr PageTablePointer => IntPtr.Zero;
|
public nint PageTablePointer => nint.Zero;
|
||||||
|
|
||||||
public MemoryManagerType Type => MemoryManagerType.SoftwarePageTable;
|
public MemoryManagerType Type => MemoryManagerType.SoftwarePageTable;
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
for (int i = 0; i < regions.Length; i++)
|
for (int i = 0; i < regions.Length; i++)
|
||||||
{
|
{
|
||||||
var guestRegion = guestRegions[i];
|
var guestRegion = guestRegions[i];
|
||||||
IntPtr pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
|
nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
|
||||||
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
|
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
|
|
||||||
// Create VCPU.
|
// Create VCPU.
|
||||||
HvVcpuExit* exitInfo = null;
|
HvVcpuExit* exitInfo = null;
|
||||||
HvApi.hv_vcpu_create(out ulong vcpuHandle, ref exitInfo, IntPtr.Zero).ThrowOnError();
|
HvApi.hv_vcpu_create(out ulong vcpuHandle, ref exitInfo, nint.Zero).ThrowOnError();
|
||||||
|
|
||||||
// Enable FP and SIMD instructions.
|
// Enable FP and SIMD instructions.
|
||||||
HvApi.hv_vcpu_set_sys_reg(vcpuHandle, HvSysReg.CPACR_EL1, 0b11 << 20).ThrowOnError();
|
HvApi.hv_vcpu_set_sys_reg(vcpuHandle, HvSysReg.CPACR_EL1, 0b11 << 20).ThrowOnError();
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Ryujinx.Cpu.AppleHv
|
||||||
{
|
{
|
||||||
if (++_addressSpaces == 1)
|
if (++_addressSpaces == 1)
|
||||||
{
|
{
|
||||||
HvApi.hv_vm_create(IntPtr.Zero).ThrowOnError();
|
HvApi.hv_vm_create(nint.Zero).ThrowOnError();
|
||||||
_ipaAllocator = ipaAllocator = new HvIpaAllocator();
|
_ipaAllocator = ipaAllocator = new HvIpaAllocator();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -307,7 +307,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
ulong size,
|
ulong size,
|
||||||
MemoryPermission protection,
|
MemoryPermission protection,
|
||||||
AddressSpacePartitioned addressSpace,
|
AddressSpacePartitioned addressSpace,
|
||||||
Action<ulong, IntPtr, ulong> updatePtCallback)
|
Action<ulong, nint, ulong> updatePtCallback)
|
||||||
{
|
{
|
||||||
if (_baseMemory.LazyInitMirrorForProtection(addressSpace, Address, Size, protection))
|
if (_baseMemory.LazyInitMirrorForProtection(addressSpace, Address, Size, protection))
|
||||||
{
|
{
|
||||||
|
@ -317,7 +317,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
updatePtCallback(va, _baseMemory.GetPointerForProtection(va - Address, size, protection), size);
|
updatePtCallback(va, _baseMemory.GetPointerForProtection(va - Address, size, protection), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr GetPointer(ulong va, ulong size)
|
public nint GetPointer(ulong va, ulong size)
|
||||||
{
|
{
|
||||||
Debug.Assert(va >= Address);
|
Debug.Assert(va >= Address);
|
||||||
Debug.Assert(va + size <= EndAddress);
|
Debug.Assert(va + size <= EndAddress);
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
private readonly AddressSpacePartitionAllocator _owner;
|
private readonly AddressSpacePartitionAllocator _owner;
|
||||||
private readonly PrivateMemoryAllocatorImpl<AddressSpacePartitionAllocator.Block>.Allocation _allocation;
|
private readonly PrivateMemoryAllocatorImpl<AddressSpacePartitionAllocator.Block>.Allocation _allocation;
|
||||||
|
|
||||||
public IntPtr Pointer => (IntPtr)((ulong)_allocation.Block.Memory.Pointer + _allocation.Offset);
|
public nint Pointer => (nint)((ulong)_allocation.Block.Memory.Pointer + _allocation.Offset);
|
||||||
|
|
||||||
public bool IsValid => _owner != null;
|
public bool IsValid => _owner != null;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
_allocation.Block.Memory.Reprotect(_allocation.Offset + offset, size, permission, throwOnFail);
|
_allocation.Block.Memory.Reprotect(_allocation.Offset + offset, size, permission, throwOnFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr GetPointer(ulong offset, ulong size)
|
public nint GetPointer(ulong offset, ulong size)
|
||||||
{
|
{
|
||||||
return _allocation.Block.Memory.GetPointer(_allocation.Offset + offset, size);
|
return _allocation.Block.Memory.GetPointer(_allocation.Offset + offset, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
_baseMemory.Reprotect(offset, size, permission, throwOnFail);
|
_baseMemory.Reprotect(offset, size, permission, throwOnFail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr GetPointer(ulong offset, ulong size)
|
public nint GetPointer(ulong offset, ulong size)
|
||||||
{
|
{
|
||||||
return _baseMemory.GetPointer(offset, size);
|
return _baseMemory.GetPointer(offset, size);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr GetPointerForProtection(ulong offset, ulong size, MemoryPermission permission)
|
public nint GetPointerForProtection(ulong offset, ulong size, MemoryPermission permission)
|
||||||
{
|
{
|
||||||
AddressSpacePartitionAllocation allocation = permission switch
|
AddressSpacePartitionAllocation allocation = permission switch
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
private readonly MemoryBlock _backingMemory;
|
private readonly MemoryBlock _backingMemory;
|
||||||
private readonly List<AddressSpacePartition> _partitions;
|
private readonly List<AddressSpacePartition> _partitions;
|
||||||
private readonly AddressSpacePartitionAllocator _asAllocator;
|
private readonly AddressSpacePartitionAllocator _asAllocator;
|
||||||
private readonly Action<ulong, IntPtr, ulong> _updatePtCallback;
|
private readonly Action<ulong, nint, ulong> _updatePtCallback;
|
||||||
private readonly bool _useProtectionMirrors;
|
private readonly bool _useProtectionMirrors;
|
||||||
|
|
||||||
public AddressSpacePartitioned(MemoryTracking tracking, MemoryBlock backingMemory, NativePageTable nativePageTable, bool useProtectionMirrors)
|
public AddressSpacePartitioned(MemoryTracking tracking, MemoryBlock backingMemory, NativePageTable nativePageTable, bool useProtectionMirrors)
|
||||||
|
@ -212,7 +212,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr GetPointer(ulong va, ulong size)
|
public nint GetPointer(ulong va, ulong size)
|
||||||
{
|
{
|
||||||
AddressSpacePartition partition = FindPartition(va);
|
AddressSpacePartition partition = FindPartition(va);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public IntPtr PageTablePointer => _nativePageTable.Pointer;
|
public nint PageTablePointer => _nativePageTable.Pointer;
|
||||||
|
|
||||||
public NativePageTable(ulong asSize)
|
public NativePageTable(ulong asSize)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
|
|
||||||
public void Unmap(ulong va, ulong size)
|
public void Unmap(ulong va, ulong size)
|
||||||
{
|
{
|
||||||
IntPtr guardPagePtr = GetGuardPagePointer();
|
nint guardPagePtr = GetGuardPagePointer();
|
||||||
|
|
||||||
while (size != 0)
|
while (size != 0)
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
return pte + (va & PageMask);
|
return pte + (va & PageMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(ulong va, IntPtr ptr, ulong size)
|
public void Update(ulong va, nint ptr, ulong size)
|
||||||
{
|
{
|
||||||
ulong remainingSize = size;
|
ulong remainingSize = size;
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
|
|
||||||
Debug.Assert(pageSpan.Length == _entriesPerPtPage);
|
Debug.Assert(pageSpan.Length == _entriesPerPtPage);
|
||||||
|
|
||||||
IntPtr guardPagePtr = GetGuardPagePointer();
|
nint guardPagePtr = GetGuardPagePointer();
|
||||||
|
|
||||||
for (int i = 0; i < pageSpan.Length; i++)
|
for (int i = 0; i < pageSpan.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -160,12 +160,12 @@ namespace Ryujinx.Cpu.Jit.HostTracked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPtr GetGuardPagePointer()
|
private nint GetGuardPagePointer()
|
||||||
{
|
{
|
||||||
return _nativePageTable.GetPointer(_nativePageTable.Size - _hostPageSize, _hostPageSize);
|
return _nativePageTable.GetPointer(_nativePageTable.Size - _hostPageSize, _hostPageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ulong GetPte(ulong va, IntPtr ptr)
|
private static ulong GetPte(ulong va, nint ptr)
|
||||||
{
|
{
|
||||||
Debug.Assert((va & PageMask) == 0);
|
Debug.Assert((va & PageMask) == 0);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.Jit
|
||||||
{
|
{
|
||||||
private readonly MemoryBlock _impl;
|
private readonly MemoryBlock _impl;
|
||||||
|
|
||||||
public IntPtr Pointer => _impl.Pointer;
|
public nint Pointer => _impl.Pointer;
|
||||||
|
|
||||||
public JitMemoryBlock(ulong size, MemoryAllocationFlags flags)
|
public JitMemoryBlock(ulong size, MemoryAllocationFlags flags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Ryujinx.Cpu.Jit
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Page table base pointer.
|
/// Page table base pointer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IntPtr PageTablePointer => _pageTable.Pointer;
|
public nint PageTablePointer => _pageTable.Pointer;
|
||||||
|
|
||||||
public MemoryManagerType Type => MemoryManagerType.SoftwarePageTable;
|
public MemoryManagerType Type => MemoryManagerType.SoftwarePageTable;
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ namespace Ryujinx.Cpu.Jit
|
||||||
for (int i = 0; i < regions.Length; i++)
|
for (int i = 0; i < regions.Length; i++)
|
||||||
{
|
{
|
||||||
var guestRegion = guestRegions[i];
|
var guestRegion = guestRegions[i];
|
||||||
IntPtr pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
|
nint pointer = _backingMemory.GetPointer(guestRegion.Address, guestRegion.Size);
|
||||||
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
|
regions[i] = new HostMemoryRange((nuint)(ulong)pointer, guestRegion.Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Cpu.Jit
|
||||||
|
|
||||||
public int AddressSpaceBits { get; }
|
public int AddressSpaceBits { get; }
|
||||||
|
|
||||||
public IntPtr PageTablePointer => _addressSpace.Base.Pointer;
|
public nint PageTablePointer => _addressSpace.Base.Pointer;
|
||||||
|
|
||||||
public MemoryManagerType Type => _unsafeMode ? MemoryManagerType.HostMappedUnsafe : MemoryManagerType.HostMapped;
|
public MemoryManagerType Type => _unsafeMode ? MemoryManagerType.HostMappedUnsafe : MemoryManagerType.HostMapped;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.Cpu.Jit
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool UsesPrivateAllocations => true;
|
public bool UsesPrivateAllocations => true;
|
||||||
|
|
||||||
public IntPtr PageTablePointer => _nativePageTable.PageTablePointer;
|
public nint PageTablePointer => _nativePageTable.PageTablePointer;
|
||||||
|
|
||||||
public MemoryManagerType Type => _unsafeMode ? MemoryManagerType.HostTrackedUnsafe : MemoryManagerType.HostTracked;
|
public MemoryManagerType Type => _unsafeMode ? MemoryManagerType.HostTrackedUnsafe : MemoryManagerType.HostTracked;
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ namespace Ryujinx.Cpu.Jit
|
||||||
{
|
{
|
||||||
(MemoryBlock memory, ulong rangeOffset, ulong rangeSize) = GetMemoryOffsetAndSize(va, endVa - va);
|
(MemoryBlock memory, ulong rangeOffset, ulong rangeSize) = GetMemoryOffsetAndSize(va, endVa - va);
|
||||||
|
|
||||||
regions.Add(new((UIntPtr)memory.GetPointer(rangeOffset, rangeSize), rangeSize));
|
regions.Add(new((nuint)memory.GetPointer(rangeOffset, rangeSize), rangeSize));
|
||||||
|
|
||||||
va += rangeSize;
|
va += rangeSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
IMemoryManager memoryManager,
|
IMemoryManager memoryManager,
|
||||||
ulong address,
|
ulong address,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr dispatchStubPtr,
|
nint dispatchStubPtr,
|
||||||
ExecutionMode executionMode,
|
ExecutionMode executionMode,
|
||||||
Architecture targetArch)
|
Architecture targetArch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32
|
||||||
IMemoryManager memoryManager,
|
IMemoryManager memoryManager,
|
||||||
ulong address,
|
ulong address,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr dispatchStubPtr,
|
nint dispatchStubPtr,
|
||||||
bool isThumb,
|
bool isThumb,
|
||||||
Architecture targetArch)
|
Architecture targetArch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,10 +24,10 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
||||||
public readonly MemoryManagerType MemoryManagerType;
|
public readonly MemoryManagerType MemoryManagerType;
|
||||||
public readonly TailMerger TailMerger;
|
public readonly TailMerger TailMerger;
|
||||||
public readonly AddressTable<ulong> FuncTable;
|
public readonly AddressTable<ulong> FuncTable;
|
||||||
public readonly IntPtr DispatchStubPointer;
|
public readonly nint DispatchStubPointer;
|
||||||
|
|
||||||
private readonly RegisterSaveRestore _registerSaveRestore;
|
private readonly RegisterSaveRestore _registerSaveRestore;
|
||||||
private readonly IntPtr _pageTablePointer;
|
private readonly nint _pageTablePointer;
|
||||||
|
|
||||||
public Context(
|
public Context(
|
||||||
CodeWriter writer,
|
CodeWriter writer,
|
||||||
|
@ -36,8 +36,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
||||||
TailMerger tailMerger,
|
TailMerger tailMerger,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
RegisterSaveRestore registerSaveRestore,
|
RegisterSaveRestore registerSaveRestore,
|
||||||
IntPtr dispatchStubPointer,
|
nint dispatchStubPointer,
|
||||||
IntPtr pageTablePointer)
|
nint pageTablePointer)
|
||||||
{
|
{
|
||||||
Writer = writer;
|
Writer = writer;
|
||||||
RegisterAllocator = registerAllocator;
|
RegisterAllocator = registerAllocator;
|
||||||
|
@ -226,7 +226,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, IntPtr dispatchStubPtr, bool isThumb)
|
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, nint dispatchStubPtr, bool isThumb)
|
||||||
{
|
{
|
||||||
MultiBlock multiBlock = Decoder<InstEmit>.DecodeMulti(cpuPreset, memoryManager, address, isThumb);
|
MultiBlock multiBlock = Decoder<InstEmit>.DecodeMulti(cpuPreset, memoryManager, address, isThumb);
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
||||||
TailMerger tailMerger,
|
TailMerger tailMerger,
|
||||||
Action writeEpilogue,
|
Action writeEpilogue,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr funcPtr,
|
nint funcPtr,
|
||||||
int spillBaseOffset,
|
int spillBaseOffset,
|
||||||
uint nextAddress,
|
uint nextAddress,
|
||||||
Operand guestAddress,
|
Operand guestAddress,
|
||||||
|
|
|
@ -324,27 +324,27 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
||||||
Udf(context, encoding, 0);
|
Udf(context, encoding, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetBkptHandlerPtr()
|
private static nint GetBkptHandlerPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Break);
|
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Break);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetSvcHandlerPtr()
|
private static nint GetSvcHandlerPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.SupervisorCall);
|
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.SupervisorCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetUdfHandlerPtr()
|
private static nint GetUdfHandlerPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Undefined);
|
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetCntpctEl0Ptr()
|
private static nint GetCntpctEl0Ptr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<Get64>(NativeInterface.GetCntpctEl0);
|
return Marshal.GetFunctionPointerForDelegate<Get64>(NativeInterface.GetCntpctEl0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr CheckSynchronizationPtr()
|
private static nint CheckSynchronizationPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<GetBool>(NativeInterface.CheckSynchronization);
|
return Marshal.GetFunctionPointerForDelegate<GetBool>(NativeInterface.CheckSynchronization);
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64
|
||||||
private static void WriteCall(
|
private static void WriteCall(
|
||||||
ref Assembler asm,
|
ref Assembler asm,
|
||||||
RegisterAllocator regAlloc,
|
RegisterAllocator regAlloc,
|
||||||
IntPtr funcPtr,
|
nint funcPtr,
|
||||||
bool skipContext,
|
bool skipContext,
|
||||||
int spillBaseOffset,
|
int spillBaseOffset,
|
||||||
int? resultRegister,
|
int? resultRegister,
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64
|
||||||
IMemoryManager memoryManager,
|
IMemoryManager memoryManager,
|
||||||
ulong address,
|
ulong address,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr dispatchStubPtr,
|
nint dispatchStubPtr,
|
||||||
Architecture targetArch)
|
Architecture targetArch)
|
||||||
{
|
{
|
||||||
if (targetArch == Architecture.Arm64)
|
if (targetArch == Architecture.Arm64)
|
||||||
|
|
|
@ -20,11 +20,11 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
public readonly RegisterAllocator RegisterAllocator;
|
public readonly RegisterAllocator RegisterAllocator;
|
||||||
public readonly TailMerger TailMerger;
|
public readonly TailMerger TailMerger;
|
||||||
public readonly AddressTable<ulong> FuncTable;
|
public readonly AddressTable<ulong> FuncTable;
|
||||||
public readonly IntPtr DispatchStubPointer;
|
public readonly nint DispatchStubPointer;
|
||||||
|
|
||||||
private readonly MultiBlock _multiBlock;
|
private readonly MultiBlock _multiBlock;
|
||||||
private readonly RegisterSaveRestore _registerSaveRestore;
|
private readonly RegisterSaveRestore _registerSaveRestore;
|
||||||
private readonly IntPtr _pageTablePointer;
|
private readonly nint _pageTablePointer;
|
||||||
|
|
||||||
public Context(
|
public Context(
|
||||||
CodeWriter writer,
|
CodeWriter writer,
|
||||||
|
@ -33,8 +33,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
RegisterSaveRestore registerSaveRestore,
|
RegisterSaveRestore registerSaveRestore,
|
||||||
MultiBlock multiBlock,
|
MultiBlock multiBlock,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr dispatchStubPointer,
|
nint dispatchStubPointer,
|
||||||
IntPtr pageTablePointer)
|
nint pageTablePointer)
|
||||||
{
|
{
|
||||||
Writer = writer;
|
Writer = writer;
|
||||||
RegisterAllocator = registerAllocator;
|
RegisterAllocator = registerAllocator;
|
||||||
|
@ -304,7 +304,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, IntPtr dispatchStubPtr)
|
public static CompiledFunction Compile(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, AddressTable<ulong> funcTable, nint dispatchStubPtr)
|
||||||
{
|
{
|
||||||
MultiBlock multiBlock = Decoder.DecodeMulti(cpuPreset, memoryManager, address);
|
MultiBlock multiBlock = Decoder.DecodeMulti(cpuPreset, memoryManager, address);
|
||||||
|
|
||||||
|
|
|
@ -144,27 +144,27 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
return name == InstName.Svc;
|
return name == InstName.Svc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetBrkHandlerPtr()
|
private static nint GetBrkHandlerPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Break);
|
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Break);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetSvcHandlerPtr()
|
private static nint GetSvcHandlerPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.SupervisorCall);
|
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.SupervisorCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetUdfHandlerPtr()
|
private static nint GetUdfHandlerPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Undefined);
|
return Marshal.GetFunctionPointerForDelegate<SoftwareInterruptHandler>(NativeInterface.Undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr GetCntpctEl0Ptr()
|
private static nint GetCntpctEl0Ptr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<Get64>(NativeInterface.GetCntpctEl0);
|
return Marshal.GetFunctionPointerForDelegate<Get64>(NativeInterface.GetCntpctEl0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr CheckSynchronizationPtr()
|
private static nint CheckSynchronizationPtr()
|
||||||
{
|
{
|
||||||
return Marshal.GetFunctionPointerForDelegate<GetBool>(NativeInterface.CheckSynchronization);
|
return Marshal.GetFunctionPointerForDelegate<GetBool>(NativeInterface.CheckSynchronization);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
TailMerger tailMerger,
|
TailMerger tailMerger,
|
||||||
Action writeEpilogue,
|
Action writeEpilogue,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr dispatchStubPtr,
|
nint dispatchStubPtr,
|
||||||
InstName name,
|
InstName name,
|
||||||
ulong pc,
|
ulong pc,
|
||||||
uint encoding,
|
uint encoding,
|
||||||
|
@ -298,7 +298,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
TailMerger tailMerger,
|
TailMerger tailMerger,
|
||||||
Action writeEpilogue,
|
Action writeEpilogue,
|
||||||
AddressTable<ulong> funcTable,
|
AddressTable<ulong> funcTable,
|
||||||
IntPtr funcPtr,
|
nint funcPtr,
|
||||||
int spillBaseOffset,
|
int spillBaseOffset,
|
||||||
ulong pc,
|
ulong pc,
|
||||||
Operand guestAddress,
|
Operand guestAddress,
|
||||||
|
@ -369,7 +369,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
|
||||||
private static void WriteCall(
|
private static void WriteCall(
|
||||||
ref Assembler asm,
|
ref Assembler asm,
|
||||||
RegisterAllocator regAlloc,
|
RegisterAllocator regAlloc,
|
||||||
IntPtr funcPtr,
|
nint funcPtr,
|
||||||
int spillBaseOffset,
|
int spillBaseOffset,
|
||||||
int? resultRegister,
|
int? resultRegister,
|
||||||
params ulong[] callArgs)
|
params ulong[] callArgs)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[LibraryImport("kernel32.dll", SetLastError = true)]
|
[LibraryImport("kernel32.dll", SetLastError = true)]
|
||||||
public static partial IntPtr FlushInstructionCache(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize);
|
public static partial nint FlushInstructionCache(nint hProcess, nint lpAddress, nuint dwSize);
|
||||||
|
|
||||||
public static void Initialize(IJitMemoryAllocator allocator)
|
public static void Initialize(IJitMemoryAllocator allocator)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe static IntPtr Map(ReadOnlySpan<byte> code)
|
public unsafe static nint Map(ReadOnlySpan<byte> code)
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
|
|
||||||
int funcOffset = Allocate(code.Length);
|
int funcOffset = Allocate(code.Length);
|
||||||
|
|
||||||
IntPtr funcPtr = _jitRegion.Pointer + funcOffset;
|
nint funcPtr = _jitRegion.Pointer + funcOffset;
|
||||||
|
|
||||||
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
{
|
{
|
||||||
fixed (byte* codePtr = code)
|
fixed (byte* codePtr = code)
|
||||||
{
|
{
|
||||||
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length);
|
JitSupportDarwin.Copy(funcPtr, (nint)codePtr, (ulong)code.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
|
||||||
{
|
{
|
||||||
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (UIntPtr)code.Length);
|
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (nuint)code.Length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Unmap(IntPtr pointer)
|
public static void Unmap(nint pointer)
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invalidate(IntPtr basePointer, ulong size)
|
public void Invalidate(nint basePointer, ulong size)
|
||||||
{
|
{
|
||||||
if (_needsInvalidation)
|
if (_needsInvalidation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,9 +8,9 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
static partial class JitSupportDarwin
|
static partial class JitSupportDarwin
|
||||||
{
|
{
|
||||||
[LibraryImport("libarmeilleure-jitsupport", EntryPoint = "armeilleure_jit_memcpy")]
|
[LibraryImport("libarmeilleure-jitsupport", EntryPoint = "armeilleure_jit_memcpy")]
|
||||||
public static partial void Copy(IntPtr dst, IntPtr src, ulong n);
|
public static partial void Copy(nint dst, nint src, ulong n);
|
||||||
|
|
||||||
[LibraryImport("libc", EntryPoint = "sys_icache_invalidate", SetLastError = true)]
|
[LibraryImport("libc", EntryPoint = "sys_icache_invalidate", SetLastError = true)]
|
||||||
public static partial void SysIcacheInvalidate(IntPtr start, IntPtr len);
|
public static partial void SysIcacheInvalidate(nint start, nint len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
private readonly CacheMemoryAllocator _cacheAllocator;
|
private readonly CacheMemoryAllocator _cacheAllocator;
|
||||||
|
|
||||||
public CacheMemoryAllocator Allocator => _cacheAllocator;
|
public CacheMemoryAllocator Allocator => _cacheAllocator;
|
||||||
public IntPtr Pointer => _region.Block.Pointer;
|
public nint Pointer => _region.Block.Pointer;
|
||||||
|
|
||||||
public MemoryCache(IJitMemoryAllocator allocator, ulong size)
|
public MemoryCache(IJitMemoryAllocator allocator, ulong size)
|
||||||
{
|
{
|
||||||
|
@ -110,10 +110,10 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
{
|
{
|
||||||
public readonly int Offset;
|
public readonly int Offset;
|
||||||
public readonly int Size;
|
public readonly int Size;
|
||||||
public readonly IntPtr FuncPtr;
|
public readonly nint FuncPtr;
|
||||||
private int _useCount;
|
private int _useCount;
|
||||||
|
|
||||||
public ThreadLocalCacheEntry(int offset, int size, IntPtr funcPtr)
|
public ThreadLocalCacheEntry(int offset, int size, nint funcPtr)
|
||||||
{
|
{
|
||||||
Offset = offset;
|
Offset = offset;
|
||||||
Size = size;
|
Size = size;
|
||||||
|
@ -140,9 +140,9 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
_lock = new();
|
_lock = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe IntPtr Map(IntPtr framePointer, ReadOnlySpan<byte> code, ulong guestAddress, ulong guestSize)
|
public unsafe nint Map(nint framePointer, ReadOnlySpan<byte> code, ulong guestAddress, ulong guestSize)
|
||||||
{
|
{
|
||||||
if (TryGetThreadLocalFunction(guestAddress, out IntPtr funcPtr))
|
if (TryGetThreadLocalFunction(guestAddress, out nint funcPtr))
|
||||||
{
|
{
|
||||||
return funcPtr;
|
return funcPtr;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe IntPtr MapPageAligned(ReadOnlySpan<byte> code)
|
public unsafe nint MapPageAligned(ReadOnlySpan<byte> code)
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
|
|
||||||
Debug.Assert((funcOffset & ((int)MemoryBlock.GetPageSize() - 1)) == 0);
|
Debug.Assert((funcOffset & ((int)MemoryBlock.GetPageSize() - 1)) == 0);
|
||||||
|
|
||||||
IntPtr funcPtr = _sharedCache.Pointer + funcOffset;
|
nint funcPtr = _sharedCache.Pointer + funcOffset;
|
||||||
code.CopyTo(new Span<byte>((void*)funcPtr, code.Length));
|
code.CopyTo(new Span<byte>((void*)funcPtr, code.Length));
|
||||||
|
|
||||||
_sharedCache.ReprotectAsRx(funcOffset, sizeAligned);
|
_sharedCache.ReprotectAsRx(funcOffset, sizeAligned);
|
||||||
|
@ -188,7 +188,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryGetThreadLocalFunction(ulong guestAddress, out IntPtr funcPtr)
|
private bool TryGetThreadLocalFunction(ulong guestAddress, out nint funcPtr)
|
||||||
{
|
{
|
||||||
if ((_threadLocalCache ??= new()).TryGetValue(guestAddress, out var entry))
|
if ((_threadLocalCache ??= new()).TryGetValue(guestAddress, out var entry))
|
||||||
{
|
{
|
||||||
|
@ -209,12 +209,12 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
funcPtr = IntPtr.Zero;
|
funcPtr = nint.Zero;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearThreadLocalCache(IntPtr framePointer)
|
private void ClearThreadLocalCache(nint framePointer)
|
||||||
{
|
{
|
||||||
// Try to delete functions that are already on the shared cache
|
// Try to delete functions that are already on the shared cache
|
||||||
// and no longer being executed.
|
// and no longer being executed.
|
||||||
|
@ -296,14 +296,14 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
||||||
_threadLocalCache = null;
|
_threadLocalCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe IntPtr AddThreadLocalFunction(ReadOnlySpan<byte> code, ulong guestAddress)
|
private unsafe nint AddThreadLocalFunction(ReadOnlySpan<byte> code, ulong guestAddress)
|
||||||
{
|
{
|
||||||
int alignedSize = BitUtils.AlignUp(code.Length, (int)MemoryBlock.GetPageSize());
|
int alignedSize = BitUtils.AlignUp(code.Length, (int)MemoryBlock.GetPageSize());
|
||||||
int funcOffset = _localCache.Allocate(alignedSize);
|
int funcOffset = _localCache.Allocate(alignedSize);
|
||||||
|
|
||||||
Debug.Assert((funcOffset & (int)(MemoryBlock.GetPageSize() - 1)) == 0);
|
Debug.Assert((funcOffset & (int)(MemoryBlock.GetPageSize() - 1)) == 0);
|
||||||
|
|
||||||
IntPtr funcPtr = _localCache.Pointer + funcOffset;
|
nint funcPtr = _localCache.Pointer + funcOffset;
|
||||||
code.CopyTo(new Span<byte>((void*)funcPtr, code.Length));
|
code.CopyTo(new Span<byte>((void*)funcPtr, code.Length));
|
||||||
|
|
||||||
(_threadLocalCache ??= new()).Add(guestAddress, new(funcOffset, code.Length, funcPtr));
|
(_threadLocalCache ??= new()).Add(guestAddress, new(funcOffset, code.Length, funcPtr));
|
||||||
|
|
|
@ -6,13 +6,13 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
|
||||||
{
|
{
|
||||||
class StackWalker : IStackWalker
|
class StackWalker : IStackWalker
|
||||||
{
|
{
|
||||||
public IEnumerable<ulong> GetCallStack(IntPtr framePointer, IntPtr codeRegionStart, int codeRegionSize, IntPtr codeRegion2Start, int codeRegion2Size)
|
public IEnumerable<ulong> GetCallStack(nint framePointer, nint codeRegionStart, int codeRegionSize, nint codeRegion2Start, int codeRegion2Size)
|
||||||
{
|
{
|
||||||
List<ulong> functionPointers = new();
|
List<ulong> functionPointers = new();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
IntPtr functionPointer = Marshal.ReadIntPtr(framePointer, IntPtr.Size);
|
nint functionPointer = Marshal.ReadIntPtr(framePointer, nint.Size);
|
||||||
|
|
||||||
if ((functionPointer < codeRegionStart || functionPointer >= codeRegionStart + codeRegionSize) &&
|
if ((functionPointer < codeRegionStart || functionPointer >= codeRegionStart + codeRegionSize) &&
|
||||||
(functionPointer < codeRegion2Start || functionPointer >= codeRegion2Start + codeRegion2Size))
|
(functionPointer < codeRegion2Start || functionPointer >= codeRegion2Start + codeRegion2Size))
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
{
|
{
|
||||||
interface IStackWalker
|
interface IStackWalker
|
||||||
{
|
{
|
||||||
IEnumerable<ulong> GetCallStack(IntPtr framePointer, IntPtr codeRegionStart, int codeRegionSize, IntPtr codeRegion2Start, int codeRegion2Size);
|
IEnumerable<ulong> GetCallStack(nint framePointer, nint codeRegionStart, int codeRegionSize, nint codeRegion2Start, int codeRegion2Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
return GetContext().CntpctEl0;
|
return GetContext().CntpctEl0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ulong GetFunctionAddress(IntPtr framePointer, ulong address)
|
public static ulong GetFunctionAddress(nint framePointer, ulong address)
|
||||||
{
|
{
|
||||||
return (ulong)Context.Translator.GetOrTranslatePointer(framePointer, address, GetContext().ExecutionMode);
|
return (ulong)Context.Translator.GetOrTranslatePointer(framePointer, address, GetContext().ExecutionMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.Cpu.LightningJit.State
|
||||||
|
|
||||||
private readonly NativeContext _nativeContext;
|
private readonly NativeContext _nativeContext;
|
||||||
|
|
||||||
internal IntPtr NativeContextPtr => _nativeContext.BasePtr;
|
internal nint NativeContextPtr => _nativeContext.BasePtr;
|
||||||
|
|
||||||
private bool _interrupted;
|
private bool _interrupted;
|
||||||
private readonly ICounter _counter;
|
private readonly ICounter _counter;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Ryujinx.Cpu.LightningJit.State
|
||||||
|
|
||||||
private readonly IJitMemoryBlock _block;
|
private readonly IJitMemoryBlock _block;
|
||||||
|
|
||||||
public IntPtr BasePtr => _block.Pointer;
|
public nint BasePtr => _block.Pointer;
|
||||||
|
|
||||||
public NativeContext(IJitMemoryAllocator allocator)
|
public NativeContext(IJitMemoryAllocator allocator)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,10 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
{
|
{
|
||||||
class TranslatedFunction
|
class TranslatedFunction
|
||||||
{
|
{
|
||||||
public IntPtr FuncPointer { get; }
|
public nint FuncPointer { get; }
|
||||||
public ulong GuestSize { get; }
|
public ulong GuestSize { get; }
|
||||||
|
|
||||||
public TranslatedFunction(IntPtr funcPointer, ulong guestSize)
|
public TranslatedFunction(nint funcPointer, ulong guestSize)
|
||||||
{
|
{
|
||||||
FuncPointer = funcPointer;
|
FuncPointer = funcPointer;
|
||||||
GuestSize = guestSize;
|
GuestSize = guestSize;
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
_noWxCache?.ClearEntireThreadLocalCache();
|
_noWxCache?.ClearEntireThreadLocalCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal IntPtr GetOrTranslatePointer(IntPtr framePointer, ulong address, ExecutionMode mode)
|
internal nint GetOrTranslatePointer(nint framePointer, ulong address, ExecutionMode mode)
|
||||||
{
|
{
|
||||||
if (_noWxCache != null)
|
if (_noWxCache != null)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
private TranslatedFunction Translate(ulong address, ExecutionMode mode)
|
private TranslatedFunction Translate(ulong address, ExecutionMode mode)
|
||||||
{
|
{
|
||||||
CompiledFunction func = Compile(address, mode);
|
CompiledFunction func = Compile(address, mode);
|
||||||
IntPtr funcPointer = JitCache.Map(func.Code);
|
nint funcPointer = JitCache.Map(func.Code);
|
||||||
|
|
||||||
return new TranslatedFunction(funcPointer, (ulong)func.GuestCodeLength);
|
return new TranslatedFunction(funcPointer, (ulong)func.GuestCodeLength);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,31 +10,31 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Cpu.LightningJit
|
namespace Ryujinx.Cpu.LightningJit
|
||||||
{
|
{
|
||||||
delegate void DispatcherFunction(IntPtr nativeContext, ulong startAddress);
|
delegate void DispatcherFunction(nint nativeContext, ulong startAddress);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a stub manager.
|
/// Represents a stub manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class TranslatorStubs : IDisposable
|
class TranslatorStubs : IDisposable
|
||||||
{
|
{
|
||||||
private delegate ulong GetFunctionAddressDelegate(IntPtr framePointer, ulong address);
|
private delegate ulong GetFunctionAddressDelegate(nint framePointer, ulong address);
|
||||||
|
|
||||||
private readonly Lazy<IntPtr> _slowDispatchStub;
|
private readonly Lazy<nint> _slowDispatchStub;
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
private readonly AddressTable<ulong> _functionTable;
|
private readonly AddressTable<ulong> _functionTable;
|
||||||
private readonly NoWxCache _noWxCache;
|
private readonly NoWxCache _noWxCache;
|
||||||
private readonly GetFunctionAddressDelegate _getFunctionAddressRef;
|
private readonly GetFunctionAddressDelegate _getFunctionAddressRef;
|
||||||
private readonly IntPtr _getFunctionAddress;
|
private readonly nint _getFunctionAddress;
|
||||||
private readonly Lazy<IntPtr> _dispatchStub;
|
private readonly Lazy<nint> _dispatchStub;
|
||||||
private readonly Lazy<DispatcherFunction> _dispatchLoop;
|
private readonly Lazy<DispatcherFunction> _dispatchLoop;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the dispatch stub.
|
/// Gets the dispatch stub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
||||||
public IntPtr DispatchStub
|
public nint DispatchStub
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
/// Gets the slow dispatch stub.
|
/// Gets the slow dispatch stub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
/// <exception cref="ObjectDisposedException"><see cref="TranslatorStubs"/> instance was disposed</exception>
|
||||||
public IntPtr SlowDispatchStub
|
public nint SlowDispatchStub
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -138,7 +138,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
/// Generates a <see cref="DispatchStub"/>.
|
/// Generates a <see cref="DispatchStub"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Generated <see cref="DispatchStub"/></returns>
|
/// <returns>Generated <see cref="DispatchStub"/></returns>
|
||||||
private IntPtr GenerateDispatchStub()
|
private nint GenerateDispatchStub()
|
||||||
{
|
{
|
||||||
List<int> branchToFallbackOffsets = new();
|
List<int> branchToFallbackOffsets = new();
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
/// Generates a <see cref="SlowDispatchStub"/>.
|
/// Generates a <see cref="SlowDispatchStub"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Generated <see cref="SlowDispatchStub"/></returns>
|
/// <returns>Generated <see cref="SlowDispatchStub"/></returns>
|
||||||
private IntPtr GenerateSlowDispatchStub()
|
private nint GenerateSlowDispatchStub()
|
||||||
{
|
{
|
||||||
CodeWriter writer = new();
|
CodeWriter writer = new();
|
||||||
|
|
||||||
|
@ -350,12 +350,12 @@ namespace Ryujinx.Cpu.LightningJit
|
||||||
throw new PlatformNotSupportedException();
|
throw new PlatformNotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr pointer = Map(writer.AsByteSpan());
|
nint pointer = Map(writer.AsByteSpan());
|
||||||
|
|
||||||
return Marshal.GetDelegateForFunctionPointer<DispatcherFunction>(pointer);
|
return Marshal.GetDelegateForFunctionPointer<DispatcherFunction>(pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPtr Map(ReadOnlySpan<byte> code)
|
private nint Map(ReadOnlySpan<byte> code)
|
||||||
{
|
{
|
||||||
if (_noWxCache != null)
|
if (_noWxCache != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace Ryujinx.Cpu
|
||||||
_mirrorAddress = (ulong)addressSpaceMirror.Pointer;
|
_mirrorAddress = (ulong)addressSpaceMirror.Pointer;
|
||||||
ulong endAddressMirror = _mirrorAddress + addressSpace.Size;
|
ulong endAddressMirror = _mirrorAddress + addressSpace.Size;
|
||||||
|
|
||||||
bool addedMirror = NativeSignalHandler.AddTrackedRegion((nuint)_mirrorAddress, (nuint)endAddressMirror, IntPtr.Zero);
|
bool addedMirror = NativeSignalHandler.AddTrackedRegion((nuint)_mirrorAddress, (nuint)endAddressMirror, nint.Zero);
|
||||||
|
|
||||||
if (!addedMirror)
|
if (!addedMirror)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.Cpu.Signal
|
||||||
public int IsActive;
|
public int IsActive;
|
||||||
public nuint RangeAddress;
|
public nuint RangeAddress;
|
||||||
public nuint RangeEndAddress;
|
public nuint RangeEndAddress;
|
||||||
public IntPtr ActionPointer;
|
public nint ActionPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
[InlineArray(NativeSignalHandlerGenerator.MaxTrackedRanges)]
|
[InlineArray(NativeSignalHandlerGenerator.MaxTrackedRanges)]
|
||||||
|
@ -54,8 +54,8 @@ namespace Ryujinx.Cpu.Signal
|
||||||
|
|
||||||
static class NativeSignalHandler
|
static class NativeSignalHandler
|
||||||
{
|
{
|
||||||
private static readonly IntPtr _handlerConfig;
|
private static readonly nint _handlerConfig;
|
||||||
private static IntPtr _signalHandlerPtr;
|
private static nint _signalHandlerPtr;
|
||||||
|
|
||||||
private static MemoryBlock _codeBlock;
|
private static MemoryBlock _codeBlock;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace Ryujinx.Cpu.Signal
|
||||||
config = new SignalHandlerConfig();
|
config = new SignalHandlerConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InitializeSignalHandler(Func<IntPtr, IntPtr, IntPtr> customSignalHandlerFactory = null)
|
public static void InitializeSignalHandler(Func<nint, nint, nint> customSignalHandlerFactory = null)
|
||||||
{
|
{
|
||||||
if (_initialized)
|
if (_initialized)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ namespace Ryujinx.Cpu.Signal
|
||||||
|
|
||||||
if (customSignalHandlerFactory != null)
|
if (customSignalHandlerFactory != null)
|
||||||
{
|
{
|
||||||
_signalHandlerPtr = customSignalHandlerFactory(IntPtr.Zero, _signalHandlerPtr);
|
_signalHandlerPtr = customSignalHandlerFactory(nint.Zero, _signalHandlerPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowsSignalHandlerRegistration.RegisterExceptionHandler(_signalHandlerPtr);
|
WindowsSignalHandlerRegistration.RegisterExceptionHandler(_signalHandlerPtr);
|
||||||
|
@ -121,7 +121,7 @@ namespace Ryujinx.Cpu.Signal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr MapCode(ReadOnlySpan<byte> code)
|
private static nint MapCode(ReadOnlySpan<byte> code)
|
||||||
{
|
{
|
||||||
Debug.Assert(_codeBlock == null);
|
Debug.Assert(_codeBlock == null);
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ namespace Ryujinx.Cpu.Signal
|
||||||
return ref Unsafe.AsRef<SignalHandlerConfig>((void*)_handlerConfig);
|
return ref Unsafe.AsRef<SignalHandlerConfig>((void*)_handlerConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AddTrackedRegion(nuint address, nuint endAddress, IntPtr action)
|
public static bool AddTrackedRegion(nuint address, nuint endAddress, nint action)
|
||||||
{
|
{
|
||||||
Span<SignalHandlerRange> ranges = GetConfigRef().Ranges;
|
Span<SignalHandlerRange> ranges = GetConfigRef().Ranges;
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@ namespace Ryujinx.Cpu.Signal
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
public struct SigAction
|
public struct SigAction
|
||||||
{
|
{
|
||||||
public IntPtr sa_handler;
|
public nint sa_handler;
|
||||||
public SigSet sa_mask;
|
public SigSet sa_mask;
|
||||||
public int sa_flags;
|
public int sa_flags;
|
||||||
public IntPtr sa_restorer;
|
public nint sa_restorer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int SIGSEGV = 11;
|
private const int SIGSEGV = 11;
|
||||||
|
@ -28,14 +28,14 @@ namespace Ryujinx.Cpu.Signal
|
||||||
private static partial int sigaction(int signum, ref SigAction sigAction, out SigAction oldAction);
|
private static partial int sigaction(int signum, ref SigAction sigAction, out SigAction oldAction);
|
||||||
|
|
||||||
[LibraryImport("libc", SetLastError = true)]
|
[LibraryImport("libc", SetLastError = true)]
|
||||||
private static partial int sigaction(int signum, IntPtr sigAction, out SigAction oldAction);
|
private static partial int sigaction(int signum, nint sigAction, out SigAction oldAction);
|
||||||
|
|
||||||
[LibraryImport("libc", SetLastError = true)]
|
[LibraryImport("libc", SetLastError = true)]
|
||||||
private static partial int sigemptyset(ref SigSet set);
|
private static partial int sigemptyset(ref SigSet set);
|
||||||
|
|
||||||
public static SigAction GetSegfaultExceptionHandler()
|
public static SigAction GetSegfaultExceptionHandler()
|
||||||
{
|
{
|
||||||
int result = sigaction(SIGSEGV, IntPtr.Zero, out SigAction old);
|
int result = sigaction(SIGSEGV, nint.Zero, out SigAction old);
|
||||||
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ namespace Ryujinx.Cpu.Signal
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SigAction RegisterExceptionHandler(IntPtr action)
|
public static SigAction RegisterExceptionHandler(nint action)
|
||||||
{
|
{
|
||||||
SigAction sig = new()
|
SigAction sig = new()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,17 +6,17 @@ namespace Ryujinx.Cpu.Signal
|
||||||
static partial class WindowsSignalHandlerRegistration
|
static partial class WindowsSignalHandlerRegistration
|
||||||
{
|
{
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
private static partial IntPtr AddVectoredExceptionHandler(uint first, IntPtr handler);
|
private static partial nint AddVectoredExceptionHandler(uint first, nint handler);
|
||||||
|
|
||||||
[LibraryImport("kernel32.dll")]
|
[LibraryImport("kernel32.dll")]
|
||||||
private static partial ulong RemoveVectoredExceptionHandler(IntPtr handle);
|
private static partial ulong RemoveVectoredExceptionHandler(nint handle);
|
||||||
|
|
||||||
public static IntPtr RegisterExceptionHandler(IntPtr action)
|
public static nint RegisterExceptionHandler(nint action)
|
||||||
{
|
{
|
||||||
return AddVectoredExceptionHandler(1, action);
|
return AddVectoredExceptionHandler(1, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool RemoveExceptionHandler(IntPtr handle)
|
public static bool RemoveExceptionHandler(nint handle)
|
||||||
{
|
{
|
||||||
return RemoveVectoredExceptionHandler(handle) != 0;
|
return RemoveVectoredExceptionHandler(handle) != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Device
|
||||||
{
|
{
|
||||||
uint alignedOffset = index * RegisterSize;
|
uint alignedOffset = index * RegisterSize;
|
||||||
|
|
||||||
var readCallback = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_readCallbacks), (IntPtr)index);
|
var readCallback = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_readCallbacks), (nint)index);
|
||||||
if (readCallback != null)
|
if (readCallback != null)
|
||||||
{
|
{
|
||||||
return readCallback();
|
return readCallback();
|
||||||
|
@ -106,7 +106,7 @@ namespace Ryujinx.Graphics.Device
|
||||||
|
|
||||||
GetRefIntAlignedUncheck(index) = data;
|
GetRefIntAlignedUncheck(index) = data;
|
||||||
|
|
||||||
Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_writeCallbacks), (IntPtr)index)?.Invoke(data);
|
Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_writeCallbacks), (nint)index)?.Invoke(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Device
|
||||||
changed = storage != data;
|
changed = storage != data;
|
||||||
storage = data;
|
storage = data;
|
||||||
|
|
||||||
Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_writeCallbacks), (IntPtr)index)?.Invoke(data);
|
Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_writeCallbacks), (nint)index)?.Invoke(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -153,13 +153,13 @@ namespace Ryujinx.Graphics.Device
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private ref T GetRefUnchecked<T>(uint offset) where T : unmanaged
|
private ref T GetRefUnchecked<T>(uint offset) where T : unmanaged
|
||||||
{
|
{
|
||||||
return ref Unsafe.As<TState, T>(ref Unsafe.AddByteOffset(ref State, (IntPtr)offset));
|
return ref Unsafe.As<TState, T>(ref Unsafe.AddByteOffset(ref State, (nint)offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private ref int GetRefIntAlignedUncheck(ulong index)
|
private ref int GetRefIntAlignedUncheck(ulong index)
|
||||||
{
|
{
|
||||||
return ref Unsafe.Add(ref Unsafe.As<TState, int>(ref State), (IntPtr)index);
|
return ref Unsafe.Add(ref Unsafe.As<TState, int>(ref State), (nint)index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
|
|
||||||
if (index < BlockSize)
|
if (index < BlockSize)
|
||||||
{
|
{
|
||||||
int groupIndex = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_registerToGroupMapping), (IntPtr)index);
|
int groupIndex = Unsafe.Add(ref MemoryMarshal.GetArrayDataReference(_registerToGroupMapping), (nint)index);
|
||||||
if (groupIndex != 0)
|
if (groupIndex != 0)
|
||||||
{
|
{
|
||||||
groupIndex--;
|
groupIndex--;
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||||
|
|
||||||
FFmpegApi.av_log_format_line(ptr, level, format, vl, lineBuffer, lineSize, &printPrefix);
|
FFmpegApi.av_log_format_line(ptr, level, format, vl, lineBuffer, lineSize, &printPrefix);
|
||||||
|
|
||||||
string line = Marshal.PtrToStringAnsi((IntPtr)lineBuffer).Trim();
|
string line = Marshal.PtrToStringAnsi((nint)lineBuffer).Trim();
|
||||||
|
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,15 +12,15 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public int Capabilities;
|
public int Capabilities;
|
||||||
public byte MaxLowRes;
|
public byte MaxLowRes;
|
||||||
public unsafe AVRational* SupportedFramerates;
|
public unsafe AVRational* SupportedFramerates;
|
||||||
public IntPtr PixFmts;
|
public nint PixFmts;
|
||||||
public IntPtr SupportedSamplerates;
|
public nint SupportedSamplerates;
|
||||||
public IntPtr SampleFmts;
|
public nint SampleFmts;
|
||||||
// Deprecated
|
// Deprecated
|
||||||
public unsafe ulong* ChannelLayouts;
|
public unsafe ulong* ChannelLayouts;
|
||||||
public unsafe IntPtr PrivClass;
|
public unsafe nint PrivClass;
|
||||||
public IntPtr Profiles;
|
public nint Profiles;
|
||||||
public unsafe byte* WrapperName;
|
public unsafe byte* WrapperName;
|
||||||
public IntPtr ChLayouts;
|
public nint ChLayouts;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,13 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public int Capabilities;
|
public int Capabilities;
|
||||||
public byte MaxLowRes;
|
public byte MaxLowRes;
|
||||||
public unsafe AVRational* SupportedFramerates;
|
public unsafe AVRational* SupportedFramerates;
|
||||||
public IntPtr PixFmts;
|
public nint PixFmts;
|
||||||
public IntPtr SupportedSamplerates;
|
public nint SupportedSamplerates;
|
||||||
public IntPtr SampleFmts;
|
public nint SampleFmts;
|
||||||
// Deprecated
|
// Deprecated
|
||||||
public unsafe ulong* ChannelLayouts;
|
public unsafe ulong* ChannelLayouts;
|
||||||
public unsafe IntPtr PrivClass;
|
public unsafe nint PrivClass;
|
||||||
public IntPtr Profiles;
|
public nint Profiles;
|
||||||
public unsafe byte* WrapperName;
|
public unsafe byte* WrapperName;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,22 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
struct AVCodecContext
|
struct AVCodecContext
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649 // Field is never assigned to
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public unsafe IntPtr AvClass;
|
public unsafe nint AvClass;
|
||||||
public int LogLevelOffset;
|
public int LogLevelOffset;
|
||||||
public int CodecType;
|
public int CodecType;
|
||||||
public unsafe AVCodec* Codec;
|
public unsafe AVCodec* Codec;
|
||||||
public AVCodecID CodecId;
|
public AVCodecID CodecId;
|
||||||
public uint CodecTag;
|
public uint CodecTag;
|
||||||
public IntPtr PrivData;
|
public nint PrivData;
|
||||||
public IntPtr Internal;
|
public nint Internal;
|
||||||
public IntPtr Opaque;
|
public nint Opaque;
|
||||||
public long BitRate;
|
public long BitRate;
|
||||||
public int BitRateTolerance;
|
public int BitRateTolerance;
|
||||||
public int GlobalQuality;
|
public int GlobalQuality;
|
||||||
public int CompressionLevel;
|
public int CompressionLevel;
|
||||||
public int Flags;
|
public int Flags;
|
||||||
public int Flags2;
|
public int Flags2;
|
||||||
public IntPtr ExtraData;
|
public nint ExtraData;
|
||||||
public int ExtraDataSize;
|
public int ExtraDataSize;
|
||||||
public AVRational TimeBase;
|
public AVRational TimeBase;
|
||||||
public int TicksPerFrame;
|
public int TicksPerFrame;
|
||||||
|
@ -32,8 +32,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public int CodedHeight;
|
public int CodedHeight;
|
||||||
public int GopSize;
|
public int GopSize;
|
||||||
public int PixFmt;
|
public int PixFmt;
|
||||||
public IntPtr DrawHorizBand;
|
public nint DrawHorizBand;
|
||||||
public IntPtr GetFormat;
|
public nint GetFormat;
|
||||||
public int MaxBFrames;
|
public int MaxBFrames;
|
||||||
public float BQuantFactor;
|
public float BQuantFactor;
|
||||||
public float BQuantOffset;
|
public float BQuantOffset;
|
||||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public float PMasking;
|
public float PMasking;
|
||||||
public float DarkMasking;
|
public float DarkMasking;
|
||||||
public int SliceCount;
|
public int SliceCount;
|
||||||
public IntPtr SliceOffset;
|
public nint SliceOffset;
|
||||||
public AVRational SampleAspectRatio;
|
public AVRational SampleAspectRatio;
|
||||||
public int MeCmp;
|
public int MeCmp;
|
||||||
public int MeSubCmp;
|
public int MeSubCmp;
|
||||||
|
@ -60,8 +60,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public int MeRange;
|
public int MeRange;
|
||||||
public int SliceFlags;
|
public int SliceFlags;
|
||||||
public int MbDecision;
|
public int MbDecision;
|
||||||
public IntPtr IntraMatrix;
|
public nint IntraMatrix;
|
||||||
public IntPtr InterMatrix;
|
public nint InterMatrix;
|
||||||
public int IntraDcPrecision;
|
public int IntraDcPrecision;
|
||||||
public int SkipTop;
|
public int SkipTop;
|
||||||
public int SkipBottom;
|
public int SkipBottom;
|
||||||
|
@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public ulong RequestChannelLayout;
|
public ulong RequestChannelLayout;
|
||||||
public int AudioServiceType;
|
public int AudioServiceType;
|
||||||
public int RequestSampleFmt;
|
public int RequestSampleFmt;
|
||||||
public IntPtr GetBuffer2;
|
public nint GetBuffer2;
|
||||||
public float QCompress;
|
public float QCompress;
|
||||||
public float QBlur;
|
public float QBlur;
|
||||||
public int QMin;
|
public int QMin;
|
||||||
|
@ -97,23 +97,23 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public int MaxQdiff;
|
public int MaxQdiff;
|
||||||
public int RcBufferSize;
|
public int RcBufferSize;
|
||||||
public int RcOverrideCount;
|
public int RcOverrideCount;
|
||||||
public IntPtr RcOverride;
|
public nint RcOverride;
|
||||||
public long RcMaxRate;
|
public long RcMaxRate;
|
||||||
public long RcMinRate;
|
public long RcMinRate;
|
||||||
public float RcMax_available_vbv_use;
|
public float RcMax_available_vbv_use;
|
||||||
public float RcMin_vbv_overflow_use;
|
public float RcMin_vbv_overflow_use;
|
||||||
public int RcInitialBufferOccupancy;
|
public int RcInitialBufferOccupancy;
|
||||||
public int Trellis;
|
public int Trellis;
|
||||||
public IntPtr StatsOut;
|
public nint StatsOut;
|
||||||
public IntPtr StatsIn;
|
public nint StatsIn;
|
||||||
public int WorkaroundBugs;
|
public int WorkaroundBugs;
|
||||||
public int StrictStdCompliance;
|
public int StrictStdCompliance;
|
||||||
public int ErrorConcealment;
|
public int ErrorConcealment;
|
||||||
public int Debug;
|
public int Debug;
|
||||||
public int ErrRecognition;
|
public int ErrRecognition;
|
||||||
public long ReorderedOpaque;
|
public long ReorderedOpaque;
|
||||||
public IntPtr HwAccel;
|
public nint HwAccel;
|
||||||
public IntPtr HwAccelContext;
|
public nint HwAccelContext;
|
||||||
public Array8<ulong> Error;
|
public Array8<ulong> Error;
|
||||||
public int DctAlgo;
|
public int DctAlgo;
|
||||||
public int IdctAlgo;
|
public int IdctAlgo;
|
||||||
|
@ -124,48 +124,48 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||||
public int ThreadType;
|
public int ThreadType;
|
||||||
public int ActiveThreadType;
|
public int ActiveThreadType;
|
||||||
public int ThreadSafeCallbacks;
|
public int ThreadSafeCallbacks;
|
||||||
public IntPtr Execute;
|
public nint Execute;
|
||||||
public IntPtr Execute2;
|
public nint Execute2;
|
||||||
public int NsseWeight;
|
public int NsseWeight;
|
||||||
public int Profile;
|
public int Profile;
|
||||||
public int Level;
|
public int Level;
|
||||||
public int SkipLoopFilter;
|
public int SkipLoopFilter;
|
||||||
public int SkipIdct;
|
public int SkipIdct;
|
||||||
public int SkipFrame;
|
public int SkipFrame;
|
||||||
public IntPtr SubtitleHeader;
|
public nint SubtitleHeader;
|
||||||
public int SubtitleHeaderSize;
|
public int SubtitleHeaderSize;
|
||||||
public int InitialPadding;
|
public int InitialPadding;
|
||||||
public AVRational Framerate;
|
public AVRational Framerate;
|
||||||
public int SwPixFmt;
|
public int SwPixFmt;
|
||||||
public AVRational PktTimebase;
|
public AVRational PktTimebase;
|
||||||
public IntPtr CodecDescriptor;
|
public nint CodecDescriptor;
|
||||||
public long PtsCorrectionNumFaultyPts;
|
public long PtsCorrectionNumFaultyPts;
|
||||||
public long PtsCorrectionNumFaultyDts;
|
public long PtsCorrectionNumFaultyDts;
|
||||||
public long PtsCorrectionLastPts;
|
public long PtsCorrectionLastPts;
|
||||||
public long PtsCorrectionLastDts;
|
public long PtsCorrectionLastDts;
|
||||||
public IntPtr SubCharenc;
|
public nint SubCharenc;
|
||||||
public int SubCharencMode;
|
public int SubCharencMode;
|
||||||
public int SkipAlpha;
|
public int SkipAlpha;
|
||||||
public int SeekPreroll;
|
public int SeekPreroll;
|
||||||
public int DebugMv;
|
public int DebugMv;
|
||||||
public IntPtr ChromaIntraMatrix;
|
public nint ChromaIntraMatrix;
|
||||||
public IntPtr DumpSeparator;
|
public nint DumpSeparator;
|
||||||
public IntPtr CodecWhitelist;
|
public nint CodecWhitelist;
|
||||||
public uint Properties;
|
public uint Properties;
|
||||||
public IntPtr CodedSideData;
|
public nint CodedSideData;
|
||||||
public int NbCodedSideData;
|
public int NbCodedSideData;
|
||||||
public IntPtr HwFramesCtx;
|
public nint HwFramesCtx;
|
||||||
public int SubTextFormat;
|
public int SubTextFormat;
|
||||||
public int TrailingPadding;
|
public int TrailingPadding;
|
||||||
public long MaxPixels;
|
public long MaxPixels;
|
||||||
public IntPtr HwDeviceCtx;
|
public nint HwDeviceCtx;
|
||||||
public int HwAccelFlags;
|
public int HwAccelFlags;
|
||||||
public int applyCropping;
|
public int applyCropping;
|
||||||
public int ExtraHwFrames;
|
public int ExtraHwFrames;
|
||||||
public int DiscardDamagedPercentage;
|
public int DiscardDamagedPercentage;
|
||||||
public long MaxSamples;
|
public long MaxSamples;
|
||||||
public int ExportSideData;
|
public int ExportSideData;
|
||||||
public IntPtr GetEncodeBuffer;
|
public nint GetEncodeBuffer;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue