From c80c397967fe141f3b4d4d89502feb3c2859bc34 Mon Sep 17 00:00:00 2001 From: Marco Carvalho Date: Sun, 5 Jan 2025 11:54:53 -0300 Subject: [PATCH] Use concrete types when possible for improved performance --- .editorconfig | 35 +------------- .../CodeGen/Arm64/CodeGenContext.cs | 3 +- src/ARMeilleure/CodeGen/X86/CodeGenContext.cs | 3 +- .../Instructions/InstEmitAluHelper.cs | 2 +- .../Instructions/InstEmitMemoryHelper.cs | 2 +- .../Translation/PTC/PtcProfiler.cs | 5 +- .../Logging/Targets/ConsoleLogTarget.cs | 2 +- .../Logging/Targets/FileLogTarget.cs | 2 +- .../SystemInterop/StdErrAdapter.cs | 8 ++-- src/Ryujinx.Common/Utilities/StreamUtils.cs | 2 +- src/Ryujinx.Cpu/LightningJit/Translator.cs | 2 +- .../Shader/DiskCache/DiskCacheGuestStorage.cs | 4 +- .../Shader/DiskCache/DiskCacheHostStorage.cs | 2 +- .../DiskCache/ShaderBinarySerializer.cs | 3 +- src/Ryujinx.Graphics.Metal/HelperShader.cs | 18 ++++---- .../Instructions/AttributeMap.cs | 6 +-- .../StructuredIr/GotoElimination.cs | 4 +- .../Optimizations/GlobalToStorage.cs | 2 +- .../Translation/Optimizations/Utils.cs | 2 +- src/Ryujinx.Graphics.Vulkan/HelperShader.cs | 46 +++++++++---------- src/Ryujinx.HLE/FileSystem/ContentManager.cs | 6 +-- .../HOS/Applets/Browser/BrowserApplet.cs | 5 +- .../Applets/Controller/ControllerApplet.cs | 5 +- .../HOS/Applets/Dummy/DummyApplet.cs | 11 +++-- .../PlayerSelect/PlayerSelectApplet.cs | 3 +- .../HOS/Diagnostics/Demangler/Demangler.cs | 30 ++++++------ src/Ryujinx.HLE/HOS/ModLoader.cs | 2 +- .../Am/AppletAE/Storage/StorageHelper.cs | 3 +- .../HOS/Services/Ro/IRoInterface.cs | 2 +- .../HOS/Services/Sdb/Pl/SharedFontManager.cs | 3 +- src/Ryujinx.HLE/HOS/Services/ServerBase.cs | 5 +- .../HOS/Services/Sockets/Bsd/IClient.cs | 2 +- .../Sockets/Bsd/Impl/ManagedSocket.cs | 2 +- .../Services/Ssl/SslService/ISslConnection.cs | 2 +- .../HOS/Tamper/AtmosphereCompiler.cs | 2 +- src/Ryujinx.Horizon.Common/ResultNames.cs | 2 +- src/Ryujinx.Input/Motion/CemuHook/Client.cs | 5 +- src/Ryujinx/UI/Helpers/ContentDialogHelper.cs | 6 +-- src/Ryujinx/UI/Renderer/EmbeddedWindow.cs | 6 +-- .../UI/ViewModels/MainWindowViewModel.cs | 32 ++++++------- .../UI/ViewModels/TitleUpdateViewModel.cs | 16 +++---- .../UserFirmwareAvatarSelectorViewModel.cs | 2 +- .../UI/ViewModels/UserSaveManagerViewModel.cs | 2 +- .../Settings/SettingsHotkeysView.axaml.cs | 2 +- src/Ryujinx/Updater.cs | 12 ++--- 45 files changed, 150 insertions(+), 171 deletions(-) diff --git a/.editorconfig b/.editorconfig index 76edc491ce..a40ae2e8d3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -236,37 +236,4 @@ dotnet_naming_style.IPascalCase.required_suffix = dotnet_naming_style.IPascalCase.word_separator = dotnet_naming_style.IPascalCase.capitalization = pascal_case -# TODO: -# .NET 8 migration (new warnings are caused by the NET 8 C# compiler and analyzer) -# The following info messages might need to be fixed in the source code instead of hiding the actual message -# Without the following lines, dotnet format would fail -# Disable "Collection initialization can be simplified" -dotnet_diagnostic.IDE0028.severity = none -dotnet_diagnostic.IDE0300.severity = none -dotnet_diagnostic.IDE0301.severity = none -dotnet_diagnostic.IDE0302.severity = none -dotnet_diagnostic.IDE0305.severity = none -# Disable "'new' expression can be simplified" -dotnet_diagnostic.IDE0090.severity = none -# Disable "Use primary constructor" -dotnet_diagnostic.IDE0290.severity = none -# Disable "Member '' does not access instance data and can be marked as static" -dotnet_diagnostic.CA1822.severity = none -# Disable "Change type of field '' from '' to '' for improved performance" -dotnet_diagnostic.CA1859.severity = none -# Disable "Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array" -dotnet_diagnostic.CA1861.severity = none -# Disable "Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'" -dotnet_diagnostic.CA1862.severity = none - -[src/Ryujinx/UI/ViewModels/**.cs] -# Disable "mark members as static" rule for ViewModels -dotnet_diagnostic.CA1822.severity = none - -[src/Ryujinx.HLE/HOS/Services/**.cs] -# Disable "mark members as static" rule for services -dotnet_diagnostic.CA1822.severity = none - -[src/Ryujinx.Tests/Cpu/*.cs] -# Disable naming rules for CPU tests -dotnet_diagnostic.IDE1006.severity = none +dotnet_diagnostic.CA1859.severity = error diff --git a/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs b/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs index 89b1e9e6bb..3f405e326c 100644 --- a/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs +++ b/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs @@ -1,6 +1,7 @@ using ARMeilleure.CodeGen.Linking; using ARMeilleure.CodeGen.RegisterAllocators; using ARMeilleure.IntermediateRepresentation; +using Microsoft.IO; using Ryujinx.Common.Memory; using System; using System.Collections.Generic; @@ -14,7 +15,7 @@ class CodeGenContext private const int CbnzInstLength = 4; private const int LdrLitInstLength = 4; - private readonly Stream _stream; + private readonly RecyclableMemoryStream _stream; public int StreamOffset => (int)_stream.Length; diff --git a/src/ARMeilleure/CodeGen/X86/CodeGenContext.cs b/src/ARMeilleure/CodeGen/X86/CodeGenContext.cs index d4d4c20586..afae3211f8 100644 --- a/src/ARMeilleure/CodeGen/X86/CodeGenContext.cs +++ b/src/ARMeilleure/CodeGen/X86/CodeGenContext.cs @@ -1,5 +1,6 @@ using ARMeilleure.CodeGen.RegisterAllocators; using ARMeilleure.IntermediateRepresentation; +using Microsoft.IO; using Ryujinx.Common.Memory; using System.IO; using System.Numerics; @@ -8,7 +9,7 @@ namespace ARMeilleure.CodeGen.X86 { class CodeGenContext { - private readonly Stream _stream; + private readonly RecyclableMemoryStream _stream; private readonly Operand[] _blockLabels; public int StreamOffset => (int)_stream.Length; diff --git a/src/ARMeilleure/Instructions/InstEmitAluHelper.cs b/src/ARMeilleure/Instructions/InstEmitAluHelper.cs index 4d4a31f7b2..4d1db30a5c 100644 --- a/src/ARMeilleure/Instructions/InstEmitAluHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitAluHelper.cs @@ -266,7 +266,7 @@ public static Operand GetAluM(ArmEmitterContext context, bool setCarry = true) } } - private static Exception InvalidOpCodeType(OpCode opCode) + private static InvalidOperationException InvalidOpCodeType(OpCode opCode) { return new InvalidOperationException($"Invalid OpCode type \"{opCode?.GetType().Name ?? "null"}\"."); } diff --git a/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs b/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs index ace6fe1ce9..bca7399839 100644 --- a/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs @@ -717,7 +717,7 @@ public static Operand GetMemM(ArmEmitterContext context, bool setCarry = true) }; } - private static Exception InvalidOpCodeType(OpCode opCode) + private static InvalidOperationException InvalidOpCodeType(OpCode opCode) { return new InvalidOperationException($"Invalid OpCode type \"{opCode?.GetType().Name ?? "null"}\"."); } diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs index bdb9abd05e..ae1372142e 100644 --- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs +++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs @@ -1,5 +1,6 @@ using ARMeilleure.State; using Humanizer; +using Microsoft.IO; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; @@ -73,7 +74,7 @@ public PtcProfiler(Ptc ptc) Enabled = false; } - private void TimerElapsed(object _, ElapsedEventArgs __) + private void TimerElapsed(object _, ElapsedEventArgs __) => new Thread(PreSave) { Name = "Ptc.DiskWriter" }.Start(); public void AddEntry(ulong address, ExecutionMode mode, bool highCq) @@ -191,7 +192,7 @@ private bool Load(string fileName, bool isBackup) return false; } - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); Debug.Assert(stream.Seek(0L, SeekOrigin.Begin) == 0L && stream.Length == 0L); try diff --git a/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs b/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs index 42ba00cd53..391cc5131f 100644 --- a/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs +++ b/src/Ryujinx.Common/Logging/Targets/ConsoleLogTarget.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Common.Logging.Targets { public class ConsoleLogTarget : ILogTarget { - private readonly ILogFormatter _formatter; + private readonly DefaultLogFormatter _formatter; private readonly string _name; diff --git a/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs b/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs index 94e9359c80..181bd489ac 100644 --- a/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs +++ b/src/Ryujinx.Common/Logging/Targets/FileLogTarget.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Common.Logging.Targets public class FileLogTarget : ILogTarget { private readonly StreamWriter _logWriter; - private readonly ILogFormatter _formatter; + private readonly DefaultLogFormatter _formatter; private readonly string _name; string ILogTarget.Name { get => _name; } diff --git a/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs b/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs index a04c404d8f..8cd3ffb3a2 100644 --- a/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs +++ b/src/Ryujinx.Common/SystemInterop/StdErrAdapter.cs @@ -12,8 +12,8 @@ namespace Ryujinx.Common.SystemInterop public partial class StdErrAdapter : IDisposable { private bool _disposable; - private Stream _pipeReader; - private Stream _pipeWriter; + private FileStream _pipeReader; + private FileStream _pipeWriter; private CancellationTokenSource _cancellationTokenSource; private Task _worker; @@ -46,7 +46,7 @@ private void RegisterPosix() [SupportedOSPlatform("macos")] private async Task EventWorkerAsync(CancellationToken cancellationToken) { - using TextReader reader = new StreamReader(_pipeReader, leaveOpen: true); + using StreamReader reader = new StreamReader(_pipeReader, leaveOpen: true); string line; while (cancellationToken.IsCancellationRequested == false && (line = await reader.ReadLineAsync(cancellationToken)) != null) { @@ -92,7 +92,7 @@ private static (int, int) MakePipe() [SupportedOSPlatform("linux")] [SupportedOSPlatform("macos")] - private static Stream CreateFileDescriptorStream(int fd) + private static FileStream CreateFileDescriptorStream(int fd) { return new FileStream( new SafeFileHandle(fd, ownsHandle: true), diff --git a/src/Ryujinx.Common/Utilities/StreamUtils.cs b/src/Ryujinx.Common/Utilities/StreamUtils.cs index aeb6e0d52a..72492a3232 100644 --- a/src/Ryujinx.Common/Utilities/StreamUtils.cs +++ b/src/Ryujinx.Common/Utilities/StreamUtils.cs @@ -58,7 +58,7 @@ public static MemoryOwner StreamToRentedMemory(Stream input) public static async Task StreamToBytesAsync(Stream input, CancellationToken cancellationToken = default) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); await input.CopyToAsync(stream, cancellationToken); diff --git a/src/Ryujinx.Cpu/LightningJit/Translator.cs b/src/Ryujinx.Cpu/LightningJit/Translator.cs index 4c4011f113..6a4d542cd9 100644 --- a/src/Ryujinx.Cpu/LightningJit/Translator.cs +++ b/src/Ryujinx.Cpu/LightningJit/Translator.cs @@ -55,7 +55,7 @@ public Translator(IMemoryManager memory, AddressTable functionTable) } } - private static IStackWalker CreateStackWalker() + private static StackWalker CreateStackWalker() { if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) { diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs index 22af88d31d..7b69474f30 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs @@ -379,8 +379,8 @@ private bool LoadTocEntries(Stream tocFileStream, ref BinarySerializer reader) /// Code and constant buffer data hash /// Entry index private int WriteNewEntry( - Stream tocFileStream, - Stream dataFileStream, + FileStream tocFileStream, + FileStream dataFileStream, ref TocHeader header, ReadOnlySpan data, ReadOnlySpan cb1Data, diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs index b6b8113892..451bb82bb6 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs @@ -746,7 +746,7 @@ private void WriteHostCode( /// Magic value to be written /// Shader codegen version, only valid for the host file /// File creation timestamp - private static void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp) + private static void CreateToc(FileStream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp) { BinarySerializer writer = new(tocFileStream); diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs index a18b5780e8..8bb19d88e6 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common; using Ryujinx.Common.Memory; using Ryujinx.Graphics.GAL; @@ -12,7 +13,7 @@ static class ShaderBinarySerializer { public static byte[] Pack(ShaderSource[] sources) { - using MemoryStream output = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream output = MemoryStreamManager.Shared.GetStream(); output.Write(sources.Length); diff --git a/src/Ryujinx.Graphics.Metal/HelperShader.cs b/src/Ryujinx.Graphics.Metal/HelperShader.cs index 53f503207a..c16f102c7b 100644 --- a/src/Ryujinx.Graphics.Metal/HelperShader.cs +++ b/src/Ryujinx.Graphics.Metal/HelperShader.cs @@ -19,18 +19,18 @@ class HelperShader : IDisposable private readonly Pipeline _pipeline; private MTLDevice _device; - private readonly ISampler _samplerLinear; - private readonly ISampler _samplerNearest; - private readonly IProgram _programColorBlitF; - private readonly IProgram _programColorBlitI; - private readonly IProgram _programColorBlitU; - private readonly IProgram _programColorBlitMsF; - private readonly IProgram _programColorBlitMsI; - private readonly IProgram _programColorBlitMsU; + private readonly SamplerHolder _samplerLinear; + private readonly SamplerHolder _samplerNearest; + private readonly Program _programColorBlitF; + private readonly Program _programColorBlitI; + private readonly Program _programColorBlitU; + private readonly Program _programColorBlitMsF; + private readonly Program _programColorBlitMsI; + private readonly Program _programColorBlitMsU; private readonly List _programsColorClearF = new(); private readonly List _programsColorClearI = new(); private readonly List _programsColorClearU = new(); - private readonly IProgram _programDepthStencilClear; + private readonly Program _programDepthStencilClear; private readonly IProgram _programStrideChange; private readonly IProgram _programConvertD32S8ToD24S8; private readonly IProgram _programConvertIndexBuffer; diff --git a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs index 54705acafe..01229fbb8d 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs @@ -46,7 +46,7 @@ public AttributeEntry( } } - private static readonly IReadOnlyDictionary _attributes; + private static readonly Dictionary _attributes; private static readonly IReadOnlyDictionary _attributesPerPatch; static AttributeMap() @@ -55,7 +55,7 @@ static AttributeMap() _attributesPerPatch = CreatePerPatchMap(); } - private static IReadOnlyDictionary CreateMap() + private static Dictionary CreateMap() { var map = new Dictionary(); @@ -82,7 +82,7 @@ private static IReadOnlyDictionary CreateMap() return map; } - private static IReadOnlyDictionary CreatePerPatchMap() + private static Dictionary CreatePerPatchMap() { var map = new Dictionary(); diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs index 3ca1266f6b..8b5ab56be6 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs @@ -102,7 +102,7 @@ private static bool DirectlyRelated(AstBlock lBlock, AstBlock rBlock, int lLevel return false; } - IAstNode block; + AstBlock block; IAstNode other; int blockLvl, otherLvl; @@ -441,7 +441,7 @@ private static AstBlock[] BackwardsPath(AstBlock top, AstBlock bottom) return path.ToArray(); } - private static int Level(IAstNode node) + private static int Level(AstBlock node) { int level = 0; diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs index 8a730ef747..29db15ca22 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs @@ -91,7 +91,7 @@ public int AddFunction(Operation baseOp, bool isMultiTarget, IReadOnlyList return functionId; } - public bool TryGetFunctionId(Operation baseOp, bool isMultiTarget, IReadOnlyList targetCbs, out int functionId) + public bool TryGetFunctionId(Operation baseOp, bool isMultiTarget, List targetCbs, out int functionId) { foreach (Entry entry in _entries) { diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs index 6ec90fa3c5..5a3e2077ea 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs @@ -45,7 +45,7 @@ private static bool IsSameOperand(Operand x, Operand y) return x == y || x.Type == OperandType.Constant || x.Type == OperandType.ConstantBuffer; } - private static bool AreAllSourcesEqual(INode node, INode otherNode) + private static bool AreAllSourcesEqual(Operation node, Operation otherNode) { if (node.SourcesCount != otherNode.SourcesCount) { diff --git a/src/Ryujinx.Graphics.Vulkan/HelperShader.cs b/src/Ryujinx.Graphics.Vulkan/HelperShader.cs index b7c42aff0f..4b6f4ad768 100644 --- a/src/Ryujinx.Graphics.Vulkan/HelperShader.cs +++ b/src/Ryujinx.Graphics.Vulkan/HelperShader.cs @@ -32,29 +32,29 @@ class HelperShader : IDisposable private readonly PipelineHelperShader _pipeline; private readonly ISampler _samplerLinear; private readonly ISampler _samplerNearest; - private readonly IProgram _programColorBlit; - private readonly IProgram _programColorBlitMs; - private readonly IProgram _programColorBlitClearAlpha; - private readonly IProgram _programColorClearF; - private readonly IProgram _programColorClearSI; - private readonly IProgram _programColorClearUI; - private readonly IProgram _programDepthStencilClear; - private readonly IProgram _programStrideChange; - private readonly IProgram _programConvertD32S8ToD24S8; - private readonly IProgram _programConvertIndexBuffer; - private readonly IProgram _programConvertIndirectData; - private readonly IProgram _programColorCopyShortening; - private readonly IProgram _programColorCopyToNonMs; - private readonly IProgram _programColorCopyWidening; - private readonly IProgram _programColorDrawToMs; - private readonly IProgram _programDepthBlit; - private readonly IProgram _programDepthBlitMs; - private readonly IProgram _programDepthDrawToMs; - private readonly IProgram _programDepthDrawToNonMs; - private readonly IProgram _programStencilBlit; - private readonly IProgram _programStencilBlitMs; - private readonly IProgram _programStencilDrawToMs; - private readonly IProgram _programStencilDrawToNonMs; + private readonly ShaderCollection _programColorBlit; + private readonly ShaderCollection _programColorBlitMs; + private readonly ShaderCollection _programColorBlitClearAlpha; + private readonly ShaderCollection _programColorClearF; + private readonly ShaderCollection _programColorClearSI; + private readonly ShaderCollection _programColorClearUI; + private readonly ShaderCollection _programDepthStencilClear; + private readonly ShaderCollection _programStrideChange; + private readonly ShaderCollection _programConvertD32S8ToD24S8; + private readonly ShaderCollection _programConvertIndexBuffer; + private readonly ShaderCollection _programConvertIndirectData; + private readonly ShaderCollection _programColorCopyShortening; + private readonly ShaderCollection _programColorCopyToNonMs; + private readonly ShaderCollection _programColorCopyWidening; + private readonly ShaderCollection _programColorDrawToMs; + private readonly ShaderCollection _programDepthBlit; + private readonly ShaderCollection _programDepthBlitMs; + private readonly ShaderCollection _programDepthDrawToMs; + private readonly ShaderCollection _programDepthDrawToNonMs; + private readonly ShaderCollection _programStencilBlit; + private readonly ShaderCollection _programStencilBlitMs; + private readonly ShaderCollection _programStencilDrawToMs; + private readonly ShaderCollection _programStencilDrawToNonMs; public HelperShader(VulkanRenderer gd, Device device) { diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index ec0f58b011..8f55cb46a2 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -641,7 +641,7 @@ private static IFile OpenPossibleFragmentedFile(IFileSystem filesystem, string p return file.Release(); } - private static Stream GetZipStream(ZipArchiveEntry entry) + private static MemoryStream GetZipStream(ZipArchiveEntry entry) { MemoryStream dest = MemoryStreamManager.Shared.GetStream(); @@ -1058,7 +1058,7 @@ public void VerifyKeysFile(string filePath) } return; - + bool VerifyKeys(string[] lines, string regex) { foreach (string line in lines) @@ -1071,7 +1071,7 @@ bool VerifyKeys(string[] lines, string regex) return true; } } - + public bool AreKeysAlredyPresent(string pathToCheck) { string[] fileNames = { "prod.keys", "title.keys", "console.keys", "dev.keys" }; diff --git a/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs index c5f13dab31..22c6a94667 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Browser/BrowserApplet.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; @@ -63,7 +64,7 @@ public ResultCode Start(AppletSession normalSession, AppletSession interactiveSe private static byte[] BuildResponseOld(WebCommonReturnValue result) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(result); @@ -71,7 +72,7 @@ private static byte[] BuildResponseOld(WebCommonReturnValue result) } private byte[] BuildResponseNew(List outputArguments) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(new WebArgHeader { diff --git a/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs index 3a7b29ab55..6b11f2cdda 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Controller/ControllerApplet.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Services.Am.AppletAE; @@ -119,7 +120,7 @@ public ResultCode Start(AppletSession normalSession, AppletSession interactiveSe private static byte[] BuildResponse(ControllerSupportResultInfo result) { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write(MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(ref result, Unsafe.SizeOf()))); @@ -129,7 +130,7 @@ private static byte[] BuildResponse(ControllerSupportResultInfo result) private static byte[] BuildResponse() { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write((ulong)ResultCode.Success); diff --git a/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs b/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs index 6b16aee7bf..3de98bb93c 100644 --- a/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/Dummy/DummyApplet.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Applets; @@ -11,14 +12,14 @@ internal class DummyApplet : IApplet { private readonly Horizon _system; private AppletSession _normalSession; - + public event EventHandler AppletStateChanged; - + public DummyApplet(Horizon system) { _system = system; } - + public ResultCode Start(AppletSession normalSession, AppletSession interactiveSession) { _normalSession = normalSession; @@ -27,10 +28,10 @@ public ResultCode Start(AppletSession normalSession, AppletSession interactiveSe _system.ReturnFocus(); return ResultCode.Success; } - + private static byte[] BuildResponse() { - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write((ulong)ResultCode.Success); return stream.ToArray(); diff --git a/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs b/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs index 05bddc76f4..3ca2c65a3c 100644 --- a/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Services.Account.Acc; using Ryujinx.HLE.HOS.Services.Am.AppletAE; @@ -41,7 +42,7 @@ private byte[] BuildResponse() { UserProfile currentUser = _system.AccountManager.LastOpenedUser; - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.Write((ulong)PlayerSelectResult.Success); diff --git a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs index 2e7b8ee763..499673f18e 100644 --- a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs +++ b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs @@ -252,7 +252,7 @@ private BaseNode ParseClassEnumType() // ::= Do # non-throwing exception-specification (e.g., noexcept, throw()) // ::= DO E # computed (instantiation-dependent) noexcept // ::= Dw + E # dynamic exception specification with instantiation-dependent types - private BaseNode ParseFunctionType() + private FunctionType ParseFunctionType() { Cv cvQualifiers = ParseCvQualifiers(); @@ -347,7 +347,7 @@ private BaseNode ParseFunctionType() // ::= A _ // ::= A [] _ - private BaseNode ParseArrayType() + private ArrayType ParseArrayType() { if (!ConsumeIf("A")) { @@ -945,7 +945,7 @@ private string ParseNumber(bool isSigned = false) } // ::= - private BaseNode ParseSourceName() + private NameType ParseSourceName() { int length = ParsePositiveNumber(); if (Count() < length || length <= 0) @@ -1320,7 +1320,7 @@ private BaseNode ParseUnqualifiedName(NameParserContext context) // ::= D0 # deleting destructor // ::= D1 # complete object destructor // ::= D2 # base object destructor - private BaseNode ParseCtorDtorName(NameParserContext context, BaseNode prev) + private CtorDtorNameType ParseCtorDtorName(NameParserContext context, BaseNode prev) { if (prev.Type == NodeType.SpecialSubstitution && prev is SpecialSubstitution substitution) { @@ -1377,7 +1377,7 @@ private BaseNode ParseCtorDtorName(NameParserContext context, BaseNode prev) // ::= fp _ # L == 0, second and later parameters // ::= fL p _ # L > 0, first parameter // ::= fL p _ # L > 0, second and later parameters - private BaseNode ParseFunctionParameter() + private FunctionParameter ParseFunctionParameter() { if (ConsumeIf("fp")) { @@ -1422,7 +1422,7 @@ private BaseNode ParseFunctionParameter() // ::= fR // ::= fl // ::= fr - private BaseNode ParseFoldExpression() + private FoldExpression ParseFoldExpression() { if (!ConsumeIf("f")) { @@ -1571,7 +1571,7 @@ private BaseNode ParseFoldExpression() // ::= cv # type (expression), conversion with one argument // ::= cv _ * E # type (expr-list), conversion with other than one argument - private BaseNode ParseConversionExpression() + private ConversionExpression ParseConversionExpression() { if (!ConsumeIf("cv")) { @@ -1616,7 +1616,7 @@ private BaseNode ParseConversionExpression() return new ConversionExpression(type, new NodeArray(expressions)); } - private BaseNode ParseBinaryExpression(string name) + private BinaryExpression ParseBinaryExpression(string name) { BaseNode leftPart = ParseExpression(); if (leftPart == null) @@ -1633,7 +1633,7 @@ private BaseNode ParseBinaryExpression(string name) return new BinaryExpression(leftPart, name, rightPart); } - private BaseNode ParsePrefixExpression(string name) + private PrefixExpression ParsePrefixExpression(string name) { BaseNode expression = ParseExpression(); if (expression == null) @@ -1720,7 +1720,7 @@ private BaseNode ParseBracedExpression() // ::= [gs] na * _ # new[] (expr-list) type (init) // // ::= pi * E # parenthesized initialization - private BaseNode ParseNewExpression() + private NewExpression ParseNewExpression() { bool isGlobal = ConsumeIf("gs"); bool isArray = Peek(1) == 'a'; @@ -2404,7 +2404,7 @@ private BaseNode ParseExpression() return null; } - private BaseNode ParseIntegerLiteral(string literalName) + private IntegerLiteral ParseIntegerLiteral(string literalName) { string number = ParseNumber(true); if (number == null || number.Length == 0 || !ConsumeIf("E")) @@ -2521,7 +2521,7 @@ private BaseNode ParseExpressionPrimary() // ::= Dt E # decltype of an id-expression or class member access (C++0x) // ::= DT E # decltype of an expression (C++0x) - private BaseNode ParseDecltype() + private EnclosedExpression ParseDecltype() { if (!ConsumeIf("D") || (!ConsumeIf("t") && !ConsumeIf("T"))) { @@ -2588,7 +2588,7 @@ private BaseNode ParseTemplateParam() } // ::= I + E - private BaseNode ParseTemplateArguments(bool hasContext = false) + private TemplateArguments ParseTemplateArguments(bool hasContext = false) { if (!ConsumeIf("I")) { @@ -2740,7 +2740,7 @@ private BaseNode ParseSimpleId() // ::= # e.g., ~T or ~decltype(f()) // ::= # e.g., ~A<2*N> - private BaseNode ParseDestructorName() + private DtorName ParseDestructorName() { BaseNode node; if (char.IsDigit(Peek())) @@ -3134,7 +3134,7 @@ private void ParseDiscriminator() // ::= Z E [] // ::= Z E s [] // ::= Z Ed [ ] _ - private BaseNode ParseLocalName(NameParserContext context) + private LocalName ParseLocalName(NameParserContext context) { if (!ConsumeIf("Z")) { diff --git a/src/Ryujinx.HLE/HOS/ModLoader.cs b/src/Ryujinx.HLE/HOS/ModLoader.cs index 4bd695ae5d..a2406d63f2 100644 --- a/src/Ryujinx.HLE/HOS/ModLoader.cs +++ b/src/Ryujinx.HLE/HOS/ModLoader.cs @@ -534,7 +534,7 @@ internal IStorage ApplyRomFsMods(ulong applicationId, IStorage baseStorage) return newStorage; } - private static void AddFiles(IFileSystem fs, string modName, string rootPath, ISet fileSet, RomFsBuilder builder) + private static void AddFiles(IFileSystem fs, string modName, string rootPath, HashSet fileSet, RomFsBuilder builder) { foreach (var entry in fs.EnumerateEntries() .AsParallel() diff --git a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs index 6c23720eef..d968773624 100644 --- a/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs +++ b/src/Ryujinx.HLE/HOS/Services/Am/AppletAE/Storage/StorageHelper.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common.Memory; using Ryujinx.HLE.HOS.Services.Account.Acc; using System.IO; @@ -11,7 +12,7 @@ class StorageHelper public static byte[] MakeLaunchParams(UserProfile userProfile) { // Size needs to be at least 0x88 bytes otherwise application errors. - using MemoryStream ms = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream ms = MemoryStreamManager.Shared.GetStream(); BinaryWriter writer = new(ms); ms.SetLength(0x88); diff --git a/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs b/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs index 5b5b3bf843..4c677b4071 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ro/IRoInterface.cs @@ -313,7 +313,7 @@ private ResultCode MapCodeMemoryInProcess(KProcess process, ulong baseAddress, u return ResultCode.Success; } - private Result SetNroMemoryPermissions(KProcess process, IExecutable relocatableObject, ulong baseAddress) + private Result SetNroMemoryPermissions(KProcess process, NroExecutable relocatableObject, ulong baseAddress) { ulong textStart = baseAddress + relocatableObject.TextOffset; ulong roStart = baseAddress + relocatableObject.RoOffset; diff --git a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs index ea3bd84dfc..5a1996ca47 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sdb/Pl/SharedFontManager.cs @@ -5,6 +5,7 @@ using LibHac.Ncm; using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem.NcaUtils; +using Microsoft.IO; using Ryujinx.Common.Memory; using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.FileSystem; @@ -161,7 +162,7 @@ private byte[] DecryptFont(Stream bfttfStream) static uint KXor(uint data) => data ^ FontKey; using BinaryReader reader = new(bfttfStream); - using MemoryStream ttfStream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream ttfStream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter output = new(ttfStream); if (KXor(reader.ReadUInt32()) != BFTTFMagic) diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index f67699b90d..9db59108fd 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common; using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; @@ -46,10 +47,10 @@ class ServerBase : IDisposable private readonly Dictionary _sessions = new(); private readonly Dictionary> _ports = new(); - private readonly MemoryStream _requestDataStream; + private readonly RecyclableMemoryStream _requestDataStream; private readonly BinaryReader _requestDataReader; - private readonly MemoryStream _responseDataStream; + private readonly RecyclableMemoryStream _responseDataStream; private readonly BinaryWriter _responseDataWriter; private int _isDisposed = 0; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 3a40a4ac55..ae5d8a41e5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -95,7 +95,7 @@ private ResultCode SocketInternal(ServiceCtx context, bool exempt) } } - ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId) + ManagedSocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId) { Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking), }; diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index 981fe0a8f1..93cd34069d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -415,7 +415,7 @@ private bool CanSupportMMsgHdr(BsdMMsgHdr message) return true; } - private static IList> ConvertMessagesToBuffer(BsdMMsgHdr message) + private static ArraySegment[] ConvertMessagesToBuffer(BsdMMsgHdr message) { int segmentCount = 0; int index = 0; diff --git a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs index b5c608d3d0..ea2f2188ce 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs @@ -21,7 +21,7 @@ class ISslConnection : IpcService, IDisposable private SessionCacheMode _sessionCacheMode; private string _hostName; - private ISslConnectionBase _connection; + private SslManagedSocketConnection _connection; private BsdContext _bsdContext; private readonly ulong _processId; diff --git a/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs b/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs index e25ba7a553..a63a96c02d 100644 --- a/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs +++ b/src/Ryujinx.HLE/HOS/Tamper/AtmosphereCompiler.cs @@ -54,7 +54,7 @@ public ITamperProgram Compile(string name, IEnumerable rawInstructions) return null; } - private ITamperProgram CompileImpl(string name, IEnumerable rawInstructions) + private AtmosphereProgram CompileImpl(string name, IEnumerable rawInstructions) { CompilationContext context = new(_exeAddress, _heapAddress, _aliasAddress, _aslrAddress, _process); context.BlockStack.Push(new OperationBlock(null)); diff --git a/src/Ryujinx.Horizon.Common/ResultNames.cs b/src/Ryujinx.Horizon.Common/ResultNames.cs index 25d04b3089..8c9ba48355 100644 --- a/src/Ryujinx.Horizon.Common/ResultNames.cs +++ b/src/Ryujinx.Horizon.Common/ResultNames.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Horizon.Common static class ResultNames { // Reference: https://github.com/Thealexbarney/LibHac/blob/master/build/CodeGen/results.csv - private static readonly IReadOnlyDictionary _names = new Dictionary() + private static readonly Dictionary _names = new Dictionary() { { 0x0, "Success" }, { 0xE01, "OutOfSessions" }, diff --git a/src/Ryujinx.Input/Motion/CemuHook/Client.cs b/src/Ryujinx.Input/Motion/CemuHook/Client.cs index e19f3d847f..b1f78baeec 100644 --- a/src/Ryujinx.Input/Motion/CemuHook/Client.cs +++ b/src/Ryujinx.Input/Motion/CemuHook/Client.cs @@ -1,3 +1,4 @@ +using Microsoft.IO; using Ryujinx.Common; using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid.Controller; @@ -380,7 +381,7 @@ public void RequestInfo(int clientId, int slot) Header header = GenerateHeader(clientId); - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(header); @@ -419,7 +420,7 @@ public void RequestData(int clientId, int slot) Header header = GenerateHeader(clientId); - using MemoryStream stream = MemoryStreamManager.Shared.GetStream(); + using RecyclableMemoryStream stream = MemoryStreamManager.Shared.GetStream(); using BinaryWriter writer = new(stream); writer.WriteStruct(header); diff --git a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs index 3f0f0f0334..19d9d4e612 100644 --- a/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs +++ b/src/Ryujinx/UI/Helpers/ContentDialogHelper.cs @@ -261,7 +261,7 @@ internal static async Task CreateUpdaterInfoDialog(string primary, string second string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Important); - + internal static async Task CreateUpdaterUpToDateInfoDialog(string primary, string secondaryText) => await ShowTextDialog( LocaleManager.Instance[LocaleKeys.DialogUpdaterTitle], @@ -319,7 +319,7 @@ internal static async Task CreateChoiceDialog(string title, string primary return response == UserResult.Yes; } - + internal static async Task CreateUpdaterChoiceDialog(string title, string primary, string secondaryText) { if (_isChoiceDialogOpen) @@ -456,7 +456,7 @@ public static async Task ShowWindowAsync(Window dialogWindow, Window mainWindow await dialogWindow.ShowDialog(_contentDialogOverlayWindow ?? mainWindow ?? GetMainWindow()); } - private static Window GetMainWindow() + private static MainWindow GetMainWindow() { if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime al) { diff --git a/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs b/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs index eea9be2836..fdb2005472 100644 --- a/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs +++ b/src/Ryujinx/UI/Renderer/EmbeddedWindow.cs @@ -116,7 +116,7 @@ protected override void DestroyNativeControlCore(IPlatformHandle control) } [SupportedOSPlatform("linux")] - private IPlatformHandle CreateLinux(IPlatformHandle control) + private PlatformHandle CreateLinux(IPlatformHandle control) { if (ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan) { @@ -135,7 +135,7 @@ private IPlatformHandle CreateLinux(IPlatformHandle control) } [SupportedOSPlatform("windows")] - IPlatformHandle CreateWin32(IPlatformHandle control) + PlatformHandle CreateWin32(IPlatformHandle control) { _className = "NativeWindow-" + Guid.NewGuid(); @@ -172,7 +172,7 @@ IPlatformHandle CreateWin32(IPlatformHandle control) } [SupportedOSPlatform("macos")] - IPlatformHandle CreateMacOS() + PlatformHandle CreateMacOS() { // Create a new CAMetalLayer. ObjectiveC.Object layerObject = new("CAMetalLayer"); diff --git a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs index e11d855a6d..1726cf1bd0 100644 --- a/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/MainWindowViewModel.cs @@ -105,7 +105,7 @@ public partial class MainWindowViewModel : BaseModel [ObservableProperty] private bool _isSubMenuOpen; [ObservableProperty] private ApplicationContextMenu _listAppContextMenu; [ObservableProperty] private ApplicationContextMenu _gridAppContextMenu; - + private bool _showLoadProgress; private bool _isGameRunning; private bool _isAmiiboRequested; @@ -126,7 +126,7 @@ public partial class MainWindowViewModel : BaseModel private int _customVSyncIntervalPercentageProxy; private ApplicationData _listSelectedApplication; private ApplicationData _gridSelectedApplication; - + // Key is Title ID public SafeDictionary LdnData = []; @@ -299,7 +299,7 @@ public bool ShowLoadProgress OnPropertyChanged(nameof(ShowFirmwareStatus)); } } - + public ApplicationData ListSelectedApplication { get => _listSelectedApplication; @@ -332,7 +332,7 @@ public ApplicationData GridSelectedApplication else if (_gridSelectedApplication == null && _gridAppContextMenu != null) GridAppContextMenu = null!; #pragma warning restore MVVMTK0034 - + OnPropertyChanged(); } } @@ -358,7 +358,7 @@ public ApplicationData SelectedApplication public bool OpenBcatSaveDirectoryEnabled => SelectedApplication.HasControlHolder && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0; - public bool ShowCustomVSyncIntervalPicker + public bool ShowCustomVSyncIntervalPicker => _isGameRunning && AppHost.Device.VSyncMode == VSyncMode.Custom; public void UpdateVSyncIntervalPicker() @@ -529,7 +529,7 @@ public Glyph Glyph public bool ShowNames { - get => ConfigurationState.Instance.UI.ShowNames && ConfigurationState.Instance.UI.GridSize > 1; + get => ConfigurationState.Instance.UI.ShowNames && ConfigurationState.Instance.UI.GridSize > 1; set { ConfigurationState.Instance.UI.ShowNames.Value = value; @@ -710,7 +710,7 @@ public KeyGesture PauseKey #region PrivateMethods - private static IComparer CreateComparer(bool ascending, Func selector) => + private static SortExpressionComparer CreateComparer(bool ascending, Func selector) => ascending ? SortExpressionComparer.Ascending(selector) : SortExpressionComparer.Descending(selector); @@ -818,10 +818,10 @@ private async Task HandleFirmwareInstallation(string filename) string message = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogFirmwareInstallerFirmwareInstallSuccessMessage, firmwareVersion.VersionString); await ContentDialogHelper.CreateInfoDialog( - dialogTitle, - message, - LocaleManager.Instance[LocaleKeys.InputDialogOk], - string.Empty, + dialogTitle, + message, + LocaleManager.Instance[LocaleKeys.InputDialogOk], + string.Empty, LocaleManager.Instance[LocaleKeys.RyujinxInfo]); Logger.Info?.Print(LogClass.Application, message); @@ -1134,11 +1134,11 @@ await Dispatcher.UIThread.InvokeAsync(async () => { await ContentDialogHelper.ShowTextDialog( LocaleManager.Instance[numAdded > 0 || numRemoved > 0 ? LocaleKeys.RyujinxConfirm : LocaleKeys.RyujinxInfo], - msg, - string.Empty, - string.Empty, - string.Empty, - LocaleManager.Instance[LocaleKeys.InputDialogOk], + msg, + string.Empty, + string.Empty, + string.Empty, + LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark); }); } diff --git a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs index 86d59d6b42..a6b6789d5a 100644 --- a/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/TitleUpdateViewModel.cs @@ -179,17 +179,17 @@ public void Save() ApplicationLibrary.SaveTitleUpdatesForGame(ApplicationData, updates); } - private Task ShowNewUpdatesAddedDialog(int numAdded) + private Task ShowNewUpdatesAddedDialog(int numAdded) { var msg = string.Format(LocaleManager.Instance[LocaleKeys.UpdateWindowUpdateAddedMessage], numAdded); - return Dispatcher.UIThread.InvokeAsync(async () => + return Dispatcher.UIThread.InvokeAsync(async () => await ContentDialogHelper.ShowTextDialog( - LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], - msg, - string.Empty, - string.Empty, - string.Empty, - LocaleManager.Instance[LocaleKeys.InputDialogOk], + LocaleManager.Instance[LocaleKeys.DialogConfirmationTitle], + msg, + string.Empty, + string.Empty, + string.Empty, + LocaleManager.Instance[LocaleKeys.InputDialogOk], (int)Symbol.Checkmark )); } diff --git a/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs b/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs index 29c81308b8..ca5fe4ff89 100644 --- a/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/UserFirmwareAvatarSelectorViewModel.cs @@ -128,7 +128,7 @@ public static void PreloadAvatars(ContentManager contentManager, VirtualFileSyst } } - private static byte[] DecompressYaz0(Stream stream) + private static byte[] DecompressYaz0(MemoryStream stream) { using BinaryReader reader = new(stream); diff --git a/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs b/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs index 187df04493..226cd4c7e8 100644 --- a/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/UserSaveManagerViewModel.cs @@ -60,7 +60,7 @@ private bool Filter(object arg) return false; } - private IComparer GetComparer() + private SortExpressionComparer GetComparer() { return SortIndex switch { diff --git a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs index 609f616335..7ca11c5858 100644 --- a/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs +++ b/src/Ryujinx/UI/Views/Settings/SettingsHotkeysView.axaml.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Ava.UI.Views.Settings public partial class SettingsHotkeysView : UserControl { private ButtonKeyAssigner _currentAssigner; - private readonly IGamepadDriver _avaloniaKeyboardDriver; + private readonly AvaloniaKeyboardDriver _avaloniaKeyboardDriver; public SettingsHotkeysView() { diff --git a/src/Ryujinx/Updater.cs b/src/Ryujinx/Updater.cs index 3e3989c66a..69434a8c66 100644 --- a/src/Ryujinx/Updater.cs +++ b/src/Ryujinx/Updater.cs @@ -32,9 +32,9 @@ namespace Ryujinx.Ava internal static class Updater { private const string GitHubApiUrl = "https://api.github.com"; - private const string LatestReleaseUrl = + private const string LatestReleaseUrl = $"{GitHubApiUrl}/repos/{ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelRepo}/releases/latest"; - + private static readonly GithubReleasesJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly string _homeDir = AppDomain.CurrentDomain.BaseDirectory; @@ -92,7 +92,7 @@ await ContentDialogHelper.CreateWarningDialog( try { using HttpClient jsonClient = ConstructHttpClient(); - + string fetchedJson = await jsonClient.GetStringAsync(LatestReleaseUrl); var fetched = JsonHelper.Deserialize(fetchedJson, _serializerContext.GithubReleasesJsonResponse); _buildVer = fetched.TagName; @@ -213,7 +213,7 @@ await Dispatcher.UIThread.InvokeAsync(async () => string newVersionString = ReleaseInformation.IsCanaryBuild ? $"Canary {currentVersion} -> Canary {newVersion}" : $"{currentVersion} -> {newVersion}"; - + RequestUserToUpdate: // Show a message asking the user if they want to update UserResult shouldUpdate = await ContentDialogHelper.CreateUpdaterChoiceDialog( @@ -472,7 +472,7 @@ private static void DoUpdateWithSingleThreadWorker(TaskDialog taskDialog, string using HttpResponseMessage response = client.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead).Result; using Stream remoteFileStream = response.Content.ReadAsStreamAsync().Result; - using Stream updateFileStream = File.Open(updateFile, FileMode.Create); + using FileStream updateFileStream = File.Open(updateFile, FileMode.Create); long totalBytes = response.Content.Headers.ContentLength.Value; long bytesWritten = 0; @@ -519,7 +519,7 @@ private static void DoUpdateWithSingleThread(TaskDialog taskDialog, string downl [SupportedOSPlatform("macos")] private static void ExtractTarGzipFile(TaskDialog taskDialog, string archivePath, string outputDirectoryPath) { - using Stream inStream = File.OpenRead(archivePath); + using FileStream inStream = File.OpenRead(archivePath); using GZipInputStream gzipStream = new(inStream); using TarInputStream tarStream = new(gzipStream, Encoding.ASCII);