Compare commits

...

3 Commits

Author SHA1 Message Date
TSRBerry
40daca5684 [Ryujinx.Headless.SDL2] Address dotnet-format issues (#5379)
* 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

* Address or silence dotnet format CA1806 and a few CA1854 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

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* 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

* Add trailing commas

* Fix naming and formatting issues
2023-06-28 19:03:27 +02:00
TSRBerry
981e0c082d [Spv.Generator] Address dotnet-format issues (#5394)
* dotnet format style --severity info

Some changes were manually reverted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0052 warnings

* Address or silence dotnet format IDE1006 warnings

* Address or silence dotnet format CA1069 warnings

* Address review comments

* Address most dotnet format whitespace warnings

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Add comments to disabled warnings

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Address IDE0251 warnings

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* Rename Operand.cs to IOperand.cs

* Update src/Spv.Generator/Module.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Remove NotNullWhen attribute and use conditional access to avoid NRE

* Fix duplicated enum values

* Remove unread member

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2023-06-28 18:54:20 +02:00
TSRBerry
cebfa54467 [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>
2023-06-28 18:46:18 +02:00
48 changed files with 1449 additions and 1335 deletions

View File

@@ -94,8 +94,8 @@ namespace Ryujinx.Graphics.Texture.Astc
public int StartBlock { get; set; } public int StartBlock { get; set; }
public int OutputByteOffset { get; set; } public int OutputByteOffset { get; set; }
public int TotalBlockCount => BlockCountX * BlockCountY * ImageSizeZ; public readonly int TotalBlockCount => BlockCountX * BlockCountY * ImageSizeZ;
public int PixelCount => ImageSizeX * ImageSizeY * ImageSizeZ; public readonly int PixelCount => ImageSizeX * ImageSizeY * ImageSizeZ;
} }
public static int QueryDecompressedSize(int sizeX, int sizeY, int sizeZ, int levelCount, int layerCount) public static int QueryDecompressedSize(int sizeX, int sizeY, int sizeZ, int levelCount, int layerCount)
@@ -133,7 +133,7 @@ namespace Ryujinx.Graphics.Texture.Astc
AstcLevel levelInfo = GetLevelInfo(index); AstcLevel levelInfo = GetLevelInfo(index);
WriteDecompressedBlock(decompressedBytes, OutputBuffer.Span.Slice(levelInfo.OutputByteOffset), WriteDecompressedBlock(decompressedBytes, OutputBuffer.Span[levelInfo.OutputByteOffset..],
index - levelInfo.StartBlock, levelInfo); index - levelInfo.StartBlock, levelInfo);
} }
@@ -171,7 +171,7 @@ namespace Ryujinx.Graphics.Texture.Astc
for (int i = 0; i < outputPixelsY; i++) for (int i = 0; i < outputPixelsY; i++)
{ {
ReadOnlySpan<byte> blockRow = block.Slice(inputOffset, outputPixelsX * 4); ReadOnlySpan<byte> blockRow = block.Slice(inputOffset, outputPixelsX * 4);
Span<byte> outputRow = outputBuffer.Slice(outputOffset); Span<byte> outputRow = outputBuffer[outputOffset..];
blockRow.CopyTo(outputRow); blockRow.CopyTo(outputRow);
inputOffset += BlockSizeX * 4; inputOffset += BlockSizeX * 4;
@@ -189,7 +189,7 @@ namespace Ryujinx.Graphics.Texture.Astc
public bool VoidExtentLdr; public bool VoidExtentLdr;
public bool VoidExtentHdr; public bool VoidExtentHdr;
public int GetPackedBitSize() public readonly int GetPackedBitSize()
{ {
// How many indices do we have? // How many indices do we have?
int indices = Height * Width; int indices = Height * Width;
@@ -204,7 +204,7 @@ namespace Ryujinx.Graphics.Texture.Astc
return intEncoded.GetBitLength(indices); return intEncoded.GetBitLength(indices);
} }
public int GetNumWeightValues() public readonly int GetNumWeightValues()
{ {
int ret = Width * Height; int ret = Width * Height;
@@ -230,7 +230,7 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
byte[] output = new byte[QueryDecompressedSize(width, height, depth, levels, layers)]; byte[] output = new byte[QueryDecompressedSize(width, height, depth, levels, layers)];
AstcDecoder decoder = new AstcDecoder(data, output, blockWidth, blockHeight, width, height, depth, levels, layers); AstcDecoder decoder = new(data, output, blockWidth, blockHeight, width, height, depth, levels, layers);
for (int i = 0; i < decoder.TotalBlockCount; i++) for (int i = 0; i < decoder.TotalBlockCount; i++)
{ {
@@ -253,7 +253,7 @@ namespace Ryujinx.Graphics.Texture.Astc
int levels, int levels,
int layers) int layers)
{ {
AstcDecoder decoder = new AstcDecoder(data, outputBuffer, blockWidth, blockHeight, width, height, depth, levels, layers); AstcDecoder decoder = new(data, outputBuffer, blockWidth, blockHeight, width, height, depth, levels, layers);
for (int i = 0; i < decoder.TotalBlockCount; i++) for (int i = 0; i < decoder.TotalBlockCount; i++)
{ {
@@ -274,7 +274,7 @@ namespace Ryujinx.Graphics.Texture.Astc
int levels, int levels,
int layers) int layers)
{ {
AstcDecoder decoder = new AstcDecoder(data, outputBuffer, blockWidth, blockHeight, width, height, depth, levels, layers); AstcDecoder decoder = new(data, outputBuffer, blockWidth, blockHeight, width, height, depth, levels, layers);
// Lazy parallelism // Lazy parallelism
Enumerable.Range(0, decoder.TotalBlockCount).AsParallel().ForAll(x => decoder.ProcessBlock(x)); Enumerable.Range(0, decoder.TotalBlockCount).AsParallel().ForAll(x => decoder.ProcessBlock(x));
@@ -295,7 +295,7 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
byte[] output = new byte[QueryDecompressedSize(width, height, depth, levels, layers)]; byte[] output = new byte[QueryDecompressedSize(width, height, depth, levels, layers)];
AstcDecoder decoder = new AstcDecoder(data, output, blockWidth, blockHeight, width, height, depth, levels, layers); AstcDecoder decoder = new(data, output, blockWidth, blockHeight, width, height, depth, levels, layers);
Enumerable.Range(0, decoder.TotalBlockCount).AsParallel().ForAll(x => decoder.ProcessBlock(x)); Enumerable.Range(0, decoder.TotalBlockCount).AsParallel().ForAll(x => decoder.ProcessBlock(x));
@@ -310,7 +310,7 @@ namespace Ryujinx.Graphics.Texture.Astc
int blockWidth, int blockWidth,
int blockHeight) int blockHeight)
{ {
BitStream128 bitStream = new BitStream128(inputBlock); BitStream128 bitStream = new(inputBlock);
DecodeBlockInfo(ref bitStream, out TexelWeightParams texelParams); DecodeBlockInfo(ref bitStream, out TexelWeightParams texelParams);
@@ -359,7 +359,7 @@ namespace Ryujinx.Graphics.Texture.Astc
Span<uint> colorEndpointMode = stackalloc uint[4]; Span<uint> colorEndpointMode = stackalloc uint[4];
BitStream128 colorEndpointStream = new BitStream128(); BitStream128 colorEndpointStream = new();
// Read extra config data... // Read extra config data...
uint baseColorEndpointMode = 0; uint baseColorEndpointMode = 0;
@@ -388,10 +388,18 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
switch (numberPartitions) switch (numberPartitions)
{ {
case 2: extraColorEndpointModeBits += 2; break; case 2:
case 3: extraColorEndpointModeBits += 5; break; extraColorEndpointModeBits += 2;
case 4: extraColorEndpointModeBits += 8; break; break;
default: Debug.Assert(false); break; case 3:
extraColorEndpointModeBits += 5;
break;
case 4:
extraColorEndpointModeBits += 8;
break;
default:
Debug.Assert(false);
break;
} }
} }
@@ -448,7 +456,12 @@ namespace Ryujinx.Graphics.Texture.Astc
for (int i = 0; i < numberPartitions; i++) for (int i = 0; i < numberPartitions; i++)
{ {
colorEndpointMode[i] = baseMode; colorEndpointMode[i] = baseMode;
if (!(c[i])) colorEndpointMode[i] -= 1;
if (!(c[i]))
{
colorEndpointMode[i] -= 1;
}
colorEndpointMode[i] <<= 2; colorEndpointMode[i] <<= 2;
colorEndpointMode[i] |= m[i]; colorEndpointMode[i] |= m[i];
} }
@@ -475,7 +488,12 @@ namespace Ryujinx.Graphics.Texture.Astc
DecodeColorValues(colorValues, ref colorEndpointStream, colorEndpointMode, numberPartitions, colorDataBits); DecodeColorValues(colorValues, ref colorEndpointStream, colorEndpointMode, numberPartitions, colorDataBits);
EndPointSet endPoints; EndPointSet endPoints;
unsafe { _ = &endPoints; } // Skip struct initialization
unsafe
{
// Skip struct initialization
_ = &endPoints;
}
int colorValuesPosition = 0; int colorValuesPosition = 0;
@@ -502,19 +520,33 @@ namespace Ryujinx.Graphics.Texture.Astc
texelWeightData[clearByteStart - 1] &= (byte)((1 << (texelParams.GetPackedBitSize() % 8)) - 1); texelWeightData[clearByteStart - 1] &= (byte)((1 << (texelParams.GetPackedBitSize() % 8)) - 1);
int cLen = 16 - clearByteStart; int cLen = 16 - clearByteStart;
for (int i = clearByteStart; i < clearByteStart + cLen; i++) texelWeightData[i] = 0; for (int i = clearByteStart; i < clearByteStart + cLen; i++)
{
texelWeightData[i] = 0;
}
IntegerSequence texelWeightValues; IntegerSequence texelWeightValues;
unsafe { _ = &texelWeightValues; } // Skip struct initialization
unsafe
{
// Skip struct initialization
_ = &texelWeightValues;
}
texelWeightValues.Reset(); texelWeightValues.Reset();
BitStream128 weightBitStream = new BitStream128(texelWeightData); BitStream128 weightBitStream = new(texelWeightData);
IntegerEncoded.DecodeIntegerSequence(ref texelWeightValues, ref weightBitStream, texelParams.MaxWeight, texelParams.GetNumWeightValues()); IntegerEncoded.DecodeIntegerSequence(ref texelWeightValues, ref weightBitStream, texelParams.MaxWeight, texelParams.GetNumWeightValues());
// Blocks can be at most 12x12, so we can have as many as 144 weights // Blocks can be at most 12x12, so we can have as many as 144 weights
Weights weights; Weights weights;
unsafe { _ = &weights; } // Skip struct initialization
unsafe
{
// Skip struct initialization
_ = &weights;
}
UnquantizeTexelWeights(ref weights, ref texelWeightValues, ref texelParams, blockWidth, blockHeight); UnquantizeTexelWeights(ref weights, ref texelWeightValues, ref texelParams, blockWidth, blockHeight);
@@ -529,7 +561,7 @@ namespace Ryujinx.Graphics.Texture.Astc
int partition = Select2dPartition(partitionIndex, i, j, numberPartitions, ((blockHeight * blockWidth) < 32)); int partition = Select2dPartition(partitionIndex, i, j, numberPartitions, ((blockHeight * blockWidth) < 32));
Debug.Assert(partition < numberPartitions); Debug.Assert(partition < numberPartitions);
AstcPixel pixel = new AstcPixel(); AstcPixel pixel = new();
for (int component = 0; component < 4; component++) for (int component = 0; component < 4; component++)
{ {
int component0 = endPoints.Get(partition)[0].GetComponent(component); int component0 = endPoints.Get(partition)[0].GetComponent(component);
@@ -579,7 +611,7 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
if ((uint)index >= Count) if ((uint)index >= Count)
{ {
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException(nameof(index), index, null);
} }
ref int start = ref Unsafe.Add(ref _start, index * 144); ref int start = ref Unsafe.Add(ref _start, index * 144);
@@ -632,12 +664,18 @@ namespace Ryujinx.Graphics.Texture.Astc
byte seed11 = (byte)((rightNum >> 26) & 0xF); byte seed11 = (byte)((rightNum >> 26) & 0xF);
byte seed12 = (byte)(((rightNum >> 30) | (rightNum << 2)) & 0xF); byte seed12 = (byte)(((rightNum >> 30) | (rightNum << 2)) & 0xF);
seed01 *= seed01; seed02 *= seed02; seed01 *= seed01;
seed03 *= seed03; seed04 *= seed04; seed02 *= seed02;
seed05 *= seed05; seed06 *= seed06; seed03 *= seed03;
seed07 *= seed07; seed08 *= seed08; seed04 *= seed04;
seed09 *= seed09; seed10 *= seed10; seed05 *= seed05;
seed11 *= seed11; seed12 *= seed12; seed06 *= seed06;
seed07 *= seed07;
seed08 *= seed08;
seed09 *= seed09;
seed10 *= seed10;
seed11 *= seed11;
seed12 *= seed12;
int seedHash1, seedHash2, seedHash3; int seedHash1, seedHash2, seedHash3;
@@ -654,31 +692,67 @@ namespace Ryujinx.Graphics.Texture.Astc
seedHash3 = (seed & 0x10) != 0 ? seedHash1 : seedHash2; seedHash3 = (seed & 0x10) != 0 ? seedHash1 : seedHash2;
seed01 >>= seedHash1; seed02 >>= seedHash2; seed03 >>= seedHash1; seed04 >>= seedHash2; seed01 >>= seedHash1;
seed05 >>= seedHash1; seed06 >>= seedHash2; seed07 >>= seedHash1; seed08 >>= seedHash2; seed02 >>= seedHash2;
seed09 >>= seedHash3; seed10 >>= seedHash3; seed11 >>= seedHash3; seed12 >>= seedHash3; seed03 >>= seedHash1;
seed04 >>= seedHash2;
seed05 >>= seedHash1;
seed06 >>= seedHash2;
seed07 >>= seedHash1;
seed08 >>= seedHash2;
seed09 >>= seedHash3;
seed10 >>= seedHash3;
seed11 >>= seedHash3;
seed12 >>= seedHash3;
int a = seed01 * x + seed02 * y + seed11 * z + (rightNum >> 14); int a = seed01 * x + seed02 * y + seed11 * z + (rightNum >> 14);
int b = seed03 * x + seed04 * y + seed12 * z + (rightNum >> 10); int b = seed03 * x + seed04 * y + seed12 * z + (rightNum >> 10);
int c = seed05 * x + seed06 * y + seed09 * z + (rightNum >> 6); int c = seed05 * x + seed06 * y + seed09 * z + (rightNum >> 6);
int d = seed07 * x + seed08 * y + seed10 * z + (rightNum >> 2); int d = seed07 * x + seed08 * y + seed10 * z + (rightNum >> 2);
a &= 0x3F; b &= 0x3F; c &= 0x3F; d &= 0x3F; a &= 0x3F;
b &= 0x3F;
c &= 0x3F;
d &= 0x3F;
if (partitionCount < 4) d = 0; if (partitionCount < 4)
if (partitionCount < 3) c = 0; {
d = 0;
}
if (partitionCount < 3)
{
c = 0;
}
if (a >= b && a >= c && a >= d)
{
return 0;
}
else if (b >= c && b >= d)
{
return 1;
}
else if (c >= d)
{
return 2;
}
if (a >= b && a >= c && a >= d) return 0;
else if (b >= c && b >= d) return 1;
else if (c >= d) return 2;
return 3; return 3;
} }
static int Hash52(uint val) static int Hash52(uint val)
{ {
val ^= val >> 15; val -= val << 17; val += val << 7; val += val << 4; val ^= val >> 15;
val ^= val >> 5; val += val << 16; val ^= val >> 7; val ^= val >> 3; val -= val << 17;
val ^= val << 6; val ^= val >> 17; val += val << 7;
val += val << 4;
val ^= val >> 5;
val += val << 16;
val ^= val >> 7;
val ^= val >> 3;
val ^= val << 6;
val ^= val >> 17;
return (int)val; return (int)val;
} }
@@ -692,7 +766,12 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
int weightIndices = 0; int weightIndices = 0;
Weights unquantized; Weights unquantized;
unsafe { _ = &unquantized; } // Skip struct initialization
unsafe
{
// Skip struct initialization
_ = &unquantized;
}
Span<IntegerEncoded> weightsList = weights.List; Span<IntegerEncoded> weightsList = weights.List;
Span<int> unquantized0 = unquantized[0]; Span<int> unquantized0 = unquantized[0];
@@ -713,7 +792,10 @@ namespace Ryujinx.Graphics.Texture.Astc
} }
} }
if (++weightIndices >= texelParams.Width * texelParams.Height) break; if (++weightIndices >= texelParams.Width * texelParams.Height)
{
break;
}
} }
// Do infill if necessary (Section C.2.18) ... // Do infill if necessary (Section C.2.18) ...
@@ -1146,7 +1228,13 @@ namespace Ryujinx.Graphics.Texture.Astc
// We now have enough to decode our integer sequence. // We now have enough to decode our integer sequence.
IntegerSequence integerEncodedSequence; IntegerSequence integerEncodedSequence;
unsafe { _ = &integerEncodedSequence; } // Skip struct initialization
unsafe
{
// Skip struct initialization
_ = &integerEncodedSequence;
}
integerEncodedSequence.Reset(); integerEncodedSequence.Reset();
IntegerEncoded.DecodeIntegerSequence(ref integerEncodedSequence, ref colorBitStream, range, numberValues); IntegerEncoded.DecodeIntegerSequence(ref integerEncodedSequence, ref colorBitStream, range, numberValues);
@@ -1162,9 +1250,9 @@ namespace Ryujinx.Graphics.Texture.Astc
Debug.Assert(bitLength >= 1); Debug.Assert(bitLength >= 1);
int a = 0, b = 0, c = 0, d = 0; int b = 0, c = 0, d = 0;
// A is just the lsb replicated 9 times. // A is just the lsb replicated 9 times.
a = Bits.Replicate(bitValue & 1, 1, 9); int a = Bits.Replicate(bitValue & 1, 1, 9);
switch (intEncoded.GetEncoding()) switch (intEncoded.GetEncoding())
{ {

View File

@@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Texture.Astc
Components[index] = (short)value; Components[index] = (short)value;
} }
public int Pack() public readonly int Pack()
{ {
return A << 24 | return A << 24 |
B << 16 | B << 16 |

View File

@@ -6,7 +6,9 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
public struct BitStream128 public struct BitStream128
{ {
#pragma warning disable IDE0044 // Make field readonly
private Buffer16 _data; private Buffer16 _data;
#pragma warning restore IDE0044
public int BitsLeft { get; set; } public int BitsLeft { get; set; }
public BitStream128(Buffer16 data) public BitStream128(Buffer16 data)
@@ -42,7 +44,10 @@ namespace Ryujinx.Graphics.Texture.Astc
{ {
Debug.Assert(bitCount < 32); Debug.Assert(bitCount < 32);
if (bitCount == 0) return; if (bitCount == 0)
{
return;
}
ulong maskedValue = (uint)(value & ((1 << bitCount) - 1)); ulong maskedValue = (uint)(value & ((1 << bitCount) - 1));

View File

@@ -29,8 +29,15 @@
public static int Replicate(int value, int numberBits, int toBit) public static int Replicate(int value, int numberBits, int toBit)
{ {
if (numberBits == 0) return 0; if (numberBits == 0)
if (toBit == 0) return 0; {
return 0;
}
if (toBit == 0)
{
return 0;
}
int tempValue = value & ((1 << numberBits) - 1); int tempValue = value & ((1 << numberBits) - 1);
int retValue = tempValue; int retValue = tempValue;
@@ -60,7 +67,10 @@
b |= a & 0x80; b |= a & 0x80;
a >>= 1; a >>= 1;
a &= 0x3F; a &= 0x3F;
if ((a & 0x20) != 0) a -= 0x40; if ((a & 0x20) != 0)
{
a -= 0x40;
}
} }
} }
} }

View File

@@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Texture.Astc
internal struct IntegerEncoded internal struct IntegerEncoded
{ {
internal const int StructSize = 8; internal const int StructSize = 8;
private static readonly IntegerEncoded[] Encodings; private static readonly IntegerEncoded[] _encodings;
public enum EIntegerEncoding : byte public enum EIntegerEncoding : byte
{ {
@@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Texture.Astc
Trit Trit
} }
EIntegerEncoding _encoding; readonly EIntegerEncoding _encoding;
public byte NumberBits { get; private set; } public byte NumberBits { get; private set; }
public byte TritValue { get; private set; } public byte TritValue { get; private set; }
public byte QuintValue { get; private set; } public byte QuintValue { get; private set; }
@@ -23,11 +23,11 @@ namespace Ryujinx.Graphics.Texture.Astc
static IntegerEncoded() 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; QuintValue = 0;
} }
public bool MatchesEncoding(IntegerEncoded other) public readonly bool MatchesEncoding(IntegerEncoded other)
{ {
return _encoding == other._encoding && NumberBits == other.NumberBits; return _encoding == other._encoding && NumberBits == other.NumberBits;
} }
public EIntegerEncoding GetEncoding() public readonly EIntegerEncoding GetEncoding()
{ {
return _encoding; return _encoding;
} }
public int GetBitLength(int numberVals) public readonly int GetBitLength(int numberVals)
{ {
int totalBits = NumberBits * numberVals; int totalBits = NumberBits * numberVals;
if (_encoding == EIntegerEncoding.Trit) if (_encoding == EIntegerEncoding.Trit)
@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Texture.Astc
public static IntegerEncoded CreateEncoding(int maxVal) public static IntegerEncoded CreateEncoding(int maxVal)
{ {
return Encodings[maxVal]; return _encodings[maxVal];
} }
private static IntegerEncoded CreateEncodingCalc(int maxVal) private static IntegerEncoded CreateEncodingCalc(int maxVal)
@@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Texture.Astc
ReadOnlySpan<byte> encodings = GetTritEncoding(encoded); 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++) for (int i = 0; i < 5; i++)
{ {
@@ -159,7 +159,7 @@ namespace Ryujinx.Graphics.Texture.Astc
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
IntegerEncoded intEncoded = new IntegerEncoded(EIntegerEncoding.Quint, numberBitsPerValue) IntegerEncoded intEncoded = new(EIntegerEncoding.Quint, numberBitsPerValue)
{ {
BitValue = m[i], BitValue = m[i],
QuintValue = encodings[i] QuintValue = encodings[i]

View File

@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Texture
int x2 = x * 4; int x2 = x * 4;
int bw = Math.Min(4, width - x2); int bw = Math.Min(4, width - x2);
DecodeBlock(blocks[y * wInBlocks + x], output64.Slice(y2 * width + x2), bw, bh, width, signed); DecodeBlock(blocks[y * wInBlocks + x], output64[(y2 * width + x2)..], bw, bh, width, signed);
} }
} }
} }

View File

@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Texture
int x2 = x * 4; int x2 = x * 4;
int bw = Math.Min(4, width - x2); int bw = Math.Min(4, width - x2);
DecodeBlock(blocks[y * wInBlocks + x], output32.Slice(y2 * width + x2), bw, bh, width); DecodeBlock(blocks[y * wInBlocks + x], output32[(y2 * width + x2)..], bw, bh, width);
} }
} }
} }
@@ -177,9 +177,18 @@ namespace Ryujinx.Graphics.Texture
switch (rotation) switch (rotation)
{ {
case 1: color.A = color.R; color.R = a; break; case 1:
case 2: color.A = color.G; color.G = a; break; color.A = color.R;
case 3: color.A = color.B; color.B = a; break; color.R = a;
break;
case 2:
color.A = color.G;
color.G = a;
break;
case 3:
color.A = color.B;
color.B = a;
break;
} }
} }

View File

@@ -54,10 +54,10 @@ namespace Ryujinx.Graphics.Texture
if (copyHeight == 4) if (copyHeight == 4)
{ {
outputLine0 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs)); outputLine0 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[lineBaseOOffs..]);
outputLine1 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width)); outputLine1 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width)..]);
outputLine2 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width * 2)); outputLine2 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width * 2)..]);
outputLine3 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width * 3)); outputLine3 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width * 3)..]);
} }
for (int x = 0; x < w; x++) 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) if (copyHeight == 4)
{ {
outputLine0 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs)); outputLine0 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[lineBaseOOffs..]);
outputLine1 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width)); outputLine1 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width)..]);
outputLine2 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width * 2)); outputLine2 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width * 2)..]);
outputLine3 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width * 3)); outputLine3 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width * 3)..]);
} }
for (int x = 0; x < w; x++) for (int x = 0; x < w; x++)
@@ -153,7 +153,7 @@ namespace Ryujinx.Graphics.Texture
int baseX = x * BlockWidth; int baseX = x * BlockWidth;
int copyWidth = Math.Min(BlockWidth, width - baseX); int copyWidth = Math.Min(BlockWidth, width - baseX);
BC23DecodeTileRgb(tile, data.Slice(8)); BC23DecodeTileRgb(tile, data[8..]);
ulong block = BinaryPrimitives.ReadUInt64LittleEndian(data); 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) if (copyHeight == 4)
{ {
outputLine0 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs)); outputLine0 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[lineBaseOOffs..]);
outputLine1 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width)); outputLine1 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width)..]);
outputLine2 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width * 2)); outputLine2 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width * 2)..]);
outputLine3 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint.Slice(lineBaseOOffs + width * 3)); outputLine3 = MemoryMarshal.Cast<uint, Vector128<byte>>(outputAsUint[(lineBaseOOffs + width * 3)..]);
} }
for (int x = 0; x < w; x++) for (int x = 0; x < w; x++)
@@ -249,7 +249,7 @@ namespace Ryujinx.Graphics.Texture
int baseX = x * BlockWidth; int baseX = x * BlockWidth;
int copyWidth = Math.Min(BlockWidth, width - baseX); int copyWidth = Math.Min(BlockWidth, width - baseX);
BC23DecodeTileRgb(tile, data.Slice(8)); BC23DecodeTileRgb(tile, data[8..]);
ulong block = BinaryPrimitives.ReadUInt64LittleEndian(data); 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); int alignedWidth = BitUtils.AlignUp(width, 4);
byte[] output = new byte[size]; byte[] output = new byte[size];
Span<byte> outputSpan = new Span<byte>(output); Span<byte> outputSpan = new(output);
ReadOnlySpan<ulong> data64 = MemoryMarshal.Cast<byte, ulong>(data); ReadOnlySpan<ulong> data64 = MemoryMarshal.Cast<byte, ulong>(data);
@@ -338,10 +338,10 @@ namespace Ryujinx.Graphics.Texture
if (copyHeight == 4) if (copyHeight == 4)
{ {
outputLine0 = MemoryMarshal.Cast<byte, uint>(outputSpan.Slice(lineBaseOOffs)); outputLine0 = MemoryMarshal.Cast<byte, uint>(outputSpan[lineBaseOOffs..]);
outputLine1 = MemoryMarshal.Cast<byte, uint>(outputSpan.Slice(lineBaseOOffs + alignedWidth)); outputLine1 = MemoryMarshal.Cast<byte, uint>(outputSpan[(lineBaseOOffs + alignedWidth)..]);
outputLine2 = MemoryMarshal.Cast<byte, uint>(outputSpan.Slice(lineBaseOOffs + alignedWidth * 2)); outputLine2 = MemoryMarshal.Cast<byte, uint>(outputSpan[(lineBaseOOffs + alignedWidth * 2)..]);
outputLine3 = MemoryMarshal.Cast<byte, uint>(outputSpan.Slice(lineBaseOOffs + alignedWidth * 3)); outputLine3 = MemoryMarshal.Cast<byte, uint>(outputSpan[(lineBaseOOffs + alignedWidth * 3)..]);
} }
for (int x = 0; x < w; x++) 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) if (copyHeight == 4)
{ {
outputLine0 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort.Slice(lineBaseOOffs)); outputLine0 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort[lineBaseOOffs..]);
outputLine1 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort.Slice(lineBaseOOffs + alignedWidth)); outputLine1 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort[(lineBaseOOffs + alignedWidth)..]);
outputLine2 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort.Slice(lineBaseOOffs + alignedWidth * 2)); outputLine2 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort[(lineBaseOOffs + alignedWidth * 2)..]);
outputLine3 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort.Slice(lineBaseOOffs + alignedWidth * 3)); outputLine3 = MemoryMarshal.Cast<ushort, ulong>(outputAsUshort[(lineBaseOOffs + alignedWidth * 3)..]);
} }
for (int x = 0; x < w; x++) 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++) 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; inputOffset += w * h * 16;
outputOffset += width * height * 8; outputOffset += width * height * 8;
@@ -586,7 +586,7 @@ namespace Ryujinx.Graphics.Texture
{ {
for (int z = 0; z < depth; z++) 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; inputOffset += w * h * 16;
outputOffset += width * height * 4; outputOffset += width * height * 4;
@@ -813,7 +813,7 @@ namespace Ryujinx.Graphics.Texture
{ {
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output); Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output);
uint indices = BinaryPrimitives.ReadUInt32LittleEndian(input.Slice(4)); uint indices = BinaryPrimitives.ReadUInt32LittleEndian(input[4..]);
for (int i = 0; i < BlockWidth * BlockHeight; i++, indices >>= 2) for (int i = 0; i < BlockWidth * BlockHeight; i++, indices >>= 2)
{ {

View File

@@ -28,8 +28,6 @@ namespace Ryujinx.Graphics.Texture
for (int l = 0; l < levels; l++) for (int l = 0; l < levels; l++)
{ {
int rgba8Size = width * height * depth * layers * 4;
int w = BitUtils.DivRoundUp(width, BlockWidth); int w = BitUtils.DivRoundUp(width, BlockWidth);
int h = BitUtils.DivRoundUp(height, BlockHeight); int h = BitUtils.DivRoundUp(height, BlockHeight);
@@ -38,8 +36,8 @@ namespace Ryujinx.Graphics.Texture
for (int z = 0; z < depth; z++) for (int z = 0; z < depth; z++)
{ {
BC7Encoder.Encode( BC7Encoder.Encode(
output.AsMemory().Slice(imageBaseOOffs), output.AsMemory()[imageBaseOOffs..],
data.AsMemory().Slice(imageBaseIOffs), data.AsMemory()[imageBaseIOffs..],
width, width,
height, height,
EncodeMode.Fast | EncodeMode.Multithreaded); EncodeMode.Fast | EncodeMode.Multithreaded);

View File

@@ -20,19 +20,19 @@ namespace Ryujinx.Graphics.Texture
} }
} }
private int _texBpp; private readonly int _texBpp;
private int _bhMask; private readonly int _bhMask;
private int _bdMask; private readonly int _bdMask;
private int _bhShift; private readonly int _bhShift;
private int _bdShift; private readonly int _bdShift;
private int _bppShift; private readonly int _bppShift;
private int _xShift; private readonly int _xShift;
private int _robSize; private readonly int _robSize;
private int _sliceSize; private readonly int _sliceSize;
// Variables for built in iteration. // Variables for built in iteration.
private int _yPart; private int _yPart;

View File

@@ -3,9 +3,9 @@
namespace Ryujinx.Graphics.Texture namespace Ryujinx.Graphics.Texture
{ {
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 12)] [StructLayout(LayoutKind.Sequential, Pack = 1, Size = 12)]
public struct Bpp12Pixel public readonly struct Bpp12Pixel
{ {
private ulong _elem1; private readonly ulong _elem1;
private uint _elem2; private readonly uint _elem2;
} }
} }

View File

@@ -119,12 +119,12 @@ namespace Ryujinx.Graphics.Texture.Encoders
{ {
uint c = tile[i]; uint c = tile[i];
if (!uniqueRGB.Slice(0, uniqueRGBCount).Contains(c & rgbMask)) if (!uniqueRGB[..uniqueRGBCount].Contains(c & rgbMask))
{ {
uniqueRGB[uniqueRGBCount++] = c & rgbMask; uniqueRGB[uniqueRGBCount++] = c & rgbMask;
} }
if (!uniqueAlpha.Slice(0, uniqueAlphaCount).Contains(c & alphaMask)) if (!uniqueAlpha[..uniqueAlphaCount].Contains(c & alphaMask))
{ {
uniqueAlpha[uniqueAlphaCount++] = c & alphaMask; uniqueAlpha[uniqueAlphaCount++] = c & alphaMask;
} }
@@ -356,7 +356,7 @@ namespace Ryujinx.Graphics.Texture.Encoders
bool alphaSwapSubset = alphaIndices[0] >= (alphaIndexCount >> 1); bool alphaSwapSubset = alphaIndices[0] >= (alphaIndexCount >> 1);
Block block = new Block(); Block block = new();
int offset = 0; int offset = 0;
@@ -591,7 +591,7 @@ namespace Ryujinx.Graphics.Texture.Encoders
RgbaColor32 e132 = RgbaColor8.FromUInt32(c1).GetColor32(); RgbaColor32 e132 = RgbaColor8.FromUInt32(c1).GetColor32();
palette[0] = e032; palette[0] = e032;
palette[palette.Length - 1] = e132; palette[^1] = e132;
for (int i = 1; i < palette.Length - 1; i++) for (int i = 1; i < palette.Length - 1; i++)
{ {
@@ -888,7 +888,7 @@ namespace Ryujinx.Graphics.Texture.Encoders
int distRange = Math.Max(1, maxDist - minDist); int distRange = Math.Max(1, maxDist - minDist);
RgbaColor32 nV = new RgbaColor32(n); RgbaColor32 nV = new(n);
int bestErrorSum = int.MaxValue; int bestErrorSum = int.MaxValue;
RgbaColor8 bestE0 = default; RgbaColor8 bestE0 = default;
@@ -922,8 +922,8 @@ namespace Ryujinx.Graphics.Texture.Encoders
for (int start = 0; start < numInterpolatedColors - maxIndex; start++) for (int start = 0; start < numInterpolatedColors - maxIndex; start++)
{ {
RgbaColor32 sumY = new RgbaColor32(0); RgbaColor32 sumY = new(0);
RgbaColor32 sumXY = new RgbaColor32(0); RgbaColor32 sumXY = new(0);
for (int i = 0; i < indices.Length; i++) for (int i = 0; i < indices.Length; i++)
{ {
@@ -933,8 +933,8 @@ namespace Ryujinx.Graphics.Texture.Encoders
sumXY += new RgbaColor32(start + indices[i]) * y; sumXY += new RgbaColor32(start + indices[i]) * y;
} }
RgbaColor32 sumXV = new RgbaColor32(sumX); RgbaColor32 sumXV = new(sumX);
RgbaColor32 sumXXV = new RgbaColor32(sumXX); RgbaColor32 sumXXV = new(sumXX);
RgbaColor32 m = RgbaColor32.DivideGuarded((nV * sumXY - sumXV * sumY) << 6, nV * sumXXV - sumXV * sumXV, 0); RgbaColor32 m = RgbaColor32.DivideGuarded((nV * sumXY - sumXV * sumY) << 6, nV * sumXXV - sumXV * sumXV, 0);
RgbaColor32 b = ((sumY << 6) - m * sumXV) / nV; RgbaColor32 b = ((sumY << 6) - m * sumXV) / nV;

View File

@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Texture
int wAligned = BitUtils.AlignUp(width, alignment); int wAligned = BitUtils.AlignUp(width, alignment);
BlockLinearLayout layoutConverter = new BlockLinearLayout(wAligned, height, gobBlocksInY, 1, bytesPerPixel); BlockLinearLayout layoutConverter = new(wAligned, height, gobBlocksInY, 1, bytesPerPixel);
unsafe bool Convert<T>(Span<byte> output, ReadOnlySpan<byte> data) where T : unmanaged unsafe bool Convert<T>(Span<byte> output, ReadOnlySpan<byte> data) where T : unmanaged
{ {
@@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Texture
int wAligned = BitUtils.AlignUp(w, alignment); int wAligned = BitUtils.AlignUp(w, alignment);
BlockLinearLayout layoutConverter = new BlockLinearLayout( BlockLinearLayout layoutConverter = new(
wAligned, wAligned,
h, h,
mipGobBlocksInY, mipGobBlocksInY,
@@ -301,7 +301,7 @@ namespace Ryujinx.Graphics.Texture
int wAligned = BitUtils.AlignUp(width, alignment); int wAligned = BitUtils.AlignUp(width, alignment);
BlockLinearLayout layoutConverter = new BlockLinearLayout(wAligned, height, gobBlocksInY, 1, bytesPerPixel); BlockLinearLayout layoutConverter = new(wAligned, height, gobBlocksInY, 1, bytesPerPixel);
unsafe bool Convert<T>(Span<byte> output, ReadOnlySpan<byte> data) where T : unmanaged unsafe bool Convert<T>(Span<byte> output, ReadOnlySpan<byte> data) where T : unmanaged
{ {
@@ -430,7 +430,7 @@ namespace Ryujinx.Graphics.Texture
int wAligned = BitUtils.AlignUp(w, alignment); int wAligned = BitUtils.AlignUp(w, alignment);
BlockLinearLayout layoutConverter = new BlockLinearLayout( BlockLinearLayout layoutConverter = new(
wAligned, wAligned,
h, h,
mipGobBlocksInY, mipGobBlocksInY,

View File

@@ -7,13 +7,13 @@ namespace Ryujinx.Graphics.Texture
{ {
public class OffsetCalculator public class OffsetCalculator
{ {
private int _width; private readonly int _width;
private int _height; private readonly int _height;
private int _stride; private readonly int _stride;
private bool _isLinear; private readonly bool _isLinear;
private int _bytesPerPixel; private readonly int _bytesPerPixel;
private BlockLinearLayout _layoutConverter; private readonly BlockLinearLayout _layoutConverter;
// Variables for built in iteration. // Variables for built in iteration.
private int _yPart; private int _yPart;

View File

@@ -1,6 +1,5 @@
using Ryujinx.Common; using Ryujinx.Common;
using System; using System;
using static Ryujinx.Graphics.Texture.BlockLinearConstants; using static Ryujinx.Graphics.Texture.BlockLinearConstants;
namespace Ryujinx.Graphics.Texture namespace Ryujinx.Graphics.Texture

View File

@@ -8,8 +8,8 @@ namespace Ryujinx.Graphics.Texture.Utils
{ {
static class BC67Utils static class BC67Utils
{ {
private static byte[][] _quantizationLut; private static readonly byte[][] _quantizationLut;
private static byte[][] _quantizationLutNoPBit; private static readonly byte[][] _quantizationLutNoPBit;
static BC67Utils() static BC67Utils()
{ {
@@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Texture.Utils
} }
else else
{ {
RgbaColor8 minColor = new RgbaColor8(255, 255, 255, 255); RgbaColor8 minColor = new(255, 255, 255, 255);
RgbaColor8 maxColor = default; RgbaColor8 maxColor = default;
for (int i = 0; i < tile.Length; i++) for (int i = 0; i < tile.Length; i++)
@@ -1176,8 +1176,8 @@ namespace Ryujinx.Graphics.Texture.Utils
int weight = (((weightIndex << 7) / ((1 << indexBitCount) - 1)) + 1) >> 1; int weight = (((weightIndex << 7) / ((1 << indexBitCount) - 1)) + 1) >> 1;
RgbaColor32 weightV = new RgbaColor32(weight); RgbaColor32 weightV = new(weight);
RgbaColor32 invWeightV = new RgbaColor32(64 - weight); RgbaColor32 invWeightV = new(64 - weight);
return (color1 * invWeightV + color2 * weightV + new RgbaColor32(32)) >> 6; return (color1 * invWeightV + color2 * weightV + new RgbaColor32(32)) >> 6;
} }
@@ -1197,8 +1197,10 @@ namespace Ryujinx.Graphics.Texture.Utils
int colorWeight = BC67Tables.Weights[colorIndexBitCount - 2][colorWeightIndex]; int colorWeight = BC67Tables.Weights[colorIndexBitCount - 2][colorWeightIndex];
int alphaWeight = BC67Tables.Weights[alphaIndexBitCount - 2][alphaWeightIndex]; int alphaWeight = BC67Tables.Weights[alphaIndexBitCount - 2][alphaWeightIndex];
RgbaColor32 weightV = new RgbaColor32(colorWeight); RgbaColor32 weightV = new(colorWeight)
weightV.A = alphaWeight; {
A = alphaWeight
};
RgbaColor32 invWeightV = new RgbaColor32(64) - weightV; RgbaColor32 invWeightV = new RgbaColor32(64) - weightV;
return (color1 * invWeightV + color2 * weightV + new RgbaColor32(32)) >> 6; return (color1 * invWeightV + color2 * weightV + new RgbaColor32(32)) >> 6;

View File

@@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Texture.Utils
offset += bits; offset += bits;
} }
public ulong Decode(ref int offset, int bits) public readonly ulong Decode(ref int offset, int bits)
{ {
ulong value; ulong value;
ulong mask = bits == 64 ? ulong.MaxValue : (1UL << bits) - 1; ulong mask = bits == 64 ? ulong.MaxValue : (1UL << bits) - 1;

View File

@@ -11,25 +11,25 @@ namespace Ryujinx.Graphics.Texture.Utils
public int R public int R
{ {
get => _color.GetElement(0); readonly get => _color.GetElement(0);
set => _color = _color.WithElement(0, value); set => _color = _color.WithElement(0, value);
} }
public int G public int G
{ {
get => _color.GetElement(1); readonly get => _color.GetElement(1);
set => _color = _color.WithElement(1, value); set => _color = _color.WithElement(1, value);
} }
public int B public int B
{ {
get => _color.GetElement(2); readonly get => _color.GetElement(2);
set => _color = _color.WithElement(2, value); set => _color = _color.WithElement(2, value);
} }
public int A public int A
{ {
get => _color.GetElement(3); readonly get => _color.GetElement(3);
set => _color = _color.WithElement(3, value); set => _color = _color.WithElement(3, value);
} }
@@ -180,7 +180,7 @@ namespace Ryujinx.Graphics.Texture.Utils
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public RgbaColor8 GetColor8() public readonly RgbaColor8 GetColor8()
{ {
if (Sse41.IsSupported) if (Sse41.IsSupported)
{ {
@@ -211,17 +211,17 @@ namespace Ryujinx.Graphics.Texture.Utils
return (byte)Math.Clamp(value, 0, 255); return (byte)Math.Clamp(value, 0, 255);
} }
public override int GetHashCode() public readonly override int GetHashCode()
{ {
return HashCode.Combine(R, G, B, A); return HashCode.Combine(R, G, B, A);
} }
public override bool Equals(object obj) public readonly override bool Equals(object obj)
{ {
return obj is RgbaColor32 other && Equals(other); return obj is RgbaColor32 other && Equals(other);
} }
public bool Equals(RgbaColor32 other) public readonly bool Equals(RgbaColor32 other)
{ {
return _color.Equals(other._color); return _color.Equals(other._color);
} }

View File

@@ -54,22 +54,22 @@ namespace Ryujinx.Graphics.Texture.Utils
return Unsafe.As<RgbaColor8, uint>(ref this); return Unsafe.As<RgbaColor8, uint>(ref this);
} }
public override int GetHashCode() public readonly override int GetHashCode()
{ {
return HashCode.Combine(R, G, B, A); return HashCode.Combine(R, G, B, A);
} }
public override bool Equals(object obj) public readonly override bool Equals(object obj)
{ {
return obj is RgbaColor8 other && Equals(other); return obj is RgbaColor8 other && Equals(other);
} }
public bool Equals(RgbaColor8 other) public readonly bool Equals(RgbaColor8 other)
{ {
return R == other.R && G == other.G && B == other.B && A == other.A; return R == other.R && G == other.G && B == other.B && A == other.A;
} }
public byte GetComponent(int index) public readonly byte GetComponent(int index)
{ {
return index switch return index switch
{ {

View File

@@ -6,12 +6,10 @@ namespace Ryujinx.Headless.SDL2
{ {
public string FontFamily => "sans-serif"; public string FontFamily => "sans-serif";
public ThemeColor DefaultBackgroundColor => new ThemeColor(1, 0, 0, 0); public ThemeColor DefaultBackgroundColor => new(1, 0, 0, 0);
public ThemeColor DefaultForegroundColor => new ThemeColor(1, 1, 1, 1); public ThemeColor DefaultForegroundColor => new(1, 1, 1, 1);
public ThemeColor DefaultBorderColor => new ThemeColor(1, 1, 1, 1); public ThemeColor DefaultBorderColor => new(1, 1, 1, 1);
public ThemeColor SelectionBackgroundColor => new ThemeColor(1, 1, 1, 1); public ThemeColor SelectionBackgroundColor => new(1, 1, 1, 1);
public ThemeColor SelectionForegroundColor => new ThemeColor(1, 0, 0, 0); public ThemeColor SelectionForegroundColor => new(1, 0, 0, 0);
public HeadlessHostUiTheme() { }
} }
} }

View File

@@ -11,23 +11,31 @@ namespace Ryujinx.Headless.SDL2.OpenGL
{ {
class OpenGLWindow : WindowBase class OpenGLWindow : WindowBase
{ {
private static void CheckResult(int result)
{
if (result < 0)
{
throw new InvalidOperationException($"SDL_GL function returned an error: {SDL_GetError()}");
}
}
private static void SetupOpenGLAttributes(bool sharedContext, GraphicsDebugLevel debugLevel) private static void SetupOpenGLAttributes(bool sharedContext, GraphicsDebugLevel debugLevel)
{ {
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 3); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 3));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 3); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 3));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_COMPATIBILITY));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_FLAGS, debugLevel != GraphicsDebugLevel.None ? (int)SDL_GLcontext.SDL_GL_CONTEXT_DEBUG_FLAG : 0); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_FLAGS, debugLevel != GraphicsDebugLevel.None ? (int)SDL_GLcontext.SDL_GL_CONTEXT_DEBUG_FLAG : 0));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, sharedContext ? 1 : 0); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, sharedContext ? 1 : 0));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ACCELERATED_VISUAL, 1); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ACCELERATED_VISUAL, 1));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 8); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 8));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DEPTH_SIZE, 16); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DEPTH_SIZE, 16));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STENCIL_SIZE, 0); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STENCIL_SIZE, 0));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1));
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STEREO, 0); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STEREO, 0));
} }
private class OpenToolkitBindingsContext : IBindingsContext private class OpenToolkitBindingsContext : IBindingsContext
@@ -40,9 +48,9 @@ namespace Ryujinx.Headless.SDL2.OpenGL
private class SDL2OpenGLContext : IOpenGLContext private class SDL2OpenGLContext : IOpenGLContext
{ {
private IntPtr _context; private readonly IntPtr _context;
private IntPtr _window; private readonly IntPtr _window;
private bool _shouldDisposeWindow; private readonly bool _shouldDisposeWindow;
public SDL2OpenGLContext(IntPtr context, IntPtr window, bool shouldDisposeWindow = true) public SDL2OpenGLContext(IntPtr context, IntPtr window, bool shouldDisposeWindow = true)
{ {
@@ -62,9 +70,9 @@ namespace Ryujinx.Headless.SDL2.OpenGL
GL.LoadBindings(new OpenToolkitBindingsContext()); GL.LoadBindings(new OpenToolkitBindingsContext());
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 0); CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 0));
SDL_GL_MakeCurrent(windowHandle, IntPtr.Zero); CheckResult(SDL_GL_MakeCurrent(windowHandle, IntPtr.Zero));
return new SDL2OpenGLContext(context, windowHandle); return new SDL2OpenGLContext(context, windowHandle);
} }
@@ -99,7 +107,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
} }
} }
private GraphicsDebugLevel _glLogLevel; private readonly GraphicsDebugLevel _glLogLevel;
private SDL2OpenGLContext _openGLContext; private SDL2OpenGLContext _openGLContext;
public OpenGLWindow( public OpenGLWindow(
@@ -120,7 +128,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
// Ensure to not share this context with other contexts before this point. // Ensure to not share this context with other contexts before this point.
SetupOpenGLAttributes(false, _glLogLevel); SetupOpenGLAttributes(false, _glLogLevel);
IntPtr context = SDL_GL_CreateContext(WindowHandle); IntPtr context = SDL_GL_CreateContext(WindowHandle);
SDL_GL_SetSwapInterval(1); CheckResult(SDL_GL_SetSwapInterval(1));
if (context == IntPtr.Zero) if (context == IntPtr.Zero)
{ {
@@ -157,7 +165,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
Device.DisposeGpu(); Device.DisposeGpu();
// Unbind context and destroy everything // Unbind context and destroy everything
SDL_GL_MakeCurrent(WindowHandle, IntPtr.Zero); CheckResult(SDL_GL_MakeCurrent(WindowHandle, IntPtr.Zero));
_openGLContext.Dispose(); _openGLContext.Dispose();
} }

View File

@@ -88,7 +88,7 @@ namespace Ryujinx.Headless.SDL2
// System // System
[Option("disable-ptc", Required = false, HelpText = "Disables profiled persistent translation cache.")] [Option("disable-ptc", Required = false, HelpText = "Disables profiled persistent translation cache.")]
public bool DisablePtc { get; set; } public bool DisablePTC { get; set; }
[Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")] [Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")]
public bool EnableInternetAccess { get; set; } public bool EnableInternetAccess { get; set; }
@@ -100,7 +100,7 @@ namespace Ryujinx.Headless.SDL2
public int FsGlobalAccessLogMode { get; set; } public int FsGlobalAccessLogMode { get; set; }
[Option("disable-vsync", Required = false, HelpText = "Disables Vertical Sync.")] [Option("disable-vsync", Required = false, HelpText = "Disables Vertical Sync.")]
public bool DisableVsync { get; set; } public bool DisableVSync { get; set; }
[Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")] [Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")]
public bool DisableShaderCache { get; set; } public bool DisableShaderCache { get; set; }
@@ -191,12 +191,12 @@ namespace Ryujinx.Headless.SDL2
public GraphicsBackend GraphicsBackend { get; set; } public GraphicsBackend GraphicsBackend { get; set; }
[Option("preferred-gpu-vendor", Required = false, Default = "", HelpText = "When using the Vulkan backend, prefer using the GPU from the specified vendor.")] [Option("preferred-gpu-vendor", Required = false, Default = "", HelpText = "When using the Vulkan backend, prefer using the GPU from the specified vendor.")]
public string PreferredGpuVendor { get; set; } public string PreferredGPUVendor { get; set; }
// Hacks // Hacks
[Option("expand-ram", Required = false, Default = false, HelpText = "Expands the RAM amount on the emulated system from 4GiB to 6GiB.")] [Option("expand-ram", Required = false, Default = false, HelpText = "Expands the RAM amount on the emulated system from 4GiB to 6GiB.")]
public bool ExpandRam { get; set; } public bool ExpandRAM { get; set; }
[Option("ignore-missing-services", Required = false, Default = false, HelpText = "Enable ignoring missing services.")] [Option("ignore-missing-services", Required = false, Default = false, HelpText = "Enable ignoring missing services.")]
public bool IgnoreMissingServices { get; set; } public bool IgnoreMissingServices { get; set; }

