mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-17 14:26:29 +02:00
misc: chore: Use collection expressions in Gpu project
This commit is contained in:
parent
ae90db2040
commit
aa0cb50c5d
41 changed files with 365 additions and 304 deletions
|
@ -48,10 +48,10 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
if (stage == null)
|
||||
{
|
||||
TextureBindings[i] = Array.Empty<TextureBindingInfo>();
|
||||
ImageBindings[i] = Array.Empty<TextureBindingInfo>();
|
||||
ConstantBufferBindings[i] = Array.Empty<BufferDescriptor>();
|
||||
StorageBufferBindings[i] = Array.Empty<BufferDescriptor>();
|
||||
TextureBindings[i] = [];
|
||||
ImageBindings[i] = [];
|
||||
ConstantBufferBindings[i] = [];
|
||||
StorageBufferBindings[i] = [];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
public ComputeShaderCacheHashTable()
|
||||
{
|
||||
_cache = new PartitionedHashTable<ShaderSpecializationList>();
|
||||
_shaderPrograms = new List<CachedShaderProgram>();
|
||||
_shaderPrograms = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// <param name="program">Program to be added</param>
|
||||
public void Add(CachedShaderProgram program)
|
||||
{
|
||||
ShaderSpecializationList specList = _cache.GetOrAdd(program.Shaders[0].Code, new ShaderSpecializationList());
|
||||
ShaderSpecializationList specList = _cache.GetOrAdd(program.Shaders[0].Code, []);
|
||||
specList.Add(program);
|
||||
_shaderPrograms.Add(program);
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
{
|
||||
if (!_toc.TryGetValue(hash, out List<TocMemoryEntry> list))
|
||||
{
|
||||
_toc.Add(hash, list = new List<TocMemoryEntry>());
|
||||
_toc.Add(hash, list = []);
|
||||
}
|
||||
|
||||
list.Add(new TocMemoryEntry(dataOffset, codeSize, cb1DataSize, index));
|
||||
|
|
|
@ -657,7 +657,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
}
|
||||
|
||||
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
|
||||
List<ShaderProgram> translatedStages = new();
|
||||
List<ShaderProgram> translatedStages = [];
|
||||
|
||||
TranslatorContext previousStage = null;
|
||||
|
||||
|
@ -729,9 +729,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
|
||||
ShaderProgram program = translatorContext.Translate();
|
||||
|
||||
CachedShaderStage[] shaders = new[] { new CachedShaderStage(program.Info, shader.Code, shader.Cb1Data) };
|
||||
CachedShaderStage[] shaders = [new CachedShaderStage(program.Info, shader.Code, shader.Cb1Data)];
|
||||
|
||||
_compilationQueue.Enqueue(new ProgramCompilation(new[] { program }, shaders, newSpecState, programIndex, isCompute: true));
|
||||
_compilationQueue.Enqueue(new ProgramCompilation([program], shaders, newSpecState, programIndex, isCompute: true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
|||
using MemoryStream input = new(code);
|
||||
using BinaryReader reader = new(input);
|
||||
|
||||
List<ShaderSource> output = new();
|
||||
List<ShaderSource> output = [];
|
||||
|
||||
int count = reader.ReadInt32();
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// </summary>
|
||||
public PartitionHashTable()
|
||||
{
|
||||
_buckets = Array.Empty<Bucket>();
|
||||
_buckets = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -234,7 +234,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
}
|
||||
else
|
||||
{
|
||||
(bucket.MoreEntries ??= new List<Entry>()).Add(entry);
|
||||
(bucket.MoreEntries ??= []).Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
|||
/// </summary>
|
||||
public PartitionedHashTable()
|
||||
{
|
||||
_sizeTable = new List<SizeEntry>();
|
||||
_sizeTable = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, gpuVa);
|
||||
TranslatedShader translatedShader = TranslateShader(_dumper, channel, translatorContext, cachedGuestCode, asCompute: false);
|
||||
|
||||
ShaderSource[] shaderSourcesArray = new ShaderSource[] { CreateShaderSource(translatedShader.Program) };
|
||||
ShaderSource[] shaderSourcesArray = [CreateShaderSource(translatedShader.Program)];
|
||||
ShaderInfo info = ShaderInfoBuilder.BuildForCompute(
|
||||
_context,
|
||||
translatedShader.Program.Info,
|
||||
|
@ -369,7 +369,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
bool geometryToCompute = ShouldConvertGeometryToCompute(_context, geometryHasStore);
|
||||
|
||||
CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1];
|
||||
List<ShaderSource> shaderSources = new();
|
||||
List<ShaderSource> shaderSources = [];
|
||||
|
||||
TranslatorContext previousStage = null;
|
||||
ShaderInfoBuilder infoBuilder = new(_context, transformFeedbackDescriptors != null, vertexToCompute);
|
||||
|
@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
ShaderSource source = new(program.Code, program.BinaryCode, ShaderStage.Compute, program.Language);
|
||||
ShaderInfo info = ShaderInfoBuilder.BuildForVertexAsCompute(_context, program.Info, context.GetVertexAsComputeInfo(), tfEnabled);
|
||||
|
||||
return new(_context.Renderer.CreateProgram(new[] { source }, info), program.Info, context.GetResourceReservations());
|
||||
return new(_context.Renderer.CreateProgram([source], info), program.Info, context.GetResourceReservations());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -802,7 +802,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
{
|
||||
if (address == MemoryManager.PteUnmapped || size == 0)
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
return [];
|
||||
}
|
||||
|
||||
return memoryManager.Physical.GetSpan(address, size).ToArray();
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
if (!_shaderPrograms.TryGetValue(idTable, out ShaderSpecializationList specList))
|
||||
{
|
||||
specList = new ShaderSpecializationList();
|
||||
specList = [];
|
||||
_shaderPrograms.Add(idTable, specList);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
for (int index = 0; index < totalSets; index++)
|
||||
{
|
||||
_resourceDescriptors[index] = new();
|
||||
_resourceUsages[index] = new();
|
||||
_resourceDescriptors[index] = [];
|
||||
_resourceUsages[index] = [];
|
||||
}
|
||||
|
||||
AddDescriptor(SupportBufferStages, ResourceType.UniformBuffer, uniformSetIndex, 0, 1);
|
||||
|
@ -302,7 +302,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
for (int index = oldLength; index <= setIndex; index++)
|
||||
{
|
||||
_resourceDescriptors[index] = new();
|
||||
_resourceDescriptors[index] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
|
||||
for (int index = oldLength; index <= setIndex; index++)
|
||||
{
|
||||
_resourceUsages[index] = new();
|
||||
_resourceUsages[index] = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
/// </summary>
|
||||
class ShaderSpecializationList : IEnumerable<CachedShaderProgram>
|
||||
{
|
||||
private readonly List<CachedShaderProgram> _entries = new();
|
||||
private readonly List<CachedShaderProgram> _entries = [];
|
||||
|
||||
/// <summary>
|
||||
/// Adds a program to the list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue