mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-01 17:06:25 +02: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
|
@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
public int Size { get; }
|
||||
|
||||
private readonly IntPtr _map;
|
||||
private readonly nint _map;
|
||||
|
||||
private readonly MultiFenceHolder _waitable;
|
||||
|
||||
|
@ -370,7 +370,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return Unsafe.As<ulong, BufferHandle>(ref handle);
|
||||
}
|
||||
|
||||
public IntPtr Map(int offset, int mappingSize)
|
||||
public nint Map(int offset, int mappingSize)
|
||||
{
|
||||
return _map;
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
Span<byte> result;
|
||||
|
||||
if (_map != IntPtr.Zero)
|
||||
if (_map != nint.Zero)
|
||||
{
|
||||
result = GetDataStorage(offset, size);
|
||||
|
||||
|
@ -470,7 +470,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
int mappingSize = Math.Min(size, Size - offset);
|
||||
|
||||
if (_map != IntPtr.Zero)
|
||||
if (_map != nint.Zero)
|
||||
{
|
||||
return new Span<byte>((void*)(_map + offset), mappingSize);
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
bool allowMirror = _useMirrors && allowCbsWait && cbs != null && _activeType <= BufferAllocationType.HostMapped;
|
||||
|
||||
if (_map != IntPtr.Zero)
|
||||
if (_map != nint.Zero)
|
||||
{
|
||||
// If persistently mapped, set the data directly if the buffer is not currently in use.
|
||||
bool isRented = _buffer.HasRentedCommandBufferDependency(_gd.CommandBufferPool);
|
||||
|
@ -630,7 +630,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return;
|
||||
}
|
||||
|
||||
if (_map != IntPtr.Zero)
|
||||
if (_map != nint.Zero)
|
||||
{
|
||||
data[..dataSize].CopyTo(new Span<byte>((void*)(_map + offset), dataSize));
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
private readonly struct HostMemoryAllocation
|
||||
{
|
||||
public readonly Auto<MemoryAllocation> Allocation;
|
||||
public readonly IntPtr Pointer;
|
||||
public readonly nint Pointer;
|
||||
public readonly ulong Size;
|
||||
|
||||
public ulong Start => (ulong)Pointer;
|
||||
public ulong End => (ulong)Pointer + Size;
|
||||
|
||||
public HostMemoryAllocation(Auto<MemoryAllocation> allocation, IntPtr pointer, ulong size)
|
||||
public HostMemoryAllocation(Auto<MemoryAllocation> allocation, nint pointer, ulong size)
|
||||
{
|
||||
Allocation = allocation;
|
||||
Pointer = pointer;
|
||||
|
@ -50,7 +50,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
public unsafe bool TryImport(
|
||||
MemoryRequirements requirements,
|
||||
MemoryPropertyFlags flags,
|
||||
IntPtr pointer,
|
||||
nint pointer,
|
||||
ulong size)
|
||||
{
|
||||
lock (_lock)
|
||||
|
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return true;
|
||||
}
|
||||
|
||||
public (Auto<MemoryAllocation>, ulong) GetExistingAllocation(IntPtr pointer, ulong size)
|
||||
public (Auto<MemoryAllocation>, ulong) GetExistingAllocation(nint pointer, ulong size)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
private readonly HostMemoryAllocator _hostMemory;
|
||||
|
||||
public DeviceMemory Memory { get; }
|
||||
public IntPtr HostPointer { get; }
|
||||
public nint HostPointer { get; }
|
||||
public ulong Offset { get; }
|
||||
public ulong Size { get; }
|
||||
|
||||
|
@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
MemoryAllocatorBlockList owner,
|
||||
MemoryAllocatorBlockList.Block block,
|
||||
DeviceMemory memory,
|
||||
IntPtr hostPointer,
|
||||
nint hostPointer,
|
||||
ulong offset,
|
||||
ulong size)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
public MemoryAllocation(
|
||||
HostMemoryAllocator hostMemory,
|
||||
DeviceMemory memory,
|
||||
IntPtr hostPointer,
|
||||
nint hostPointer,
|
||||
ulong offset,
|
||||
ulong size)
|
||||
{
|
||||
|
|
|
@ -14,9 +14,9 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
public class Block : IComparable<Block>
|
||||
{
|
||||
public DeviceMemory Memory { get; private set; }
|
||||
public IntPtr HostPointer { get; private set; }
|
||||
public nint HostPointer { get; private set; }
|
||||
public ulong Size { get; }
|
||||
public bool Mapped => HostPointer != IntPtr.Zero;
|
||||
public bool Mapped => HostPointer != nint.Zero;
|
||||
|
||||
private readonly struct Range : IComparable<Range>
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
private readonly List<Range> _freeRanges;
|
||||
|
||||
public Block(DeviceMemory memory, IntPtr hostPointer, ulong size)
|
||||
public Block(DeviceMemory memory, nint hostPointer, ulong size)
|
||||
{
|
||||
Memory = memory;
|
||||
HostPointer = hostPointer;
|
||||
|
@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
if (Mapped)
|
||||
{
|
||||
api.UnmapMemory(device, Memory);
|
||||
HostPointer = IntPtr.Zero;
|
||||
HostPointer = nint.Zero;
|
||||
}
|
||||
|
||||
if (Memory.Handle != 0)
|
||||
|
@ -222,13 +222,13 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
_api.AllocateMemory(_device, in memoryAllocateInfo, null, out var deviceMemory).ThrowOnError();
|
||||
|
||||
IntPtr hostPointer = IntPtr.Zero;
|
||||
nint hostPointer = nint.Zero;
|
||||
|
||||
if (map)
|
||||
{
|
||||
void* pointer = null;
|
||||
_api.MapMemory(_device, deviceMemory, 0, blockAlignedSize, 0, ref pointer).ThrowOnError();
|
||||
hostPointer = (IntPtr)pointer;
|
||||
hostPointer = (nint)pointer;
|
||||
}
|
||||
|
||||
var newBlock = new Block(deviceMemory, hostPointer, blockAlignedSize);
|
||||
|
@ -241,14 +241,14 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
return new MemoryAllocation(this, newBlock, deviceMemory, GetHostPointer(newBlock, newBlockOffset), newBlockOffset, size);
|
||||
}
|
||||
|
||||
private static IntPtr GetHostPointer(Block block, ulong offset)
|
||||
private static nint GetHostPointer(Block block, ulong offset)
|
||||
{
|
||||
if (block.HostPointer == IntPtr.Zero)
|
||||
if (block.HostPointer == nint.Zero)
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
return nint.Zero;
|
||||
}
|
||||
|
||||
return (IntPtr)((nuint)block.HostPointer + offset);
|
||||
return (nint)((nuint)block.HostPointer + offset);
|
||||
}
|
||||
|
||||
public void Free(Block block, ulong offset, ulong size)
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
|
|||
public Bool32 SemaphoreUseMTLFence;
|
||||
public MVKVkSemaphoreSupportStyle SemaphoreSupportStyle;
|
||||
public MVKConfigAutoGPUCaptureScope AutoGPUCaptureScope;
|
||||
public IntPtr AutoGPUCaptureOutputFilepath;
|
||||
public nint AutoGPUCaptureOutputFilepath;
|
||||
public Bool32 Texture1DAs2D;
|
||||
public Bool32 PreallocateDescriptors;
|
||||
public Bool32 UseCommandPooling;
|
||||
|
|
|
@ -12,16 +12,16 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
|
|||
private const string VulkanLib = "libvulkan.dylib";
|
||||
|
||||
[LibraryImport("libMoltenVK.dylib")]
|
||||
private static partial Result vkGetMoltenVKConfigurationMVK(IntPtr unusedInstance, out MVKConfiguration config, in IntPtr configSize);
|
||||
private static partial Result vkGetMoltenVKConfigurationMVK(nint unusedInstance, out MVKConfiguration config, in nint configSize);
|
||||
|
||||
[LibraryImport("libMoltenVK.dylib")]
|
||||
private static partial Result vkSetMoltenVKConfigurationMVK(IntPtr unusedInstance, in MVKConfiguration config, in IntPtr configSize);
|
||||
private static partial Result vkSetMoltenVKConfigurationMVK(nint unusedInstance, in MVKConfiguration config, in nint configSize);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
var configSize = (IntPtr)Marshal.SizeOf<MVKConfiguration>();
|
||||
var configSize = (nint)Marshal.SizeOf<MVKConfiguration>();
|
||||
|
||||
vkGetMoltenVKConfigurationMVK(IntPtr.Zero, out MVKConfiguration config, configSize);
|
||||
vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize);
|
||||
|
||||
config.UseMetalArgumentBuffers = true;
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
|
|||
|
||||
config.ResumeLostDevice = true;
|
||||
|
||||
vkSetMoltenVKConfigurationMVK(IntPtr.Zero, config, configSize);
|
||||
vkSetMoltenVKConfigurationMVK(nint.Zero, config, configSize);
|
||||
}
|
||||
|
||||
private static string[] Resolver(string path)
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
{
|
||||
if (Pointer != null)
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)Pointer);
|
||||
Marshal.FreeHGlobal((nint)Pointer);
|
||||
Pointer = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
|||
private QueryPool _queryPool;
|
||||
|
||||
private readonly BufferHolder _buffer;
|
||||
private readonly IntPtr _bufferMap;
|
||||
private readonly nint _bufferMap;
|
||||
private readonly CounterType _type;
|
||||
private readonly bool _result32Bit;
|
||||
private readonly bool _isSupported;
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
// Take this lock when using them.
|
||||
private static readonly object _shaderOptionsLock = new();
|
||||
|
||||
private static readonly IntPtr _ptrMainEntryPointName = Marshal.StringToHGlobalAnsi("main");
|
||||
private static readonly nint _ptrMainEntryPointName = Marshal.StringToHGlobalAnsi("main");
|
||||
|
||||
private readonly Vk _api;
|
||||
private readonly Device _device;
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
DebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||
void* pUserData)
|
||||
{
|
||||
var msg = Marshal.PtrToStringAnsi((IntPtr)pCallbackData->PMessage);
|
||||
var msg = Marshal.PtrToStringAnsi((nint)pCallbackData->PMessage);
|
||||
|
||||
if (messageSeverity.HasFlag(DebugUtilsMessageSeverityFlagsEXT.ErrorBitExt))
|
||||
{
|
||||
|
|
|
@ -94,8 +94,8 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
ApiVersion = _maximumVulkanVersion,
|
||||
};
|
||||
|
||||
IntPtr* ppEnabledExtensions = stackalloc IntPtr[enabledExtensions.Length];
|
||||
IntPtr* ppEnabledLayers = stackalloc IntPtr[enabledLayers.Count];
|
||||
nint* ppEnabledExtensions = stackalloc nint[enabledExtensions.Length];
|
||||
nint* ppEnabledLayers = stackalloc nint[enabledLayers.Count];
|
||||
|
||||
for (int i = 0; i < enabledExtensions.Length; i++)
|
||||
{
|
||||
|
@ -587,7 +587,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
var enabledExtensions = _requiredExtensions.Union(_desirableExtensions.Intersect(physicalDevice.DeviceExtensions)).ToArray();
|
||||
|
||||
IntPtr* ppEnabledExtensions = stackalloc IntPtr[enabledExtensions.Length];
|
||||
nint* ppEnabledExtensions = stackalloc nint[enabledExtensions.Length];
|
||||
|
||||
for (int i = 0; i < enabledExtensions.Length; i++)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
_api = api;
|
||||
Instance = instance;
|
||||
|
||||
if (api.GetInstanceProcAddr(instance, "vkEnumerateInstanceVersion") == IntPtr.Zero)
|
||||
if (api.GetInstanceProcAddr(instance, "vkEnumerateInstanceVersion") == nint.Zero)
|
||||
{
|
||||
InstanceVersion = Vk.Version10;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
unsafe
|
||||
{
|
||||
return extensionProperties.Select(x => Marshal.PtrToStringAnsi((IntPtr)x.ExtensionName)).ToImmutableHashSet();
|
||||
return extensionProperties.Select(x => Marshal.PtrToStringAnsi((nint)x.ExtensionName)).ToImmutableHashSet();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
unsafe
|
||||
{
|
||||
return layerProperties.Select(x => Marshal.PtrToStringAnsi((IntPtr)x.LayerName)).ToImmutableHashSet();
|
||||
return layerProperties.Select(x => Marshal.PtrToStringAnsi((nint)x.LayerName)).ToImmutableHashSet();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
unsafe
|
||||
{
|
||||
DeviceName = Marshal.PtrToStringAnsi((IntPtr)physicalDeviceProperties.DeviceName);
|
||||
DeviceName = Marshal.PtrToStringAnsi((nint)physicalDeviceProperties.DeviceName);
|
||||
}
|
||||
|
||||
uint propertiesCount = 0;
|
||||
|
@ -50,7 +50,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
unsafe
|
||||
{
|
||||
DeviceExtensions = extensionProperties.Select(x => Marshal.PtrToStringAnsi((IntPtr)x.ExtensionName)).ToImmutableHashSet();
|
||||
DeviceExtensions = extensionProperties.Select(x => Marshal.PtrToStringAnsi((nint)x.ExtensionName)).ToImmutableHashSet();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||
|
||||
fixed (byte* deviceName = properties.DeviceName)
|
||||
{
|
||||
GpuRenderer = Marshal.PtrToStringAnsi((IntPtr)deviceName);
|
||||
GpuRenderer = Marshal.PtrToStringAnsi((nint)deviceName);
|
||||
}
|
||||
|
||||
GpuVersion = $"Vulkan v{ParseStandardVulkanVersion(properties.ApiVersion)}, Driver v{ParseDriverVersion(ref properties)}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue