From 4da44e09cb2a32f69b4a6b47221117b78e4618dc Mon Sep 17 00:00:00 2001 From: Andrey Sukharev Date: Mon, 5 Dec 2022 16:47:39 +0300 Subject: [PATCH] Make structs readonly when applicable (#4002) * Make all structs readonly when applicable. It should reduce amount of needless defensive copies * Make structs with trivial boilerplate equality code record structs * Remove unnecessary readonly modifiers from TextureCreateInfo * Make BitMap structs readonly too --- .editorconfig | 1 + .../RegisterAllocators/AllocationResult.cs | 2 +- .../RegisterAllocators/CopyResolver.cs | 2 +- .../RegisterAllocators/HybridAllocator.cs | 2 +- .../RegisterAllocators/RegisterMasks.cs | 2 +- ARMeilleure/CodeGen/X86/IntrinsicInfo.cs | 2 +- ARMeilleure/Decoders/InstDescriptor.cs | 2 +- ARMeilleure/Decoders/OpCodeTable.cs | 2 +- ARMeilleure/Diagnostics/Symbols.cs | 2 +- .../PhiOperation.cs | 2 +- .../IntermediateRepresentation/Register.cs | 2 +- ARMeilleure/Translation/Cache/CacheEntry.cs | 2 +- .../Translation/Cache/CacheMemoryAllocator.cs | 2 +- ARMeilleure/Translation/CompilerContext.cs | 2 +- ARMeilleure/Translation/RegisterUsage.cs | 2 +- ARMeilleure/Translation/Translator.cs | 2 +- .../Native/libsoundio/SoundIOChannelLayout.cs | 2 +- .../libsoundio/SoundIOSampleRateRange.cs | 2 +- Ryujinx.Ava/Ui/Windows/IconColorPicker.cs | 2 +- Ryujinx.Common/Logging/Logger.cs | 2 +- Ryujinx.Common/Memory/SpanOrArray.cs | 2 +- Ryujinx.Cpu/ExceptionCallbacks.cs | 2 +- Ryujinx.Graphics.Device/RwCallback.cs | 2 +- Ryujinx.Graphics.GAL/BlendDescriptor.cs | 2 +- Ryujinx.Graphics.GAL/BufferAssignment.cs | 2 +- Ryujinx.Graphics.GAL/BufferHandle.cs | 12 +----- Ryujinx.Graphics.GAL/BufferRange.cs | 2 +- Ryujinx.Graphics.GAL/Capabilities.cs | 2 +- Ryujinx.Graphics.GAL/ColorF.cs | 30 +-------------- Ryujinx.Graphics.GAL/DepthTestDescriptor.cs | 2 +- Ryujinx.Graphics.GAL/DeviceInfo.cs | 2 +- Ryujinx.Graphics.GAL/Extents2D.cs | 2 +- Ryujinx.Graphics.GAL/Extents2DF.cs | 2 +- Ryujinx.Graphics.GAL/HardwareInfo.cs | 2 +- Ryujinx.Graphics.GAL/ImageCrop.cs | 2 +- Ryujinx.Graphics.GAL/MultisampleDescriptor.cs | 2 +- Ryujinx.Graphics.GAL/ProgramPipelineState.cs | 2 +- Ryujinx.Graphics.GAL/Rectangle.cs | 2 +- Ryujinx.Graphics.GAL/SamplerCreateInfo.cs | 2 +- .../ScreenCaptureImageInfo.cs | 2 +- Ryujinx.Graphics.GAL/ShaderBindings.cs | 2 +- Ryujinx.Graphics.GAL/ShaderSource.cs | 2 +- Ryujinx.Graphics.GAL/StencilTestDescriptor.cs | 2 +- Ryujinx.Graphics.GAL/TextureCreateInfo.cs | 20 +++++----- .../VertexAttribDescriptor.cs | 38 +------------------ .../VertexBufferDescriptor.cs | 2 +- Ryujinx.Graphics.GAL/Viewport.cs | 2 +- Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs | 2 +- .../Engine/MME/MacroHLETable.cs | 2 +- .../Engine/Threed/StateUpdateTracker.cs | 2 +- Ryujinx.Graphics.Gpu/Image/FormatInfo.cs | 2 +- .../Image/TextureBindingInfo.cs | 2 +- Ryujinx.Graphics.Gpu/Image/TextureCache.cs | 2 +- Ryujinx.Graphics.Gpu/Image/TextureGroup.cs | 2 +- Ryujinx.Graphics.Gpu/Image/TextureInfo.cs | 2 +- Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs | 2 +- .../Memory/BufferTextureBinding.cs | 2 +- Ryujinx.Graphics.Gpu/Memory/CounterCache.cs | 2 +- .../DiskCache/BackgroundDiskCacheWriter.cs | 4 +- .../Shader/DiskCache/GuestCodeAndCbData.cs | 2 +- .../DiskCache/ParallelDiskCacheLoader.cs | 6 +-- .../Shader/GpuChannelComputeState.cs | 2 +- .../Shader/GpuChannelPoolState.cs | 2 +- .../Shader/HashTable/PartitionedHashTable.cs | 2 +- Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 6 +-- .../Shader/ShaderCodeAccessor.cs | 2 +- .../Shader/ShaderDumpPaths.cs | 2 +- .../Shader/ShaderSpecializationState.cs | 17 +-------- Ryujinx.Graphics.Gpu/Window.cs | 2 +- Ryujinx.Graphics.Host1x/Host1xDevice.cs | 2 +- Ryujinx.Graphics.Host1x/SyncptIncrManager.cs | 2 +- .../FrameDecodedEventArgs.cs | 2 +- Ryujinx.Graphics.Nvdec/ResourceManager.cs | 2 +- Ryujinx.Graphics.OpenGL/FormatInfo.cs | 2 +- .../CodeGen/Glsl/Instructions/InstInfo.cs | 2 +- .../CodeGen/Glsl/OperandManager.cs | 2 +- .../CodeGen/Spirv/OperationResult.cs | 2 +- .../CodeGen/Spirv/SpirvDelegates.cs | 2 +- .../CodeGen/Spirv/TextureMeta.cs | 33 +--------------- Ryujinx.Graphics.Shader/Decoders/Block.cs | 2 +- .../Decoders/DecodedProgram.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/Decoder.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/InstTable.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/Register.cs | 2 +- .../StructuredIr/InstructionInfo.cs | 2 +- .../StructuredIr/StructuredProgramInfo.cs | 2 +- .../Translation/AttributeInfo.cs | 2 +- .../Translation/EmitterContext.cs | 2 +- .../Translation/FunctionMatch.cs | 4 +- .../Translation/RegisterUsage.cs | 2 +- .../Translation/ShaderConfig.cs | 31 +-------------- .../Translation/ShaderHeader.cs | 2 +- Ryujinx.Graphics.Shader/Translation/Ssa.cs | 2 +- .../Translation/TranslationOptions.cs | 2 +- .../Translation/Translator.cs | 2 +- Ryujinx.Graphics.Texture/Region.cs | 2 +- Ryujinx.Graphics.Texture/Size.cs | 2 +- Ryujinx.Graphics.Texture/SizeInfo.cs | 2 +- Ryujinx.Graphics.Texture/Utils/BC7ModeInfo.cs | 2 +- Ryujinx.Graphics.Vic/Image/Surface.cs | 2 +- Ryujinx.Graphics.Vic/Rectangle.cs | 2 +- Ryujinx.Graphics.Vic/ResourceManager.cs | 2 +- Ryujinx.Graphics.Video/Plane.cs | 38 +------------------ Ryujinx.Graphics.Vulkan/BitMap.cs | 2 +- Ryujinx.Graphics.Vulkan/BufferState.cs | 2 +- Ryujinx.Graphics.Vulkan/CacheByRange.cs | 4 +- .../CommandBufferScoped.cs | 2 +- Ryujinx.Graphics.Vulkan/DisposableBuffer.cs | 2 +- .../DisposableBufferView.cs | 2 +- .../DisposableFramebuffer.cs | 2 +- Ryujinx.Graphics.Vulkan/DisposableImage.cs | 2 +- .../DisposableImageView.cs | 2 +- Ryujinx.Graphics.Vulkan/DisposableMemory.cs | 2 +- Ryujinx.Graphics.Vulkan/DisposablePipeline.cs | 2 +- .../DisposableRenderPass.cs | 2 +- Ryujinx.Graphics.Vulkan/DisposableSampler.cs | 2 +- .../HardwareCapabilities.cs | 2 +- Ryujinx.Graphics.Vulkan/MemoryAllocation.cs | 2 +- .../MemoryAllocatorBlockList.cs | 2 +- Ryujinx.Graphics.Vulkan/StagingBuffer.cs | 2 +- Ryujinx.HLE/HOS/Kernel/Common/KernelInit.cs | 2 +- Ryujinx.HLE/HOS/Kernel/Common/OnScopeExit.cs | 2 +- Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs | 4 +- .../HOS/Kernel/Process/ProcessCreationInfo.cs | 2 +- Ryujinx.HLE/HOS/ModLoader.cs | 2 +- .../HOS/Services/Account/Acc/Types/UserId.cs | 31 ++------------- .../NvHostAsGpu/NvHostAsGpuDeviceFile.cs | 2 +- Ryujinx.HLE/HOS/Tamper/OperationBlock.cs | 2 +- Ryujinx.HLE/Ui/ThemeColor.cs | 2 +- .../Kernel/SyscallGenerator.cs | 4 +- Ryujinx.Memory/Range/MemoryRange.cs | 21 +--------- Ryujinx.Memory/Range/MultiRange.cs | 2 +- Ryujinx.Memory/Tracking/BitMap.cs | 2 +- 133 files changed, 156 insertions(+), 378 deletions(-) diff --git a/.editorconfig b/.editorconfig index 214e54692b..9e00e3bae7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -89,6 +89,7 @@ csharp_style_conditional_delegate_call = true:suggestion # Modifier preferences csharp_prefer_static_local_function = true:suggestion csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent +csharp_style_prefer_readonly_struct = true # Code-block preferences csharp_prefer_braces = true:silent diff --git a/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs b/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs index 94ac6991b0..43e5c7e2c9 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs @@ -1,6 +1,6 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { - struct AllocationResult + readonly struct AllocationResult { public int IntUsedRegisters { get; } public int VecUsedRegisters { get; } diff --git a/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs b/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs index df4b6db1ba..587b1a024d 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { private class ParallelCopy { - private struct Copy + private readonly struct Copy { public Register Dest { get; } public Register Source { get; } diff --git a/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs b/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs index de0840265f..25952c775e 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { class HybridAllocator : IRegisterAllocator { - private struct BlockInfo + private readonly struct BlockInfo { public bool HasCall { get; } diff --git a/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs b/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs index 9652224e5f..5b11aac204 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs @@ -3,7 +3,7 @@ using System; namespace ARMeilleure.CodeGen.RegisterAllocators { - struct RegisterMasks + readonly struct RegisterMasks { public int IntAvailableRegisters { get; } public int VecAvailableRegisters { get; } diff --git a/ARMeilleure/CodeGen/X86/IntrinsicInfo.cs b/ARMeilleure/CodeGen/X86/IntrinsicInfo.cs index b1af352bc3..302bf4d3c0 100644 --- a/ARMeilleure/CodeGen/X86/IntrinsicInfo.cs +++ b/ARMeilleure/CodeGen/X86/IntrinsicInfo.cs @@ -1,6 +1,6 @@ namespace ARMeilleure.CodeGen.X86 { - struct IntrinsicInfo + readonly struct IntrinsicInfo { public X86Instruction Inst { get; } public IntrinsicType Type { get; } diff --git a/ARMeilleure/Decoders/InstDescriptor.cs b/ARMeilleure/Decoders/InstDescriptor.cs index 29966d6dd1..577ff3946c 100644 --- a/ARMeilleure/Decoders/InstDescriptor.cs +++ b/ARMeilleure/Decoders/InstDescriptor.cs @@ -2,7 +2,7 @@ using ARMeilleure.Instructions; namespace ARMeilleure.Decoders { - struct InstDescriptor + readonly struct InstDescriptor { public static InstDescriptor Undefined => new InstDescriptor(InstName.Und, InstEmit.Und); diff --git a/ARMeilleure/Decoders/OpCodeTable.cs b/ARMeilleure/Decoders/OpCodeTable.cs index f44c154006..caa93099ec 100644 --- a/ARMeilleure/Decoders/OpCodeTable.cs +++ b/ARMeilleure/Decoders/OpCodeTable.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.Decoders private const int FastLookupSize = 0x1000; - private struct InstInfo + private readonly struct InstInfo { public int Mask { get; } public int Value { get; } diff --git a/ARMeilleure/Diagnostics/Symbols.cs b/ARMeilleure/Diagnostics/Symbols.cs index 17764f7e3a..6bde62f561 100644 --- a/ARMeilleure/Diagnostics/Symbols.cs +++ b/ARMeilleure/Diagnostics/Symbols.cs @@ -6,7 +6,7 @@ namespace ARMeilleure.Diagnostics { static class Symbols { - private struct RangedSymbol + private readonly struct RangedSymbol { public readonly ulong Start; public readonly ulong End; diff --git a/ARMeilleure/IntermediateRepresentation/PhiOperation.cs b/ARMeilleure/IntermediateRepresentation/PhiOperation.cs index f24308820d..d2a3cf2188 100644 --- a/ARMeilleure/IntermediateRepresentation/PhiOperation.cs +++ b/ARMeilleure/IntermediateRepresentation/PhiOperation.cs @@ -3,7 +3,7 @@ using static ARMeilleure.IntermediateRepresentation.Operand.Factory; namespace ARMeilleure.IntermediateRepresentation { - struct PhiOperation + readonly struct PhiOperation { private readonly Operation _operation; diff --git a/ARMeilleure/IntermediateRepresentation/Register.cs b/ARMeilleure/IntermediateRepresentation/Register.cs index 745b315382..241e4d13d5 100644 --- a/ARMeilleure/IntermediateRepresentation/Register.cs +++ b/ARMeilleure/IntermediateRepresentation/Register.cs @@ -2,7 +2,7 @@ using System; namespace ARMeilleure.IntermediateRepresentation { - struct Register : IEquatable + readonly struct Register : IEquatable { public int Index { get; } diff --git a/ARMeilleure/Translation/Cache/CacheEntry.cs b/ARMeilleure/Translation/Cache/CacheEntry.cs index fce984c34d..dc5503b185 100644 --- a/ARMeilleure/Translation/Cache/CacheEntry.cs +++ b/ARMeilleure/Translation/Cache/CacheEntry.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; namespace ARMeilleure.Translation.Cache { - struct CacheEntry : IComparable + readonly struct CacheEntry : IComparable { public int Offset { get; } public int Size { get; } diff --git a/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs b/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs index 3111e886f1..4c22de40e2 100644 --- a/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs +++ b/ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs @@ -6,7 +6,7 @@ namespace ARMeilleure.Translation.Cache { class CacheMemoryAllocator { - private struct MemoryBlock : IComparable + private readonly struct MemoryBlock : IComparable { public int Offset { get; } public int Size { get; } diff --git a/ARMeilleure/Translation/CompilerContext.cs b/ARMeilleure/Translation/CompilerContext.cs index cfe5ad1e50..510dec58f1 100644 --- a/ARMeilleure/Translation/CompilerContext.cs +++ b/ARMeilleure/Translation/CompilerContext.cs @@ -2,7 +2,7 @@ using ARMeilleure.IntermediateRepresentation; namespace ARMeilleure.Translation { - struct CompilerContext + readonly struct CompilerContext { public ControlFlowGraph Cfg { get; } diff --git a/ARMeilleure/Translation/RegisterUsage.cs b/ARMeilleure/Translation/RegisterUsage.cs index 775fa3abc2..3ec0a7b4fe 100644 --- a/ARMeilleure/Translation/RegisterUsage.cs +++ b/ARMeilleure/Translation/RegisterUsage.cs @@ -14,7 +14,7 @@ namespace ARMeilleure.Translation private const int RegsCount = 32; private const int RegsMask = RegsCount - 1; - private struct RegisterMask : IEquatable + private readonly struct RegisterMask : IEquatable { public long IntMask => Mask.GetElement(0); public long VecMask => Mask.GetElement(1); diff --git a/ARMeilleure/Translation/Translator.cs b/ARMeilleure/Translation/Translator.cs index c50b1c3d0c..2edbe4011a 100644 --- a/ARMeilleure/Translation/Translator.cs +++ b/ARMeilleure/Translation/Translator.cs @@ -293,7 +293,7 @@ namespace ARMeilleure.Translation } } - private struct Range + private readonly struct Range { public ulong Start { get; } public ulong End { get; } diff --git a/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOChannelLayout.cs b/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOChannelLayout.cs index cff6114fa8..ea617d4b4c 100644 --- a/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOChannelLayout.cs +++ b/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOChannelLayout.cs @@ -4,7 +4,7 @@ using System.Runtime.InteropServices; namespace SoundIOSharp { - public struct SoundIOChannelLayout + public readonly struct SoundIOChannelLayout { public static int BuiltInCount { diff --git a/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOSampleRateRange.cs b/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOSampleRateRange.cs index 3cdf751382..daf7921b5c 100644 --- a/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOSampleRateRange.cs +++ b/Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOSampleRateRange.cs @@ -1,6 +1,6 @@ namespace SoundIOSharp { - public struct SoundIOSampleRateRange + public readonly struct SoundIOSampleRateRange { internal SoundIOSampleRateRange(int min, int max) { diff --git a/Ryujinx.Ava/Ui/Windows/IconColorPicker.cs b/Ryujinx.Ava/Ui/Windows/IconColorPicker.cs index 7cf4c2edef..c0a2602f85 100644 --- a/Ryujinx.Ava/Ui/Windows/IconColorPicker.cs +++ b/Ryujinx.Ava/Ui/Windows/IconColorPicker.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Ava.Ui.Windows private const int CutOffLuminosity = 64; - private struct PaletteColor + private readonly struct PaletteColor { public int Qck { get; } public byte R { get; } diff --git a/Ryujinx.Common/Logging/Logger.cs b/Ryujinx.Common/Logging/Logger.cs index 475e36281e..c1abdba9b8 100644 --- a/Ryujinx.Common/Logging/Logger.cs +++ b/Ryujinx.Common/Logging/Logger.cs @@ -16,7 +16,7 @@ namespace Ryujinx.Common.Logging public static event EventHandler Updated; - public struct Log + public readonly struct Log { internal readonly LogLevel Level; diff --git a/Ryujinx.Common/Memory/SpanOrArray.cs b/Ryujinx.Common/Memory/SpanOrArray.cs index c1f0665553..a9798d2780 100644 --- a/Ryujinx.Common/Memory/SpanOrArray.cs +++ b/Ryujinx.Common/Memory/SpanOrArray.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Common.Memory /// This is useful to keep the Array representation when possible to avoid copies. /// /// Element Type - public ref struct SpanOrArray where T : unmanaged + public readonly ref struct SpanOrArray where T : unmanaged { public readonly T[] Array; public readonly ReadOnlySpan Span; diff --git a/Ryujinx.Cpu/ExceptionCallbacks.cs b/Ryujinx.Cpu/ExceptionCallbacks.cs index 1485ca7d2a..d9293302b8 100644 --- a/Ryujinx.Cpu/ExceptionCallbacks.cs +++ b/Ryujinx.Cpu/ExceptionCallbacks.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Cpu /// /// Stores handlers for the various CPU exceptions. /// - public struct ExceptionCallbacks + public readonly struct ExceptionCallbacks { /// /// Handler for CPU interrupts triggered using . diff --git a/Ryujinx.Graphics.Device/RwCallback.cs b/Ryujinx.Graphics.Device/RwCallback.cs index 6f1c8898ed..dc8499e9d7 100644 --- a/Ryujinx.Graphics.Device/RwCallback.cs +++ b/Ryujinx.Graphics.Device/RwCallback.cs @@ -2,7 +2,7 @@ namespace Ryujinx.Graphics.Device { - public struct RwCallback + public readonly struct RwCallback { public Action Write { get; } public Func Read { get; } diff --git a/Ryujinx.Graphics.GAL/BlendDescriptor.cs b/Ryujinx.Graphics.GAL/BlendDescriptor.cs index cc1e17c73d..83b8afe24e 100644 --- a/Ryujinx.Graphics.GAL/BlendDescriptor.cs +++ b/Ryujinx.Graphics.GAL/BlendDescriptor.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct BlendDescriptor + public readonly struct BlendDescriptor { public bool Enable { get; } diff --git a/Ryujinx.Graphics.GAL/BufferAssignment.cs b/Ryujinx.Graphics.GAL/BufferAssignment.cs index 9f0f56c5fb..d803d90bae 100644 --- a/Ryujinx.Graphics.GAL/BufferAssignment.cs +++ b/Ryujinx.Graphics.GAL/BufferAssignment.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct BufferAssignment + public readonly struct BufferAssignment { public readonly int Binding; public readonly BufferRange Range; diff --git a/Ryujinx.Graphics.GAL/BufferHandle.cs b/Ryujinx.Graphics.GAL/BufferHandle.cs index 49f834425a..5ba50d195d 100644 --- a/Ryujinx.Graphics.GAL/BufferHandle.cs +++ b/Ryujinx.Graphics.GAL/BufferHandle.cs @@ -1,22 +1,14 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace Ryujinx.Graphics.GAL { [StructLayout(LayoutKind.Sequential, Size = 8)] - public struct BufferHandle : IEquatable + public readonly record struct BufferHandle { private readonly ulong _value; public static BufferHandle Null => new BufferHandle(0); private BufferHandle(ulong value) => _value = value; - - public override bool Equals(object obj) => obj is BufferHandle handle && Equals(handle); - public bool Equals([AllowNull] BufferHandle other) => other._value == _value; - public override int GetHashCode() => _value.GetHashCode(); - public static bool operator ==(BufferHandle left, BufferHandle right) => left.Equals(right); - public static bool operator !=(BufferHandle left, BufferHandle right) => !(left == right); } } diff --git a/Ryujinx.Graphics.GAL/BufferRange.cs b/Ryujinx.Graphics.GAL/BufferRange.cs index 9a030c8089..ad9ebee48d 100644 --- a/Ryujinx.Graphics.GAL/BufferRange.cs +++ b/Ryujinx.Graphics.GAL/BufferRange.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct BufferRange + public readonly struct BufferRange { private static readonly BufferRange _empty = new BufferRange(BufferHandle.Null, 0, 0); diff --git a/Ryujinx.Graphics.GAL/Capabilities.cs b/Ryujinx.Graphics.GAL/Capabilities.cs index c4428f175c..2d38ecccfc 100644 --- a/Ryujinx.Graphics.GAL/Capabilities.cs +++ b/Ryujinx.Graphics.GAL/Capabilities.cs @@ -2,7 +2,7 @@ using Ryujinx.Graphics.Shader.Translation; namespace Ryujinx.Graphics.GAL { - public struct Capabilities + public readonly struct Capabilities { public readonly TargetApi Api; public readonly string VendorName; diff --git a/Ryujinx.Graphics.GAL/ColorF.cs b/Ryujinx.Graphics.GAL/ColorF.cs index b3002f8c50..235f4229a4 100644 --- a/Ryujinx.Graphics.GAL/ColorF.cs +++ b/Ryujinx.Graphics.GAL/ColorF.cs @@ -1,32 +1,4 @@ -using System; - namespace Ryujinx.Graphics.GAL { - public struct ColorF : IEquatable - { - public float Red { get; } - public float Green { get; } - public float Blue { get; } - public float Alpha { get; } - - public ColorF(float red, float green, float blue, float alpha) - { - Red = red; - Green = green; - Blue = blue; - Alpha = alpha; - } - - public bool Equals(ColorF color) => Red == color.Red && - Green == color.Green && - Blue == color.Blue && - Alpha == color.Alpha; - - public override bool Equals(object obj) => (obj is ColorF color) && Equals(color); - - public override int GetHashCode() => HashCode.Combine(Red, Green, Blue, Alpha); - - public static bool operator ==(ColorF l, ColorF r) => l.Equals(r); - public static bool operator !=(ColorF l, ColorF r) => !l.Equals(r); - } + public readonly record struct ColorF(float Red, float Green, float Blue, float Alpha); } diff --git a/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs b/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs index c835e94141..4c593392b7 100644 --- a/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs +++ b/Ryujinx.Graphics.GAL/DepthTestDescriptor.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct DepthTestDescriptor + public readonly struct DepthTestDescriptor { public bool TestEnable { get; } public bool WriteEnable { get; } diff --git a/Ryujinx.Graphics.GAL/DeviceInfo.cs b/Ryujinx.Graphics.GAL/DeviceInfo.cs index c525eb6016..eb4a016ff5 100644 --- a/Ryujinx.Graphics.GAL/DeviceInfo.cs +++ b/Ryujinx.Graphics.GAL/DeviceInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct DeviceInfo + public readonly struct DeviceInfo { public readonly string Id; public readonly string Vendor; diff --git a/Ryujinx.Graphics.GAL/Extents2D.cs b/Ryujinx.Graphics.GAL/Extents2D.cs index 05b0ce6395..bac44f83a1 100644 --- a/Ryujinx.Graphics.GAL/Extents2D.cs +++ b/Ryujinx.Graphics.GAL/Extents2D.cs @@ -2,7 +2,7 @@ using Ryujinx.Common; namespace Ryujinx.Graphics.GAL { - public struct Extents2D + public readonly struct Extents2D { public int X1 { get; } public int Y1 { get; } diff --git a/Ryujinx.Graphics.GAL/Extents2DF.cs b/Ryujinx.Graphics.GAL/Extents2DF.cs index 8fb263c479..43f0e25e1d 100644 --- a/Ryujinx.Graphics.GAL/Extents2DF.cs +++ b/Ryujinx.Graphics.GAL/Extents2DF.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct Extents2DF + public readonly struct Extents2DF { public float X1 { get; } public float Y1 { get; } diff --git a/Ryujinx.Graphics.GAL/HardwareInfo.cs b/Ryujinx.Graphics.GAL/HardwareInfo.cs index 9baf1924ff..4dd6849bdd 100644 --- a/Ryujinx.Graphics.GAL/HardwareInfo.cs +++ b/Ryujinx.Graphics.GAL/HardwareInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct HardwareInfo + public readonly struct HardwareInfo { public string GpuVendor { get; } public string GpuModel { get; } diff --git a/Ryujinx.Graphics.GAL/ImageCrop.cs b/Ryujinx.Graphics.GAL/ImageCrop.cs index a7d571de35..e8220974be 100644 --- a/Ryujinx.Graphics.GAL/ImageCrop.cs +++ b/Ryujinx.Graphics.GAL/ImageCrop.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct ImageCrop + public readonly struct ImageCrop { public int Left { get; } public int Right { get; } diff --git a/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs b/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs index 76e569874c..a6fb65aaf6 100644 --- a/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs +++ b/Ryujinx.Graphics.GAL/MultisampleDescriptor.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct MultisampleDescriptor + public readonly struct MultisampleDescriptor { public bool AlphaToCoverageEnable { get; } public bool AlphaToCoverageDitherEnable { get; } diff --git a/Ryujinx.Graphics.GAL/ProgramPipelineState.cs b/Ryujinx.Graphics.GAL/ProgramPipelineState.cs index 8872820719..41afb34b0b 100644 --- a/Ryujinx.Graphics.GAL/ProgramPipelineState.cs +++ b/Ryujinx.Graphics.GAL/ProgramPipelineState.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.GAL /// /// Descriptor for a pipeline buffer binding. /// - public struct BufferPipelineDescriptor + public readonly struct BufferPipelineDescriptor { public bool Enable { get; } public int Stride { get; } diff --git a/Ryujinx.Graphics.GAL/Rectangle.cs b/Ryujinx.Graphics.GAL/Rectangle.cs index 1e207926da..c8fa93d9fa 100644 --- a/Ryujinx.Graphics.GAL/Rectangle.cs +++ b/Ryujinx.Graphics.GAL/Rectangle.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct Rectangle where T : unmanaged + public readonly struct Rectangle where T : unmanaged { public T X { get; } public T Y { get; } diff --git a/Ryujinx.Graphics.GAL/SamplerCreateInfo.cs b/Ryujinx.Graphics.GAL/SamplerCreateInfo.cs index fe711c3ad3..4c514671c2 100644 --- a/Ryujinx.Graphics.GAL/SamplerCreateInfo.cs +++ b/Ryujinx.Graphics.GAL/SamplerCreateInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct SamplerCreateInfo + public readonly struct SamplerCreateInfo { public MinFilter MinFilter { get; } public MagFilter MagFilter { get; } diff --git a/Ryujinx.Graphics.GAL/ScreenCaptureImageInfo.cs b/Ryujinx.Graphics.GAL/ScreenCaptureImageInfo.cs index 227d64b69b..129913ec17 100644 --- a/Ryujinx.Graphics.GAL/ScreenCaptureImageInfo.cs +++ b/Ryujinx.Graphics.GAL/ScreenCaptureImageInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct ScreenCaptureImageInfo + public readonly struct ScreenCaptureImageInfo { public ScreenCaptureImageInfo(int width, int height, bool isBgra, byte[] data, bool flipX, bool flipY) { diff --git a/Ryujinx.Graphics.GAL/ShaderBindings.cs b/Ryujinx.Graphics.GAL/ShaderBindings.cs index ea8e174910..6ab2938298 100644 --- a/Ryujinx.Graphics.GAL/ShaderBindings.cs +++ b/Ryujinx.Graphics.GAL/ShaderBindings.cs @@ -2,7 +2,7 @@ namespace Ryujinx.Graphics.GAL { - public struct ShaderBindings + public readonly struct ShaderBindings { public IReadOnlyCollection UniformBufferBindings { get; } public IReadOnlyCollection StorageBufferBindings { get; } diff --git a/Ryujinx.Graphics.GAL/ShaderSource.cs b/Ryujinx.Graphics.GAL/ShaderSource.cs index c68ba80d60..91d3a6325d 100644 --- a/Ryujinx.Graphics.GAL/ShaderSource.cs +++ b/Ryujinx.Graphics.GAL/ShaderSource.cs @@ -3,7 +3,7 @@ using Ryujinx.Graphics.Shader.Translation; namespace Ryujinx.Graphics.GAL { - public struct ShaderSource + public readonly struct ShaderSource { public string Code { get; } public byte[] BinaryCode { get; } diff --git a/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs b/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs index 8c9d1644aa..db46c95792 100644 --- a/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs +++ b/Ryujinx.Graphics.GAL/StencilTestDescriptor.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct StencilTestDescriptor + public readonly struct StencilTestDescriptor { public bool TestEnable { get; } diff --git a/Ryujinx.Graphics.GAL/TextureCreateInfo.cs b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs index 3ccfb70098..52b3b11f97 100644 --- a/Ryujinx.Graphics.GAL/TextureCreateInfo.cs +++ b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs @@ -4,7 +4,7 @@ using System.Numerics; namespace Ryujinx.Graphics.GAL { - public struct TextureCreateInfo : IEquatable + public readonly struct TextureCreateInfo : IEquatable { public int Width { get; } public int Height { get; } @@ -62,42 +62,42 @@ namespace Ryujinx.Graphics.GAL SwizzleA = swizzleA; } - public readonly int GetMipSize(int level) + public int GetMipSize(int level) { return GetMipStride(level) * GetLevelHeight(level) * GetLevelDepth(level); } - public readonly int GetMipSize2D(int level) + public int GetMipSize2D(int level) { return GetMipStride(level) * GetLevelHeight(level); } - public readonly int GetMipStride(int level) + public int GetMipStride(int level) { return BitUtils.AlignUp(GetLevelWidth(level) * BytesPerPixel, 4); } - private readonly int GetLevelWidth(int level) + private int GetLevelWidth(int level) { return BitUtils.DivRoundUp(GetLevelSize(Width, level), BlockWidth); } - private readonly int GetLevelHeight(int level) + private int GetLevelHeight(int level) { return BitUtils.DivRoundUp(GetLevelSize(Height, level), BlockHeight); } - private readonly int GetLevelDepth(int level) + private int GetLevelDepth(int level) { return Target == Target.Texture3D ? GetLevelSize(Depth, level) : GetLayers(); } - public readonly int GetDepthOrLayers() + public int GetDepthOrLayers() { return Target == Target.Texture3D ? Depth : GetLayers(); } - public readonly int GetLayers() + public int GetLayers() { if (Target == Target.Texture2DArray || Target == Target.Texture2DMultisampleArray || @@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.GAL return 1; } - public readonly int GetLevelsClamped() + public int GetLevelsClamped() { int maxSize = Width; diff --git a/Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs b/Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs index b3248b621f..4f5ea6a680 100644 --- a/Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs +++ b/Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs @@ -1,40 +1,4 @@ -using System; - namespace Ryujinx.Graphics.GAL { - public struct VertexAttribDescriptor : IEquatable - { - public int BufferIndex { get; } - public int Offset { get; } - - public bool IsZero { get; } - - public Format Format { get; } - - public VertexAttribDescriptor(int bufferIndex, int offset, bool isZero, Format format) - { - BufferIndex = bufferIndex; - Offset = offset; - IsZero = isZero; - Format = format; - } - - public override bool Equals(object obj) - { - return obj is VertexAttribDescriptor other && Equals(other); - } - - public bool Equals(VertexAttribDescriptor other) - { - return BufferIndex == other.BufferIndex && - Offset == other.Offset && - IsZero == other.IsZero && - Format == other.Format; - } - - public override int GetHashCode() - { - return HashCode.Combine(BufferIndex, Offset, IsZero, Format); - } - } + public readonly record struct VertexAttribDescriptor(int BufferIndex, int Offset, bool IsZero, Format Format); } diff --git a/Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs b/Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs index bcd3b28f5d..15f0dff852 100644 --- a/Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs +++ b/Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct VertexBufferDescriptor + public readonly struct VertexBufferDescriptor { public BufferRange Buffer { get; } diff --git a/Ryujinx.Graphics.GAL/Viewport.cs b/Ryujinx.Graphics.GAL/Viewport.cs index 58135db2c4..94012c0030 100644 --- a/Ryujinx.Graphics.GAL/Viewport.cs +++ b/Ryujinx.Graphics.GAL/Viewport.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.GAL { - public struct Viewport + public readonly struct Viewport { public Rectangle Region { get; } diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs b/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs index 640687f00c..117961db23 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// /// FIFO word. /// - struct FifoWord + readonly struct FifoWord { /// /// GPU virtual address where the word is located in memory. diff --git a/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs b/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs index ab6f54efbe..719e170fd6 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME /// /// Macroo High-level implementation table entry. /// - struct TableEntry + readonly struct TableEntry { /// /// Name of the Macro function. diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs index 2af7a4023a..628eb46a7d 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs @@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed /// /// State update callback entry, with the callback function and associated field names. /// - struct StateUpdateCallbackEntry + readonly struct StateUpdateCallbackEntry { /// /// Callback function, to be called if the register was written as the state needs to be updated. diff --git a/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs b/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs index 62f41cbb02..9ee649d2d7 100644 --- a/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs +++ b/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// Represents texture format information. /// - struct FormatInfo + readonly struct FormatInfo { /// /// A default, generic RGBA8 texture format. diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs index be94f310e0..febe508be8 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Texture binding information. /// This is used for textures that needs to be accessed from shaders. /// - struct TextureBindingInfo + readonly struct TextureBindingInfo { /// /// Shader sampler target type. diff --git a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index a6bb57419e..16bfc69316 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// class TextureCache : IDisposable { - private struct OverlapInfo + private readonly struct OverlapInfo { public TextureViewCompatibility Compatibility { get; } public int FirstLayer { get; } diff --git a/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs index 9efd18028b..ca54dc2f25 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// An overlapping texture group with a given view compatibility. /// - struct TextureIncompatibleOverlap + readonly struct TextureIncompatibleOverlap { public readonly TextureGroup Group; public readonly TextureViewCompatibility Compatibility; diff --git a/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs b/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs index 571f440e56..65cc698b0f 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// /// Texture information. /// - struct TextureInfo + readonly struct TextureInfo { /// /// Address of the texture in GPU mapped memory. diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs b/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs index 5569b9470b..d513b7adf8 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// Memory range used for buffers. /// - struct BufferBounds + readonly struct BufferBounds { /// /// Region virtual address. diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferTextureBinding.cs b/Ryujinx.Graphics.Gpu/Memory/BufferTextureBinding.cs index 2a1408708c..b7a0e7264d 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferTextureBinding.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferTextureBinding.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// /// A buffer binding to apply to a buffer texture. /// - struct BufferTextureBinding + readonly struct BufferTextureBinding { /// /// Shader stage accessing the texture. diff --git a/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs b/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs index 90b9187b41..e763a899c2 100644 --- a/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs +++ b/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// class CounterCache { - private struct CounterEntry + private readonly struct CounterEntry { public ulong Address { get; } public ICounterEvent Event { get; } diff --git a/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs b/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs index 98655ed685..568fe96833 100644 --- a/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs +++ b/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs @@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// /// Represents an operation to perform on the . /// - private struct CacheFileOperationTask + private readonly struct CacheFileOperationTask { /// /// The type of operation to perform. @@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// /// Background shader cache write information. /// - private struct AddShaderData + private readonly struct AddShaderData { /// /// Cached shader program. diff --git a/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs b/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs index 0096533d41..959d6e1848 100644 --- a/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs +++ b/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs @@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// /// Guest shader code and constant buffer data accessed by the shader. /// - struct GuestCodeAndCbData + readonly struct GuestCodeAndCbData { /// /// Maxwell binary shader code. diff --git a/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs index 9261cb0dc3..722e66b363 100644 --- a/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs +++ b/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs @@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// /// Program validation entry. /// - private struct ProgramEntry + private readonly struct ProgramEntry { /// /// Cached shader program. @@ -90,7 +90,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// /// Translated shader compilation entry. /// - private struct ProgramCompilation + private readonly struct ProgramCompilation { /// /// Translated shader stages. @@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache /// /// Program translation entry. /// - private struct AsyncProgramTranslation + private readonly struct AsyncProgramTranslation { /// /// Guest code for each active stage. diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs b/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs index 356d3f3e41..b65dd75e3c 100644 --- a/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs +++ b/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs @@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// State used by the . /// - struct GpuChannelComputeState + readonly struct GpuChannelComputeState { // New fields should be added to the end of the struct to keep disk shader cache compatibility. diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs b/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs index b894c57e78..1e34c5ded4 100644 --- a/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs +++ b/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// State used by the . /// - struct GpuChannelPoolState : IEquatable + readonly struct GpuChannelPoolState : IEquatable { /// /// GPU virtual address of the texture pool. diff --git a/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs b/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs index f26fbdbb3d..e9a4f65496 100644 --- a/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs +++ b/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable /// /// Entry for a given data size. /// - private struct SizeEntry + private readonly struct SizeEntry { /// /// Size for the data that will be stored on the hash table on this entry. diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 23b213b4b4..5c045d9bac 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// public const TranslationFlags DefaultFlags = TranslationFlags.DebugMode; - private struct TranslatedShader + private readonly struct TranslatedShader { public readonly CachedShaderStage Shader; public readonly ShaderProgram Program; @@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Shader } } - private struct TranslatedShaderVertexPair + private readonly struct TranslatedShaderVertexPair { public readonly CachedShaderStage VertexA; public readonly CachedShaderStage VertexB; @@ -59,7 +59,7 @@ namespace Ryujinx.Graphics.Gpu.Shader private readonly Dictionary _cpPrograms; private readonly Dictionary _gpPrograms; - private struct ProgramToSave + private readonly struct ProgramToSave { public readonly CachedShaderProgram CachedProgram; public readonly IProgram HostProgram; diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs index dbb33d2241..e896493c5f 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// Shader code accessor. /// - struct ShaderCodeAccessor : IDataAccessor + readonly struct ShaderCodeAccessor : IDataAccessor { private readonly MemoryManager _memoryManager; private readonly ulong _baseAddress; diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs index f96a8ce11d..6ca7daef2a 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// Paths where shader code was dumped on disk. /// - struct ShaderDumpPaths + readonly struct ShaderDumpPaths { /// /// Path where the full shader code with header was dumped, or null if not dumped. diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs index 14f64bbf40..872aaf67c9 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs @@ -121,7 +121,7 @@ namespace Ryujinx.Graphics.Gpu.Shader /// /// Texture binding information, used to identify each texture accessed by the shader. /// - private struct TextureKey : IEquatable + private readonly record struct TextureKey { // New fields should be added to the end of the struct to keep disk shader cache compatibility. @@ -152,21 +152,6 @@ namespace Ryujinx.Graphics.Gpu.Shader Handle = handle; CbufSlot = cbufSlot; } - - public override bool Equals(object obj) - { - return obj is TextureKey textureKey && Equals(textureKey); - } - - public bool Equals(TextureKey other) - { - return StageIndex == other.StageIndex && Handle == other.Handle && CbufSlot == other.CbufSlot; - } - - public override int GetHashCode() - { - return HashCode.Combine(StageIndex, Handle, CbufSlot); - } } private readonly Dictionary> _textureSpecialization; diff --git a/Ryujinx.Graphics.Gpu/Window.cs b/Ryujinx.Graphics.Gpu/Window.cs index 18320c74df..c116d94661 100644 --- a/Ryujinx.Graphics.Gpu/Window.cs +++ b/Ryujinx.Graphics.Gpu/Window.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Gpu /// /// Texture presented on the window. /// - private struct PresentationTexture + private readonly struct PresentationTexture { /// /// Texture cache where the texture might be located. diff --git a/Ryujinx.Graphics.Host1x/Host1xDevice.cs b/Ryujinx.Graphics.Host1x/Host1xDevice.cs index 61408fc41e..90dd4fa053 100644 --- a/Ryujinx.Graphics.Host1x/Host1xDevice.cs +++ b/Ryujinx.Graphics.Host1x/Host1xDevice.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Host1x { public sealed class Host1xDevice : IDisposable { - private struct Command + private readonly struct Command { public int[] Buffer { get; } public long ContextId { get; } diff --git a/Ryujinx.Graphics.Host1x/SyncptIncrManager.cs b/Ryujinx.Graphics.Host1x/SyncptIncrManager.cs index 82ac5e7d4d..62c499175c 100644 --- a/Ryujinx.Graphics.Host1x/SyncptIncrManager.cs +++ b/Ryujinx.Graphics.Host1x/SyncptIncrManager.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Host1x { private readonly SynchronizationManager _syncMgr; - private struct SyncptIncr + private readonly struct SyncptIncr { public uint Id { get; } public ClassId ClassId { get; } diff --git a/Ryujinx.Graphics.Nvdec/FrameDecodedEventArgs.cs b/Ryujinx.Graphics.Nvdec/FrameDecodedEventArgs.cs index f5074f4854..4ee29d9d01 100644 --- a/Ryujinx.Graphics.Nvdec/FrameDecodedEventArgs.cs +++ b/Ryujinx.Graphics.Nvdec/FrameDecodedEventArgs.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Nvdec { - public struct FrameDecodedEventArgs + public readonly struct FrameDecodedEventArgs { public CodecId CodecId { get; } public uint LumaOffset { get; } diff --git a/Ryujinx.Graphics.Nvdec/ResourceManager.cs b/Ryujinx.Graphics.Nvdec/ResourceManager.cs index 6e0d9ab297..08d2425861 100644 --- a/Ryujinx.Graphics.Nvdec/ResourceManager.cs +++ b/Ryujinx.Graphics.Nvdec/ResourceManager.cs @@ -3,7 +3,7 @@ using Ryujinx.Graphics.Nvdec.Image; namespace Ryujinx.Graphics.Nvdec { - struct ResourceManager + readonly struct ResourceManager { public MemoryManager Gmm { get; } public SurfaceCache Cache { get; } diff --git a/Ryujinx.Graphics.OpenGL/FormatInfo.cs b/Ryujinx.Graphics.OpenGL/FormatInfo.cs index 6aa70691d3..aef4dbad39 100644 --- a/Ryujinx.Graphics.OpenGL/FormatInfo.cs +++ b/Ryujinx.Graphics.OpenGL/FormatInfo.cs @@ -2,7 +2,7 @@ using OpenTK.Graphics.OpenGL; namespace Ryujinx.Graphics.OpenGL { - struct FormatInfo + readonly struct FormatInfo { public int Components { get; } public bool Normalized { get; } diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs index fc9aef7ec3..7b2a6b464f 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { - struct InstInfo + readonly struct InstInfo { public InstType Type { get; } diff --git a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs index b78914260e..ccc87a7fc4 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { private static readonly string[] StagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" }; - private struct BuiltInAttribute + private readonly struct BuiltInAttribute { public string Name { get; } diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs index f432f1c419..f80c8110b6 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs @@ -3,7 +3,7 @@ using Spv.Generator; namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { - struct OperationResult + readonly struct OperationResult { public static OperationResult Invalid => new OperationResult(AggregateType.Invalid, null); diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs index fa0341ee96..04c3be1b81 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv /// /// Delegate cache for SPIR-V instruction generators. Avoids delegate allocation when passing generators as arguments. /// - internal struct SpirvDelegates + internal readonly struct SpirvDelegates { // Unary public readonly FuncUnaryInstruction GlslFAbs; diff --git a/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs b/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs index 686259ad71..4de0560377 100644 --- a/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs +++ b/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs @@ -1,33 +1,4 @@ -using System; - -namespace Ryujinx.Graphics.Shader.CodeGen.Spirv +namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { - struct TextureMeta : IEquatable - { - public int CbufSlot { get; } - public int Handle { get; } - public TextureFormat Format { get; } - - public TextureMeta(int cbufSlot, int handle, TextureFormat format) - { - CbufSlot = cbufSlot; - Handle = handle; - Format = format; - } - - public override bool Equals(object obj) - { - return obj is TextureMeta other && Equals(other); - } - - public bool Equals(TextureMeta other) - { - return CbufSlot == other.CbufSlot && Handle == other.Handle && Format == other.Format; - } - - public override int GetHashCode() - { - return HashCode.Combine(CbufSlot, Handle, Format); - } - } + readonly record struct TextureMeta(int CbufSlot, int Handle, TextureFormat Format); } \ No newline at end of file diff --git a/Ryujinx.Graphics.Shader/Decoders/Block.cs b/Ryujinx.Graphics.Shader/Decoders/Block.cs index ddd81cc53f..7d94e3f9a5 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Block.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Block.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Decoders } } - struct SyncTarget + readonly struct SyncTarget { public PushOpInfo PushOpInfo { get; } public int PushOpId { get; } diff --git a/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs b/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs index 80de41d7ea..2dd60155e0 100644 --- a/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs +++ b/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace Ryujinx.Graphics.Shader.Decoders { - struct DecodedProgram : IEnumerable + readonly struct DecodedProgram : IEnumerable { public DecodedFunction MainFunction { get; } private readonly IReadOnlyDictionary _functions; diff --git a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index 9dafb089f7..380c425e5f 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -473,7 +473,7 @@ namespace Ryujinx.Graphics.Shader.Decoders op = Unsafe.As(ref rawOp); } - private struct BlockLocation + private readonly struct BlockLocation { public Block Block { get; } public int Index { get; } diff --git a/Ryujinx.Graphics.Shader/Decoders/InstTable.cs b/Ryujinx.Graphics.Shader/Decoders/InstTable.cs index 0a64632ef6..911f158161 100644 --- a/Ryujinx.Graphics.Shader/Decoders/InstTable.cs +++ b/Ryujinx.Graphics.Shader/Decoders/InstTable.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { private const int EncodingBits = 14; - private struct TableEntry + private readonly struct TableEntry { public InstName Name { get; } public InstEmitter Emitter { get; } diff --git a/Ryujinx.Graphics.Shader/Decoders/Register.cs b/Ryujinx.Graphics.Shader/Decoders/Register.cs index 30840d8c03..e375096ddb 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Register.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Register.cs @@ -2,7 +2,7 @@ using System; namespace Ryujinx.Graphics.Shader.Decoders { - struct Register : IEquatable + readonly struct Register : IEquatable { public int Index { get; } diff --git a/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs b/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs index 799aec24e5..aea36423e2 100644 --- a/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs +++ b/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { static class InstructionInfo { - private struct InstInfo + private readonly struct InstInfo { public VariableType DestType { get; } diff --git a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs index 57253148f1..489a591057 100644 --- a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs +++ b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Ryujinx.Graphics.Shader.StructuredIr { - struct TransformFeedbackOutput + readonly struct TransformFeedbackOutput { public readonly bool Valid; public readonly int Buffer; diff --git a/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs b/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs index 839edbe9e3..1647f65620 100644 --- a/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs +++ b/Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs @@ -2,7 +2,7 @@ namespace Ryujinx.Graphics.Shader.Translation { - struct AttributeInfo + readonly struct AttributeInfo { private static readonly Dictionary _builtInAttributes = new Dictionary() { diff --git a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs index ef5d7b96dd..7961ada898 100644 --- a/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs +++ b/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Shader.Translation public int OperationsCount => _operations.Count; - private struct BrxTarget + private readonly struct BrxTarget { public readonly Operand Selector; public readonly int ExpectedValue; diff --git a/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs b/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs index 1c5d8c545f..073e120a32 100644 --- a/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs +++ b/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs @@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Shader.Translation } } - private struct TreeNodeUse + private readonly struct TreeNodeUse { public TreeNode Node { get; } public int Index { get; } @@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Shader.Translation bool Matches(in InstOp opInfo); } - private struct PatternTreeNodeUse + private readonly struct PatternTreeNodeUse { public IPatternTreeNode Node { get; } public int Index { get; } diff --git a/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs b/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs index 158ba5ef9c..9e31831de0 100644 --- a/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs +++ b/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs @@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Shader.Translation } } - public struct FunctionRegisterUsage + public readonly struct FunctionRegisterUsage { public Register[] InArguments { get; } public Register[] OutArguments { get; } diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs index ae4107e80d..12cd4cd185 100644 --- a/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs +++ b/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs @@ -69,36 +69,7 @@ namespace Ryujinx.Graphics.Shader.Translation private int _usedStorageBuffers; private int _usedStorageBuffersWrite; - private struct TextureInfo : IEquatable - { - public int CbufSlot { get; } - public int Handle { get; } - public bool Indexed { get; } - public TextureFormat Format { get; } - - public TextureInfo(int cbufSlot, int handle, bool indexed, TextureFormat format) - { - CbufSlot = cbufSlot; - Handle = handle; - Indexed = indexed; - Format = format; - } - - public override bool Equals(object obj) - { - return obj is TextureInfo other && Equals(other); - } - - public bool Equals(TextureInfo other) - { - return CbufSlot == other.CbufSlot && Handle == other.Handle && Indexed == other.Indexed && Format == other.Format; - } - - public override int GetHashCode() - { - return HashCode.Combine(CbufSlot, Handle, Indexed, Format); - } - } + private readonly record struct TextureInfo(int CbufSlot, int Handle, bool Indexed, TextureFormat Format); private struct TextureMeta { diff --git a/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs b/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs index e53c77af0e..b643262fcf 100644 --- a/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs +++ b/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs @@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Shader.Translation ScreenLinear = 3 } - struct ImapPixelType + readonly struct ImapPixelType { public PixelImap X { get; } public PixelImap Y { get; } diff --git a/Ryujinx.Graphics.Shader/Translation/Ssa.cs b/Ryujinx.Graphics.Shader/Translation/Ssa.cs index 8c63d72ddb..16b8b92406 100644 --- a/Ryujinx.Graphics.Shader/Translation/Ssa.cs +++ b/Ryujinx.Graphics.Shader/Translation/Ssa.cs @@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Shader.Translation } } - private struct Definition + private readonly struct Definition { public BasicBlock Block { get; } public Operand Local { get; } diff --git a/Ryujinx.Graphics.Shader/Translation/TranslationOptions.cs b/Ryujinx.Graphics.Shader/Translation/TranslationOptions.cs index 532e9abb83..d9829ac4fc 100644 --- a/Ryujinx.Graphics.Shader/Translation/TranslationOptions.cs +++ b/Ryujinx.Graphics.Shader/Translation/TranslationOptions.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Shader.Translation { - public struct TranslationOptions + public readonly struct TranslationOptions { public TargetLanguage TargetLanguage { get; } public TargetApi TargetApi { get; } diff --git a/Ryujinx.Graphics.Shader/Translation/Translator.cs b/Ryujinx.Graphics.Shader/Translation/Translator.cs index f8795c0ff5..3fb586cbbc 100644 --- a/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation { private const int HeaderSize = 0x50; - internal struct FunctionCode + internal readonly struct FunctionCode { public Operation[] Code { get; } diff --git a/Ryujinx.Graphics.Texture/Region.cs b/Ryujinx.Graphics.Texture/Region.cs index a60951e321..e59888a0e9 100644 --- a/Ryujinx.Graphics.Texture/Region.cs +++ b/Ryujinx.Graphics.Texture/Region.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Texture { - public struct Region + public readonly struct Region { public int Offset { get; } public int Size { get; } diff --git a/Ryujinx.Graphics.Texture/Size.cs b/Ryujinx.Graphics.Texture/Size.cs index 35611b987a..21c45b3865 100644 --- a/Ryujinx.Graphics.Texture/Size.cs +++ b/Ryujinx.Graphics.Texture/Size.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Texture { - public struct Size + public readonly struct Size { public int Width { get; } public int Height { get; } diff --git a/Ryujinx.Graphics.Texture/SizeInfo.cs b/Ryujinx.Graphics.Texture/SizeInfo.cs index ed5379b344..eb57372837 100644 --- a/Ryujinx.Graphics.Texture/SizeInfo.cs +++ b/Ryujinx.Graphics.Texture/SizeInfo.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Ryujinx.Graphics.Texture { - public struct SizeInfo + public readonly struct SizeInfo { private readonly int[] _mipOffsets; diff --git a/Ryujinx.Graphics.Texture/Utils/BC7ModeInfo.cs b/Ryujinx.Graphics.Texture/Utils/BC7ModeInfo.cs index 749324bf0e..687df22c52 100644 --- a/Ryujinx.Graphics.Texture/Utils/BC7ModeInfo.cs +++ b/Ryujinx.Graphics.Texture/Utils/BC7ModeInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Texture.Utils { - struct BC7ModeInfo + readonly struct BC7ModeInfo { public readonly int SubsetCount; public readonly int PartitionBitCount; diff --git a/Ryujinx.Graphics.Vic/Image/Surface.cs b/Ryujinx.Graphics.Vic/Image/Surface.cs index 03767f8a7d..f393eb15c2 100644 --- a/Ryujinx.Graphics.Vic/Image/Surface.cs +++ b/Ryujinx.Graphics.Vic/Image/Surface.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; namespace Ryujinx.Graphics.Vic.Image { - struct Surface : IDisposable + readonly struct Surface : IDisposable { private readonly int _bufferIndex; diff --git a/Ryujinx.Graphics.Vic/Rectangle.cs b/Ryujinx.Graphics.Vic/Rectangle.cs index 2a13b95c7c..8a8dd63a4d 100644 --- a/Ryujinx.Graphics.Vic/Rectangle.cs +++ b/Ryujinx.Graphics.Vic/Rectangle.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Vic { - struct Rectangle + readonly struct Rectangle { public readonly int X; public readonly int Y; diff --git a/Ryujinx.Graphics.Vic/ResourceManager.cs b/Ryujinx.Graphics.Vic/ResourceManager.cs index 036b30b63b..7c3f507edb 100644 --- a/Ryujinx.Graphics.Vic/ResourceManager.cs +++ b/Ryujinx.Graphics.Vic/ResourceManager.cs @@ -3,7 +3,7 @@ using Ryujinx.Graphics.Vic.Image; namespace Ryujinx.Graphics.Vic { - struct ResourceManager + readonly struct ResourceManager { public MemoryManager Gmm { get; } public BufferPool SurfacePool { get; } diff --git a/Ryujinx.Graphics.Video/Plane.cs b/Ryujinx.Graphics.Video/Plane.cs index c0aca59cd8..1a2ad251b9 100644 --- a/Ryujinx.Graphics.Video/Plane.cs +++ b/Ryujinx.Graphics.Video/Plane.cs @@ -1,42 +1,6 @@ using System; -using System.Diagnostics.CodeAnalysis; namespace Ryujinx.Graphics.Video { - public struct Plane : IEquatable - { - public IntPtr Pointer { get; } - public int Length { get; } - - public Plane(IntPtr pointer, int length) - { - Pointer = pointer; - Length = length; - } - - public override bool Equals(object obj) - { - return obj is Plane other && Equals(other); - } - - public bool Equals([AllowNull] Plane other) - { - return Pointer == other.Pointer && Length == other.Length; - } - - public override int GetHashCode() - { - return HashCode.Combine(Pointer, Length); - } - - public static bool operator ==(Plane left, Plane right) - { - return left.Equals(right); - } - - public static bool operator !=(Plane left, Plane right) - { - return !(left == right); - } - } + public readonly record struct Plane(IntPtr Pointer, int Length); } diff --git a/Ryujinx.Graphics.Vulkan/BitMap.cs b/Ryujinx.Graphics.Vulkan/BitMap.cs index ee3c3c938e..efa71fc78d 100644 --- a/Ryujinx.Graphics.Vulkan/BitMap.cs +++ b/Ryujinx.Graphics.Vulkan/BitMap.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Graphics.Vulkan { - struct BitMap + readonly struct BitMap { public const int IntSize = 64; diff --git a/Ryujinx.Graphics.Vulkan/BufferState.cs b/Ryujinx.Graphics.Vulkan/BufferState.cs index 88858e8633..f3a5846954 100644 --- a/Ryujinx.Graphics.Vulkan/BufferState.cs +++ b/Ryujinx.Graphics.Vulkan/BufferState.cs @@ -2,7 +2,7 @@ namespace Ryujinx.Graphics.Vulkan { - struct BufferState : IDisposable + readonly struct BufferState : IDisposable { public static BufferState Null => new BufferState(null, 0, 0); diff --git a/Ryujinx.Graphics.Vulkan/CacheByRange.cs b/Ryujinx.Graphics.Vulkan/CacheByRange.cs index afd7140eb2..a9d1b0ef74 100644 --- a/Ryujinx.Graphics.Vulkan/CacheByRange.cs +++ b/Ryujinx.Graphics.Vulkan/CacheByRange.cs @@ -106,7 +106,7 @@ namespace Ryujinx.Graphics.Vulkan } } - struct TopologyConversionIndirectCacheKey : ICacheKey + readonly struct TopologyConversionIndirectCacheKey : ICacheKey { private readonly TopologyConversionCacheKey _baseKey; private readonly BufferHolder _indirectDataBuffer; @@ -178,7 +178,7 @@ namespace Ryujinx.Graphics.Vulkan } } - struct Dependency + readonly struct Dependency { private readonly BufferHolder _buffer; private readonly int _offset; diff --git a/Ryujinx.Graphics.Vulkan/CommandBufferScoped.cs b/Ryujinx.Graphics.Vulkan/CommandBufferScoped.cs index 372950a88f..1d9e14bb29 100644 --- a/Ryujinx.Graphics.Vulkan/CommandBufferScoped.cs +++ b/Ryujinx.Graphics.Vulkan/CommandBufferScoped.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct CommandBufferScoped : IDisposable + readonly struct CommandBufferScoped : IDisposable { private readonly CommandBufferPool _pool; public CommandBuffer CommandBuffer { get; } diff --git a/Ryujinx.Graphics.Vulkan/DisposableBuffer.cs b/Ryujinx.Graphics.Vulkan/DisposableBuffer.cs index 6d227ca2c3..0f474f970d 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableBuffer.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableBuffer.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableBuffer : IDisposable + readonly struct DisposableBuffer : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableBufferView.cs b/Ryujinx.Graphics.Vulkan/DisposableBufferView.cs index 7d3fe6eee4..28ddd7ddb1 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableBufferView.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableBufferView.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableBufferView : System.IDisposable + readonly struct DisposableBufferView : System.IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableFramebuffer.cs b/Ryujinx.Graphics.Vulkan/DisposableFramebuffer.cs index 5f219a4a09..5b19535474 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableFramebuffer.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableFramebuffer.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableFramebuffer : IDisposable + readonly struct DisposableFramebuffer : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableImage.cs b/Ryujinx.Graphics.Vulkan/DisposableImage.cs index 4e9b3bd42d..c76091b73b 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableImage.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableImage.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableImage : IDisposable + readonly struct DisposableImage : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableImageView.cs b/Ryujinx.Graphics.Vulkan/DisposableImageView.cs index 3509858e36..3b3bf6adfe 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableImageView.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableImageView.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableImageView : IDisposable + readonly struct DisposableImageView : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableMemory.cs b/Ryujinx.Graphics.Vulkan/DisposableMemory.cs index e0b5f09986..638989acdd 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableMemory.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableMemory.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableMemory : IDisposable + readonly struct DisposableMemory : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposablePipeline.cs b/Ryujinx.Graphics.Vulkan/DisposablePipeline.cs index ff069f7e63..6e5cf4dbc6 100644 --- a/Ryujinx.Graphics.Vulkan/DisposablePipeline.cs +++ b/Ryujinx.Graphics.Vulkan/DisposablePipeline.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposablePipeline : IDisposable + readonly struct DisposablePipeline : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableRenderPass.cs b/Ryujinx.Graphics.Vulkan/DisposableRenderPass.cs index f561912afe..65652f4132 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableRenderPass.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableRenderPass.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableRenderPass : IDisposable + readonly struct DisposableRenderPass : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/DisposableSampler.cs b/Ryujinx.Graphics.Vulkan/DisposableSampler.cs index 0b93528f10..4788b192a8 100644 --- a/Ryujinx.Graphics.Vulkan/DisposableSampler.cs +++ b/Ryujinx.Graphics.Vulkan/DisposableSampler.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct DisposableSampler : IDisposable + readonly struct DisposableSampler : IDisposable { private readonly Vk _api; private readonly Device _device; diff --git a/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs b/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs index 7b1beb5ff5..31acfc9b63 100644 --- a/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs +++ b/Ryujinx.Graphics.Vulkan/HardwareCapabilities.cs @@ -2,7 +2,7 @@ namespace Ryujinx.Graphics.Vulkan { - struct HardwareCapabilities + readonly struct HardwareCapabilities { public readonly bool SupportsIndexTypeUint8; public readonly bool SupportsCustomBorderColor; diff --git a/Ryujinx.Graphics.Vulkan/MemoryAllocation.cs b/Ryujinx.Graphics.Vulkan/MemoryAllocation.cs index 04956e36a6..76de129679 100644 --- a/Ryujinx.Graphics.Vulkan/MemoryAllocation.cs +++ b/Ryujinx.Graphics.Vulkan/MemoryAllocation.cs @@ -3,7 +3,7 @@ using System; namespace Ryujinx.Graphics.Vulkan { - struct MemoryAllocation : IDisposable + readonly struct MemoryAllocation : IDisposable { private readonly MemoryAllocatorBlockList _owner; private readonly MemoryAllocatorBlockList.Block _block; diff --git a/Ryujinx.Graphics.Vulkan/MemoryAllocatorBlockList.cs b/Ryujinx.Graphics.Vulkan/MemoryAllocatorBlockList.cs index 1c008d4973..66d339b8c7 100644 --- a/Ryujinx.Graphics.Vulkan/MemoryAllocatorBlockList.cs +++ b/Ryujinx.Graphics.Vulkan/MemoryAllocatorBlockList.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Vulkan public ulong Size { get; } public bool Mapped => HostPointer != IntPtr.Zero; - private struct Range : IComparable + private readonly struct Range : IComparable { public ulong Offset { get; } public ulong Size { get; } diff --git a/Ryujinx.Graphics.Vulkan/StagingBuffer.cs b/Ryujinx.Graphics.Vulkan/StagingBuffer.cs index df353453fc..4e3c1deeaf 100644 --- a/Ryujinx.Graphics.Vulkan/StagingBuffer.cs +++ b/Ryujinx.Graphics.Vulkan/StagingBuffer.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Vulkan private readonly VulkanRenderer _gd; private readonly BufferHolder _buffer; - private struct PendingCopy + private readonly struct PendingCopy { public FenceHolder Fence { get; } public int Size { get; } diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KernelInit.cs b/Ryujinx.HLE/HOS/Kernel/Common/KernelInit.cs index 1949df311c..9829ae0379 100644 --- a/Ryujinx.HLE/HOS/Kernel/Common/KernelInit.cs +++ b/Ryujinx.HLE/HOS/Kernel/Common/KernelInit.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common { static class KernelInit { - private struct MemoryRegion + private readonly struct MemoryRegion { public ulong Address { get; } public ulong Size { get; } diff --git a/Ryujinx.HLE/HOS/Kernel/Common/OnScopeExit.cs b/Ryujinx.HLE/HOS/Kernel/Common/OnScopeExit.cs index 098d83d135..d805a4e17f 100644 --- a/Ryujinx.HLE/HOS/Kernel/Common/OnScopeExit.cs +++ b/Ryujinx.HLE/HOS/Kernel/Common/OnScopeExit.cs @@ -2,7 +2,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common { - struct OnScopeExit : IDisposable + readonly struct OnScopeExit : IDisposable { private readonly Action _action; public OnScopeExit(Action action) => _action = action; diff --git a/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs b/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs index e28677ffe1..dc5ad71774 100644 --- a/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs +++ b/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs @@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc (MemoryState)0xfffce5d4 //This is invalid, shouldn't be accessed. }; - private struct Message + private readonly struct Message { public ulong Address { get; } public ulong Size { get; } @@ -45,7 +45,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc request.CustomCmdBuffSize) { } } - private struct MessageHeader + private readonly struct MessageHeader { public uint Word0 { get; } public uint Word1 { get; } diff --git a/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs b/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs index 26c23b3bb0..c05bb574e3 100644 --- a/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs +++ b/Ryujinx.HLE/HOS/Kernel/Process/ProcessCreationInfo.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { - struct ProcessCreationInfo + readonly struct ProcessCreationInfo { public string Name { get; } diff --git a/Ryujinx.HLE/HOS/ModLoader.cs b/Ryujinx.HLE/HOS/ModLoader.cs index c24f0f745a..3b26951760 100644 --- a/Ryujinx.HLE/HOS/ModLoader.cs +++ b/Ryujinx.HLE/HOS/ModLoader.cs @@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS private const string AmsNroPatchDir = "nro_patches"; private const string AmsKipPatchDir = "kip_patches"; - public struct Mod where T : FileSystemInfo + public readonly struct Mod where T : FileSystemInfo { public readonly string Name; public readonly T Path; diff --git a/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs b/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs index 8cf4bff16f..1793067d0c 100644 --- a/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs +++ b/Ryujinx.HLE/HOS/Services/Account/Acc/Types/UserId.cs @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Account.Acc { [StructLayout(LayoutKind.Sequential)] - public struct UserId : IEquatable + public readonly record struct UserId { public readonly long High; public readonly long Low; @@ -50,37 +50,12 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc return High.ToString("x16") + Low.ToString("x16"); } - public static bool operator ==(UserId x, UserId y) - { - return x.Equals(y); - } - - public static bool operator !=(UserId x, UserId y) - { - return !x.Equals(y); - } - - public override bool Equals(object obj) - { - return obj is UserId userId && Equals(userId); - } - - public bool Equals(UserId cmpObj) - { - return Low == cmpObj.Low && High == cmpObj.High; - } - - public override int GetHashCode() - { - return HashCode.Combine(Low, High); - } - - public readonly Uid ToLibHacUid() + public Uid ToLibHacUid() { return new Uid((ulong)High, (ulong)Low); } - public readonly UInt128 ToUInt128() + public UInt128 ToUInt128() { return new UInt128((ulong)High, (ulong)Low); } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs index a1ad1c941e..0e0fe7f2df 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostAsGpu/NvHostAsGpuDeviceFile.cs @@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu private const ulong SmallRegionLimit = 0x400000000UL; // 16 GiB private const ulong DefaultUserSize = 1UL << 37; - private struct VmRegion + private readonly struct VmRegion { public ulong Start { get; } public ulong Limit { get; } diff --git a/Ryujinx.HLE/HOS/Tamper/OperationBlock.cs b/Ryujinx.HLE/HOS/Tamper/OperationBlock.cs index db43994607..c16c2812ad 100644 --- a/Ryujinx.HLE/HOS/Tamper/OperationBlock.cs +++ b/Ryujinx.HLE/HOS/Tamper/OperationBlock.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Ryujinx.HLE.HOS.Tamper { - struct OperationBlock + readonly struct OperationBlock { public byte[] BaseInstruction { get; } public List Operations { get; } diff --git a/Ryujinx.HLE/Ui/ThemeColor.cs b/Ryujinx.HLE/Ui/ThemeColor.cs index 1a42b16731..c594c370bf 100644 --- a/Ryujinx.HLE/Ui/ThemeColor.cs +++ b/Ryujinx.HLE/Ui/ThemeColor.cs @@ -1,6 +1,6 @@ namespace Ryujinx.HLE.Ui { - public struct ThemeColor + public readonly struct ThemeColor { public float A { get; } public float R { get; } diff --git a/Ryujinx.Horizon.Generators/Kernel/SyscallGenerator.cs b/Ryujinx.Horizon.Generators/Kernel/SyscallGenerator.cs index 2681551b10..2562cd46cf 100644 --- a/Ryujinx.Horizon.Generators/Kernel/SyscallGenerator.cs +++ b/Ryujinx.Horizon.Generators/Kernel/SyscallGenerator.cs @@ -40,7 +40,7 @@ namespace Ryujinx.Horizon.Generators.Kernel $"{TypeKernelResultName}.InvalidState" }; - private struct OutParameter + private readonly struct OutParameter { public readonly string Identifier; public readonly bool NeedsSplit; @@ -104,7 +104,7 @@ namespace Ryujinx.Horizon.Generators.Kernel } } - private struct SyscallIdAndName : IComparable + private readonly struct SyscallIdAndName : IComparable { public readonly int Id; public readonly string Name; diff --git a/Ryujinx.Memory/Range/MemoryRange.cs b/Ryujinx.Memory/Range/MemoryRange.cs index 33d2439f60..7465fbcb37 100644 --- a/Ryujinx.Memory/Range/MemoryRange.cs +++ b/Ryujinx.Memory/Range/MemoryRange.cs @@ -1,11 +1,9 @@ -using System; - -namespace Ryujinx.Memory.Range +namespace Ryujinx.Memory.Range { /// /// Range of memory composed of an address and size. /// - public struct MemoryRange : IEquatable + public readonly record struct MemoryRange { /// /// An empty memory range, with a null address and zero size. @@ -59,20 +57,5 @@ namespace Ryujinx.Memory.Range return thisAddress < otherEndAddress && otherAddress < thisEndAddress; } - - public override bool Equals(object obj) - { - return obj is MemoryRange other && Equals(other); - } - - public bool Equals(MemoryRange other) - { - return Address == other.Address && Size == other.Size; - } - - public override int GetHashCode() - { - return HashCode.Combine(Address, Size); - } } } diff --git a/Ryujinx.Memory/Range/MultiRange.cs b/Ryujinx.Memory/Range/MultiRange.cs index 21ca5f093b..e95af02f4c 100644 --- a/Ryujinx.Memory/Range/MultiRange.cs +++ b/Ryujinx.Memory/Range/MultiRange.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Memory.Range /// /// Sequence of physical memory regions that a single non-contiguous virtual memory region maps to. /// - public struct MultiRange : IEquatable + public readonly struct MultiRange : IEquatable { private readonly MemoryRange _singleRange; private readonly MemoryRange[] _ranges; diff --git a/Ryujinx.Memory/Tracking/BitMap.cs b/Ryujinx.Memory/Tracking/BitMap.cs index d3f15994f1..173952f3c4 100644 --- a/Ryujinx.Memory/Tracking/BitMap.cs +++ b/Ryujinx.Memory/Tracking/BitMap.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Memory.Tracking /// /// A bitmap that can check or set large ranges of true/false values at once. /// - struct BitMap + readonly struct BitMap { public const int IntSize = 64;