[ci skip] replace all usages of IntPtr with nint

This commit is contained in:
GreemDev 2026-01-27 17:41:46 -06:00
parent 82074eb191
commit fef93a453a
11 changed files with 52 additions and 52 deletions

View file

@ -168,7 +168,7 @@ namespace ARMeilleure.Common
{ {
_allocated.Dispose(); _allocated.Dispose();
foreach (IntPtr page in _pages.Values) foreach (nint page in _pages.Values)
{ {
NativeAllocator.Instance.Free((void*)page); NativeAllocator.Instance.Free((void*)page);
} }

View file

@ -44,12 +44,12 @@ namespace Ryujinx.Audio.Backends.Apple
int result = AudioQueueNewOutput( int result = AudioQueueNewOutput(
ref format, ref format,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
0, 0,
out IntPtr testQueue); out nint testQueue);
if (result == 0) if (result == 0)
{ {
@ -95,12 +95,12 @@ namespace Ryujinx.Audio.Backends.Apple
GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2); GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2);
int result = AudioQueueNewOutput( int result = AudioQueueNewOutput(
ref format, ref format,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
0, 0,
out IntPtr testQueue); out nint testQueue);
if (result == 0) if (result == 0)
{ {

View file

@ -27,8 +27,8 @@ namespace Ryujinx.Audio.Backends.Apple
private readonly AudioQueueOutputCallback _callbackDelegate; private readonly AudioQueueOutputCallback _callbackDelegate;
private readonly GCHandle _gcHandle; private readonly GCHandle _gcHandle;
private IntPtr _audioQueue; private nint _audioQueue;
private readonly IntPtr[] _audioQueueBuffers = new IntPtr[NumBuffers]; private readonly nint[] _audioQueueBuffers = new nint[NumBuffers];
private readonly int[] _bufferBytesFilled = new int[NumBuffers]; private readonly int[] _bufferBytesFilled = new int[NumBuffers];
private readonly int _bytesPerFrame; private readonly int _bytesPerFrame;
@ -41,9 +41,9 @@ namespace Ryujinx.Audio.Backends.Apple
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void AudioQueueOutputCallback( private delegate void AudioQueueOutputCallback(
IntPtr userData, nint userData,
IntPtr audioQueue, nint audioQueue,
IntPtr buffer); nint buffer);
public AppleHardwareDeviceSession( public AppleHardwareDeviceSession(
AppleHardwareDeviceDriver driver, AppleHardwareDeviceDriver driver,
@ -72,15 +72,15 @@ namespace Ryujinx.Audio.Backends.Apple
RequestedSampleRate, RequestedSampleRate,
RequestedChannelCount); RequestedChannelCount);
IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate); nint callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
IntPtr userData = GCHandle.ToIntPtr(_gcHandle); nint userData = GCHandle.ToIntPtr(_gcHandle);
int result = AudioQueueNewOutput( int result = AudioQueueNewOutput(
ref format, ref format,
callbackPtr, callbackPtr,
userData, userData,
IntPtr.Zero, nint.Zero,
IntPtr.Zero, nint.Zero,
0, 0,
out _audioQueue); out _audioQueue);
@ -102,7 +102,7 @@ namespace Ryujinx.Audio.Backends.Apple
} }
} }
private unsafe void PrimeBuffer(IntPtr bufferPtr, int bufferIndex) private unsafe void PrimeBuffer(nint bufferPtr, int bufferIndex)
{ {
AudioQueueBuffer* buffer = (AudioQueueBuffer*)bufferPtr; AudioQueueBuffer* buffer = (AudioQueueBuffer*)bufferPtr;
@ -126,12 +126,12 @@ namespace Ryujinx.Audio.Backends.Apple
buffer->AudioDataByteSize = (uint)capacityBytes; buffer->AudioDataByteSize = (uint)capacityBytes;
_bufferBytesFilled[bufferIndex] = bytesToRead; _bufferBytesFilled[bufferIndex] = bytesToRead;
AudioQueueEnqueueBuffer(_audioQueue, bufferPtr, 0, IntPtr.Zero); AudioQueueEnqueueBuffer(_audioQueue, bufferPtr, 0, nint.Zero);
} }
private void OutputCallback(IntPtr userData, IntPtr audioQueue, IntPtr bufferPtr) private void OutputCallback(nint userData, nint audioQueue, nint bufferPtr)
{ {
if (!_started || bufferPtr == IntPtr.Zero) if (!_started || bufferPtr == nint.Zero)
return; return;
int bufferIndex = Array.IndexOf(_audioQueueBuffers, bufferPtr); int bufferIndex = Array.IndexOf(_audioQueueBuffers, bufferPtr);
@ -176,7 +176,7 @@ namespace Ryujinx.Audio.Backends.Apple
} }
} }
private unsafe void ApplyVolume(IntPtr dataPtr, int byteSize) private unsafe void ApplyVolume(nint dataPtr, int byteSize)
{ {
float volume = Math.Clamp(_volume * _driver.Volume, 0f, 1f); float volume = Math.Clamp(_volume * _driver.Volume, 0f, 1f);
if (volume >= 0.999f) if (volume >= 0.999f)
@ -226,7 +226,7 @@ namespace Ryujinx.Audio.Backends.Apple
return; return;
_started = true; _started = true;
AudioQueueStart(_audioQueue, IntPtr.Zero); AudioQueueStart(_audioQueue, nint.Zero);
} }
} }
@ -265,11 +265,11 @@ namespace Ryujinx.Audio.Backends.Apple
{ {
Stop(); Stop();
if (_audioQueue != IntPtr.Zero) if (_audioQueue != nint.Zero)
{ {
AudioQueueStop(_audioQueue, true); AudioQueueStop(_audioQueue, true);
AudioQueueDispose(_audioQueue, true); AudioQueueDispose(_audioQueue, true);
_audioQueue = IntPtr.Zero; _audioQueue = nint.Zero;
} }
if (_gcHandle.IsAllocated) if (_gcHandle.IsAllocated)

View file

@ -130,7 +130,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
unsafe unsafe
{ {
int* frameCountPtr = &nativeFrameCount; int* frameCountPtr = &nativeFrameCount;
IntPtr* arenasPtr = &arenas; nint* arenasPtr = &arenas;
CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr)); CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr));
frameCount = *frameCountPtr; frameCount = *frameCountPtr;

