Move solution and projects to src
This commit is contained in:
parent
cd124bda58
commit
cee7121058
3466 changed files with 55 additions and 55 deletions
1621
src/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
Normal file
1621
src/Ryujinx.Graphics.Texture/Astc/AstcDecoder.cs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
public class AstcDecoderException : Exception
|
||||
{
|
||||
public AstcDecoderException(string exMsg) : base(exMsg) { }
|
||||
}
|
||||
}
|
68
src/Ryujinx.Graphics.Texture/Astc/AstcPixel.cs
Normal file
68
src/Ryujinx.Graphics.Texture/Astc/AstcPixel.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct AstcPixel
|
||||
{
|
||||
internal const int StructSize = 12;
|
||||
|
||||
public short A;
|
||||
public short R;
|
||||
public short G;
|
||||
public short B;
|
||||
|
||||
private uint _bitDepthInt;
|
||||
|
||||
private Span<byte> BitDepth => MemoryMarshal.CreateSpan(ref Unsafe.As<uint, byte>(ref _bitDepthInt), 4);
|
||||
private Span<short> Components => MemoryMarshal.CreateSpan(ref A, 4);
|
||||
|
||||
public AstcPixel(short a, short r, short g, short b)
|
||||
{
|
||||
A = a;
|
||||
R = r;
|
||||
G = g;
|
||||
B = b;
|
||||
|
||||
_bitDepthInt = 0x08080808;
|
||||
}
|
||||
|
||||
public void ClampByte()
|
||||
{
|
||||
R = Math.Min(Math.Max(R, (short)0), (short)255);
|
||||
G = Math.Min(Math.Max(G, (short)0), (short)255);
|
||||
B = Math.Min(Math.Max(B, (short)0), (short)255);
|
||||
A = Math.Min(Math.Max(A, (short)0), (short)255);
|
||||
}
|
||||
|
||||
public short GetComponent(int index)
|
||||
{
|
||||
return Components[index];
|
||||
}
|
||||
|
||||
public void SetComponent(int index, int value)
|
||||
{
|
||||
Components[index] = (short)value;
|
||||
}
|
||||
|
||||
public int Pack()
|
||||
{
|
||||
return A << 24 |
|
||||
B << 16 |
|
||||
G << 8 |
|
||||
R << 0;
|
||||
}
|
||||
|
||||
// Adds more precision to the blue channel as described
|
||||
// in C.2.14
|
||||
public static AstcPixel BlueContract(int a, int r, int g, int b)
|
||||
{
|
||||
return new AstcPixel((short)(a),
|
||||
(short)((r + b) >> 1),
|
||||
(short)((g + b) >> 1),
|
||||
(short)(b));
|
||||
}
|
||||
}
|
||||
}
|
72
src/Ryujinx.Graphics.Texture/Astc/BitStream128.cs
Normal file
72
src/Ryujinx.Graphics.Texture/Astc/BitStream128.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
public struct BitStream128
|
||||
{
|
||||
private Buffer16 _data;
|
||||
public int BitsLeft { get; set; }
|
||||
|
||||
public BitStream128(Buffer16 data)
|
||||
{
|
||||
_data = data;
|
||||
BitsLeft = 128;
|
||||
}
|
||||
|
||||
public int ReadBits(int bitCount)
|
||||
{
|
||||
Debug.Assert(bitCount < 32);
|
||||
|
||||
if (bitCount == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mask = (1 << bitCount) - 1;
|
||||
int value = _data.As<int>() & mask;
|
||||
|
||||
Span<ulong> span = _data.AsSpan<ulong>();
|
||||
|
||||
ulong carry = span[1] << (64 - bitCount);
|
||||
span[0] = (span[0] >> bitCount) | carry;
|
||||
span[1] >>= bitCount;
|
||||
|
||||
BitsLeft -= bitCount;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public void WriteBits(int value, int bitCount)
|
||||
{
|
||||
Debug.Assert(bitCount < 32);
|
||||
|
||||
if (bitCount == 0) return;
|
||||
|
||||
ulong maskedValue = (uint)(value & ((1 << bitCount) - 1));
|
||||
|
||||
Span<ulong> span = _data.AsSpan<ulong>();
|
||||
|
||||
if (BitsLeft < 64)
|
||||
{
|
||||
ulong lowMask = maskedValue << BitsLeft;
|
||||
span[0] |= lowMask;
|
||||
}
|
||||
|
||||
if (BitsLeft + bitCount > 64)
|
||||
{
|
||||
if (BitsLeft > 64)
|
||||
{
|
||||
span[1] |= maskedValue << (BitsLeft - 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
span[1] |= maskedValue >> (64 - BitsLeft);
|
||||
}
|
||||
}
|
||||
|
||||
BitsLeft += bitCount;
|
||||
}
|
||||
}
|
||||
}
|
66
src/Ryujinx.Graphics.Texture/Astc/Bits.cs
Normal file
66
src/Ryujinx.Graphics.Texture/Astc/Bits.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
internal static class Bits
|
||||
{
|
||||
public static readonly ushort[] Replicate8_16Table;
|
||||
public static readonly byte[] Replicate1_7Table;
|
||||
|
||||
static Bits()
|
||||
{
|
||||
Replicate8_16Table = new ushort[0x200];
|
||||
Replicate1_7Table = new byte[0x200];
|
||||
|
||||
for (int i = 0; i < 0x200; i++)
|
||||
{
|
||||
Replicate8_16Table[i] = (ushort)Replicate(i, 8, 16);
|
||||
Replicate1_7Table[i] = (byte)Replicate(i, 1, 7);
|
||||
}
|
||||
}
|
||||
|
||||
public static int Replicate8_16(int value)
|
||||
{
|
||||
return Replicate8_16Table[value];
|
||||
}
|
||||
|
||||
public static int Replicate1_7(int value)
|
||||
{
|
||||
return Replicate1_7Table[value];
|
||||
}
|
||||
|
||||
public static int Replicate(int value, int numberBits, int toBit)
|
||||
{
|
||||
if (numberBits == 0) return 0;
|
||||
if (toBit == 0) return 0;
|
||||
|
||||
int tempValue = value & ((1 << numberBits) - 1);
|
||||
int retValue = tempValue;
|
||||
int resLength = numberBits;
|
||||
|
||||
while (resLength < toBit)
|
||||
{
|
||||
int comp = 0;
|
||||
if (numberBits > toBit - resLength)
|
||||
{
|
||||
int newShift = toBit - resLength;
|
||||
comp = numberBits - newShift;
|
||||
numberBits = newShift;
|
||||
}
|
||||
retValue <<= numberBits;
|
||||
retValue |= tempValue >> comp;
|
||||
resLength += numberBits;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
// Transfers a bit as described in C.2.14
|
||||
public static void BitTransferSigned(ref int a, ref int b)
|
||||
{
|
||||
b >>= 1;
|
||||
b |= a & 0x80;
|
||||
a >>= 1;
|
||||
a &= 0x3F;
|
||||
if ((a & 0x20) != 0) a -= 0x40;
|
||||
}
|
||||
}
|
||||
}
|
23
src/Ryujinx.Graphics.Texture/Astc/EndPointSet.cs
Normal file
23
src/Ryujinx.Graphics.Texture/Astc/EndPointSet.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = AstcPixel.StructSize * 8)]
|
||||
internal struct EndPointSet
|
||||
{
|
||||
private AstcPixel _start;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Span<AstcPixel> Get(int index)
|
||||
{
|
||||
Debug.Assert(index < 4);
|
||||
|
||||
ref AstcPixel start = ref Unsafe.Add(ref _start, index * 2);
|
||||
|
||||
return MemoryMarshal.CreateSpan(ref start, 2);
|
||||
}
|
||||
}
|
||||
}
|
345
src/Ryujinx.Graphics.Texture/Astc/IntegerEncoded.cs
Normal file
345
src/Ryujinx.Graphics.Texture/Astc/IntegerEncoded.cs
Normal file
|
@ -0,0 +1,345 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
internal struct IntegerEncoded
|
||||
{
|
||||
internal const int StructSize = 8;
|
||||
private static readonly IntegerEncoded[] Encodings;
|
||||
|
||||
public enum EIntegerEncoding : byte
|
||||
{
|
||||
JustBits,
|
||||
Quint,
|
||||
Trit
|
||||
}
|
||||
|
||||
EIntegerEncoding _encoding;
|
||||
public byte NumberBits { get; private set; }
|
||||
public byte TritValue { get; private set; }
|
||||
public byte QuintValue { get; private set; }
|
||||
public int BitValue { get; private set; }
|
||||
|
||||
static IntegerEncoded()
|
||||
{
|
||||
Encodings = new IntegerEncoded[0x100];
|
||||
|
||||
for (int i = 0; i < Encodings.Length; i++)
|
||||
{
|
||||
Encodings[i] = CreateEncodingCalc(i);
|
||||
}
|
||||
}
|
||||
|
||||
public IntegerEncoded(EIntegerEncoding encoding, int numBits)
|
||||
{
|
||||
_encoding = encoding;
|
||||
NumberBits = (byte)numBits;
|
||||
BitValue = 0;
|
||||
TritValue = 0;
|
||||
QuintValue = 0;
|
||||
}
|
||||
|
||||
public bool MatchesEncoding(IntegerEncoded other)
|
||||
{
|
||||
return _encoding == other._encoding && NumberBits == other.NumberBits;
|
||||
}
|
||||
|
||||
public EIntegerEncoding GetEncoding()
|
||||
{
|
||||
return _encoding;
|
||||
}
|
||||
|
||||
public int GetBitLength(int numberVals)
|
||||
{
|
||||
int totalBits = NumberBits * numberVals;
|
||||
if (_encoding == EIntegerEncoding.Trit)
|
||||
{
|
||||
totalBits += (numberVals * 8 + 4) / 5;
|
||||
}
|
||||
else if (_encoding == EIntegerEncoding.Quint)
|
||||
{
|
||||
totalBits += (numberVals * 7 + 2) / 3;
|
||||
}
|
||||
return totalBits;
|
||||
}
|
||||
|
||||
public static IntegerEncoded CreateEncoding(int maxVal)
|
||||
{
|
||||
return Encodings[maxVal];
|
||||
}
|
||||
|
||||
private static IntegerEncoded CreateEncodingCalc(int maxVal)
|
||||
{
|
||||
while (maxVal > 0)
|
||||
{
|
||||
int check = maxVal + 1;
|
||||
|
||||
// Is maxVal a power of two?
|
||||
if ((check & (check - 1)) == 0)
|
||||
{
|
||||
return new IntegerEncoded(EIntegerEncoding.JustBits, BitOperations.PopCount((uint)maxVal));
|
||||
}
|
||||
|
||||
// Is maxVal of the type 3*2^n - 1?
|
||||
if ((check % 3 == 0) && ((check / 3) & ((check / 3) - 1)) == 0)
|
||||
{
|
||||
return new IntegerEncoded(EIntegerEncoding.Trit, BitOperations.PopCount((uint)(check / 3 - 1)));
|
||||
}
|
||||
|
||||
// Is maxVal of the type 5*2^n - 1?
|
||||
if ((check % 5 == 0) && ((check / 5) & ((check / 5) - 1)) == 0)
|
||||
{
|
||||
return new IntegerEncoded(EIntegerEncoding.Quint, BitOperations.PopCount((uint)(check / 5 - 1)));
|
||||
}
|
||||
|
||||
// Apparently it can't be represented with a bounded integer sequence...
|
||||
// just iterate.
|
||||
maxVal--;
|
||||
}
|
||||
|
||||
return new IntegerEncoded(EIntegerEncoding.JustBits, 0);
|
||||
}
|
||||
|
||||
public static void DecodeTritBlock(
|
||||
ref BitStream128 bitStream,
|
||||
ref IntegerSequence listIntegerEncoded,
|
||||
int numberBitsPerValue)
|
||||
{
|
||||
// Implement the algorithm in section C.2.12
|
||||
Span<int> m = stackalloc int[5];
|
||||
|
||||
m[0] = bitStream.ReadBits(numberBitsPerValue);
|
||||
int encoded = bitStream.ReadBits(2);
|
||||
m[1] = bitStream.ReadBits(numberBitsPerValue);
|
||||
encoded |= bitStream.ReadBits(2) << 2;
|
||||
m[2] = bitStream.ReadBits(numberBitsPerValue);
|
||||
encoded |= bitStream.ReadBits(1) << 4;
|
||||
m[3] = bitStream.ReadBits(numberBitsPerValue);
|
||||
encoded |= bitStream.ReadBits(2) << 5;
|
||||
m[4] = bitStream.ReadBits(numberBitsPerValue);
|
||||
encoded |= bitStream.ReadBits(1) << 7;
|
||||
|
||||
ReadOnlySpan<byte> encodings = GetTritEncoding(encoded);
|
||||
|
||||
IntegerEncoded intEncoded = new IntegerEncoded(EIntegerEncoding.Trit, numberBitsPerValue);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
intEncoded.BitValue = m[i];
|
||||
intEncoded.TritValue = encodings[i];
|
||||
|
||||
listIntegerEncoded.Add(ref intEncoded);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DecodeQuintBlock(
|
||||
ref BitStream128 bitStream,
|
||||
ref IntegerSequence listIntegerEncoded,
|
||||
int numberBitsPerValue)
|
||||
{
|
||||
ReadOnlySpan<byte> interleavedBits = new byte[] { 3, 2, 2 };
|
||||
|
||||
// Implement the algorithm in section C.2.12
|
||||
Span<int> m = stackalloc int[3];
|
||||
ulong encoded = 0;
|
||||
int encodedBitsRead = 0;
|
||||
|
||||
for (int i = 0; i < m.Length; i++)
|
||||
{
|
||||
m[i] = bitStream.ReadBits(numberBitsPerValue);
|
||||
|
||||
uint encodedBits = (uint)bitStream.ReadBits(interleavedBits[i]);
|
||||
|
||||
encoded |= encodedBits << encodedBitsRead;
|
||||
encodedBitsRead += interleavedBits[i];
|
||||
}
|
||||
|
||||
ReadOnlySpan<byte> encodings = GetQuintEncoding((int)encoded);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
IntegerEncoded intEncoded = new IntegerEncoded(EIntegerEncoding.Quint, numberBitsPerValue)
|
||||
{
|
||||
BitValue = m[i],
|
||||
QuintValue = encodings[i]
|
||||
};
|
||||
|
||||
listIntegerEncoded.Add(ref intEncoded);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DecodeIntegerSequence(
|
||||
ref IntegerSequence decodeIntegerSequence,
|
||||
ref BitStream128 bitStream,
|
||||
int maxRange,
|
||||
int numberValues)
|
||||
{
|
||||
// Determine encoding parameters
|
||||
IntegerEncoded intEncoded = CreateEncoding(maxRange);
|
||||
|
||||
// Start decoding
|
||||
int numberValuesDecoded = 0;
|
||||
while (numberValuesDecoded < numberValues)
|
||||
{
|
||||
switch (intEncoded.GetEncoding())
|
||||
{
|
||||
case EIntegerEncoding.Quint:
|
||||
{
|
||||
DecodeQuintBlock(ref bitStream, ref decodeIntegerSequence, intEncoded.NumberBits);
|
||||
numberValuesDecoded += 3;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EIntegerEncoding.Trit:
|
||||
{
|
||||
DecodeTritBlock(ref bitStream, ref decodeIntegerSequence, intEncoded.NumberBits);
|
||||
numberValuesDecoded += 5;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EIntegerEncoding.JustBits:
|
||||
{
|
||||
intEncoded.BitValue = bitStream.ReadBits(intEncoded.NumberBits);
|
||||
decodeIntegerSequence.Add(ref intEncoded);
|
||||
numberValuesDecoded++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> GetTritEncoding(int index)
|
||||
{
|
||||
return TritEncodings.Slice(index * 5, 5);
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> GetQuintEncoding(int index)
|
||||
{
|
||||
return QuintEncodings.Slice(index * 3, 3);
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<byte> TritEncodings => new byte[]
|
||||
{
|
||||
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0,
|
||||
0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0,
|
||||
2, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 0, 0, 0,
|
||||
1, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 0, 2, 0, 0,
|
||||
0, 2, 2, 0, 0, 1, 2, 2, 0, 0, 2, 2, 2, 0, 0,
|
||||
2, 0, 2, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0,
|
||||
2, 0, 1, 0, 0, 0, 1, 2, 0, 0, 0, 1, 1, 0, 0,
|
||||
1, 1, 1, 0, 0, 2, 1, 1, 0, 0, 1, 1, 2, 0, 0,
|
||||
0, 2, 1, 0, 0, 1, 2, 1, 0, 0, 2, 2, 1, 0, 0,
|
||||
2, 1, 2, 0, 0, 0, 0, 0, 2, 2, 1, 0, 0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||||
}
|
||||
}
|
31
src/Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs
Normal file
31
src/Ryujinx.Graphics.Texture/Astc/IntegerSequence.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture.Astc
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = IntegerEncoded.StructSize * Capacity + sizeof(int))]
|
||||
internal struct IntegerSequence
|
||||
{
|
||||
private const int Capacity = 100;
|
||||
|
||||
private int _length;
|
||||
private IntegerEncoded _start;
|
||||
|
||||
public Span<IntegerEncoded> List => MemoryMarshal.CreateSpan(ref _start, _length);
|
||||
|
||||
public void Reset() => _length = 0;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Add(ref IntegerEncoded item)
|
||||
{
|
||||
Debug.Assert(_length < Capacity);
|
||||
|
||||
int oldLength = _length;
|
||||
_length++;
|
||||
|
||||
List[oldLength] = item;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue