From 3b46bb73f781a011705ecbc8a1d3207dfb145829 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Sun, 2 Jul 2023 02:47:54 +0200 Subject: [Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address or silence dotnet format CA2211 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Another rebase, another dotnet format run * Run dotnet format style after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Remove a few unused parameters * Replace MmeShadowScratch with Array256 * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Address IDE0251 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First pass of dotnet format * Add unsafe dotnet format changes * Fix typos * Add trailing commas * Disable formatting for FormatTable * Address review feedback --- .../Image/TextureDescriptor.cs | 61 ++++++++++++---------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs') diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs index 3e35f8d2..c82a555e 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// struct TextureDescriptor : ITextureDescriptor, IEquatable { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Word0; public uint Word1; public uint Word2; @@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks Maxwell texture format integer. /// /// The texture format integer - public uint UnpackFormat() + public readonly uint UnpackFormat() { return Word0 & 0x8007ffff; } @@ -33,43 +33,43 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the swizzle component for the texture red color channel. /// /// The swizzle component - public TextureComponent UnpackSwizzleR() + public readonly TextureComponent UnpackSwizzleR() { - return(TextureComponent)((Word0 >> 19) & 7); + return (TextureComponent)((Word0 >> 19) & 7); } /// /// Unpacks the swizzle component for the texture green color channel. /// /// The swizzle component - public TextureComponent UnpackSwizzleG() + public readonly TextureComponent UnpackSwizzleG() { - return(TextureComponent)((Word0 >> 22) & 7); + return (TextureComponent)((Word0 >> 22) & 7); } /// /// Unpacks the swizzle component for the texture blue color channel. /// /// The swizzle component - public TextureComponent UnpackSwizzleB() + public readonly TextureComponent UnpackSwizzleB() { - return(TextureComponent)((Word0 >> 25) & 7); + return (TextureComponent)((Word0 >> 25) & 7); } /// /// Unpacks the swizzle component for the texture alpha color channel. /// /// The swizzle component - public TextureComponent UnpackSwizzleA() + public readonly TextureComponent UnpackSwizzleA() { - return(TextureComponent)((Word0 >> 28) & 7); + return (TextureComponent)((Word0 >> 28) & 7); } /// /// Unpacks the 40-bits texture GPU virtual address. /// /// The GPU virtual address - public ulong UnpackAddress() + public readonly ulong UnpackAddress() { return Word1 | ((ulong)(Word2 & 0xffff) << 32); } @@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// This defines the texture layout, among other things. /// /// The texture descriptor type - public TextureDescriptorType UnpackTextureDescriptorType() + public readonly TextureDescriptorType UnpackTextureDescriptorType() { return (TextureDescriptorType)((Word2 >> 21) & 7); } @@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Always 32-bytes aligned. /// /// The linear texture stride - public int UnpackStride() + public readonly int UnpackStride() { return (int)(Word3 & 0xffff) << 5; } @@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Must be always 1, ignored by the GPU. /// /// THe GOB block X size - public int UnpackGobBlocksInX() + public readonly int UnpackGobBlocksInX() { return 1 << (int)(Word3 & 7); } @@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Must be always a power of 2, with a maximum value of 32. /// /// THe GOB block Y size - public int UnpackGobBlocksInY() + public readonly int UnpackGobBlocksInY() { return 1 << (int)((Word3 >> 3) & 7); } @@ -120,7 +120,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Must be 1 for any texture target other than 3D textures. /// /// The GOB block Z size - public int UnpackGobBlocksInZ() + public readonly int UnpackGobBlocksInZ() { return 1 << (int)((Word3 >> 6) & 7); } @@ -130,7 +130,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// This is only used for sparse textures, should be 1 otherwise. /// /// The number of GOB blocks per tile - public int UnpackGobBlocksInTileX() + public readonly int UnpackGobBlocksInTileX() { return 1 << (int)((Word3 >> 10) & 7); } @@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the number of mipmap levels of the texture. /// /// The number of mipmap levels - public int UnpackLevels() + public readonly int UnpackLevels() { return (int)(Word3 >> 28) + 1; } @@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpack the base level texture width size. /// /// The texture width - public int UnpackWidth() + public readonly int UnpackWidth() { return (int)(Word4 & 0xffff) + 1; } @@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpack the width of a buffer texture. /// /// The texture width - public int UnpackBufferTextureWidth() + public readonly int UnpackBufferTextureWidth() { return (int)((Word4 & 0xffff) | (Word3 << 16)) + 1; } @@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the texture sRGB format flag. /// /// True if the texture is sRGB, false otherwise - public bool UnpackSrgb() + public readonly bool UnpackSrgb() { return (Word4 & (1 << 22)) != 0; } @@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the texture target. /// /// The texture target - public TextureTarget UnpackTextureTarget() + public readonly TextureTarget UnpackTextureTarget() { return (TextureTarget)((Word4 >> 23) & 0xf); } @@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Should be ignored for 1D or buffer textures. /// /// The texture height or layers count - public int UnpackHeight() + public readonly int UnpackHeight() { return (int)(Word5 & 0xffff) + 1; } @@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The meaning of this value depends on the texture target. /// /// The texture depth, layer or faces count - public int UnpackDepth() + public readonly int UnpackDepth() { return (int)((Word5 >> 16) & 0x3fff) + 1; } @@ -207,7 +207,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// It must be set to false (by the guest driver) for rectangle textures. /// /// The texture coordinates normalized flag - public bool UnpackTextureCoordNormalized() + public readonly bool UnpackTextureCoordNormalized() { return (Word5 & (1 << 31)) != 0; } @@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the base mipmap level of the texture. /// /// The base mipmap level of the texture - public int UnpackBaseLevel() + public readonly int UnpackBaseLevel() { return (int)(Word7 & 0xf); } @@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Usually equal to Levels minus 1. /// /// The maximum mipmap level (inclusive) of the texture - public int UnpackMaxLevelInclusive() + public readonly int UnpackMaxLevelInclusive() { return (int)((Word7 >> 4) & 0xf); } @@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Must be ignored for non-multisample textures. /// /// The multisample counts enum - public TextureMsaaMode UnpackTextureMsaaMode() + public readonly TextureMsaaMode UnpackTextureMsaaMode() { return (TextureMsaaMode)((Word7 >> 8) & 0xf); } @@ -269,5 +269,10 @@ namespace Ryujinx.Graphics.Gpu.Image { return Unsafe.As>(ref this).GetHashCode(); } + + public override bool Equals(object obj) + { + return obj is TextureDescriptor descriptor && Equals(descriptor); + } } } -- cgit v1.2.3