misc: chore: Use collection expressions in Gpu project

This commit is contained in:
Evan Husted 2025-01-26 15:49:22 -06:00
parent ae90db2040
commit aa0cb50c5d
41 changed files with 365 additions and 304 deletions

View file

@ -799,7 +799,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
try
{
(_virtualDependencies ??= new()).Add(virtualBuffer);
(_virtualDependencies ??= []).Add(virtualBuffer);
}
finally
{

View file

@ -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);
}
}

View file

@ -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];
}

View file

@ -437,7 +437,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (_source == null)
{
// Create a new migration.
_source = new BufferMigration(new BufferMigrationSpan[] { span }, this, _context.SyncNumber);
_source = new BufferMigration([span], this, _context.SyncNumber);
_context.RegisterBufferMigration(_source);
}
@ -476,7 +476,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
lock (_lock)
{
BufferMigrationSpan span = new(_parent, _parent.GetSnapshotDisposeAction(), _parent.GetSnapshotFlushAction(), _source);
BufferMigration migration = new(new BufferMigrationSpan[] { span }, this, _context.SyncNumber);
BufferMigration migration = new([span], this, _context.SyncNumber);
// Migration target is used to redirect flush actions to the latest range list,
// so we don't need to set it here. (this range list is still the latest)

View file

@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (binding >= 0)
{
BufferRange range = new(_handle, 0, data.Length);
_renderer.Pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, range) });
_renderer.Pipeline.SetUniformBuffers([new BufferAssignment(0, range)]);
}
};

View file

@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
public CounterCache()
{
_items = new List<CounterEntry>();
_items = [];
}
/// <summary>

View file

@ -458,7 +458,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int pages = (int)((endVaRounded - va) / PageSize);
List<MemoryRange> regions = new();
List<MemoryRange> regions = [];
for (int page = 0; page < pages - 1; page++)
{

View file

@ -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);
}

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
public void AddRemapAction(Action action)
{
RemapActions ??= new List<Action>();
RemapActions ??= [];
RemapActions.Add(action);
}
}

View file

@ -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>();
}