diff --git a/.editorconfig b/.editorconfig index 214e54692..9e00e3bae 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 94ac6991b..43e5c7e2c 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 df4b6db1b..587b1a024 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 de0840265..25952c775 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 9652224e5..5b11aac20 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 b1af352bc..302bf4d3c 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 29966d6dd..577ff3946 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 f44c15400..caa93099e 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 17764f7e3..6bde62f56 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 f24308820..d2a3cf218 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 745b31538..241e4d13d 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 fce984c34..dc5503b18 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 3111e886f..4c22de40e 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 cfe5ad1e5..510dec58f 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 775fa3abc..3ec0a7b4f 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 c50b1c3d0..2edbe4011 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 cff6114fa..ea617d4b4 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 3cdf75138..daf7921b5 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 7cf4c2ede..c0a2602f8 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 475e36281..c1abdba9b 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 c1f066555..a9798d278 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 1485ca7d2..d9293302b 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 6f1c8898e..dc8499e9d 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 cc1e17c73..83b8afe24 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 9f0f56c5f..d803d90ba 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 49f834425..5ba50d195 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 9a030c808..ad9ebee48 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 c4428f175..2d38ecccf 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 b3002f8c5..235f4229a 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 c835e9414..4c593392b 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 c525eb601..eb4a016ff 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 05b0ce639..bac44f83a 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 8fb263c47..43f0e25e1 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 9baf1924f..4dd6849bd 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 a7d571de3..e8220974b 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 76e569874..a6fb65aaf 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 887282071..41afb34b0 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 1e207926d..c8fa93d9f 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 fe711c3ad..4c514671c 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 227d64b69..129913ec1 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 ea8e17491..6ab293829 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 c68ba80d6..91d3a6325 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 8c9d1644a..db46c9579 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 3ccfb7009..52b3b11f9 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 b3248b621..4f5ea6a68 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 bcd3b28f5..15f0dff85 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 58135db2c..94012c003 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 640687f00..117961db2 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 ab6f54efb..719e170fd 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 2af7a4023..628eb46a7 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 62f41cbb0..9ee649d2d 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 be94f310e..febe508be 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 a6bb57419..16bfc6931 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 9efd18028..ca54dc2f2 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 571f440e5..65cc698b0 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 5569b9470..d513b7adf 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 2a1408708..b7a0e7264 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 90b9187b4..e763a899c 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 98655ed68..568fe9683 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 0096533d4..959d6e184 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 9261cb0dc..722e66b36 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 356d3f3e4..b65dd75e3 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 b894c57e7..1e34c5ded 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 f26fbdbb3..e9a4f6549 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 23b213b4b..5c045d9ba 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 dbb33d224..e896493c5 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 f96a8ce11..6ca7daef2 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 14f64bbf4..872aaf67c 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 18320c74d..c116d9466 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 61408fc41..90dd4fa05 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 82ac5e7d4..62c499175 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 f5074f485..4ee29d9d0 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 6e0d9ab29..08d242586 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 6aa70691d..aef4dbad3 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 fc9aef7ec..7b2a6b464 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 b78914260..ccc87a7fc 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 f432f1c41..f80c8110b 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 fa0341ee9..04c3be1b8 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 686259ad7..4de056037 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 ddd81cc53..7d94e3f9a 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 80de41d7e..2dd60155e 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 9dafb089f..380c425e5 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 0a64632ef..911f15816 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 30840d8c0..e375096dd 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 799aec24e..aea36423e 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 57253148f..489a59105 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 839edbe9e..1647f6562 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 ef5d7b96d..7961ada89 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 1c5d8c545..073e120a3 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 158ba5ef9..9e31831de 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 ae4107e80..12cd4cd18 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 e53c77af0..b643262fc 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 8c63d72dd..16b8b9240 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 532e9abb8..d9829ac4f 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 f8795c0ff..3fb586cbb 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 a60951e32..e59888a0e 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 35611b987..21c45b386 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 ed5379b34..eb5737283 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 749324bf0..687df22c5 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 03767f8a7..f393eb15c 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 2a13b95c7..8a8dd63a4 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 036b30b63..7c3f507ed 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 c0aca59cd..1a2ad251b 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 ee3c3c938..efa71fc78 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 88858e863..f3a584695 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 afd7140eb..a9d1b0ef7 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 372950a88..1d9e14bb2 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 6d227ca2c..0f474f970 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 7d3fe6eee..28ddd7ddb 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 5f219a4a0..5b1953547 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 4e9b3bd42..c76091b73 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 3509858e3..3b3bf6adf 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 e0b5f0998..638989acd 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 ff069f7e6..6e5cf4dbc 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 f561912af..65652f413 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 0b93528f1..4788b192a 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 7b1beb5ff..31acfc9b6 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 04956e36a..76de12967 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 1c008d497..66d339b8c 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 df353453f..4e3c1deea 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 1949df311..9829ae037 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 098d83d13..d805a4e17 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 e28677ffe..dc5ad7177 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 26c23b3bb..c05bb574e 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 c24f0f745..3b2695176 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 8cf4bff16..1793067d0 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 a1ad1c941..0e0fe7f2d 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 db4399460..c16c2812a 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 1a42b1673..c594c370b 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 2681551b1..2562cd46c 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 33d2439f6..7465fbcb3 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 21ca5f093..e95af02f4 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 d3f15994f..173952f3c 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;