misc: chore: Use collection expressions (part 2)

This commit is contained in:
KeatonTheBot 2025-03-10 21:32:01 -05:00
parent c923c0043a
commit 340ec79e9f
176 changed files with 308 additions and 308 deletions

View file

@ -1079,7 +1079,7 @@ namespace ARMeilleure.CodeGen.Arm64
private static UnwindInfo WritePrologue(CodeGenContext context)
{
List<UnwindPushEntry> pushEntries = new();
List<UnwindPushEntry> pushEntries = [];
Operand rsp = Register(SpRegister);

View file

@ -31,7 +31,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
public ParallelCopy()
{
_copies = new List<Copy>();
_copies = [];
}
public void AddCopy(Register dest, Register source, OperandType type)
@ -218,7 +218,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
public Operation[] Sequence()
{
List<Operation> sequence = new();
List<Operation> sequence = [];
if (_spillQueue != null)
{

View file

@ -799,8 +799,8 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
private void NumberLocals(ControlFlowGraph cfg, int registersCount)
{
_operationNodes = new List<(IntrusiveList<Operation>, Operation)>();
_intervals = new List<LiveInterval>();
_operationNodes = [];
_intervals = [];
for (int index = 0; index < registersCount; index++)
{
@ -980,7 +980,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
_blockLiveIn = blkLiveIn;
_blockEdges = new HashSet<int>();
_blockEdges = [];
// Compute lifetime intervals.
int operationPos = _operationsCount;

View file

@ -74,9 +74,9 @@ namespace ARMeilleure.CodeGen.X86
{
_stream = stream;
_labels = new Dictionary<Operand, long>();
_jumps = new List<Jump>();
_jumps = [];
_relocs = relocatable ? new List<Reloc>() : null;
_relocs = relocatable ? [] : null;
}
public void MarkLabel(Operand label)

View file

@ -1748,7 +1748,7 @@ namespace ARMeilleure.CodeGen.X86
private static UnwindInfo WritePrologue(CodeGenContext context)
{
List<UnwindPushEntry> pushEntries = new();
List<UnwindPushEntry> pushEntries = [];
Operand rsp = Register(X86Register.Rsp);

View file

@ -31,11 +31,11 @@ namespace ARMeilleure.Common
_pageIndex = -1;
_page = null;
_pages = new List<PageInfo>();
_pages = [];
_pageSize = pageSize;
_pageCount = pageCount;
_extras = new List<IntPtr>();
_extras = [];
}
public Span<T> AllocateSpan<T>(ulong count) where T : unmanaged

View file

@ -17,7 +17,7 @@ namespace ARMeilleure.Decoders
public Block()
{
OpCodes = new List<OpCode>();
OpCodes = [];
}
public Block(ulong address) : this()

View file

@ -20,7 +20,7 @@ namespace ARMeilleure.Decoders
public static Block[] Decode(IMemoryManager memory, ulong address, ExecutionMode mode, bool highCq, DecoderMode dMode)
{
List<Block> blocks = new();
List<Block> blocks = [];
Queue<Block> workQueue = new();

View file

@ -12,7 +12,7 @@ namespace ARMeilleure.Decoders
public OpCodeT16IfThen(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode)
{
List<Condition> conds = new();
List<Condition> conds = [];
int cond = (opCode >> 4) & 0xf;
int mask = opCode & 0xf;

View file

@ -29,9 +29,9 @@ namespace ARMeilleure.Decoders
}
}
private static readonly List<InstInfo> _allInstA32 = new();
private static readonly List<InstInfo> _allInstT32 = new();
private static readonly List<InstInfo> _allInstA64 = new();
private static readonly List<InstInfo> _allInstA32 = [];
private static readonly List<InstInfo> _allInstT32 = [];
private static readonly List<InstInfo> _allInstA64 = [];
private static readonly InstInfo[][] _instA32FastLookup = new InstInfo[FastLookupSize][];
private static readonly InstInfo[][] _instT32FastLookup = new InstInfo[FastLookupSize][];
@ -1330,7 +1330,7 @@ namespace ARMeilleure.Decoders
for (int index = 0; index < temp.Length; index++)
{
temp[index] = new List<InstInfo>();
temp[index] = [];
}
foreach (InstInfo inst in allInsts)

View file

@ -29,7 +29,7 @@ namespace ARMeilleure.Diagnostics
static Symbols()
{
_symbols = new ConcurrentDictionary<ulong, string>();
_rangedSymbols = new List<RangedSymbol>();
_rangedSymbols = [];
}
public static string Get(ulong address)

View file

@ -27,7 +27,7 @@ namespace ARMeilleure.IntermediateRepresentation
{
get
{
_domFrontiers ??= new HashSet<BasicBlock>();
_domFrontiers ??= [];
return _domFrontiers;
}
@ -38,7 +38,7 @@ namespace ARMeilleure.IntermediateRepresentation
public BasicBlock(int index)
{
Operations = new IntrusiveList<Operation>();
Predecessors = new List<BasicBlock>();
Predecessors = [];
Index = index;
}

View file

@ -23,7 +23,7 @@ namespace ARMeilleure.Translation.Cache
}
}
private readonly List<MemoryBlock> _blocks = new();
private readonly List<MemoryBlock> _blocks = [];
public CacheMemoryAllocator(int capacity)
{

View file

@ -26,12 +26,12 @@ namespace ARMeilleure.Translation.Cache
private static List<CacheMemoryAllocator> _cacheAllocators = [];
private static readonly List<CacheEntry> _cacheEntries = new();
private static readonly List<CacheEntry> _cacheEntries = [];
private static readonly Lock _lock = new();
private static bool _initialized;
private static readonly List<ReservedRegion> _jitRegions = new();
private static readonly List<ReservedRegion> _jitRegions = [];
private static int _activeRegionIndex = 0;
[SupportedOSPlatform("windows")]

View file

@ -108,7 +108,7 @@ namespace ARMeilleure.Translation
/// <returns>A list of all values sorted by Key Order</returns>
public List<TV> AsList()
{
List<TV> list = new();
List<TV> list = [];
AddToList(_root, list);

View file

@ -50,7 +50,7 @@ namespace ARMeilleure.Translation.PTC
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static List<T> DeserializeList<T>(Stream stream) where T : struct
{
List<T> list = new();
List<T> list = [];
int count = DeserializeStructure<int>(stream);

View file

@ -140,7 +140,7 @@ namespace ARMeilleure.Translation.PTC
public List<ulong> GetBlacklistedFunctions()
{
List<ulong> funcs = new List<ulong>();
List<ulong> funcs = [];
foreach (var profiledFunc in ProfiledFuncs)
{

View file

@ -36,7 +36,7 @@ namespace ARMeilleure.Translation
Sync = new object();
_requests = new Stack<RejitRequest>();
_requestAddresses = new HashSet<ulong>();
_requestAddresses = [];
}
/// <summary>

View file

@ -46,7 +46,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
SampleRate = sampleRate;
BufferCount = mixBufferCount + voiceChannelCountMax;
Buffers = mixBuffer;
Commands = new List<ICommand>();
Commands = [];
MemoryManager = memoryManager;
_buffersEntryCount = Buffers.Length;

View file

@ -139,7 +139,7 @@ namespace Ryujinx.Common.Collections
/// <param name="list">List to add the tree pairs into</param>
public List<KeyValuePair<TKey, TValue>> AsLevelOrderList()
{
List<KeyValuePair<TKey, TValue>> list = new();
List<KeyValuePair<TKey, TValue>> list = [];
Queue<Node<TKey, TValue>> nodes = new();
@ -168,7 +168,7 @@ namespace Ryujinx.Common.Collections
/// <returns>A list of all KeyValuePairs sorted by Key Order</returns>
public List<KeyValuePair<TKey, TValue>> AsList()
{
List<KeyValuePair<TKey, TValue>> list = new();
List<KeyValuePair<TKey, TValue>> list = [];
AddToList(Root, list);

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Common.Configuration
public ModMetadata()
{
Mods = new List<Mod>();
Mods = [];
}
}
}

View file

@ -131,7 +131,7 @@ namespace Ryujinx.Common.Logging
_enabledClasses[index] = true;
}
_logTargets = new List<ILogTarget>();
_logTargets = [];
_time = Stopwatch.StartNew();

View file

@ -125,8 +125,8 @@ namespace Ryujinx.Common.PreciseSleep
}
private readonly Lock _lock = new();
private readonly List<NanosleepThread> _threads = new();
private readonly List<NanosleepThread> _active = new();
private readonly List<NanosleepThread> _threads = [];
private readonly List<NanosleepThread> _active = [];
private readonly Stack<NanosleepThread> _free = new();
private readonly AutoResetEvent _signalTarget;

View file

@ -51,7 +51,7 @@ namespace Ryujinx.Common.SystemInterop
private long _lastId;
private readonly Lock _lock = new();
private readonly List<WaitingObject> _waitingObjects = new();
private readonly List<WaitingObject> _waitingObjects = [];
private WindowsGranularTimer()
{

View file

@ -164,7 +164,7 @@ namespace ARMeilleure.Common
_fillBottomLevel = new SparseMemoryBlock(bottomLevelSize, null, _sparseFill);
_fillBottomLevelPtr = (TEntry*)_fillBottomLevel.Block.Pointer;
_sparseReserved = new List<TableSparseBlock>();
_sparseReserved = [];
_sparseLock = new ReaderWriterLockSlim();
_sparseBlockSize = bottomLevelSize;

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Cpu.Jit.HostTracked
public AddressSpacePartitioned(MemoryTracking tracking, MemoryBlock backingMemory, NativePageTable nativePageTable, bool useProtectionMirrors)
{
_backingMemory = backingMemory;
_partitions = new();
_partitions = [];
_asAllocator = new(tracking, nativePageTable.Read, _partitions);
_updatePtCallback = nativePageTable.Update;
_useProtectionMirrors = useProtectionMirrors;

View file

@ -36,7 +36,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32
RegisterAllocator = registerAllocator;
MemoryManagerType = mmType;
_itConditions = new ArmCondition[4];
_pendingBranches = new();
_pendingBranches = [];
IsThumb = isThumb;
}

View file

@ -10,8 +10,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm32
{
public static MultiBlock DecodeMulti(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address, bool isThumb)
{
List<Block> blocks = new();
List<ulong> branchTargets = new();
List<Block> blocks = [];
List<ulong> branchTargets = [];
while (true)
{
@ -202,7 +202,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32
{
ulong startAddress = address;
List<InstInfo> insts = new();
List<InstInfo> insts = [];
uint encoding;
InstMeta meta;

View file

@ -25,8 +25,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm64
{
Debug.Assert((int)((endAddress - address) / 4) == instructions.Count);
_predecessors = new();
_successors = new();
_predecessors = [];
_successors = [];
Address = address;
EndAddress = endAddress;
Instructions = instructions;

View file

@ -36,8 +36,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm64
{
Console.WriteLine($"bb {block.Index}");
List<int> predList = new();
List<int> succList = new();
List<int> predList = [];
List<int> succList = [];
for (int index = 0; index < block.PredecessorsCount; index++)
{

View file

@ -309,7 +309,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
MultiBlock multiBlock = Decoder.DecodeMulti(cpuPreset, memoryManager, address);
Dictionary<ulong, int> targets = new();
List<PendingBranch> pendingBranches = new();
List<PendingBranch> pendingBranches = [];
uint gprUseMask = multiBlock.GlobalUseMask.GprMask;
uint fpSimdUseMask = multiBlock.GlobalUseMask.FpSimdMask;

View file

@ -15,8 +15,8 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
public static MultiBlock DecodeMulti(CpuPreset cpuPreset, IMemoryManager memoryManager, ulong address)
{
List<Block> blocks = new();
List<ulong> branchTargets = new();
List<Block> blocks = [];
List<ulong> branchTargets = [];
RegisterMask useMask = RegisterMask.Zero;
@ -238,7 +238,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64
{
ulong startAddress = address;
List<InstInfo> insts = new();
List<InstInfo> insts = [];
uint gprUseMask = useMask.GprMask;
uint fpSimdUseMask = useMask.FpSimdMask;

View file

@ -24,7 +24,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
}
}
private readonly List<MemoryBlock> _blocks = new();
private readonly List<MemoryBlock> _blocks = [];
public CacheMemoryAllocator(int capacity)
{

View file

@ -23,11 +23,11 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private static CacheMemoryAllocator _cacheAllocator;
private static readonly List<CacheEntry> _cacheEntries = new();
private static readonly List<CacheEntry> _cacheEntries = [];
private static readonly Lock _lock = new();
private static bool _initialized;
private static readonly List<ReservedRegion> _jitRegions = new();
private static readonly List<ReservedRegion> _jitRegions = [];
private static int _activeRegionIndex = 0;
[SupportedOSPlatform("windows")]

View file

@ -231,7 +231,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
_sharedCache.Pointer,
SharedCacheSize);
List<(ulong, ThreadLocalCacheEntry)> toDelete = new();
List<(ulong, ThreadLocalCacheEntry)> toDelete = [];
foreach ((ulong address, ThreadLocalCacheEntry entry) in _threadLocalCache)
{

View file

@ -35,8 +35,8 @@ namespace Ryujinx.Cpu.LightningJit.Cache
{
_alignedRangeAction = alignedRangeAction;
_alignedFunctionAction = alignedFunctionAction;
_pendingFunctions = new();
_ranges = new();
_pendingFunctions = [];
_ranges = [];
}
public bool Has(ulong address)

View file

@ -26,7 +26,7 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
public Assembler(CodeWriter writer)
{
_code = writer.GetList();
_labels = new List<LabelState>();
_labels = [];
}
public readonly Operand CreateLabel()

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
{
public IEnumerable<ulong> GetCallStack(IntPtr framePointer, IntPtr codeRegionStart, int codeRegionSize, IntPtr codeRegion2Start, int codeRegion2Size)
{
List<ulong> functionPointers = new();
List<ulong> functionPointers = [];
while (true)
{

View file

@ -16,7 +16,7 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64
public TailMerger()
{
_branchPointers = new();
_branchPointers = [];
}
public void AddConditionalReturn(CodeWriter writer, in Assembler asm, ArmCondition returnCondition)

View file

@ -12,7 +12,7 @@ namespace Ryujinx.Cpu.LightningJit
public CodeWriter()
{
_instructions = new();
_instructions = [];
}
public void WriteInstruction(uint instruction)

View file

@ -34,7 +34,7 @@ namespace Ryujinx.Cpu.LightningJit.Table
{
int splitIndex = (int)((insts[index].Encoding >> _shift) & _mask);
(splitList[splitIndex] ??= new()).Add(insts[index]);
(splitList[splitIndex] ??= []).Add(insts[index]);
}
for (int index = 0; index < count; index++)

View file

@ -140,7 +140,7 @@ namespace Ryujinx.Cpu.LightningJit
/// <returns>Generated <see cref="DispatchStub"/></returns>
private IntPtr GenerateDispatchStub()
{
List<int> branchToFallbackOffsets = new();
List<int> branchToFallbackOffsets = [];
CodeWriter writer = new();

View file

@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
private ulong _bufferHandle = 0;
private readonly Dictionary<BufferHandle, BufferHandle> _bufferMap = new();
private readonly HashSet<BufferHandle> _inFlight = new();
private readonly HashSet<BufferHandle> _inFlight = [];
private readonly AutoResetEvent _inFlightChanged = new(false);
internal BufferHandle CreateBufferHandle()

View file

@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
_renderer = renderer;
_toCompile = new Queue<IProgramRequest>();
_inProgress = new List<ThreadedProgram>();
_inProgress = [];
}
public void Add(IProgramRequest request)

View file

@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
{
class SyncMap : IDisposable
{
private readonly HashSet<ulong> _inFlight = new();
private readonly HashSet<ulong> _inFlight = [];
private readonly AutoResetEvent _inFlightChanged = new(false);
internal void CreateSyncHandle(ulong id)

View file

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

View file

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

View file

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

View file

@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Gpu.Image
public PoolCache(GpuContext context)
{
_context = context;
_pools = new LinkedList<T>();
_pools = [];
}
/// <summary>

View file

@ -260,8 +260,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_viewStorage = this;
_views = new List<Texture>();
_poolOwners = new List<TexturePoolOwner>();
_views = [];
_poolOwners = [];
}
/// <summary>

View file

@ -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)
{

View file

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

View file

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

View file

@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
public TextureAliasList()
{
_aliases = new List<Alias>();
_aliases = [];
}
/// <summary>

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

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

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

View file

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

View file

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

View file

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

View file

@ -104,7 +104,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// </summary>
public PartitionedHashTable()
{
_sizeTable = new List<SizeEntry>();
_sizeTable = [];
}
/// <summary>

View file

@ -192,7 +192,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (!_shaderPrograms.TryGetValue(idTable, out ShaderSpecializationList specList))
{
specList = new ShaderSpecializationList();
specList = [];
_shaderPrograms.Add(idTable, specList);
}

View file

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

View file

@ -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.

View file

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

View file

@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Host1x
}
}
private readonly List<SyncptIncr> _incrs = new();
private readonly List<SyncptIncr> _incrs = [];
private uint _currentId;

View file

@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
public IntermediatePool(OpenGLRenderer renderer)
{
_renderer = renderer;
_entries = new List<TextureView>();
_entries = [];
}
public TextureView GetOrCreateWithAtLeast(

View file

@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.OpenGL
{
if (!_textures.TryGetValue(view.Info, out List<DisposedTexture> list))
{
list = new List<DisposedTexture>();
list = [];
_textures.Add(view.Info, list);
}

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.OpenGL
private ulong _firstHandle = 0;
private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit;
private readonly List<SyncHandle> _handles = new();
private readonly List<SyncHandle> _handles = [];
public void Create(ulong id)
{

View file

@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
private class BlockState
{
private int _entryCount;
private readonly List<Instruction> _labels = new();
private readonly List<Instruction> _labels = [];
public Instruction GetNextLabel(CodeGenContext context)
{

View file

@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
private static void DeclareBuffers(CodeGenContext context, IEnumerable<BufferDefinition> buffers, bool isBuffer)
{
HashSet<SpvInstruction> decoratedTypes = new();
HashSet<SpvInstruction> decoratedTypes = [];
foreach (BufferDefinition buffer in buffers)
{

View file

@ -45,11 +45,11 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
Address = address;
Predecessors = new List<Block>();
Successors = new List<Block>();
Predecessors = [];
Successors = [];
OpCodes = new List<InstOp>();
PushOpCodes = new List<PushOpInfo>();
OpCodes = [];
PushOpCodes = [];
SyncTargets = new Dictionary<ulong, SyncTarget>();
}

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
public DecodedFunction(ulong address)
{
Address = address;
_callers = new HashSet<DecodedFunction>();
_callers = [];
Type = FunctionType.User;
Id = -1;
}

View file

@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
MainFunction = mainFunction;
_functions = functions;
_functionsWithId = new();
_functionsWithId = [];
AttributeUsage = attributeUsage;
UsedFeatures = usedFeatures;
ClipDistancesWritten = clipDistancesWritten;

View file

@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
while (functionsQueue.TryDequeue(out DecodedFunction currentFunction))
{
List<Block> blocks = new();
List<Block> blocks = [];
Queue<Block> workQueue = new();
Dictionary<ulong, Block> visited = new();
@ -520,7 +520,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0))
{
HashSet<ulong> visited = new();
HashSet<ulong> visited = [];
InstBrx opBrx = new(lastOp.RawOpCode);
ulong baseOffset = lastOp.GetAbsoluteAddress();
@ -566,7 +566,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
// On a successful match, "BaseOffset" is the offset in bytes where the jump offsets are
// located on the constant buffer, and "UpperBound" is the total number of offsets for the BRX, minus 1.
HashSet<Block> visited = new();
HashSet<Block> visited = [];
var ldcLocation = FindFirstRegWrite(visited, new BlockLocation(block, block.OpCodes.Count - 1), brxReg);
if (ldcLocation.Block == null || ldcLocation.Block.OpCodes[ldcLocation.Index].Name != InstName.Ldc)
@ -752,7 +752,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
Block target = blocks[pushOp.GetAbsoluteAddress()];
Stack<PathBlockState> workQueue = new();
HashSet<Block> visited = new();
HashSet<Block> visited = [];
Stack<(ulong, MergeType)> branchStack = new();
void Push(PathBlockState pbs)

View file

@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand d = Register(dest, RegisterType.Gpr);
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@ -328,7 +328,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@ -500,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@ -605,7 +605,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{

View file

@ -34,11 +34,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
public BasicBlock()
{
Operations = new LinkedList<INode>();
Operations = [];
Predecessors = new List<BasicBlock>();
Predecessors = [];
DominanceFrontiers = new HashSet<BasicBlock>();
DominanceFrontiers = [];
}
public BasicBlock(int index) : this()

View file

@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
private Operand()
{
UseOps = new HashSet<INode>();
UseOps = [];
}
public Operand(OperandType type) : this()

View file

@ -35,9 +35,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
public PhiNode(Operand dest)
{
_blocks = new HashSet<BasicBlock>();
_blocks = [];
_sources = new List<PhiSource>();
_sources = [];
dest.AsgOp = this;

View file

@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Type = type;
Condition = condition;
_nodes = new LinkedList<IAstNode>();
_nodes = [];
}
public void Add(IAstNode node)

View file

@ -17,8 +17,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private AstOperand()
{
Defs = new HashSet<IAstNode>();
Uses = new HashSet<IAstNode>();
Defs = [];
Uses = [];
VarType = AggregateType.S32;
}

View file

@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
AstBlock block = bottom;
List<AstBlock> path = new();
List<AstBlock> path = [];
while (block != top)
{

View file

@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
InArguments = inArguments;
OutArguments = outArguments;
Locals = new HashSet<AstOperand>();
Locals = [];
}
public AggregateType GetArgumentType(int index)

View file

@ -343,7 +343,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static AggregateType GetVarTypeFromUses(Operand dest)
{
HashSet<Operand> visited = new();
HashSet<Operand> visited = [];
Queue<Operand> pending = new();

View file

@ -12,9 +12,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public StructuredProgramInfo()
{
Functions = new List<StructuredFunction>();
Functions = [];
IoDefinitions = new HashSet<IoDefinition>();
IoDefinitions = [];
}
}
}

View file

@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.Translation
{
_gpuAccessor = gpuAccessor;
UsedInputAttributesPerPatch = new();
UsedOutputAttributesPerPatch = new();
UsedInputAttributesPerPatch = [];
UsedOutputAttributesPerPatch = [];
}
public void SetInputUserAttribute(int index, int component)

View file

@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Blocks = blocks;
HashSet<BasicBlock> visited = new();
HashSet<BasicBlock> visited = [];
Stack<BasicBlock> blockStack = new();
@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Dictionary<Operand, BasicBlock> labels = new();
List<BasicBlock> blocks = new();
List<BasicBlock> blocks = [];
BasicBlock currentBlock = null;

View file

@ -128,8 +128,8 @@ namespace Ryujinx.Graphics.Shader.Translation
public static FunctionRegisterUsage RunPass(ControlFlowGraph cfg)
{
List<Register> inArguments = new();
List<Register> outArguments = new();
List<Register> inArguments = [];
List<Register> outArguments = [];
// Compute local register inputs and outputs used inside blocks.
RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Length];

View file

@ -19,9 +19,9 @@ namespace Ryujinx.Graphics.Vulkan
private readonly NativeArray<BufferMemoryBarrier> _bufferBarrierBatch = new(MaxBarriersPerCall);
private readonly NativeArray<ImageMemoryBarrier> _imageBarrierBatch = new(MaxBarriersPerCall);
private readonly List<BarrierWithStageFlags<MemoryBarrier, int>> _memoryBarriers = new();
private readonly List<BarrierWithStageFlags<BufferMemoryBarrier, int>> _bufferBarriers = new();
private readonly List<BarrierWithStageFlags<ImageMemoryBarrier, TextureStorage>> _imageBarriers = new();
private readonly List<BarrierWithStageFlags<MemoryBarrier, int>> _memoryBarriers = [];
private readonly List<BarrierWithStageFlags<BufferMemoryBarrier, int>> _bufferBarriers = [];
private readonly List<BarrierWithStageFlags<ImageMemoryBarrier, TextureStorage>> _imageBarriers = [];
private int _queuedBarrierCount;
private enum IncoherentBarrierType

View file

@ -486,7 +486,7 @@ namespace Ryujinx.Graphics.Vulkan
(int keyOffset, int keySize) = FromMirrorKey(key);
if (!(offset + size <= keyOffset || offset >= keyOffset + keySize))
{
toRemove ??= new List<ulong>();
toRemove ??= [];
toRemove.Add(key);
}

View file

@ -249,7 +249,7 @@ namespace Ryujinx.Graphics.Vulkan
{
if (entry.DependencyList == null)
{
entry.DependencyList = new List<Dependency>();
entry.DependencyList = [];
entries[i] = entry;
}
@ -340,7 +340,7 @@ namespace Ryujinx.Graphics.Vulkan
DestroyEntry(entry);
}
(toRemove ??= new List<ulong>()).Add(range.Key);
(toRemove ??= []).Add(range.Key);
}
}
@ -362,7 +362,7 @@ namespace Ryujinx.Graphics.Vulkan
if (!_ranges.TryGetValue(key, out List<Entry> value))
{
value = new List<Entry>();
value = [];
_ranges.Add(key, value);
}

View file

@ -47,8 +47,8 @@ namespace Ryujinx.Graphics.Vulkan
api.AllocateCommandBuffers(device, in allocateInfo, out CommandBuffer);
Dependants = new List<IAuto>();
Waitables = new List<MultiFenceHolder>();
Dependants = [];
Waitables = [];
}
}

View file

@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Vulkan
_hostMemoryApi = hostMemoryApi;
_device = device;
_allocations = new List<HostMemoryAllocation>();
_allocations = [];
_allocationTree = new IntervalTree<ulong, HostMemoryAllocation>();
}

View file

@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Vulkan
public IdList()
{
_list = new List<T>();
_list = [];
_freeMin = 0;
}

View file

@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Vulkan
if (storages == null)
{
storages = new HashSet<TextureStorage>();
storages = [];
for (int index = 0; index < _textureRefs.Length; index++)
{

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Vulkan
_api = api;
_physicalDevice = physicalDevice;
_device = device;
_blockLists = new List<MemoryAllocatorBlockList>();
_blockLists = [];
_blockAlignment = (int)Math.Min(int.MaxValue, MaxDeviceMemoryUsageEstimate / _physicalDevice.PhysicalDeviceProperties.Limits.MaxMemoryAllocationCount);
_lock = new(LockRecursionPolicy.NoRecursion);
}

Some files were not shown because too many files have changed in this diff Show more