aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Shader/DiskCache
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-07-02 02:47:54 +0200
committerGitHub <noreply@github.com>2023-07-02 02:47:54 +0200
commit3b46bb73f781a011705ecbc8a1d3207dfb145829 (patch)
tree1d5d2714c7001775b512bc14ce91a1ebbfc808df /src/Ryujinx.Graphics.Gpu/Shader/DiskCache
parent2457cfc9118a6ebb6008945c919edfd8b46af5e7 (diff)
[Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address or silence dotnet format CA2211 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Another rebase, another dotnet format run * Run dotnet format style after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Remove a few unused parameters * Replace MmeShadowScratch with Array256<uint> * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Run dotnet format after rebase * Address IDE0251 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First pass of dotnet format * Add unsafe dotnet format changes * Fix typos * Add trailing commas * Disable formatting for FormatTable * Address review feedback
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Shader/DiskCache')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs20
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs8
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs22
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs84
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs39
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs9
12 files changed, 100 insertions, 100 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
index 568fe968..e0f17ba9 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary>
/// Operation to add a shader to the cache.
/// </summary>
- AddShader
+ AddShader,
}
/// <summary>
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
index 50e37033..b08c44d6 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
@@ -29,12 +29,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary>
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param>
- public void Read<T>(ref T data) where T : unmanaged
+ public readonly void Read<T>(ref T data) where T : unmanaged
{
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1));
for (int offset = 0; offset < buffer.Length;)
{
- offset += _activeStream.Read(buffer.Slice(offset));
+ offset += _activeStream.Read(buffer[offset..]);
}
}
@@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param>
/// <returns>True if the read was successful, false otherwise</returns>
- public bool TryRead<T>(ref T data) where T : unmanaged
+ public readonly bool TryRead<T>(ref T data) where T : unmanaged
{
// Length is unknown on compressed streams.
if (_activeStream == _stream)
@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param>
/// <param name="magic">Expected magic value, for validation</param>
- public void ReadWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
+ public readonly void ReadWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
{
uint actualMagic = 0;
int size = 0;
@@ -84,10 +84,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedInvalidLength);
}
- Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1)).Slice(0, size);
+ Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1))[..size];
for (int offset = 0; offset < buffer.Length;)
{
- offset += _activeStream.Read(buffer.Slice(offset));
+ offset += _activeStream.Read(buffer[offset..]);
}
}
@@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary>
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data to be written</param>
- public void Write<T>(ref T data) where T : unmanaged
+ public readonly void Write<T>(ref T data) where T : unmanaged
{
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1));
_activeStream.Write(buffer);
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data to write</param>
/// <param name="magic">Magic value to write</param>
- public void WriteWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
+ public readonly void WriteWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
{
int size = Unsafe.SizeOf<T>();
Write(ref magic);
@@ -183,7 +183,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
stream = new DeflateStream(stream, CompressionMode.Decompress, true);
for (int offset = 0; offset < data.Length;)
{
- offset += stream.Read(data.Slice(offset));
+ offset += stream.Read(data[offset..]);
}
stream.Dispose();
break;
@@ -213,4 +213,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
index a46e1ef7..96ddbb51 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
@@ -13,6 +13,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary>
/// Deflate compression (RFC 1951).
/// </summary>
- Deflate
+ Deflate,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
index c8a9f7ff..c4ce0b87 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
@@ -54,4 +54,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return CompressionAlgorithm.Deflate;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
index 537cead0..7f01aca6 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
@@ -19,7 +19,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private readonly ShaderSpecializationState _newSpecState;
private readonly int _stageIndex;
private readonly bool _isVulkan;
- private readonly ResourceCounts _resourceCounts;
/// <summary>
/// Creates a new instance of the cached GPU state accessor for shader translation.
@@ -45,7 +44,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_newSpecState = newSpecState;
_stageIndex = stageIndex;
_isVulkan = context.Capabilities.Api == TargetApi.Vulkan;
- _resourceCounts = counts;
}
/// <inheritdoc/>
@@ -56,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.InvalidCb1DataLength);
}
- return MemoryMarshal.Cast<byte, uint>(_cb1Data.Span.Slice(offset))[0];
+ return MemoryMarshal.Cast<byte, uint>(_cb1Data.Span[offset..])[0];
}
/// <inheritdoc/>
@@ -68,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <inheritdoc/>
public ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize)
{
- return MemoryMarshal.Cast<byte, ulong>(_data.Span.Slice((int)address));
+ return MemoryMarshal.Cast<byte, ulong>(_data.Span[(int)address..]);
}
/// <inheritdoc/>
@@ -94,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
CompareOp.Greater or CompareOp.GreaterGl => AlphaTestOp.Greater,
CompareOp.NotEqual or CompareOp.NotEqualGl => AlphaTestOp.NotEqual,
CompareOp.GreaterOrEqual or CompareOp.GreaterOrEqualGl => AlphaTestOp.GreaterOrEqual,
- _ => AlphaTestOp.Always
+ _ => AlphaTestOp.Always,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
index 01034b49..59d2cfb3 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
@@ -205,10 +205,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (guestCode == null || cb1Data == null)
{
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
tocFileStream.Seek(Unsafe.SizeOf<TocHeader>() + index * Unsafe.SizeOf<TocEntry>(), SeekOrigin.Begin);
- TocEntry entry = new TocEntry();
+ TocEntry entry = new();
tocReader.Read(ref entry);
guestCode = new byte[entry.CodeSize];
@@ -261,7 +261,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true);
using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
LoadOrCreateToc(tocFileStream, ref header);
@@ -299,7 +299,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="header">Set to the TOC file header</param>
private void LoadOrCreateToc(Stream tocFileStream, ref TocHeader header)
{
- BinarySerializer reader = new BinarySerializer(tocFileStream);
+ BinarySerializer reader = new(tocFileStream);
if (!reader.TryRead(ref header) || header.Magic != TocMagic || header.Version != VersionPacked)
{
@@ -322,9 +322,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary>
/// <param name="tocFileStream">Guest TOC file stream</param>
/// <param name="header">Set to the TOC header</param>
- private void CreateToc(Stream tocFileStream, ref TocHeader header)
+ private static void CreateToc(Stream tocFileStream, ref TocHeader header)
{
- BinarySerializer writer = new BinarySerializer(tocFileStream);
+ BinarySerializer writer = new(tocFileStream);
header.Magic = TocMagic;
header.Version = VersionPacked;
@@ -352,7 +352,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
_toc = new Dictionary<uint, List<TocMemoryEntry>>();
- TocEntry entry = new TocEntry();
+ TocEntry entry = new();
int index = 0;
while (tocFileStream.Position < tocFileStream.Length)
@@ -386,7 +386,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
ReadOnlySpan<byte> cb1Data,
uint hash)
{
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
dataFileStream.Seek(0, SeekOrigin.End);
uint dataOffset = checked((uint)dataFileStream.Position);
@@ -399,12 +399,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream.Seek(0, SeekOrigin.Begin);
tocWriter.Write(ref header);
- TocEntry entry = new TocEntry()
+ TocEntry entry = new()
{
Offset = dataOffset,
CodeSize = codeSize,
Cb1DataSize = cb1DataSize,
- Hash = hash
+ Hash = hash,
};
tocFileStream.Seek(0, SeekOrigin.End);
@@ -456,4 +456,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return (uint)XXHash128.ComputeHash(data).Low;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
index 26711286..95a0a6bd 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
@@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
int indexOfSpace = fileName.IndexOf(' ');
if (indexOfSpace >= 0)
{
- fileName = fileName.Substring(0, indexOfSpace);
+ fileName = fileName[..indexOfSpace];
}
return string.Concat(fileName.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
@@ -287,10 +287,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
using var guestTocFileStream = _guestStorage.OpenTocFileStream();
using var guestDataFileStream = _guestStorage.OpenDataFileStream();
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
- BinarySerializer dataReader = new BinarySerializer(dataFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
+ BinarySerializer dataReader = new(dataFileStream);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
if (!tocReader.TryRead(ref header) || header.Magic != TocsMagic)
{
@@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
int programIndex = 0;
- DataEntry entry = new DataEntry();
+ DataEntry entry = new();
while (tocFileStream.Position < tocFileStream.Length && loader.Active)
{
@@ -337,7 +337,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
GuestCodeAndCbData?[] guestShaders = new GuestCodeAndCbData?[isCompute ? 1 : Constants.ShaderStages + 1];
- DataEntryPerStage stageEntry = new DataEntryPerStage();
+ DataEntryPerStage stageEntry = new();
while (stagesBitMask != 0)
{
@@ -389,7 +389,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
hostProgram = context.Renderer.LoadProgramBinary(hostCode, hasFragmentShader, shaderInfo);
}
- CachedShaderProgram program = new CachedShaderProgram(hostProgram, specState, shaders);
+ CachedShaderProgram program = new(hostProgram, specState, shaders);
loader.QueueHostProgram(program, hostCode, programIndex, isCompute);
}
@@ -448,9 +448,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: false);
dataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: false);
- BinarySerializer tempTocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tempTocReader = new(tocFileStream);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
tempTocReader.Read(ref header);
@@ -473,9 +473,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream.Seek(offset, SeekOrigin.Begin);
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
- OffsetAndSize offsetAndSize = new OffsetAndSize();
+ OffsetAndSize offsetAndSize = new();
tocReader.Read(ref offsetAndSize);
if (offsetAndSize.Offset >= (ulong)dataFileStream.Length)
@@ -490,7 +490,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
BinarySerializer.ReadCompressed(dataFileStream, hostCode);
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
- BinarySerializer dataReader = new BinarySerializer(dataFileStream);
+ BinarySerializer dataReader = new(dataFileStream);
dataFileStream.Seek((long)(offsetAndSize.Offset + offsetAndSize.CompressedSize), SeekOrigin.Begin);
@@ -559,27 +559,28 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (tocFileStream.Length == 0)
{
- TocHeader header = new TocHeader();
+ TocHeader header = new();
CreateToc(tocFileStream, ref header, TocsMagic, CodeGenVersion, timestamp);
}
tocFileStream.Seek(0, SeekOrigin.End);
dataFileStream.Seek(0, SeekOrigin.End);
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
- BinarySerializer dataWriter = new BinarySerializer(dataFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
+ BinarySerializer dataWriter = new(dataFileStream);
ulong dataOffset = (ulong)dataFileStream.Position;
tocWriter.Write(ref dataOffset);
- DataEntry entry = new DataEntry();
-
- entry.StagesBitMask = stagesBitMask;
+ DataEntry entry = new()
+ {
+ StagesBitMask = stagesBitMask,
+ };
dataWriter.BeginCompression(DiskCacheCommon.GetCompressionAlgorithm());
dataWriter.Write(ref entry);
- DataEntryPerStage stageEntry = new DataEntryPerStage();
+ DataEntryPerStage stageEntry = new();
for (int index = 0; index < program.Shaders.Length; index++)
{
@@ -665,19 +666,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (tocFileStream.Length == 0)
{
- TocHeader header = new TocHeader();
+ TocHeader header = new();
CreateToc(tocFileStream, ref header, TochMagic, 0, timestamp);
}
tocFileStream.Seek(0, SeekOrigin.End);
dataFileStream.Seek(0, SeekOrigin.End);
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
- BinarySerializer dataWriter = new BinarySerializer(dataFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
+ BinarySerializer dataWriter = new(dataFileStream);
- OffsetAndSize offsetAndSize = new OffsetAndSize();
- offsetAndSize.Offset = (ulong)dataFileStream.Position;
- offsetAndSize.UncompressedSize = (uint)hostCode.Length;
+ OffsetAndSize offsetAndSize = new()
+ {
+ Offset = (ulong)dataFileStream.Position,
+ UncompressedSize = (uint)hostCode.Length,
+ };
long dataStartPosition = dataFileStream.Position;
@@ -714,9 +717,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="magic">Magic value to be written</param>
/// <param name="codegenVersion">Shader codegen version, only valid for the host file</param>
/// <param name="timestamp">File creation timestamp</param>
- private void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
+ private static void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
{
- BinarySerializer writer = new BinarySerializer(tocFileStream);
+ BinarySerializer writer = new(tocFileStream);
header.Magic = magic;
header.FormatVersion = FileFormatVersionPacked;
@@ -741,7 +744,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <returns>Shader program info</returns>
private static ShaderProgramInfo ReadShaderProgramInfo(ref BinarySerializer dataReader)
{
- DataShaderInfo dataInfo = new DataShaderInfo();
+ DataShaderInfo dataInfo = new();
dataReader.ReadWithMagicAndSize(ref dataInfo, ShdiMagic);
@@ -797,18 +800,19 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return;
}
- DataShaderInfo dataInfo = new DataShaderInfo();
-
- dataInfo.CBuffersCount = (ushort)info.CBuffers.Count;
- dataInfo.SBuffersCount = (ushort)info.SBuffers.Count;
- dataInfo.TexturesCount = (ushort)info.Textures.Count;
- dataInfo.ImagesCount = (ushort)info.Images.Count;
- dataInfo.Stage = info.Stage;
- dataInfo.UsesInstanceId = info.UsesInstanceId;
- dataInfo.UsesDrawParameters = info.UsesDrawParameters;
- dataInfo.UsesRtLayer = info.UsesRtLayer;
- dataInfo.ClipDistancesWritten = info.ClipDistancesWritten;
- dataInfo.FragmentOutputMap = info.FragmentOutputMap;
+ DataShaderInfo dataInfo = new()
+ {
+ CBuffersCount = (ushort)info.CBuffers.Count,
+ SBuffersCount = (ushort)info.SBuffers.Count,
+ TexturesCount = (ushort)info.Textures.Count,
+ ImagesCount = (ushort)info.Images.Count,
+ Stage = info.Stage,
+ UsesInstanceId = info.UsesInstanceId,
+ UsesDrawParameters = info.UsesDrawParameters,
+ UsesRtLayer = info.UsesRtLayer,
+ ClipDistancesWritten = info.ClipDistancesWritten,
+ FragmentOutputMap = info.FragmentOutputMap,
+ };
dataWriter.WriteWithMagicAndSize(ref dataInfo, ShdiMagic);
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
index d6e23302..9320638c 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
@@ -45,4 +45,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
Result = result;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
index b3ffa4a7..ba23f70e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary>
/// File might be valid, but is incompatible with the current emulator version.
/// </summary>
- IncompatibleVersion
+ IncompatibleVersion,
}
static class DiskCacheLoadResultExtensions
@@ -65,8 +65,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
DiskCacheLoadResult.FileCorruptedInvalidMagic => "Magic check failed, the cache file is corrupted.",
DiskCacheLoadResult.FileCorruptedInvalidLength => "Length check failed, the cache file is corrupted.",
DiskCacheLoadResult.IncompatibleVersion => "The version of the disk cache is not compatible with this version of the emulator.",
- _ => "Unknown error."
+ _ => "Unknown error.",
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
index 959d6e18..f412c62e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
@@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
Cb1Data = cb1Data;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
index 8df89824..8c2108bf 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
@@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private readonly BlockingCollection<AsyncProgramTranslation> _asyncTranslationQueue;
private readonly SortedList<int, (CachedShaderProgram, byte[])> _programList;
- private int _backendParallelCompileThreads;
+ private readonly int _backendParallelCompileThreads;
private int _compiledCount;
private int _totalCount;
@@ -201,22 +201,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="graphicsCache">Graphics shader cache</param>
/// <param name="computeCache">Compute shader cache</param>
/// <param name="hostStorage">Disk cache host storage</param>
- /// <param name="cancellationToken">Cancellation token</param>
/// <param name="stateChangeCallback">Function to be called when there is a state change, reporting state, compiled and total shaders count</param>
- public ParallelDiskCacheLoader(
- GpuContext context,
+ /// <param name="cancellationToken">Cancellation token</param>
+ public ParallelDiskCacheLoader(GpuContext context,
ShaderCacheHashTable graphicsCache,
ComputeShaderCacheHashTable computeCache,
DiskCacheHostStorage hostStorage,
- CancellationToken cancellationToken,
- Action<ShaderCacheState, int, int> stateChangeCallback)
+ Action<ShaderCacheState, int, int> stateChangeCallback,
+ CancellationToken cancellationToken)
{
_context = context;
_graphicsCache = graphicsCache;
_computeCache = computeCache;
_hostStorage = hostStorage;
- _cancellationToken = cancellationToken;
_stateChangeCallback = stateChangeCallback;
+ _cancellationToken = cancellationToken;
_validationQueue = new Queue<ProgramEntry>();
_compilationQueue = new ConcurrentQueue<ProgramCompilation>();
_asyncTranslationQueue = new BlockingCollection<AsyncProgramTranslation>(ThreadCount);
@@ -235,7 +234,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
workThreads[index] = new Thread(ProcessAsyncQueue)
{
- Name = $"GPU.AsyncTranslationThread.{index}"
+ Name = $"GPU.AsyncTranslationThread.{index}",
};
}
@@ -367,7 +366,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
try
{
- AsyncProgramTranslation asyncTranslation = new AsyncProgramTranslation(guestShaders, specState, programIndex, isCompute);
+ AsyncProgramTranslation asyncTranslation = new(guestShaders, specState, programIndex, isCompute);
_asyncTranslationQueue.Add(asyncTranslation, _cancellationToken);
}
catch (OperationCanceledException)
@@ -491,7 +490,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
ShaderSource[] shaderSources = new ShaderSource[compilation.TranslatedStages.Length];
- ShaderInfoBuilder shaderInfoBuilder = new ShaderInfoBuilder(_context, compilation.SpecializationState.TransformFeedbackDescriptors != null);
+ ShaderInfoBuilder shaderInfoBuilder = new(_context, compilation.SpecializationState.TransformFeedbackDescriptors != null);
for (int index = 0; index < compilation.TranslatedStages.Length; index++)
{
@@ -502,7 +501,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
ShaderInfo shaderInfo = shaderInfoBuilder.Build(compilation.SpecializationState.PipelineState, fromCache: true);
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources, shaderInfo);
- CachedShaderProgram program = new CachedShaderProgram(hostProgram, compilation.SpecializationState, compilation.Shaders);
+ CachedShaderProgram program = new(hostProgram, compilation.SpecializationState, compilation.Shaders);
// Vulkan's binary code is the SPIR-V used for compilation, so it is ready immediately. Other APIs get this after compilation.
byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(shaderSources) : null;
@@ -589,12 +588,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="programIndex">Program index</param>
private void RecompileGraphicsFromGuestCode(GuestCodeAndCbData?[] guestShaders, ShaderSpecializationState specState, int programIndex)
{
- ShaderSpecializationState newSpecState = new ShaderSpecializationState(
+ ShaderSpecializationState newSpecState = new(
ref specState.GraphicsState,
specState.PipelineState,
specState.TransformFeedbackDescriptors);
- ResourceCounts counts = new ResourceCounts();
+ ResourceCounts counts = new();
TranslatorContext[] translatorContexts = new TranslatorContext[Constants.ShaderStages + 1];
TranslatorContext nextStage = null;
@@ -610,7 +609,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
byte[] guestCode = shader.Code;
byte[] cb1Data = shader.Cb1Data;
- DiskCacheGpuAccessor gpuAccessor = new DiskCacheGpuAccessor(_context, guestCode, cb1Data, specState, newSpecState, counts, stageIndex);
+ DiskCacheGpuAccessor gpuAccessor = new(_context, guestCode, cb1Data, specState, newSpecState, counts, stageIndex);
TranslatorContext currentStage = DecodeGraphicsShader(gpuAccessor, api, DefaultFlags, 0);
if (nextStage != null)
@@ -623,7 +622,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
byte[] guestCodeA = guestShaders[0].Value.Code;
byte[] cb1DataA = guestShaders[0].Value.Cb1Data;
- DiskCacheGpuAccessor gpuAccessorA = new DiskCacheGpuAccessor(_context, guestCodeA, cb1DataA, specState, newSpecState, counts, 0);
+ DiskCacheGpuAccessor gpuAccessorA = new(_context, guestCodeA, cb1DataA, specState, newSpecState, counts, 0);
translatorContexts[0] = DecodeGraphicsShader(gpuAccessorA, api, DefaultFlags | TranslationFlags.VertexA, 0);
}
@@ -638,7 +637,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
}
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
- List<ShaderProgram> translatedStages = new List<ShaderProgram>();
+ List<ShaderProgram> translatedStages = new();
TranslatorContext previousStage = null;
@@ -699,9 +698,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private void RecompileComputeFromGuestCode(GuestCodeAndCbData?[] guestShaders, ShaderSpecializationState specState, int programIndex)
{
GuestCodeAndCbData shader = guestShaders[0].Value;
- ResourceCounts counts = new ResourceCounts();
- ShaderSpecializationState newSpecState = new ShaderSpecializationState(ref specState.ComputeState);
- DiskCacheGpuAccessor gpuAccessor = new DiskCacheGpuAccessor(_context, shader.Code, shader.Cb1Data, specState, newSpecState, counts, 0);
+ ResourceCounts counts = new();
+ ShaderSpecializationState newSpecState = new(ref specState.ComputeState);
+ DiskCacheGpuAccessor gpuAccessor = new(_context, shader.Code, shader.Cb1Data, specState, newSpecState, counts, 0);
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, 0);
@@ -721,4 +720,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_stateChangeCallback(ShaderCacheState.Loading, ++_compiledCount, _totalCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
index 2dc5c971..a18b5780 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
@@ -3,7 +3,6 @@ using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Shader.Translation;
-using System;
using System.Collections.Generic;
using System.IO;
@@ -29,10 +28,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
public static ShaderSource[] Unpack(CachedShaderStage[] stages, byte[] code)
{
- using MemoryStream input = new MemoryStream(code);
- using BinaryReader reader = new BinaryReader(input);
+ using MemoryStream input = new(code);
+ using BinaryReader reader = new(input);
- List<ShaderSource> output = new List<ShaderSource>();
+ List<ShaderSource> output = new();
int count = reader.ReadInt32();
@@ -48,4 +47,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return output.ToArray();
}
}
-} \ No newline at end of file
+}