From 4da44e09cb2a32f69b4a6b47221117b78e4618dc Mon Sep 17 00:00:00 2001 From: Andrey Sukharev Date: Mon, 5 Dec 2022 16:47:39 +0300 Subject: 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 --- Ryujinx.Graphics.GAL/TextureCreateInfo.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Ryujinx.Graphics.GAL/TextureCreateInfo.cs') diff --git a/Ryujinx.Graphics.GAL/TextureCreateInfo.cs b/Ryujinx.Graphics.GAL/TextureCreateInfo.cs index 3ccfb700..52b3b11f 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; -- cgit v1.2.3