Procházet zdrojové kódy

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
Andrey Sukharev před 3 roky
rodič
revize
4da44e09cb
100 změnil soubory, kde provedl 117 přidání a 261 odebrání
  1. 1 0
      .editorconfig
  2. 1 1
      ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs
  3. 1 1
      ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs
  4. 1 1
      ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs
  5. 1 1
      ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs
  6. 1 1
      ARMeilleure/CodeGen/X86/IntrinsicInfo.cs
  7. 1 1
      ARMeilleure/Decoders/InstDescriptor.cs
  8. 1 1
      ARMeilleure/Decoders/OpCodeTable.cs
  9. 1 1
      ARMeilleure/Diagnostics/Symbols.cs
  10. 1 1
      ARMeilleure/IntermediateRepresentation/PhiOperation.cs
  11. 1 1
      ARMeilleure/IntermediateRepresentation/Register.cs
  12. 1 1
      ARMeilleure/Translation/Cache/CacheEntry.cs
  13. 1 1
      ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs
  14. 1 1
      ARMeilleure/Translation/CompilerContext.cs
  15. 1 1
      ARMeilleure/Translation/RegisterUsage.cs
  16. 1 1
      ARMeilleure/Translation/Translator.cs
  17. 1 1
      Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOChannelLayout.cs
  18. 1 1
      Ryujinx.Audio.Backends.SoundIo/Native/libsoundio/SoundIOSampleRateRange.cs
  19. 1 1
      Ryujinx.Ava/Ui/Windows/IconColorPicker.cs
  20. 1 1
      Ryujinx.Common/Logging/Logger.cs
  21. 1 1
      Ryujinx.Common/Memory/SpanOrArray.cs
  22. 1 1
      Ryujinx.Cpu/ExceptionCallbacks.cs
  23. 1 1
      Ryujinx.Graphics.Device/RwCallback.cs
  24. 1 1
      Ryujinx.Graphics.GAL/BlendDescriptor.cs
  25. 1 1
      Ryujinx.Graphics.GAL/BufferAssignment.cs
  26. 2 10
      Ryujinx.Graphics.GAL/BufferHandle.cs
  27. 1 1
      Ryujinx.Graphics.GAL/BufferRange.cs
  28. 1 1
      Ryujinx.Graphics.GAL/Capabilities.cs
  29. 1 29
      Ryujinx.Graphics.GAL/ColorF.cs
  30. 1 1
      Ryujinx.Graphics.GAL/DepthTestDescriptor.cs
  31. 1 1
      Ryujinx.Graphics.GAL/DeviceInfo.cs
  32. 1 1
      Ryujinx.Graphics.GAL/Extents2D.cs
  33. 1 1
      Ryujinx.Graphics.GAL/Extents2DF.cs
  34. 1 1
      Ryujinx.Graphics.GAL/HardwareInfo.cs
  35. 1 1
      Ryujinx.Graphics.GAL/ImageCrop.cs
  36. 1 1
      Ryujinx.Graphics.GAL/MultisampleDescriptor.cs
  37. 1 1
      Ryujinx.Graphics.GAL/ProgramPipelineState.cs
  38. 1 1
      Ryujinx.Graphics.GAL/Rectangle.cs
  39. 1 1
      Ryujinx.Graphics.GAL/SamplerCreateInfo.cs
  40. 1 1
      Ryujinx.Graphics.GAL/ScreenCaptureImageInfo.cs
  41. 1 1
      Ryujinx.Graphics.GAL/ShaderBindings.cs
  42. 1 1
      Ryujinx.Graphics.GAL/ShaderSource.cs
  43. 1 1
      Ryujinx.Graphics.GAL/StencilTestDescriptor.cs
  44. 10 10
      Ryujinx.Graphics.GAL/TextureCreateInfo.cs
  45. 1 37
      Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs
  46. 1 1
      Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs
  47. 1 1
      Ryujinx.Graphics.GAL/Viewport.cs
  48. 1 1
      Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs
  49. 1 1
      Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
  50. 1 1
      Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs
  51. 1 1
      Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
  52. 1 1
      Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
  53. 1 1
      Ryujinx.Graphics.Gpu/Image/TextureCache.cs
  54. 1 1
      Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
  55. 1 1
      Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
  56. 1 1
      Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
  57. 1 1
      Ryujinx.Graphics.Gpu/Memory/BufferTextureBinding.cs
  58. 1 1
      Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
  59. 2 2
      Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
  60. 1 1
      Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
  61. 3 3
      Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
  62. 1 1
      Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
  63. 1 1
      Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
  64. 1 1
      Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
  65. 3 3
      Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
  66. 1 1
      Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
  67. 1 1
      Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
  68. 1 16
      Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
  69. 1 1
      Ryujinx.Graphics.Gpu/Window.cs
  70. 1 1
      Ryujinx.Graphics.Host1x/Host1xDevice.cs
  71. 1 1
      Ryujinx.Graphics.Host1x/SyncptIncrManager.cs
  72. 1 1
      Ryujinx.Graphics.Nvdec/FrameDecodedEventArgs.cs
  73. 1 1
      Ryujinx.Graphics.Nvdec/ResourceManager.cs
  74. 1 1
      Ryujinx.Graphics.OpenGL/FormatInfo.cs
  75. 1 1
      Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs
  76. 1 1
      Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs
  77. 1 1
      Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs
  78. 1 1
      Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs
  79. 2 31
      Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs
  80. 1 1
      Ryujinx.Graphics.Shader/Decoders/Block.cs
  81. 1 1
      Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs
  82. 1 1
      Ryujinx.Graphics.Shader/Decoders/Decoder.cs
  83. 1 1
      Ryujinx.Graphics.Shader/Decoders/InstTable.cs
  84. 1 1
      Ryujinx.Graphics.Shader/Decoders/Register.cs
  85. 1 1
      Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs
  86. 1 1
      Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs
  87. 1 1
      Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs
  88. 1 1
      Ryujinx.Graphics.Shader/Translation/EmitterContext.cs
  89. 2 2
      Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs
  90. 1 1
      Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs
  91. 1 30
      Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs
  92. 1 1
      Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs
  93. 1 1
      Ryujinx.Graphics.Shader/Translation/Ssa.cs
  94. 1 1
      Ryujinx.Graphics.Shader/Translation/TranslationOptions.cs
  95. 1 1
      Ryujinx.Graphics.Shader/Translation/Translator.cs
  96. 1 1
      Ryujinx.Graphics.Texture/Region.cs
  97. 1 1
      Ryujinx.Graphics.Texture/Size.cs
  98. 1 1
      Ryujinx.Graphics.Texture/SizeInfo.cs
  99. 1 1
      Ryujinx.Graphics.Texture/Utils/BC7ModeInfo.cs
  100. 1 1
      Ryujinx.Graphics.Vic/Image/Surface.cs

