[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>
This commit is contained in:
@@ -49,4 +49,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// <param name="detailType">The type to use.</param>
|
||||
void SetDetailType(PerformanceDetailType detailType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// <param name="type">The type to use.</param>
|
||||
void SetEntryType(PerformanceEntryType type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
BaseMemory.Span[(int)ProcessingTimeOffset / 4] = (int)(endTimeNano / 1000) - BaseMemory.Span[(int)StartTimeOffset / 4];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}"),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user