[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 <Acoustik666@gmail.com> * Address review feedback * Update src/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
parent
fc20d9b925
commit
cebfa54467
25 changed files with 741 additions and 630 deletions
File diff suppressed because it is too large
Load diff
|
@ -6,4 +6,4 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
{
|
||||
public AstcDecoderException(string exMsg) : base(exMsg) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
Components[index] = (short)value;
|
||||
}
|
||||
|
||||
public int Pack()
|
||||
public readonly int Pack()
|
||||
{
|
||||
return A << 24 |
|
||||
B << 16 |
|
||||
|
|
|
@ -6,7 +6,9 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
{
|
||||
public struct BitStream128
|
||||
{
|
||||
#pragma warning disable IDE0044 // Make field readonly
|
||||
private Buffer16 _data;
|
||||
#pragma warning restore IDE0044
|
||||
public int BitsLeft { get; set; }
|
||||
|
||||
public BitStream128(Buffer16 data)
|
||||
|
@ -42,7 +44,10 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
{
|
||||
Debug.Assert(bitCount < 32);
|
||||
|
||||
if (bitCount == 0) return;
|
||||
if (bitCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ulong maskedValue = (uint)(value & ((1 << bitCount) - 1));
|
||||
|
||||
|
@ -69,4 +74,4 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
BitsLeft += bitCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,15 @@
|
|||
|
||||
public static int Replicate(int value, int numberBits, int toBit)
|
||||
{
|
||||
if (numberBits == 0) return 0;
|
||||
if (toBit == 0) return 0;
|
||||
if (numberBits == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (toBit == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tempValue = value & ((1 << numberBits) - 1);
|
||||
int retValue = tempValue;
|
||||
|
@ -60,7 +67,10 @@
|
|||
b |= a & 0x80;
|
||||
a >>= 1;
|
||||
a &= 0x3F;
|
||||
if ((a & 0x20) != 0) a -= 0x40;
|
||||
if ((a & 0x20) != 0)
|
||||
{
|
||||
a -= 0x40;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
internal struct IntegerEncoded
|
||||
{
|
||||
internal const int StructSize = 8;
|
||||
private static readonly IntegerEncoded[] Encodings;
|
||||
private static readonly IntegerEncoded[] _encodings;
|
||||
|
||||
public enum EIntegerEncoding : byte
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
Trit
|
||||
}
|
||||
|
||||
EIntegerEncoding _encoding;
|
||||
readonly EIntegerEncoding _encoding;
|
||||
public byte NumberBits { get; private set; }
|
||||
public byte TritValue { get; private set; }
|
||||
public byte QuintValue { get; private set; }
|
||||
|
@ -23,11 +23,11 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
|
||||
static IntegerEncoded()
|
||||
{
|
||||
Encodings = new IntegerEncoded[0x100];
|
||||
_encodings = new IntegerEncoded[0x100];
|
||||
|
||||
for (int i = 0; i < Encodings.Length; i++)
|
||||
for (int i = 0; i < _encodings.Length; i++)
|
||||
{
|
||||
Encodings[i] = CreateEncodingCalc(i);
|
||||
_encodings[i] = CreateEncodingCalc(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,17 +40,17 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
QuintValue = 0;
|
||||
}
|
||||
|
||||
public bool MatchesEncoding(IntegerEncoded other)
|
||||
public readonly bool MatchesEncoding(IntegerEncoded other)
|
||||
{
|
||||
return _encoding == other._encoding && NumberBits == other.NumberBits;
|
||||
}
|
||||
|
||||
public EIntegerEncoding GetEncoding()
|
||||
public readonly EIntegerEncoding GetEncoding()
|
||||
{
|
||||
return _encoding;
|
||||
}
|
||||
|
||||
public int GetBitLength(int numberVals)
|
||||
public readonly int GetBitLength(int numberVals)
|
||||
{
|
||||
int totalBits = NumberBits * numberVals;
|
||||
if (_encoding == EIntegerEncoding.Trit)
|
||||
|
@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
|
||||
public static IntegerEncoded CreateEncoding(int maxVal)
|
||||
{
|
||||
return Encodings[maxVal];
|
||||
return _encodings[maxVal];
|
||||
}
|
||||
|
||||
private static IntegerEncoded CreateEncodingCalc(int maxVal)
|
||||
|
@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
|
||||
ReadOnlySpan<byte> encodings = GetTritEncoding(encoded);
|
||||
|
||||
IntegerEncoded intEncoded = new IntegerEncoded(EIntegerEncoding.Trit, numberBitsPerValue);
|
||||
IntegerEncoded intEncoded = new(EIntegerEncoding.Trit, numberBitsPerValue);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
IntegerEncoded intEncoded = new IntegerEncoded(EIntegerEncoding.Quint, numberBitsPerValue)
|
||||
IntegerEncoded intEncoded = new(EIntegerEncoding.Quint, numberBitsPerValue)
|
||||
{
|
||||
BitValue = m[i],
|
||||
QuintValue = encodings[i]
|
||||
|
@ -185,29 +185,29 @@ namespace Ryujinx.Graphics.Texture.Astc
|
|||
switch (intEncoded.GetEncoding())
|
||||
{
|
||||
case EIntegerEncoding.Quint:
|
||||
{
|
||||
DecodeQuintBlock(ref bitStream, ref decodeIntegerSequence, intEncoded.NumberBits);
|
||||
numberValuesDecoded += 3;
|
||||
{
|
||||
DecodeQuintBlock(ref bitStream, ref decodeIntegerSequence, intEncoded.NumberBits);
|
||||
numberValuesDecoded += 3;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EIntegerEncoding.Trit:
|
||||
{
|
||||
DecodeTritBlock(ref bitStream, ref decodeIntegerSequence, intEncoded.NumberBits);
|
||||
numberValuesDecoded += 5;
|
||||
{
|
||||
DecodeTritBlock(ref bitStream, ref decodeIntegerSequence, intEncoded.NumberBits);
|
||||
numberValuesDecoded += 5;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EIntegerEncoding.JustBits:
|
||||
{
|
||||
intEncoded.BitValue = bitStream.ReadBits(intEncoded.NumberBits);
|
||||
decodeIntegerSequence.Add(ref intEncoded);
|
||||
numberValuesDecoded++;
|
||||
{
|
||||
intEncoded.BitValue = bitStream.ReadBits(intEncoded.NumberBits);
|
||||
decodeIntegerSequence.Add(ref intEncoded);
|
||||
numberValuesDecoded++;
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue