mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-29 22:27:53 +02:00
misc: chore: Use collection expressions (part 2)
This commit is contained in:
@@ -274,7 +274,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
|
||||
|
||||
private void Assemble(CC cc, Instruction inst, Dest dest, OpAC srcA, OpBD srcB, OpAC srcC, OpBD srcD)
|
||||
{
|
||||
(_code ??= new List<uint>()).Add(new UcodeOp(cc, inst, _constantIndex, dest, srcA, srcB, srcC, srcD).Word);
|
||||
(_code ??= []).Add(new UcodeOp(cc, inst, _constantIndex, dest, srcA, srcB, srcC, srcD).Word);
|
||||
}
|
||||
|
||||
public void SetConstant(int index, float r, float g, float b)
|
||||
|
||||
@@ -126,9 +126,9 @@ namespace Ryujinx.Graphics.Gpu
|
||||
HostInitalized = new ManualResetEvent(false);
|
||||
_gpuReadyEvent = new ManualResetEvent(false);
|
||||
|
||||
SyncActions = new List<ISyncActionHandler>();
|
||||
SyncpointActions = new List<ISyncActionHandler>();
|
||||
BufferMigrations = new List<BufferMigration>();
|
||||
SyncActions = [];
|
||||
SyncpointActions = [];
|
||||
BufferMigrations = [];
|
||||
|
||||
DeferredActions = new Queue<Action>();
|
||||
|
||||
|
||||
@@ -118,10 +118,10 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// </summary>
|
||||
public AutoDeleteCache()
|
||||
{
|
||||
_textures = new LinkedList<Texture>();
|
||||
_textures = [];
|
||||
|
||||
_shortCacheBuilder = new HashSet<ShortTextureCacheEntry>();
|
||||
_shortCache = new HashSet<ShortTextureCacheEntry>();
|
||||
_shortCacheBuilder = [];
|
||||
_shortCache = [];
|
||||
|
||||
_shortCacheLookup = new Dictionary<TextureDescriptor, ShortTextureCacheEntry>();
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
public PoolCache(GpuContext context)
|
||||
{
|
||||
_context = context;
|
||||
_pools = new LinkedList<T>();
|
||||
_pools = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -260,8 +260,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
_viewStorage = this;
|
||||
|
||||
_views = new List<Texture>();
|
||||
_poolOwners = new List<TexturePoolOwner>();
|
||||
_views = [];
|
||||
_poolOwners = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -549,7 +549,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
_channel = channel;
|
||||
_cacheFromBuffer = new Dictionary<CacheEntryFromBufferKey, CacheEntryFromBuffer>();
|
||||
_cacheFromPool = new Dictionary<CacheEntryFromPoolKey, CacheEntry>();
|
||||
_lruCache = new LinkedList<CacheEntryFromBuffer>();
|
||||
_lruCache = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1116,7 +1116,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
if (key.MatchesPool(pool))
|
||||
{
|
||||
(keysToRemove ??= new()).Add(key);
|
||||
(keysToRemove ??= []).Add(key);
|
||||
|
||||
if (key.IsImage)
|
||||
{
|
||||
|
||||
@@ -58,15 +58,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
_context = context;
|
||||
_physicalMemory = physicalMemory;
|
||||
|
||||
_textures = new MultiRangeList<Texture>();
|
||||
_partiallyMappedTextures = new HashSet<Texture>();
|
||||
_textures = [];
|
||||
_partiallyMappedTextures = [];
|
||||
|
||||
_texturesLock = new ReaderWriterLockSlim();
|
||||
|
||||
_textureOverlaps = new Texture[OverlapsBufferInitialCapacity];
|
||||
_overlapInfo = new OverlapInfo[OverlapsBufferInitialCapacity];
|
||||
|
||||
_cache = new AutoDeleteCache();
|
||||
_cache = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -892,7 +892,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
// otherwise we only need the data that is copied from the existing texture, without loading the CPU data.
|
||||
bool updateNewTexture = texture.Width > overlap.Width || texture.Height > overlap.Height;
|
||||
|
||||
texture.InitializeGroup(true, true, new List<TextureIncompatibleOverlap>());
|
||||
texture.InitializeGroup(true, true, []);
|
||||
texture.InitializeData(false, updateNewTexture);
|
||||
|
||||
overlap.SynchronizeMemory();
|
||||
|
||||
@@ -134,8 +134,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
Offset = offset;
|
||||
Size = (int)size;
|
||||
Overlaps = new List<Texture>();
|
||||
Dependencies = new List<TextureDependency>();
|
||||
Overlaps = [];
|
||||
Dependencies = [];
|
||||
|
||||
BaseSlice = baseSlice;
|
||||
SliceCount = sliceCount;
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
/// </summary>
|
||||
public TextureAliasList()
|
||||
{
|
||||
_aliases = new List<Alias>();
|
||||
_aliases = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -799,7 +799,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
try
|
||||
{
|
||||
(_virtualDependencies ??= new()).Add(virtualBuffer);
|
||||
(_virtualDependencies ??= []).Add(virtualBuffer);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
_context = context;
|
||||
_physicalMemory = physicalMemory;
|
||||
|
||||
_buffers = new RangeList<Buffer>();
|
||||
_multiRangeBuffers = new MultiRangeList<MultiRangeBuffer>();
|
||||
_buffers = [];
|
||||
_multiRangeBuffers = [];
|
||||
|
||||
_bufferOverlaps = new Buffer[OverlapsBufferInitialCapacity];
|
||||
|
||||
@@ -395,7 +395,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
ulong dstOffset = 0;
|
||||
|
||||
HashSet<Buffer> physicalBuffers = new();
|
||||
HashSet<Buffer> physicalBuffers = [];
|
||||
|
||||
for (int i = 0; i < virtualBuffer.Range.Count; i++)
|
||||
{
|
||||
@@ -1041,7 +1041,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
{
|
||||
if (entry.Value.UnmappedSequence != entry.Value.Buffer.UnmappedSequence)
|
||||
{
|
||||
(toDelete ??= new()).Add(entry.Key);
|
||||
(toDelete ??= []).Add(entry.Key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -141,9 +141,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
_gpUniformBuffers[index] = new BuffersPerStage(Constants.TotalGpUniformBuffers);
|
||||
}
|
||||
|
||||
_bufferTextures = new List<BufferTextureBinding>();
|
||||
_bufferTextureArrays = new List<BufferTextureArrayBinding<ITextureArray>>();
|
||||
_bufferImageArrays = new List<BufferTextureArrayBinding<IImageArray>>();
|
||||
_bufferTextures = [];
|
||||
_bufferTextureArrays = [];
|
||||
_bufferImageArrays = [];
|
||||
|
||||
_ranges = new BufferAssignment[Constants.TotalGpUniformBuffers * Constants.ShaderStages];
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
/// </summary>
|
||||
public CounterCache()
|
||||
{
|
||||
_items = new List<CounterEntry>();
|
||||
_items = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
/// <param name="rangeSize">Size of the range in bytes</param>
|
||||
public void AddPhysicalDependency(Buffer buffer, ulong rangeAddress, ulong dstOffset, ulong rangeSize)
|
||||
{
|
||||
(_dependencies ??= new()).Add(new(buffer, rangeAddress - buffer.Address, dstOffset, rangeSize));
|
||||
(_dependencies ??= []).Add(new(buffer, rangeAddress - buffer.Address, dstOffset, rangeSize));
|
||||
buffer.AddVirtualDependency(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
|
||||
public void AddRemapAction(Action action)
|
||||
{
|
||||
RemapActions ??= new List<Action>();
|
||||
RemapActions ??= [];
|
||||
RemapActions.Add(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
public VirtualRangeCache(MemoryManager memoryManager)
|
||||
{
|
||||
_memoryManager = memoryManager;
|
||||
_virtualRanges = new RangeList<VirtualRange>();
|
||||
_virtualRanges = [];
|
||||
_virtualRangeOverlaps = new VirtualRange[BufferCache.OverlapsBufferInitialCapacity];
|
||||
_deferredUnmaps = new ConcurrentQueue<VirtualRange>();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
var specList = _cache.GetOrAdd(program.Shaders[0].Code, new ShaderSpecializationList());
|
||||
var 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 var list))
|
||||
{
|
||||
_toc.Add(hash, list = new List<TocMemoryEntry>());
|
||||
_toc.Add(hash, list = []);
|
||||
}
|
||||
|
||||
list.Add(new TocMemoryEntry(dataOffset, codeSize, cb1DataSize, index));
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
||||
/// </summary>
|
||||
public PartitionedHashTable()
|
||||
{
|
||||
_sizeTable = new List<SizeEntry>();
|
||||
_sizeTable = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
|
||||
if (!_shaderPrograms.TryGetValue(idTable, out ShaderSpecializationList specList))
|
||||
{
|
||||
specList = new ShaderSpecializationList();
|
||||
specList = [];
|
||||
_shaderPrograms.Add(idTable, specList);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,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);
|
||||
@@ -280,7 +280,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
|
||||
for (int index = oldLength; index <= setIndex; index++)
|
||||
{
|
||||
_resourceDescriptors[index] = new();
|
||||
_resourceDescriptors[index] = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +301,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.
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
|
||||
public Syncpoint(uint id)
|
||||
{
|
||||
Id = id;
|
||||
_waiters = new List<SyncpointWaiterHandle>();
|
||||
_waiters = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
|
||||
}
|
||||
else
|
||||
{
|
||||
expiredList ??= new List<SyncpointWaiterHandle>();
|
||||
expiredList ??= [];
|
||||
|
||||
expiredList.Add(item);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user