diff --git a/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs b/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs index 7fe683e64..8b135afab 100644 --- a/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs +++ b/src/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs @@ -146,9 +146,9 @@ namespace ARMeilleure.CodeGen.RegisterAllocators } } - private Queue _fillQueue; - private Queue _spillQueue; - private ParallelCopy _parallelCopy; + private Queue _fillQueue = null; + private Queue _spillQueue = null; + private ParallelCopy _parallelCopy = null; public bool HasCopy { get; private set; } diff --git a/src/ARMeilleure/Instructions/MathHelper.cs b/src/ARMeilleure/Instructions/MathHelper.cs index a11ce9d2e..acf9a5028 100644 --- a/src/ARMeilleure/Instructions/MathHelper.cs +++ b/src/ARMeilleure/Instructions/MathHelper.cs @@ -1,5 +1,9 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; namespace ARMeilleure.Instructions { diff --git a/src/ARMeilleure/Optimizations.cs b/src/ARMeilleure/Optimizations.cs index ac6510143..0536302e8 100644 --- a/src/ARMeilleure/Optimizations.cs +++ b/src/ARMeilleure/Optimizations.cs @@ -1,7 +1,7 @@ namespace ARMeilleure { - using Arm64HardwareCapabilities = CodeGen.Arm64.HardwareCapabilities; - using X86HardwareCapabilities = CodeGen.X86.HardwareCapabilities; + using Arm64HardwareCapabilities = ARMeilleure.CodeGen.Arm64.HardwareCapabilities; + using X86HardwareCapabilities = ARMeilleure.CodeGen.X86.HardwareCapabilities; public static class Optimizations { diff --git a/src/ARMeilleure/State/NativeContext.cs b/src/ARMeilleure/State/NativeContext.cs index 08c2248a6..f84cb5080 100644 --- a/src/ARMeilleure/State/NativeContext.cs +++ b/src/ARMeilleure/State/NativeContext.cs @@ -24,7 +24,7 @@ namespace ARMeilleure.State public long Tpidr2El0; } - private static NativeCtxStorage _dummyStorage; + private static NativeCtxStorage _dummyStorage = new(); private readonly IJitMemoryBlock _block; diff --git a/src/ARMeilleure/Translation/ArmEmitterContext.cs b/src/ARMeilleure/Translation/ArmEmitterContext.cs index 813fc2745..41a2cf995 100644 --- a/src/ARMeilleure/Translation/ArmEmitterContext.cs +++ b/src/ARMeilleure/Translation/ArmEmitterContext.cs @@ -54,7 +54,7 @@ namespace ARMeilleure.Translation public bool HasPtc { get; } public Aarch32Mode Mode { get; } - private int _ifThenBlockStateIndex; + private int _ifThenBlockStateIndex = 0; private Condition[] _ifThenBlockState = []; public bool IsInIfThenBlock => _ifThenBlockStateIndex < _ifThenBlockState.Length; public Condition CurrentIfThenBlockCond => _ifThenBlockState[_ifThenBlockStateIndex]; diff --git a/src/ARMeilleure/Translation/Cache/CacheEntry.cs b/src/ARMeilleure/Translation/Cache/CacheEntry.cs index 5b1a27355..25b06f781 100644 --- a/src/ARMeilleure/Translation/Cache/CacheEntry.cs +++ b/src/ARMeilleure/Translation/Cache/CacheEntry.cs @@ -18,7 +18,7 @@ namespace ARMeilleure.Translation.Cache UnwindInfo = unwindInfo; } - public int CompareTo(CacheEntry other) + public int CompareTo([AllowNull] CacheEntry other) { return Offset.CompareTo(other.Offset); } diff --git a/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs b/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs index c72a0f398..9c5ca29df 100644 --- a/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs +++ b/src/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs @@ -17,7 +17,7 @@ namespace ARMeilleure.Translation.Cache Size = size; } - public int CompareTo(MemoryBlock other) + public int CompareTo([AllowNull] MemoryBlock other) { return Offset.CompareTo(other.Offset); } diff --git a/src/ARMeilleure/Translation/Cache/JitCache.cs b/src/ARMeilleure/Translation/Cache/JitCache.cs index 49bce5bbe..faccdabbe 100644 --- a/src/ARMeilleure/Translation/Cache/JitCache.cs +++ b/src/ARMeilleure/Translation/Cache/JitCache.cs @@ -32,7 +32,7 @@ namespace ARMeilleure.Translation.Cache private static bool _initialized; private static readonly List _jitRegions = []; - private static int _activeRegionIndex; + private static int _activeRegionIndex = 0; [SupportedOSPlatform("windows")] [LibraryImport("kernel32.dll", SetLastError = true)] diff --git a/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs b/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs index 3aee406cc..ef54b32f8 100644 --- a/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs +++ b/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs @@ -79,7 +79,7 @@ namespace ARMeilleure.Translation.Cache _unwindInfo = (UnwindInfo*)(workBufferPtr + _sizeOfRuntimeFunction); - _getRuntimeFunctionCallback = FunctionTableHandler; + _getRuntimeFunctionCallback = new GetRuntimeFunctionCallback(FunctionTableHandler); result = RtlInstallFunctionTableCallback( codeCachePtr | 3, @@ -102,7 +102,10 @@ namespace ARMeilleure.Translation.Cache bool result; - result = RtlDeleteFunctionTable(codeCachePtr | 3); + unsafe + { + result = RtlDeleteFunctionTable(codeCachePtr | 3); + } if (!result) { diff --git a/src/ARMeilleure/Translation/Delegates.cs b/src/ARMeilleure/Translation/Delegates.cs index 5d2c39e04..9877c57b1 100644 --- a/src/ARMeilleure/Translation/Delegates.cs +++ b/src/ARMeilleure/Translation/Delegates.cs @@ -63,7 +63,7 @@ namespace ARMeilleure.Translation private static readonly SortedList _delegates; - static Delegates() + unsafe static Delegates() { _delegates = new SortedList(); diff --git a/src/ARMeilleure/Translation/IntervalTree.cs b/src/ARMeilleure/Translation/IntervalTree.cs index ad2c44e88..2fa431a8b 100644 --- a/src/ARMeilleure/Translation/IntervalTree.cs +++ b/src/ARMeilleure/Translation/IntervalTree.cs @@ -14,8 +14,8 @@ namespace ARMeilleure.Translation private const bool Black = true; private const bool Red = false; - private IntervalTreeNode _root; - private int _count; + private IntervalTreeNode _root = null; + private int _count = 0; public int Count => _count; @@ -709,9 +709,9 @@ namespace ARMeilleure.Translation class IntervalTreeNode { public bool Color = true; - public IntervalTreeNode Left; - public IntervalTreeNode Right; - public IntervalTreeNode Parent; + public IntervalTreeNode Left = null; + public IntervalTreeNode Right = null; + public IntervalTreeNode Parent = null; /// /// The start of the range. diff --git a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs index 2ac085e77..4148ea0dd 100644 --- a/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs +++ b/src/Ryujinx.Audio.Backends.SoundIo/Native/SoundIoOutStreamContext.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native public class SoundIoOutStreamContext : IDisposable { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax); + private unsafe delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax); private IntPtr _context; private IntPtr _nameStored; diff --git a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs index dcdf32de2..1a46d41fd 100644 --- a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs +++ b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs @@ -127,21 +127,24 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter { get { - if (Unsafe.IsNullRef(ref _v2)) + unsafe { - if (Unsafe.IsNullRef(ref _v1)) + if (Unsafe.IsNullRef(ref _v2)) { - return new SplitterDestination(); + if (Unsafe.IsNullRef(ref _v1)) + { + return new SplitterDestination(); + } + else + { + return new SplitterDestination(ref _v1.Next); + } } else { - return new SplitterDestination(ref _v1.Next); + return new SplitterDestination(ref _v2.Next); } } - else - { - return new SplitterDestination(ref _v2.Next); - } } } diff --git a/src/Ryujinx.Common/Memory/ArrayPtr.cs b/src/Ryujinx.Common/Memory/ArrayPtr.cs index 3608dac59..7487a1ff5 100644 --- a/src/Ryujinx.Common/Memory/ArrayPtr.cs +++ b/src/Ryujinx.Common/Memory/ArrayPtr.cs @@ -100,7 +100,7 @@ namespace Ryujinx.Common.Memory return obj is ArrayPtr other && Equals(other); } - public readonly bool Equals(ArrayPtr other) + public readonly bool Equals([AllowNull] ArrayPtr other) { return _ptr == other._ptr && Length == other.Length; } diff --git a/src/Ryujinx.Common/Memory/Ptr.cs b/src/Ryujinx.Common/Memory/Ptr.cs index 5315eaae2..d01748c16 100644 --- a/src/Ryujinx.Common/Memory/Ptr.cs +++ b/src/Ryujinx.Common/Memory/Ptr.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Common.Memory return obj is Ptr other && Equals(other); } - public readonly bool Equals(Ptr other) + public readonly bool Equals([AllowNull] Ptr other) { return _ptr == other._ptr; } diff --git a/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs b/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs index d774f4851..4399ea39d 100644 --- a/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs +++ b/src/Ryujinx.Common/Utilities/XCIFileTrimmer.cs @@ -90,8 +90,8 @@ namespace Ryujinx.Common.Utilities private BinaryReader _binaryReader; private long _offsetB, _dataSizeB, _cartSizeB, _fileSizeB; private bool _fileOK = true; - private bool _freeSpaceChecked; - private bool _freeSpaceValid; + private bool _freeSpaceChecked = false; + private bool _freeSpaceValid = false; public enum OperationOutcome { @@ -191,7 +191,7 @@ namespace Ryujinx.Common.Utilities if (timedSw.Elapsed.TotalSeconds > 0) { - Log?.Write(LogType.Info, $"Checked at {readSizeB / (double)BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); + Log?.Write(LogType.Info, $"Checked at {readSizeB / (double)XCIFileTrimmer.BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); } if (freeSpaceValid) @@ -219,7 +219,7 @@ namespace Ryujinx.Common.Utilities private bool CheckPadding(long readSizeB, CancellationToken? cancelToken = null) { - long maxReads = readSizeB / BufferSize; + long maxReads = readSizeB / XCIFileTrimmer.BufferSize; long read = 0; var buffer = new byte[BufferSize]; @@ -230,12 +230,12 @@ namespace Ryujinx.Common.Utilities return false; } - int bytes = _fileStream.Read(buffer, 0, BufferSize); + int bytes = _fileStream.Read(buffer, 0, XCIFileTrimmer.BufferSize); if (bytes == 0) break; Log?.Progress(read, maxReads, "Verifying file can be trimmed", false); - if (buffer.Take(bytes).AsParallel().Any(b => b != PaddingByte)) + if (buffer.Take(bytes).AsParallel().Any(b => b != XCIFileTrimmer.PaddingByte)) { Log?.Write(LogType.Warn, "Free space is NOT valid"); return false; @@ -380,7 +380,7 @@ namespace Ryujinx.Common.Utilities if (timedSw.Elapsed.TotalSeconds > 0) { - Log?.Write(LogType.Info, $"Wrote at {bytesToWriteB / (double)BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); + Log?.Write(LogType.Info, $"Wrote at {bytesToWriteB / (double)XCIFileTrimmer.BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); } if (cancelToken.HasValue && cancelToken.Value.IsCancellationRequested) @@ -408,13 +408,13 @@ namespace Ryujinx.Common.Utilities private void WritePadding(FileStream outfileStream, long bytesToWriteB, CancellationToken? cancelToken = null) { long bytesLeftToWriteB = bytesToWriteB; - long writes = bytesLeftToWriteB / BufferSize; + long writes = bytesLeftToWriteB / XCIFileTrimmer.BufferSize; int write = 0; try { var buffer = new byte[BufferSize]; - Array.Fill(buffer, PaddingByte); + Array.Fill(buffer, XCIFileTrimmer.PaddingByte); while (bytesLeftToWriteB > 0) { @@ -423,7 +423,7 @@ namespace Ryujinx.Common.Utilities return; } - long bytesToWrite = Math.Min(BufferSize, bytesLeftToWriteB); + long bytesToWrite = Math.Min(XCIFileTrimmer.BufferSize, bytesLeftToWriteB); #if !XCI_TRIMMER_READ_ONLY_MODE outfileStream.Write(buffer, 0, (int)bytesToWrite); @@ -504,12 +504,12 @@ namespace Ryujinx.Common.Utilities } // Setup offset - _offsetB = (long)(assumeKeyArea ? CartKeyAreaSize : 0); + _offsetB = (long)(assumeKeyArea ? XCIFileTrimmer.CartKeyAreaSize : 0); // Check header - Pos = _offsetB + HeaderFilePos; + Pos = _offsetB + XCIFileTrimmer.HeaderFilePos; string head = System.Text.Encoding.ASCII.GetString(_binaryReader.ReadBytes(4)); - if (head != HeaderMagicValue) + if (head != XCIFileTrimmer.HeaderMagicValue) { if (!assumeKeyArea) { @@ -524,17 +524,17 @@ namespace Ryujinx.Common.Utilities } // Read Cart Size - Pos = _offsetB + CartSizeFilePos; + Pos = _offsetB + XCIFileTrimmer.CartSizeFilePos; byte cartSizeId = _binaryReader.ReadByte(); if (!_cartSizesGB.TryGetValue(cartSizeId, out long cartSizeNGB)) { Log?.Write(LogType.Error, $"The source file doesn't look like an XCI file as the Cartridge Size is incorrect (0x{cartSizeId:X2})"); return false; } - _cartSizeB = cartSizeNGB * CartSizeMBinFormattedGB * BytesInAMegabyte; + _cartSizeB = cartSizeNGB * XCIFileTrimmer.CartSizeMBinFormattedGB * XCIFileTrimmer.BytesInAMegabyte; // Read data size - Pos = _offsetB + DataSizeFilePos; + Pos = _offsetB + XCIFileTrimmer.DataSizeFilePos; long records = (long)BitConverter.ToUInt32(_binaryReader.ReadBytes(4), 0); _dataSizeB = RecordsToByte(records); diff --git a/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs b/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs index 65b79c39c..86936c592 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvMemoryBlockAllocator.cs @@ -4,8 +4,7 @@ using System.Runtime.Versioning; namespace Ryujinx.Cpu.AppleHv { [SupportedOSPlatform("macos")] - class HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) - : PrivateMemoryAllocatorImpl(blockAlignment, MemoryAllocationFlags.None) + class HvMemoryBlockAllocator : PrivateMemoryAllocatorImpl { public class Block : PrivateMemoryAllocator.Block { @@ -37,6 +36,13 @@ namespace Ryujinx.Cpu.AppleHv } } + private readonly HvIpaAllocator _ipaAllocator; + + public HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) : base(blockAlignment, MemoryAllocationFlags.None) + { + _ipaAllocator = ipaAllocator; + } + public HvMemoryBlockAllocation Allocate(ulong size, ulong alignment) { var allocation = Allocate(size, alignment, CreateBlock); @@ -46,7 +52,7 @@ namespace Ryujinx.Cpu.AppleHv private Block CreateBlock(MemoryBlock memory, ulong size) { - return new Block(ipaAllocator, memory, size); + return new Block(_ipaAllocator, memory, size); } } } diff --git a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs index c58e87d44..aae21ae5d 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvMemoryManager.cs @@ -5,6 +5,7 @@ using Ryujinx.Memory.Tracking; using System; using System.Buffers; using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.Versioning; diff --git a/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs b/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs index 1b7b96b0f..ee91c478b 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvVcpu.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.AppleHv { private const ulong InterruptIntervalNs = 16 * 1000000; // 16 ms - private static ulong _interruptTimeDeltaTicks; + private static ulong _interruptTimeDeltaTicks = 0; public readonly ulong Handle; public readonly HvVcpuExit* ExitInfo; diff --git a/src/Ryujinx.Cpu/Jit/MemoryManager.cs b/src/Ryujinx.Cpu/Jit/MemoryManager.cs index 8d41be736..fdfb18683 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManager.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManager.cs @@ -5,6 +5,7 @@ using Ryujinx.Memory.Tracking; using System; using System.Buffers; using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; diff --git a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs index 2849a03d8..95200a7dc 100644 --- a/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs +++ b/src/Ryujinx.Cpu/Jit/MemoryManagerHostTracked.cs @@ -8,6 +8,7 @@ using Ryujinx.Memory.Tracking; using System; using System.Buffers; using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; namespace Ryujinx.Cpu.Jit diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs b/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs index 7264190da..0249e24b8 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/CacheEntry.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache Size = size; } - public int CompareTo(CacheEntry other) + public int CompareTo([AllowNull] CacheEntry other) { return Offset.CompareTo(other.Offset); } diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs b/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs index b43093cb5..05c889922 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/CacheMemoryAllocator.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache Size = size; } - public int CompareTo(MemoryBlock other) + public int CompareTo([AllowNull] MemoryBlock other) { return Offset.CompareTo(other.Offset); } diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs index 653035e50..26bb50bef 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/JitCache.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache private static readonly Lock _lock = new(); private static bool _initialized; private static readonly List _jitRegions = []; - private static int _activeRegionIndex; + private static int _activeRegionIndex = 0; [SupportedOSPlatform("windows")] [LibraryImport("kernel32.dll", SetLastError = true)] @@ -75,9 +75,12 @@ namespace Ryujinx.Cpu.LightningJit.Cache if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64) { - fixed (byte* codePtr = code) + unsafe { - JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length); + fixed (byte* codePtr = code) + { + JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length); + } } } else diff --git a/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs b/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs index 8012fa915..dd53dcbf7 100644 --- a/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs +++ b/src/Ryujinx.Cpu/LightningJit/Cache/PageAlignedRangeList.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache Size = size; } - public int CompareTo(Range other) + public int CompareTo([AllowNull] Range other) { return Offset.CompareTo(other.Offset); } diff --git a/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs b/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs index 968684177..fdb8793de 100644 --- a/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs +++ b/src/Ryujinx.Cpu/LightningJit/State/NativeContext.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Cpu.LightningJit.State public int Running; } - private static NativeCtxStorage _dummyStorage; + private static NativeCtxStorage _dummyStorage = new(); private readonly IJitMemoryBlock _block; @@ -79,22 +79,22 @@ namespace Ryujinx.Cpu.LightningJit.State GetStorage().V[index * 2 + 1] = value.Extract(1); } - public uint GetPstate() + public unsafe uint GetPstate() { return GetStorage().Flags; } - public void SetPstate(uint value) + public unsafe void SetPstate(uint value) { GetStorage().Flags = value; } - public uint GetFPState(uint mask = uint.MaxValue) + public unsafe uint GetFPState(uint mask = uint.MaxValue) { return GetStorage().FpFlags & mask; } - public void SetFPState(uint value, uint mask = uint.MaxValue) + public unsafe void SetFPState(uint value, uint mask = uint.MaxValue) { GetStorage().FpFlags = (value & mask) | (GetStorage().FpFlags & ~mask); } diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs b/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs index 00a6a2e3f..48bec3633 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/BufferMap.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading /// class BufferMap { - private ulong _bufferHandle; + private ulong _bufferHandle = 0; private readonly Dictionary _bufferMap = new(); private readonly HashSet _inFlight = []; diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs index 8a23f4d88..6375d290c 100644 --- a/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs +++ b/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs @@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading private int _refProducerPtr; private int _refConsumerPtr; - public uint ProgramCount { get; set; } + public uint ProgramCount { get; set; } = 0; private Action _interruptAction; private readonly Lock _interruptLock = new(); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs index 802035ff4..475d1ee4e 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs @@ -506,7 +506,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME maxDrawCount, stride, indexCount, - IndirectDrawType.DrawIndexedIndirectCount); + Threed.IndirectDrawType.DrawIndexedIndirectCount); } /// diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs index 5d420a140..c2276480b 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs @@ -1,5 +1,6 @@ using Ryujinx.Common; using Ryujinx.Graphics.GAL; +using System; using System.Collections.Generic; namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs index b7fffac64..2095fcd7a 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs @@ -15,10 +15,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed // State associated with direct uniform buffer updates. // This state is used to attempt to batch together consecutive updates. - private ulong _ubBeginCpuAddress; - private ulong _ubFollowUpAddress; - private ulong _ubByteCount; - private int _ubIndex; + private ulong _ubBeginCpuAddress = 0; + private ulong _ubFollowUpAddress = 0; + private ulong _ubByteCount = 0; + private int _ubIndex = 0; private readonly int[] _ubData = new int[UniformDataCacheSize]; /// diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs index 357e5d9d3..5f23b5b1a 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs @@ -4,6 +4,7 @@ using Ryujinx.Graphics.Gpu.Memory; using Ryujinx.Graphics.Shader; using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Gpu.Image diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index bc28675e9..a9444daa4 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -60,13 +60,13 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// This is null until at least one modification occurs. /// - private BufferModifiedRangeList _modifiedRanges; + private BufferModifiedRangeList _modifiedRanges = null; /// /// A structure that is used to flush buffer data back to a host mapped buffer for cached readback. /// Only used if the buffer data is explicitly owned by device local memory. /// - private BufferPreFlush _preFlush; + private BufferPreFlush _preFlush = null; /// /// Usage tracking state that determines what type of backing the buffer should use. @@ -171,9 +171,9 @@ namespace Ryujinx.Graphics.Gpu.Memory _memoryTracking.RegisterPreciseAction(PreciseAction); } - _externalFlushDelegate = ExternalFlush; - _loadDelegate = LoadRegion; - _modifiedDelegate = RegionModified; + _externalFlushDelegate = new RegionSignal(ExternalFlush); + _loadDelegate = new Action(LoadRegion); + _modifiedDelegate = new Action(RegionModified); _virtualDependenciesLock = new ReaderWriterLockSlim(); } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs index 789fe504a..86de37876 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/MultiRangeBuffer.cs @@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Gpu.Memory } private List _dependencies; - private BufferModifiedRangeList _modifiedRanges; + private BufferModifiedRangeList _modifiedRanges = null; /// /// Creates a new instance of the buffer. diff --git a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs index 805bce37a..e0396006d 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderBindings.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Gpu.Engine; using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Shader; +using System; using System.Linq; namespace Ryujinx.Graphics.Gpu.Shader diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs index 090e198ae..0767cc9d6 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg { unsafe class FFmpegContext : IDisposable { - private delegate int AVCodec_decode(AVCodecContext* avctx, void* outdata, int* got_frame_ptr, AVPacket* avpkt); + private unsafe delegate int AVCodec_decode(AVCodecContext* avctx, void* outdata, int* got_frame_ptr, AVPacket* avpkt); private readonly AVCodec_decode _decodeFrame; private static readonly FFmpegApi.av_log_set_callback_callback _logFunc; diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs index cad042556..0267000c8 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native public IntPtr SampleFmts; // Deprecated public unsafe ulong* ChannelLayouts; - public IntPtr PrivClass; + public unsafe IntPtr PrivClass; public IntPtr Profiles; public unsafe byte* WrapperName; public IntPtr ChLayouts; diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs index 162942628..9084f4024 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodec501.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native public IntPtr SampleFmts; // Deprecated public unsafe ulong* ChannelLayouts; - public IntPtr PrivClass; + public unsafe IntPtr PrivClass; public IntPtr Profiles; public unsafe byte* WrapperName; #pragma warning restore CS0649 diff --git a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs index 857fa99b5..c743ab33e 100644 --- a/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs +++ b/src/Ryujinx.Graphics.Nvdec.FFmpeg/Native/AVCodecContext.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native struct AVCodecContext { #pragma warning disable CS0649 // Field is never assigned to - public IntPtr AvClass; + public unsafe IntPtr AvClass; public int LogLevelOffset; public int CodecType; public unsafe AVCodec* Codec; diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs index f4239d374..fdd48a23d 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Decoder.cs @@ -281,7 +281,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types Array8 frameSizes = new(); int frameCount = 0; - res = Decoder.ParseSuperframeIndex(data, (ulong)data.Length, ref frameSizes, out frameCount); + res = Types.Decoder.ParseSuperframeIndex(data, (ulong)data.Length, ref frameSizes, out frameCount); if (res != CodecErr.Ok) { return res; @@ -322,7 +322,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types // Account for suboptimal termination by the encoder. while (dataStart.Length != 0) { - byte marker = Decoder.ReadMarker(dataStart); + byte marker = Types.Decoder.ReadMarker(dataStart); if (marker != 0) { break; diff --git a/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs b/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs index cff89a6d6..5ed508647 100644 --- a/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Nvdec { private static readonly Decoder _decoder = new(); - public static void Decode(ResourceManager rm, ref NvdecRegisters state) + public unsafe static void Decode(ResourceManager rm, ref NvdecRegisters state) { PictureInfo pictureInfo = rm.MemoryManager.DeviceRead(state.SetDrvPicSetupOffset); EntropyProbs entropy = rm.MemoryManager.DeviceRead(state.Vp9SetProbTabBufOffset); diff --git a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs index 8bd6df6d1..f22e0df57 100644 --- a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs +++ b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs @@ -5,7 +5,7 @@ using System.Threading; namespace Ryujinx.Graphics.OpenGL { - class BackgroundContextWorker : IDisposable + unsafe class BackgroundContextWorker : IDisposable { [ThreadStatic] public static bool InBackground; diff --git a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs index bc3a76b2c..d58326367 100644 --- a/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs +++ b/src/Ryujinx.Graphics.OpenGL/Effects/SmaaPostProcessingEffect.cs @@ -6,7 +6,7 @@ using System; namespace Ryujinx.Graphics.OpenGL.Effects.Smaa { - internal class SmaaPostProcessingEffect : IPostProcessingEffect + internal partial class SmaaPostProcessingEffect : IPostProcessingEffect { public const int AreaWidth = 160; public const int AreaHeight = 560; @@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa } } - private void RecreateShaders(int width, int height) + private unsafe void RecreateShaders(int width, int height) { string baseShader = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa.hlsl"); var pixelSizeDefine = $"#define SMAA_RT_METRICS float4(1.0 / {width}.0, 1.0 / {height}.0, {width}, {height}) \n"; diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index 725e6e06e..c241379c4 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.OpenGL private readonly Sync _sync; - public uint ProgramCount { get; set; } + public uint ProgramCount { get; set; } = 0; public event EventHandler ScreenCaptured; diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs index 78b94342c..889517480 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries private readonly CounterQueue _queue; private readonly BufferedQuery _counter; - private bool _hostAccessReserved; + private bool _hostAccessReserved = false; private int _refCount = 1; // Starts with a reference from the counter queue. private readonly Lock _lock = new(); diff --git a/src/Ryujinx.Graphics.OpenGL/Sync.cs b/src/Ryujinx.Graphics.OpenGL/Sync.cs index 5f646592b..dd9a9b3ec 100644 --- a/src/Ryujinx.Graphics.OpenGL/Sync.cs +++ b/src/Ryujinx.Graphics.OpenGL/Sync.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.OpenGL public IntPtr Handle; } - private ulong _firstHandle; + private ulong _firstHandle = 0; private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit; private readonly List _handles = []; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs index 21cf79a68..4faba77f3 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs @@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { using IrOperandType = IntermediateRepresentation.OperandType; - class CodeGenContext : Module + partial class CodeGenContext : Module { private const uint SpirvVersionMajor = 1; private const uint SpirvVersionMinor = 3; diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs index e6ae98ff7..8118deb89 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs @@ -4,10 +4,17 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { class StructuredProgramInfo { - public List Functions { get; } = []; + public List Functions { get; } - public HashSet IoDefinitions { get; } = []; + public HashSet IoDefinitions { get; } public HelperFunctionsMask HelperFunctionsMask { get; set; } + + public StructuredProgramInfo() + { + Functions = []; + + IoDefinitions = []; + } } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs b/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs index 4d14590da..5504ef4ed 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/AttributeUsage.cs @@ -4,22 +4,31 @@ using System.Numerics; namespace Ryujinx.Graphics.Shader.Translation { - class AttributeUsage(IGpuAccessor gpuAccessor) + class AttributeUsage { public bool NextUsesFixedFuncAttributes { get; private set; } public int UsedInputAttributes { get; private set; } public int UsedOutputAttributes { get; private set; } - public HashSet UsedInputAttributesPerPatch { get; } = []; - public HashSet UsedOutputAttributesPerPatch { get; } = []; + public HashSet UsedInputAttributesPerPatch { get; } + public HashSet UsedOutputAttributesPerPatch { get; } public HashSet NextUsedInputAttributesPerPatch { get; private set; } public int PassthroughAttributes { get; private set; } private int _nextUsedInputAttributes; private int _thisUsedInputAttributes; private Dictionary _perPatchAttributeLocations; + private readonly IGpuAccessor _gpuAccessor; public UInt128 NextInputAttributesComponents { get; private set; } public UInt128 ThisInputAttributesComponents { get; private set; } + public AttributeUsage(IGpuAccessor gpuAccessor) + { + _gpuAccessor = gpuAccessor; + + UsedInputAttributesPerPatch = []; + UsedOutputAttributesPerPatch = []; + } + public void SetInputUserAttribute(int index, int component) { int mask = 1 << index; @@ -65,7 +74,7 @@ namespace Ryujinx.Graphics.Shader.Translation int location = BitOperations.TrailingZeroCount(freeMask); if (location == 32) { - gpuAccessor.Log($"No enough free locations for patch input/output 0x{attr:X}."); + _gpuAccessor.Log($"No enough free locations for patch input/output 0x{attr:X}."); break; } diff --git a/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs b/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs index aa9f4af3e..f831ec940 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ShaderDefinitions.cs @@ -61,12 +61,18 @@ namespace Ryujinx.Graphics.Shader.Translation private readonly TransformFeedbackOutput[] _transformFeedbackOutputs; - readonly struct TransformFeedbackVariable(IoVariable ioVariable, int location = 0, int component = 0) - : IEquatable + readonly struct TransformFeedbackVariable : IEquatable { - public IoVariable IoVariable { get; } = ioVariable; - public int Location { get; } = location; - public int Component { get; } = component; + public IoVariable IoVariable { get; } + public int Location { get; } + public int Component { get; } + + public TransformFeedbackVariable(IoVariable ioVariable, int location = 0, int component = 0) + { + IoVariable = ioVariable; + Location = location; + Component = component; + } public override bool Equals(object other) { diff --git a/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs b/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs index 679ef1572..3f8ca3401 100644 --- a/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs +++ b/src/Ryujinx.Graphics.Vulkan/BarrierBatch.cs @@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Vulkan return (access, stages); } - private readonly record struct StageFlags + private readonly record struct StageFlags : IEquatable { public readonly PipelineStageFlags Source; public readonly PipelineStageFlags Dest; @@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Vulkan } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void FlushMemoryBarrier(ShaderCollection program, bool inRenderPass) + public unsafe void FlushMemoryBarrier(ShaderCollection program, bool inRenderPass) { if (_queuedIncoherentBarrier > IncoherentBarrierType.None) { @@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public void Flush(CommandBufferScoped cbs, bool inRenderPass, RenderPassHolder rpHolder, Action endRenderPass) + public unsafe void Flush(CommandBufferScoped cbs, bool inRenderPass, RenderPassHolder rpHolder, Action endRenderPass) { Flush(cbs, null, inRenderPass, rpHolder, endRenderPass); } diff --git a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs index dc7316990..5e05701e9 100644 --- a/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs +++ b/src/Ryujinx.Graphics.Vulkan/BufferHolder.cs @@ -640,7 +640,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public void SetDataUnchecked(int offset, ReadOnlySpan data) where T : unmanaged + public unsafe void SetDataUnchecked(int offset, ReadOnlySpan data) where T : unmanaged { SetDataUnchecked(offset, MemoryMarshal.AsBytes(data)); } diff --git a/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs b/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs index dfaabf5ec..97669942c 100644 --- a/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs +++ b/src/Ryujinx.Graphics.Vulkan/DescriptorSetManager.cs @@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Vulkan } } - public DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan layouts, int consumedDescriptors) + public unsafe DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan layouts, int consumedDescriptors) { TryAllocateDescriptorSets(layouts, consumedDescriptors, isTry: false, out var dsc); return dsc; diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index d4f3def3b..2362902e1 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -9,48 +9,48 @@ namespace Ryujinx.Graphics.Vulkan { class FormatCapabilities { - private static readonly Format[] _scaledFormats = + private static readonly GAL.Format[] _scaledFormats = [ - Format.R8Uscaled, - Format.R8Sscaled, - Format.R16Uscaled, - Format.R16Sscaled, - Format.R8G8Uscaled, - Format.R8G8Sscaled, - Format.R16G16Uscaled, - Format.R16G16Sscaled, - Format.R8G8B8Uscaled, - Format.R8G8B8Sscaled, - Format.R16G16B16Uscaled, - Format.R16G16B16Sscaled, - Format.R8G8B8A8Uscaled, - Format.R8G8B8A8Sscaled, - Format.R16G16B16A16Uscaled, - Format.R16G16B16A16Sscaled, - Format.R10G10B10A2Uscaled, - Format.R10G10B10A2Sscaled + GAL.Format.R8Uscaled, + GAL.Format.R8Sscaled, + GAL.Format.R16Uscaled, + GAL.Format.R16Sscaled, + GAL.Format.R8G8Uscaled, + GAL.Format.R8G8Sscaled, + GAL.Format.R16G16Uscaled, + GAL.Format.R16G16Sscaled, + GAL.Format.R8G8B8Uscaled, + GAL.Format.R8G8B8Sscaled, + GAL.Format.R16G16B16Uscaled, + GAL.Format.R16G16B16Sscaled, + GAL.Format.R8G8B8A8Uscaled, + GAL.Format.R8G8B8A8Sscaled, + GAL.Format.R16G16B16A16Uscaled, + GAL.Format.R16G16B16A16Sscaled, + GAL.Format.R10G10B10A2Uscaled, + GAL.Format.R10G10B10A2Sscaled ]; - private static readonly Format[] _intFormats = + private static readonly GAL.Format[] _intFormats = [ - Format.R8Uint, - Format.R8Sint, - Format.R16Uint, - Format.R16Sint, - Format.R8G8Uint, - Format.R8G8Sint, - Format.R16G16Uint, - Format.R16G16Sint, - Format.R8G8B8Uint, - Format.R8G8B8Sint, - Format.R16G16B16Uint, - Format.R16G16B16Sint, - Format.R8G8B8A8Uint, - Format.R8G8B8A8Sint, - Format.R16G16B16A16Uint, - Format.R16G16B16A16Sint, - Format.R10G10B10A2Uint, - Format.R10G10B10A2Sint + GAL.Format.R8Uint, + GAL.Format.R8Sint, + GAL.Format.R16Uint, + GAL.Format.R16Sint, + GAL.Format.R8G8Uint, + GAL.Format.R8G8Sint, + GAL.Format.R16G16Uint, + GAL.Format.R16G16Sint, + GAL.Format.R8G8B8Uint, + GAL.Format.R8G8B8Sint, + GAL.Format.R16G16B16Uint, + GAL.Format.R16G16B16Sint, + GAL.Format.R8G8B8A8Uint, + GAL.Format.R8G8B8A8Sint, + GAL.Format.R16G16B16A16Uint, + GAL.Format.R16G16B16A16Sint, + GAL.Format.R10G10B10A2Uint, + GAL.Format.R10G10B10A2Sint ]; private readonly FormatFeatureFlags[] _bufferTable; diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs index ce6d9f6f9..5756ba9ae 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs @@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Vulkan TriFanToTrisPattern = new IndexBufferPattern(Gd, 3, 3, 2, [int.MinValue, -1, 0], 1, true); } - public void Barrier() + public unsafe void Barrier() { Gd.Barriers.QueueMemoryBarrier(); } @@ -255,7 +255,7 @@ namespace Ryujinx.Graphics.Vulkan Gd.Api.CmdClearAttachments(CommandBuffer, 1, &attachment, 1, &clearRect); } - public void CommandBufferBarrier() + public unsafe void CommandBufferBarrier() { Gd.Barriers.QueueCommandBufferBarrier(); } @@ -1348,7 +1348,7 @@ namespace Ryujinx.Graphics.Vulkan _descriptorSetUpdater.ForceImageDirty(); } - public void TextureBarrier() + public unsafe void TextureBarrier() { Gd.Barriers.QueueTextureBarrier(); } @@ -1446,7 +1446,7 @@ namespace Ryujinx.Graphics.Vulkan _newState.SamplesCount = FramebufferParams.AttachmentSamples.Length != 0 ? FramebufferParams.AttachmentSamples[0] : 1; } - protected void CreateRenderPass() + protected unsafe void CreateRenderPass() { var hasFramebuffer = FramebufferParams != null; diff --git a/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs b/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs index b220792fb..90a47bb67 100644 --- a/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs +++ b/src/Ryujinx.Graphics.Vulkan/StagingBuffer.cs @@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.Vulkan /// The minimum size the reserved data requires /// The required alignment for the buffer offset /// The reserved range of the staging buffer - public StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment) + public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment) { if (size > BufferSize) { @@ -235,7 +235,7 @@ namespace Ryujinx.Graphics.Vulkan /// Command buffer to reserve the data on /// The minimum size the reserved data requires /// The reserved range of the staging buffer - public StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size) + public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size) { return TryReserveData(cbs, size, _resourceAlignment); } diff --git a/src/Ryujinx.Graphics.Vulkan/SyncManager.cs b/src/Ryujinx.Graphics.Vulkan/SyncManager.cs index 3f3ba5c3c..5f6214a4f 100644 --- a/src/Ryujinx.Graphics.Vulkan/SyncManager.cs +++ b/src/Ryujinx.Graphics.Vulkan/SyncManager.cs @@ -6,7 +6,7 @@ using System.Linq; namespace Ryujinx.Graphics.Vulkan { - class SyncManager(VulkanRenderer gd, Device device) + class SyncManager { private class SyncHandle { @@ -23,10 +23,19 @@ namespace Ryujinx.Graphics.Vulkan private ulong _firstHandle; - private readonly List _handles = []; + private readonly VulkanRenderer _gd; + private readonly Device _device; + private readonly List _handles; private ulong _flushId; private long _waitTicks; + public SyncManager(VulkanRenderer gd, Device device) + { + _gd = gd; + _device = device; + _handles = []; + } + public void RegisterFlush() { _flushId++; @@ -36,17 +45,17 @@ namespace Ryujinx.Graphics.Vulkan { ulong flushId = _flushId; MultiFenceHolder waitable = new(); - if (strict || gd.InterruptAction == null) + if (strict || _gd.InterruptAction == null) { - gd.FlushAllCommands(); - gd.CommandBufferPool.AddWaitable(waitable); + _gd.FlushAllCommands(); + _gd.CommandBufferPool.AddWaitable(waitable); } else { // Don't flush commands, instead wait for the current command buffer to finish. // If this sync is waited on before the command buffer is submitted, interrupt the gpu thread and flush it manually. - gd.CommandBufferPool.AddInUseWaitable(waitable); + _gd.CommandBufferPool.AddInUseWaitable(waitable); } SyncHandle handle = new() @@ -79,7 +88,7 @@ namespace Ryujinx.Graphics.Vulkan if (handle.ID > lastHandle) { - bool signaled = handle.Signalled || handle.Waitable.WaitForFences(gd.Api, device, 0); + bool signaled = handle.Signalled || handle.Waitable.WaitForFences(_gd.Api, _device, 0); if (signaled) { lastHandle = handle.ID; @@ -125,11 +134,11 @@ namespace Ryujinx.Graphics.Vulkan if (result.NeedsFlush(_flushId)) { - gd.InterruptAction(() => + _gd.InterruptAction(() => { if (result.NeedsFlush(_flushId)) { - gd.FlushAllCommands(); + _gd.FlushAllCommands(); } }); } @@ -141,7 +150,7 @@ namespace Ryujinx.Graphics.Vulkan return; } - bool signaled = result.Signalled || result.Waitable.WaitForFences(gd.Api, device, 1000000000); + bool signaled = result.Signalled || result.Waitable.WaitForFences(_gd.Api, _device, 1000000000); if (!signaled) { @@ -173,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan break; } - bool signaled = first.Waitable.WaitForFences(gd.Api, device, 0); + bool signaled = first.Waitable.WaitForFences(_gd.Api, _device, 0); if (signaled) { // Delete the sync object. diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index d144d5474..9d4f07736 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Vulkan private bool _initialized; - public uint ProgramCount { get; set; } + public uint ProgramCount { get; set; } = 0; internal FormatCapabilities FormatCapabilities { get; private set; } internal HardwareCapabilities Capabilities; diff --git a/src/Ryujinx.Graphics.Vulkan/Window.cs b/src/Ryujinx.Graphics.Vulkan/Window.cs index 885b7abdb..bfa15d9a5 100644 --- a/src/Ryujinx.Graphics.Vulkan/Window.cs +++ b/src/Ryujinx.Graphics.Vulkan/Window.cs @@ -42,7 +42,7 @@ namespace Ryujinx.Graphics.Vulkan private ScalingFilter _currentScalingFilter; private bool _colorSpacePassthroughEnabled; - public Window(VulkanRenderer gd, SurfaceKHR surface, PhysicalDevice physicalDevice, Device device) + public unsafe Window(VulkanRenderer gd, SurfaceKHR surface, PhysicalDevice physicalDevice, Device device) { _gd = gd; _physicalDevice = physicalDevice; diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index d9e9e1f75..4e136a8da 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -698,6 +698,8 @@ namespace Ryujinx.HLE.FileSystem { throw new InvalidFirmwarePackageException("Update not found in xci file."); } + default: + break; } SystemVersion VerifyAndGetVersionDirectory(string firmwareDirectory) diff --git a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs index 619462eab..1103329c1 100644 --- a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs +++ b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs @@ -38,7 +38,7 @@ namespace Ryujinx.HLE.FileSystem private readonly ConcurrentDictionary _romFsByPid; - private static bool _isInitialized; + private static bool _isInitialized = false; public static VirtualFileSystem CreateInstance() { diff --git a/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs index 40ecd7ef0..294b8d1f6 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Cabinet/CabinetApplet.cs @@ -128,13 +128,13 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet #region Structs [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct TagInfo + public unsafe struct TagInfo { public fixed byte Data[0x58]; } [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct StartParamForAmiiboSettings + public unsafe struct StartParamForAmiiboSettings { public byte ZeroValue; // Left at zero by sdknso public byte Type; @@ -151,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet } [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct ReturnValueForAmiiboSettings + public unsafe struct ReturnValueForAmiiboSettings { public byte AmiiboSettingsReturnFlag; private byte Padding1; diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 2a127f74c..3545c71aa 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Applets private SoftwareKeyboardState _foregroundState = SoftwareKeyboardState.Uninitialized; private volatile InlineKeyboardState _backgroundState = InlineKeyboardState.Uninitialized; - private bool _isBackground; + private bool _isBackground = false; private AppletSession _normalSession; private AppletSession _interactiveSession; @@ -53,14 +53,14 @@ namespace Ryujinx.HLE.HOS.Applets private byte[] _transferMemory; private string _textValue = ""; - private int _cursorBegin; + private int _cursorBegin = 0; private Encoding _encoding = Encoding.Unicode; private KeyboardResult _lastResult = KeyboardResult.NotSet; - private IDynamicTextInputHandler _dynamicTextInputHandler; - private SoftwareKeyboardRenderer _keyboardRenderer; - private NpadReader _npads; - private bool _canAcceptController; + private IDynamicTextInputHandler _dynamicTextInputHandler = null; + private SoftwareKeyboardRenderer _keyboardRenderer = null; + private NpadReader _npads = null; + private bool _canAcceptController = false; private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard; private readonly Lock _lock = new(); diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs index ef9362b8e..9183b6383 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardRendererBase.cs @@ -23,15 +23,15 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard private readonly Lock _bufferLock = new(); - private RenderingSurfaceInfo _surfaceInfo; + private RenderingSurfaceInfo _surfaceInfo = null; private SKImageInfo _imageInfo; - private SKSurface _surface; - private byte[] _bufferData; + private SKSurface _surface = null; + private byte[] _bufferData = null; - private readonly SKBitmap _ryujinxLogo; - private readonly SKBitmap _padAcceptIcon; - private readonly SKBitmap _padCancelIcon; - private readonly SKBitmap _keyModeIcon; + private readonly SKBitmap _ryujinxLogo = null; + private readonly SKBitmap _padAcceptIcon = null; + private readonly SKBitmap _padCancelIcon = null; + private readonly SKBitmap _keyModeIcon = null; private readonly float _textBoxOutlineWidth; private readonly float _padPressedPenWidth; diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs index 089a245b6..a8b137df2 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/TimedAction.cs @@ -25,8 +25,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard } } - private TRef _cancelled; - private Thread _thread; + private TRef _cancelled = null; + private Thread _thread = null; private readonly Lock _lock = new(); public bool IsRunning diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs index 42046f39a..72f906422 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SyscallHandler.cs @@ -3,7 +3,7 @@ using Ryujinx.HLE.HOS.Kernel.Threading; namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall { - class SyscallHandler + partial class SyscallHandler { private readonly KernelContext _context; diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs index 60ecb497e..19f1b8be0 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KScheduler.cs @@ -6,7 +6,7 @@ using System.Threading; namespace Ryujinx.HLE.HOS.Kernel.Threading { - class KScheduler : IDisposable + partial class KScheduler : IDisposable { public const int PrioritiesCount = 64; public static int CpuCoresCount; diff --git a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs index d41b208f3..8c436b1b2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Account/Acc/AccountSaveDataManager.cs @@ -4,6 +4,7 @@ using Ryujinx.Common.Utilities; using Ryujinx.HLE.HOS.Services.Account.Acc.Types; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.IO; namespace Ryujinx.HLE.HOS.Services.Account.Acc 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 6b9793bd5..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 @@ -26,21 +26,21 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys // TODO: Determine where those fields are used. #pragma warning disable IDE0052 // Remove unread private member - private bool _screenShotPermission; - private bool _operationModeChangedNotification; - private bool _performanceModeChangedNotification; - private bool _restartMessageEnabled; - private bool _outOfFocusSuspendingEnabled; - private bool _handlesRequestToDisplay; + private bool _screenShotPermission = false; + private bool _operationModeChangedNotification = false; + private bool _performanceModeChangedNotification = false; + private bool _restartMessageEnabled = false; + private bool _outOfFocusSuspendingEnabled = false; + private bool _handlesRequestToDisplay = false; #pragma warning restore IDE0052 - private bool _autoSleepDisabled; + private bool _autoSleepDisabled = false; #pragma warning disable IDE0052 // Remove unread private member - private bool _albumImageTakenNotificationEnabled; - private bool _recordVolumeMuted; + private bool _albumImageTakenNotificationEnabled = false; + private bool _recordVolumeMuted = false; - private uint _screenShotImageOrientation; + private uint _screenShotImageOrientation = 0; #pragma warning restore IDE0052 - private uint _idleTimeDetectionExtension; + private uint _idleTimeDetectionExtension = 0; public ISelfController(ServiceCtx context, ulong pid) { diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs index 57f46bdbd..a13e77e72 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Irs/IIrSensorServer.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs [Service("irs")] class IIrSensorServer : IpcService { - private int _irsensorSharedMemoryHandle; + private int _irsensorSharedMemoryHandle = 0; public IIrSensorServer(ServiceCtx context) { } diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs index b7b82a4e6..d3a8bead2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/Lp2p/ISfServiceMonitor.cs @@ -10,8 +10,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.Lp2p { private readonly KEvent _stateChangeEvent; private readonly KEvent _jointEvent; - private int _stateChangeEventHandle; - private int _jointEventHandle; + private int _stateChangeEventHandle = 0; + private int _jointEventHandle = 0; public ISfServiceMonitor(ServiceCtx context) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs index 09ade3f88..054f38794 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/LdnMasterProxyClient.cs @@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu { public bool NeedsRealId => true; - private static InitializeMessage InitializeMemory; + private static InitializeMessage InitializeMemory = new InitializeMessage(); private const int InactiveTimeout = 6000; private const int FailureTimeout = 4000; diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs index 87c5cb07d..d0eeaf125 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/RyuLdnProtocol.cs @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu private readonly int _headerSize = Marshal.SizeOf(); private readonly byte[] _buffer = new byte[MaxPacketSize]; - private int _bufferEnd; + private int _bufferEnd = 0; // Client Packets. public event Action Initialize; @@ -312,6 +312,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu break; } + + default: + break; } } diff --git a/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs b/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs index 1e1ced8cf..23a52d908 100644 --- a/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Mii/MiiDatabaseManager.cs @@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii class MiiDatabaseManager { private readonly bool _isTestModeEnabled = false; - private uint _mountCounter; + private uint _mountCounter = 0; private const ulong DatabaseTestSaveDataId = 0x8000000000000031; private const ulong DatabaseSaveDataId = 0x8000000000000030; diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 7e3e4c0a2..36a89070d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -7,6 +7,7 @@ using Ryujinx.HLE.HOS.Services.Mii.Types; using Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption; using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager; using System; +using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs index dcf30a1d5..581a2906b 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs @@ -13,9 +13,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService { private readonly GeneralServiceDetail _generalServiceDetail; - private IPInterfaceProperties _targetPropertiesCache; - private UnicastIPAddressInformation _targetAddressInfoCache; - private string _cacheChosenInterface; + private IPInterfaceProperties _targetPropertiesCache = null; + private UnicastIPAddressInformation _targetAddressInfoCache = null; + private string _cacheChosenInterface = null; public IGeneralService() { diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 72ba7e3ef..fea09ef47 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv private IVirtualMemoryManager _clientMemory; private ulong _owner; - private bool _transferMemInitialized; + private bool _transferMemInitialized = false; // TODO: This should call set:sys::GetDebugModeFlag private readonly bool _debugModeEnabled = false; diff --git a/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs b/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs index e755189a6..9b026a1c3 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pctl/ParentalControlServiceFactory/IParentalControlService.cs @@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory // TODO: Find where they are set. private readonly bool _restrictionEnabled = false; private readonly bool _featuresRestriction = false; - private bool _freeCommunicationEnabled; + private bool _freeCommunicationEnabled = false; private readonly bool _stereoVisionRestrictionConfigurable = true; - private bool _stereoVisionRestriction; + private bool _stereoVisionRestriction = false; #pragma warning restore IDE0052, CS0414 public IParentalControlService(ServiceCtx context, ulong pid, bool withInitialize, int permissionFlag) diff --git a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs index d45735066..c7c459196 100644 --- a/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Pcv/Clkrst/IClkrstManager.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst [Service("clkrst:i")] // 8.0.0+ class IClkrstManager : IpcService { - private int _moduleStateTableEventHandle; + private int _moduleStateTableEventHandle = 0; public IClkrstManager(ServiceCtx context) { } diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index a13b08edc..40329aa36 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services private KProcess _selfProcess; private KThread _selfThread; private KEvent _wakeEvent; - private int _wakeHandle; + private int _wakeHandle = 0; private readonly ReaderWriterLockSlim _handleLock = new(); private readonly Dictionary _sessions = new(); @@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services private readonly MemoryStream _responseDataStream; private readonly BinaryWriter _responseDataWriter; - private int _isDisposed; + private int _isDisposed = 0; public ManualResetEvent InitDone { get; } public string Name { get; } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index bc2994448..2240f60e4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { [Service("bsd:s", true)] [Service("bsd:u", false)] - class IClient(ServiceCtx context, bool isPrivileged) : IpcService(context.Device.System.BsdServer) + class IClient : IpcService { private static readonly List _pollManagers = [ @@ -23,6 +23,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd ]; private BsdContext _context; + private readonly bool _isPrivileged; + + public IClient(ServiceCtx context, bool isPrivileged) : base(context.Device.System.BsdServer) + { + _isPrivileged = isPrivileged; + } private ResultCode WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = LinuxError.SUCCESS) { @@ -73,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT); } - else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !isPrivileged) + else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !_isPrivileged) { if (domain != BsdAddressFamily.InterNetwork || type != BsdSocketType.Raw || protocol != ProtocolType.Icmp) { @@ -1034,7 +1040,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd LinuxError errno = LinuxError.ENOENT; int newSockFd = -1; - if (isPrivileged) + if (_isPrivileged) { errno = LinuxError.SUCCESS; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs index 77d9a7b1a..84135d87a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Proxy/SocketHelpers.cs @@ -1,5 +1,6 @@ using Ryujinx.Common.Logging; using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy; +using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs index bf967d8f2..0c1fa3a9f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/IManager.cs @@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd private readonly FqdnResolver _fqdnResolver; #pragma warning restore IDE0052 - private readonly bool _isInitialized; + private readonly bool _isInitialized = false; public IManager(ServiceCtx context) { diff --git a/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs b/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs index 5f2e3b3ce..4a2a910f8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Spl/IGeneralInterface.cs @@ -44,6 +44,8 @@ namespace Ryujinx.HLE.HOS.Services.Spl configValue = (ulong)HardwareState.Development; result = SmcResult.Success; break; + default: + break; } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs index 68238a5eb..ae61d0bf7 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueProducer.cs @@ -792,6 +792,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger freeSlot = slot; } break; + default: + break; } } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs index 55d7d0ddb..5151930a5 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/HOSBinderDriverServer.cs @@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { private static readonly Dictionary _registeredBinderObjects = new(); - private static int _lastBinderId; + private static int _lastBinderId = 0; private static readonly Lock _lock = new(); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs index e3ac777ad..a6b33e4ae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/IStaticServiceForPsc.cs @@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Time private readonly TimeManager _timeManager; private readonly TimePermissions _permissions; - private int _timeSharedMemoryNativeHandle; + private int _timeSharedMemoryNativeHandle = 0; public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) { } diff --git a/src/Ryujinx.HLE/HOS/Tamper/Register.cs b/src/Ryujinx.HLE/HOS/Tamper/Register.cs index 7e46afe9a..cce13ee69 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/Register.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/Register.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Tamper { class Register : IOperand { - private ulong _register; + private ulong _register = 0; private readonly string _alias; public Register(string alias) diff --git a/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs b/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs index 0f077115d..422e4ef0e 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/TamperedKProcess.cs @@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Tamper public ProcessState State => _process.State; - public bool TamperedCodeMemory { get; set; } + public bool TamperedCodeMemory { get; set; } = false; public TamperedKProcess(KProcess process) { diff --git a/src/Ryujinx.HLE/HOS/TamperMachine.cs b/src/Ryujinx.HLE/HOS/TamperMachine.cs index d65345051..609221535 100644 --- a/src/Ryujinx.HLE/HOS/TamperMachine.cs +++ b/src/Ryujinx.HLE/HOS/TamperMachine.cs @@ -16,9 +16,9 @@ namespace Ryujinx.HLE.HOS // cheat and the re-execution of the first one. private const int TamperMachineSleepMs = 1000 / 12; - private Thread _tamperThread; + private Thread _tamperThread = null; private readonly ConcurrentQueue _programs = new(); - private long _pressedKeys; + private long _pressedKeys = 0; private readonly Dictionary _programDictionary = new(); private void Activate() diff --git a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs index d74e50a61..acec66e82 100644 --- a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs +++ b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs @@ -2,6 +2,7 @@ using Ryujinx.Common; using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Sdk.Sf; using Ryujinx.Horizon.Sdk.Sf.Hipc; +using System; namespace Ryujinx.Horizon.Sdk.Codec.Detail { diff --git a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs index efbaca728..fc5cd683d 100644 --- a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs +++ b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/CompressedArray.cs @@ -9,11 +9,20 @@ namespace Ryujinx.Horizon.Sdk.Ngc.Detail private const int CompressedEntriesPerBlock = 64; private const int BitsPerWord = Set.BitsPerWord; - private readonly struct BitfieldRange(uint range, int baseValue) + private readonly struct BitfieldRange { - public int BitfieldIndex => (int)(range & 0x7ffffff); - public int BitfieldLength => (int)(range >> 27) + 1; - public int BaseValue => baseValue; + private readonly uint _range; + private readonly int _baseValue; + + public int BitfieldIndex => (int)(_range & 0x7ffffff); + public int BitfieldLength => (int)(_range >> 27) + 1; + public int BaseValue => _baseValue; + + public BitfieldRange(uint range, int baseValue) + { + _range = range; + _baseValue = baseValue; + } } private uint[] _bitfieldRanges; diff --git a/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs b/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs index 0cd147771..422f756e4 100644 --- a/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs +++ b/src/Ryujinx.Horizon/Sdk/OsTypes/OsEvent.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading; namespace Ryujinx.Horizon.Sdk.OsTypes diff --git a/src/Ryujinx.Memory/AddressSpaceManager.cs b/src/Ryujinx.Memory/AddressSpaceManager.cs index 02dbe8558..916ac1ca6 100644 --- a/src/Ryujinx.Memory/AddressSpaceManager.cs +++ b/src/Ryujinx.Memory/AddressSpaceManager.cs @@ -1,6 +1,7 @@ using Ryujinx.Memory.Range; using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; namespace Ryujinx.Memory diff --git a/src/Ryujinx.Memory/NativeMemoryManager.cs b/src/Ryujinx.Memory/NativeMemoryManager.cs index 6d1cfacf4..cb8d5c243 100644 --- a/src/Ryujinx.Memory/NativeMemoryManager.cs +++ b/src/Ryujinx.Memory/NativeMemoryManager.cs @@ -19,7 +19,7 @@ namespace Ryujinx.Memory _length = length; } - public T* Pointer => _pointer; + public unsafe T* Pointer => _pointer; public int Length => _length; diff --git a/src/Ryujinx.Memory/Tracking/RegionHandle.cs b/src/Ryujinx.Memory/Tracking/RegionHandle.cs index ed238f289..4e81a9723 100644 --- a/src/Ryujinx.Memory/Tracking/RegionHandle.cs +++ b/src/Ryujinx.Memory/Tracking/RegionHandle.cs @@ -60,8 +60,8 @@ namespace Ryujinx.Memory.Tracking private readonly MemoryTracking _tracking; private bool _disposed; - private int _checkCount; - private int _volatileCount; + private int _checkCount = 0; + private int _volatileCount = 0; private bool _volatile; internal MemoryPermission RequiredPermission diff --git a/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs b/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs index 3d8847dc4..b7ad8efe7 100644 --- a/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs +++ b/src/Ryujinx.Tests/Cpu/CpuTestT32Mem.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using System; namespace Ryujinx.Tests.Cpu { diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 97eae54ee..4b04d6348 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -795,10 +795,10 @@ namespace Ryujinx.UI.App.Common { ldnWebHost = DefaultLanPlayWebHost; } - + IEnumerable ldnGameDataArray = Array.Empty(); using HttpClient httpClient = new HttpClient(); string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games"); - IEnumerable ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData); + ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData); var evt = new LdnGameDataReceivedEventArgs { LdnData = ldnGameDataArray diff --git a/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs b/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs index e3b71c9d4..81193c5b3 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationMetadata.cs @@ -12,7 +12,7 @@ namespace Ryujinx.UI.App.Common public TimeSpan TimePlayed { get; set; } = TimeSpan.Zero; [JsonPropertyName("last_played_utc")] - public DateTime? LastPlayed { get; set; } + public DateTime? LastPlayed { get; set; } = null; [JsonPropertyName("time_played")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index 8f4afcc2b..de8b68ace 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -13,6 +13,7 @@ using Ryujinx.UI.Common.Helper; using System; using System.Collections.Generic; using System.Globalization; +using System.Text.Json.Nodes; namespace Ryujinx.UI.Common.Configuration { @@ -25,23 +26,44 @@ namespace Ryujinx.UI.Common.Configuration { public class Columns { - public ReactiveObject FavColumn { get; private set; } = new(); - public ReactiveObject IconColumn { get; private set; } = new(); - public ReactiveObject AppColumn { get; private set; } = new(); - public ReactiveObject DevColumn { get; private set; } = new(); - public ReactiveObject VersionColumn { get; private set; } = new(); - public ReactiveObject LdnInfoColumn { get; private set; } = new(); - public ReactiveObject TimePlayedColumn { get; private set; } = new(); - public ReactiveObject LastPlayedColumn { get; private set; } = new(); - public ReactiveObject FileExtColumn { get; private set; } = new(); - public ReactiveObject FileSizeColumn { get; private set; } = new(); - public ReactiveObject PathColumn { get; private set; } = new(); + public ReactiveObject FavColumn { get; private set; } + public ReactiveObject IconColumn { get; private set; } + public ReactiveObject AppColumn { get; private set; } + public ReactiveObject DevColumn { get; private set; } + public ReactiveObject VersionColumn { get; private set; } + public ReactiveObject LdnInfoColumn { get; private set; } + public ReactiveObject TimePlayedColumn { get; private set; } + public ReactiveObject LastPlayedColumn { get; private set; } + public ReactiveObject FileExtColumn { get; private set; } + public ReactiveObject FileSizeColumn { get; private set; } + public ReactiveObject PathColumn { get; private set; } + + public Columns() + { + FavColumn = new ReactiveObject(); + IconColumn = new ReactiveObject(); + AppColumn = new ReactiveObject(); + DevColumn = new ReactiveObject(); + VersionColumn = new ReactiveObject(); + LdnInfoColumn = new ReactiveObject(); + TimePlayedColumn = new ReactiveObject(); + LastPlayedColumn = new ReactiveObject(); + FileExtColumn = new ReactiveObject(); + FileSizeColumn = new ReactiveObject(); + PathColumn = new ReactiveObject(); + } } public class ColumnSortSettings { - public ReactiveObject SortColumnId { get; private set; } = new(); - public ReactiveObject SortAscending { get; private set; } = new(); + public ReactiveObject SortColumnId { get; private set; } + public ReactiveObject SortAscending { get; private set; } + + public ColumnSortSettings() + { + SortColumnId = new ReactiveObject(); + SortAscending = new ReactiveObject(); + } } /// @@ -49,12 +71,22 @@ namespace Ryujinx.UI.Common.Configuration /// public class ShownFileTypeSettings { - public ReactiveObject NSP { get; private set; } = new(); - public ReactiveObject PFS0 { get; private set; } = new(); - public ReactiveObject XCI { get; private set; } = new(); - public ReactiveObject NCA { get; private set; } = new(); - public ReactiveObject NRO { get; private set; } = new(); - public ReactiveObject NSO { get; private set; } = new(); + public ReactiveObject NSP { get; private set; } + public ReactiveObject PFS0 { get; private set; } + public ReactiveObject XCI { get; private set; } + public ReactiveObject NCA { get; private set; } + public ReactiveObject NRO { get; private set; } + public ReactiveObject NSO { get; private set; } + + public ShownFileTypeSettings() + { + NSP = new ReactiveObject(); + PFS0 = new ReactiveObject(); + XCI = new ReactiveObject(); + NCA = new ReactiveObject(); + NRO = new ReactiveObject(); + NSO = new ReactiveObject(); + } } // @@ -62,11 +94,20 @@ namespace Ryujinx.UI.Common.Configuration /// public class WindowStartupSettings { - public ReactiveObject WindowSizeWidth { get; private set; } = new(); - public ReactiveObject WindowSizeHeight { get; private set; } = new(); - public ReactiveObject WindowPositionX { get; private set; } = new(); - public ReactiveObject WindowPositionY { get; private set; } = new(); - public ReactiveObject WindowMaximized { get; private set; } = new(); + public ReactiveObject WindowSizeWidth { get; private set; } + public ReactiveObject WindowSizeHeight { get; private set; } + public ReactiveObject WindowPositionX { get; private set; } + public ReactiveObject WindowPositionY { get; private set; } + public ReactiveObject WindowMaximized { get; private set; } + + public WindowStartupSettings() + { + WindowSizeWidth = new ReactiveObject(); + WindowSizeHeight = new ReactiveObject(); + WindowPositionX = new ReactiveObject(); + WindowPositionY = new ReactiveObject(); + WindowMaximized = new ReactiveObject(); + } } /// @@ -380,24 +421,32 @@ namespace Ryujinx.UI.Common.Configuration /// /// Enable or disable keyboard support (Independent from controllers binding) /// - public ReactiveObject EnableKeyboard { get; private set; } = new(); + public ReactiveObject EnableKeyboard { get; private set; } /// /// Enable or disable mouse support (Independent from controllers binding) /// - public ReactiveObject EnableMouse { get; private set; } = new(); + public ReactiveObject EnableMouse { get; private set; } /// /// Hotkey Keyboard Bindings /// - public ReactiveObject Hotkeys { get; private set; } = new(); + public ReactiveObject Hotkeys { get; private set; } /// /// Input device configuration. /// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed. /// TODO: Implement a ReactiveList class. /// - public ReactiveObject> InputConfig { get; private set; } = new(); + public ReactiveObject> InputConfig { get; private set; } + + public HidSection() + { + EnableKeyboard = new ReactiveObject(); + EnableMouse = new ReactiveObject(); + Hotkeys = new ReactiveObject(); + InputConfig = new ReactiveObject>(); + } } /// diff --git a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs index 975eda3ff..ea6d7c32a 100644 --- a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs @@ -99,13 +99,16 @@ namespace Ryujinx.UI.Common.Helper Dictionary updates = pfs.GetContentData(ContentMetaType.Patch, vfs, checkLevel); + Nca patchNca = null; + Nca controlNca = null; + if (!updates.TryGetValue(applicationIdBase, out ContentMetaData content)) { continue; } - Nca patchNca = content.GetNcaByType(vfs.KeySet, ContentType.Program); - Nca controlNca = content.GetNcaByType(vfs.KeySet, ContentType.Control); + patchNca = content.GetNcaByType(vfs.KeySet, ContentType.Program); + controlNca = content.GetNcaByType(vfs.KeySet, ContentType.Control); if (controlNca == null || patchNca == null) { diff --git a/src/Ryujinx/App.axaml.cs b/src/Ryujinx/App.axaml.cs index cd4416aa1..22c8d59de 100644 --- a/src/Ryujinx/App.axaml.cs +++ b/src/Ryujinx/App.axaml.cs @@ -144,7 +144,7 @@ namespace Ryujinx.Ava public static ThemeVariant DetectSystemTheme() { - if (Current is App app) + if (Application.Current is App app) { var colorValues = app.PlatformSettings.GetColorValues(); diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index faab95996..1bb32c8be 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -92,7 +92,7 @@ namespace Ryujinx.Ava private long _lastCursorMoveTime; private bool _isCursorInRenderer = true; - private bool _ignoreCursorState; + private bool _ignoreCursorState = false; private enum CursorStates { @@ -106,7 +106,7 @@ namespace Ryujinx.Ava private DateTime _lastShaderReset; private uint _displayCount; - private uint _previousCount; + private uint _previousCount = 0; private bool _isStopped; private bool _isActive; diff --git a/src/Ryujinx/UI/Models/CheatNode.cs b/src/Ryujinx/UI/Models/CheatNode.cs index 9007593ed..9179fb0ef 100644 --- a/src/Ryujinx/UI/Models/CheatNode.cs +++ b/src/Ryujinx/UI/Models/CheatNode.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Ava.UI.Models { public class CheatNode : BaseModel { - private bool _isEnabled; + private bool _isEnabled = false; public ObservableCollection SubNodes { get; } = []; public string CleanName => Name.Length > 0 ? Name[1..^7] : Name; public string BuildIdKey => $"{BuildId}-{Name}"; diff --git a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs index a404a2ab4..e651baa22 100644 --- a/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/DownloadableContentManagerViewModel.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Ava.UI.ViewModels private AvaloniaList _downloadableContents = []; private AvaloniaList _selectedDownloadableContents = []; private AvaloniaList _views = []; - private bool _showBundledContentNotice; + private bool _showBundledContentNotice = false; private string _search; private readonly ApplicationData _applicationData; diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index b3377b018..e195b9e3b 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -6,6 +6,7 @@ using Avalonia.Media; using Avalonia.Platform.Storage; using Avalonia.Threading; using DynamicData; +using DynamicData.Alias; using DynamicData.Binding; using FluentAvalonia.UI.Controls; using Gommon; @@ -465,7 +466,7 @@ namespace Ryujinx.Ava.UI.ViewModels public bool OpenDeviceSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0; - public bool TrimXCIEnabled => XCIFileTrimmer.CanTrim(SelectedApplication.Path, new XCIFileTrimmerMainWindowLog(this)); + public bool TrimXCIEnabled => Ryujinx.Common.Utilities.XCIFileTrimmer.CanTrim(SelectedApplication.Path, new Common.XCIFileTrimmerMainWindowLog(this)); public bool OpenBcatSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0; @@ -1541,7 +1542,7 @@ namespace Ryujinx.Ava.UI.ViewModels Dispatcher.UIThread.InvokeAsync(() => { Application.Current.Styles.TryGetResource(args.VSyncMode, - Application.Current.ActualThemeVariant, + Avalonia.Application.Current.ActualThemeVariant, out object color); if (color is not null) @@ -2217,7 +2218,7 @@ namespace Ryujinx.Ava.UI.ViewModels } } - public async void ProcessTrimResult(String filename, XCIFileTrimmer.OperationOutcome operationOutcome) + public async void ProcessTrimResult(String filename, Ryujinx.Common.Utilities.XCIFileTrimmer.OperationOutcome operationOutcome) { string notifyUser = operationOutcome.ToLocalisedText(); @@ -2232,8 +2233,8 @@ namespace Ryujinx.Ava.UI.ViewModels { switch (operationOutcome) { - case XCIFileTrimmer.OperationOutcome.Successful: - if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + case Ryujinx.Common.Utilities.XCIFileTrimmer.OperationOutcome.Successful: + if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { if (desktop.MainWindow is MainWindow mainWindow) mainWindow.LoadApplications(); @@ -2250,7 +2251,7 @@ namespace Ryujinx.Ava.UI.ViewModels return; } - var trimmer = new XCIFileTrimmer(filename, new XCIFileTrimmerMainWindowLog(this)); + var trimmer = new XCIFileTrimmer(filename, new Common.XCIFileTrimmerMainWindowLog(this)); if (trimmer.CanBeTrimmed) { diff --git a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs index a10a5db3e..a6be45eea 100644 --- a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs @@ -25,7 +25,7 @@ namespace Ryujinx.Ava.UI.ViewModels private AvaloniaList _titleUpdates = []; private AvaloniaList _views = []; private object _selectedUpdate = new TitleUpdateViewNoUpdateSentinal(); - private bool _showBundledContentNotice; + private bool _showBundledContentNotice = false; public AvaloniaList TitleUpdates { diff --git a/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs b/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs index 4d9cd9bfe..45c631ded 100644 --- a/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/CheatWindow.axaml.cs @@ -6,6 +6,7 @@ using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; using Ryujinx.UI.App.Common; using Ryujinx.UI.Common.Configuration; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; diff --git a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs index cfaca7818..639085b63 100644 --- a/src/Ryujinx/UI/Windows/MainWindow.axaml.cs +++ b/src/Ryujinx/UI/Windows/MainWindow.axaml.cs @@ -231,7 +231,7 @@ namespace Ryujinx.Ava.UI.Windows ViewModel.ShowContent = true; ViewModel.IsLoadingIndeterminate = false; - if (startFullscreen && ViewModel.WindowState != FullScreenWindowState) + if (startFullscreen && ViewModel.WindowState != MainWindow.FullScreenWindowState) { ViewModel.ToggleFullscreen(); } @@ -243,7 +243,7 @@ namespace Ryujinx.Ava.UI.Windows ViewModel.ShowLoadProgress = true; ViewModel.IsLoadingIndeterminate = true; - if (startFullscreen && ViewModel.WindowState != FullScreenWindowState) + if (startFullscreen && ViewModel.WindowState != MainWindow.FullScreenWindowState) { ViewModel.ToggleFullscreen(); }