+ 1 - 0
.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

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }
 

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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);
 

+ 1 - 1
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; }

+ 1 - 1
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;

+ 1 - 1
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;
 

+ 1 - 1
ARMeilleure/IntermediateRepresentation/Register.cs

@@ -2,7 +2,7 @@ using System;
 
 namespace ARMeilleure.IntermediateRepresentation
 {
-    struct Register : IEquatable<Register>
+    readonly struct Register : IEquatable<Register>
     {
         public int Index { get; }
 

+ 1 - 1
ARMeilleure/Translation/Cache/CacheEntry.cs

@@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis;
 
 namespace ARMeilleure.Translation.Cache
 {
-    struct CacheEntry : IComparable<CacheEntry>
+    readonly struct CacheEntry : IComparable<CacheEntry>
     {
         public int Offset { get; }
         public int Size   { get; }

+ 1 - 1
ARMeilleure/Translation/Cache/CacheMemoryAllocator.cs

@@ -6,7 +6,7 @@ namespace ARMeilleure.Translation.Cache
 {
     class CacheMemoryAllocator
     {
-        private struct MemoryBlock : IComparable<MemoryBlock>
+        private readonly struct MemoryBlock : IComparable<MemoryBlock>
         {
             public int Offset { get; }
             public int Size { get; }

+ 1 - 1
ARMeilleure/Translation/CompilerContext.cs

@@ -2,7 +2,7 @@ using ARMeilleure.IntermediateRepresentation;
 
 namespace ARMeilleure.Translation
 {
-    struct CompilerContext
+    readonly struct CompilerContext
     {
         public ControlFlowGraph Cfg { get; }
 

+ 1 - 1
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<RegisterMask>
+        private readonly struct RegisterMask : IEquatable<RegisterMask>
         {
             public long IntMask => Mask.GetElement(0);
             public long VecMask => Mask.GetElement(1);

+ 1 - 1
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; }

+ 1 - 1
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
         {

+ 1 - 1
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)
         {

+ 1 - 1
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; }

+ 1 - 1
Ryujinx.Common/Logging/Logger.cs

@@ -16,7 +16,7 @@ namespace Ryujinx.Common.Logging
 
         public static event EventHandler<LogEventArgs> Updated;
 
-        public struct Log
+        public readonly struct Log
         {
             internal readonly LogLevel Level;
 

+ 1 - 1
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.
     /// </summary>
     /// <typeparam name="T">Element Type</typeparam>
-    public ref struct SpanOrArray<T> where T : unmanaged
+    public readonly ref struct SpanOrArray<T> where T : unmanaged
     {
         public readonly T[] Array;
         public readonly ReadOnlySpan<T> Span;

+ 1 - 1
Ryujinx.Cpu/ExceptionCallbacks.cs

@@ -17,7 +17,7 @@ namespace Ryujinx.Cpu
     /// <summary>
     /// Stores handlers for the various CPU exceptions.
     /// </summary>
-    public struct ExceptionCallbacks
+    public readonly struct ExceptionCallbacks
     {
         /// <summary>
         /// Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/>.

+ 1 - 1
Ryujinx.Graphics.Device/RwCallback.cs

@@ -2,7 +2,7 @@
 
 namespace Ryujinx.Graphics.Device
 {
-    public struct RwCallback
+    public readonly struct RwCallback
     {
         public Action<int> Write { get; }
         public Func<int> Read { get; }

+ 1 - 1
Ryujinx.Graphics.GAL/BlendDescriptor.cs

@@ -1,6 +1,6 @@
 namespace Ryujinx.Graphics.GAL
 {
-    public struct BlendDescriptor
+    public readonly struct BlendDescriptor
     {
         public bool Enable { get; }
 

+ 1 - 1
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;

+ 2 - 10
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<BufferHandle>
+    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);
     }
 }

+ 1 - 1
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);
 

+ 1 - 1
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;

+ 1 - 29
Ryujinx.Graphics.GAL/ColorF.cs

@@ -1,32 +1,4 @@
-using System;
-
 namespace Ryujinx.Graphics.GAL
 {
-    public struct ColorF : IEquatable<ColorF>
-    {
-        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);
 }

+ 1 - 1
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; }

+ 1 - 1
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;

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
Ryujinx.Graphics.GAL/ProgramPipelineState.cs

@@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.GAL
     /// <summary>
     /// Descriptor for a pipeline buffer binding.
     /// </summary>
-    public struct BufferPipelineDescriptor
+    public readonly struct BufferPipelineDescriptor
     {
         public bool Enable { get; }
         public int Stride { get; }

+ 1 - 1
Ryujinx.Graphics.GAL/Rectangle.cs

@@ -1,6 +1,6 @@
 namespace Ryujinx.Graphics.GAL
 {
-    public struct Rectangle<T> where T : unmanaged
+    public readonly struct Rectangle<T> where T : unmanaged
     {
         public T X { get; }
         public T Y { get; }

+ 1 - 1
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; }

+ 1 - 1
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)
         {

+ 1 - 1
Ryujinx.Graphics.GAL/ShaderBindings.cs

@@ -2,7 +2,7 @@
 
 namespace Ryujinx.Graphics.GAL
 {
-    public struct ShaderBindings
+    public readonly struct ShaderBindings
     {
         public IReadOnlyCollection<int> UniformBufferBindings { get; }
         public IReadOnlyCollection<int> StorageBufferBindings { get; }

+ 1 - 1
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; }

+ 1 - 1
Ryujinx.Graphics.GAL/StencilTestDescriptor.cs

@@ -1,6 +1,6 @@
 namespace Ryujinx.Graphics.GAL
 {
-    public struct StencilTestDescriptor
+    public readonly struct StencilTestDescriptor
     {
         public bool TestEnable { get; }
 

+ 10 - 10
Ryujinx.Graphics.GAL/TextureCreateInfo.cs

@@ -4,7 +4,7 @@ using System.Numerics;
 
 namespace Ryujinx.Graphics.GAL
 {
-    public struct TextureCreateInfo : IEquatable<TextureCreateInfo>
+    public readonly struct TextureCreateInfo : IEquatable<TextureCreateInfo>
     {
         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;
 

+ 1 - 37
Ryujinx.Graphics.GAL/VertexAttribDescriptor.cs

@@ -1,40 +1,4 @@
-using System;
-
 namespace Ryujinx.Graphics.GAL
 {
-    public struct VertexAttribDescriptor : IEquatable<VertexAttribDescriptor>
-    {
-        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);
 }

+ 1 - 1
Ryujinx.Graphics.GAL/VertexBufferDescriptor.cs

@@ -1,6 +1,6 @@
 namespace Ryujinx.Graphics.GAL
 {
-    public struct VertexBufferDescriptor
+    public readonly struct VertexBufferDescriptor
     {
         public BufferRange Buffer { get; }
 

+ 1 - 1
Ryujinx.Graphics.GAL/Viewport.cs

@@ -1,6 +1,6 @@
 namespace Ryujinx.Graphics.GAL
 {
-    public struct Viewport
+    public readonly struct Viewport
     {
         public Rectangle<float> Region { get; }
 

+ 1 - 1
Ryujinx.Graphics.Gpu/Engine/MME/IMacroEE.cs

@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
     /// <summary>
     /// FIFO word.
     /// </summary>
-    struct FifoWord
+    readonly struct FifoWord
     {
         /// <summary>
         /// GPU virtual address where the word is located in memory.

+ 1 - 1
Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
         /// <summary>
         /// Macroo High-level implementation table entry.
         /// </summary>
-        struct TableEntry
+        readonly struct TableEntry
         {
             /// <summary>
             /// Name of the Macro function.

+ 1 - 1
Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdateTracker.cs

@@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
     /// <summary>
     /// State update callback entry, with the callback function and associated field names.
     /// </summary>
-    struct StateUpdateCallbackEntry
+    readonly struct StateUpdateCallbackEntry
     {
         /// <summary>
         /// Callback function, to be called if the register was written as the state needs to be updated.

+ 1 - 1
Ryujinx.Graphics.Gpu/Image/FormatInfo.cs

@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Image
     /// <summary>
     /// Represents texture format information.
     /// </summary>
-    struct FormatInfo
+    readonly struct FormatInfo
     {
         /// <summary>
         /// A default, generic RGBA8 texture format.

+ 1 - 1
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.
     /// </summary>
-    struct TextureBindingInfo
+    readonly struct TextureBindingInfo
     {
         /// <summary>
         /// Shader sampler target type.

+ 1 - 1
Ryujinx.Graphics.Gpu/Image/TextureCache.cs

@@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image
     /// </summary>
     class TextureCache : IDisposable
     {
-        private struct OverlapInfo
+        private readonly struct OverlapInfo
         {
             public TextureViewCompatibility Compatibility { get; }
             public int FirstLayer { get; }

+ 1 - 1
Ryujinx.Graphics.Gpu/Image/TextureGroup.cs

@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Image
     /// <summary>
     /// An overlapping texture group with a given view compatibility.
     /// </summary>
-    struct TextureIncompatibleOverlap
+    readonly struct TextureIncompatibleOverlap
     {
         public readonly TextureGroup Group;
         public readonly TextureViewCompatibility Compatibility;

+ 1 - 1
Ryujinx.Graphics.Gpu/Image/TextureInfo.cs

@@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Gpu.Image
     /// <summary>
     /// Texture information.
     /// </summary>
-    struct TextureInfo
+    readonly struct TextureInfo
     {
         /// <summary>
         /// Address of the texture in GPU mapped memory.

+ 1 - 1
Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs

@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
     /// <summary>
     /// Memory range used for buffers.
     /// </summary>
-    struct BufferBounds
+    readonly struct BufferBounds
     {
         /// <summary>
         /// Region virtual address.

+ 1 - 1
Ryujinx.Graphics.Gpu/Memory/BufferTextureBinding.cs

@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
     /// <summary>
     /// A buffer binding to apply to a buffer texture.
     /// </summary>
-    struct BufferTextureBinding
+    readonly struct BufferTextureBinding
     {
         /// <summary>
         /// Shader stage accessing the texture.

+ 1 - 1
Ryujinx.Graphics.Gpu/Memory/CounterCache.cs

@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
     /// </summary>
     class CounterCache
     {
-        private struct CounterEntry
+        private readonly struct CounterEntry
         {
             public ulong Address { get; }
             public ICounterEvent Event { get; }

+ 2 - 2
Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs

@@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
         /// <summary>
         /// Represents an operation to perform on the <see cref="_fileWriterWorkerQueue"/>.
         /// </summary>
-        private struct CacheFileOperationTask
+        private readonly struct CacheFileOperationTask
         {
             /// <summary>
             /// The type of operation to perform.
@@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
         /// <summary>
         /// Background shader cache write information.
         /// </summary>
-        private struct AddShaderData
+        private readonly struct AddShaderData
         {
             /// <summary>
             /// Cached shader program.

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs

@@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
     /// <summary>
     /// Guest shader code and constant buffer data accessed by the shader.
     /// </summary>
-    struct GuestCodeAndCbData
+    readonly struct GuestCodeAndCbData
     {
         /// <summary>
         /// Maxwell binary shader code.

+ 3 - 3
Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs

@@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
         /// <summary>
         /// Program validation entry.
         /// </summary>
-        private struct ProgramEntry
+        private readonly struct ProgramEntry
         {
             /// <summary>
             /// Cached shader program.
@@ -90,7 +90,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
         /// <summary>
         /// Translated shader compilation entry.
         /// </summary>
-        private struct ProgramCompilation
+        private readonly struct ProgramCompilation
         {
             /// <summary>
             /// Translated shader stages.
@@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
         /// <summary>
         /// Program translation entry.
         /// </summary>
-        private struct AsyncProgramTranslation
+        private readonly struct AsyncProgramTranslation
         {
             /// <summary>
             /// Guest code for each active stage.

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs

@@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
     /// <summary>
     /// State used by the <see cref="GpuAccessor"/>.
     /// </summary>
-    struct GpuChannelComputeState
+    readonly struct GpuChannelComputeState
     {
         // New fields should be added to the end of the struct to keep disk shader cache compatibility.
 

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs

@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
     /// <summary>
     /// State used by the <see cref="GpuAccessor"/>.
     /// </summary>
-    struct GpuChannelPoolState : IEquatable<GpuChannelPoolState>
+    readonly struct GpuChannelPoolState : IEquatable<GpuChannelPoolState>
     {
         /// <summary>
         /// GPU virtual address of the texture pool.

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs

@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
         /// <summary>
         /// Entry for a given data size.
         /// </summary>
-        private struct SizeEntry
+        private readonly struct SizeEntry
         {
             /// <summary>
             /// Size for the data that will be stored on the hash table on this entry.

+ 3 - 3
Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs

@@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
         /// </summary>
         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<ulong, CachedShaderProgram> _cpPrograms;
         private readonly Dictionary<ShaderAddresses, CachedShaderProgram> _gpPrograms;
 
-        private struct ProgramToSave
+        private readonly struct ProgramToSave
         {
             public readonly CachedShaderProgram CachedProgram;
             public readonly IProgram HostProgram;

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs

@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
     /// <summary>
     /// Shader code accessor.
     /// </summary>
-    struct ShaderCodeAccessor : IDataAccessor
+    readonly struct ShaderCodeAccessor : IDataAccessor
     {
         private readonly MemoryManager _memoryManager;
         private readonly ulong _baseAddress;

+ 1 - 1
Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs

@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
     /// <summary>
     /// Paths where shader code was dumped on disk.
     /// </summary>
-    struct ShaderDumpPaths
+    readonly struct ShaderDumpPaths
     {
         /// <summary>
         /// Path where the full shader code with header was dumped, or null if not dumped.

+ 1 - 16
Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs

@@ -121,7 +121,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
         /// <summary>
         /// Texture binding information, used to identify each texture accessed by the shader.
         /// </summary>
-        private struct TextureKey : IEquatable<TextureKey>
+        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<TextureKey, Box<TextureSpecializationState>> _textureSpecialization;

+ 1 - 1
Ryujinx.Graphics.Gpu/Window.cs

@@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Gpu
         /// <summary>
         /// Texture presented on the window.
         /// </summary>
-        private struct PresentationTexture
+        private readonly struct PresentationTexture
         {
             /// <summary>
             /// Texture cache where the texture might be located.

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }
 

+ 1 - 1
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; }
 

+ 1 - 1
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);
 

+ 1 - 1
Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvDelegates.cs

@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
     /// <summary>
     /// Delegate cache for SPIR-V instruction generators. Avoids delegate allocation when passing generators as arguments.
     /// </summary>
-    internal struct SpirvDelegates
+    internal readonly struct SpirvDelegates
     {
         // Unary
         public readonly FuncUnaryInstruction GlslFAbs;

+ 2 - 31
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<TextureMeta>
-    {
-        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);
 }

+ 1 - 1
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; }

+ 1 - 1
Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs

@@ -4,7 +4,7 @@ using System.Collections.Generic;
 
 namespace Ryujinx.Graphics.Shader.Decoders
 {
-    struct DecodedProgram : IEnumerable<DecodedFunction>
+    readonly struct DecodedProgram : IEnumerable<DecodedFunction>
     {
         public DecodedFunction MainFunction { get; }
         private readonly IReadOnlyDictionary<ulong, DecodedFunction> _functions;

+ 1 - 1
Ryujinx.Graphics.Shader/Decoders/Decoder.cs

@@ -473,7 +473,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
             op = Unsafe.As<ulong, T>(ref rawOp);
         }
 
-        private struct BlockLocation
+        private readonly struct BlockLocation
         {
             public Block Block { get; }
             public int Index { get; }

+ 1 - 1
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; }

+ 1 - 1
Ryujinx.Graphics.Shader/Decoders/Register.cs

@@ -2,7 +2,7 @@ using System;
 
 namespace Ryujinx.Graphics.Shader.Decoders
 {
-    struct Register : IEquatable<Register>
+    readonly struct Register : IEquatable<Register>
     {
         public int Index { get; }
 

+ 1 - 1
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; }
 

+ 1 - 1
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;

+ 1 - 1
Ryujinx.Graphics.Shader/Translation/AttributeInfo.cs

@@ -2,7 +2,7 @@
 
 namespace Ryujinx.Graphics.Shader.Translation
 {
-    struct AttributeInfo
+    readonly struct AttributeInfo
     {
         private static readonly Dictionary<int, AttributeInfo> _builtInAttributes = new Dictionary<int, AttributeInfo>()
         {

+ 1 - 1
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;

+ 2 - 2
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; }

+ 1 - 1
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; }

+ 1 - 30
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<TextureInfo>
-        {
-            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
         {

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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; }
 

+ 1 - 1
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; }

+ 1 - 1
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; }

+ 1 - 1
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;
 

+ 1 - 1
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;

+ 1 - 1
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;
 

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů