From cebfa54467231f0d1ca43021608b8b1ab03f39fb Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 28 Jun 2023 18:46:18 +0200 Subject: [Ryujinx.Graphics.Texture] Address dotnet-format issues (#5375) * dotnet format style --severity info Some changes were manually reverted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0059 warnings * Address or silence dotnet format CA2208 warnings * 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 * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * 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 dotnet format pass * Apply suggestions from code review Co-authored-by: Ac_K * Address review feedback * Update src/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs Co-authored-by: Ac_K --------- Co-authored-by: Ac_K --- src/Ryujinx.Graphics.Texture/BCnDecoder.cs | 64 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/Ryujinx.Graphics.Texture/BCnDecoder.cs') diff --git a/src/Ryujinx.Graphics.Texture/BCnDecoder.cs b/src/Ryujinx.Graphics.Texture/BCnDecoder.cs index b21fa4d1..2d68ca34 100644 --- a/src/Ryujinx.Graphics.Texture/BCnDecoder.cs +++ b/src/Ryujinx.Graphics.Texture/BCnDecoder.cs @@ -54,10 +54,10 @@ namespace Ryujinx.Graphics.Texture if (copyHeight == 4) { - outputLine0 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs)); - outputLine1 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width)); - outputLine2 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width * 2)); - outputLine3 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width * 3)); + outputLine0 = MemoryMarshal.Cast>(outputAsUint[lineBaseOOffs..]); + outputLine1 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width)..]); + outputLine2 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width * 2)..]); + outputLine3 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width * 3)..]); } for (int x = 0; x < w; x++) @@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Texture } } - data = data.Slice(8); + data = data[8..]; } } @@ -142,10 +142,10 @@ namespace Ryujinx.Graphics.Texture if (copyHeight == 4) { - outputLine0 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs)); - outputLine1 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width)); - outputLine2 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width * 2)); - outputLine3 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width * 3)); + outputLine0 = MemoryMarshal.Cast>(outputAsUint[lineBaseOOffs..]); + outputLine1 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width)..]); + outputLine2 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width * 2)..]); + outputLine3 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width * 3)..]); } for (int x = 0; x < w; x++) @@ -153,7 +153,7 @@ namespace Ryujinx.Graphics.Texture int baseX = x * BlockWidth; int copyWidth = Math.Min(BlockWidth, width - baseX); - BC23DecodeTileRgb(tile, data.Slice(8)); + BC23DecodeTileRgb(tile, data[8..]); ulong block = BinaryPrimitives.ReadUInt64LittleEndian(data); @@ -179,7 +179,7 @@ namespace Ryujinx.Graphics.Texture } } - data = data.Slice(16); + data = data[16..]; } } @@ -238,10 +238,10 @@ namespace Ryujinx.Graphics.Texture if (copyHeight == 4) { - outputLine0 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs)); - outputLine1 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width)); - outputLine2 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width * 2)); - outputLine3 = MemoryMarshal.Cast>(outputAsUint.Slice(lineBaseOOffs + width * 3)); + outputLine0 = MemoryMarshal.Cast>(outputAsUint[lineBaseOOffs..]); + outputLine1 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width)..]); + outputLine2 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width * 2)..]); + outputLine3 = MemoryMarshal.Cast>(outputAsUint[(lineBaseOOffs + width * 3)..]); } for (int x = 0; x < w; x++) @@ -249,7 +249,7 @@ namespace Ryujinx.Graphics.Texture int baseX = x * BlockWidth; int copyWidth = Math.Min(BlockWidth, width - baseX); - BC23DecodeTileRgb(tile, data.Slice(8)); + BC23DecodeTileRgb(tile, data[8..]); ulong block = BinaryPrimitives.ReadUInt64LittleEndian(data); @@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Texture } } - data = data.Slice(16); + data = data[16..]; } } @@ -305,7 +305,7 @@ namespace Ryujinx.Graphics.Texture int alignedWidth = BitUtils.AlignUp(width, 4); byte[] output = new byte[size]; - Span outputSpan = new Span(output); + Span outputSpan = new(output); ReadOnlySpan data64 = MemoryMarshal.Cast(data); @@ -338,10 +338,10 @@ namespace Ryujinx.Graphics.Texture if (copyHeight == 4) { - outputLine0 = MemoryMarshal.Cast(outputSpan.Slice(lineBaseOOffs)); - outputLine1 = MemoryMarshal.Cast(outputSpan.Slice(lineBaseOOffs + alignedWidth)); - outputLine2 = MemoryMarshal.Cast(outputSpan.Slice(lineBaseOOffs + alignedWidth * 2)); - outputLine3 = MemoryMarshal.Cast(outputSpan.Slice(lineBaseOOffs + alignedWidth * 3)); + outputLine0 = MemoryMarshal.Cast(outputSpan[lineBaseOOffs..]); + outputLine1 = MemoryMarshal.Cast(outputSpan[(lineBaseOOffs + alignedWidth)..]); + outputLine2 = MemoryMarshal.Cast(outputSpan[(lineBaseOOffs + alignedWidth * 2)..]); + outputLine3 = MemoryMarshal.Cast(outputSpan[(lineBaseOOffs + alignedWidth * 3)..]); } for (int x = 0; x < w; x++) @@ -382,7 +382,7 @@ namespace Ryujinx.Graphics.Texture } } - data64 = data64.Slice(1); + data64 = data64[1..]; } } @@ -450,10 +450,10 @@ namespace Ryujinx.Graphics.Texture if (copyHeight == 4) { - outputLine0 = MemoryMarshal.Cast(outputAsUshort.Slice(lineBaseOOffs)); - outputLine1 = MemoryMarshal.Cast(outputAsUshort.Slice(lineBaseOOffs + alignedWidth)); - outputLine2 = MemoryMarshal.Cast(outputAsUshort.Slice(lineBaseOOffs + alignedWidth * 2)); - outputLine3 = MemoryMarshal.Cast(outputAsUshort.Slice(lineBaseOOffs + alignedWidth * 3)); + outputLine0 = MemoryMarshal.Cast(outputAsUshort[lineBaseOOffs..]); + outputLine1 = MemoryMarshal.Cast(outputAsUshort[(lineBaseOOffs + alignedWidth)..]); + outputLine2 = MemoryMarshal.Cast(outputAsUshort[(lineBaseOOffs + alignedWidth * 2)..]); + outputLine3 = MemoryMarshal.Cast(outputAsUshort[(lineBaseOOffs + alignedWidth * 3)..]); } for (int x = 0; x < w; x++) @@ -507,7 +507,7 @@ namespace Ryujinx.Graphics.Texture } } - data64 = data64.Slice(2); + data64 = data64[2..]; } } @@ -548,7 +548,7 @@ namespace Ryujinx.Graphics.Texture { for (int z = 0; z < depth; z++) { - BC6Decoder.Decode(output.AsSpan().Slice(outputOffset), data.Slice(inputOffset), width, height, signed); + BC6Decoder.Decode(output.AsSpan()[outputOffset..], data[inputOffset..], width, height, signed); inputOffset += w * h * 16; outputOffset += width * height * 8; @@ -586,7 +586,7 @@ namespace Ryujinx.Graphics.Texture { for (int z = 0; z < depth; z++) { - BC7Decoder.Decode(output.AsSpan().Slice(outputOffset), data.Slice(inputOffset), width, height); + BC7Decoder.Decode(output.AsSpan()[outputOffset..], data[inputOffset..], width, height); inputOffset += w * h * 16; outputOffset += width * height * 4; @@ -813,7 +813,7 @@ namespace Ryujinx.Graphics.Texture { Span outputAsUint = MemoryMarshal.Cast(output); - uint indices = BinaryPrimitives.ReadUInt32LittleEndian(input.Slice(4)); + uint indices = BinaryPrimitives.ReadUInt32LittleEndian(input[4..]); for (int i = 0; i < BlockWidth * BlockHeight; i++, indices >>= 2) { @@ -891,4 +891,4 @@ namespace Ryujinx.Graphics.Texture return r | (g & 0xff00) | (b & 0xff0000); } } -} \ No newline at end of file +} -- cgit v1.2.3