View file

@ -30,9 +30,9 @@ namespace ARMeilleure.Common
/// <summary> /// <summary>
/// Base address for the page. /// Base address for the page.
/// </summary> /// </summary>
public readonly IntPtr Address; public readonly nint Address;
public AddressTablePage(bool isSparse, IntPtr address) public AddressTablePage(bool isSparse, nint address)
{ {
IsSparse = isSparse; IsSparse = isSparse;
Address = address; Address = address;
@ -47,20 +47,20 @@ namespace ARMeilleure.Common
public readonly SparseMemoryBlock Block; public readonly SparseMemoryBlock Block;
private readonly TrackingEventDelegate _trackingEvent; private readonly TrackingEventDelegate _trackingEvent;
public TableSparseBlock(ulong size, Action<IntPtr> ensureMapped, PageInitDelegate pageInit) public TableSparseBlock(ulong size, Action<nint> ensureMapped, PageInitDelegate pageInit)
{ {
SparseMemoryBlock block = new(size, pageInit, null); SparseMemoryBlock block = new(size, pageInit, null);
_trackingEvent = (address, size, write) => _trackingEvent = (address, size, write) =>
{ {
ulong pointer = (ulong)block.Block.Pointer + address; ulong pointer = (ulong)block.Block.Pointer + address;
ensureMapped((IntPtr)pointer); ensureMapped((nint)pointer);
return pointer; return pointer;
}; };
bool added = NativeSignalHandler.AddTrackedRegion( bool added = NativeSignalHandler.AddTrackedRegion(
(nuint)block.Block.Pointer, (nuint)block.Block.Pointer,
(nuint)(block.Block.Pointer + (IntPtr)block.Block.Size), (nuint)(block.Block.Pointer + (nint)block.Block.Size),
Marshal.GetFunctionPointerForDelegate(_trackingEvent)); Marshal.GetFunctionPointerForDelegate(_trackingEvent));
if (!added) if (!added)
@ -116,7 +116,7 @@ namespace ARMeilleure.Common
} }
/// <inheritdoc/> /// <inheritdoc/>
public IntPtr Base public nint Base
{ {
get get
{ {
@ -124,7 +124,7 @@ namespace ARMeilleure.Common
lock (_pages) lock (_pages)
{ {
return (IntPtr)GetRootPage(); return (nint)GetRootPage();
} }
} }
} }
@ -240,7 +240,7 @@ namespace ARMeilleure.Common
long index = Levels[^1].GetValue(address); long index = Levels[^1].GetValue(address);
EnsureMapped((IntPtr)(page + index)); EnsureMapped((nint)(page + index));
return ref page[index]; return ref page[index];
} }
@ -284,7 +284,7 @@ namespace ARMeilleure.Common
/// Ensure the given pointer is mapped in any overlapping sparse reservations. /// Ensure the given pointer is mapped in any overlapping sparse reservations.
/// </summary> /// </summary>
/// <param name="ptr">Pointer to be mapped</param> /// <param name="ptr">Pointer to be mapped</param>
private void EnsureMapped(IntPtr ptr) private void EnsureMapped(nint ptr)
{ {
if (Sparse) if (Sparse)
{ {
@ -299,7 +299,7 @@ namespace ARMeilleure.Common
{ {
SparseMemoryBlock sparse = reserved.Block; SparseMemoryBlock sparse = reserved.Block;
if (ptr >= sparse.Block.Pointer && ptr < sparse.Block.Pointer + (IntPtr)sparse.Block.Size) if (ptr >= sparse.Block.Pointer && ptr < sparse.Block.Pointer + (nint)sparse.Block.Size)
{ {
sparse.EnsureMapped((ulong)(ptr - sparse.Block.Pointer)); sparse.EnsureMapped((ulong)(ptr - sparse.Block.Pointer));
@ -319,15 +319,15 @@ namespace ARMeilleure.Common
/// </summary> /// </summary>
/// <param name="level">Level to get the fill value for</param> /// <param name="level">Level to get the fill value for</param>
/// <returns>The fill value</returns> /// <returns>The fill value</returns>
private IntPtr GetFillValue(int level) private nint GetFillValue(int level)
{ {
if (_fillBottomLevel != null && level == Levels.Length - 2) if (_fillBottomLevel != null && level == Levels.Length - 2)
{ {
return (IntPtr)_fillBottomLevelPtr; return (nint)_fillBottomLevelPtr;
} }
else else
{ {
return IntPtr.Zero; return nint.Zero;
} }
} }
@ -379,7 +379,7 @@ 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
{ {
int size = sizeof(T) * length; int size = sizeof(T) * length;
@ -405,7 +405,7 @@ namespace ARMeilleure.Common
} }
} }
page = new AddressTablePage(true, block.Block.Pointer + (IntPtr)_sparseReservedOffset); page = new AddressTablePage(true, block.Block.Pointer + (nint)_sparseReservedOffset);
_sparseReservedOffset += (ulong)size; _sparseReservedOffset += (ulong)size;
@ -413,7 +413,7 @@ namespace ARMeilleure.Common
} }
else else
{ {
IntPtr address = (IntPtr)NativeAllocator.Instance.Allocate((uint)size); nint address = (nint)NativeAllocator.Instance.Allocate((uint)size);
page = new AddressTablePage(false, address); page = new AddressTablePage(false, address);
Span<T> span = new((void*)page.Address, length); Span<T> span = new((void*)page.Address, length);

View file

@ -658,7 +658,7 @@ namespace Ryujinx.Graphics.Gpu.Image
bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel; bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel;
IntPtr hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0; nint hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0;
if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size)) if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size))
{ {

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
public static void Initialize() public static void Initialize()
{ {
IntPtr configSize = (nint)Marshal.SizeOf<MVKConfiguration>(); nint configSize = (nint)Marshal.SizeOf<MVKConfiguration>();
vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize); vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize);

View file

@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Vulkan
enabledExtensions = enabledExtensions.Append(ExtDebugUtils.ExtensionName).ToArray(); enabledExtensions = enabledExtensions.Append(ExtDebugUtils.ExtensionName).ToArray();
} }
IntPtr appName = Marshal.StringToHGlobalAnsi(AppName); nint appName = Marshal.StringToHGlobalAnsi(AppName);
ApplicationInfo applicationInfo = new() ApplicationInfo applicationInfo = new()
{ {
@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Vulkan
internal static DeviceInfo[] GetSuitablePhysicalDevices(Vk api) internal static DeviceInfo[] GetSuitablePhysicalDevices(Vk api)
{ {
IntPtr appName = Marshal.StringToHGlobalAnsi(AppName); nint appName = Marshal.StringToHGlobalAnsi(AppName);
ApplicationInfo applicationInfo = new() ApplicationInfo applicationInfo = new()
{ {

View file

@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
public bool Blocking { get => Socket.Blocking; set => Socket.Blocking = value; } public bool Blocking { get => Socket.Blocking; set => Socket.Blocking = value; }
public nint Handle => IntPtr.Zero; public nint Handle => nint.Zero;
public IPEndPoint RemoteEndPoint => Socket.RemoteEndPoint as IPEndPoint; public IPEndPoint RemoteEndPoint => Socket.RemoteEndPoint as IPEndPoint;

View file

@ -159,7 +159,7 @@ namespace Ryujinx.Memory.WindowsShared
{ {
SplitForMap((ulong)location, (ulong)size, srcOffset); SplitForMap((ulong)location, (ulong)size, srcOffset);
IntPtr ptr = WindowsApi.MapViewOfFile3( nint ptr = WindowsApi.MapViewOfFile3(
sharedMemory, sharedMemory,
WindowsApi.CurrentProcessHandle, WindowsApi.CurrentProcessHandle,
location, location,

View file

@ -227,7 +227,7 @@ namespace Ryujinx.Tests.Memory
// Create some info to be used for managing the native writing loop. // Create some info to be used for managing the native writing loop.
int stateSize = Unsafe.SizeOf<NativeWriteLoopState>(); int stateSize = Unsafe.SizeOf<NativeWriteLoopState>();
IntPtr statePtr = Marshal.AllocHGlobal(stateSize); nint statePtr = Marshal.AllocHGlobal(stateSize);
Unsafe.InitBlockUnaligned((void*)statePtr, 0, (uint)stateSize); Unsafe.InitBlockUnaligned((void*)statePtr, 0, (uint)stateSize);
ref NativeWriteLoopState writeLoopState = ref Unsafe.AsRef<NativeWriteLoopState>((void*)statePtr); ref NativeWriteLoopState writeLoopState = ref Unsafe.AsRef<NativeWriteLoopState>((void*)statePtr);