View File

@@ -28,6 +28,7 @@ using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.Input; using Ryujinx.Input;
using Ryujinx.Input.HLE; using Ryujinx.Input.HLE;
using Ryujinx.Input.SDL2; using Ryujinx.Input.SDL2;
using Ryujinx.SDL2.Common;
using Silk.NET.Vulkan; using Silk.NET.Vulkan;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -57,7 +58,7 @@ namespace Ryujinx.Headless.SDL2
private static bool _enableKeyboard; private static bool _enableKeyboard;
private static bool _enableMouse; private static bool _enableMouse;
private static readonly InputConfigJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
static void Main(string[] args) static void Main(string[] args)
{ {
@@ -67,10 +68,10 @@ namespace Ryujinx.Headless.SDL2
if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux()) if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
{ {
AutoResetEvent invoked = new AutoResetEvent(false); AutoResetEvent invoked = new(false);
// MacOS must perform SDL polls from the main thread. // MacOS must perform SDL polls from the main thread.
Ryujinx.SDL2.Common.SDL2Driver.MainThreadDispatcher = (Action action) => SDL2Driver.MainThreadDispatcher = action =>
{ {
invoked.Reset(); invoked.Reset();
@@ -154,7 +155,7 @@ namespace Ryujinx.Headless.SDL2
ButtonL = Key.E, ButtonL = Key.E,
ButtonZl = Key.Q, ButtonZl = Key.Q,
ButtonSl = Key.Unbound, ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound ButtonSr = Key.Unbound,
}, },
LeftJoyconStick = new JoyconConfigKeyboardStick<Key> LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
@@ -176,7 +177,7 @@ namespace Ryujinx.Headless.SDL2
ButtonR = Key.U, ButtonR = Key.U,
ButtonZr = Key.O, ButtonZr = Key.O,
ButtonSl = Key.Unbound, ButtonSl = Key.Unbound,
ButtonSr = Key.Unbound ButtonSr = Key.Unbound,
}, },
RightJoyconStick = new JoyconConfigKeyboardStick<Key> RightJoyconStick = new JoyconConfigKeyboardStick<Key>
@@ -186,7 +187,7 @@ namespace Ryujinx.Headless.SDL2
StickLeft = Key.J, StickLeft = Key.J,
StickRight = Key.L, StickRight = Key.L,
StickButton = Key.H, StickButton = Key.H,
} },
}; };
} }
else else
@@ -259,8 +260,8 @@ namespace Ryujinx.Headless.SDL2
{ {
StrongRumble = 1f, StrongRumble = 1f,
WeakRumble = 1f, WeakRumble = 1f,
EnableRumble = false EnableRumble = false,
} },
}; };
} }
} }
@@ -288,7 +289,7 @@ namespace Ryujinx.Headless.SDL2
try try
{ {
config = JsonHelper.DeserializeFromFile(path, SerializerContext.InputConfig); config = JsonHelper.DeserializeFromFile(path, _serializerContext.InputConfig);
} }
catch (JsonException) catch (JsonException)
{ {
@@ -387,7 +388,7 @@ namespace Ryujinx.Headless.SDL2
_enableKeyboard = option.EnableKeyboard; _enableKeyboard = option.EnableKeyboard;
_enableMouse = option.EnableMouse; _enableMouse = option.EnableMouse;
void LoadPlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index) static void LoadPlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index)
{ {
InputConfig inputConfig = HandlePlayerConfiguration(inputProfileName, inputId, index); InputConfig inputConfig = HandlePlayerConfiguration(inputProfileName, inputId, index);
@@ -468,19 +469,12 @@ namespace Ryujinx.Headless.SDL2
private static void ProgressHandler<T>(T state, int current, int total) where T : Enum private static void ProgressHandler<T>(T state, int current, int total) where T : Enum
{ {
string label; string label = state switch
switch (state)
{ {
case LoadState ptcState: LoadState => $"PTC : {current}/{total}",
label = $"PTC : {current}/{total}"; ShaderCacheState => $"Shaders : {current}/{total}",
break; _ => throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}"),
case ShaderCacheState shaderCacheState: };
label = $"Shaders : {current}/{total}";
break;
default:
throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
}
Logger.Info?.Print(LogClass.Application, label); Logger.Info?.Print(LogClass.Application, label);
} }
@@ -499,9 +493,9 @@ namespace Ryujinx.Headless.SDL2
string preferredGpuId = string.Empty; string preferredGpuId = string.Empty;
Vk api = Vk.GetApi(); Vk api = Vk.GetApi();
if (!string.IsNullOrEmpty(options.PreferredGpuVendor)) if (!string.IsNullOrEmpty(options.PreferredGPUVendor))
{ {
string preferredGpuVendor = options.PreferredGpuVendor.ToLowerInvariant(); string preferredGpuVendor = options.PreferredGPUVendor.ToLowerInvariant();
var devices = VulkanRenderer.GetPhysicalDevices(api); var devices = VulkanRenderer.GetPhysicalDevices(api);
foreach (var device in devices) foreach (var device in devices)
@@ -520,11 +514,9 @@ namespace Ryujinx.Headless.SDL2
vulkanWindow.GetRequiredInstanceExtensions, vulkanWindow.GetRequiredInstanceExtensions,
preferredGpuId); preferredGpuId);
} }
else
{
return new OpenGLRenderer(); return new OpenGLRenderer();
} }
}
private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options) private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options)
{ {
@@ -537,20 +529,20 @@ namespace Ryujinx.Headless.SDL2
renderer = new ThreadedRenderer(renderer); renderer = new ThreadedRenderer(renderer);
} }
HLEConfiguration configuration = new HLEConfiguration(_virtualFileSystem, HLEConfiguration configuration = new(_virtualFileSystem,
_libHacHorizonManager, _libHacHorizonManager,
_contentManager, _contentManager,
_accountManager, _accountManager,
_userChannelPersistence, _userChannelPersistence,
renderer, renderer,
new SDL2HardwareDeviceDriver(), new SDL2HardwareDeviceDriver(),
options.ExpandRam ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB, options.ExpandRAM ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB,
window, window,
options.SystemLanguage, options.SystemLanguage,
options.SystemRegion, options.SystemRegion,
!options.DisableVsync, !options.DisableVSync,
!options.DisableDockedMode, !options.DisableDockedMode,
!options.DisablePtc, !options.DisablePTC,
options.EnableInternetAccess, options.EnableInternetAccess,
!options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, !options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
options.FsGlobalAccessLogMode, options.FsGlobalAccessLogMode,

View File

@@ -1,4 +1,5 @@
using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Input; using Ryujinx.Input;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@@ -14,7 +15,7 @@ namespace Ryujinx.Headless.SDL2
private const int CursorHideIdleTime = 5; // seconds private const int CursorHideIdleTime = 5; // seconds
private bool _isDisposed; private bool _isDisposed;
private HideCursorMode _hideCursorMode; private readonly HideCursorMode _hideCursorMode;
private bool _isHidden; private bool _isHidden;
private long _lastCursorMoveTime; private long _lastCursorMoveTime;
@@ -22,7 +23,7 @@ namespace Ryujinx.Headless.SDL2
public Vector2 CurrentPosition { get; private set; } public Vector2 CurrentPosition { get; private set; }
public Vector2 Scroll { get; private set; } public Vector2 Scroll { get; private set; }
public Size _clientSize; public Size ClientSize;
public SDL2MouseDriver(HideCursorMode hideCursorMode) public SDL2MouseDriver(HideCursorMode hideCursorMode)
{ {
@@ -31,7 +32,11 @@ namespace Ryujinx.Headless.SDL2
if (_hideCursorMode == HideCursorMode.Always) if (_hideCursorMode == HideCursorMode.Always)
{ {
SDL_ShowCursor(SDL_DISABLE); if (SDL_ShowCursor(SDL_DISABLE) != SDL_DISABLE)
{
Logger.Error?.PrintMsg(LogClass.Application, "Failed to disable the cursor.");
}
_isHidden = true; _isHidden = true;
} }
} }
@@ -46,7 +51,7 @@ namespace Ryujinx.Headless.SDL2
public void UpdatePosition() public void UpdatePosition()
{ {
SDL_GetMouseState(out int posX, out int posY); _ = SDL_GetMouseState(out int posX, out int posY);
Vector2 position = new(posX, posY); Vector2 position = new(posX, posY);
if (CurrentPosition != position) if (CurrentPosition != position)
@@ -71,7 +76,11 @@ namespace Ryujinx.Headless.SDL2
{ {
if (!_isHidden) if (!_isHidden)
{ {
SDL_ShowCursor(SDL_DISABLE); if (SDL_ShowCursor(SDL_DISABLE) != SDL_DISABLE)
{
Logger.Error?.PrintMsg(LogClass.Application, "Failed to disable the cursor.");
}
_isHidden = true; _isHidden = true;
} }
} }
@@ -79,7 +88,11 @@ namespace Ryujinx.Headless.SDL2
{ {
if (_isHidden) if (_isHidden)
{ {
SDL_ShowCursor(SDL_ENABLE); if (SDL_ShowCursor(SDL_ENABLE) != SDL_ENABLE)
{
Logger.Error?.PrintMsg(LogClass.Application, "Failed to enable the cursor.");
}
_isHidden = false; _isHidden = false;
} }
} }
@@ -118,7 +131,7 @@ namespace Ryujinx.Headless.SDL2
public void SetClientSize(int width, int height) public void SetClientSize(int width, int height)
{ {
_clientSize = new Size(width, height); ClientSize = new Size(width, height);
} }
public bool IsButtonPressed(MouseButton button) public bool IsButtonPressed(MouseButton button)
@@ -128,7 +141,7 @@ namespace Ryujinx.Headless.SDL2
public Size GetClientSize() public Size GetClientSize()
{ {
return _clientSize; return ClientSize;
} }
public string DriverName => "SDL2"; public string DriverName => "SDL2";

View File

@@ -10,7 +10,7 @@ namespace Ryujinx.Headless.SDL2.Vulkan
{ {
class VulkanWindow : WindowBase class VulkanWindow : WindowBase
{ {
private GraphicsDebugLevel _glLogLevel; private readonly GraphicsDebugLevel _glLogLevel;
public VulkanWindow( public VulkanWindow(
InputManager inputManager, InputManager inputManager,
@@ -33,16 +33,16 @@ namespace Ryujinx.Headless.SDL2.Vulkan
MouseDriver.SetClientSize(DefaultWidth, DefaultHeight); MouseDriver.SetClientSize(DefaultWidth, DefaultHeight);
} }
private void BasicInvoke(Action action) private static void BasicInvoke(Action action)
{ {
action(); action();
} }
public unsafe IntPtr CreateWindowSurface(IntPtr instance) public IntPtr CreateWindowSurface(IntPtr instance)
{ {
ulong surfaceHandle = 0; ulong surfaceHandle = 0;
Action createSurface = () => void CreateSurface()
{ {
if (SDL_Vulkan_CreateSurface(WindowHandle, instance, out surfaceHandle) == SDL_bool.SDL_FALSE) if (SDL_Vulkan_CreateSurface(WindowHandle, instance, out surfaceHandle) == SDL_bool.SDL_FALSE)
{ {
@@ -52,15 +52,15 @@ namespace Ryujinx.Headless.SDL2.Vulkan
throw new Exception(errorMessage); throw new Exception(errorMessage);
} }
}; }
if (SDL2Driver.MainThreadDispatcher != null) if (SDL2Driver.MainThreadDispatcher != null)
{ {
SDL2Driver.MainThreadDispatcher(createSurface); SDL2Driver.MainThreadDispatcher(CreateSurface);
} }
else else
{ {
createSurface(); CreateSurface();
} }
return (IntPtr)surfaceHandle; return (IntPtr)surfaceHandle;

View File

@@ -4,6 +4,8 @@ using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.GAL.Multithreading; using Ryujinx.Graphics.GAL.Multithreading;
using Ryujinx.Graphics.Gpu;
using Ryujinx.Graphics.OpenGL;
using Ryujinx.HLE.HOS.Applets; using Ryujinx.HLE.HOS.Applets;
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types; using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
using Ryujinx.HLE.Ui; using Ryujinx.HLE.Ui;
@@ -30,7 +32,7 @@ namespace Ryujinx.Headless.SDL2
private const SDL_WindowFlags DefaultFlags = SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI | SDL_WindowFlags.SDL_WINDOW_RESIZABLE | SDL_WindowFlags.SDL_WINDOW_INPUT_FOCUS | SDL_WindowFlags.SDL_WINDOW_SHOWN; private const SDL_WindowFlags DefaultFlags = SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI | SDL_WindowFlags.SDL_WINDOW_RESIZABLE | SDL_WindowFlags.SDL_WINDOW_INPUT_FOCUS | SDL_WindowFlags.SDL_WINDOW_SHOWN;
private const int TargetFps = 60; private const int TargetFps = 60;
private static ConcurrentQueue<Action> MainThreadActions = new ConcurrentQueue<Action>(); private static readonly ConcurrentQueue<Action> _mainThreadActions = new();
[LibraryImport("SDL2")] [LibraryImport("SDL2")]
// TODO: Remove this as soon as SDL2-CS was updated to expose this method publicly // TODO: Remove this as soon as SDL2-CS was updated to expose this method publicly
@@ -38,7 +40,7 @@ namespace Ryujinx.Headless.SDL2
public static void QueueMainThreadAction(Action action) public static void QueueMainThreadAction(Action action)
{ {
MainThreadActions.Enqueue(action); _mainThreadActions.Enqueue(action);
} }
public NpadManager NpadManager { get; } public NpadManager NpadManager { get; }
@@ -55,9 +57,9 @@ namespace Ryujinx.Headless.SDL2
public int Height { get; private set; } public int Height { get; private set; }
protected SDL2MouseDriver MouseDriver; protected SDL2MouseDriver MouseDriver;
private InputManager _inputManager; private readonly InputManager _inputManager;
private IKeyboard _keyboardInterface; private readonly IKeyboard _keyboardInterface;
private GraphicsDebugLevel _glLogLevel; private readonly GraphicsDebugLevel _glLogLevel;
private readonly Stopwatch _chrono; private readonly Stopwatch _chrono;
private readonly long _ticksPerFrame; private readonly long _ticksPerFrame;
private readonly CancellationTokenSource _gpuCancellationTokenSource; private readonly CancellationTokenSource _gpuCancellationTokenSource;
@@ -71,8 +73,8 @@ namespace Ryujinx.Headless.SDL2
private string _gpuVendorName; private string _gpuVendorName;
private AspectRatio _aspectRatio; private readonly AspectRatio _aspectRatio;
private bool _enableMouse; private readonly bool _enableMouse;
public WindowBase( public WindowBase(
InputManager inputManager, InputManager inputManager,
@@ -192,9 +194,6 @@ namespace Ryujinx.Headless.SDL2
case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE: case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
Exit(); Exit();
break; break;
default:
break;
} }
} }
else else
@@ -260,7 +259,7 @@ namespace Ryujinx.Headless.SDL2
if (_ticks >= _ticksPerFrame) if (_ticks >= _ticksPerFrame)
{ {
string dockedMode = Device.System.State.DockedMode ? "Docked" : "Handheld"; string dockedMode = Device.System.State.DockedMode ? "Docked" : "Handheld";
float scale = Graphics.Gpu.GraphicsConfig.ResScale; float scale = GraphicsConfig.ResScale;
if (scale != 1) if (scale != 1)
{ {
dockedMode += $" ({scale}x)"; dockedMode += $" ({scale}x)";
@@ -309,9 +308,9 @@ namespace Ryujinx.Headless.SDL2
_exitEvent.Dispose(); _exitEvent.Dispose();
} }
public void ProcessMainThreadQueue() public static void ProcessMainThreadQueue()
{ {
while (MainThreadActions.TryDequeue(out Action action)) while (_mainThreadActions.TryDequeue(out Action action))
{ {
action(); action();
} }
@@ -334,7 +333,7 @@ namespace Ryujinx.Headless.SDL2
_exitEvent.Set(); _exitEvent.Set();
} }
private void NVStutterWorkaround() private void NvidiaStutterWorkaround()
{ {
while (_isActive) while (_isActive)
{ {
@@ -348,7 +347,7 @@ namespace Ryujinx.Headless.SDL2
// TODO: This should be removed when the issue with the GateThread is resolved. // TODO: This should be removed when the issue with the GateThread is resolved.
ThreadPool.QueueUserWorkItem((state) => { }); ThreadPool.QueueUserWorkItem(state => { });
Thread.Sleep(300); Thread.Sleep(300);
} }
} }
@@ -396,20 +395,20 @@ namespace Ryujinx.Headless.SDL2
InitializeWindow(); InitializeWindow();
Thread renderLoopThread = new Thread(Render) Thread renderLoopThread = new(Render)
{ {
Name = "GUI.RenderLoop" Name = "GUI.RenderLoop",
}; };
renderLoopThread.Start(); renderLoopThread.Start();
Thread nvStutterWorkaround = null; Thread nvidiaStutterWorkaround = null;
if (Renderer is Graphics.OpenGL.OpenGLRenderer) if (Renderer is OpenGLRenderer)
{ {
nvStutterWorkaround = new Thread(NVStutterWorkaround) nvidiaStutterWorkaround = new Thread(NvidiaStutterWorkaround)
{ {
Name = "GUI.NVStutterWorkaround" Name = "GUI.NvidiaStutterWorkaround",
}; };
nvStutterWorkaround.Start(); nvidiaStutterWorkaround.Start();
} }
MainLoop(); MainLoop();
@@ -418,7 +417,7 @@ namespace Ryujinx.Headless.SDL2
// We only need to wait for all commands submitted during the main gpu loop to be processed. // We only need to wait for all commands submitted during the main gpu loop to be processed.
_gpuDoneEvent.WaitOne(); _gpuDoneEvent.WaitOne();
_gpuDoneEvent.Dispose(); _gpuDoneEvent.Dispose();
nvStutterWorkaround?.Join(); nvidiaStutterWorkaround?.Join();
Exit(); Exit();
} }
@@ -465,13 +464,13 @@ namespace Ryujinx.Headless.SDL2
public bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText) public bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText)
{ {
SDL_MessageBoxData data = new SDL_MessageBoxData SDL_MessageBoxData data = new()
{ {
title = title, title = title,
message = message, message = message,
buttons = new SDL_MessageBoxButtonData[buttonsText.Length], buttons = new SDL_MessageBoxButtonData[buttonsText.Length],
numbuttons = buttonsText.Length, numbuttons = buttonsText.Length,
window = WindowHandle window = WindowHandle,
}; };
for (int i = 0; i < buttonsText.Length; i++) for (int i = 0; i < buttonsText.Length; i++)
@@ -479,7 +478,7 @@ namespace Ryujinx.Headless.SDL2
data.buttons[i] = new SDL_MessageBoxButtonData data.buttons[i] = new SDL_MessageBoxButtonData
{ {
buttonid = i, buttonid = i,
text = buttonsText[i] text = buttonsText[i],
}; };
} }

View File

@@ -180,7 +180,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction Decorate(Instruction target, Decoration decoration, Operand parameter) public Instruction Decorate(Instruction target, Decoration decoration, IOperand parameter)
{ {
Instruction result = NewInstruction(Op.OpDecorate); Instruction result = NewInstruction(Op.OpDecorate);
@@ -192,7 +192,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction Decorate(Instruction target, Decoration decoration, params Operand[] parameters) public Instruction Decorate(Instruction target, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorate); Instruction result = NewInstruction(Op.OpDecorate);
@@ -216,7 +216,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, Operand parameter) public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, IOperand parameter)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorate); Instruction result = NewInstruction(Op.OpMemberDecorate);
@@ -229,7 +229,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, params Operand[] parameters) public Instruction MemberDecorate(Instruction structureType, LiteralInteger member, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorate); Instruction result = NewInstruction(Op.OpMemberDecorate);
@@ -262,7 +262,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction GroupMemberDecorate(Instruction decorationGroup, params Operand[] targets) public Instruction GroupMemberDecorate(Instruction decorationGroup, params IOperand[] targets)
{ {
Instruction result = NewInstruction(Op.OpGroupMemberDecorate); Instruction result = NewInstruction(Op.OpGroupMemberDecorate);
@@ -273,7 +273,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction DecorateId(Instruction target, Decoration decoration, params Operand[] parameters) public Instruction DecorateId(Instruction target, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorateId); Instruction result = NewInstruction(Op.OpDecorateId);
@@ -285,7 +285,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction DecorateString(Instruction target, Decoration decoration, params Operand[] parameters) public Instruction DecorateString(Instruction target, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorateString); Instruction result = NewInstruction(Op.OpDecorateString);
@@ -297,7 +297,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params Operand[] parameters) public Instruction DecorateStringGOOGLE(Instruction target, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpDecorateStringGOOGLE); Instruction result = NewInstruction(Op.OpDecorateStringGOOGLE);
@@ -309,7 +309,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction MemberDecorateString(Instruction structType, LiteralInteger member, Decoration decoration, params Operand[] parameters) public Instruction MemberDecorateString(Instruction structType, LiteralInteger member, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorateString); Instruction result = NewInstruction(Op.OpMemberDecorateString);
@@ -322,7 +322,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction MemberDecorateStringGOOGLE(Instruction structType, LiteralInteger member, Decoration decoration, params Operand[] parameters) public Instruction MemberDecorateStringGOOGLE(Instruction structType, LiteralInteger member, Decoration decoration, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpMemberDecorateStringGOOGLE); Instruction result = NewInstruction(Op.OpMemberDecorateStringGOOGLE);
@@ -2815,7 +2815,7 @@ namespace Spv.Generator
return result; return result;
} }
public Instruction Switch(Instruction selector, Instruction defaultObj, params Operand[] target) public Instruction Switch(Instruction selector, Instruction defaultObj, params IOperand[] target)
{ {
Instruction result = NewInstruction(Op.OpSwitch); Instruction result = NewInstruction(Op.OpSwitch);

View File

@@ -26,8 +26,6 @@
// IN THE MATERIALS. // IN THE MATERIALS.
#endregion #endregion
using static Spv.Specification;
namespace Spv.Generator namespace Spv.Generator
{ {
public partial class Module public partial class Module

View File

@@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
namespace Spv.Generator namespace Spv.Generator
{ {
internal struct ConstantKey : IEquatable<ConstantKey> internal readonly struct ConstantKey : IEquatable<ConstantKey>
{ {
private readonly Instruction _constant; private readonly Instruction _constant;
@@ -24,7 +24,7 @@ namespace Spv.Generator
public override bool Equals([NotNullWhen(true)] object obj) public override bool Equals([NotNullWhen(true)] object obj)
{ {
return obj is ConstantKey && Equals((ConstantKey)obj); return obj is ConstantKey key && Equals(key);
} }
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
namespace Spv.Generator namespace Spv.Generator
{ {
@@ -19,12 +18,12 @@ namespace Spv.Generator
public bool Equals(DeterministicStringKey other) public bool Equals(DeterministicStringKey other)
{ {
return _value == other._value; return _value == other?._value;
} }
public override bool Equals([NotNullWhen(true)] object obj) public override bool Equals(object obj)
{ {
return obj is DeterministicStringKey && Equals((DeterministicStringKey)obj); return obj is DeterministicStringKey key && Equals(key);
} }
} }
} }

View File

@@ -4,17 +4,15 @@ namespace Spv.Generator
{ {
public class GeneratorPool<T> where T : class, new() public class GeneratorPool<T> where T : class, new()
{ {
private List<T[]> _pool; private readonly List<T[]> _pool;
private int _chunkIndex = -1; private int _chunkIndex = -1;
private int _poolIndex = -1; private int _poolIndex = -1;
private int _initialSize; private readonly int _poolSizeIncrement;
private int _poolSizeIncrement;
public GeneratorPool() : this(1000, 200) { } public GeneratorPool() : this(1000, 200) { }
public GeneratorPool(int chunkSizeLimit, int poolSizeIncrement) public GeneratorPool(int chunkSizeLimit, int poolSizeIncrement)
{ {
_initialSize = chunkSizeLimit;
_poolSizeIncrement = poolSizeIncrement; _poolSizeIncrement = poolSizeIncrement;
_pool = new(chunkSizeLimit * 2); _pool = new(chunkSizeLimit * 2);

View File

@@ -3,7 +3,7 @@ using System.IO;
namespace Spv.Generator namespace Spv.Generator
{ {
public interface Operand : IEquatable<Operand> public interface IOperand : IEquatable<IOperand>
{ {
OperandType Type { get; } OperandType Type { get; }

View File

@@ -5,7 +5,7 @@ using System.IO;
namespace Spv.Generator namespace Spv.Generator
{ {
public sealed class Instruction : Operand, IEquatable<Instruction> public sealed class Instruction : IOperand, IEquatable<Instruction>
{ {
public const uint InvalidId = uint.MaxValue; public const uint InvalidId = uint.MaxValue;
@@ -47,7 +47,7 @@ namespace Spv.Generator
result += _resultType.WordCount; result += _resultType.WordCount;
} }
Span<Operand> operands = _operands.AsSpan(); Span<IOperand> operands = _operands.AsSpan();
for (int i = 0; i < operands.Length; i++) for (int i = 0; i < operands.Length; i++)
{ {
result += operands[i].WordCount; result += operands[i].WordCount;
@@ -58,15 +58,15 @@ namespace Spv.Generator
public ushort WordCount => 1; public ushort WordCount => 1;
public void AddOperand(Operand value) public void AddOperand(IOperand value)
{ {
Debug.Assert(value != null); Debug.Assert(value != null);
_operands.Add(value); _operands.Add(value);
} }
public void AddOperand(Operand[] value) public void AddOperand(IOperand[] value)
{ {
foreach (Operand instruction in value) foreach (IOperand instruction in value)
{ {
AddOperand(instruction); AddOperand(instruction);
} }
@@ -82,7 +82,7 @@ namespace Spv.Generator
public void AddOperand(LiteralInteger value) public void AddOperand(LiteralInteger value)
{ {
AddOperand((Operand)value); AddOperand((IOperand)value);
} }
public void AddOperand(Instruction[] value) public void AddOperand(Instruction[] value)
@@ -95,7 +95,7 @@ namespace Spv.Generator
public void AddOperand(Instruction value) public void AddOperand(Instruction value)
{ {
AddOperand((Operand)value); AddOperand((IOperand)value);
} }
public void AddOperand(string value) public void AddOperand(string value)
@@ -121,7 +121,7 @@ namespace Spv.Generator
writer.Write(Id); writer.Write(Id);
} }
Span<Operand> operands = _operands.AsSpan(); Span<IOperand> operands = _operands.AsSpan();
for (int i = 0; i < operands.Length; i++) for (int i = 0; i < operands.Length; i++)
{ {
operands[i].WriteOperand(writer); operands[i].WriteOperand(writer);
@@ -186,8 +186,8 @@ namespace Spv.Generator
public bool EqualsContent(Instruction cmpObj) public bool EqualsContent(Instruction cmpObj)
{ {
Span<Operand> thisOperands = _operands.AsSpan(); Span<IOperand> thisOperands = _operands.AsSpan();
Span<Operand> cmpOperands = cmpObj._operands.AsSpan(); Span<IOperand> cmpOperands = cmpObj._operands.AsSpan();
if (thisOperands.Length != cmpOperands.Length) if (thisOperands.Length != cmpOperands.Length)
{ {
@@ -212,7 +212,7 @@ namespace Spv.Generator
public int GetHashCodeContent() public int GetHashCodeContent()
{ {
return DeterministicHashCode.Combine<Operand>(_operands.AsSpan()); return DeterministicHashCode.Combine<IOperand>(_operands.AsSpan());
} }
public int GetHashCodeResultType() public int GetHashCodeResultType()
@@ -222,10 +222,10 @@ namespace Spv.Generator
public override int GetHashCode() public override int GetHashCode()
{ {
return DeterministicHashCode.Combine(Opcode, Id, _resultType, DeterministicHashCode.Combine<Operand>(_operands.AsSpan())); return DeterministicHashCode.Combine(Opcode, Id, _resultType, DeterministicHashCode.Combine<IOperand>(_operands.AsSpan()));
} }
public bool Equals(Operand obj) public bool Equals(IOperand obj)
{ {
return obj is Instruction instruction && Equals(instruction); return obj is Instruction instruction && Equals(instruction);
} }

View File

@@ -10,14 +10,14 @@ namespace Spv.Generator
private const int InternalCount = 5; private const int InternalCount = 5;
public int Count; public int Count;
public Operand Operand1; public IOperand Operand1;
public Operand Operand2; public IOperand Operand2;
public Operand Operand3; public IOperand Operand3;
public Operand Operand4; public IOperand Operand4;
public Operand Operand5; public IOperand Operand5;
public Operand[] Overflow; public IOperand[] Overflow;
public Span<Operand> AsSpan() public Span<IOperand> AsSpan()
{ {
if (Count > InternalCount) if (Count > InternalCount)
{ {
@@ -29,7 +29,7 @@ namespace Spv.Generator
} }
} }
public void Add(Operand operand) public void Add(IOperand operand)
{ {
if (Count < InternalCount) if (Count < InternalCount)
{ {
@@ -40,7 +40,7 @@ namespace Spv.Generator
{ {
if (Overflow == null) if (Overflow == null)
{ {
Overflow = new Operand[InternalCount * 2]; Overflow = new IOperand[InternalCount * 2];
MemoryMarshal.CreateSpan(ref this.Operand1, InternalCount).CopyTo(Overflow.AsSpan()); MemoryMarshal.CreateSpan(ref this.Operand1, InternalCount).CopyTo(Overflow.AsSpan());
} }
else if (Count == Overflow.Length) else if (Count == Overflow.Length)
@@ -52,16 +52,16 @@ namespace Spv.Generator
} }
} }
private IEnumerable<Operand> AllOperands => new[] { Operand1, Operand2, Operand3, Operand4, Operand5 } private readonly IEnumerable<IOperand> AllOperands => new[] { Operand1, Operand2, Operand3, Operand4, Operand5 }
.Concat(Overflow ?? Array.Empty<Operand>()) .Concat(Overflow ?? Array.Empty<IOperand>())
.Take(Count); .Take(Count);
public override string ToString() public readonly override string ToString()
{ {
return $"({string.Join(", ", AllOperands)})"; return $"({string.Join(", ", AllOperands)})";
} }
public string ToString(string[] labels) public readonly string ToString(string[] labels)
{ {
var labeledParams = AllOperands.Zip(labels, (op, label) => $"{label}: {op}"); var labeledParams = AllOperands.Zip(labels, (op, label) => $"{label}: {op}");
var unlabeledParams = AllOperands.Skip(labels.Length).Select(op => op.ToString()); var unlabeledParams = AllOperands.Skip(labels.Length).Select(op => op.ToString());

View File

@@ -3,7 +3,7 @@ using System.IO;
namespace Spv.Generator namespace Spv.Generator
{ {
public class LiteralInteger : Operand, IEquatable<LiteralInteger> public class LiteralInteger : IOperand, IEquatable<LiteralInteger>
{ {
[ThreadStatic] [ThreadStatic]
private static GeneratorPool<LiteralInteger> _pool; private static GeneratorPool<LiteralInteger> _pool;
@@ -95,7 +95,7 @@ namespace Spv.Generator
return DeterministicHashCode.Combine(Type, _data); return DeterministicHashCode.Combine(Type, _data);
} }
public bool Equals(Operand obj) public bool Equals(IOperand obj)
{ {
return obj is LiteralInteger literalInteger && Equals(literalInteger); return obj is LiteralInteger literalInteger && Equals(literalInteger);
} }

View File

@@ -4,7 +4,7 @@ using System.Text;
namespace Spv.Generator namespace Spv.Generator
{ {
public class LiteralString : Operand, IEquatable<LiteralString> public class LiteralString : IOperand, IEquatable<LiteralString>
{ {
public OperandType Type => OperandType.String; public OperandType Type => OperandType.String;
@@ -44,7 +44,7 @@ namespace Spv.Generator
return DeterministicHashCode.Combine(Type, DeterministicHashCode.GetHashCode(_value)); return DeterministicHashCode.Combine(Type, DeterministicHashCode.GetHashCode(_value));
} }
public bool Equals(Operand obj) public bool Equals(IOperand obj)
{ {
return obj is LiteralString literalString && Equals(literalString); return obj is LiteralString literalString && Equals(literalString);
} }

View File

@@ -15,30 +15,30 @@ namespace Spv.Generator
private uint _bound; private uint _bound;
// Follow spec order here while keeping it as simple as possible. // Follow spec order here while keeping it as simple as possible.
private List<Capability> _capabilities; private readonly List<Capability> _capabilities;
private List<string> _extensions; private readonly List<string> _extensions;
private Dictionary<DeterministicStringKey, Instruction> _extInstImports; private readonly Dictionary<DeterministicStringKey, Instruction> _extInstImports;
private AddressingModel _addressingModel; private AddressingModel _addressingModel;
private MemoryModel _memoryModel; private MemoryModel _memoryModel;
private List<Instruction> _entrypoints; private readonly List<Instruction> _entrypoints;
private List<Instruction> _executionModes; private readonly List<Instruction> _executionModes;
private List<Instruction> _debug; private readonly List<Instruction> _debug;
private List<Instruction> _annotations; private readonly List<Instruction> _annotations;
// In the declaration block. // In the declaration block.
private Dictionary<TypeDeclarationKey, Instruction> _typeDeclarations; private readonly Dictionary<TypeDeclarationKey, Instruction> _typeDeclarations;
// In the declaration block. // In the declaration block.
private List<Instruction> _globals; private readonly List<Instruction> _globals;
// In the declaration block. // In the declaration block.
private Dictionary<ConstantKey, Instruction> _constants; private readonly Dictionary<ConstantKey, Instruction> _constants;
// In the declaration block, for function that aren't defined in the module. // In the declaration block, for function that aren't defined in the module.
private List<Instruction> _functionsDeclarations; private readonly List<Instruction> _functionsDeclarations;
private List<Instruction> _functionsDefinitions; private readonly List<Instruction> _functionsDefinitions;
private GeneratorPool<Instruction> _instPool; private readonly GeneratorPool<Instruction> _instPool;
private GeneratorPool<LiteralInteger> _integerPool; private readonly GeneratorPool<LiteralInteger> _integerPool;
public Module(uint version, GeneratorPool<Instruction> instPool = null, GeneratorPool<LiteralInteger> integerPool = null) public Module(uint version, GeneratorPool<Instruction> instPool = null, GeneratorPool<LiteralInteger> integerPool = null)
{ {
@@ -143,7 +143,7 @@ namespace Spv.Generator
_entrypoints.Add(entryPoint); _entrypoints.Add(entryPoint);
} }
public void AddExecutionMode(Instruction function, ExecutionMode mode, params Operand[] parameters) public void AddExecutionMode(Instruction function, ExecutionMode mode, params IOperand[] parameters)
{ {
Debug.Assert(function.Opcode == Op.OpFunction); Debug.Assert(function.Opcode == Op.OpFunction);
@@ -225,7 +225,7 @@ namespace Spv.Generator
_constants.Add(key, constant); _constants.Add(key, constant);
} }
public Instruction ExtInst(Instruction resultType, Instruction set, LiteralInteger instruction, params Operand[] parameters) public Instruction ExtInst(Instruction resultType, Instruction set, LiteralInteger instruction, params IOperand[] parameters)
{ {
Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType); Instruction result = NewInstruction(Op.OpExtInst, GetNewId(), resultType);
@@ -262,9 +262,9 @@ namespace Spv.Generator
// Estimate the size needed for the generated code, to avoid expanding the MemoryStream. // Estimate the size needed for the generated code, to avoid expanding the MemoryStream.
int sizeEstimate = 1024 + _functionsDefinitions.Count * 32; int sizeEstimate = 1024 + _functionsDefinitions.Count * 32;
using (MemoryStream stream = new MemoryStream(sizeEstimate)) using MemoryStream stream = new(sizeEstimate);
{
BinaryWriter writer = new BinaryWriter(stream, System.Text.Encoding.ASCII); BinaryWriter writer = new(stream, System.Text.Encoding.ASCII);
// Header // Header
writer.Write(MagicNumber); writer.Write(MagicNumber);
@@ -329,7 +329,7 @@ namespace Spv.Generator
} }
// Ensure that everything is in the right order in the declarations section. // Ensure that everything is in the right order in the declarations section.
List<Instruction> declarations = new List<Instruction>(); List<Instruction> declarations = new();
declarations.AddRange(_typeDeclarations.Values); declarations.AddRange(_typeDeclarations.Values);
declarations.AddRange(_globals); declarations.AddRange(_globals);
declarations.AddRange(_constants.Values); declarations.AddRange(_constants.Values);
@@ -362,4 +362,3 @@ namespace Spv.Generator
} }
} }
} }
}

View File

@@ -3,7 +3,7 @@ using System.Diagnostics.CodeAnalysis;
namespace Spv.Generator namespace Spv.Generator
{ {
internal struct TypeDeclarationKey : IEquatable<TypeDeclarationKey> internal readonly struct TypeDeclarationKey : IEquatable<TypeDeclarationKey>
{ {
private readonly Instruction _typeDeclaration; private readonly Instruction _typeDeclaration;
@@ -24,7 +24,7 @@ namespace Spv.Generator
public override bool Equals([NotNullWhen(true)] object obj) public override bool Equals([NotNullWhen(true)] object obj)
{ {
return obj is TypeDeclarationKey && Equals((TypeDeclarationKey)obj); return obj is TypeDeclarationKey key && Equals(key);
} }
} }
} }

View File

@@ -75,17 +75,17 @@ namespace Spv
TaskNV = 5267, TaskNV = 5267,
MeshNV = 5268, MeshNV = 5268,
RayGenerationKHR = 5313, RayGenerationKHR = 5313,
RayGenerationNV = 5313, RayGenerationNV = RayGenerationKHR,
IntersectionKHR = 5314, IntersectionKHR = 5314,
IntersectionNV = 5314, IntersectionNV = IntersectionKHR,
AnyHitKHR = 5315, AnyHitKHR = 5315,
AnyHitNV = 5315, AnyHitNV = AnyHitKHR,
ClosestHitKHR = 5316, ClosestHitKHR = 5316,
ClosestHitNV = 5316, ClosestHitNV = ClosestHitKHR,
MissKHR = 5317, MissKHR = 5317,
MissNV = 5317, MissNV = MissKHR,
CallableKHR = 5318, CallableKHR = 5318,
CallableNV = 5318, CallableNV = CallableKHR,
} }
public enum AddressingModel public enum AddressingModel
@@ -94,7 +94,7 @@ namespace Spv
Physical32 = 1, Physical32 = 1,
Physical64 = 2, Physical64 = 2,
PhysicalStorageBuffer64 = 5348, PhysicalStorageBuffer64 = 5348,
PhysicalStorageBuffer64EXT = 5348, PhysicalStorageBuffer64EXT = PhysicalStorageBuffer64,
} }
public enum MemoryModel public enum MemoryModel
@@ -103,7 +103,7 @@ namespace Spv
GLSL450 = 1, GLSL450 = 1,
OpenCL = 2, OpenCL = 2,
Vulkan = 3, Vulkan = 3,
VulkanKHR = 3, VulkanKHR = Vulkan,
} }
public enum ExecutionMode public enum ExecutionMode
@@ -186,19 +186,19 @@ namespace Spv
Image = 11, Image = 11,
StorageBuffer = 12, StorageBuffer = 12,
CallableDataKHR = 5328, CallableDataKHR = 5328,
CallableDataNV = 5328, CallableDataNV = CallableDataKHR,
IncomingCallableDataKHR = 5329, IncomingCallableDataKHR = 5329,
IncomingCallableDataNV = 5329, IncomingCallableDataNV = IncomingCallableDataKHR,
RayPayloadKHR = 5338, RayPayloadKHR = 5338,
RayPayloadNV = 5338, RayPayloadNV = RayPayloadKHR,
HitAttributeKHR = 5339, HitAttributeKHR = 5339,
HitAttributeNV = 5339, HitAttributeNV = HitAttributeKHR,
IncomingRayPayloadKHR = 5342, IncomingRayPayloadKHR = 5342,
IncomingRayPayloadNV = 5342, IncomingRayPayloadNV = IncomingRayPayloadKHR,
ShaderRecordBufferKHR = 5343, ShaderRecordBufferKHR = 5343,
ShaderRecordBufferNV = 5343, ShaderRecordBufferNV = ShaderRecordBufferKHR,
PhysicalStorageBuffer = 5349, PhysicalStorageBuffer = 5349,
PhysicalStorageBufferEXT = 5349, PhysicalStorageBufferEXT = PhysicalStorageBuffer,
CodeSectionINTEL = 5605, CodeSectionINTEL = 5605,
} }
@@ -330,13 +330,13 @@ namespace Spv
Sample = 6, Sample = 6,
MinLod = 7, MinLod = 7,
MakeTexelAvailable = 8, MakeTexelAvailable = 8,
MakeTexelAvailableKHR = 8, MakeTexelAvailableKHR = MakeTexelAvailable,
MakeTexelVisible = 9, MakeTexelVisible = 9,
MakeTexelVisibleKHR = 9, MakeTexelVisibleKHR = MakeTexelVisible,
NonPrivateTexel = 10, NonPrivateTexel = 10,
NonPrivateTexelKHR = 10, NonPrivateTexelKHR = NonPrivateTexel,
VolatileTexel = 11, VolatileTexel = 11,
VolatileTexelKHR = 11, VolatileTexelKHR = VolatileTexel,
SignExtend = 12, SignExtend = 12,
ZeroExtend = 13, ZeroExtend = 13,
} }
@@ -353,13 +353,13 @@ namespace Spv
Sample = 0x00000040, Sample = 0x00000040,
MinLod = 0x00000080, MinLod = 0x00000080,
MakeTexelAvailable = 0x00000100, MakeTexelAvailable = 0x00000100,
MakeTexelAvailableKHR = 0x00000100, MakeTexelAvailableKHR = MakeTexelAvailable,
MakeTexelVisible = 0x00000200, MakeTexelVisible = 0x00000200,
MakeTexelVisibleKHR = 0x00000200, MakeTexelVisibleKHR = MakeTexelVisible,
NonPrivateTexel = 0x00000400, NonPrivateTexel = 0x00000400,
NonPrivateTexelKHR = 0x00000400, NonPrivateTexelKHR = NonPrivateTexel,
VolatileTexel = 0x00000800, VolatileTexel = 0x00000800,
VolatileTexelKHR = 0x00000800, VolatileTexelKHR = VolatileTexel,
SignExtend = 0x00001000, SignExtend = 0x00001000,
ZeroExtend = 0x00002000, ZeroExtend = 0x00002000,
Offsets = 0x00010000, Offsets = 0x00010000,
@@ -478,16 +478,16 @@ namespace Spv
PerTaskNV = 5273, PerTaskNV = 5273,
PerVertexNV = 5285, PerVertexNV = 5285,
NonUniform = 5300, NonUniform = 5300,
NonUniformEXT = 5300, NonUniformEXT = NonUniform,
RestrictPointer = 5355, RestrictPointer = 5355,
RestrictPointerEXT = 5355, RestrictPointerEXT = RestrictPointer,
AliasedPointer = 5356, AliasedPointer = 5356,
AliasedPointerEXT = 5356, AliasedPointerEXT = AliasedPointer,
ReferencedIndirectlyINTEL = 5602, ReferencedIndirectlyINTEL = 5602,
CounterBuffer = 5634, CounterBuffer = 5634,
HlslCounterBufferGOOGLE = 5634, HlslCounterBufferGOOGLE = CounterBuffer,
HlslSemanticGOOGLE = 5635, HlslSemanticGOOGLE = 5635,
UserSemantic = 5635, UserSemantic = HlslSemanticGOOGLE,
UserTypeGOOGLE = 5636, UserTypeGOOGLE = 5636,
RegisterINTEL = 5825, RegisterINTEL = 5825,
MemoryINTEL = 5826, MemoryINTEL = 5826,
@@ -547,15 +547,15 @@ namespace Spv
VertexIndex = 42, VertexIndex = 42,
InstanceIndex = 43, InstanceIndex = 43,
SubgroupEqMask = 4416, SubgroupEqMask = 4416,
SubgroupEqMaskKHR = 4416, SubgroupEqMaskKHR = SubgroupEqMask,
SubgroupGeMask = 4417, SubgroupGeMask = 4417,
SubgroupGeMaskKHR = 4417, SubgroupGeMaskKHR = SubgroupGeMask,
SubgroupGtMask = 4418, SubgroupGtMask = 4418,
SubgroupGtMaskKHR = 4418, SubgroupGtMaskKHR = SubgroupGtMask,
SubgroupLeMask = 4419, SubgroupLeMask = 4419,
SubgroupLeMaskKHR = 4419, SubgroupLeMaskKHR = SubgroupLeMask,
SubgroupLtMask = 4420, SubgroupLtMask = 4420,
SubgroupLtMaskKHR = 4420, SubgroupLtMaskKHR = SubgroupLtMask,
BaseVertex = 4424, BaseVertex = 4424,
BaseInstance = 4425, BaseInstance = 4425,
DrawIndex = 4426, DrawIndex = 4426,
@@ -588,36 +588,36 @@ namespace Spv
BaryCoordNV = 5286, BaryCoordNV = 5286,
BaryCoordNoPerspNV = 5287, BaryCoordNoPerspNV = 5287,
FragSizeEXT = 5292, FragSizeEXT = 5292,
FragmentSizeNV = 5292, FragmentSizeNV = FragSizeEXT,
FragInvocationCountEXT = 5293, FragInvocationCountEXT = 5293,
InvocationsPerPixelNV = 5293, InvocationsPerPixelNV = FragInvocationCountEXT,
LaunchIdKHR = 5319, LaunchIdKHR = 5319,
LaunchIdNV = 5319, LaunchIdNV = LaunchIdKHR,
LaunchSizeKHR = 5320, LaunchSizeKHR = 5320,
LaunchSizeNV = 5320, LaunchSizeNV = LaunchSizeKHR,
WorldRayOriginKHR = 5321, WorldRayOriginKHR = 5321,
WorldRayOriginNV = 5321, WorldRayOriginNV = WorldRayOriginKHR,
WorldRayDirectionKHR = 5322, WorldRayDirectionKHR = 5322,
WorldRayDirectionNV = 5322, WorldRayDirectionNV = WorldRayDirectionKHR,
ObjectRayOriginKHR = 5323, ObjectRayOriginKHR = 5323,
ObjectRayOriginNV = 5323, ObjectRayOriginNV = ObjectRayOriginKHR,
ObjectRayDirectionKHR = 5324, ObjectRayDirectionKHR = 5324,
ObjectRayDirectionNV = 5324, ObjectRayDirectionNV = ObjectRayDirectionKHR,
RayTminKHR = 5325, RayTminKHR = 5325,
RayTminNV = 5325, RayTminNV = RayTminKHR,
RayTmaxKHR = 5326, RayTmaxKHR = 5326,
RayTmaxNV = 5326, RayTmaxNV = RayTmaxKHR,
InstanceCustomIndexKHR = 5327, InstanceCustomIndexKHR = 5327,
InstanceCustomIndexNV = 5327, InstanceCustomIndexNV = InstanceCustomIndexKHR,
ObjectToWorldKHR = 5330, ObjectToWorldKHR = 5330,
ObjectToWorldNV = 5330, ObjectToWorldNV = ObjectToWorldKHR,
WorldToObjectKHR = 5331, WorldToObjectKHR = 5331,
WorldToObjectNV = 5331, WorldToObjectNV = WorldToObjectKHR,
HitTNV = 5332, HitTNV = 5332,
HitKindKHR = 5333, HitKindKHR = 5333,
HitKindNV = 5333, HitKindNV = HitKindKHR,
IncomingRayFlagsKHR = 5351, IncomingRayFlagsKHR = 5351,
IncomingRayFlagsNV = 5351, IncomingRayFlagsNV = IncomingRayFlagsKHR,
RayGeometryIndexKHR = 5352, RayGeometryIndexKHR = 5352,
WarpsPerSMNV = 5374, WarpsPerSMNV = 5374,
SMCountNV = 5375, SMCountNV = 5375,
@@ -709,11 +709,11 @@ namespace Spv
AtomicCounterMemory = 10, AtomicCounterMemory = 10,
ImageMemory = 11, ImageMemory = 11,
OutputMemory = 12, OutputMemory = 12,
OutputMemoryKHR = 12, OutputMemoryKHR = OutputMemory,
MakeAvailable = 13, MakeAvailable = 13,
MakeAvailableKHR = 13, MakeAvailableKHR = MakeAvailable,
MakeVisible = 14, MakeVisible = 14,
MakeVisibleKHR = 14, MakeVisibleKHR = MakeVisible,
Volatile = 15, Volatile = 15,
} }
@@ -731,11 +731,11 @@ namespace Spv
AtomicCounterMemory = 0x00000400, AtomicCounterMemory = 0x00000400,
ImageMemory = 0x00000800, ImageMemory = 0x00000800,
OutputMemory = 0x00001000, OutputMemory = 0x00001000,
OutputMemoryKHR = 0x00001000, OutputMemoryKHR = OutputMemory,
MakeAvailable = 0x00002000, MakeAvailable = 0x00002000,
MakeAvailableKHR = 0x00002000, MakeAvailableKHR = MakeAvailable,
MakeVisible = 0x00004000, MakeVisible = 0x00004000,
MakeVisibleKHR = 0x00004000, MakeVisibleKHR = MakeVisible,
Volatile = 0x00008000, Volatile = 0x00008000,
} }
@@ -745,11 +745,11 @@ namespace Spv
Aligned = 1, Aligned = 1,
Nontemporal = 2, Nontemporal = 2,
MakePointerAvailable = 3, MakePointerAvailable = 3,
MakePointerAvailableKHR = 3, MakePointerAvailableKHR = MakePointerAvailable,
MakePointerVisible = 4, MakePointerVisible = 4,
MakePointerVisibleKHR = 4, MakePointerVisibleKHR = MakePointerVisible,
NonPrivatePointer = 5, NonPrivatePointer = 5,
NonPrivatePointerKHR = 5, NonPrivatePointerKHR = NonPrivatePointer,
} }
public enum MemoryAccessMask public enum MemoryAccessMask
@@ -759,11 +759,11 @@ namespace Spv
Aligned = 0x00000002, Aligned = 0x00000002,
Nontemporal = 0x00000004, Nontemporal = 0x00000004,
MakePointerAvailable = 0x00000008, MakePointerAvailable = 0x00000008,
MakePointerAvailableKHR = 0x00000008, MakePointerAvailableKHR = MakePointerAvailable,
MakePointerVisible = 0x00000010, MakePointerVisible = 0x00000010,
MakePointerVisibleKHR = 0x00000010, MakePointerVisibleKHR = MakePointerVisible,
NonPrivatePointer = 0x00000020, NonPrivatePointer = 0x00000020,
NonPrivatePointerKHR = 0x00000020, NonPrivatePointerKHR = NonPrivatePointer,
} }
public enum Scope public enum Scope
@@ -774,7 +774,7 @@ namespace Spv
Subgroup = 3, Subgroup = 3,
Invocation = 4, Invocation = 4,
QueueFamily = 5, QueueFamily = 5,
QueueFamilyKHR = 5, QueueFamilyKHR = QueueFamily,
ShaderCallKHR = 6, ShaderCallKHR = 6,
} }
@@ -883,9 +883,9 @@ namespace Spv
DrawParameters = 4427, DrawParameters = 4427,
SubgroupVoteKHR = 4431, SubgroupVoteKHR = 4431,
StorageBuffer16BitAccess = 4433, StorageBuffer16BitAccess = 4433,
StorageUniformBufferBlock16 = 4433, StorageUniformBufferBlock16 = StorageBuffer16BitAccess,
StorageUniform16 = 4434, StorageUniform16 = 4434,
UniformAndStorageBuffer16BitAccess = 4434, UniformAndStorageBuffer16BitAccess = StorageUniform16,
StoragePushConstant16 = 4435, StoragePushConstant16 = 4435,
StorageInputOutput16 = 4436, StorageInputOutput16 = 4436,
DeviceGroup = 4437, DeviceGroup = 4437,
@@ -916,7 +916,7 @@ namespace Spv
SampleMaskOverrideCoverageNV = 5249, SampleMaskOverrideCoverageNV = 5249,
GeometryShaderPassthroughNV = 5251, GeometryShaderPassthroughNV = 5251,
ShaderViewportIndexLayerEXT = 5254, ShaderViewportIndexLayerEXT = 5254,
ShaderViewportIndexLayerNV = 5254, ShaderViewportIndexLayerNV = ShaderViewportIndexLayerEXT,
ShaderViewportMaskNV = 5255, ShaderViewportMaskNV = 5255,
ShaderStereoViewNV = 5259, ShaderStereoViewNV = 5259,
PerViewAttributesNV = 5260, PerViewAttributesNV = 5260,
@@ -926,39 +926,39 @@ namespace Spv
FragmentBarycentricNV = 5284, FragmentBarycentricNV = 5284,
ComputeDerivativeGroupQuadsNV = 5288, ComputeDerivativeGroupQuadsNV = 5288,
FragmentDensityEXT = 5291, FragmentDensityEXT = 5291,
ShadingRateNV = 5291, ShadingRateNV = FragmentDensityEXT,
GroupNonUniformPartitionedNV = 5297, GroupNonUniformPartitionedNV = 5297,
ShaderNonUniform = 5301, ShaderNonUniform = 5301,
ShaderNonUniformEXT = 5301, ShaderNonUniformEXT = ShaderNonUniform,
RuntimeDescriptorArray = 5302, RuntimeDescriptorArray = 5302,
RuntimeDescriptorArrayEXT = 5302, RuntimeDescriptorArrayEXT = RuntimeDescriptorArray,
InputAttachmentArrayDynamicIndexing = 5303, InputAttachmentArrayDynamicIndexing = 5303,
InputAttachmentArrayDynamicIndexingEXT = 5303, InputAttachmentArrayDynamicIndexingEXT = InputAttachmentArrayDynamicIndexing,
UniformTexelBufferArrayDynamicIndexing = 5304, UniformTexelBufferArrayDynamicIndexing = 5304,
UniformTexelBufferArrayDynamicIndexingEXT = 5304, UniformTexelBufferArrayDynamicIndexingEXT = UniformTexelBufferArrayDynamicIndexing,
StorageTexelBufferArrayDynamicIndexing = 5305, StorageTexelBufferArrayDynamicIndexing = 5305,
StorageTexelBufferArrayDynamicIndexingEXT = 5305, StorageTexelBufferArrayDynamicIndexingEXT = StorageTexelBufferArrayDynamicIndexing,
UniformBufferArrayNonUniformIndexing = 5306, UniformBufferArrayNonUniformIndexing = 5306,
UniformBufferArrayNonUniformIndexingEXT = 5306, UniformBufferArrayNonUniformIndexingEXT = UniformBufferArrayNonUniformIndexing,
SampledImageArrayNonUniformIndexing = 5307, SampledImageArrayNonUniformIndexing = 5307,
SampledImageArrayNonUniformIndexingEXT = 5307, SampledImageArrayNonUniformIndexingEXT = SampledImageArrayNonUniformIndexing,
StorageBufferArrayNonUniformIndexing = 5308, StorageBufferArrayNonUniformIndexing = 5308,
StorageBufferArrayNonUniformIndexingEXT = 5308, StorageBufferArrayNonUniformIndexingEXT = StorageBufferArrayNonUniformIndexing,
StorageImageArrayNonUniformIndexing = 5309, StorageImageArrayNonUniformIndexing = 5309,
StorageImageArrayNonUniformIndexingEXT = 5309, StorageImageArrayNonUniformIndexingEXT = StorageImageArrayNonUniformIndexing,
InputAttachmentArrayNonUniformIndexing = 5310, InputAttachmentArrayNonUniformIndexing = 5310,
InputAttachmentArrayNonUniformIndexingEXT = 5310, InputAttachmentArrayNonUniformIndexingEXT = InputAttachmentArrayNonUniformIndexing,
UniformTexelBufferArrayNonUniformIndexing = 5311, UniformTexelBufferArrayNonUniformIndexing = 5311,
UniformTexelBufferArrayNonUniformIndexingEXT = 5311, UniformTexelBufferArrayNonUniformIndexingEXT = UniformTexelBufferArrayNonUniformIndexing,
StorageTexelBufferArrayNonUniformIndexing = 5312, StorageTexelBufferArrayNonUniformIndexing = 5312,
StorageTexelBufferArrayNonUniformIndexingEXT = 5312, StorageTexelBufferArrayNonUniformIndexingEXT = StorageTexelBufferArrayNonUniformIndexing,
RayTracingNV = 5340, RayTracingNV = 5340,
VulkanMemoryModel = 5345, VulkanMemoryModel = 5345,
VulkanMemoryModelKHR = 5345, VulkanMemoryModelKHR = VulkanMemoryModel,
VulkanMemoryModelDeviceScope = 5346, VulkanMemoryModelDeviceScope = 5346,
VulkanMemoryModelDeviceScopeKHR = 5346, VulkanMemoryModelDeviceScopeKHR = VulkanMemoryModelDeviceScope,
PhysicalStorageBufferAddresses = 5347, PhysicalStorageBufferAddresses = 5347,
PhysicalStorageBufferAddressesEXT = 5347, PhysicalStorageBufferAddressesEXT = PhysicalStorageBufferAddresses,
ComputeDerivativeGroupLinearNV = 5350, ComputeDerivativeGroupLinearNV = 5350,
RayTracingProvisionalKHR = 5353, RayTracingProvisionalKHR = 5353,
CooperativeMatrixNV = 5357, CooperativeMatrixNV = 5357,
@@ -1433,12 +1433,12 @@ namespace Spv
OpGroupNonUniformPartitionNV = 5296, OpGroupNonUniformPartitionNV = 5296,
OpWritePackedPrimitiveIndices4x8NV = 5299, OpWritePackedPrimitiveIndices4x8NV = 5299,
OpReportIntersectionKHR = 5334, OpReportIntersectionKHR = 5334,
OpReportIntersectionNV = 5334, OpReportIntersectionNV = OpReportIntersectionKHR,
OpIgnoreIntersectionNV = 5335, OpIgnoreIntersectionNV = 5335,
OpTerminateRayNV = 5336, OpTerminateRayNV = 5336,
OpTraceNV = 5337, OpTraceNV = 5337,
OpTypeAccelerationStructureKHR = 5341, OpTypeAccelerationStructureKHR = 5341,
OpTypeAccelerationStructureNV = 5341, OpTypeAccelerationStructureNV = OpTypeAccelerationStructureKHR,
OpExecuteCallableNV = 5344, OpExecuteCallableNV = 5344,
OpTypeCooperativeMatrixNV = 5358, OpTypeCooperativeMatrixNV = 5358,
OpCooperativeMatrixLoadNV = 5359, OpCooperativeMatrixLoadNV = 5359,
@@ -1476,9 +1476,9 @@ namespace Spv
OpFunctionPointerINTEL = 5600, OpFunctionPointerINTEL = 5600,
OpFunctionPointerCallINTEL = 5601, OpFunctionPointerCallINTEL = 5601,
OpDecorateString = 5632, OpDecorateString = 5632,
OpDecorateStringGOOGLE = 5632, OpDecorateStringGOOGLE = OpDecorateString,
OpMemberDecorateString = 5633, OpMemberDecorateString = 5633,
OpMemberDecorateStringGOOGLE = 5633, OpMemberDecorateStringGOOGLE = OpMemberDecorateString,
OpVmeImageINTEL = 5699, OpVmeImageINTEL = 5699,
OpTypeVmeImageINTEL = 5700, OpTypeVmeImageINTEL = 5700,
OpTypeAvcImePayloadINTEL = 5701, OpTypeAvcImePayloadINTEL = 5701,
@@ -1622,4 +1622,3 @@ namespace Spv
} }
} }
} }