aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio/Renderer/Server/Performance
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-07-02 01:27:18 +0200
committerGitHub <noreply@github.com>2023-07-02 01:27:18 +0200
commit515fc32b21f59298ec8ca45f5d3c36e9d3041084 (patch)
treeac3683b0bc6b6be56e6e4bdf7e37cea0e64a3fd0 /src/Ryujinx.Audio/Renderer/Server/Performance
parent0684b00b3c4d000cf627b9c08a49d7469ae50d04 (diff)
[Ryujinx.Audio] Address dotnet-format issues (#5362)
* 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 CA2208 warnings * Address or silence dotnet format CA2211 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 after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Remove a few unused parameters * 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 * 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 * Fix naming rule violations, remove redundant code and fix build issues * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Address review feedback --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
Diffstat (limited to 'src/Ryujinx.Audio/Renderer/Server/Performance')
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceEntry.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceHeader.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion1.cs10
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion2.cs10
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryAddresses.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion1.cs10
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion2.cs10
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion1.cs14
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion2.cs8
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManager.cs24
-rw-r--r--src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManagerGeneric.cs44
12 files changed, 69 insertions, 69 deletions
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs
index dbe59cb0..ffabf467 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs
@@ -49,4 +49,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// <param name="detailType">The type to use.</param>
void SetDetailType(PerformanceDetailType detailType);
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceEntry.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceEntry.cs
index 9888a4cc..a0178187 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceEntry.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceEntry.cs
@@ -43,4 +43,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// <param name="type">The type to use.</param>
void SetEntryType(PerformanceEntryType type);
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceHeader.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceHeader.cs
index 21876b4b..deacd8cc 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceHeader.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceHeader.cs
@@ -77,4 +77,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// <param name="entryDetailCount">The total count of detailed entries in this frame.</param>
void SetEntryDetailCount(int entryDetailCount);
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion1.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion1.cs
index 22704c0d..a4024607 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion1.cs
@@ -34,22 +34,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
public PerformanceEntryType EntryType;
- public int GetProcessingTime()
+ public readonly int GetProcessingTime()
{
return ProcessingTime;
}
- public int GetProcessingTimeOffset()
+ public readonly int GetProcessingTimeOffset()
{
return 8;
}
- public int GetStartTime()
+ public readonly int GetStartTime()
{
return StartTime;
}
- public int GetStartTimeOffset()
+ public readonly int GetStartTimeOffset()
{
return 4;
}
@@ -69,4 +69,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
NodeId = nodeId;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion2.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion2.cs
index 05ecda9b..f10e2937 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceDetailVersion2.cs
@@ -34,22 +34,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
public PerformanceEntryType EntryType;
- public int GetProcessingTime()
+ public readonly int GetProcessingTime()
{
return ProcessingTime;
}
- public int GetProcessingTimeOffset()
+ public readonly int GetProcessingTimeOffset()
{
return 8;
}
- public int GetStartTime()
+ public readonly int GetStartTime()
{
return StartTime;
}
- public int GetStartTimeOffset()
+ public readonly int GetStartTimeOffset()
{
return 4;
}
@@ -69,4 +69,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
NodeId = nodeId;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryAddresses.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryAddresses.cs
index 1b8d8668..d24b96a2 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryAddresses.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryAddresses.cs
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
BaseMemory.Span[(int)ProcessingTimeOffset / 4] = (int)(endTimeNano / 1000) - BaseMemory.Span[(int)StartTimeOffset / 4];
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion1.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion1.cs
index fa2d3216..2c407670 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion1.cs
@@ -29,22 +29,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
public PerformanceEntryType EntryType;
- public int GetProcessingTime()
+ public readonly int GetProcessingTime()
{
return ProcessingTime;
}
- public int GetProcessingTimeOffset()
+ public readonly int GetProcessingTimeOffset()
{
return 8;
}
- public int GetStartTime()
+ public readonly int GetStartTime()
{
return StartTime;
}
- public int GetStartTimeOffset()
+ public readonly int GetStartTimeOffset()
{
return 4;
}
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
NodeId = nodeId;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion2.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion2.cs
index 49d4b3ce..eb96a314 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceEntryVersion2.cs
@@ -29,22 +29,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
public PerformanceEntryType EntryType;
- public int GetProcessingTime()
+ public readonly int GetProcessingTime()
{
return ProcessingTime;
}
- public int GetProcessingTimeOffset()
+ public readonly int GetProcessingTimeOffset()
{
return 8;
}
- public int GetStartTime()
+ public readonly int GetStartTime()
{
return StartTime;
}
- public int GetStartTimeOffset()
+ public readonly int GetStartTimeOffset()
{
return 4;
}
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
NodeId = nodeId;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion1.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion1.cs
index 5fe6bff0..5aeb703c 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion1.cs
@@ -38,22 +38,22 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
public uint VoiceDropCount;
- public int GetEntryCount()
+ public readonly int GetEntryCount()
{
return EntryCount;
}
- public int GetEntryCountOffset()
+ public readonly int GetEntryCountOffset()
{
return 4;
}
- public int GetEntryDetailCount()
+ public readonly int GetEntryDetailCount()
{
return EntryDetailCount;
}
- public void SetDspRunningBehind(bool isRunningBehind)
+ public readonly void SetDspRunningBehind(bool isRunningBehind)
{
// NOTE: Not present in version 1
}
@@ -68,7 +68,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
EntryDetailCount = entryDetailCount;
}
- public void SetIndex(uint index)
+ public readonly void SetIndex(uint index)
{
// NOTE: Not present in version 1
}
@@ -83,7 +83,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
NextOffset = nextOffset;
}
- public void SetStartRenderingTicks(ulong startTicks)
+ public readonly void SetStartRenderingTicks(ulong startTicks)
{
// NOTE: not present in version 1
}
@@ -98,4 +98,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
VoiceDropCount = voiceCount;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion2.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion2.cs
index a1822968..d6e0ffc8 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceFrameHeaderVersion2.cs
@@ -54,17 +54,17 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
[MarshalAs(UnmanagedType.I1)]
public bool IsDspRunningBehind;
- public int GetEntryCount()
+ public readonly int GetEntryCount()
{
return EntryCount;
}
- public int GetEntryCountOffset()
+ public readonly int GetEntryCountOffset()
{
return 4;
}
- public int GetEntryDetailCount()
+ public readonly int GetEntryDetailCount()
{
return EntryDetailCount;
}
@@ -114,4 +114,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
VoiceDropCount = voiceCount;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManager.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManager.cs
index f996441c..0a035916 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManager.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManager.cs
@@ -22,11 +22,12 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
PerformanceEntryVersion2,
PerformanceDetailVersion2>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
}
- else if (version == 1)
+
+ if (version == 1)
{
return (ulong)PerformanceManagerGeneric<PerformanceFrameHeaderVersion1,
- PerformanceEntryVersion1,
- PerformanceDetailVersion1>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
+ PerformanceEntryVersion1,
+ PerformanceDetailVersion1>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
}
throw new NotImplementedException($"Unknown Performance metrics data format version {version}");
@@ -90,17 +91,12 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
{
uint version = behaviourContext.GetPerformanceMetricsDataFormat();
- switch (version)
+ return version switch
{
- case 1:
- return new PerformanceManagerGeneric<PerformanceFrameHeaderVersion1, PerformanceEntryVersion1, PerformanceDetailVersion1>(performanceBuffer,
- ref parameter);
- case 2:
- return new PerformanceManagerGeneric<PerformanceFrameHeaderVersion2, PerformanceEntryVersion2, PerformanceDetailVersion2>(performanceBuffer,
- ref parameter);
- default:
- throw new NotImplementedException($"Unknown Performance metrics data format version {version}");
- }
+ 1 => new PerformanceManagerGeneric<PerformanceFrameHeaderVersion1, PerformanceEntryVersion1, PerformanceDetailVersion1>(performanceBuffer, ref parameter),
+ 2 => new PerformanceManagerGeneric<PerformanceFrameHeaderVersion2, PerformanceEntryVersion2, PerformanceDetailVersion2>(performanceBuffer, ref parameter),
+ _ => throw new NotImplementedException($"Unknown Performance metrics data format version {version}"),
+ };
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManagerGeneric.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManagerGeneric.cs
index 18e77391..5a70a1bc 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManagerGeneric.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Performance/PerformanceManagerGeneric.cs
@@ -25,20 +25,20 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
private const int MaxFrameDetailCount = 100;
- private Memory<byte> _buffer;
- private Memory<byte> _historyBuffer;
+ private readonly Memory<byte> _buffer;
+ private readonly Memory<byte> _historyBuffer;
- private Memory<byte> CurrentBuffer => _buffer.Slice(0, _frameSize);
- private Memory<byte> CurrentBufferData => CurrentBuffer.Slice(Unsafe.SizeOf<THeader>());
+ private Memory<byte> CurrentBuffer => _buffer[.._frameSize];
+ private Memory<byte> CurrentBufferData => CurrentBuffer[Unsafe.SizeOf<THeader>()..];
private ref THeader CurrentHeader => ref MemoryMarshal.Cast<byte, THeader>(CurrentBuffer.Span)[0];
- private Span<TEntry> Entries => MemoryMarshal.Cast<byte, TEntry>(CurrentBufferData.Span.Slice(0, GetEntriesSize()));
+ private Span<TEntry> Entries => MemoryMarshal.Cast<byte, TEntry>(CurrentBufferData.Span[..GetEntriesSize()]);
private Span<TEntryDetail> EntriesDetail => MemoryMarshal.Cast<byte, TEntryDetail>(CurrentBufferData.Span.Slice(GetEntriesSize(), GetEntriesDetailSize()));
- private int _frameSize;
- private int _availableFrameCount;
- private int _entryCountPerFrame;
+ private readonly int _frameSize;
+ private readonly int _availableFrameCount;
+ private readonly int _entryCountPerFrame;
private int _detailTarget;
private int _entryIndex;
private int _entryDetailIndex;
@@ -56,7 +56,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
_historyFrameIndex = 0;
- _historyBuffer = _buffer.Slice(_frameSize);
+ _historyBuffer = _buffer[_frameSize..];
SetupNewHeader();
}
@@ -130,7 +130,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
Span<TEntry> inputEntries = GetEntriesFromBuffer(_historyBuffer.Span, _indexHistoryRead);
Span<TEntryDetail> inputEntriesDetail = GetEntriesDetailFromBuffer(_historyBuffer.Span, _indexHistoryRead);
- Span<byte> targetSpan = performanceOutput.Slice(nextOffset);
+ Span<byte> targetSpan = performanceOutput[nextOffset..];
// NOTE: We check for the space for two headers for the final blank header.
int requiredSpace = Unsafe.SizeOf<THeader>() + Unsafe.SizeOf<TEntry>() * inputHeader.GetEntryCount()
@@ -146,7 +146,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
nextOffset += Unsafe.SizeOf<THeader>();
- Span<TEntry> outputEntries = MemoryMarshal.Cast<byte, TEntry>(performanceOutput.Slice(nextOffset));
+ Span<TEntry> outputEntries = MemoryMarshal.Cast<byte, TEntry>(performanceOutput[nextOffset..]);
int totalProcessingTime = 0;
@@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
}
}
- Span<TEntryDetail> outputEntriesDetail = MemoryMarshal.Cast<byte, TEntryDetail>(performanceOutput.Slice(nextOffset));
+ Span<TEntryDetail> outputEntriesDetail = MemoryMarshal.Cast<byte, TEntryDetail>(performanceOutput[nextOffset..]);
int effectiveEntryDetailCount = 0;
@@ -198,7 +198,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
if (nextOffset < performanceOutput.Length && (performanceOutput.Length - nextOffset) >= Unsafe.SizeOf<THeader>())
{
- ref THeader outputHeader = ref MemoryMarshal.Cast<byte, THeader>(performanceOutput.Slice(nextOffset))[0];
+ ref THeader outputHeader = ref MemoryMarshal.Cast<byte, THeader>(performanceOutput[nextOffset..])[0];
outputHeader = default;
}
@@ -208,9 +208,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
public override bool GetNextEntry(out PerformanceEntryAddresses performanceEntry, PerformanceEntryType entryType, int nodeId)
{
- performanceEntry = new PerformanceEntryAddresses();
- performanceEntry.BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer);
- performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
+ performanceEntry = new PerformanceEntryAddresses
+ {
+ BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer),
+ EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
+ };
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + Unsafe.SizeOf<TEntry>() * _entryIndex);
@@ -237,9 +239,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
return false;
}
- performanceEntry = new PerformanceEntryAddresses();
- performanceEntry.BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer);
- performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
+ performanceEntry = new PerformanceEntryAddresses
+ {
+ BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer),
+ EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
+ };
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + GetEntriesSize() + Unsafe.SizeOf<IPerformanceDetailEntry>() * _entryDetailIndex);
@@ -301,4 +305,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
}
}
}
-} \ No newline at end of file
+}