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/SamplerDescriptor.cs | 52 ++++++++++++---------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs') diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs index 64a146fb..e04c31df 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs @@ -43,17 +43,17 @@ namespace Ryujinx.Graphics.Gpu.Image 0.45833334f, 0.46153846f, 0.4642857f, - 0.46666667f + 0.46666667f, }; private static readonly float[] _maxAnisotropyLut = new float[] { - 1, 2, 4, 6, 8, 10, 12, 16 + 1, 2, 4, 6, 8, 10, 12, 16, }; private const float Frac8ToF32 = 1.0f / 256.0f; -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Word0; public uint Word1; public uint Word2; @@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the texture wrap mode along the X axis. /// /// The texture wrap mode enum - public AddressMode UnpackAddressU() + public readonly AddressMode UnpackAddressU() { return (AddressMode)(Word0 & 7); } @@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the texture wrap mode along the Y axis. /// /// The texture wrap mode enum - public AddressMode UnpackAddressV() + public readonly AddressMode UnpackAddressV() { return (AddressMode)((Word0 >> 3) & 7); } @@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the texture wrap mode along the Z axis. /// /// The texture wrap mode enum - public AddressMode UnpackAddressP() + public readonly AddressMode UnpackAddressP() { return (AddressMode)((Word0 >> 6) & 7); } @@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// This is only relevant for shaders with shadow samplers. /// /// The depth comparison mode enum - public CompareMode UnpackCompareMode() + public readonly CompareMode UnpackCompareMode() { return (CompareMode)((Word0 >> 9) & 1); } @@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// This is only relevant for shaders with shadow samplers. /// /// The depth comparison operation enum - public CompareOp UnpackCompareOp() + public readonly CompareOp UnpackCompareOp() { return (CompareOp)(((Word0 >> 10) & 7) + 1); } @@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks and converts the maximum anisotropy value used for texture anisotropic filtering. /// /// The maximum anisotropy - public float UnpackMaxAnisotropy() + public readonly float UnpackMaxAnisotropy() { return _maxAnisotropyLut[(Word0 >> 20) & 7]; } @@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// that is larger than the texture size. /// /// The magnification filter - public MagFilter UnpackMagFilter() + public readonly MagFilter UnpackMagFilter() { return (MagFilter)(Word1 & 3); } @@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// that is smaller than the texture size. /// /// The minification filter - public MinFilter UnpackMinFilter() + public readonly MinFilter UnpackMinFilter() { SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3); SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3); @@ -161,24 +161,30 @@ namespace Ryujinx.Graphics.Gpu.Image case SamplerMipFilter.None: switch (minFilter) { - case SamplerMinFilter.Nearest: return MinFilter.Nearest; - case SamplerMinFilter.Linear: return MinFilter.Linear; + case SamplerMinFilter.Nearest: + return MinFilter.Nearest; + case SamplerMinFilter.Linear: + return MinFilter.Linear; } break; case SamplerMipFilter.Nearest: switch (minFilter) { - case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapNearest; - case SamplerMinFilter.Linear: return MinFilter.LinearMipmapNearest; + case SamplerMinFilter.Nearest: + return MinFilter.NearestMipmapNearest; + case SamplerMinFilter.Linear: + return MinFilter.LinearMipmapNearest; } break; case SamplerMipFilter.Linear: switch (minFilter) { - case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapLinear; - case SamplerMinFilter.Linear: return MinFilter.LinearMipmapLinear; + case SamplerMinFilter.Nearest: + return MinFilter.NearestMipmapLinear; + case SamplerMinFilter.Linear: + return MinFilter.LinearMipmapLinear; } break; } @@ -190,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the seamless cubemap flag. /// /// The seamless cubemap flag - public bool UnpackSeamlessCubemap() + public readonly bool UnpackSeamlessCubemap() { return (Word1 & (1 << 9)) != 0; } @@ -200,7 +206,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// This describes how the final value will be computed from neighbouring pixels. /// /// The reduction filter - public ReductionFilter UnpackReductionFilter() + public readonly ReductionFilter UnpackReductionFilter() { return (ReductionFilter)((Word1 >> 10) & 3); } @@ -211,7 +217,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// which mipmap level to use from a given texture. /// /// The level-of-detail bias value - public float UnpackMipLodBias() + public readonly float UnpackMipLodBias() { int fixedValue = (int)(Word1 >> 12) & 0x1fff; @@ -224,7 +230,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the level-of-detail snap value. /// /// The level-of-detail snap value - public float UnpackLodSnap() + public readonly float UnpackLodSnap() { return _f5ToF32ConversionLut[(Word1 >> 26) & 0x1f]; } @@ -233,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the minimum level-of-detail value. /// /// The minimum level-of-detail value - public float UnpackMinLod() + public readonly float UnpackMinLod() { return (Word2 & 0xfff) * Frac8ToF32; } @@ -242,7 +248,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// Unpacks the maximum level-of-detail value. /// /// The maximum level-of-detail value - public float UnpackMaxLod() + public readonly float UnpackMaxLod() { return ((Word2 >> 12) & 0xfff) * Frac8ToF32; } -- cgit v1.2.3