mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-29 05:37:11 +02:00
[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
This commit is contained in:
parent
2457cfc911
commit
3b46bb73f7
145 changed files with 1445 additions and 1427 deletions
|
@ -35,4 +35,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
Cb1Data = cb1Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
out byte[] cachedGuestCode)
|
||||
{
|
||||
program = null;
|
||||
ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(channel.MemoryManager, gpuVa);
|
||||
ShaderCodeAccessor codeAccessor = new(channel.MemoryManager, gpuVa);
|
||||
bool hasSpecList = _cache.TryFindItem(codeAccessor, out var specList, out cachedGuestCode);
|
||||
|
||||
return hasSpecList && specList.TryFindForCompute(channel, poolState, computeState, out program);
|
||||
}
|
||||
|
||||
|
@ -67,4 +68,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
/// <summary>
|
||||
/// Operation to add a shader to the cache.
|
||||
/// </summary>
|
||||
AddShader
|
||||
AddShader,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
/// <summary>
|
||||
/// Deflate compression (RFC 1951).
|
||||
/// </summary>
|
||||
Deflate
|
||||
Deflate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,4 +54,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
return CompressionAlgorithm.Deflate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -45,4 +45,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
Result = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
Cb1Data = cb1Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ using Ryujinx.Graphics.Gpu.Engine.Threed;
|
|||
using Ryujinx.Graphics.Gpu.Image;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using Ryujinx.Graphics.Shader.Translation;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Gpu.Shader
|
||||
{
|
||||
|
@ -125,7 +124,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
3 => 2, // Geometry
|
||||
1 => 3, // Tessellation control
|
||||
2 => 4, // Tessellation evaluation
|
||||
_ => 0 // Vertex/Compute
|
||||
_ => 0, // Vertex/Compute
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -188,6 +187,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
return formatInfo.Format switch
|
||||
{
|
||||
#pragma warning disable IDE0055 // Disable formatting
|
||||
Format.R8Unorm => TextureFormat.R8Unorm,
|
||||
Format.R8Snorm => TextureFormat.R8Snorm,
|
||||
Format.R8Uint => TextureFormat.R8Uint,
|
||||
|
@ -228,7 +228,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
Format.R10G10B10A2Unorm => TextureFormat.R10G10B10A2Unorm,
|
||||
Format.R10G10B10A2Uint => TextureFormat.R10G10B10A2Uint,
|
||||
Format.R11G11B10Float => TextureFormat.R11G11B10Float,
|
||||
_ => TextureFormat.Unknown
|
||||
_ => TextureFormat.Unknown,
|
||||
#pragma warning restore IDE0055
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -256,7 +257,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
PrimitiveTopology.Patches => tessellationMode.UnpackPatchType() == TessPatchType.Isolines
|
||||
? InputTopology.Lines
|
||||
: InputTopology.Triangles,
|
||||
_ => InputTopology.Points
|
||||
_ => InputTopology.Points,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,4 +58,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
ResourceCounts = new ResourceCounts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,4 +62,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
HasUnalignedStorageBuffer = hasUnalignedStorageBuffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,4 +155,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
DualSourceBlendEnable = dualSourceBlendEnable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ using System;
|
|||
|
||||
namespace Ryujinx.Graphics.Gpu.Shader
|
||||
{
|
||||
#pragma warning disable CS0659 // Class overrides Object.Equals(object o) but does not override Object.GetHashCode()
|
||||
/// <summary>
|
||||
/// State used by the <see cref="GpuAccessor"/>.
|
||||
/// </summary>
|
||||
|
@ -46,5 +47,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
TexturePoolMaximumId == other.TexturePoolMaximumId &&
|
||||
TextureBufferIndex == other.TextureBufferIndex;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is GpuChannelPoolState state && Equals(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0659
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// <returns>Hash of the given data</returns>
|
||||
public static uint CalcHash(ReadOnlySpan<byte> data)
|
||||
{
|
||||
HashState state = new HashState();
|
||||
HashState state = new();
|
||||
|
||||
state.Initialize();
|
||||
state.Continue(data);
|
||||
|
@ -50,7 +50,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
{
|
||||
ulong h = _hash;
|
||||
|
||||
ReadOnlySpan<ulong> dataAsUlong = MemoryMarshal.Cast<byte, ulong>(data.Slice(_start));
|
||||
ReadOnlySpan<ulong> dataAsUlong = MemoryMarshal.Cast<byte, ulong>(data[_start..]);
|
||||
|
||||
for (int i = 0; i < dataAsUlong.Length; i++)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// </remarks>
|
||||
/// <param name="data">Data to be hashed</param>
|
||||
/// <returns>Hash of all the data hashed with this <see cref="HashState"/></returns>
|
||||
public uint Finalize(ReadOnlySpan<byte> data)
|
||||
public readonly uint Finalize(ReadOnlySpan<byte> data)
|
||||
{
|
||||
ulong h = _hash;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// Partial entries have no items associated with them. They just indicates that the data might be present on
|
||||
/// the table, and one must keep looking for the full entry on other tables of larger data size.
|
||||
/// </remarks>
|
||||
public bool IsPartial => OwnSize != 0;
|
||||
public readonly bool IsPartial => OwnSize != 0;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new partial hash table entry.
|
||||
|
@ -82,11 +82,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// Gets the data for this entry, either full or partial.
|
||||
/// </summary>
|
||||
/// <returns>Data sub-region</returns>
|
||||
public ReadOnlySpan<byte> GetData()
|
||||
public readonly ReadOnlySpan<byte> GetData()
|
||||
{
|
||||
if (OwnSize != 0)
|
||||
{
|
||||
return new ReadOnlySpan<byte>(Data).Slice(0, OwnSize);
|
||||
return new ReadOnlySpan<byte>(Data)[..OwnSize];
|
||||
}
|
||||
|
||||
return Data;
|
||||
|
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
return existingItem;
|
||||
}
|
||||
|
||||
Entry entry = new Entry(dataHash, data, item);
|
||||
Entry entry = new(dataHash, data, item);
|
||||
|
||||
AddToBucket(dataHash, ref entry);
|
||||
|
||||
|
@ -160,7 +160,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
return false;
|
||||
}
|
||||
|
||||
Entry entry = new Entry(dataHash, data, item);
|
||||
Entry entry = new(dataHash, data, item);
|
||||
|
||||
AddToBucket(dataHash, ref entry);
|
||||
|
||||
|
@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// <returns>True if added, false otherwise</returns>
|
||||
public bool AddPartial(byte[] ownerData, int ownSize)
|
||||
{
|
||||
ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData).Slice(0, ownSize);
|
||||
ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData)[..ownSize];
|
||||
|
||||
return AddPartial(ownerData, HashState.CalcHash(data), ownSize);
|
||||
}
|
||||
|
@ -189,14 +189,14 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// <returns>True if added, false otherwise</returns>
|
||||
public bool AddPartial(byte[] ownerData, uint dataHash, int ownSize)
|
||||
{
|
||||
ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData).Slice(0, ownSize);
|
||||
ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData)[..ownSize];
|
||||
|
||||
if (TryFindItem(dataHash, data, out _))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Entry entry = new Entry(dataHash, ownerData, ownSize);
|
||||
Entry entry = new(dataHash, ownerData, ownSize);
|
||||
|
||||
AddToBucket(dataHash, ref entry);
|
||||
|
||||
|
@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// </summary>
|
||||
/// <param name="bucket">Bucket to add the entry into</param>
|
||||
/// <param name="entry">Entry to be added</param>
|
||||
private void AddToBucket(ref Bucket bucket, ref Entry entry)
|
||||
private static void AddToBucket(ref Bucket bucket, ref Entry entry)
|
||||
{
|
||||
if (bucket.InlineEntry.Data == null)
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// <summary>
|
||||
/// A full entry was found, the search was concluded and the item can be retrieved.
|
||||
/// </summary>
|
||||
FoundFull
|
||||
FoundFull,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -149,12 +149,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
}
|
||||
}
|
||||
|
||||
HashState hashState = new HashState();
|
||||
HashState hashState = new();
|
||||
hashState.Initialize();
|
||||
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
ReadOnlySpan<byte> dataSlice = new ReadOnlySpan<byte>(data).Slice(0, _sizeTable[i].Size);
|
||||
ReadOnlySpan<byte> dataSlice = new ReadOnlySpan<byte>(data)[.._sizeTable[i].Size];
|
||||
hashState.Continue(dataSlice);
|
||||
_sizeTable[i].AddPartial(data, hashState.Finalize(dataSlice));
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// <returns>True if the item was found on the table, false otherwise</returns>
|
||||
public bool TryFindItem(IDataAccessor dataAccessor, out T item, out byte[] data)
|
||||
{
|
||||
SmartDataAccessor sda = new SmartDataAccessor(dataAccessor);
|
||||
SmartDataAccessor sda = new(dataAccessor);
|
||||
|
||||
item = default;
|
||||
data = null;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
}
|
||||
else if (_data.Length > length)
|
||||
{
|
||||
return _data.Slice(0, length);
|
||||
return _data[..length];
|
||||
}
|
||||
|
||||
return _data;
|
||||
|
@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// </summary>
|
||||
/// <param name="data">Data to be hashed</param>
|
||||
/// <returns>Hash of the data</returns>
|
||||
private uint CalcHashCached(ReadOnlySpan<byte> data)
|
||||
private readonly uint CalcHashCached(ReadOnlySpan<byte> data)
|
||||
{
|
||||
HashState state = default;
|
||||
bool found = false;
|
||||
|
|
|
@ -25,4 +25,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
public int ImagesCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
struct ShaderAddresses : IEquatable<ShaderAddresses>
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public ulong VertexA;
|
||||
public ulong VertexB;
|
||||
public ulong TessControl;
|
||||
|
@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
/// <param name="other">Shader addresses structure to compare with</param>
|
||||
/// <returns>True if they are equal, false otherwise</returns>
|
||||
public override bool Equals(object other)
|
||||
public readonly override bool Equals(object other)
|
||||
{
|
||||
return other is ShaderAddresses addresses && Equals(addresses);
|
||||
}
|
||||
|
@ -33,21 +33,21 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
/// <param name="other">Shader addresses structure to compare with</param>
|
||||
/// <returns>True if they are equal, false otherwise</returns>
|
||||
public bool Equals(ShaderAddresses other)
|
||||
public readonly bool Equals(ShaderAddresses other)
|
||||
{
|
||||
return VertexA == other.VertexA &&
|
||||
VertexB == other.VertexB &&
|
||||
TessControl == other.TessControl &&
|
||||
return VertexA == other.VertexA &&
|
||||
VertexB == other.VertexB &&
|
||||
TessControl == other.TessControl &&
|
||||
TessEvaluation == other.TessEvaluation &&
|
||||
Geometry == other.Geometry &&
|
||||
Fragment == other.Fragment;
|
||||
Geometry == other.Geometry &&
|
||||
Fragment == other.Fragment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes hash code from the addresses.
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
public readonly override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(VertexA, VertexB, TessControl, TessEvaluation, Geometry, Fragment);
|
||||
}
|
||||
|
@ -61,4 +61,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
return MemoryMarshal.CreateSpan(ref VertexA, Unsafe.SizeOf<ShaderAddresses>() / sizeof(ulong));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ using Ryujinx.Graphics.Shader.Translation;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Graphics.Gpu.Shader
|
||||
|
@ -73,7 +72,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
}
|
||||
}
|
||||
|
||||
private Queue<ProgramToSave> _programsToSaveQueue;
|
||||
private readonly Queue<ProgramToSave> _programsToSaveQueue;
|
||||
|
||||
private readonly ComputeShaderCacheHashTable _computeShaderCache;
|
||||
private readonly ShaderCacheHashTable _graphicsShaderCache;
|
||||
|
@ -157,13 +156,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
{
|
||||
if (_diskCacheHostStorage.CacheEnabled)
|
||||
{
|
||||
ParallelDiskCacheLoader loader = new ParallelDiskCacheLoader(
|
||||
ParallelDiskCacheLoader loader = new(
|
||||
_context,
|
||||
_graphicsShaderCache,
|
||||
_computeShaderCache,
|
||||
_diskCacheHostStorage,
|
||||
cancellationToken,
|
||||
ShaderCacheStateUpdate);
|
||||
ShaderCacheStateUpdate, cancellationToken);
|
||||
|
||||
loader.LoadShaders();
|
||||
|
||||
|
@ -214,9 +212,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
return cpShader;
|
||||
}
|
||||
|
||||
ShaderSpecializationState specState = new ShaderSpecializationState(ref computeState);
|
||||
GpuAccessorState gpuAccessorState = new GpuAccessorState(poolState, computeState, default, specState);
|
||||
GpuAccessor gpuAccessor = new GpuAccessor(_context, channel, gpuAccessorState);
|
||||
ShaderSpecializationState specState = new(ref computeState);
|
||||
GpuAccessorState gpuAccessorState = new(poolState, computeState, default, specState);
|
||||
GpuAccessor gpuAccessor = new(_context, channel, gpuAccessorState);
|
||||
|
||||
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, gpuVa);
|
||||
TranslatedShader translatedShader = TranslateShader(_dumper, channel, translatorContext, cachedGuestCode);
|
||||
|
@ -241,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <param name="pipeline">Shader pipeline state to be updated</param>
|
||||
/// <param name="graphicsState">Current graphics state</param>
|
||||
/// <param name="channel">Current GPU channel</param>
|
||||
private void UpdatePipelineInfo(
|
||||
private static void UpdatePipelineInfo(
|
||||
ref ThreedClassState state,
|
||||
ref ProgramPipelineState pipeline,
|
||||
GpuChannelGraphicsState graphicsState,
|
||||
|
@ -318,8 +316,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
UpdatePipelineInfo(ref state, ref pipeline, graphicsState, channel);
|
||||
|
||||
ShaderSpecializationState specState = new ShaderSpecializationState(ref graphicsState, ref pipeline, transformFeedbackDescriptors);
|
||||
GpuAccessorState gpuAccessorState = new GpuAccessorState(poolState, default, graphicsState, specState, transformFeedbackDescriptors);
|
||||
ShaderSpecializationState specState = new(ref graphicsState, ref pipeline, transformFeedbackDescriptors);
|
||||
GpuAccessorState gpuAccessorState = new(poolState, default, graphicsState, specState, transformFeedbackDescriptors);
|
||||
|
||||
ReadOnlySpan<ulong> addressesSpan = addresses.AsSpan();
|
||||
|
||||
|
@ -334,7 +332,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
if (gpuVa != 0)
|
||||
{
|
||||
GpuAccessor gpuAccessor = new GpuAccessor(_context, channel, gpuAccessorState, stageIndex);
|
||||
GpuAccessor gpuAccessor = new(_context, channel, gpuAccessorState, stageIndex);
|
||||
TranslatorContext currentStage = DecodeGraphicsShader(gpuAccessor, api, DefaultFlags, gpuVa);
|
||||
|
||||
if (nextStage != null)
|
||||
|
@ -358,11 +356,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
}
|
||||
|
||||
CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1];
|
||||
List<ShaderSource> shaderSources = new List<ShaderSource>();
|
||||
List<ShaderSource> shaderSources = new();
|
||||
|
||||
TranslatorContext previousStage = null;
|
||||
|
||||
ShaderInfoBuilder infoBuilder = new ShaderInfoBuilder(_context, transformFeedbackDescriptors != null);
|
||||
ShaderInfoBuilder infoBuilder = new(_context, transformFeedbackDescriptors != null);
|
||||
|
||||
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
|
||||
{
|
||||
|
@ -486,7 +484,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
if (_diskCacheHostStorage.CacheEnabled)
|
||||
{
|
||||
byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(sources) : null;
|
||||
ProgramToSave programToSave = new ProgramToSave(program, hostProgram, binaryCode);
|
||||
ProgramToSave programToSave = new(program, hostProgram, binaryCode);
|
||||
|
||||
_programsToSaveQueue.Enqueue(programToSave);
|
||||
}
|
||||
|
@ -670,8 +668,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
pathsB.Prepend(program);
|
||||
pathsA.Prepend(program);
|
||||
|
||||
CachedShaderStage vertexAStage = new CachedShaderStage(null, codeA, cb1DataA);
|
||||
CachedShaderStage vertexBStage = new CachedShaderStage(program.Info, codeB, cb1DataB);
|
||||
CachedShaderStage vertexAStage = new(null, codeA, cb1DataA);
|
||||
CachedShaderStage vertexBStage = new(program.Info, codeB, cb1DataB);
|
||||
|
||||
return new TranslatedShaderVertexPair(vertexAStage, vertexBStage, program);
|
||||
}
|
||||
|
@ -716,7 +714,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
ShaderStage.TessellationEvaluation => 2,
|
||||
ShaderStage.Geometry => 3,
|
||||
ShaderStage.Fragment => 4,
|
||||
_ => 0
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
/// <param name="stageIndex">Index of the shader stage</param>
|
||||
/// <returns>Guest code, or null if not present</returns>
|
||||
public byte[] GetByIndex(int stageIndex)
|
||||
public readonly byte[] GetByIndex(int stageIndex)
|
||||
{
|
||||
return stageIndex switch
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
2 => TessEvaluationCode,
|
||||
3 => GeometryCode,
|
||||
4 => FragmentCode,
|
||||
_ => VertexBCode
|
||||
_ => VertexBCode,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <param name="id">ID of the guest code, if found</param>
|
||||
/// <param name="data">Cached guest code, if found</param>
|
||||
/// <returns>True if found, false otherwise</returns>
|
||||
public bool TryFind(IDataAccessor dataAccessor, out int id, out byte[] data)
|
||||
public readonly bool TryFind(IDataAccessor dataAccessor, out int id, out byte[] data)
|
||||
{
|
||||
return _cache.TryFindItem(dataAccessor, out id, out data);
|
||||
}
|
||||
|
@ -103,12 +103,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
public int GeometryId;
|
||||
public int FragmentId;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public readonly override bool Equals(object obj)
|
||||
{
|
||||
return obj is IdTable other && Equals(other);
|
||||
}
|
||||
|
||||
public bool Equals(IdTable other)
|
||||
public readonly bool Equals(IdTable other)
|
||||
{
|
||||
return other.VertexAId == VertexAId &&
|
||||
other.VertexBId == VertexBId &&
|
||||
|
@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
other.FragmentId == FragmentId;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
public readonly override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(VertexAId, VertexBId, TessControlId, TessEvaluationId, GeometryId, FragmentId);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <param name="program">Program to be added</param>
|
||||
public void Add(CachedShaderProgram program)
|
||||
{
|
||||
IdTable idTable = new IdTable();
|
||||
IdTable idTable = new();
|
||||
|
||||
foreach (var shader in program.Shaders)
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
out CachedGraphicsGuestCode guestCode)
|
||||
{
|
||||
var memoryManager = channel.MemoryManager;
|
||||
IdTable idTable = new IdTable();
|
||||
IdTable idTable = new();
|
||||
guestCode = new CachedGraphicsGuestCode();
|
||||
|
||||
program = null;
|
||||
|
@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
return true;
|
||||
}
|
||||
|
||||
ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(memoryManager, baseAddress);
|
||||
ShaderCodeAccessor codeAccessor = new(memoryManager, baseAddress);
|
||||
return idCache.TryFind(codeAccessor, out id, out data);
|
||||
}
|
||||
|
||||
|
@ -279,4 +279,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <summary>Shader cache is written to disk</summary>
|
||||
Packaging,
|
||||
/// <summary>Shader cache finished loading</summary>
|
||||
Loaded
|
||||
Loaded,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,4 +29,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
return _memoryManager.GetSpanMapped(_baseAddress + (ulong)offset, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,4 +46,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
CurrentDumpIndex++;
|
||||
|
||||
using MemoryStream stream = new MemoryStream(code);
|
||||
BinaryReader codeReader = new BinaryReader(stream);
|
||||
using MemoryStream stream = new(code);
|
||||
BinaryReader codeReader = new(stream);
|
||||
|
||||
using FileStream fullFile = File.Create(fullPath);
|
||||
using FileStream codeFile = File.Create(codePath);
|
||||
BinaryWriter fullWriter = new BinaryWriter(fullFile);
|
||||
BinaryWriter codeWriter = new BinaryWriter(codeFile);
|
||||
BinaryWriter fullWriter = new(fullFile);
|
||||
BinaryWriter codeWriter = new(codeFile);
|
||||
|
||||
int headerSize = compute ? 0 : 0x50;
|
||||
|
||||
|
@ -126,4 +126,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
return dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
ShaderStage.TessellationEvaluation => 2,
|
||||
ShaderStage.Geometry => 3,
|
||||
ShaderStage.Fragment => 4,
|
||||
_ => 0
|
||||
_ => 0,
|
||||
});
|
||||
|
||||
ResourceStages stages = info.Stage switch
|
||||
|
@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
ShaderStage.TessellationEvaluation => ResourceStages.TessellationEvaluation,
|
||||
ShaderStage.Geometry => ResourceStages.Geometry,
|
||||
ShaderStage.Fragment => ResourceStages.Fragment,
|
||||
_ => ResourceStages.None
|
||||
_ => ResourceStages.None,
|
||||
};
|
||||
|
||||
int uniformsPerStage = (int)_context.Capabilities.MaximumUniformBuffersPerStage;
|
||||
|
@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
usages[index] = new ResourceUsageCollection(_resourceUsages[index].ToArray().AsReadOnly());
|
||||
}
|
||||
|
||||
ResourceLayout resourceLayout = new ResourceLayout(descriptors.AsReadOnly(), usages.AsReadOnly());
|
||||
ResourceLayout resourceLayout = new(descriptors.AsReadOnly(), usages.AsReadOnly());
|
||||
|
||||
if (pipeline.HasValue)
|
||||
{
|
||||
|
@ -262,7 +262,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
ProgramPipelineState? pipeline,
|
||||
bool tfEnabled)
|
||||
{
|
||||
ShaderInfoBuilder builder = new ShaderInfoBuilder(context, tfEnabled);
|
||||
ShaderInfoBuilder builder = new(context, tfEnabled);
|
||||
|
||||
foreach (CachedShaderStage program in programs)
|
||||
{
|
||||
|
@ -284,11 +284,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>Shader information</returns>
|
||||
public static ShaderInfo BuildForCompute(GpuContext context, ShaderProgramInfo info, bool fromCache = false)
|
||||
{
|
||||
ShaderInfoBuilder builder = new ShaderInfoBuilder(context, tfEnabled: false);
|
||||
ShaderInfoBuilder builder = new(context, tfEnabled: false);
|
||||
|
||||
builder.AddStageInfo(info);
|
||||
|
||||
return builder.Build(null, fromCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
class ShaderSpecializationList : IEnumerable<CachedShaderProgram>
|
||||
{
|
||||
private readonly List<CachedShaderProgram> _entries = new List<CachedShaderProgram>();
|
||||
private readonly List<CachedShaderProgram> _entries = new();
|
||||
|
||||
/// <summary>
|
||||
/// Adds a program to the list.
|
||||
|
@ -81,4 +81,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
EarlyZForce = 1 << 0,
|
||||
PrimitiveTopology = 1 << 1,
|
||||
TessellationMode = 1 << 2,
|
||||
TransformFeedback = 1 << 3
|
||||
TransformFeedback = 1 << 3,
|
||||
}
|
||||
|
||||
private QueriedStateFlags _queriedState;
|
||||
|
@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
{
|
||||
TextureFormat = 1 << 0,
|
||||
SamplerType = 1 << 1,
|
||||
CoordNormalized = 1 << 2
|
||||
CoordNormalized = 1 << 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -440,7 +440,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>Texture specialization state</returns>
|
||||
private Box<TextureSpecializationState> GetOrCreateTextureSpecState(int stageIndex, int handle, int cbufSlot)
|
||||
{
|
||||
TextureKey key = new TextureKey(stageIndex, handle, cbufSlot);
|
||||
TextureKey key = new(stageIndex, handle, cbufSlot);
|
||||
|
||||
if (!_textureSpecialization.TryGetValue(key, out Box<TextureSpecializationState> state))
|
||||
{
|
||||
|
@ -459,7 +459,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>Texture specialization state</returns>
|
||||
private Box<TextureSpecializationState> GetTextureSpecState(int stageIndex, int handle, int cbufSlot)
|
||||
{
|
||||
TextureKey key = new TextureKey(stageIndex, handle, cbufSlot);
|
||||
TextureKey key = new(stageIndex, handle, cbufSlot);
|
||||
|
||||
if (_textureSpecialization.TryGetValue(key, out Box<TextureSpecializationState> state))
|
||||
{
|
||||
|
@ -694,7 +694,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <param name="descriptor">Texture descriptor</param>
|
||||
/// <returns>True if the state matches, false otherwise</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private bool MatchesTexture(Box<TextureSpecializationState> specializationState, in Image.TextureDescriptor descriptor)
|
||||
private static bool MatchesTexture(Box<TextureSpecializationState> specializationState, in Image.TextureDescriptor descriptor)
|
||||
{
|
||||
if (specializationState != null)
|
||||
{
|
||||
|
@ -756,7 +756,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>Shader specialization state</returns>
|
||||
public static ShaderSpecializationState Read(ref BinarySerializer dataReader)
|
||||
{
|
||||
ShaderSpecializationState specState = new ShaderSpecializationState();
|
||||
ShaderSpecializationState specState = new();
|
||||
|
||||
dataReader.Read(ref specState._queriedState);
|
||||
dataReader.Read(ref specState._compute);
|
||||
|
@ -812,7 +812,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
TextureKey textureKey = default;
|
||||
Box<TextureSpecializationState> textureState = new Box<TextureSpecializationState>();
|
||||
Box<TextureSpecializationState> textureState = new();
|
||||
|
||||
dataReader.ReadWithMagicAndSize(ref textureKey, TexkMagic);
|
||||
dataReader.ReadWithMagicAndSize(ref textureState.Value, TexsMagic);
|
||||
|
@ -886,4 +886,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <returns>Span of varying locations</returns>
|
||||
public ReadOnlySpan<byte> AsSpan()
|
||||
{
|
||||
return MemoryMarshal.Cast<uint, byte>(VaryingLocations.AsSpan()).Slice(0, Math.Min(128, VaryingCount));
|
||||
return MemoryMarshal.Cast<uint, byte>(VaryingLocations.AsSpan())[..Math.Min(128, VaryingCount)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue