[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:
TSRBerry 2023-07-02 02:47:54 +02:00 committed by GitHub
parent 2457cfc911
commit 3b46bb73f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
145 changed files with 1445 additions and 1427 deletions

View file

@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private int _sequenceNumber;
private bool _useGranular;
private readonly bool _useGranular;
private bool _syncActionRegistered;
private int _referenceCount = 1;
@ -80,10 +80,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="baseBuffers">Buffers which this buffer contains, and will inherit tracking handles from</param>
public Buffer(GpuContext context, PhysicalMemory physicalMemory, ulong address, ulong size, IEnumerable<Buffer> baseBuffers = null)
{
_context = context;
_context = context;
_physicalMemory = physicalMemory;
Address = address;
Size = size;
Address = address;
Size = size;
Handle = context.Renderer.CreateBuffer((int)size, baseBuffers?.MaxBy(x => x.Size).Handle ?? BufferHandle.Null);
@ -252,10 +252,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
private void EnsureRangeList()
{
if (_modifiedRanges == null)
{
_modifiedRanges = new BufferModifiedRangeList(_context, this, Flush);
}
_modifiedRanges ??= new BufferModifiedRangeList(_context, this, Flush);
}
/// <summary>
@ -326,7 +323,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_syncActionRegistered = true;
}
Action<ulong, ulong> registerRangeAction = (ulong address, ulong size) =>
void registerRangeAction(ulong address, ulong size)
{
if (_useGranular)
{
@ -336,7 +333,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
_memoryTracking.RegisterAction(_externalFlushDelegate);
}
};
}
EnsureRangeList();
@ -643,4 +640,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
DecrementReferenceCount();
}
}
}
}

View file

@ -35,4 +35,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
Flags = flags;
}
}
}
}

View file

@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
class BufferCache : IDisposable
{
private const int OverlapsBufferInitialCapacity = 10;
private const int OverlapsBufferMaxCapacity = 10000;
private const int OverlapsBufferMaxCapacity = 10000;
private const ulong BufferAlignmentSize = 0x1000;
private const ulong BufferAlignmentMask = BufferAlignmentSize - 1;
@ -246,7 +246,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
Buffer buffer = _bufferOverlaps[index];
address = Math.Min(address, buffer.Address);
address = Math.Min(address, buffer.Address);
endAddress = Math.Max(endAddress, buffer.EndAddress);
lock (_buffers)
@ -257,7 +257,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
ulong newSize = endAddress - address;
Buffer newBuffer = new Buffer(_context, _physicalMemory, address, newSize, _bufferOverlaps.Take(overlapsCount));
Buffer newBuffer = new(_context, _physicalMemory, address, newSize, _bufferOverlaps.Take(overlapsCount));
lock (_buffers)
{
@ -285,7 +285,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
else
{
// No overlap, just create a new buffer.
Buffer buffer = new Buffer(_context, _physicalMemory, address, size);
Buffer buffer = new(_context, _physicalMemory, address, size);
lock (_buffers)
{
@ -446,7 +446,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
/// <param name="dictionary">Dictionary to prune</param>
/// <param name="toDelete">List used to track entries to delete</param>
private void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
private static void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
{
foreach (var entry in dictionary)
{
@ -504,4 +504,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
}
}
}
}

View file

@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private readonly BuffersPerStage[] _gpUniformBuffers;
private BufferHandle _tfInfoBuffer;
private int[] _tfInfoData;
private readonly int[] _tfInfoData;
private bool _gpStorageBuffersDirty;
private bool _gpUniformBuffersDirty;
@ -777,11 +777,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
if (isStorage)
{
_context.Renderer.Pipeline.SetStorageBuffers(ranges.Slice(0, count));
_context.Renderer.Pipeline.SetStorageBuffers(ranges[..count]);
}
else
{
_context.Renderer.Pipeline.SetUniformBuffers(ranges.Slice(0, count));
_context.Renderer.Pipeline.SetUniformBuffers(ranges[..count]);
}
}

View file

@ -1,5 +1,4 @@
using Ryujinx.Common.Logging;
using Ryujinx.Common.Pools;
using Ryujinx.Common.Pools;
using Ryujinx.Memory.Range;
using System;
using System.Collections.Generic;
@ -71,9 +70,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
private const int BackingInitialSize = 8;
private GpuContext _context;
private Buffer _parent;
private Action<ulong, ulong> _flushAction;
private readonly GpuContext _context;
private readonly Buffer _parent;
private readonly Action<ulong, ulong> _flushAction;
private List<BufferMigration> _sources;
private BufferMigration _migrationTarget;

View file

@ -34,11 +34,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// Adds a new counter to the counter cache, or updates a existing one.
/// </summary>
/// <param name="gpuVa">GPU virtual address where the counter will be written in memory</param>
/// <param name="evt">The new counter</param>
public void AddOrUpdate(ulong gpuVa, ICounterEvent evt)
{
int index = BinarySearch(gpuVa);
CounterEntry entry = new CounterEntry(gpuVa, evt);
CounterEntry entry = new(gpuVa, evt);
if (index < 0)
{
@ -127,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_items[index].Event?.Flush();
return true;
}
}
else
{
return false;
@ -168,7 +169,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int middle = left + (range >> 1);
CounterEntry item = _items[middle];
CounterEntry item = _items[middle];
if (item.Address == address)
{

View file

@ -12,4 +12,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
public IndexType Type;
}
}
}

