diff --git a/COMPILING.md b/COMPILING.md index 20a2eb7ff..64f7e4e1b 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -5,7 +5,7 @@ If you wish to build the emulator yourself, follow these steps: ### Step 1 -Install the [.NET 8.0 (or higher) SDK](https://dotnet.microsoft.com/download/dotnet/8.0). +Install the [.NET 9.0 (or higher) SDK](https://dotnet.microsoft.com/download/dotnet/9.0). Make sure your SDK version is higher or equal to the required version specified in [global.json](global.json). ### Step 2 diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 000000000..d7a2ac1f2 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,6 @@ + + + net9.0 + latest + + diff --git a/Directory.Packages.props b/Directory.Packages.props index 7059af0e0..93d212b07 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -48,8 +48,8 @@ - - + + diff --git a/README.md b/README.md index f5bd87c7f..1532245f2 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ failing to meet this requirement may result in a poor gameplay experience or une ## Latest build -Stable builds are made every so often onto a separate "release" branch that then gets put into the releases you know and love. +Stable builds are made every so often onto a separate "release" branch that then gets put into the releases you know and love. These stable builds exist so that the end user can get a more **enjoyable and stable experience**. You can find the latest stable release [here](https://github.com/GreemDev/Ryujinx/releases/latest). @@ -82,7 +82,7 @@ If you are planning to contribute or just want to learn more about this project It translates the ARM code to a custom IR, performs a few optimizations, and turns that into x86 code. There are three memory manager options available depending on the user's preference, leveraging both software-based (slower) and host-mapped modes (much faster). The fastest option (host, unchecked) is set by default. - Ryujinx also features an optional Profiled Persistent Translation Cache, which essentially caches translated functions so that they do not need to be translated every time the game loads. + Ryujinx also features an optional Profiled Persistent Translation Cache, which essentially caches translated functions so that they do not need to be translated every time the game loads. The net result is a significant reduction in load times (the amount of time between launching a game and arriving at the title screen) for nearly every game. NOTE: This feature is enabled by default in the Options menu > System tab. You must launch the game at least twice to the title screen or beyond before performance improvements are unlocked on the third launch! diff --git a/global.json b/global.json index 391ba3c2a..cdbb589ed 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "9.0.100", "rollForward": "latestFeature" } } diff --git a/src/ARMeilleure/ARMeilleure.csproj b/src/ARMeilleure/ARMeilleure.csproj index 4b67fdb3b..5b6c5a6da 100644 --- a/src/ARMeilleure/ARMeilleure.csproj +++ b/src/ARMeilleure/ARMeilleure.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/ARMeilleure/Decoders/DecoderHelper.cs b/src/ARMeilleure/Decoders/DecoderHelper.cs index 35e573955..c39a8a88b 100644 --- a/src/ARMeilleure/Decoders/DecoderHelper.cs +++ b/src/ARMeilleure/Decoders/DecoderHelper.cs @@ -1,4 +1,5 @@ using ARMeilleure.Common; +using System; namespace ARMeilleure.Decoders { @@ -149,7 +150,7 @@ namespace ARMeilleure.Decoders return (((long)opCode << 45) >> 48) & ~3; } - public static bool VectorArgumentsInvalid(bool q, params int[] args) + public static bool VectorArgumentsInvalid(bool q, params ReadOnlySpan args) { if (q) { diff --git a/src/ARMeilleure/Instructions/SoftFallback.cs b/src/ARMeilleure/Instructions/SoftFallback.cs index c4fe677bf..899326c4b 100644 --- a/src/ARMeilleure/Instructions/SoftFallback.cs +++ b/src/ARMeilleure/Instructions/SoftFallback.cs @@ -264,7 +264,7 @@ namespace ARMeilleure.Instructions return TblOrTbx(dest, vector, bytes, tb0, tb1, tb2, tb3); } - private static V128 TblOrTbx(V128 dest, V128 vector, int bytes, params V128[] tb) + private static V128 TblOrTbx(V128 dest, V128 vector, int bytes, params ReadOnlySpan tb) { byte[] res = new byte[16]; diff --git a/src/ARMeilleure/IntermediateRepresentation/Operation.cs b/src/ARMeilleure/IntermediateRepresentation/Operation.cs index b0dc173af..4bc3a2e09 100644 --- a/src/ARMeilleure/IntermediateRepresentation/Operation.cs +++ b/src/ARMeilleure/IntermediateRepresentation/Operation.cs @@ -337,7 +337,7 @@ namespace ARMeilleure.IntermediateRepresentation return result; } - public static Operation Operation(Intrinsic intrin, Operand dest, params Operand[] srcs) + public static Operation Operation(Intrinsic intrin, Operand dest, params ReadOnlySpan srcs) { Operation result = Make(Instruction.Extended, 0, srcs.Length); diff --git a/src/ARMeilleure/Translation/Cache/JitCache.cs b/src/ARMeilleure/Translation/Cache/JitCache.cs index cf13cd6cb..3bbec482c 100644 --- a/src/ARMeilleure/Translation/Cache/JitCache.cs +++ b/src/ARMeilleure/Translation/Cache/JitCache.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using System.Runtime.Versioning; +using System.Threading; namespace ARMeilleure.Translation.Cache { @@ -26,7 +27,7 @@ namespace ARMeilleure.Translation.Cache private static readonly List _cacheEntries = new(); - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static bool _initialized; [SupportedOSPlatform("windows")] diff --git a/src/ARMeilleure/Translation/EmitterContext.cs b/src/ARMeilleure/Translation/EmitterContext.cs index e2d860f82..22b6b9842 100644 --- a/src/ARMeilleure/Translation/EmitterContext.cs +++ b/src/ARMeilleure/Translation/EmitterContext.cs @@ -559,27 +559,27 @@ namespace ARMeilleure.Translation return dest; } - public Operand AddIntrinsic(Intrinsic intrin, params Operand[] args) + public Operand AddIntrinsic(Intrinsic intrin, params ReadOnlySpan args) { return Add(intrin, Local(OperandType.V128), args); } - public Operand AddIntrinsicInt(Intrinsic intrin, params Operand[] args) + public Operand AddIntrinsicInt(Intrinsic intrin, params ReadOnlySpan args) { return Add(intrin, Local(OperandType.I32), args); } - public Operand AddIntrinsicLong(Intrinsic intrin, params Operand[] args) + public Operand AddIntrinsicLong(Intrinsic intrin, params ReadOnlySpan args) { return Add(intrin, Local(OperandType.I64), args); } - public void AddIntrinsicNoRet(Intrinsic intrin, params Operand[] args) + public void AddIntrinsicNoRet(Intrinsic intrin, params ReadOnlySpan args) { Add(intrin, default, args); } - private Operand Add(Intrinsic intrin, Operand dest, params Operand[] sources) + private Operand Add(Intrinsic intrin, Operand dest, params ReadOnlySpan sources) { NewNextBlockIfNeeded(); diff --git a/src/ARMeilleure/Translation/PTC/Ptc.cs b/src/ARMeilleure/Translation/PTC/Ptc.cs index 841e5fefa..4675abc49 100644 --- a/src/ARMeilleure/Translation/PTC/Ptc.cs +++ b/src/ARMeilleure/Translation/PTC/Ptc.cs @@ -59,7 +59,7 @@ namespace ARMeilleure.Translation.PTC private readonly ManualResetEvent _waitEvent; - private readonly object _lock; + private readonly Lock _lock = new(); private bool _disposed; @@ -89,8 +89,6 @@ namespace ARMeilleure.Translation.PTC _waitEvent = new ManualResetEvent(true); - _lock = new object(); - _disposed = false; TitleIdText = TitleIdTextDefault; diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs index 8e95c5e4b..7e630ae10 100644 --- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs +++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs @@ -41,7 +41,7 @@ namespace ARMeilleure.Translation.PTC private readonly ManualResetEvent _waitEvent; - private readonly object _lock; + private readonly Lock _lock = new(); private bool _disposed; @@ -65,8 +65,6 @@ namespace ARMeilleure.Translation.PTC _waitEvent = new ManualResetEvent(true); - _lock = new object(); - _disposed = false; ProfiledFuncs = new Dictionary(); diff --git a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs index 3b9129130..7292450a6 100644 --- a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs +++ b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs @@ -5,6 +5,7 @@ using Ryujinx.Memory; using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading; namespace Ryujinx.Audio.Backends.OpenAL { @@ -18,7 +19,7 @@ namespace Ryujinx.Audio.Backends.OpenAL private ulong _playedSampleCount; private float _volume; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public OpenALHardwareDeviceSession(OpenALHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount) { diff --git a/src/Ryujinx.Audio.Backends.OpenAL/Ryujinx.Audio.Backends.OpenAL.csproj b/src/Ryujinx.Audio.Backends.OpenAL/Ryujinx.Audio.Backends.OpenAL.csproj index bdf46d688..4ef3aebec 100644 --- a/src/Ryujinx.Audio.Backends.OpenAL/Ryujinx.Audio.Backends.OpenAL.csproj +++ b/src/Ryujinx.Audio.Backends.OpenAL/Ryujinx.Audio.Backends.OpenAL.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Audio.Backends.SDL2/Ryujinx.Audio.Backends.SDL2.csproj b/src/Ryujinx.Audio.Backends.SDL2/Ryujinx.Audio.Backends.SDL2.csproj index 940e47308..d0d45122e 100644 --- a/src/Ryujinx.Audio.Backends.SDL2/Ryujinx.Audio.Backends.SDL2.csproj +++ b/src/Ryujinx.Audio.Backends.SDL2/Ryujinx.Audio.Backends.SDL2.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Audio.Backends.SoundIo/Ryujinx.Audio.Backends.SoundIo.csproj b/src/Ryujinx.Audio.Backends.SoundIo/Ryujinx.Audio.Backends.SoundIo.csproj index 671a6ad5e..d06f66181 100644 --- a/src/Ryujinx.Audio.Backends.SoundIo/Ryujinx.Audio.Backends.SoundIo.csproj +++ b/src/Ryujinx.Audio.Backends.SoundIo/Ryujinx.Audio.Backends.SoundIo.csproj @@ -1,7 +1,6 @@ - net8.0 true win-x64;osx-x64;linux-x64 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Audio/AudioManager.cs b/src/Ryujinx.Audio/AudioManager.cs index 370d3d098..8c2c0ef6b 100644 --- a/src/Ryujinx.Audio/AudioManager.cs +++ b/src/Ryujinx.Audio/AudioManager.cs @@ -11,7 +11,7 @@ namespace Ryujinx.Audio /// /// Lock used to control the waiters registration. /// - private readonly object _lock = new(); + private readonly Lock _lock = new(); /// /// Events signaled when the driver played audio buffers. diff --git a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs index 7aefe8865..6f31755a3 100644 --- a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs +++ b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs @@ -2,6 +2,7 @@ using Ryujinx.Common; using Ryujinx.Common.Memory; using System; using System.Buffers; +using System.Threading; namespace Ryujinx.Audio.Backends.Common { @@ -12,7 +13,7 @@ namespace Ryujinx.Audio.Backends.Common { private const int RingBufferAlignment = 2048; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private MemoryOwner _bufferOwner; private Memory _buffer; diff --git a/src/Ryujinx.Audio/Input/AudioInputManager.cs b/src/Ryujinx.Audio/Input/AudioInputManager.cs index d56997e9c..ffc3e6da2 100644 --- a/src/Ryujinx.Audio/Input/AudioInputManager.cs +++ b/src/Ryujinx.Audio/Input/AudioInputManager.cs @@ -14,12 +14,12 @@ namespace Ryujinx.Audio.Input /// public class AudioInputManager : IDisposable { - private readonly object _lock = new(); + private readonly Lock _lock = new(); /// /// Lock used for session allocation. /// - private readonly object _sessionLock = new(); + private readonly Lock _sessionLock = new(); /// /// The session ids allocation table. diff --git a/src/Ryujinx.Audio/Input/AudioInputSystem.cs b/src/Ryujinx.Audio/Input/AudioInputSystem.cs index 34623b34f..65b99745d 100644 --- a/src/Ryujinx.Audio/Input/AudioInputSystem.cs +++ b/src/Ryujinx.Audio/Input/AudioInputSystem.cs @@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Input /// /// The lock of the parent. /// - private readonly object _parentLock; + private readonly Lock _parentLock; /// /// The dispose state. @@ -62,7 +62,7 @@ namespace Ryujinx.Audio.Input /// The lock of the manager /// The hardware device session /// The buffer release event of the audio input - public AudioInputSystem(AudioInputManager manager, object parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent) + public AudioInputSystem(AudioInputManager manager, Lock parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent) { _manager = manager; _parentLock = parentLock; diff --git a/src/Ryujinx.Audio/Output/AudioOutputManager.cs b/src/Ryujinx.Audio/Output/AudioOutputManager.cs index 308cd1564..13e169a24 100644 --- a/src/Ryujinx.Audio/Output/AudioOutputManager.cs +++ b/src/Ryujinx.Audio/Output/AudioOutputManager.cs @@ -14,12 +14,12 @@ namespace Ryujinx.Audio.Output /// public class AudioOutputManager : IDisposable { - private readonly object _lock = new(); + private readonly Lock _lock = new(); /// /// Lock used for session allocation. /// - private readonly object _sessionLock = new(); + private readonly Lock _sessionLock = new(); /// /// The session ids allocation table. diff --git a/src/Ryujinx.Audio/Output/AudioOutputSystem.cs b/src/Ryujinx.Audio/Output/AudioOutputSystem.cs index f9b9bdcf1..dc7d52ced 100644 --- a/src/Ryujinx.Audio/Output/AudioOutputSystem.cs +++ b/src/Ryujinx.Audio/Output/AudioOutputSystem.cs @@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Output /// /// THe lock of the parent. /// - private readonly object _parentLock; + private readonly Lock _parentLock; /// /// The dispose state. @@ -62,7 +62,7 @@ namespace Ryujinx.Audio.Output /// The lock of the manager /// The hardware device session /// The buffer release event of the audio output - public AudioOutputSystem(AudioOutputManager manager, object parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent) + public AudioOutputSystem(AudioOutputManager manager, Lock parentLock, IHardwareDeviceSession deviceSession, IWritableEvent bufferEvent) { _manager = manager; _parentLock = parentLock; diff --git a/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs b/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs index 246889c48..65a134af1 100644 --- a/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs +++ b/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs @@ -26,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Server { public class AudioRenderSystem : IDisposable { - private readonly object _lock = new(); + private readonly Lock _lock = new(); private AudioRendererRenderingDevice _renderingDevice; private AudioRendererExecutionMode _executionMode; diff --git a/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs b/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs index e334a89f6..6d7db059f 100644 --- a/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs +++ b/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs @@ -19,12 +19,12 @@ namespace Ryujinx.Audio.Renderer.Server /// /// Lock used for session allocation. /// - private readonly object _sessionLock = new(); + private readonly Lock _sessionLock = new(); /// /// Lock used to control the running state. /// - private readonly object _audioProcessorLock = new(); + private readonly Lock _audioProcessorLock = new(); /// /// The session ids allocation table. diff --git a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs index dbc2c9b3f..8b3f39439 100644 --- a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs +++ b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Threading; namespace Ryujinx.Audio.Renderer.Server.Upsampler { @@ -16,7 +17,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler /// /// Global lock of the object. /// - private readonly object _lock = new(); + private readonly Lock _lock = new(); /// /// The upsamplers instances. diff --git a/src/Ryujinx.Audio/Ryujinx.Audio.csproj b/src/Ryujinx.Audio/Ryujinx.Audio.csproj index 8901bbf59..92e0fe93f 100644 --- a/src/Ryujinx.Audio/Ryujinx.Audio.csproj +++ b/src/Ryujinx.Audio/Ryujinx.Audio.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Common/PreciseSleep/NanosleepPool.cs b/src/Ryujinx.Common/PreciseSleep/NanosleepPool.cs index c0973dcb3..45b8e95fa 100644 --- a/src/Ryujinx.Common/PreciseSleep/NanosleepPool.cs +++ b/src/Ryujinx.Common/PreciseSleep/NanosleepPool.cs @@ -124,7 +124,7 @@ namespace Ryujinx.Common.PreciseSleep } } - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly List _threads = new(); private readonly List _active = new(); private readonly Stack _free = new(); diff --git a/src/Ryujinx.Common/PreciseSleep/WindowsGranularTimer.cs b/src/Ryujinx.Common/PreciseSleep/WindowsGranularTimer.cs index 3bf092704..cef4dc927 100644 --- a/src/Ryujinx.Common/PreciseSleep/WindowsGranularTimer.cs +++ b/src/Ryujinx.Common/PreciseSleep/WindowsGranularTimer.cs @@ -50,7 +50,7 @@ namespace Ryujinx.Common.SystemInterop private long _lastTicks = PerformanceCounter.ElapsedTicks; private long _lastId; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly List _waitingObjects = new(); private WindowsGranularTimer() diff --git a/src/Ryujinx.Common/Ryujinx.Common.csproj b/src/Ryujinx.Common/Ryujinx.Common.csproj index 85d4b58bd..de163aae7 100644 --- a/src/Ryujinx.Common/Ryujinx.Common.csproj +++ b/src/Ryujinx.Common/Ryujinx.Common.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefineConstants);$(ExtraDefineConstants) $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Cpu/AppleHv/HvVm.cs b/src/Ryujinx.Cpu/AppleHv/HvVm.cs index a12bbea9b..b4d45f36d 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvVm.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvVm.cs @@ -1,6 +1,7 @@ using Ryujinx.Memory; using System; using System.Runtime.Versioning; +using System.Threading; namespace Ryujinx.Cpu.AppleHv { @@ -12,7 +13,7 @@ namespace Ryujinx.Cpu.AppleHv private static int _addressSpaces; private static HvIpaAllocator _ipaAllocator; - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); public static (ulong, HvIpaAllocator) CreateAddressSpace(MemoryBlock block) { diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs index 4d97a2264..21e40b6aa 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitSystem.cs @@ -478,7 +478,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 bool skipContext, int spillBaseOffset, int? resultRegister, - params ulong[] callArgs) + params ReadOnlySpan callArgs) { uint resultMask = 0u; diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs index f534e8b6e..bf9338400 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs @@ -307,7 +307,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 int tempRegister; int tempGuestAddress = -1; - bool inlineLookup = guestAddress.Kind != OperandKind.Constant && + bool inlineLookup = guestAddress.Kind != OperandKind.Constant && funcTable is { Sparse: true }; if (guestAddress.Kind == OperandKind.Constant) @@ -417,7 +417,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 nint funcPtr, int spillBaseOffset, int? resultRegister, - params ulong[] callArgs) + params ReadOnlySpan callArgs) { uint resultMask = 0u; diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs index ac1274bf6..10ae050b6 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using System.Runtime.Versioning; +using System.Threading; namespace Ryujinx.Cpu.LightningJit.Cache { @@ -23,7 +24,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache private static readonly List _cacheEntries = new(); - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static bool _initialized; [SupportedOSPlatform("windows")] diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs index 3cf279ae3..e9a342aba 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/NoWxCache.cs @@ -4,6 +4,7 @@ using Ryujinx.Memory; using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading; namespace Ryujinx.Cpu.LightningJit.Cache { @@ -104,7 +105,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache private readonly MemoryCache _sharedCache; private readonly MemoryCache _localCache; private readonly PageAlignedRangeList _pendingMap; - private readonly object _lock; + private readonly Lock _lock = new(); class ThreadLocalCacheEntry { @@ -137,7 +138,6 @@ namespace Ryujinx.Cpu.LightningJit.Cache _sharedCache = new(allocator, SharedCacheSize); _localCache = new(allocator, LocalCacheSize); _pendingMap = new(_sharedCache.ReprotectAsRx, RegisterFunction); - _lock = new(); } public unsafe nint Map(nint framePointer, ReadOnlySpan code, ulong guestAddress, ulong guestSize) diff --git a/src/Ryujinx.Cpu/Ryujinx.Cpu.csproj b/src/Ryujinx.Cpu/Ryujinx.Cpu.csproj index 0a55a7dea..e58a2ce97 100644 --- a/src/Ryujinx.Cpu/Ryujinx.Cpu.csproj +++ b/src/Ryujinx.Cpu/Ryujinx.Cpu.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Cpu/Signal/NativeSignalHandler.cs b/src/Ryujinx.Cpu/Signal/NativeSignalHandler.cs index 2985f1c21..75a6d3bf8 100644 --- a/src/Ryujinx.Cpu/Signal/NativeSignalHandler.cs +++ b/src/Ryujinx.Cpu/Signal/NativeSignalHandler.cs @@ -5,6 +5,7 @@ using System; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Threading; namespace Ryujinx.Cpu.Signal { @@ -59,7 +60,7 @@ namespace Ryujinx.Cpu.Signal private static MemoryBlock _codeBlock; - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); private static bool _initialized; static NativeSignalHandler() diff --git a/src/Ryujinx.Graphics.Device/Ryujinx.Graphics.Device.csproj b/src/Ryujinx.Graphics.Device/Ryujinx.Graphics.Device.csproj index 58f54de7d..cbe276355 100644 --- a/src/Ryujinx.Graphics.Device/Ryujinx.Graphics.Device.csproj +++ b/src/Ryujinx.Graphics.Device/Ryujinx.Graphics.Device.csproj @@ -1,7 +1,6 @@  - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs index 0bd3dc592..6375d290c 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs @@ -58,7 +58,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading public uint ProgramCount { get; set; } = 0; private Action _interruptAction; - private readonly object _interruptLock = new(); + private readonly Lock _interruptLock = new(); public event EventHandler ScreenCaptured; diff --git a/src/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj b/src/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj index a230296c1..b94a4ec90 100644 --- a/src/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj +++ b/src/Ryujinx.Graphics.GAL/Ryujinx.Graphics.GAL.csproj @@ -1,7 +1,6 @@  - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index 2cfd9af5b..ff7f11142 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -8,6 +8,7 @@ using Ryujinx.Graphics.Texture; using Ryujinx.Memory.Range; using System; using System.Collections.Generic; +using System.Linq; using System.Threading; namespace Ryujinx.Graphics.Gpu.Image @@ -998,7 +999,7 @@ namespace Ryujinx.Graphics.Gpu.Image { bool dataOverlaps = texture.DataOverlaps(overlap, compatibility); - if (!overlap.IsView && dataOverlaps && !incompatibleOverlaps.Exists(incompatible => incompatible.Group == overlap.Group)) + if (!overlap.IsView && dataOverlaps && !incompatibleOverlaps.Any(incompatible => incompatible.Group == overlap.Group)) { incompatibleOverlaps.Add(new TextureIncompatibleOverlap(overlap.Group, compatibility)); } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs index 526fc0c24..2db5c6290 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs @@ -7,6 +7,7 @@ using Ryujinx.Memory.Range; using Ryujinx.Memory.Tracking; using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; namespace Ryujinx.Graphics.Gpu.Image @@ -1555,7 +1556,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if the overlap should register copy dependencies public void RegisterIncompatibleOverlap(TextureIncompatibleOverlap other, bool copy) { - if (!_incompatibleOverlaps.Exists(overlap => overlap.Group == other.Group)) + if (!_incompatibleOverlaps.Any(overlap => overlap.Group == other.Group)) { if (copy && other.Compatibility == TextureViewCompatibility.LayoutIncompatible) { @@ -1701,3 +1702,4 @@ namespace Ryujinx.Graphics.Gpu.Image } } } + diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index be7cb0b89..3bf122412 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -721,7 +721,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The format of the texture /// The texture swizzle components /// The depth-stencil mode - private static DepthStencilMode GetDepthStencilMode(Format format, params SwizzleComponent[] components) + private static DepthStencilMode GetDepthStencilMode(Format format, params ReadOnlySpan components) { // R = Depth, G = Stencil. // On 24-bits depth formats, this is inverted (Stencil is R etc). diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs index d330de638..c5a12c1fc 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs @@ -2,6 +2,7 @@ using Ryujinx.Common.Pools; using Ryujinx.Memory.Range; using System; using System.Linq; +using System.Threading; namespace Ryujinx.Graphics.Gpu.Memory { @@ -76,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Memory private BufferMigration _source; private BufferModifiedRangeList _migrationTarget; - private readonly object _lock = new(); + private readonly Lock _lock = new(); /// /// Whether the modified range list has any entries or not. @@ -435,7 +436,7 @@ namespace Ryujinx.Graphics.Gpu.Memory if (_source == null) { - // Create a new migration. + // Create a new migration. _source = new BufferMigration(new BufferMigrationSpan[] { span }, this, _context.SyncNumber); _context.RegisterBufferMigration(_source); diff --git a/src/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj b/src/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj index 8c740fadc..4cd9c1d5c 100644 --- a/src/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj +++ b/src/Ryujinx.Graphics.Gpu/Ryujinx.Graphics.Gpu.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Host1x/Ryujinx.Graphics.Host1x.csproj b/src/Ryujinx.Graphics.Host1x/Ryujinx.Graphics.Host1x.csproj index 92077e26a..3000d41de 100644 --- a/src/Ryujinx.Graphics.Host1x/Ryujinx.Graphics.Host1x.csproj +++ b/src/Ryujinx.Graphics.Host1x/Ryujinx.Graphics.Host1x.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Ryujinx.Graphics.Nvdec.FFmpeg.csproj b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Ryujinx.Graphics.Nvdec.FFmpeg.csproj index 7659c4b25..9e250d171 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Ryujinx.Graphics.Nvdec.FFmpeg.csproj +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Ryujinx.Graphics.Nvdec.FFmpeg.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Ryujinx.Graphics.Nvdec.Vp9.csproj b/src/Ryujinx.Graphics.Nvdec.Vp9/Ryujinx.Graphics.Nvdec.Vp9.csproj index 7659c4b25..9e250d171 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/Ryujinx.Graphics.Nvdec.Vp9.csproj +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Ryujinx.Graphics.Nvdec.Vp9.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Nvdec/Ryujinx.Graphics.Nvdec.csproj b/src/Ryujinx.Graphics.Nvdec/Ryujinx.Graphics.Nvdec.csproj index 7a13b5d1b..d020ae50e 100644 --- a/src/Ryujinx.Graphics.Nvdec/Ryujinx.Graphics.Nvdec.csproj +++ b/src/Ryujinx.Graphics.Nvdec/Ryujinx.Graphics.Nvdec.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs index 345a99ffa..7e0311407 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs @@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries private ulong _accumulatedCounter; private int _waiterCount; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly Queue _queryPool; private readonly AutoResetEvent _queuedEvent = new(false); diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs index 32b75c615..889517480 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs @@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries private bool _hostAccessReserved = false; private int _refCount = 1; // Starts with a reference from the counter queue. - private readonly object _lock = new(); + private readonly Lock _lock = new(); private ulong _result = ulong.MaxValue; private double _divisor = 1f; diff --git a/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs b/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs index 6385f57b5..c8ff30a07 100644 --- a/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs +++ b/src/Ryujinx.Graphics.OpenGL/ResourcePool.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.OpenGL.Image; using System; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.Graphics.OpenGL { @@ -19,7 +20,7 @@ namespace Ryujinx.Graphics.OpenGL { private const int DisposedLiveFrames = 2; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly Dictionary> _textures = new(); /// diff --git a/src/Ryujinx.Graphics.OpenGL/Ryujinx.Graphics.OpenGL.csproj b/src/Ryujinx.Graphics.OpenGL/Ryujinx.Graphics.OpenGL.csproj index 931e70c03..47cec29e2 100644 --- a/src/Ryujinx.Graphics.OpenGL/Ryujinx.Graphics.OpenGL.csproj +++ b/src/Ryujinx.Graphics.OpenGL/Ryujinx.Graphics.OpenGL.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs index b259dde28..105812ebf 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs @@ -4,6 +4,7 @@ using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; using System; using System.Collections.Generic; +using System.Threading; using static Spv.Specification; namespace Ryujinx.Graphics.Shader.CodeGen.Spirv @@ -19,13 +20,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private const int GeneratorPoolCount = 1; private static readonly ObjectPool _instructionPool; private static readonly ObjectPool _integerPool; - private static readonly object _poolLock; + private static readonly Lock _poolLock = new(); static SpirvGenerator() { _instructionPool = new(() => new SpvInstructionPool(), GeneratorPoolCount); _integerPool = new(() => new SpvLiteralIntegerPool(), GeneratorPoolCount); - _poolLock = new object(); } private const HelperFunctionsMask NeedsInvocationIdMask = HelperFunctionsMask.SwizzleAdd; diff --git a/src/Ryujinx.Graphics.Shader/Ryujinx.Graphics.Shader.csproj b/src/Ryujinx.Graphics.Shader/Ryujinx.Graphics.Shader.csproj index be32641eb..cfb188daf 100644 --- a/src/Ryujinx.Graphics.Shader/Ryujinx.Graphics.Shader.csproj +++ b/src/Ryujinx.Graphics.Shader/Ryujinx.Graphics.Shader.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Texture/Ryujinx.Graphics.Texture.csproj b/src/Ryujinx.Graphics.Texture/Ryujinx.Graphics.Texture.csproj index 48d10f1d5..2b4445aeb 100644 --- a/src/Ryujinx.Graphics.Texture/Ryujinx.Graphics.Texture.csproj +++ b/src/Ryujinx.Graphics.Texture/Ryujinx.Graphics.Texture.csproj @@ -1,6 +1,5 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Vic/Ryujinx.Graphics.Vic.csproj b/src/Ryujinx.Graphics.Vic/Ryujinx.Graphics.Vic.csproj index 820e807e6..5505a3aa1 100644 --- a/src/Ryujinx.Graphics.Vic/Ryujinx.Graphics.Vic.csproj +++ b/src/Ryujinx.Graphics.Vic/Ryujinx.Graphics.Vic.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Video/Ryujinx.Graphics.Video.csproj b/src/Ryujinx.Graphics.Video/Ryujinx.Graphics.Video.csproj index d85effe32..d64990f82 100644 --- a/src/Ryujinx.Graphics.Video/Ryujinx.Graphics.Video.csproj +++ b/src/Ryujinx.Graphics.Video/Ryujinx.Graphics.Video.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs b/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs index 0290987fd..e4b68fa40 100644 --- a/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs +++ b/src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Vulkan { bool useBackground = _gd.BackgroundQueue.Handle != 0 && _gd.Vendor != Vendor.Amd; Queue queue = useBackground ? _gd.BackgroundQueue : _gd.Queue; - object queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock; + Lock queueLock = useBackground ? _gd.BackgroundQueueLock : _gd.QueueLock; lock (queueLock) { diff --git a/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs b/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs index e1fd3fb9d..ed76c6566 100644 --- a/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs +++ b/src/Ryujinx.Graphics.Vulkan/CommandBufferPool.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Vulkan private readonly Vk _api; private readonly Device _device; private readonly Queue _queue; - private readonly object _queueLock; + private readonly Lock _queueLock; private readonly bool _concurrentFenceWaitUnsupported; private readonly CommandPool _pool; private readonly Thread _owner; @@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Vulkan Vk api, Device device, Queue queue, - object queueLock, + Lock queueLock, uint queueFamilyIndex, bool concurrentFenceWaitUnsupported, bool isLight = false) diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index 9ea8cec4b..5a3bd61bd 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Vulkan _optimalTable = new FormatFeatureFlags[totalFormats]; } - public bool BufferFormatsSupport(FormatFeatureFlags flags, params Format[] formats) + public bool BufferFormatsSupport(FormatFeatureFlags flags, params ReadOnlySpan formats) { foreach (Format format in formats) { @@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Vulkan return true; } - public bool OptimalFormatsSupport(FormatFeatureFlags flags, params Format[] formats) + public bool OptimalFormatsSupport(FormatFeatureFlags flags, params ReadOnlySpan formats) { foreach (Format format in formats) { diff --git a/src/Ryujinx.Graphics.Vulkan/HostMemoryAllocator.cs b/src/Ryujinx.Graphics.Vulkan/HostMemoryAllocator.cs index 77c5f95c9..5c8b2a761 100644 --- a/src/Ryujinx.Graphics.Vulkan/HostMemoryAllocator.cs +++ b/src/Ryujinx.Graphics.Vulkan/HostMemoryAllocator.cs @@ -5,6 +5,7 @@ using Silk.NET.Vulkan; using Silk.NET.Vulkan.Extensions.EXT; using System; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.Graphics.Vulkan { @@ -31,7 +32,7 @@ namespace Ryujinx.Graphics.Vulkan private readonly Vk _api; private readonly ExtExternalMemoryHost _hostMemoryApi; private readonly Device _device; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly List _allocations; private readonly IntervalTree _allocationTree; diff --git a/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs b/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs index 0d133e50e..fa10f13b9 100644 --- a/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs +++ b/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueue.cs @@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries private ulong _accumulatedCounter; private int _waiterCount; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly Queue _queryPool; private readonly AutoResetEvent _queuedEvent = new(false); diff --git a/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs b/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs index 14d3050bf..0bac3be12 100644 --- a/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs +++ b/src/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries private bool _hostAccessReserved; private int _refCount = 1; // Starts with a reference from the counter queue. - private readonly object _lock = new(); + private readonly Lock _lock = new(); private ulong _result = ulong.MaxValue; private double _divisor = 1f; diff --git a/src/Ryujinx.Graphics.Vulkan/Ryujinx.Graphics.Vulkan.csproj b/src/Ryujinx.Graphics.Vulkan/Ryujinx.Graphics.Vulkan.csproj index b138e309a..5481e57f2 100644 --- a/src/Ryujinx.Graphics.Vulkan/Ryujinx.Graphics.Vulkan.csproj +++ b/src/Ryujinx.Graphics.Vulkan/Ryujinx.Graphics.Vulkan.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Graphics.Vulkan/Shader.cs b/src/Ryujinx.Graphics.Vulkan/Shader.cs index f23b78f51..79e2f712a 100644 --- a/src/Ryujinx.Graphics.Vulkan/Shader.cs +++ b/src/Ryujinx.Graphics.Vulkan/Shader.cs @@ -5,6 +5,7 @@ using shaderc; using Silk.NET.Vulkan; using System; using System.Runtime.InteropServices; +using System.Threading; using System.Threading.Tasks; namespace Ryujinx.Graphics.Vulkan @@ -13,7 +14,7 @@ namespace Ryujinx.Graphics.Vulkan { // The shaderc.net dependency's Options constructor and dispose are not thread safe. // Take this lock when using them. - private static readonly object _shaderOptionsLock = new(); + private static readonly Lock _shaderOptionsLock = new(); private static readonly nint _ptrMainEntryPointName = Marshal.StringToHGlobalAnsi("main"); diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index cc2bc36c2..ad4b18e50 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -11,6 +11,7 @@ using Silk.NET.Vulkan.Extensions.KHR; using System; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Threading; using Format = Ryujinx.Graphics.GAL.Format; using PrimitiveTopology = Ryujinx.Graphics.GAL.PrimitiveTopology; using SamplerCreateInfo = Ryujinx.Graphics.GAL.SamplerCreateInfo; @@ -45,8 +46,8 @@ namespace Ryujinx.Graphics.Vulkan internal uint QueueFamilyIndex { get; private set; } internal Queue Queue { get; private set; } internal Queue BackgroundQueue { get; private set; } - internal object BackgroundQueueLock { get; private set; } - internal object QueueLock { get; private set; } + internal Lock BackgroundQueueLock { get; private set; } + internal Lock QueueLock { get; private set; } internal MemoryAllocator MemoryAllocator { get; private set; } internal HostMemoryAllocator HostMemoryAllocator { get; private set; } @@ -120,7 +121,7 @@ namespace Ryujinx.Graphics.Vulkan } public static VulkanRenderer Create( - string preferredGpuId, + string preferredGpuId, Func getSurface, Func getRequiredExtensions ) => new(Vk.GetApi(), getSurface, getRequiredExtensions, preferredGpuId); @@ -163,7 +164,7 @@ namespace Ryujinx.Graphics.Vulkan { Api.GetDeviceQueue(_device, queueFamilyIndex, 1, out var backgroundQueue); BackgroundQueue = backgroundQueue; - BackgroundQueueLock = new object(); + BackgroundQueueLock = new(); } PhysicalDeviceProperties2 properties2 = new() @@ -496,7 +497,7 @@ namespace Ryujinx.Graphics.Vulkan Api.GetDeviceQueue(_device, queueFamilyIndex, 0, out var queue); Queue = queue; - QueueLock = new object(); + QueueLock = new(); LoadFeatures(maxQueueCount, queueFamilyIndex); diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index 51f6058fc..9bda759a5 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -22,6 +22,7 @@ using System.IO.Compression; using System.Linq; using System.Text; using System.Text.RegularExpressions; +using System.Threading; using Path = System.IO.Path; namespace Ryujinx.HLE.FileSystem @@ -55,7 +56,7 @@ namespace Ryujinx.HLE.FileSystem private readonly VirtualFileSystem _virtualFileSystem; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public ContentManager(VirtualFileSystem virtualFileSystem) { @@ -396,7 +397,7 @@ namespace Ryujinx.HLE.FileSystem if (locationList != null) { LocationEntry entry = - locationList.ToList().Find(x => x.TitleId == titleId && x.ContentType == contentType); + locationList.ToList().FirstOrDefault(x => x.TitleId == titleId && x.ContentType == contentType); if (entry.ContentPath != null) { @@ -424,7 +425,7 @@ namespace Ryujinx.HLE.FileSystem { LinkedList locationList = _locationEntries[storageId]; - return locationList.ToList().Find(x => x.TitleId == titleId && x.ContentType == contentType); + return locationList.ToList().FirstOrDefault(x => x.TitleId == titleId && x.ContentType == contentType); } public void InstallFirmware(string firmwareSource) @@ -719,7 +720,7 @@ namespace Ryujinx.HLE.FileSystem if (updateNcas.TryGetValue(SystemUpdateTitleId, out var ncaEntry)) { - string metaPath = ncaEntry.Find(x => x.type == NcaContentType.Meta).path; + string metaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path; CnmtContentMetaEntry[] metaEntries = null; @@ -755,7 +756,7 @@ namespace Ryujinx.HLE.FileSystem if (updateNcas.TryGetValue(SystemVersionTitleId, out var updateNcasItem)) { - string versionEntry = updateNcasItem.Find(x => x.type != NcaContentType.Meta).path; + string versionEntry = updateNcasItem.FirstOrDefault(x => x.type != NcaContentType.Meta).path; using Stream ncaStream = GetZipStream(archive.GetEntry(versionEntry)); Nca nca = new(_virtualFileSystem.KeySet, ncaStream.AsStorage()); @@ -774,9 +775,9 @@ namespace Ryujinx.HLE.FileSystem { if (updateNcas.TryGetValue(metaEntry.TitleId, out ncaEntry)) { - metaPath = ncaEntry.Find(x => x.type == NcaContentType.Meta).path; + metaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path; - string contentPath = ncaEntry.Find(x => x.type != NcaContentType.Meta).path; + string contentPath = ncaEntry.FirstOrDefault(x => x.type != NcaContentType.Meta).path; // Nintendo in 9.0.0, removed PPC and only kept the meta nca of it. // This is a perfect valid case, so we should just ignore the missing content nca and continue. @@ -915,8 +916,8 @@ namespace Ryujinx.HLE.FileSystem { if (updateNcas.TryGetValue(metaEntry.TitleId, out var ncaEntry)) { - string metaNcaPath = ncaEntry.Find(x => x.type == NcaContentType.Meta).path; - string contentPath = ncaEntry.Find(x => x.type != NcaContentType.Meta).path; + string metaNcaPath = ncaEntry.FirstOrDefault(x => x.type == NcaContentType.Meta).path; + string contentPath = ncaEntry.FirstOrDefault(x => x.type != NcaContentType.Meta).path; // Nintendo in 9.0.0, removed PPC and only kept the meta nca of it. // This is a perfect valid case, so we should just ignore the missing content nca and continue. @@ -1076,7 +1077,7 @@ namespace Ryujinx.HLE.FileSystem { if (File.Exists(Path.Combine(pathToCheck, file))) { - return true; + return true; } } return false; diff --git a/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs b/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs index aebcf7988..8cdb889be 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentMetaData.cs @@ -46,7 +46,7 @@ namespace Ryujinx.HLE.FileSystem continue; } - string ncaId = BitConverter.ToString(entry.NcaId).Replace("-", null).ToLower(); + string ncaId = Convert.ToHexStringLower(entry.NcaId).Replace("-", null); Nca nca = _pfs.GetNca(keySet, $"/{ncaId}.nca"); if (nca.GetProgramIndex() == programIndex) diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 9ec202357..8fda00a7d 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -14,6 +14,7 @@ using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; +using System.Threading; namespace Ryujinx.HLE.HOS.Applets { @@ -62,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Applets private bool _canAcceptController = false; private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public event EventHandler AppletStateChanged; diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs index 67b5f2b1f..e17b36911 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; +using System.Threading; namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard { @@ -21,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard const string CancelText = "Cancel"; const string ControllerToggleText = "Toggle input"; - private readonly object _bufferLock = new(); + private readonly Lock _bufferLock = new(); private RenderingSurfaceInfo _surfaceInfo = null; private SKImageInfo _imageInfo; diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs index 3eaf64596..a8b137df2 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs @@ -27,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard private TRef _cancelled = null; private Thread _thread = null; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public bool IsRunning { diff --git a/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs b/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs index 3f16f8c24..90231b460 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Common/KResourceLimit.cs @@ -2,6 +2,7 @@ using Ryujinx.Common; using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.Horizon.Common; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.HLE.HOS.Kernel.Common { @@ -14,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common private readonly long[] _current2; private readonly long[] _peak; - private readonly object _lock; + private readonly object _lock = new(); private readonly LinkedList _waitingThreads; @@ -27,8 +28,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Common _current2 = new long[(int)LimitableResource.Count]; _peak = new long[(int)LimitableResource.Count]; - _lock = new object(); - _waitingThreads = new LinkedList(); } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs index c725501b0..e6d96d803 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs @@ -4,6 +4,7 @@ using Ryujinx.HLE.HOS.Kernel.Process; using Ryujinx.Horizon.Common; using System; using System.Diagnostics; +using System.Threading; namespace Ryujinx.HLE.HOS.Kernel.Memory { @@ -11,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory { public KProcess Owner { get; private set; } private readonly KPageList _pageList; - private readonly object _lock; + private readonly Lock _lock = new(); private ulong _address; private bool _isOwnerMapped; private bool _isMapped; @@ -19,7 +20,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory public KCodeMemory(KernelContext context) : base(context) { _pageList = new KPageList(); - _lock = new object(); } public Result Initialize(ulong address, ulong size) diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index 422f03c64..b4aa5ca5c 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -40,8 +40,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process public ProcessState State { get; private set; } - private readonly object _processLock = new(); - private readonly object _threadingLock = new(); + private readonly Lock _processLock = new(); + private readonly Lock _threadingLock = new(); public KAddressArbiter AddressArbiter { get; private set; } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs index f6b9a112c..0c63c7e0e 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KAddressArbiter.cs @@ -200,7 +200,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading WakeThreads(_condVarThreads, count, TryAcquireMutex, x => x.CondVarAddress == address); - if (!_condVarThreads.Exists(x => x.CondVarAddress == address)) + if (!_condVarThreads.Any(x => x.CondVarAddress == address)) { KernelTransfer.KernelToUser(address, 0); } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs index 3d6744882..bfa6b68f6 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KCriticalSection.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading class KCriticalSection { private readonly KernelContext _context; - private readonly object _lock; + private readonly object _lock = new(); private int _recursionCount; public object Lock => _lock; @@ -13,7 +13,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading public KCriticalSection(KernelContext context) { _context = context; - _lock = new object(); } public void Enter() diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs index 835bf5d40..4abc0ddf3 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs @@ -112,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading public bool WaitingInArbitration { get; set; } - private readonly object _activityOperationLock = new(); + private readonly Lock _activityOperationLock = new(); public KThread(KernelContext context) : base(context) { diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs index 7cbe1afca..d8c62fc66 100644 --- a/src/Ryujinx.HLE/HOS/ModLoader.cs +++ b/src/Ryujinx.HLE/HOS/ModLoader.cs @@ -168,7 +168,7 @@ namespace Ryujinx.HLE.HOS if (StrEquals(RomfsDir, modDir.Name)) { - var modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path)); + var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path)); var enabled = modData?.Enabled ?? true; mods.RomfsDirs.Add(mod = new Mod(dir.Name, modDir, enabled)); @@ -176,7 +176,7 @@ namespace Ryujinx.HLE.HOS } else if (StrEquals(ExefsDir, modDir.Name)) { - var modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path)); + var modData = modMetadata.Mods.FirstOrDefault(x => modDir.FullName.Contains(x.Path)); var enabled = modData?.Enabled ?? true; mods.ExefsDirs.Add(mod = new Mod(dir.Name, modDir, enabled)); @@ -275,7 +275,7 @@ namespace Ryujinx.HLE.HOS var fsFile = new FileInfo(Path.Combine(applicationDir.FullName, RomfsContainer)); if (fsFile.Exists) { - var modData = modMetadata.Mods.Find(x => fsFile.FullName.Contains(x.Path)); + var modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); var enabled = modData == null || modData.Enabled; mods.RomfsContainers.Add(new Mod($"<{applicationDir.Name} RomFs>", fsFile, enabled)); @@ -284,7 +284,7 @@ namespace Ryujinx.HLE.HOS fsFile = new FileInfo(Path.Combine(applicationDir.FullName, ExefsContainer)); if (fsFile.Exists) { - var modData = modMetadata.Mods.Find(x => fsFile.FullName.Contains(x.Path)); + var modData = modMetadata.Mods.FirstOrDefault(x => fsFile.FullName.Contains(x.Path)); var enabled = modData == null || modData.Enabled; mods.ExefsContainers.Add(new Mod($"<{applicationDir.Name} ExeFs>", fsFile, enabled)); @@ -403,7 +403,7 @@ namespace Ryujinx.HLE.HOS } // Assumes searchDirPaths don't overlap - private static void CollectMods(Dictionary modCaches, PatchCache patches, params string[] searchDirPaths) + private static void CollectMods(Dictionary modCaches, PatchCache patches, params ReadOnlySpan searchDirPaths) { static bool IsPatchesDir(string name) => StrEquals(AmsNsoPatchDir, name) || StrEquals(AmsNroPatchDir, name) || @@ -453,7 +453,7 @@ namespace Ryujinx.HLE.HOS patches.Initialized = true; } - public void CollectMods(IEnumerable applications, params string[] searchDirPaths) + public void CollectMods(IEnumerable applications, params ReadOnlySpan searchDirPaths) { Clear(); @@ -680,7 +680,7 @@ namespace Ryujinx.HLE.HOS ApplyProgramPatches(nroPatches, 0, nro); } - internal bool ApplyNsoPatches(ulong applicationId, params IExecutable[] programs) + internal bool ApplyNsoPatches(ulong applicationId, params ReadOnlySpan programs) { IEnumerable> nsoMods = _patches.NsoPatches; @@ -744,7 +744,7 @@ namespace Ryujinx.HLE.HOS } } - private static bool ApplyProgramPatches(IEnumerable> mods, int protectedOffset, params IExecutable[] programs) + private static bool ApplyProgramPatches(IEnumerable> mods, int protectedOffset, params ReadOnlySpan programs) { int count = 0; @@ -755,12 +755,18 @@ namespace Ryujinx.HLE.HOS patches[i] = new MemPatch(); } - var buildIds = programs.Select(p => p switch + var buildIds = new List(programs.Length); + + foreach (IExecutable p in programs) { - NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'), - NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'), - _ => string.Empty, - }).ToList(); + var buildId = p switch + { + NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()).TrimEnd('0'), + NroExecutable nro => Convert.ToHexString(nro.Header.BuildId).TrimEnd('0'), + _ => string.Empty, + }; + buildIds.Add(buildId); + } int GetIndex(string buildId) => buildIds.FindIndex(id => id == buildId); // O(n) but list is small diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs index 85898f138..8e0f515ba 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/SystemAppletProxy/ISelfController.cs @@ -4,6 +4,7 @@ using Ryujinx.HLE.HOS.Kernel.Threading; using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy.Types; using Ryujinx.Horizon.Common; using System; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy { @@ -17,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys private KEvent _accumulatedSuspendedTickChangedEvent; private int _accumulatedSuspendedTickChangedEventHandle; - private readonly object _fatalSectionLock = new(); + private readonly Lock _fatalSectionLock = new(); private int _fatalSectionCount; // TODO: Set this when the game goes in suspension (go back to home menu ect), we currently don't support that so we can keep it set to 0. diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs index 86c6a825f..834bee6f0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/NpadDevices.cs @@ -123,7 +123,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid return true; } - public void Configure(params ControllerConfig[] configs) + public void Configure(params ReadOnlySpan configs) { _configuredTypes = new ControllerType[MaxControllers]; diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs index 35ac1a16f..e8a56933b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/HidDevices/TouchDevice.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid { public TouchDevice(Switch device, bool active) : base(device, active) { } - public void Update(params TouchPoint[] points) + public void Update(params ReadOnlySpan points) { ref RingLifo lifo = ref _device.Hid.SharedMemory.TouchScreen; diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeLatestUpdate.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeLatestUpdate.cs index 0461e783e..826a50458 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeLatestUpdate.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/Types/NodeLatestUpdate.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Memory; using System.Runtime.InteropServices; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Ldn.Types { @@ -12,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.Types static class NodeLatestUpdateHelper { - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); public static void CalculateLatestUpdate(this Array8 array, Array8 beforeNodes, Array8 afterNodes) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs index b5f643d23..8b7af42a0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/LanDiscovery.cs @@ -29,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm private ILdnTcpSocket _tcp; private LdnProxyUdpServer _udp, _udp2; private readonly List _stations = new(); - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly AutoResetEvent _apConnected = new(false); diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs index 0f5875a1d..536ae476d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnMitm/Proxy/LdnProxyUdpServer.cs @@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm.Proxy private byte[] _buffer; private int _bufferEnd; - private readonly object _scanLock = new(); + private readonly Lock _scanLock = new(); private Dictionary _scanResultsLast = new(); private Dictionary _scanResults = new(); diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/NetworkTimeout.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/NetworkTimeout.cs index 5012d5d81..f7a9d77a4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/NetworkTimeout.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/NetworkTimeout.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu private readonly Action _timeoutCallback; private CancellationTokenSource _cancel; - private readonly object _lock = new object(); + private readonly Lock _lock = new(); public NetworkTimeout(int idleTimeout, Action timeoutCallback) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/EphemeralPortPool.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/EphemeralPortPool.cs index bc3a5edf2..9ea56d050 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/EphemeralPortPool.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/EphemeralPortPool.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy { @@ -8,7 +9,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy private readonly List _ephemeralPorts = new List(); - private readonly object _lock = new object(); + private readonly Lock _lock = new(); public ushort Get() { diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 0c685471c..7cb62ae41 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -8,6 +8,7 @@ using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager; using System; using System.Collections.Generic; using System.IO; +using System.Linq; namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { @@ -104,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId); - if (virtualAmiiboFile.ApplicationAreas.Exists(item => item.ApplicationAreaId == applicationAreaId)) + if (virtualAmiiboFile.ApplicationAreas.Any(item => item.ApplicationAreaId == applicationAreaId)) { _openedApplicationAreaId = applicationAreaId; @@ -133,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId); - if (virtualAmiiboFile.ApplicationAreas.Exists(item => item.ApplicationAreaId == applicationAreaId)) + if (virtualAmiiboFile.ApplicationAreas.Any(item => item.ApplicationAreaId == applicationAreaId)) { return false; } @@ -153,7 +154,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId); - if (virtualAmiiboFile.ApplicationAreas.Exists(item => item.ApplicationAreaId == _openedApplicationAreaId)) + if (virtualAmiiboFile.ApplicationAreas.Any(item => item.ApplicationAreaId == _openedApplicationAreaId)) { for (int i = 0; i < virtualAmiiboFile.ApplicationAreas.Count; i++) { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs index 8f851f37a..48622a224 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostEvent.cs @@ -26,7 +26,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl private NvFence _previousFailingFence; private uint _failingCount; - public readonly object Lock = new(); + public readonly Lock Lock = new(); /// /// Max failing count until waiting on CPU. diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs index b83c642e5..49637f757 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/Types/NvHostSyncPt.cs @@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl private readonly Switch _device; - private readonly object _syncpointAllocatorLock = new(); + private readonly Lock _syncpointAllocatorLock = new(); public NvHostSyncpt(Switch device) { diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs index 7ecd6835d..9d5bb8d01 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/BsdContext.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Numerics; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { @@ -10,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { private static readonly ConcurrentDictionary _registry = new(); - private readonly object _lock = new(); + private readonly Lock _lock = new(); private readonly List _fds; diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs index 49becac55..622b62c16 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/BuiltInCertificateManager.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Ssl { @@ -43,7 +44,7 @@ namespace Ryujinx.HLE.HOS.Services.Ssl private bool _initialized; private Dictionary _certificates; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private struct CertStoreFileHeader { diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs index f8ee84842..017365c6f 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/ConsumerBase.cs @@ -1,5 +1,6 @@ using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types; using System; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { @@ -23,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger protected BufferQueueConsumer Consumer; - protected readonly object Lock = new(); + protected readonly Lock Lock = new(); private readonly IConsumerListener _listener; diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs index bc7bffcb6..5151930a5 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs @@ -2,6 +2,7 @@ using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Kernel.Threading; using System; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { @@ -11,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private static int _lastBinderId = 0; - private static readonly object _lock = new(); + private static readonly Lock _lock = new(); public static int RegisterBinderObject(IBinder binder) { diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs index 601e85867..23bf8bcfc 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs @@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger private int _swapInterval; private int _swapIntervalDelay; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public long RenderLayerId { get; private set; } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs index 3b57b1805..155733d2e 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs @@ -2,6 +2,7 @@ using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Services.Time.Clock; using System; using System.IO; +using System.Threading; namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { @@ -13,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone private UInt128 _timeZoneRuleVersion; private uint _totalLocationNameCount; private SteadyClockTimePoint _timeZoneUpdateTimePoint; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public TimeZoneManager() { diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs index 33aee1c4c..e4286ae90 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoaderHelper.cs @@ -231,7 +231,7 @@ namespace Ryujinx.HLE.Loaders.Processes ulong programId, byte programIndex, byte[] arguments = null, - params IExecutable[] executables) + params ReadOnlySpan executables) { context.Device.System.ServiceTable.WaitServicesReady(); @@ -251,12 +251,17 @@ namespace Ryujinx.HLE.Loaders.Processes ulong codeStart = ((meta.Flags & 1) != 0 ? 0x8000000UL : 0x200000UL) + CodeStartOffset; uint codeSize = 0; - var buildIds = executables.Select(e => (e switch + var buildIds = new string[executables.Length]; + + for (int i = 0; i < executables.Length; i++) { - NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()), - NroExecutable nro => Convert.ToHexString(nro.Header.BuildId), - _ => string.Empty - }).ToUpper()); + buildIds[i] = (executables[i] switch + { + NsoExecutable nso => Convert.ToHexString(nso.BuildId.ItemsRo.ToArray()), + NroExecutable nro => Convert.ToHexString(nro.Header.BuildId), + _ => string.Empty + }).ToUpper(); + } ulong[] nsoBase = new ulong[executables.Length]; diff --git a/src/Ryujinx.HLE/PerformanceStatistics.cs b/src/Ryujinx.HLE/PerformanceStatistics.cs index 3767a7fb4..890bce8bc 100644 --- a/src/Ryujinx.HLE/PerformanceStatistics.cs +++ b/src/Ryujinx.HLE/PerformanceStatistics.cs @@ -1,4 +1,5 @@ using Ryujinx.Common; +using System.Threading; using System.Timers; namespace Ryujinx.HLE @@ -20,12 +21,12 @@ namespace Ryujinx.HLE private readonly long[] _framesRendered; private readonly double[] _percentTime; - private readonly object[] _frameLock; - private readonly object[] _percentLock; + private readonly Lock[] _frameLock = [new()]; + private readonly Lock[] _percentLock = [new()]; private readonly double _ticksToSeconds; - private readonly Timer _resetTimer; + private readonly System.Timers.Timer _resetTimer; public PerformanceStatistics() { @@ -41,10 +42,7 @@ namespace Ryujinx.HLE _framesRendered = new long[1]; _percentTime = new double[1]; - _frameLock = new[] { new object() }; - _percentLock = new[] { new object() }; - - _resetTimer = new Timer(750); + _resetTimer = new(750); _resetTimer.Elapsed += ResetTimerElapsed; _resetTimer.AutoReset = true; diff --git a/src/Ryujinx.HLE/Ryujinx.HLE.csproj b/src/Ryujinx.HLE/Ryujinx.HLE.csproj index 83e7b8810..d42ecf8b8 100644 --- a/src/Ryujinx.HLE/Ryujinx.HLE.csproj +++ b/src/Ryujinx.HLE/Ryujinx.HLE.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj b/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj index 8fbf9be1e..fe535e6d5 100644 --- a/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj +++ b/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj @@ -1,7 +1,6 @@ - net8.0 win-x64;osx-x64;linux-x64 Exe true diff --git a/src/Ryujinx.Horizon.Common/Ryujinx.Horizon.Common.csproj b/src/Ryujinx.Horizon.Common/Ryujinx.Horizon.Common.csproj index 00e0b1af9..b1caf6780 100644 --- a/src/Ryujinx.Horizon.Common/Ryujinx.Horizon.Common.csproj +++ b/src/Ryujinx.Horizon.Common/Ryujinx.Horizon.Common.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Horizon/Ryujinx.Horizon.csproj b/src/Ryujinx.Horizon/Ryujinx.Horizon.csproj index 18c639d67..727513484 100644 --- a/src/Ryujinx.Horizon/Ryujinx.Horizon.csproj +++ b/src/Ryujinx.Horizon/Ryujinx.Horizon.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Horizon/Sdk/Friends/Detail/Ipc/NotificationService.cs b/src/Ryujinx.Horizon/Sdk/Friends/Detail/Ipc/NotificationService.cs index 534bf63ed..585b40df3 100644 --- a/src/Ryujinx.Horizon/Sdk/Friends/Detail/Ipc/NotificationService.cs +++ b/src/Ryujinx.Horizon/Sdk/Friends/Detail/Ipc/NotificationService.cs @@ -4,6 +4,7 @@ using Ryujinx.Horizon.Sdk.OsTypes; using Ryujinx.Horizon.Sdk.Sf; using System; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.Horizon.Sdk.Friends.Detail.Ipc { @@ -13,7 +14,7 @@ namespace Ryujinx.Horizon.Sdk.Friends.Detail.Ipc private readonly Uid _userId; private readonly FriendsServicePermissionLevel _permissionLevel; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private SystemEventType _notificationEvent; diff --git a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ContentsReader.cs b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ContentsReader.cs index 6a0fc4f9e..d3ed37e78 100644 --- a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ContentsReader.cs +++ b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ContentsReader.cs @@ -3,6 +3,7 @@ using Ryujinx.Horizon.Sdk.Fs; using System; using System.IO; using System.IO.Compression; +using System.Threading; namespace Ryujinx.Horizon.Sdk.Ngc.Detail { @@ -22,13 +23,12 @@ namespace Ryujinx.Horizon.Sdk.Ngc.Detail } private readonly IFsClient _fsClient; - private readonly object _lock; + private readonly Lock _lock = new(); private bool _intialized; private ulong _cacheSize; public ContentsReader(IFsClient fsClient) { - _lock = new(); _fsClient = fsClient; } diff --git a/src/Ryujinx.Horizon/Sdk/OsTypes/Impl/MultiWaitImpl.cs b/src/Ryujinx.Horizon/Sdk/OsTypes/Impl/MultiWaitImpl.cs index 406352003..879a3a58f 100644 --- a/src/Ryujinx.Horizon/Sdk/OsTypes/Impl/MultiWaitImpl.cs +++ b/src/Ryujinx.Horizon/Sdk/OsTypes/Impl/MultiWaitImpl.cs @@ -2,6 +2,7 @@ using Ryujinx.Common; using Ryujinx.Horizon.Common; using System; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.Horizon.Sdk.OsTypes.Impl { @@ -13,7 +14,7 @@ namespace Ryujinx.Horizon.Sdk.OsTypes.Impl private readonly List _multiWaits; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private int _waitingThreadHandle; diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs index 7762345af..13f9fb7a9 100644 --- a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs +++ b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServerDomainManager.cs @@ -1,6 +1,7 @@ using Ryujinx.Horizon.Common; using System; using System.Collections.Generic; +using System.Threading; namespace Ryujinx.Horizon.Sdk.Sf.Cmif { @@ -209,14 +210,13 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif } private readonly EntryManager _entryManager; - private readonly object _entryOwnerLock; + private readonly Lock _entryOwnerLock = new(); private readonly HashSet _domains; private readonly int _maxDomains; public ServerDomainManager(int entryCount, int maxDomains) { _entryManager = new EntryManager(entryCount); - _entryOwnerLock = new object(); _domains = new HashSet(); _maxDomains = maxDomains; } diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManager.cs b/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManager.cs index e8957b758..6aa32faee 100644 --- a/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManager.cs +++ b/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManager.cs @@ -4,6 +4,7 @@ using Ryujinx.Horizon.Sdk.Sm; using System; using System.Collections.Generic; using System.Numerics; +using System.Threading; namespace Ryujinx.Horizon.Sdk.Sf.Hipc { @@ -17,7 +18,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc private readonly ulong _pointerBuffersBaseAddress; private readonly ulong _savedMessagesBaseAddress; - private readonly object _resourceLock; + private readonly Lock _resourceLock = new(); private readonly ulong[] _sessionAllocationBitmap; private readonly HashSet _sessions; private readonly HashSet _servers; @@ -42,7 +43,6 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc } } - _resourceLock = new object(); _sessionAllocationBitmap = new ulong[(maxSessions + 63) / 64]; _sessions = new HashSet(); _servers = new HashSet(); diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManagerBase.cs b/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManagerBase.cs index 570e3c802..31ca264e3 100644 --- a/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManagerBase.cs +++ b/src/Ryujinx.Horizon/Sdk/Sf/Hipc/ServerManagerBase.cs @@ -4,6 +4,7 @@ using Ryujinx.Horizon.Sdk.Sf.Cmif; using Ryujinx.Horizon.Sdk.Sm; using System; using System.Linq; +using System.Threading; namespace Ryujinx.Horizon.Sdk.Sf.Hipc { @@ -16,8 +17,8 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc private readonly MultiWait _multiWait; private readonly MultiWait _waitList; - private readonly object _multiWaitSelectionLock; - private readonly object _waitListLock; + private readonly Lock _multiWaitSelectionLock = new(); + private readonly Lock _waitListLock = new(); private readonly Event _requestStopEvent; private readonly Event _notifyEvent; @@ -39,9 +40,6 @@ namespace Ryujinx.Horizon.Sdk.Sf.Hipc _multiWait = new MultiWait(); _waitList = new MultiWait(); - _multiWaitSelectionLock = new object(); - _waitListLock = new object(); - _requestStopEvent = new Event(EventClearMode.ManualClear); _notifyEvent = new Event(EventClearMode.ManualClear); diff --git a/src/Ryujinx.Input.SDL2/Ryujinx.Input.SDL2.csproj b/src/Ryujinx.Input.SDL2/Ryujinx.Input.SDL2.csproj index 3d880d5fa..89f5adda1 100644 --- a/src/Ryujinx.Input.SDL2/Ryujinx.Input.SDL2.csproj +++ b/src/Ryujinx.Input.SDL2/Ryujinx.Input.SDL2.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs b/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs index af6f4c625..12bfab4bb 100644 --- a/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs +++ b/src/Ryujinx.Input.SDL2/SDL2Gamepad.cs @@ -4,6 +4,7 @@ using Ryujinx.Common.Logging; using System; using System.Collections.Generic; using System.Numerics; +using System.Threading; using static SDL2.SDL; namespace Ryujinx.Input.SDL2 @@ -58,7 +59,7 @@ namespace Ryujinx.Input.SDL2 SDL_GameControllerButton.SDL_CONTROLLER_BUTTON_INVALID, }; - private readonly object _userMappingLock = new(); + private readonly Lock _userMappingLock = new(); private readonly List _buttonsUserMapping; diff --git a/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs b/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs index fd34fe219..c580e4e7d 100644 --- a/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs +++ b/src/Ryujinx.Input.SDL2/SDL2GamepadDriver.cs @@ -1,6 +1,7 @@ using Ryujinx.SDL2.Common; using System; using System.Collections.Generic; +using System.Threading; using static SDL2.SDL; namespace Ryujinx.Input.SDL2 @@ -9,7 +10,7 @@ namespace Ryujinx.Input.SDL2 { private readonly Dictionary _gamepadsInstanceIdsMapping; private readonly List _gamepadsIds; - private readonly object _lock = new(); + private readonly Lock _lock = new(); public ReadOnlySpan GamepadsIds { diff --git a/src/Ryujinx.Input.SDL2/SDL2Keyboard.cs b/src/Ryujinx.Input.SDL2/SDL2Keyboard.cs index a0dd8ab95..8d6a30d11 100644 --- a/src/Ryujinx.Input.SDL2/SDL2Keyboard.cs +++ b/src/Ryujinx.Input.SDL2/SDL2Keyboard.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Numerics; using System.Runtime.CompilerServices; +using System.Threading; using static SDL2.SDL; using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; @@ -17,7 +18,7 @@ namespace Ryujinx.Input.SDL2 public bool IsValid => To is not GamepadButtonInputId.Unbound && From is not Key.Unbound; } - private readonly object _userMappingLock = new(); + private readonly Lock _userMappingLock = new(); #pragma warning disable IDE0052 // Remove unread private member private readonly SDL2KeyboardDriver _driver; diff --git a/src/Ryujinx.Input/HLE/NpadManager.cs b/src/Ryujinx.Input/HLE/NpadManager.cs index 1dc87358d..08f222a91 100644 --- a/src/Ryujinx.Input/HLE/NpadManager.cs +++ b/src/Ryujinx.Input/HLE/NpadManager.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Runtime.CompilerServices; +using System.Threading; using CemuHookClient = Ryujinx.Input.Motion.CemuHook.Client; using ControllerType = Ryujinx.Common.Configuration.Hid.ControllerType; using PlayerIndex = Ryujinx.HLE.HOS.Services.Hid.PlayerIndex; @@ -18,7 +19,7 @@ namespace Ryujinx.Input.HLE { private readonly CemuHookClient _cemuHookClient; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private bool _blockInputUpdates; @@ -320,7 +321,7 @@ namespace Ryujinx.Input.HLE { lock (_lock) { - return _inputConfig.Find(x => x.PlayerIndex == (Common.Configuration.Hid.PlayerIndex)index); + return _inputConfig.FirstOrDefault(x => x.PlayerIndex == (Common.Configuration.Hid.PlayerIndex)index); } } diff --git a/src/Ryujinx.Input/Ryujinx.Input.csproj b/src/Ryujinx.Input/Ryujinx.Input.csproj index 0974b707a..6741a2b3e 100644 --- a/src/Ryujinx.Input/Ryujinx.Input.csproj +++ b/src/Ryujinx.Input/Ryujinx.Input.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Memory/Ryujinx.Memory.csproj b/src/Ryujinx.Memory/Ryujinx.Memory.csproj index 17745dd61..eda3ed17f 100644 --- a/src/Ryujinx.Memory/Ryujinx.Memory.csproj +++ b/src/Ryujinx.Memory/Ryujinx.Memory.csproj @@ -1,7 +1,6 @@  - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Memory/SparseMemoryBlock.cs b/src/Ryujinx.Memory/SparseMemoryBlock.cs index 523685de1..5717d7b64 100644 --- a/src/Ryujinx.Memory/SparseMemoryBlock.cs +++ b/src/Ryujinx.Memory/SparseMemoryBlock.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Memory private readonly PageInitDelegate _pageInit; - private readonly object _lock = new object(); + private readonly Lock _lock = new(); private readonly ulong _pageSize; private readonly MemoryBlock _reservedBlock; private readonly List _mappedBlocks; diff --git a/src/Ryujinx.Memory/Tracking/RegionHandle.cs b/src/Ryujinx.Memory/Tracking/RegionHandle.cs index a94ffa43c..4e81a9723 100644 --- a/src/Ryujinx.Memory/Tracking/RegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/RegionHandle.cs @@ -51,7 +51,7 @@ namespace Ryujinx.Memory.Tracking private event Action OnDirty; - private readonly object _preActionLock = new(); + private readonly Lock _preActionLock = new(); private RegionSignal _preAction; // Action to perform before a read or write. This will block the memory access. private PreciseRegionSignal _preciseAction; // Action to perform on a precise read or write. private readonly List _regions; diff --git a/src/Ryujinx.SDL2.Common/Ryujinx.SDL2.Common.csproj b/src/Ryujinx.SDL2.Common/Ryujinx.SDL2.Common.csproj index 0811ad850..895d1a9ce 100644 --- a/src/Ryujinx.SDL2.Common/Ryujinx.SDL2.Common.csproj +++ b/src/Ryujinx.SDL2.Common/Ryujinx.SDL2.Common.csproj @@ -1,7 +1,6 @@ - net8.0 $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.SDL2.Common/SDL2Driver.cs b/src/Ryujinx.SDL2.Common/SDL2Driver.cs index 4d8961335..851c07867 100644 --- a/src/Ryujinx.SDL2.Common/SDL2Driver.cs +++ b/src/Ryujinx.SDL2.Common/SDL2Driver.cs @@ -36,7 +36,7 @@ namespace Ryujinx.SDL2.Common private ConcurrentDictionary> _registeredWindowHandlers; - private readonly object _lock = new(); + private readonly Lock _lock = new(); private SDL2Driver() { } diff --git a/src/Ryujinx.ShaderTools/Ryujinx.ShaderTools.csproj b/src/Ryujinx.ShaderTools/Ryujinx.ShaderTools.csproj index 639ceeac2..08d587f9c 100644 --- a/src/Ryujinx.ShaderTools/Ryujinx.ShaderTools.csproj +++ b/src/Ryujinx.ShaderTools/Ryujinx.ShaderTools.csproj @@ -1,7 +1,6 @@ - net8.0 Exe Debug;Release $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Tests.Memory/Ryujinx.Tests.Memory.csproj b/src/Ryujinx.Tests.Memory/Ryujinx.Tests.Memory.csproj index 3bb4bf74d..e5ebca789 100644 --- a/src/Ryujinx.Tests.Memory/Ryujinx.Tests.Memory.csproj +++ b/src/Ryujinx.Tests.Memory/Ryujinx.Tests.Memory.csproj @@ -1,7 +1,6 @@ - net8.0 false $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Tests.Unicorn/Ryujinx.Tests.Unicorn.csproj b/src/Ryujinx.Tests.Unicorn/Ryujinx.Tests.Unicorn.csproj index 2f7695356..f9f42416f 100644 --- a/src/Ryujinx.Tests.Unicorn/Ryujinx.Tests.Unicorn.csproj +++ b/src/Ryujinx.Tests.Unicorn/Ryujinx.Tests.Unicorn.csproj @@ -1,7 +1,6 @@ - net8.0 true Debug;Release $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.Tests/Ryujinx.Tests.csproj b/src/Ryujinx.Tests/Ryujinx.Tests.csproj index 0480c206e..daa2b4287 100644 --- a/src/Ryujinx.Tests/Ryujinx.Tests.csproj +++ b/src/Ryujinx.Tests/Ryujinx.Tests.csproj @@ -1,7 +1,6 @@ - net8.0 Exe false diff --git a/src/Ryujinx.UI.Common/App/ApplicationData.cs b/src/Ryujinx.UI.Common/App/ApplicationData.cs index 7aa0dccaa..151220f39 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationData.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationData.cs @@ -164,7 +164,7 @@ namespace Ryujinx.UI.App.Common NsoReader reader = new(); reader.Initialize(nsoFile.Release().AsStorage().AsFile(OpenMode.Read)).ThrowIfFailure(); - return BitConverter.ToString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", string.Empty).ToUpper()[..16]; + return Convert.ToHexString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", string.Empty).ToUpper()[..16]; } } } diff --git a/src/Ryujinx.UI.Common/Ryujinx.UI.Common.csproj b/src/Ryujinx.UI.Common/Ryujinx.UI.Common.csproj index 00b0bacac..c43f95e4a 100644 --- a/src/Ryujinx.UI.Common/Ryujinx.UI.Common.csproj +++ b/src/Ryujinx.UI.Common/Ryujinx.UI.Common.csproj @@ -1,7 +1,6 @@ - net8.0 true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx.UI.LocaleGenerator/Ryujinx.UI.LocaleGenerator.csproj b/src/Ryujinx.UI.LocaleGenerator/Ryujinx.UI.LocaleGenerator.csproj index e4e627072..49cb39713 100644 --- a/src/Ryujinx.UI.LocaleGenerator/Ryujinx.UI.LocaleGenerator.csproj +++ b/src/Ryujinx.UI.LocaleGenerator/Ryujinx.UI.LocaleGenerator.csproj @@ -3,7 +3,6 @@ netstandard2.0 enable - latest true $(DefaultItemExcludes);._* diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 65c798ac2..5872b278f 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -124,7 +124,7 @@ namespace Ryujinx.Ava private bool _dialogShown; private readonly bool _isFirmwareTitle; - private readonly object _lockObject = new(); + private readonly Lock _lockObject = new(); public event EventHandler AppExit; public event EventHandler StatusUpdatedEvent; @@ -682,13 +682,13 @@ namespace Ryujinx.Ava if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime) { if (!SetupValidator.CanStartApplication(ContentManager, ApplicationPath, out UserError userError)) - { + { if (SetupValidator.CanFixStartApplication(ContentManager, ApplicationPath, userError, out firmwareVersion)) { if (userError is UserError.NoFirmware) { UserResult result = await ContentDialogHelper.CreateConfirmationDialog( - LocaleManager.Instance[LocaleKeys.DialogFirmwareNoFirmwareInstalledMessage], + LocaleManager.Instance[LocaleKeys.DialogFirmwareNoFirmwareInstalledMessage], LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallEmbeddedMessage, firmwareVersion.VersionString), LocaleManager.Instance[LocaleKeys.InputDialogYes], LocaleManager.Instance[LocaleKeys.InputDialogNo], diff --git a/src/Ryujinx/Input/AvaloniaKeyboard.cs b/src/Ryujinx/Input/AvaloniaKeyboard.cs index 95d2936f6..0b63af2d9 100644 --- a/src/Ryujinx/Input/AvaloniaKeyboard.cs +++ b/src/Ryujinx/Input/AvaloniaKeyboard.cs @@ -4,6 +4,7 @@ using Ryujinx.Input; using System; using System.Collections.Generic; using System.Numerics; +using System.Threading; using ConfigKey = Ryujinx.Common.Configuration.Hid.Key; using Key = Ryujinx.Input.Key; @@ -15,7 +16,7 @@ namespace Ryujinx.Ava.Input private readonly AvaloniaKeyboardDriver _driver; private StandardKeyboardInputConfig _configuration; - private readonly object _userMappingLock = new(); + private readonly Lock _userMappingLock = new(); public string Id { get; } public string Name { get; } diff --git a/src/Ryujinx/Ryujinx.csproj b/src/Ryujinx/Ryujinx.csproj index 989a3a5bd..e5f6636c3 100644 --- a/src/Ryujinx/Ryujinx.csproj +++ b/src/Ryujinx/Ryujinx.csproj @@ -1,6 +1,5 @@ - net8.0 win-x64;osx-x64;linux-x64 Exe true diff --git a/src/Ryujinx/UI/ViewModels/AmiiboWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/AmiiboWindowViewModel.cs index a852d474c..ab08ce385 100644 --- a/src/Ryujinx/UI/ViewModels/AmiiboWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/AmiiboWindowViewModel.cs @@ -332,7 +332,7 @@ namespace Ryujinx.Ava.UI.ViewModels private void SelectLastScannedAmiibo() { - AmiiboApi scanned = _amiiboList.Find(amiibo => amiibo.GetId() == LastScannedAmiiboId); + AmiiboApi scanned = _amiiboList.FirstOrDefault(amiibo => amiibo.GetId() == LastScannedAmiiboId); SeriesSelectedIndex = AmiiboSeries.IndexOf(scanned.AmiiboSeries); AmiiboSelectedIndex = AmiiboList.IndexOf(scanned); @@ -393,7 +393,7 @@ namespace Ryujinx.Ava.UI.ViewModels AmiiboApi selected = _amiibos[_amiiboSelectedIndex]; - string imageUrl = _amiiboList.Find(amiibo => amiibo.Equals(selected)).Image; + string imageUrl = _amiiboList.FirstOrDefault(amiibo => amiibo.Equals(selected)).Image; StringBuilder usageStringBuilder = new(); diff --git a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs index 54f278cec..f11d6e404 100644 --- a/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/Input/InputViewModel.cs @@ -287,7 +287,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input private void LoadConfiguration(InputConfig inputConfig = null) { - Config = inputConfig ?? ConfigurationState.Instance.Hid.InputConfig.Value.Find(inputConfig => inputConfig.PlayerIndex == _playerId); + Config = inputConfig ?? ConfigurationState.Instance.Hid.InputConfig.Value.FirstOrDefault(inputConfig => inputConfig.PlayerIndex == _playerId); if (Config is StandardKeyboardInputConfig keyboardInputConfig) { @@ -597,7 +597,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input } else if (activeDevice.Type == DeviceType.Controller) { - bool isNintendoStyle = Devices.ToList().Find(x => x.Id == activeDevice.Id).Name.Contains("Nintendo"); + bool isNintendoStyle = Devices.ToList().FirstOrDefault(x => x.Id == activeDevice.Id).Name.Contains("Nintendo"); string id = activeDevice.Id.Split(" ")[0]; @@ -823,11 +823,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value); - newConfig.Remove(newConfig.Find(x => x == null)); + newConfig.Remove(newConfig.FirstOrDefault(x => x == null)); if (Device == 0) { - newConfig.Remove(newConfig.Find(x => x.PlayerIndex == this.PlayerId)); + newConfig.Remove(newConfig.FirstOrDefault(x => x.PlayerIndex == this.PlayerId)); } else { diff --git a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs index 09c8b9448..c433d7fdb 100644 --- a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs @@ -354,7 +354,7 @@ namespace Ryujinx.Ava.UI.Windows if (_launchApplicationId != null) { - applicationData = applications.Find(application => application.IdString == _launchApplicationId); + applicationData = applications.FirstOrDefault(application => application.IdString == _launchApplicationId); if (applicationData != null) { diff --git a/src/Spv.Generator/Autogenerated/CoreGrammar.cs b/src/Spv.Generator/Autogenerated/CoreGrammar.cs index 37936b8ef..9982fdfa8 100644 --- a/src/Spv.Generator/Autogenerated/CoreGrammar.cs +++ b/src/Spv.Generator/Autogenerated/CoreGrammar.cs @@ -26,6 +26,7 @@ // IN THE MATERIALS. #endregion +using System; using static Spv.Specification; namespace Spv.Generator @@ -192,7 +193,7 @@ namespace Spv.Generator return result; } - public Instruction Decorate(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction Decorate(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorate); @@ -229,7 +230,7 @@ namespace Spv.Generator return result; } - public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, params IOperand[] parameters) + public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpMemberDecorate); @@ -251,7 +252,7 @@ namespace Spv.Generator return result; } - public Instruction GroupDecorate(Instruction decorationGroup, params Instruction[] targets) + public Instruction GroupDecorate(Instruction decorationGroup, params ReadOnlySpan targets) { Instruction result = NewInstruction(Op.OpGroupDecorate); @@ -262,7 +263,7 @@ namespace Spv.Generator return result; } - public Instruction GroupMemberDecorate(Instruction decorationGroup, params IOperand[] targets) + public Instruction GroupMemberDecorate(Instruction decorationGroup, params ReadOnlySpan targets) { Instruction result = NewInstruction(Op.OpGroupMemberDecorate); @@ -273,7 +274,7 @@ namespace Spv.Generator return result; } - public Instruction DecorateId(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction DecorateId(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorateId); @@ -285,7 +286,7 @@ namespace Spv.Generator return result; } - public Instruction DecorateString(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction DecorateString(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorateString); @@ -297,7 +298,7 @@ namespace Spv.Generator return result; } - public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params IOperand[] parameters) + public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpDecorateStringGOOGLE); @@ -309,7 +310,7 @@ namespace Spv.Generator return result; } - public Instruction MemberDecorateString(Instruction structType, LiteralInteger member, Decoration decoration, params IOperand[] parameters) + public Instruction MemberDecorateString(Instruction structType, LiteralInteger member, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpMemberDecorateString); @@ -322,7 +323,7 @@ namespace Spv.Generator return result; } - public Instruction MemberDecorateStringGOOGLE(Instruction structType, LiteralInteger member, Decoration decoration, params IOperand[] parameters) + public Instruction MemberDecorateStringGOOGLE(Instruction structType, LiteralInteger member, Decoration decoration, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpMemberDecorateStringGOOGLE); @@ -458,7 +459,7 @@ namespace Spv.Generator return result; } - public Instruction TypeStruct(bool forceIdAllocation, params Instruction[] parameters) + public Instruction TypeStruct(bool forceIdAllocation, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpTypeStruct); @@ -489,7 +490,7 @@ namespace Spv.Generator return result; } - public Instruction TypeFunction(Instruction returnType, bool forceIdAllocation, params Instruction[] parameters) + public Instruction TypeFunction(Instruction returnType, bool forceIdAllocation, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpTypeFunction); @@ -605,7 +606,7 @@ namespace Spv.Generator return result; } - public Instruction ConstantComposite(Instruction resultType, params Instruction[] constituents) + public Instruction ConstantComposite(Instruction resultType, params ReadOnlySpan constituents) { Instruction result = NewInstruction(Op.OpConstantComposite, Instruction.InvalidId, resultType); @@ -664,7 +665,7 @@ namespace Spv.Generator return result; } - public Instruction SpecConstantComposite(Instruction resultType, params Instruction[] constituents) + public Instruction SpecConstantComposite(Instruction resultType, params ReadOnlySpan constituents) { Instruction result = NewInstruction(Op.OpSpecConstantComposite, GetNewId(), resultType); @@ -814,7 +815,7 @@ namespace Spv.Generator return result; } - public Instruction AccessChain(Instruction resultType, Instruction baseObj, params Instruction[] indexes) + public Instruction AccessChain(Instruction resultType, Instruction baseObj, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpAccessChain, GetNewId(), resultType); @@ -825,7 +826,7 @@ namespace Spv.Generator return result; } - public Instruction InBoundsAccessChain(Instruction resultType, Instruction baseObj, params Instruction[] indexes) + public Instruction InBoundsAccessChain(Instruction resultType, Instruction baseObj, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpInBoundsAccessChain, GetNewId(), resultType); @@ -836,7 +837,7 @@ namespace Spv.Generator return result; } - public Instruction PtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params Instruction[] indexes) + public Instruction PtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpPtrAccessChain, GetNewId(), resultType); @@ -869,7 +870,7 @@ namespace Spv.Generator return result; } - public Instruction InBoundsPtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params Instruction[] indexes) + public Instruction InBoundsPtrAccessChain(Instruction resultType, Instruction baseObj, Instruction element, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpInBoundsPtrAccessChain, GetNewId(), resultType); @@ -949,7 +950,7 @@ namespace Spv.Generator return result; } - public Instruction FunctionCall(Instruction resultType, Instruction function, params Instruction[] parameters) + public Instruction FunctionCall(Instruction resultType, Instruction function, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpFunctionCall, GetNewId(), resultType); @@ -973,7 +974,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleImplicitLod, GetNewId(), resultType); @@ -992,7 +993,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleExplicitLod, GetNewId(), resultType); @@ -1008,7 +1009,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleDrefImplicitLod, GetNewId(), resultType); @@ -1028,7 +1029,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleDrefExplicitLod, GetNewId(), resultType); @@ -1045,7 +1046,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjImplicitLod, GetNewId(), resultType); @@ -1064,7 +1065,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjExplicitLod, GetNewId(), resultType); @@ -1080,7 +1081,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjDrefImplicitLod, GetNewId(), resultType); @@ -1100,7 +1101,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleProjDrefExplicitLod, GetNewId(), resultType); @@ -1117,7 +1118,7 @@ namespace Spv.Generator return result; } - public Instruction ImageFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageFetch, GetNewId(), resultType); @@ -1136,7 +1137,7 @@ namespace Spv.Generator return result; } - public Instruction ImageGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageGather, GetNewId(), resultType); @@ -1156,7 +1157,7 @@ namespace Spv.Generator return result; } - public Instruction ImageDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageDrefGather, GetNewId(), resultType); @@ -1176,7 +1177,7 @@ namespace Spv.Generator return result; } - public Instruction ImageRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageRead, GetNewId(), resultType); @@ -1195,7 +1196,7 @@ namespace Spv.Generator return result; } - public Instruction ImageWrite(Instruction image, Instruction coordinate, Instruction texel, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageWrite(Instruction image, Instruction coordinate, Instruction texel, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageWrite); @@ -1297,7 +1298,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleImplicitLod, GetNewId(), resultType); @@ -1316,7 +1317,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleExplicitLod, GetNewId(), resultType); @@ -1332,7 +1333,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleDrefImplicitLod, GetNewId(), resultType); @@ -1352,7 +1353,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleDrefExplicitLod, GetNewId(), resultType); @@ -1369,7 +1370,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjImplicitLod, GetNewId(), resultType); @@ -1388,7 +1389,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjExplicitLod, GetNewId(), resultType); @@ -1404,7 +1405,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjDrefImplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefImplicitLod, GetNewId(), resultType); @@ -1424,7 +1425,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseSampleProjDrefExplicitLod(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseSampleProjDrefExplicitLod, GetNewId(), resultType); @@ -1441,7 +1442,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseFetch(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseFetch, GetNewId(), resultType); @@ -1460,7 +1461,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction component, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseGather, GetNewId(), resultType); @@ -1480,7 +1481,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseDrefGather(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction dRef, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseDrefGather, GetNewId(), resultType); @@ -1510,7 +1511,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSparseRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSparseRead(Instruction resultType, Instruction image, Instruction coordinate, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSparseRead, GetNewId(), resultType); @@ -1529,7 +1530,7 @@ namespace Spv.Generator return result; } - public Instruction ImageSampleFootprintNV(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction granularity, Instruction coarse, ImageOperandsMask imageOperands, params Instruction[] imageOperandIds) + public Instruction ImageSampleFootprintNV(Instruction resultType, Instruction sampledImage, Instruction coordinate, Instruction granularity, Instruction coarse, ImageOperandsMask imageOperands, params ReadOnlySpan imageOperandIds) { Instruction result = NewInstruction(Op.OpImageSampleFootprintNV, GetNewId(), resultType); @@ -1738,7 +1739,7 @@ namespace Spv.Generator return result; } - public Instruction VectorShuffle(Instruction resultType, Instruction vector1, Instruction vector2, params LiteralInteger[] components) + public Instruction VectorShuffle(Instruction resultType, Instruction vector1, Instruction vector2, params ReadOnlySpan components) { Instruction result = NewInstruction(Op.OpVectorShuffle, GetNewId(), resultType); @@ -1750,7 +1751,7 @@ namespace Spv.Generator return result; } - public Instruction CompositeConstruct(Instruction resultType, params Instruction[] constituents) + public Instruction CompositeConstruct(Instruction resultType, params ReadOnlySpan constituents) { Instruction result = NewInstruction(Op.OpCompositeConstruct, GetNewId(), resultType); @@ -1760,7 +1761,7 @@ namespace Spv.Generator return result; } - public Instruction CompositeExtract(Instruction resultType, Instruction composite, params LiteralInteger[] indexes) + public Instruction CompositeExtract(Instruction resultType, Instruction composite, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpCompositeExtract, GetNewId(), resultType); @@ -1771,7 +1772,7 @@ namespace Spv.Generator return result; } - public Instruction CompositeInsert(Instruction resultType, Instruction obj, Instruction composite, params LiteralInteger[] indexes) + public Instruction CompositeInsert(Instruction resultType, Instruction obj, Instruction composite, params ReadOnlySpan indexes) { Instruction result = NewInstruction(Op.OpCompositeInsert, GetNewId(), resultType); @@ -2752,7 +2753,7 @@ namespace Spv.Generator // Control-Flow - public Instruction Phi(Instruction resultType, params Instruction[] parameters) + public Instruction Phi(Instruction resultType, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpPhi, GetNewId(), resultType); @@ -2802,7 +2803,7 @@ namespace Spv.Generator return result; } - public Instruction BranchConditional(Instruction condition, Instruction trueLabel, Instruction falseLabel, params LiteralInteger[] branchweights) + public Instruction BranchConditional(Instruction condition, Instruction trueLabel, Instruction falseLabel, params ReadOnlySpan branchweights) { Instruction result = NewInstruction(Op.OpBranchConditional); @@ -2815,7 +2816,7 @@ namespace Spv.Generator return result; } - public Instruction Switch(Instruction selector, Instruction defaultObj, params IOperand[] target) + public Instruction Switch(Instruction selector, Instruction defaultObj, params ReadOnlySpan target) { Instruction result = NewInstruction(Op.OpSwitch); @@ -3678,7 +3679,7 @@ namespace Spv.Generator return result; } - public Instruction EnqueueKernel(Instruction resultType, Instruction queue, Instruction flags, Instruction nDRange, Instruction numEvents, Instruction waitEvents, Instruction retEvent, Instruction invoke, Instruction param, Instruction paramSize, Instruction paramAlign, params Instruction[] localSize) + public Instruction EnqueueKernel(Instruction resultType, Instruction queue, Instruction flags, Instruction nDRange, Instruction numEvents, Instruction waitEvents, Instruction retEvent, Instruction invoke, Instruction param, Instruction paramSize, Instruction paramAlign, params ReadOnlySpan localSize) { Instruction result = NewInstruction(Op.OpEnqueueKernel, GetNewId(), resultType); @@ -5108,7 +5109,7 @@ namespace Spv.Generator return result; } - public Instruction LoopControlINTEL(params LiteralInteger[] loopControlParameters) + public Instruction LoopControlINTEL(params ReadOnlySpan loopControlParameters) { Instruction result = NewInstruction(Op.OpLoopControlINTEL); diff --git a/src/Spv.Generator/Instruction.cs b/src/Spv.Generator/Instruction.cs index 45492033f..741b30d6d 100644 --- a/src/Spv.Generator/Instruction.cs +++ b/src/Spv.Generator/Instruction.cs @@ -64,7 +64,7 @@ namespace Spv.Generator _operands.Add(value); } - public void AddOperand(IOperand[] value) + public void AddOperand(ReadOnlySpan value) { foreach (IOperand instruction in value) { @@ -72,7 +72,7 @@ namespace Spv.Generator } } - public void AddOperand(LiteralInteger[] value) + public void AddOperand(ReadOnlySpan value) { foreach (LiteralInteger instruction in value) { @@ -85,7 +85,7 @@ namespace Spv.Generator AddOperand((IOperand)value); } - public void AddOperand(Instruction[] value) + public void AddOperand(ReadOnlySpan value) { foreach (Instruction instruction in value) { diff --git a/src/Spv.Generator/Module.cs b/src/Spv.Generator/Module.cs index fb02cc966..fdcd62752 100644 --- a/src/Spv.Generator/Module.cs +++ b/src/Spv.Generator/Module.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -132,7 +133,7 @@ namespace Spv.Generator _typeDeclarationsList.Add(instruction); } - public void AddEntryPoint(ExecutionModel executionModel, Instruction function, string name, params Instruction[] interfaces) + public void AddEntryPoint(ExecutionModel executionModel, Instruction function, string name, params ReadOnlySpan interfaces) { Debug.Assert(function.Opcode == Op.OpFunction); @@ -146,7 +147,7 @@ namespace Spv.Generator _entrypoints.Add(entryPoint); } - public void AddExecutionMode(Instruction function, ExecutionMode mode, params IOperand[] parameters) + public void AddExecutionMode(Instruction function, ExecutionMode mode, params ReadOnlySpan parameters) { Debug.Assert(function.Opcode == Op.OpFunction); @@ -228,7 +229,7 @@ namespace Spv.Generator _constants.Add(key, constant); } - public Instruction ExtInst(Instruction resultType, Instruction set, LiteralInteger instruction, params IOperand[] parameters) + public Instruction ExtInst(Instruction resultType, Instruction set, LiteralInteger instruction, params ReadOnlySpan parameters) { Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType); @@ -247,7 +248,7 @@ namespace Spv.Generator } // TODO: Find a way to make the auto generate one used. - public Instruction OpenClPrintf(Instruction resultType, Instruction format, params Instruction[] additionalarguments) + public Instruction OpenClPrintf(Instruction resultType, Instruction format, params ReadOnlySpan additionalarguments) { Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType); diff --git a/src/Spv.Generator/Spv.Generator.csproj b/src/Spv.Generator/Spv.Generator.csproj index 5dec0b64e..3642709d8 100644 --- a/src/Spv.Generator/Spv.Generator.csproj +++ b/src/Spv.Generator/Spv.Generator.csproj @@ -1,7 +1,6 @@  - net8.0 $(DefaultItemExcludes);._*