aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Memory
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-07-02 02:47:54 +0200
committerGitHub <noreply@github.com>2023-07-02 02:47:54 +0200
commit3b46bb73f781a011705ecbc8a1d3207dfb145829 (patch)
tree1d5d2714c7001775b512bc14ce91a1ebbfc808df /src/Ryujinx.Graphics.Gpu/Memory
parent2457cfc9118a6ebb6008945c919edfd8b46af5e7 (diff)
[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
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Memory')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs19
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs9
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs7
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs16
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs6
12 files changed, 43 insertions, 46 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index dc5037c5..e27c14a1 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -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();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
index d513b7ad..a9ea04ce 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
@@ -35,4 +35,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
Flags = flags;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
index a5a9b75e..99c571ba 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
@@ -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
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
index 07429cfe..4cd3710b 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
@@ -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]);
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
index 03504b11..160a9aff 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
@@ -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;
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
index e763a899..6dcc52cb 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
@@ -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)
{
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs
index 7765e899..c72fa50e 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs
@@ -12,4 +12,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
public IndexType Type;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
index c7a138c9..6af12de1 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
@@ -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;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index cb95b04a..d0b4478e 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -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();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs b/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs
index 4ceb6bcf..1585328f 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs
@@ -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;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs b/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
index 55d697b8..5d2ada56 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
@@ -8,6 +8,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
None,
Buffer,
Texture,
- Pool
+ Pool,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs
index 8f089125..ac334881 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs
@@ -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;
}
-} \ No newline at end of file
+}