View file

@ -14,15 +14,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
private const int PtLvl0Bits = 14;
private const int PtLvl1Bits = 14;
public const int PtPageBits = 12;
public const int PtPageBits = 12;
private const ulong PtLvl0Size = 1UL << PtLvl0Bits;
private const ulong PtLvl1Size = 1UL << PtLvl1Bits;
public const ulong PageSize = 1UL << PtPageBits;
public const ulong PageSize = 1UL << PtPageBits;
private const ulong PtLvl0Mask = PtLvl0Size - 1;
private const ulong PtLvl1Mask = PtLvl1Size - 1;
public const ulong PageMask = PageSize - 1;
public const ulong PageMask = PageSize - 1;
private const int PtLvl0Bit = PtPageBits + PtLvl1Bits;
private const int PtLvl1Bit = PtPageBits;
@ -203,7 +203,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
Physical.GetSpan(pa, size, tracked).CopyTo(data.Slice(0, size));
Physical.GetSpan(pa, size, tracked).CopyTo(data[..size]);
offset += size;
}
@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
writeCallback(pa, data.Slice(0, size));
writeCallback(pa, data[..size]);
offset += size;
}
@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (pa != PteUnmapped && Physical.IsMapped(pa))
{
Physical.Write(pa, data.Slice(0, size));
Physical.Write(pa, data[..size]);
}
offset += size;
@ -370,7 +370,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// These must run after the mapping completes.
/// </summary>
/// <param name="e">Event with remap actions</param>
private void RunRemapActions(UnmapEventArgs e)
private static void RunRemapActions(UnmapEventArgs e)
{
if (e.RemapActions != null)
{
@ -759,4 +759,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
return pte & 0xffffffffffffffUL;
}
}
}
}

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
class PhysicalMemory : IDisposable
{
private readonly GpuContext _context;
private IVirtualMemoryManagerTracked _cpuMemory;
private readonly IVirtualMemoryManagerTracked _cpuMemory;
private int _referenceCount;
/// <summary>
@ -438,4 +438,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
DecrementReferenceCount();
}
}
}
}

View file

@ -250,7 +250,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
X8C24 = 0xfc,
PitchNoSwizzle = 0xfd,
SmSkedMessage = 0xca,
SmHostMessage = 0xcb
SmHostMessage = 0xcb,
}
static class PteKindExtensions
@ -265,4 +265,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
return kind == PteKind.Pitch || kind == PteKind.PitchNoSwizzle;
}
}
}
}

View file

@ -8,6 +8,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
None,
Buffer,
Texture,
Pool
Pool,
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
public ulong Address;
public ulong Size;
public int Stride;
public int Divisor;
public int Stride;
public int Divisor;
}
}
}