diff --git a/src/Ryujinx.Audio/AudioManager.cs b/src/Ryujinx.Audio/AudioManager.cs
index 9f2a05b09..370d3d098 100644
--- a/src/Ryujinx.Audio/AudioManager.cs
+++ b/src/Ryujinx.Audio/AudioManager.cs
@@ -16,17 +16,17 @@ namespace Ryujinx.Audio
///
/// Events signaled when the driver played audio buffers.
///
- private ManualResetEvent[] _updateRequiredEvents;
+ private readonly ManualResetEvent[] _updateRequiredEvents;
///
/// Action to execute when the driver played audio buffers.
///
- private Action[] _actions;
+ private readonly Action[] _actions;
///
/// The worker thread in charge of handling sessions update.
///
- private Thread _workerThread;
+ private readonly Thread _workerThread;
private bool _isRunning;
@@ -44,7 +44,7 @@ namespace Ryujinx.Audio
_workerThread = new Thread(Update)
{
- Name = "AudioManager.Worker"
+ Name = "AudioManager.Worker",
};
}
@@ -115,6 +115,7 @@ namespace Ryujinx.Audio
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -129,4 +130,4 @@ namespace Ryujinx.Audio
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/Common/BackendHelper.cs b/src/Ryujinx.Audio/Backends/Common/BackendHelper.cs
index 30db340fa..124d8364f 100644
--- a/src/Ryujinx.Audio/Backends/Common/BackendHelper.cs
+++ b/src/Ryujinx.Audio/Backends/Common/BackendHelper.cs
@@ -23,4 +23,4 @@ namespace Ryujinx.Audio.Backends.Common
return bufferSize / GetSampleSize(format) / channelCount;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs
index d17303cd3..05dd2162a 100644
--- a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs
+++ b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs
@@ -163,4 +163,4 @@ namespace Ryujinx.Audio.Backends.Common
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/Common/HardwareDeviceSessionOutputBase.cs b/src/Ryujinx.Audio/Backends/Common/HardwareDeviceSessionOutputBase.cs
index 6fb3bee02..5599c0827 100644
--- a/src/Ryujinx.Audio/Backends/Common/HardwareDeviceSessionOutputBase.cs
+++ b/src/Ryujinx.Audio/Backends/Common/HardwareDeviceSessionOutputBase.cs
@@ -66,14 +66,11 @@ namespace Ryujinx.Audio.Backends.Common
return false;
}
- if (buffer.Data == null)
- {
- buffer.Data = samples;
- }
+ buffer.Data ??= samples;
return true;
}
public virtual void UnregisterBuffer(AudioBuffer buffer) { }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs b/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs
index 22919f1e1..3f3806c3e 100644
--- a/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs
+++ b/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs
@@ -6,14 +6,13 @@ using Ryujinx.Common.Logging;
using Ryujinx.Memory;
using System;
using System.Threading;
-
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
namespace Ryujinx.Audio.Backends.CompatLayer
{
public class CompatLayerHardwareDeviceDriver : IHardwareDeviceDriver
{
- private IHardwareDeviceDriver _realDriver;
+ private readonly IHardwareDeviceDriver _realDriver;
public static bool IsSupported => true;
@@ -24,6 +23,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
public void Dispose()
{
+ GC.SuppressFinalize(this);
_realDriver.Dispose();
}
@@ -49,7 +49,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
6 => SelectHardwareChannelCount(2),
2 => SelectHardwareChannelCount(1),
1 => throw new ArgumentException("No valid channel configuration found!"),
- _ => throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}")
+ _ => throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}"),
};
}
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer
{
Logger.Warning?.Print(LogClass.Audio, "The selected audio backend doesn't support audio input, fallback to dummy...");
- return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
+ return new DummyHardwareDeviceSessionInput(this, memoryManager);
}
throw new NotImplementedException();
@@ -138,12 +138,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
if (direction == Direction.Input)
{
- Logger.Warning?.Print(LogClass.Audio, $"The selected audio backend doesn't support the requested audio input configuration, fallback to dummy...");
+ Logger.Warning?.Print(LogClass.Audio, "The selected audio backend doesn't support the requested audio input configuration, fallback to dummy...");
// TODO: We currently don't support audio input upsampling/downsampling, implement this.
realSession.Dispose();
- return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
+ return new DummyHardwareDeviceSessionInput(this, memoryManager);
}
// It must be a HardwareDeviceSessionOutputBase.
@@ -183,4 +183,4 @@ namespace Ryujinx.Audio.Backends.CompatLayer
return direction == Direction.Input || direction == Direction.Output;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceSession.cs b/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceSession.cs
index f22a7a690..a9acabec9 100644
--- a/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceSession.cs
+++ b/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceSession.cs
@@ -8,9 +8,9 @@ namespace Ryujinx.Audio.Backends.CompatLayer
{
class CompatLayerHardwareDeviceSession : HardwareDeviceSessionOutputBase
{
- private HardwareDeviceSessionOutputBase _realSession;
- private SampleFormat _userSampleFormat;
- private uint _userChannelCount;
+ private readonly HardwareDeviceSessionOutputBase _realSession;
+ private readonly SampleFormat _userSampleFormat;
+ private readonly uint _userChannelCount;
public CompatLayerHardwareDeviceSession(HardwareDeviceSessionOutputBase realSession, SampleFormat userSampleFormat, uint userChannelCount) : base(realSession.MemoryManager, realSession.RequestedSampleFormat, realSession.RequestedSampleRate, userChannelCount)
{
@@ -116,11 +116,11 @@ namespace Ryujinx.Audio.Backends.CompatLayer
samples = MemoryMarshal.Cast(samplesPCM16).ToArray();
}
- AudioBuffer fakeBuffer = new AudioBuffer
+ AudioBuffer fakeBuffer = new()
{
BufferTag = buffer.BufferTag,
DataPointer = buffer.DataPointer,
- DataSize = (ulong)samples.Length
+ DataSize = (ulong)samples.Length,
};
bool result = _realSession.RegisterBuffer(fakeBuffer, samples);
@@ -159,4 +159,4 @@ namespace Ryujinx.Audio.Backends.CompatLayer
return _realSession.WasBufferFullyConsumed(buffer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/CompatLayer/Downmixing.cs b/src/Ryujinx.Audio/Backends/CompatLayer/Downmixing.cs
index 6959c1588..ffd427a5e 100644
--- a/src/Ryujinx.Audio/Backends/CompatLayer/Downmixing.cs
+++ b/src/Ryujinx.Audio/Backends/CompatLayer/Downmixing.cs
@@ -31,18 +31,18 @@ namespace Ryujinx.Audio.Backends.CompatLayer
private const int Minus6dBInQ15 = (int)(0.501f * RawQ15One);
private const int Minus12dBInQ15 = (int)(0.251f * RawQ15One);
- private static readonly int[] DefaultSurroundToStereoCoefficients = new int[4]
+ private static readonly int[] _defaultSurroundToStereoCoefficients = new int[4]
{
RawQ15One,
Minus3dBInQ15,
Minus12dBInQ15,
- Minus3dBInQ15
+ Minus3dBInQ15,
};
- private static readonly int[] DefaultStereoToMonoCoefficients = new int[2]
+ private static readonly int[] _defaultStereoToMonoCoefficients = new int[2]
{
Minus6dBInQ15,
- Minus6dBInQ15
+ Minus6dBInQ15,
};
private const int SurroundChannelCount = 6;
@@ -114,12 +114,12 @@ namespace Ryujinx.Audio.Backends.CompatLayer
public static short[] DownMixStereoToMono(ReadOnlySpan data)
{
- return DownMixStereoToMono(DefaultStereoToMonoCoefficients, data);
+ return DownMixStereoToMono(_defaultStereoToMonoCoefficients, data);
}
public static short[] DownMixSurroundToStereo(ReadOnlySpan data)
{
- return DownMixSurroundToStereo(DefaultSurroundToStereoCoefficients, data);
+ return DownMixSurroundToStereo(_defaultSurroundToStereoCoefficients, data);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs
index 641640f0e..bac21c448 100644
--- a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs
+++ b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs
@@ -1,16 +1,16 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Integration;
using Ryujinx.Memory;
+using System;
using System.Threading;
-
using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
namespace Ryujinx.Audio.Backends.Dummy
{
public class DummyHardwareDeviceDriver : IHardwareDeviceDriver
{
- private ManualResetEvent _updateRequiredEvent;
- private ManualResetEvent _pauseEvent;
+ private readonly ManualResetEvent _updateRequiredEvent;
+ private readonly ManualResetEvent _pauseEvent;
public static bool IsSupported => true;
@@ -36,10 +36,8 @@ namespace Ryujinx.Audio.Backends.Dummy
{
return new DummyHardwareDeviceSessionOutput(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
}
- else
- {
- return new DummyHardwareDeviceSessionInput(this, memoryManager, sampleFormat, sampleRate, channelCount);
- }
+
+ return new DummyHardwareDeviceSessionInput(this, memoryManager);
}
public ManualResetEvent GetUpdateRequiredEvent()
@@ -54,6 +52,7 @@ namespace Ryujinx.Audio.Backends.Dummy
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -86,4 +85,4 @@ namespace Ryujinx.Audio.Backends.Dummy
return channelCount == 1 || channelCount == 2 || channelCount == 6;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionInput.cs b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionInput.cs
index 845713a19..f51a63393 100644
--- a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionInput.cs
+++ b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionInput.cs
@@ -8,10 +8,10 @@ namespace Ryujinx.Audio.Backends.Dummy
class DummyHardwareDeviceSessionInput : IHardwareDeviceSession
{
private float _volume;
- private IHardwareDeviceDriver _manager;
- private IVirtualMemoryManager _memoryManager;
+ private readonly IHardwareDeviceDriver _manager;
+ private readonly IVirtualMemoryManager _memoryManager;
- public DummyHardwareDeviceSessionInput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount)
+ public DummyHardwareDeviceSessionInput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager)
{
_volume = 1.0f;
_manager = manager;
@@ -64,4 +64,4 @@ namespace Ryujinx.Audio.Backends.Dummy
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionOutput.cs b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionOutput.cs
index 8e2c949ec..1c248faaa 100644
--- a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionOutput.cs
+++ b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceSessionOutput.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Audio.Backends.Dummy
internal class DummyHardwareDeviceSessionOutput : HardwareDeviceSessionOutputBase
{
private float _volume;
- private IHardwareDeviceDriver _manager;
+ private readonly IHardwareDeviceDriver _manager;
private ulong _playedSampleCount;
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Backends.Dummy
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/AudioBuffer.cs b/src/Ryujinx.Audio/Common/AudioBuffer.cs
index b79401b77..87a7d5f32 100644
--- a/src/Ryujinx.Audio/Common/AudioBuffer.cs
+++ b/src/Ryujinx.Audio/Common/AudioBuffer.cs
@@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Common
///
public byte[] Data;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/AudioDeviceSession.cs b/src/Ryujinx.Audio/Common/AudioDeviceSession.cs
index 0191f7ccd..a0e04c80d 100644
--- a/src/Ryujinx.Audio/Common/AudioDeviceSession.cs
+++ b/src/Ryujinx.Audio/Common/AudioDeviceSession.cs
@@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Common
///
/// Array of all buffers currently used or released.
///
- private AudioBuffer[] _buffers;
+ private readonly AudioBuffer[] _buffers;
///
/// The server index inside (appended but not queued to device driver).
@@ -58,17 +58,17 @@ namespace Ryujinx.Audio.Common
///
/// The released buffer event.
///
- private IWritableEvent _bufferEvent;
+ private readonly IWritableEvent _bufferEvent;
///
/// The session on the device driver.
///
- private IHardwareDeviceSession _hardwareDeviceSession;
+ private readonly IHardwareDeviceSession _hardwareDeviceSession;
///
/// Max number of buffers that can be registered to the device driver at a time.
///
- private uint _bufferRegisteredLimit;
+ private readonly uint _bufferRegisteredLimit;
///
/// Create a new .
@@ -311,9 +311,9 @@ namespace Ryujinx.Audio.Common
return false;
}
- public bool AppendUacBuffer(AudioBuffer buffer, uint handle)
+ public static bool AppendUacBuffer(AudioBuffer buffer, uint handle)
{
- // NOTE: On hardware, there is another RegisterBuffer method taking an handle.
+ // NOTE: On hardware, there is another RegisterBuffer method taking a handle.
// This variant of the call always return false (stubbed?) as a result this logic will never succeed.
return false;
@@ -425,10 +425,8 @@ namespace Ryujinx.Audio.Common
{
return 0;
}
- else
- {
- return _hardwareDeviceSession.GetPlayedSampleCount();
- }
+
+ return _hardwareDeviceSession.GetPlayedSampleCount();
}
///
@@ -515,4 +513,4 @@ namespace Ryujinx.Audio.Common
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/AudioDeviceState.cs b/src/Ryujinx.Audio/Common/AudioDeviceState.cs
index b3f968da2..8705e802e 100644
--- a/src/Ryujinx.Audio/Common/AudioDeviceState.cs
+++ b/src/Ryujinx.Audio/Common/AudioDeviceState.cs
@@ -13,6 +13,6 @@ namespace Ryujinx.Audio.Common
///
/// The audio device is stopped.
///
- Stopped
+ Stopped,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/AudioInputConfiguration.cs b/src/Ryujinx.Audio/Common/AudioInputConfiguration.cs
index d3cfdd47b..078c3a394 100644
--- a/src/Ryujinx.Audio/Common/AudioInputConfiguration.cs
+++ b/src/Ryujinx.Audio/Common/AudioInputConfiguration.cs
@@ -24,6 +24,6 @@ namespace Ryujinx.Audio.Common
///
/// Reserved/unused.
///
- private ushort _reserved;
+ private readonly ushort _reserved;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/AudioOutputConfiguration.cs b/src/Ryujinx.Audio/Common/AudioOutputConfiguration.cs
index e17e17576..594f12250 100644
--- a/src/Ryujinx.Audio/Common/AudioOutputConfiguration.cs
+++ b/src/Ryujinx.Audio/Common/AudioOutputConfiguration.cs
@@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Common
///
public AudioDeviceState AudioOutState;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/AudioUserBuffer.cs b/src/Ryujinx.Audio/Common/AudioUserBuffer.cs
index 50ab67fa3..bb71165ff 100644
--- a/src/Ryujinx.Audio/Common/AudioUserBuffer.cs
+++ b/src/Ryujinx.Audio/Common/AudioUserBuffer.cs
@@ -33,4 +33,4 @@ namespace Ryujinx.Audio.Common
///
public ulong DataOffset;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Common/SampleFormat.cs b/src/Ryujinx.Audio/Common/SampleFormat.cs
index 901410a24..39e525e87 100644
--- a/src/Ryujinx.Audio/Common/SampleFormat.cs
+++ b/src/Ryujinx.Audio/Common/SampleFormat.cs
@@ -38,6 +38,6 @@ namespace Ryujinx.Audio.Common
///
/// ADPCM sample format. (Also known as GC-ADPCM)
///
- Adpcm = 6
+ Adpcm = 6,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Constants.cs b/src/Ryujinx.Audio/Constants.cs
index cde87744f..eb5b39013 100644
--- a/src/Ryujinx.Audio/Constants.cs
+++ b/src/Ryujinx.Audio/Constants.cs
@@ -172,4 +172,4 @@ namespace Ryujinx.Audio
0.707f,
};
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Input/AudioInputManager.cs b/src/Ryujinx.Audio/Input/AudioInputManager.cs
index 63cbe031f..4d1796c96 100644
--- a/src/Ryujinx.Audio/Input/AudioInputManager.cs
+++ b/src/Ryujinx.Audio/Input/AudioInputManager.cs
@@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Input
///
/// The session ids allocation table.
///
- private int[] _sessionIds;
+ private readonly int[] _sessionIds;
///
/// The device driver.
@@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Input
///
/// The session instances.
///
- private AudioInputSystem[] _sessions;
+ private readonly AudioInputSystem[] _sessions;
///
/// The count of active sessions.
@@ -166,6 +166,7 @@ namespace Ryujinx.Audio.Input
///
/// If true, filter disconnected devices
/// The list of all audio inputs name
+#pragma warning disable CA1822 // Mark member as static
public string[] ListAudioIns(bool filtered)
{
if (filtered)
@@ -173,8 +174,9 @@ namespace Ryujinx.Audio.Input
// TODO: Detect if the driver supports audio input
}
- return new string[] { Constants.DefaultDeviceInputName };
+ return new[] { Constants.DefaultDeviceInputName };
}
+#pragma warning restore CA1822
///
/// Open a new .
@@ -205,7 +207,7 @@ namespace Ryujinx.Audio.Input
IHardwareDeviceSession deviceSession = _deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Input, memoryManager, sampleFormat, parameter.SampleRate, parameter.ChannelCount);
- AudioInputSystem audioIn = new AudioInputSystem(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
+ AudioInputSystem audioIn = new(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
ResultCode result = audioIn.Initialize(inputDeviceName, sampleFormat, ref parameter, sessionId);
@@ -238,6 +240,8 @@ namespace Ryujinx.Audio.Input
public void Dispose()
{
+ GC.SuppressFinalize(this);
+
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@@ -263,4 +267,4 @@ namespace Ryujinx.Audio.Input
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Input/AudioInputSystem.cs b/src/Ryujinx.Audio/Input/AudioInputSystem.cs
index 33364e28a..34623b34f 100644
--- a/src/Ryujinx.Audio/Input/AudioInputSystem.cs
+++ b/src/Ryujinx.Audio/Input/AudioInputSystem.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Input
///
/// The session the .
///
- private AudioDeviceSession _session;
+ private readonly AudioDeviceSession _session;
///
/// The target device name of the .
@@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Input
///
/// The owning this.
///
- private AudioInputManager _manager;
+ private readonly AudioInputManager _manager;
///
/// The lock of the parent.
@@ -90,11 +90,13 @@ namespace Ryujinx.Audio.Input
{
return ResultCode.DeviceNotFound;
}
- else if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
+
+ if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
{
return ResultCode.UnsupportedSampleRate;
}
- else if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
+
+ if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
{
return ResultCode.UnsupportedChannelConfiguration;
}
@@ -185,11 +187,11 @@ namespace Ryujinx.Audio.Input
{
lock (_parentLock)
{
- AudioBuffer buffer = new AudioBuffer
+ AudioBuffer buffer = new()
{
BufferTag = bufferTag,
DataPointer = userBuffer.Data,
- DataSize = userBuffer.DataSize
+ DataSize = userBuffer.DataSize,
};
if (_session.AppendBuffer(buffer))
@@ -213,14 +215,14 @@ namespace Ryujinx.Audio.Input
{
lock (_parentLock)
{
- AudioBuffer buffer = new AudioBuffer
+ AudioBuffer buffer = new()
{
BufferTag = bufferTag,
DataPointer = userBuffer.Data,
- DataSize = userBuffer.DataSize
+ DataSize = userBuffer.DataSize,
};
- if (_session.AppendUacBuffer(buffer, handle))
+ if (AudioDeviceSession.AppendUacBuffer(buffer, handle))
{
return ResultCode.Success;
}
@@ -373,6 +375,8 @@ namespace Ryujinx.Audio.Input
public void Dispose()
{
+ GC.SuppressFinalize(this);
+
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@@ -389,4 +393,4 @@ namespace Ryujinx.Audio.Input
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Integration/HardwareDeviceImpl.cs b/src/Ryujinx.Audio/Integration/HardwareDeviceImpl.cs
index 552f1ab24..576954b96 100644
--- a/src/Ryujinx.Audio/Integration/HardwareDeviceImpl.cs
+++ b/src/Ryujinx.Audio/Integration/HardwareDeviceImpl.cs
@@ -6,12 +6,12 @@ namespace Ryujinx.Audio.Integration
{
public class HardwareDeviceImpl : IHardwareDevice
{
- private IHardwareDeviceSession _session;
- private uint _channelCount;
- private uint _sampleRate;
+ private readonly IHardwareDeviceSession _session;
+ private readonly uint _channelCount;
+ private readonly uint _sampleRate;
private uint _currentBufferTag;
- private byte[] _buffer;
+ private readonly byte[] _buffer;
public HardwareDeviceImpl(IHardwareDeviceDriver deviceDriver, uint channelCount, uint sampleRate, float volume)
{
@@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Integration
DataSize = (ulong)_buffer.Length,
});
- _currentBufferTag = _currentBufferTag % 4;
+ _currentBufferTag %= 4;
}
public void SetVolume(float volume)
@@ -61,6 +61,7 @@ namespace Ryujinx.Audio.Integration
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -72,4 +73,4 @@ namespace Ryujinx.Audio.Integration
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Integration/IHardwareDevice.cs b/src/Ryujinx.Audio/Integration/IHardwareDevice.cs
index 300de8c5d..f9ade9dbc 100644
--- a/src/Ryujinx.Audio/Integration/IHardwareDevice.cs
+++ b/src/Ryujinx.Audio/Integration/IHardwareDevice.cs
@@ -52,4 +52,4 @@ namespace Ryujinx.Audio.Integration
return channelCount != Constants.ChannelCountMax;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Integration/IHardwareDeviceDriver.cs b/src/Ryujinx.Audio/Integration/IHardwareDeviceDriver.cs
index 4ed179519..9c812fb9a 100644
--- a/src/Ryujinx.Audio/Integration/IHardwareDeviceDriver.cs
+++ b/src/Ryujinx.Audio/Integration/IHardwareDeviceDriver.cs
@@ -13,7 +13,7 @@ namespace Ryujinx.Audio.Integration
public enum Direction
{
Input,
- Output
+ Output,
}
IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount, float volume = 1f);
@@ -33,4 +33,4 @@ namespace Ryujinx.Audio.Integration
return this;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Integration/IHardwareDeviceSession.cs b/src/Ryujinx.Audio/Integration/IHardwareDeviceSession.cs
index 400daec00..f29c109cb 100644
--- a/src/Ryujinx.Audio/Integration/IHardwareDeviceSession.cs
+++ b/src/Ryujinx.Audio/Integration/IHardwareDeviceSession.cs
@@ -25,4 +25,4 @@ namespace Ryujinx.Audio.Integration
void PrepareToClose();
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Integration/IWritableEvent.cs b/src/Ryujinx.Audio/Integration/IWritableEvent.cs
index 9a12e3d28..a3b3bc0bc 100644
--- a/src/Ryujinx.Audio/Integration/IWritableEvent.cs
+++ b/src/Ryujinx.Audio/Integration/IWritableEvent.cs
@@ -15,4 +15,4 @@ namespace Ryujinx.Audio.Integration
///
void Clear();
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Output/AudioOutputManager.cs b/src/Ryujinx.Audio/Output/AudioOutputManager.cs
index bc2fc6f43..5232357bb 100644
--- a/src/Ryujinx.Audio/Output/AudioOutputManager.cs
+++ b/src/Ryujinx.Audio/Output/AudioOutputManager.cs
@@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Output
///
/// The session ids allocation table.
///
- private int[] _sessionIds;
+ private readonly int[] _sessionIds;
///
/// The device driver.
@@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Output
///
/// The session instances.
///
- private AudioOutputSystem[] _sessions;
+ private readonly AudioOutputSystem[] _sessions;
///
/// The count of active sessions.
@@ -165,10 +165,12 @@ namespace Ryujinx.Audio.Output
/// Get the list of all audio outputs name.
///
/// The list of all audio outputs name
+#pragma warning disable CA1822 // Mark member as static
public string[] ListAudioOuts()
{
- return new string[] { Constants.DefaultDeviceOutputName };
+ return new[] { Constants.DefaultDeviceOutputName };
}
+#pragma warning restore CA1822
///
/// Open a new .
@@ -182,6 +184,7 @@ namespace Ryujinx.Audio.Output
/// The user configuration
/// The applet resource user id of the application
/// The process handle of the application
+ /// The volume level to request
/// A reporting an error or a success
public ResultCode OpenAudioOut(out string outputDeviceName,
out AudioOutputConfiguration outputConfiguration,
@@ -200,7 +203,7 @@ namespace Ryujinx.Audio.Output
IHardwareDeviceSession deviceSession = _deviceDriver.OpenDeviceSession(IHardwareDeviceDriver.Direction.Output, memoryManager, sampleFormat, parameter.SampleRate, parameter.ChannelCount, volume);
- AudioOutputSystem audioOut = new AudioOutputSystem(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
+ AudioOutputSystem audioOut = new(this, _lock, deviceSession, _sessionsBufferEvents[sessionId]);
ResultCode result = audioOut.Initialize(inputDeviceName, sampleFormat, ref parameter, sessionId);
@@ -268,6 +271,8 @@ namespace Ryujinx.Audio.Output
public void Dispose()
{
+ GC.SuppressFinalize(this);
+
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@@ -293,4 +298,4 @@ namespace Ryujinx.Audio.Output
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Output/AudioOutputSystem.cs b/src/Ryujinx.Audio/Output/AudioOutputSystem.cs
index 8378f33f8..f9b9bdcf1 100644
--- a/src/Ryujinx.Audio/Output/AudioOutputSystem.cs
+++ b/src/Ryujinx.Audio/Output/AudioOutputSystem.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Output
///
/// The session the .
///
- private AudioDeviceSession _session;
+ private readonly AudioDeviceSession _session;
///
/// The target device name of the .
@@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Output
///
/// The owning this.
///
- private AudioOutputManager _manager;
+ private readonly AudioOutputManager _manager;
///
/// THe lock of the parent.
@@ -90,11 +90,13 @@ namespace Ryujinx.Audio.Output
{
return ResultCode.DeviceNotFound;
}
- else if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
+
+ if (configuration.SampleRate != 0 && configuration.SampleRate != Constants.TargetSampleRate)
{
return ResultCode.UnsupportedSampleRate;
}
- else if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
+
+ if (configuration.ChannelCount != 0 && configuration.ChannelCount != 1 && configuration.ChannelCount != 2 && configuration.ChannelCount != 6)
{
return ResultCode.UnsupportedChannelConfiguration;
}
@@ -185,11 +187,11 @@ namespace Ryujinx.Audio.Output
{
lock (_parentLock)
{
- AudioBuffer buffer = new AudioBuffer
+ AudioBuffer buffer = new()
{
BufferTag = bufferTag,
DataPointer = userBuffer.Data,
- DataSize = userBuffer.DataSize
+ DataSize = userBuffer.DataSize,
};
if (_session.AppendBuffer(buffer))
@@ -346,6 +348,8 @@ namespace Ryujinx.Audio.Output
public void Dispose()
{
+ GC.SuppressFinalize(this);
+
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@@ -362,4 +366,4 @@ namespace Ryujinx.Audio.Output
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/AuxiliaryBufferAddresses.cs b/src/Ryujinx.Audio/Renderer/Common/AuxiliaryBufferAddresses.cs
index 966474052..b7b97d5d8 100644
--- a/src/Ryujinx.Audio/Renderer/Common/AuxiliaryBufferAddresses.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/AuxiliaryBufferAddresses.cs
@@ -10,4 +10,4 @@ namespace Ryujinx.Audio.Renderer.Common
public ulong ReturnBufferInfo;
public ulong ReturnBufferInfoBase;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/BehaviourParameter.cs b/src/Ryujinx.Audio/Renderer/Common/BehaviourParameter.cs
index 270f84d5b..b0963c935 100644
--- a/src/Ryujinx.Audio/Renderer/Common/BehaviourParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/BehaviourParameter.cs
@@ -16,7 +16,7 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// Reserved/padding.
///
- private uint _padding;
+ private readonly uint _padding;
///
/// The flags given controlling behaviour of the audio renderer
@@ -38,7 +38,7 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// Reserved/padding.
///
- private uint _padding;
+ private readonly uint _padding;
///
/// Extra information given with the
@@ -47,4 +47,4 @@ namespace Ryujinx.Audio.Renderer.Common
public ulong ExtraErrorInfo;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/EdgeMatrix.cs b/src/Ryujinx.Audio/Renderer/Common/EdgeMatrix.cs
index 24a9350fc..3beb62399 100644
--- a/src/Ryujinx.Audio/Renderer/Common/EdgeMatrix.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/EdgeMatrix.cs
@@ -147,4 +147,4 @@ namespace Ryujinx.Audio.Renderer.Common
return _nodeCount;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/EffectType.cs b/src/Ryujinx.Audio/Renderer/Common/EffectType.cs
index 7128db4ce..7c8713b12 100644
--- a/src/Ryujinx.Audio/Renderer/Common/EffectType.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/EffectType.cs
@@ -55,4 +55,4 @@ namespace Ryujinx.Audio.Renderer.Common
///
Compressor,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/MemoryPoolUserState.cs b/src/Ryujinx.Audio/Renderer/Common/MemoryPoolUserState.cs
index 590731c3b..6d835879c 100644
--- a/src/Ryujinx.Audio/Renderer/Common/MemoryPoolUserState.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/MemoryPoolUserState.cs
@@ -38,6 +38,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// The memory pool is released. (client side only)
///
- Released = 6
+ Released = 6,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/NodeIdHelper.cs b/src/Ryujinx.Audio/Renderer/Common/NodeIdHelper.cs
index a999e3ad1..76fba54b6 100644
--- a/src/Ryujinx.Audio/Renderer/Common/NodeIdHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/NodeIdHelper.cs
@@ -25,4 +25,4 @@ namespace Ryujinx.Audio.Renderer.Common
return (nodeId >> 16) & 0xFFF;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/NodeIdType.cs b/src/Ryujinx.Audio/Renderer/Common/NodeIdType.cs
index 69b58f6bc..b226da14f 100644
--- a/src/Ryujinx.Audio/Renderer/Common/NodeIdType.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/NodeIdType.cs
@@ -28,6 +28,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// Performance monitoring related node id (performance commands)
///
- Performance = 15
+ Performance = 15,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/NodeStates.cs b/src/Ryujinx.Audio/Renderer/Common/NodeStates.cs
index 45748d606..75290a741 100644
--- a/src/Ryujinx.Audio/Renderer/Common/NodeStates.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/NodeStates.cs
@@ -53,17 +53,17 @@ namespace Ryujinx.Audio.Renderer.Common
}
private int _nodeCount;
- private EdgeMatrix _discovered;
- private EdgeMatrix _finished;
+ private readonly EdgeMatrix _discovered;
+ private readonly EdgeMatrix _finished;
private Memory _resultArray;
- private Stack _stack;
+ private readonly Stack _stack;
private int _tsortResultIndex;
private enum NodeState : byte
{
Unknown,
Discovered,
- Finished
+ Finished,
}
public NodeStates()
@@ -88,16 +88,16 @@ namespace Ryujinx.Audio.Renderer.Common
int edgeMatrixWorkBufferSize = EdgeMatrix.GetWorkBufferSize(nodeCount);
- _discovered.Initialize(nodeStatesWorkBuffer.Slice(0, edgeMatrixWorkBufferSize), nodeCount);
+ _discovered.Initialize(nodeStatesWorkBuffer[..edgeMatrixWorkBufferSize], nodeCount);
_finished.Initialize(nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize, edgeMatrixWorkBufferSize), nodeCount);
- nodeStatesWorkBuffer = nodeStatesWorkBuffer.Slice(edgeMatrixWorkBufferSize * 2);
+ nodeStatesWorkBuffer = nodeStatesWorkBuffer[(edgeMatrixWorkBufferSize * 2)..];
- _resultArray = SpanMemoryManager.Cast(nodeStatesWorkBuffer.Slice(0, sizeof(int) * nodeCount));
+ _resultArray = SpanMemoryManager.Cast(nodeStatesWorkBuffer[..(sizeof(int) * nodeCount)]);
- nodeStatesWorkBuffer = nodeStatesWorkBuffer.Slice(sizeof(int) * nodeCount);
+ nodeStatesWorkBuffer = nodeStatesWorkBuffer[(sizeof(int) * nodeCount)..];
- Memory stackWorkBuffer = SpanMemoryManager.Cast(nodeStatesWorkBuffer.Slice(0, Stack.CalcBufferSize(nodeCount * nodeCount)));
+ Memory stackWorkBuffer = SpanMemoryManager.Cast(nodeStatesWorkBuffer[..Stack.CalcBufferSize(nodeCount * nodeCount)]);
_stack.Reset(stackWorkBuffer, nodeCount * nodeCount);
}
@@ -120,7 +120,8 @@ namespace Ryujinx.Audio.Renderer.Common
return NodeState.Discovered;
}
- else if (_finished.Test(index))
+
+ if (_finished.Test(index))
{
Debug.Assert(!_discovered.Test(index));
@@ -158,7 +159,7 @@ namespace Ryujinx.Audio.Renderer.Common
public ReadOnlySpan GetTsortResult()
{
- return _resultArray.Span.Slice(0, _tsortResultIndex);
+ return _resultArray.Span[.._tsortResultIndex];
}
public bool Sort(EdgeMatrix edgeMatrix)
@@ -226,4 +227,4 @@ namespace Ryujinx.Audio.Renderer.Common
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/PerformanceDetailType.cs b/src/Ryujinx.Audio/Renderer/Common/PerformanceDetailType.cs
index 805d55183..bde32a709 100644
--- a/src/Ryujinx.Audio/Renderer/Common/PerformanceDetailType.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/PerformanceDetailType.cs
@@ -15,6 +15,6 @@ namespace Ryujinx.Audio.Renderer.Common
PcmFloat,
Limiter,
CaptureBuffer,
- Compressor
+ Compressor,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/PerformanceEntryType.cs b/src/Ryujinx.Audio/Renderer/Common/PerformanceEntryType.cs
index bde72aaed..e32095e62 100644
--- a/src/Ryujinx.Audio/Renderer/Common/PerformanceEntryType.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/PerformanceEntryType.cs
@@ -6,6 +6,6 @@ namespace Ryujinx.Audio.Renderer.Common
Voice,
SubMix,
FinalMix,
- Sink
+ Sink,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/PlayState.cs b/src/Ryujinx.Audio/Renderer/Common/PlayState.cs
index 4a6929e03..a83d16afb 100644
--- a/src/Ryujinx.Audio/Renderer/Common/PlayState.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/PlayState.cs
@@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// The user request the voice to be paused.
///
- Pause
+ Pause,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/ReverbEarlyMode.cs b/src/Ryujinx.Audio/Renderer/Common/ReverbEarlyMode.cs
index aa7685621..c7443cc49 100644
--- a/src/Ryujinx.Audio/Renderer/Common/ReverbEarlyMode.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/ReverbEarlyMode.cs
@@ -28,6 +28,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// No early reflection.
///
- Disabled
+ Disabled,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/ReverbLateMode.cs b/src/Ryujinx.Audio/Renderer/Common/ReverbLateMode.cs
index 8aa88165a..78f91cf08 100644
--- a/src/Ryujinx.Audio/Renderer/Common/ReverbLateMode.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/ReverbLateMode.cs
@@ -33,6 +33,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// Max delay. (used for delay line limits)
///
- Limit = NoDelay
+ Limit = NoDelay,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/SinkType.cs b/src/Ryujinx.Audio/Renderer/Common/SinkType.cs
index 2e17201e7..5a08df4e1 100644
--- a/src/Ryujinx.Audio/Renderer/Common/SinkType.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/SinkType.cs
@@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// The sink is a circular buffer.
///
- CircularBuffer
+ CircularBuffer,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/UpdateDataHeader.cs b/src/Ryujinx.Audio/Renderer/Common/UpdateDataHeader.cs
index 70dbfa947..7efe3b02b 100644
--- a/src/Ryujinx.Audio/Renderer/Common/UpdateDataHeader.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/UpdateDataHeader.cs
@@ -1,3 +1,4 @@
+using Ryujinx.Common.Memory;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Common
@@ -19,7 +20,9 @@ namespace Ryujinx.Audio.Renderer.Common
public uint Unknown24;
public uint RenderInfoSize;
- private unsafe fixed int _reserved[4];
+#pragma warning disable IDE0051, CS0169 // Remove unused field
+ private Array4 _reserved;
+#pragma warning restore IDE0051, CS0169
public uint TotalSize;
@@ -30,4 +33,4 @@ namespace Ryujinx.Audio.Renderer.Common
TotalSize = (uint)Unsafe.SizeOf();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/VoiceUpdateState.cs b/src/Ryujinx.Audio/Renderer/Common/VoiceUpdateState.cs
index f52c2f4c4..608381af1 100644
--- a/src/Ryujinx.Audio/Renderer/Common/VoiceUpdateState.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/VoiceUpdateState.cs
@@ -101,4 +101,4 @@ namespace Ryujinx.Audio.Renderer.Common
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/WaveBuffer.cs b/src/Ryujinx.Audio/Renderer/Common/WaveBuffer.cs
index 0d00e8384..5109d3fa0 100644
--- a/src/Ryujinx.Audio/Renderer/Common/WaveBuffer.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/WaveBuffer.cs
@@ -1,5 +1,4 @@
using System.Runtime.InteropServices;
-
using DspAddr = System.UInt64;
namespace Ryujinx.Audio.Renderer.Common
@@ -77,6 +76,6 @@ namespace Ryujinx.Audio.Renderer.Common
///
/// Padding/Reserved.
///
- private ushort _padding;
+ private readonly ushort _padding;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs b/src/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs
index f35dbec7f..54673f2f6 100644
--- a/src/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs
+++ b/src/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs
@@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Common
if (size != 0)
{
- ulong alignedOffset = BitUtils.AlignUp(Offset, (ulong)align);
+ ulong alignedOffset = BitUtils.AlignUp(Offset, (ulong)align);
if (alignedOffset + size <= (ulong)BackingMemory.Length)
{
@@ -32,7 +32,7 @@ namespace Ryujinx.Audio.Renderer.Common
Offset = alignedOffset + size;
// Clear the memory to be sure that is does not contain any garbage.
- result.Span.Fill(0);
+ result.Span.Clear();
return result;
}
@@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Common
public static ulong GetTargetSize(ulong currentSize, ulong count, int align) where T : unmanaged
{
- return BitUtils.AlignUp(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf() * count;
+ return BitUtils.AlignUp(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf() * count;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs b/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
index 90692b004..91956fda6 100644
--- a/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
+++ b/src/Ryujinx.Audio/Renderer/Device/VirtualDevice.cs
@@ -12,11 +12,11 @@ namespace Ryujinx.Audio.Renderer.Device
///
public static readonly VirtualDevice[] Devices = new VirtualDevice[5]
{
- new VirtualDevice("AudioStereoJackOutput", 2, true),
- new VirtualDevice("AudioBuiltInSpeakerOutput", 2, false),
- new VirtualDevice("AudioTvOutput", 6, false),
- new VirtualDevice("AudioUsbDeviceOutput", 2, true),
- new VirtualDevice("AudioExternalOutput", 6, true),
+ new("AudioStereoJackOutput", 2, true),
+ new("AudioBuiltInSpeakerOutput", 2, false),
+ new("AudioTvOutput", 6, false),
+ new("AudioUsbDeviceOutput", 2, true),
+ new("AudioExternalOutput", 6, true),
};
///
@@ -86,4 +86,4 @@ namespace Ryujinx.Audio.Renderer.Device
return Name;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSession.cs b/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSession.cs
index db35d26d2..09fa71eda 100644
--- a/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSession.cs
+++ b/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSession.cs
@@ -24,4 +24,4 @@ namespace Ryujinx.Audio.Renderer.Device
Device = virtualDevice;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs b/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs
index 696af90fa..4ad70619e 100644
--- a/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs
+++ b/src/Ryujinx.Audio/Renderer/Device/VirtualDeviceSessionRegistry.cs
@@ -11,13 +11,15 @@ namespace Ryujinx.Audio.Renderer.Device
///
/// The session registry, used to store the sessions of a given AppletResourceId.
///
- private Dictionary _sessionsRegistry = new Dictionary();
+ private readonly Dictionary _sessionsRegistry = new();
///
/// The default .
///
/// This is used when the USB device is the default one on older revision.
+#pragma warning disable CA1822 // Mark member as static
public VirtualDevice DefaultDevice => VirtualDevice.Devices[0];
+#pragma warning restore CA1822
///
/// The current active .
@@ -76,4 +78,4 @@ namespace Ryujinx.Audio.Renderer.Device
return virtualDeviceSession;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs
index 2680dcb1e..5cb4509ff 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs
@@ -12,7 +12,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
private const int SamplesPerFrame = 14;
private const int NibblesPerFrame = SamplesPerFrame + 2;
private const int BytesPerFrame = 8;
+#pragma warning disable IDE0051 // Remove unused private member
private const int BitsPerFrame = BytesPerFrame * 8;
+#pragma warning restore IDE0051
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint GetAdpcmDataSize(int sampleCount)
@@ -64,10 +66,14 @@ namespace Ryujinx.Audio.Renderer.Dsp
private static short Saturate(int value)
{
if (value > short.MaxValue)
+ {
value = short.MaxValue;
+ }
if (value < short.MinValue)
+ {
value = short.MinValue;
+ }
return (short)value;
}
@@ -109,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
ReadOnlySpan targetInput;
- targetInput = input.Slice(nibbles / 2);
+ targetInput = input[(nibbles / 2)..];
while (remaining > 0)
{
@@ -213,4 +219,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return decodedCount;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs b/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
index 899c2ef97..9c885b2cf 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
Start,
Stop,
RenderStart,
- RenderEnd
+ RenderEnd,
}
private class RendererSession
@@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
private long _lastTime;
private long _playbackEnds;
- private ManualResetEvent _event;
+ private readonly ManualResetEvent _event;
private ManualResetEvent _pauseEvent;
@@ -45,6 +45,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
_event = new ManualResetEvent(false);
}
+#pragma warning disable IDE0051 // Remove unused private member
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
{
// Get the real device driver (In case the compat layer is on top of it).
@@ -54,12 +55,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return 6;
}
- else
- {
- // NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
- return 2;
- }
+
+ // NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
+ return 2;
}
+#pragma warning restore IDE0051
public void Start(IHardwareDeviceDriver deviceDriver, float volume)
{
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
CommandList = commands,
RenderingLimit = renderingLimit,
- AppletResourceId = appletResourceId
+ AppletResourceId = appletResourceId,
};
}
@@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
_workerThread = new Thread(Work)
{
- Name = "AudioProcessor.Worker"
+ Name = "AudioProcessor.Worker",
};
_workerThread.Start();
@@ -260,6 +260,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -271,4 +272,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs
index 98460ff1a..1a51a1fbd 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs
@@ -80,4 +80,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs
index 1fe6069f7..51a12b4e7 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -29,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public DecodingBehaviour DecodingBehaviour { get; }
- public AdpcmDataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory state, ushort outputBufferIndex, int nodeId)
+ public AdpcmDataSourceCommandVersion1(ref VoiceState serverState, Memory state, ushort outputBufferIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -57,7 +59,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.Adpcm,
@@ -72,4 +74,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs
index 5c3c0324b..7ed32800f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs
@@ -155,7 +155,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (readResult != context.SampleCount)
{
- outputBuffer.Slice((int)readResult, (int)context.SampleCount - (int)readResult).Fill(0);
+ outputBuffer[(int)readResult..(int)context.SampleCount].Clear();
}
}
else
@@ -170,4 +170,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs
index b994c1cb9..f56dd70e3 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs
@@ -48,4 +48,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
BiquadFilterHelper.ProcessBiquadFilter(ref _parameter, ref state, outputBuffer, inputBuffer, context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs
index da1cb2546..01bff1e7d 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs
@@ -133,4 +133,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs
index 9e653e804..f0f85b0b2 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs
@@ -21,4 +21,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.ClearBuffers();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs
index 2cbed9c2b..19a9576f7 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs
@@ -71,7 +71,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return (IntPtr)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
}
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(index), index, null);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -149,7 +149,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public void Dispose()
{
+ GC.SuppressFinalize(this);
_buffersMemoryHandle.Dispose();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs
index 9ce181b17..098a04a04 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs
@@ -32,6 +32,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
LimiterVersion2,
GroupedBiquadFilter,
CaptureBuffer,
- Compressor
+ Compressor,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs
index 34231e614..01291852e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs
@@ -1,6 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.Effect;
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
@@ -51,11 +52,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (_parameter.Status == Server.Effect.UsageState.Invalid)
+ if (_parameter.Status == UsageState.Invalid)
{
state = new CompressorState(ref _parameter);
}
- else if (_parameter.Status == Server.Effect.UsageState.New)
+ else if (_parameter.Status == UsageState.New)
{
state.UpdateParameter(ref _parameter);
}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs
index 7237fddf6..3f6aa8390 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.CopyBuffer(OutputBufferIndex, InputBufferIndex);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs
index c1503b6a0..e82d403bf 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -37,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public SampleRateConversionQuality SrcQuality { get; }
- public DataSourceVersion2Command(ref Server.Voice.VoiceState serverState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
+ public DataSourceVersion2Command(ref VoiceState serverState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -72,24 +74,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)
{
- switch (sampleFormat)
+ return sampleFormat switch
{
- case SampleFormat.Adpcm:
- return CommandType.AdpcmDataSourceVersion2;
- case SampleFormat.PcmInt16:
- return CommandType.PcmInt16DataSourceVersion2;
- case SampleFormat.PcmFloat:
- return CommandType.PcmFloatDataSourceVersion2;
- default:
- throw new NotImplementedException($"{sampleFormat}");
- }
+ SampleFormat.Adpcm => CommandType.AdpcmDataSourceVersion2,
+ SampleFormat.PcmInt16 => CommandType.PcmInt16DataSourceVersion2,
+ SampleFormat.PcmFloat => CommandType.PcmFloatDataSourceVersion2,
+ _ => throw new NotImplementedException($"{sampleFormat}"),
+ };
}
public void Process(CommandList context)
{
Span outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat,
@@ -99,10 +97,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ExtraParameterSize = ExtraParameterSize,
ChannelIndex = (int)ChannelIndex,
ChannelCount = (int)ChannelCount,
- SrcQuality = SrcQuality
+ SrcQuality = SrcQuality,
};
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
index e7e179389..003806cf7 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
@@ -87,18 +87,18 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
- Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain, delayFeedbackCrossGain,
+ Matrix2x2 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain,
delayFeedbackCrossGain, delayFeedbackBaseGain);
for (int i = 0; i < sampleCount; i++)
{
- Vector2 channelInput = new Vector2
+ Vector2 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
};
- Vector2 delayLineValues = new Vector2()
+ Vector2 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
@@ -124,7 +124,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
- Matrix4x4 delayFeedback = new Matrix4x4(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
+ Matrix4x4 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain,
delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain,
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
@@ -132,20 +132,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int i = 0; i < sampleCount; i++)
{
- Vector4 channelInput = new Vector4
+ Vector4 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
Z = *((float*)inputBuffers[2] + i) * 64,
- W = *((float*)inputBuffers[3] + i) * 64
+ W = *((float*)inputBuffers[3] + i) * 64,
};
- Vector4 delayLineValues = new Vector4()
+ Vector4 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
Z = state.DelayLines[2].Read(),
- W = state.DelayLines[3].Read()
+ W = state.DelayLines[3].Read(),
};
Vector4 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
@@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
- Matrix6x6 delayFeedback = new Matrix6x6(delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f,
+ Matrix6x6 delayFeedback = new(delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f,
0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain, 0.0f, 0.0f, delayFeedbackCrossGain,
delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, feedbackGain, 0.0f, 0.0f,
@@ -180,24 +180,24 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int i = 0; i < sampleCount; i++)
{
- Vector6 channelInput = new Vector6
+ Vector6 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
Z = *((float*)inputBuffers[2] + i) * 64,
W = *((float*)inputBuffers[3] + i) * 64,
V = *((float*)inputBuffers[4] + i) * 64,
- U = *((float*)inputBuffers[5] + i) * 64
+ U = *((float*)inputBuffers[5] + i) * 64,
};
- Vector6 delayLineValues = new Vector6
+ Vector6 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
Z = state.DelayLines[2].Read(),
W = state.DelayLines[3].Read(),
V = state.DelayLines[4].Read(),
- U = state.DelayLines[5].Read()
+ U = state.DelayLines[5].Read(),
};
Vector6 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs
index 1dba56e6c..ff38f38ca 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs
@@ -55,17 +55,15 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return -depopValue;
}
- else
+
+ for (int i = 0; i < sampleCount; i++)
{
- for (int i = 0; i < sampleCount; i++)
- {
- depopValue = FloatingPointHelper.MultiplyRoundDown(Decay, depopValue);
+ depopValue = FloatingPointHelper.MultiplyRoundDown(Decay, depopValue);
- buffer[i] += depopValue;
- }
-
- return depopValue;
+ buffer[i] += depopValue;
}
+
+ return depopValue;
}
public void Process(CommandList context)
@@ -89,4 +87,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs
index d02f7c121..c64bbdc57 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs
@@ -54,4 +54,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs
index 79cefcc53..8997b0dbd 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs
@@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.ClearBuffer(OutputBufferIndices[5]);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs
index b190cc10d..7af851bdc 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs
@@ -14,11 +14,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public uint EstimatedProcessingTime { get; set; }
- private BiquadFilterParameter[] _parameters;
- private Memory _biquadFilterStates;
- private int _inputBufferIndex;
- private int _outputBufferIndex;
- private bool[] _isInitialized;
+ private readonly BiquadFilterParameter[] _parameters;
+ private readonly Memory _biquadFilterStates;
+ private readonly int _inputBufferIndex;
+ private readonly int _outputBufferIndex;
+ private readonly bool[] _isInitialized;
public GroupedBiquadFilterCommand(int baseIndex, ReadOnlySpan filters, Memory biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan isInitialized, int nodeId)
{
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs
index d281e6e9f..34a62c58d 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs
@@ -17,4 +17,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs
index a464ad704..3ba0b5884 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs
@@ -1,5 +1,6 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
@@ -50,13 +51,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (Parameter.Status == Server.Effect.UsageState.Invalid)
+ if (Parameter.Status == UsageState.Invalid)
{
state = new LimiterState(ref _parameter, WorkBuffer);
}
- else if (Parameter.Status == Server.Effect.UsageState.New)
+ else if (Parameter.Status == UsageState.New)
{
- state.UpdateParameter(ref _parameter);
+ LimiterState.UpdateParameter(ref _parameter);
}
}
@@ -141,4 +142,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs
index 950de97b8..682098670 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs
@@ -1,6 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@@ -54,13 +55,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (Parameter.Status == Server.Effect.UsageState.Invalid)
+ if (Parameter.Status == UsageState.Invalid)
{
state = new LimiterState(ref _parameter, WorkBuffer);
}
- else if (Parameter.Status == Server.Effect.UsageState.New)
+ else if (Parameter.Status == UsageState.New)
{
- state.UpdateParameter(ref _parameter);
+ LimiterState.UpdateParameter(ref _parameter);
}
}
@@ -160,4 +161,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs
index 2616bda57..c701f80eb 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs
@@ -134,4 +134,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessMix(outputBuffer, inputBuffer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs
index 76a1aba25..f77a233e1 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs
@@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
State.Span[0].LastSamples[LastSampleIndex] = ProcessMixRamp(outputBuffer, inputBuffer, (int)context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs
index e348e3588..3c7dd63b2 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private float ProcessMixRampGrouped(Span outputBuffer, ReadOnlySpan inputBuffer, float volume0, float volume1, int sampleCount)
+ private static float ProcessMixRampGrouped(Span outputBuffer, ReadOnlySpan inputBuffer, float volume0, float volume1, int sampleCount)
{
float ramp = (volume1 - volume0) / sampleCount;
float volume = volume0;
@@ -88,4 +88,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs
index 7cec7d2ab..585edc058 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public Memory State { get; }
public DecodingBehaviour DecodingBehaviour { get; }
- public PcmFloatDataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
+ public PcmFloatDataSourceCommandVersion1(ref VoiceState serverState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.PcmFloat,
@@ -71,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs
index dfe9814fe..6f01219f3 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public Memory State { get; }
public DecodingBehaviour DecodingBehaviour { get; }
- public PcmInt16DataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
+ public PcmInt16DataSourceCommandVersion1(ref VoiceState serverState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.PcmInt16,
@@ -71,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs
index d3e3f8056..d3d2ee306 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Invalid,
Start,
- End
+ End,
}
public bool Enabled { get; set; }
@@ -44,4 +44,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
index d1177e60f..8cdd4843b 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
@@ -9,21 +9,21 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
public class Reverb3dCommand : ICommand
{
- private static readonly int[] OutputEarlyIndicesTableMono = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableMono = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableMono = new int[1] { 0 };
+ private static readonly int[] _outputEarlyIndicesTableMono = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableMono = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableMono = new int[1] { 0 };
- private static readonly int[] OutputEarlyIndicesTableStereo = new int[20] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableStereo = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableStereo = new int[2] { 0, 1 };
+ private static readonly int[] _outputEarlyIndicesTableStereo = new int[20] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableStereo = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableStereo = new int[2] { 0, 1 };
- private static readonly int[] OutputEarlyIndicesTableQuadraphonic = new int[20] { 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableQuadraphonic = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
+ private static readonly int[] _outputEarlyIndicesTableQuadraphonic = new int[20] { 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableQuadraphonic = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
- private static readonly int[] OutputEarlyIndicesTableSurround = new int[40] { 4, 5, 0, 5, 0, 5, 1, 5, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 5, 1, 5, 1, 5, 1, 5, 0, 5, 0, 5, 0, 5, 0, 5, 3, 5, 3, 5, 3, 5 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableSurround = new int[40] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
+ private static readonly int[] _outputEarlyIndicesTableSurround = new int[40] { 4, 5, 0, 5, 0, 5, 1, 5, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 5, 1, 5, 1, 5, 1, 5, 0, 5, 0, 5, 0, 5, 0, 5, 3, 5, 3, 5, 3, 5 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableSurround = new int[40] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
public bool Enabled { get; set; }
@@ -73,25 +73,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dMono(ref Reverb3dState state, ReadOnlySpan outputBuffers, ReadOnlySpan inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableMono, TargetEarlyDelayLineIndicesTableMono, TargetOutputFeedbackIndicesTableMono);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableMono, _targetEarlyDelayLineIndicesTableMono, _targetOutputFeedbackIndicesTableMono);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dStereo(ref Reverb3dState state, ReadOnlySpan outputBuffers, ReadOnlySpan inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableStereo, TargetEarlyDelayLineIndicesTableStereo, TargetOutputFeedbackIndicesTableStereo);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableStereo, _targetEarlyDelayLineIndicesTableStereo, _targetOutputFeedbackIndicesTableStereo);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dQuadraphonic(ref Reverb3dState state, ReadOnlySpan outputBuffers, ReadOnlySpan inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableQuadraphonic, TargetEarlyDelayLineIndicesTableQuadraphonic, TargetOutputFeedbackIndicesTableQuadraphonic);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableQuadraphonic, _targetEarlyDelayLineIndicesTableQuadraphonic, _targetOutputFeedbackIndicesTableQuadraphonic);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dSurround(ref Reverb3dState state, ReadOnlySpan outputBuffers, ReadOnlySpan inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableSurround, TargetEarlyDelayLineIndicesTableSurround, TargetOutputFeedbackIndicesTableSurround);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableSurround, _targetEarlyDelayLineIndicesTableSurround, _targetOutputFeedbackIndicesTableSurround);
}
private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan outputBuffers, ReadOnlySpan inputBuffers, uint sampleCount, ReadOnlySpan outputEarlyIndicesTable, ReadOnlySpan targetEarlyDelayLineIndicesTable, ReadOnlySpan targetOutputFeedbackIndicesTable)
@@ -109,7 +109,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
{
- outputValues.Fill(0);
+ outputValues.Clear();
float tapOut = state.PreDelayLine.TapUnsafe(state.ReflectionDelayTime, DelayLineSampleIndexOffset);
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
index cd08b838a..f494b3028 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
@@ -1,5 +1,6 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
@@ -8,25 +9,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
public class ReverbCommand : ICommand
{
- private static readonly int[] OutputEarlyIndicesTableMono = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableMono = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- private static readonly int[] OutputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
- private static readonly int[] TargetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
+ private static readonly int[] _outputEarlyIndicesTableMono = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableMono = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ private static readonly int[] _outputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
- private static readonly int[] OutputEarlyIndicesTableStereo = new int[10] { 0, 0, 1, 1, 0, 1, 0, 0, 1, 1 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableStereo = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- private static readonly int[] OutputIndicesTableStereo = new int[4] { 0, 0, 1, 1 };
- private static readonly int[] TargetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 1 };
+ private static readonly int[] _outputEarlyIndicesTableStereo = new int[10] { 0, 0, 1, 1, 0, 1, 0, 0, 1, 1 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableStereo = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ private static readonly int[] _outputIndicesTableStereo = new int[4] { 0, 0, 1, 1 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 1 };
- private static readonly int[] OutputEarlyIndicesTableQuadraphonic = new int[10] { 0, 0, 1, 1, 0, 1, 2, 2, 3, 3 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableQuadraphonic = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- private static readonly int[] OutputIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
- private static readonly int[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
+ private static readonly int[] _outputEarlyIndicesTableQuadraphonic = new int[10] { 0, 0, 1, 1, 0, 1, 2, 2, 3, 3 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableQuadraphonic = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ private static readonly int[] _outputIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
- private static readonly int[] OutputEarlyIndicesTableSurround = new int[20] { 0, 5, 0, 5, 1, 5, 1, 5, 4, 5, 4, 5, 2, 5, 2, 5, 3, 5, 3, 5 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableSurround = new int[20] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 };
- private static readonly int[] OutputIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, 4, 5 };
- private static readonly int[] TargetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
+ private static readonly int[] _outputEarlyIndicesTableSurround = new int[20] { 0, 5, 0, 5, 1, 5, 1, 5, 4, 5, 4, 5, 2, 5, 2, 5, 3, 5, 3, 5 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableSurround = new int[20] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 };
+ private static readonly int[] _outputIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, 4, 5 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
public bool Enabled { get; set; }
@@ -82,10 +83,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableMono,
- TargetEarlyDelayLineIndicesTableMono,
- TargetOutputFeedbackIndicesTableMono,
- OutputIndicesTableMono);
+ _outputEarlyIndicesTableMono,
+ _targetEarlyDelayLineIndicesTableMono,
+ _targetOutputFeedbackIndicesTableMono,
+ _outputIndicesTableMono);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -95,10 +96,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableStereo,
- TargetEarlyDelayLineIndicesTableStereo,
- TargetOutputFeedbackIndicesTableStereo,
- OutputIndicesTableStereo);
+ _outputEarlyIndicesTableStereo,
+ _targetEarlyDelayLineIndicesTableStereo,
+ _targetOutputFeedbackIndicesTableStereo,
+ _outputIndicesTableStereo);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -108,10 +109,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableQuadraphonic,
- TargetEarlyDelayLineIndicesTableQuadraphonic,
- TargetOutputFeedbackIndicesTableQuadraphonic,
- OutputIndicesTableQuadraphonic);
+ _outputEarlyIndicesTableQuadraphonic,
+ _targetEarlyDelayLineIndicesTableQuadraphonic,
+ _targetOutputFeedbackIndicesTableQuadraphonic,
+ _outputIndicesTableQuadraphonic);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -121,10 +122,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableSurround,
- TargetEarlyDelayLineIndicesTableSurround,
- TargetOutputFeedbackIndicesTableSurround,
- OutputIndicesTableSurround);
+ _outputEarlyIndicesTableSurround,
+ _targetEarlyDelayLineIndicesTableSurround,
+ _targetOutputFeedbackIndicesTableSurround,
+ _outputIndicesTableSurround);
}
private unsafe void ProcessReverbGeneric(ref ReverbState state, ReadOnlySpan outputBuffers, ReadOnlySpan inputBuffers, uint sampleCount, ReadOnlySpan outputEarlyIndicesTable, ReadOnlySpan targetEarlyDelayLineIndicesTable, ReadOnlySpan targetOutputFeedbackIndicesTable, ReadOnlySpan outputIndicesTable)
@@ -143,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
{
- outputValues.Fill(0);
+ outputValues.Clear();
for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
{
@@ -263,11 +264,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (Parameter.Status == Server.Effect.UsageState.Invalid)
+ if (Parameter.Status == UsageState.Invalid)
{
state = new ReverbState(ref _parameter, WorkBuffer, IsLongSizePreDelaySupported);
}
- else if (Parameter.Status == Server.Effect.UsageState.New)
+ else if (Parameter.Status == UsageState.New)
{
state.UpdateParameter(ref _parameter);
}
@@ -276,4 +277,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessReverb(context, ref state);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
index 0870d59ce..8882500cd 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
@@ -67,4 +67,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs
index 0628f6d81..5deeb07f1 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs
@@ -134,4 +134,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessVolume(outputBuffer, inputBuffer);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs
index 5c0c88451..bffbcbc63 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessVolumeRamp(outputBuffer, inputBuffer, (int)context.SampleCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
index 12e0f13ff..98657bd13 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
@@ -76,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
if (!info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
{
- voiceState.Pitch.AsSpan().Slice(0, pitchMaxLength).CopyTo(tempBuffer);
+ voiceState.Pitch.AsSpan()[..pitchMaxLength].CopyTo(tempBuffer);
tempBufferIndex += pitchMaxLength;
}
@@ -107,7 +107,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
voiceState.LoopContext = memoryManager.Read(waveBuffer.Context);
}
- Span tempSpan = tempBuffer.Slice(tempBufferIndex + y);
+ Span tempSpan = tempBuffer[(tempBufferIndex + y)..];
int decodedSampleCount = -1;
@@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
decodedSampleCount = PcmHelper.Decode(tempSpan, waveBufferPcmFloat, targetSampleStartOffset, targetSampleEndOffset, info.ChannelIndex, info.ChannelCount);
break;
default:
- Logger.Error?.Print(LogClass.AudioRenderer, $"Unsupported sample format " + info.SampleFormat);
+ Logger.Error?.Print(LogClass.AudioRenderer, "Unsupported sample format " + info.SampleFormat);
break;
}
@@ -220,7 +220,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
- Span outputSpanInt = MemoryMarshal.Cast(outputBuffer.Slice(i));
+ Span outputSpanInt = MemoryMarshal.Cast(outputBuffer[i..]);
if (info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
{
@@ -231,9 +231,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
else
{
- Span tempSpan = tempBuffer.Slice(tempBufferIndex + y);
+ Span tempSpan = tempBuffer[(tempBufferIndex + y)..];
- tempSpan.Slice(0, sampleCountToDecode - y).Fill(0);
+ tempSpan[..(sampleCountToDecode - y)].Clear();
ToFloat(outputBuffer, outputSpanInt, sampleCountToProcess);
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs
index 37e066bf0..7253fdc92 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs
@@ -49,4 +49,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return _delayLine.Tap(sampleIndex);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs
index 56890ebe8..8a3590a20 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs
@@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public class DelayLine : IDelayLine
{
- private float[] _workBuffer;
- private uint _sampleRate;
+ private readonly float[] _workBuffer;
+ private readonly uint _sampleRate;
private uint _currentSampleIndex;
private uint _lastSampleIndex;
@@ -75,4 +75,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return TapUnsafe(sampleIndex, -1);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs
index a2ac9d265..ed8e7cfe0 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs
@@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public class DelayLine3d : IDelayLine
{
- private float[] _workBuffer;
- private uint _sampleRate;
+ private readonly float[] _workBuffer;
+ private readonly uint _sampleRate;
private uint _currentSampleIndex;
private uint _lastSampleIndex;
@@ -73,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return TapUnsafe(sampleIndex, -1);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs
index 78e46bf96..253400a5a 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs
@@ -1,6 +1,4 @@
-using System.Runtime.CompilerServices;
-
-namespace Ryujinx.Audio.Renderer.Dsp.Effect
+namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public struct ExponentialMovingAverage
{
@@ -11,7 +9,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
_mean = mean;
}
- public float Read()
+ public readonly float Read()
{
return _mean;
}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
index fd902525e..b408e294d 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
@@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return (uint)MathF.Round(sampleRate * delayTime);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
index 280e47c0c..d519de333 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
@@ -36,4 +36,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return ToInt(value + half, qBits);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs
index 6645e20a3..b231dbb6a 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs
@@ -1,5 +1,4 @@
using System;
-using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp
@@ -39,7 +38,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return 1.0f;
}
- else if (x <= -5.3f)
+
+ if (x <= -5.3f)
{
return 0.0f;
}
@@ -112,4 +112,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return MathF.Sin(DegreesToRadians(value));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs
index 0233a8d71..d209c515b 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs
@@ -1,5 +1,4 @@
using System;
-using System.Numerics;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp
@@ -62,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
for (int i = 0; i < input.Length; i++)
{
- output[i] = ((int)input[i]) << 16;
+ output[i] = input[i] << 16;
}
}
@@ -127,4 +126,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return (short)value;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs
index 7873c4d27..e44e9f41e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs
@@ -1,6 +1,5 @@
using System;
using System.Linq;
-using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
@@ -11,8 +10,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
public static class ResamplerHelper
{
#region "Default Quality Lookup Tables"
- private static short[] _normalCurveLut0 = new short[]
- {
+ private static readonly short[] _normalCurveLut0 = {
6600, 19426, 6722, 3, 6479, 19424, 6845, 9, 6359, 19419, 6968, 15, 6239, 19412, 7093, 22,
6121, 19403, 7219, 28, 6004, 19391, 7345, 34, 5888, 19377, 7472, 41, 5773, 19361, 7600, 48,
5659, 19342, 7728, 55, 5546, 19321, 7857, 62, 5434, 19298, 7987, 69, 5323, 19273, 8118, 77,
@@ -44,11 +42,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
109, 8646, 19148, 4890, 101, 8513, 19183, 4997, 92, 8381, 19215, 5104, 84, 8249, 19245, 5213,
77, 8118, 19273, 5323, 69, 7987, 19298, 5434, 62, 7857, 19321, 5546, 55, 7728, 19342, 5659,
48, 7600, 19361, 5773, 41, 7472, 19377, 5888, 34, 7345, 19391, 6004, 28, 7219, 19403, 6121,
- 22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600
+ 22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600,
};
- private static short[] _normalCurveLut1 = new short[]
- {
+ private static readonly short[] _normalCurveLut1 = {
-68, 32639, 69, -5, -200, 32630, 212, -15, -328, 32613, 359, -26, -450, 32586, 512, -36,
-568, 32551, 669, -47, -680, 32507, 832, -58, -788, 32454, 1000, -69, -891, 32393, 1174, -80,
-990, 32323, 1352, -92, -1084, 32244, 1536, -103, -1173, 32157, 1724, -115, -1258, 32061, 1919, -128,
@@ -80,11 +77,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
-180, 2747, 31593, -1554, -167, 2532, 31723, -1486, -153, 2322, 31844, -1414, -140, 2118, 31956, -1338,
-128, 1919, 32061, -1258, -115, 1724, 32157, -1173, -103, 1536, 32244, -1084, -92, 1352, 32323, -990,
-80, 1174, 32393, -891, -69, 1000, 32454, -788, -58, 832, 32507, -680, -47, 669, 32551, -568,
- -36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68
+ -36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68,
};
- private static short[] _normalCurveLut2 = new short[]
- {
+ private static readonly short[] _normalCurveLut2 = {
3195, 26287, 3329, -32, 3064, 26281, 3467, -34, 2936, 26270, 3608, -38, 2811, 26253, 3751, -42,
2688, 26230, 3897, -46, 2568, 26202, 4046, -50, 2451, 26169, 4199, -54, 2338, 26130, 4354, -58,
2227, 26085, 4512, -63, 2120, 26035, 4673, -67, 2015, 25980, 4837, -72, 1912, 25919, 5004, -76,
@@ -116,13 +112,12 @@ namespace Ryujinx.Audio.Renderer.Dsp
-98, 5701, 25621, 1531, -92, 5522, 25704, 1622, -87, 5347, 25780, 1716, -81, 5174, 25852, 1813,
-76, 5004, 25919, 1912, -72, 4837, 25980, 2015, -67, 4673, 26035, 2120, -63, 4512, 26085, 2227,
-58, 4354, 26130, 2338, -54, 4199, 26169, 2451, -50, 4046, 26202, 2568, -46, 3897, 26230, 2688,
- -42, 3751, 26253, 2811, -38, 3608, 26270, 2936, -34, 3467, 26281, 3064, -32, 3329, 26287, 3195
+ -42, 3751, 26253, 2811, -38, 3608, 26270, 2936, -34, 3467, 26281, 3064, -32, 3329, 26287, 3195,
};
#endregion
#region "High Quality Lookup Tables"
- private static short[] _highCurveLut0 = new short[]
- {
+ private static readonly short[] _highCurveLut0 = {
-582, -23, 8740, 16386, 8833, 8, -590, 0, -573, -54, 8647, 16385, 8925, 40, -598, -1,
-565, -84, 8555, 16383, 9018, 72, -606, -1, -557, -113, 8462, 16379, 9110, 105, -614, -2,
-549, -142, 8370, 16375, 9203, 139, -622, -2, -541, -170, 8277, 16369, 9295, 173, -630, -3,
@@ -189,8 +184,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
-1, -598, 40, 8925, 16385, 8647, -54, -573, 0, -590, 8, 8833, 16386, 8740, -23, -582,
};
- private static short[] _highCurveLut1 = new short[]
- {
+ private static readonly short[] _highCurveLut1 = {
-12, 47, -134, 32767, 81, -16, 2, 0, -26, 108, -345, 32760, 301, -79, 17, -1,
-40, 168, -552, 32745, 526, -144, 32, -2, -53, 226, -753, 32723, 755, -210, 47, -3,
-66, 284, -950, 32694, 989, -277, 63, -5, -78, 340, -1143, 32658, 1226, -346, 79, -6,
@@ -257,8 +251,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
-1, 17, -79, 301, 32760, -345, 108, -26, 0, 2, -16, 81, 32767, -134, 47, -12,
};
- private static short[] _highCurveLut2 = new short[]
- {
+ private static readonly short[] _highCurveLut2 = {
418, -2538, 6118, 24615, 6298, -2563, 417, 0, 420, -2512, 5939, 24611, 6479, -2588, 415, 1,
421, -2485, 5761, 24605, 6662, -2612, 412, 2, 422, -2458, 5585, 24595, 6846, -2635, 409, 3,
423, -2430, 5410, 24582, 7030, -2658, 406, 4, 423, -2402, 5236, 24565, 7216, -2680, 403, 5,
@@ -326,13 +319,13 @@ namespace Ryujinx.Audio.Renderer.Dsp
};
#endregion
- private static float[] _normalCurveLut0F;
- private static float[] _normalCurveLut1F;
- private static float[] _normalCurveLut2F;
+ private static readonly float[] _normalCurveLut0F;
+ private static readonly float[] _normalCurveLut1F;
+ private static readonly float[] _normalCurveLut2F;
- private static float[] _highCurveLut0F;
- private static float[] _highCurveLut1F;
- private static float[] _highCurveLut2F;
+ private static readonly float[] _highCurveLut0F;
+ private static readonly float[] _highCurveLut1F;
+ private static readonly float[] _highCurveLut2F;
static ResamplerHelper()
{
@@ -373,7 +366,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return _normalCurveLut1F;
}
- else if (ratio > 1.333313f)
+
+ if (ratio > 1.333313f)
{
return _normalCurveLut0F;
}
@@ -514,7 +508,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return _highCurveLut1F;
}
- else if (ratio > 1.333313f)
+
+ if (ratio > 1.333313f)
{
return _highCurveLut0F;
}
@@ -601,4 +596,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs
index 821a135ef..f9ef201f2 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs
@@ -9,4 +9,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
public short History0;
public short History1;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs
index 4e8d11e4c..97bbc80cc 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs
@@ -71,4 +71,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
public AuxiliaryBufferInfo CpuBufferInfo;
public AuxiliaryBufferInfo DspBufferInfo;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs
index 4220e6d51..f9a32b3f9 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs
@@ -10,4 +10,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
public float State2;
public float State3;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs
index 2a1e7f834..c56fa078a 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs
@@ -64,4 +64,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs
index 0560757c9..80d1cb62e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs
@@ -20,12 +20,12 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
DetectorAverage.AsSpan().Fill(new ExponentialMovingAverage(0.0f));
CompressionGainAverage.AsSpan().Fill(new ExponentialMovingAverage(1.0f));
- DelayedSampleBufferPosition.AsSpan().Fill(0);
- DelayedSampleBuffer.AsSpan().Fill(0.0f);
+ DelayedSampleBufferPosition.AsSpan().Clear();
+ DelayedSampleBuffer.AsSpan().Clear();
UpdateParameter(ref parameter);
}
- public void UpdateParameter(ref LimiterParameter parameter) { }
+ public static void UpdateParameter(ref LimiterParameter parameter) { }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs
index c06466031..5056b750e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs
@@ -6,11 +6,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
{
public class Reverb3dState
{
- private readonly float[] FdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
- private readonly float[] FdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
- private readonly float[] DecayDelayMaxTimes1 = new float[4] { 17.0f, 13.0f, 9.0f, 7.0f };
- private readonly float[] DecayDelayMaxTimes2 = new float[4] { 19.0f, 11.0f, 10.0f, 6.0f };
- private readonly float[] EarlyDelayTimes = new float[20] { 0.017136f, 0.059154f, 0.16173f, 0.39019f, 0.42526f, 0.45541f, 0.68974f, 0.74591f, 0.83384f, 0.8595f, 0.0f, 0.075024f, 0.16879f, 0.2999f, 0.33744f, 0.3719f, 0.59901f, 0.71674f, 0.81786f, 0.85166f };
+ private readonly float[] _fdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
+ private readonly float[] _fdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
+ private readonly float[] _decayDelayMaxTimes1 = new float[4] { 17.0f, 13.0f, 9.0f, 7.0f };
+ private readonly float[] _decayDelayMaxTimes2 = new float[4] { 19.0f, 11.0f, 10.0f, 6.0f };
+ private readonly float[] _earlyDelayTimes = new float[20] { 0.017136f, 0.059154f, 0.16173f, 0.39019f, 0.42526f, 0.45541f, 0.68974f, 0.74591f, 0.83384f, 0.8595f, 0.0f, 0.075024f, 0.16879f, 0.2999f, 0.33744f, 0.3719f, 0.59901f, 0.71674f, 0.81786f, 0.85166f };
public readonly float[] EarlyGain = new float[20] { 0.67096f, 0.61027f, 1.0f, 0.35680f, 0.68361f, 0.65978f, 0.51939f, 0.24712f, 0.45945f, 0.45021f, 0.64196f, 0.54879f, 0.92925f, 0.38270f, 0.72867f, 0.69794f, 0.5464f, 0.24563f, 0.45214f, 0.44042f };
public IDelayLine[] FdnDelayLines { get; }
@@ -46,9 +46,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < 4; i++)
{
- FdnDelayLines[i] = new DelayLine3d(sampleRate, FdnDelayMaxTimes[i]);
- DecayDelays1[i] = new DecayDelay(new DelayLine3d(sampleRate, DecayDelayMaxTimes1[i]));
- DecayDelays2[i] = new DecayDelay(new DelayLine3d(sampleRate, DecayDelayMaxTimes2[i]));
+ FdnDelayLines[i] = new DelayLine3d(sampleRate, _fdnDelayMaxTimes[i]);
+ DecayDelays1[i] = new DecayDelay(new DelayLine3d(sampleRate, _decayDelayMaxTimes1[i]));
+ DecayDelays2[i] = new DecayDelay(new DelayLine3d(sampleRate, _decayDelayMaxTimes2[i]));
}
PreDelayLine = new DelayLine3d(sampleRate, 400);
@@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
EarlyDelayTime = new uint[20];
DryGain = parameter.DryGain;
- PreviousFeedbackOutputDecayed.AsSpan().Fill(0);
+ PreviousFeedbackOutputDecayed.AsSpan().Clear();
PreviousPreDelayValue = 0;
EarlyReflectionsGain = FloatingPointHelper.Pow10(Math.Min(parameter.RoomGain + parameter.ReflectionsGain, 5000.0f) / 2000.0f);
@@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < FdnDelayLines.Length; i++)
{
- FdnDelayLines[i].SetDelay(FdnDelayMinTimes[i] + (parameter.Density / 100 * (FdnDelayMaxTimes[i] - FdnDelayMinTimes[i])));
+ FdnDelayLines[i].SetDelay(_fdnDelayMinTimes[i] + (parameter.Density / 100 * (_fdnDelayMaxTimes[i] - _fdnDelayMinTimes[i])));
uint tempSampleCount = FdnDelayLines[i].CurrentSampleCount + DecayDelays1[i].CurrentSampleCount + DecayDelays2[i].CurrentSampleCount;
@@ -111,9 +111,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < EarlyDelayTime.Length; i++)
{
- uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (EarlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax);
+ uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (_earlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax);
EarlyDelayTime[i] = sampleCount;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs
index 1ffabe05c..2f574f475 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
{
public class ReverbState
{
- private static readonly float[] FdnDelayTimes = new float[20]
+ private static readonly float[] _fdnDelayTimes = new float[20]
{
// Room
53.953247f, 79.192566f, 116.238770f, 130.615295f,
@@ -21,7 +21,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
53.953247f, 79.192566f, 116.238770f, 170.615295f,
};
- private static readonly float[] DecayDelayTimes = new float[20]
+ private static readonly float[] _decayDelayTimes = new float[20]
{
// Room
7f, 9f, 13f, 17f,
@@ -35,7 +35,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
7f, 9f, 13f, 17f,
};
- private static readonly float[] EarlyDelayTimes = new float[50]
+ private static readonly float[] _earlyDelayTimes = new float[50]
{
// Room
0.0f, 3.5f, 2.8f, 3.9f, 2.7f, 13.4f, 7.9f, 8.4f, 9.9f, 12.0f,
@@ -46,10 +46,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
// Cathedral
33.1f, 43.3f, 22.8f, 37.9f, 14.9f, 35.3f, 17.9f, 34.2f, 0.0f, 43.3f,
// Disabled
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
+ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
};
- private static readonly float[] EarlyGainBase = new float[50]
+ private static readonly float[] _earlyGainBase = new float[50]
{
// Room
0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.68f, 0.68f,
@@ -60,10 +60,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
// Cathedral
0.93f, 0.92f, 0.87f, 0.86f, 0.94f, 0.81f, 0.80f, 0.77f, 0.76f, 0.65f,
// Disabled
- 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f
+ 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f,
};
- private static readonly float[] PreDelayTimes = new float[5]
+ private static readonly float[] _preDelayTimes = new float[5]
{
// Room
12.5f,
@@ -74,7 +74,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
// Cathedral
50.0f,
// Disabled
- 0.0f
+ 0.0f,
};
public DelayLine[] FdnDelayLines { get; }
@@ -93,14 +93,14 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
private const int FixedPointPrecision = 14;
- private ReadOnlySpan GetFdnDelayTimesByLateMode(ReverbLateMode lateMode)
+ private static ReadOnlySpan GetFdnDelayTimesByLateMode(ReverbLateMode lateMode)
{
- return FdnDelayTimes.AsSpan((int)lateMode * 4, 4);
+ return _fdnDelayTimes.AsSpan((int)lateMode * 4, 4);
}
- private ReadOnlySpan GetDecayDelayTimesByLateMode(ReverbLateMode lateMode)
+ private static ReadOnlySpan GetDecayDelayTimesByLateMode(ReverbLateMode lateMode)
{
- return DecayDelayTimes.AsSpan((int)lateMode * 4, 4);
+ return _decayDelayTimes.AsSpan((int)lateMode * 4, 4);
}
public ReverbState(ref ReverbParameter parameter, ulong workBuffer, bool isLongSizePreDelaySupported)
@@ -148,8 +148,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < 10; i++)
{
- EarlyDelayTime[i] = Math.Min(IDelayLine.GetSampleCount(sampleRate, EarlyDelayTimes[i] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax) + 1;
- EarlyGain[i] = EarlyGainBase[i] * earlyGain;
+ EarlyDelayTime[i] = Math.Min(IDelayLine.GetSampleCount(sampleRate, _earlyDelayTimes[i] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax) + 1;
+ EarlyGain[i] = _earlyGainBase[i] * earlyGain;
}
if (parameter.ChannelCount == 2)
@@ -158,7 +158,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
EarlyGain[5] = EarlyGain[5] * 0.5f;
}
- PreDelayLineDelayTime = Math.Min(IDelayLine.GetSampleCount(sampleRate, PreDelayTimes[(int)parameter.EarlyMode] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax);
+ PreDelayLineDelayTime = Math.Min(IDelayLine.GetSampleCount(sampleRate, _preDelayTimes[(int)parameter.EarlyMode] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax);
ReadOnlySpan fdnDelayTimes = GetFdnDelayTimesByLateMode(parameter.LateMode);
ReadOnlySpan decayDelayTimes = GetDecayDelayTimesByLateMode(parameter.LateMode);
@@ -201,4 +201,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs
index 54a63ace0..5732cdb21 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs
@@ -13,11 +13,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
private const int FilterBankLength = 20;
// Bank0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
private const int Bank0CenterIndex = 9;
- private static readonly Array20 Bank1 = PrecomputeFilterBank(1.0f / 6.0f);
- private static readonly Array20 Bank2 = PrecomputeFilterBank(2.0f / 6.0f);
- private static readonly Array20 Bank3 = PrecomputeFilterBank(3.0f / 6.0f);
- private static readonly Array20 Bank4 = PrecomputeFilterBank(4.0f / 6.0f);
- private static readonly Array20 Bank5 = PrecomputeFilterBank(5.0f / 6.0f);
+ private static readonly Array20 _bank1 = PrecomputeFilterBank(1.0f / 6.0f);
+ private static readonly Array20 _bank2 = PrecomputeFilterBank(2.0f / 6.0f);
+ private static readonly Array20 _bank3 = PrecomputeFilterBank(3.0f / 6.0f);
+ private static readonly Array20 _bank4 = PrecomputeFilterBank(4.0f / 6.0f);
+ private static readonly Array20 _bank5 = PrecomputeFilterBank(5.0f / 6.0f);
private static Array20 PrecomputeFilterBank(float offset)
{
@@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
return A0 + A1 * MathF.Cos(2 * MathF.PI * x) + A2 * MathF.Cos(4 * MathF.PI * x);
}
- Array20 result = new Array20();
+ Array20 result = new();
for (int i = 0; i < FilterBankLength; i++)
{
@@ -58,10 +58,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
state.Scale = inputSampleCount switch
{
- 40 => 6.0f,
- 80 => 3.0f,
+ 40 => 6.0f,
+ 80 => 3.0f,
160 => 1.5f,
- _ => throw new ArgumentOutOfRangeException()
+ _ => throw new ArgumentOutOfRangeException(nameof(inputSampleCount), inputSampleCount, null),
};
state.Initialized = true;
}
@@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void NextInput(ref UpsamplerBufferState state, float input)
{
- state.History.AsSpan().Slice(1).CopyTo(state.History.AsSpan());
+ state.History.AsSpan()[1..].CopyTo(state.History.AsSpan());
state.History[HistoryLength - 1] = input;
}
@@ -123,19 +123,19 @@ namespace Ryujinx.Audio.Renderer.Dsp
outputBuffer[i] = state.History[Bank0CenterIndex];
break;
case 1:
- outputBuffer[i] = DoFilterBank(ref state, Bank1);
+ outputBuffer[i] = DoFilterBank(ref state, _bank1);
break;
case 2:
- outputBuffer[i] = DoFilterBank(ref state, Bank2);
+ outputBuffer[i] = DoFilterBank(ref state, _bank2);
break;
case 3:
- outputBuffer[i] = DoFilterBank(ref state, Bank3);
+ outputBuffer[i] = DoFilterBank(ref state, _bank3);
break;
case 4:
- outputBuffer[i] = DoFilterBank(ref state, Bank4);
+ outputBuffer[i] = DoFilterBank(ref state, _bank4);
break;
case 5:
- outputBuffer[i] = DoFilterBank(ref state, Bank5);
+ outputBuffer[i] = DoFilterBank(ref state, _bank5);
break;
}
@@ -152,10 +152,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
outputBuffer[i] = state.History[Bank0CenterIndex];
break;
case 1:
- outputBuffer[i] = DoFilterBank(ref state, Bank2);
+ outputBuffer[i] = DoFilterBank(ref state, _bank2);
break;
case 2:
- outputBuffer[i] = DoFilterBank(ref state, Bank4);
+ outputBuffer[i] = DoFilterBank(ref state, _bank4);
break;
}
@@ -173,11 +173,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
outputBuffer[i] = state.History[Bank0CenterIndex];
break;
case 1:
- outputBuffer[i] = DoFilterBank(ref state, Bank4);
+ outputBuffer[i] = DoFilterBank(ref state, _bank4);
break;
case 2:
NextInput(ref state, inputBuffer[inputBufferIndex++]);
- outputBuffer[i] = DoFilterBank(ref state, Bank2);
+ outputBuffer[i] = DoFilterBank(ref state, _bank2);
break;
}
@@ -185,7 +185,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
break;
default:
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(state), state.Scale, null);
}
}
}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/AudioRendererConfiguration.cs b/src/Ryujinx.Audio/Renderer/Parameter/AudioRendererConfiguration.cs
index 359cd4c02..491a05c86 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/AudioRendererConfiguration.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/AudioRendererConfiguration.cs
@@ -60,7 +60,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/unused
///
- private byte _reserved;
+ private readonly byte _reserved;
///
/// The target rendering device.
@@ -96,4 +96,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
public int Revision;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/BehaviourErrorInfoOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/BehaviourErrorInfoOutStatus.cs
index aba7dcd61..5a0565dc6 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/BehaviourErrorInfoOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/BehaviourErrorInfoOutStatus.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
private unsafe fixed uint _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/BiquadFilterParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/BiquadFilterParameter.cs
index ef86015fe..f1492b0b1 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/BiquadFilterParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/BiquadFilterParameter.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private byte _reserved;
+ private readonly byte _reserved;
///
/// Biquad filter numerator (b0, b1, b2).
@@ -31,4 +31,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// a0 = 1
public Array2 Denominator;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/AuxiliaryBufferParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/AuxiliaryBufferParameter.cs
index 36f286775..65f265a32 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/AuxiliaryBufferParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/AuxiliaryBufferParameter.cs
@@ -81,4 +81,4 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// This is unused.
public uint MixBufferSampleCount;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/BiquadFilterEffectParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/BiquadFilterEffectParameter.cs
index 73e0e9bbc..b12a941a5 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/BiquadFilterEffectParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/BiquadFilterEffectParameter.cs
@@ -41,4 +41,4 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
///
public UsageState Status;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/BufferMixerParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/BufferMixerParameter.cs
index b03559eba..49b70e501 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/BufferMixerParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/BufferMixerParameter.cs
@@ -29,4 +29,4 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
///
public uint MixesCount;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/CompressorParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/CompressorParameter.cs
index 0be376088..1a936b0df 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/CompressorParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/CompressorParameter.cs
@@ -98,7 +98,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountValid()
+ public readonly bool IsChannelCountValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
}
@@ -107,7 +107,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountMaxValid()
+ public readonly bool IsChannelCountMaxValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/DelayParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/DelayParameter.cs
index 72332c170..99c97d9d9 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/DelayParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/DelayParameter.cs
@@ -84,7 +84,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountValid()
+ public readonly bool IsChannelCountValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
}
@@ -93,9 +93,9 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountMaxValid()
+ public readonly bool IsChannelCountMaxValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterParameter.cs
index 0bce94a27..23ccb8c88 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterParameter.cs
@@ -115,13 +115,13 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
///
/// Reserved/padding.
///
- private byte _reserved;
+ private readonly byte _reserved;
///
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountValid()
+ public readonly bool IsChannelCountValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
}
@@ -130,9 +130,9 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountMaxValid()
+ public readonly bool IsChannelCountMaxValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterStatistics.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterStatistics.cs
index f353f18d1..97e2f39fc 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterStatistics.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/LimiterStatistics.cs
@@ -24,8 +24,8 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
///
public void Reset()
{
- InputMax.AsSpan().Fill(0.0f);
+ InputMax.AsSpan().Clear();
CompressionGainMin.AsSpan().Fill(1.0f);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/Reverb3dParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/Reverb3dParameter.cs
index c78ce5951..d2cd78707 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/Reverb3dParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/Reverb3dParameter.cs
@@ -33,7 +33,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
///
/// Reserved/unused.
///
- private uint _reserved;
+ private readonly uint _reserved;
///
/// The target sample rate.
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountValid()
+ public readonly bool IsChannelCountValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
}
@@ -119,9 +119,9 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountMaxValid()
+ public readonly bool IsChannelCountMaxValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Effect/ReverbParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Effect/ReverbParameter.cs
index baf049fbd..51ab156d2 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Effect/ReverbParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Effect/ReverbParameter.cs
@@ -102,7 +102,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountValid()
+ public readonly bool IsChannelCountValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCount);
}
@@ -111,9 +111,9 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// Check if the is valid.
///
/// Returns true if the is valid.
- public bool IsChannelCountMaxValid()
+ public readonly bool IsChannelCountMaxValid()
{
return EffectInParameterVersion1.IsChannelCountValid(ChannelCountMax);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs
index e5419f70a..46686e3b4 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs
@@ -31,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private byte _reserved1;
+ private readonly byte _reserved1;
///
/// The target mix id of the effect.
@@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private uint _reserved2;
+ private readonly uint _reserved2;
///
/// Specific data storage.
@@ -70,19 +70,19 @@ namespace Ryujinx.Audio.Renderer.Parameter
public Span SpecificData => SpanHelpers.AsSpan(ref _specificDataStart);
- EffectType IEffectInParameter.Type => Type;
+ readonly EffectType IEffectInParameter.Type => Type;
- bool IEffectInParameter.IsNew => IsNew;
+ readonly bool IEffectInParameter.IsNew => IsNew;
- bool IEffectInParameter.IsEnabled => IsEnabled;
+ readonly bool IEffectInParameter.IsEnabled => IsEnabled;
- int IEffectInParameter.MixId => MixId;
+ readonly int IEffectInParameter.MixId => MixId;
- ulong IEffectInParameter.BufferBase => BufferBase;
+ readonly ulong IEffectInParameter.BufferBase => BufferBase;
- ulong IEffectInParameter.BufferSize => BufferSize;
+ readonly ulong IEffectInParameter.BufferSize => BufferSize;
- uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
+ readonly uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
///
/// Check if the given channel count is valid.
@@ -94,4 +94,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
return channelCount == 1 || channelCount == 2 || channelCount == 4 || channelCount == 6;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs
index 250012d16..3854c7148 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs
@@ -31,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private byte _reserved1;
+ private readonly byte _reserved1;
///
/// The target mix id of the effect.
@@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private uint _reserved2;
+ private readonly uint _reserved2;
///
/// Specific data storage.
@@ -70,19 +70,19 @@ namespace Ryujinx.Audio.Renderer.Parameter
public Span SpecificData => SpanHelpers.AsSpan(ref _specificDataStart);
- EffectType IEffectInParameter.Type => Type;
+ readonly EffectType IEffectInParameter.Type => Type;
- bool IEffectInParameter.IsNew => IsNew;
+ readonly bool IEffectInParameter.IsNew => IsNew;
- bool IEffectInParameter.IsEnabled => IsEnabled;
+ readonly bool IEffectInParameter.IsEnabled => IsEnabled;
- int IEffectInParameter.MixId => MixId;
+ readonly int IEffectInParameter.MixId => MixId;
- ulong IEffectInParameter.BufferBase => BufferBase;
+ readonly ulong IEffectInParameter.BufferBase => BufferBase;
- ulong IEffectInParameter.BufferSize => BufferSize;
+ readonly ulong IEffectInParameter.BufferSize => BufferSize;
- uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
+ readonly uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
///
/// Check if the given channel count is valid.
@@ -94,4 +94,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
return channelCount == 1 || channelCount == 2 || channelCount == 4 || channelCount == 6;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion1.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion1.cs
index 5e6a33ace..3c3e95538 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion1.cs
@@ -18,6 +18,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
private unsafe fixed byte _reserved[15];
- EffectState IEffectOutStatus.State { get => State; set => State = value; }
+ EffectState IEffectOutStatus.State { readonly get => State; set => State = value; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion2.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion2.cs
index f2c9768b3..ee058d3ae 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectOutStatusVersion2.cs
@@ -23,6 +23,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
public EffectResultState ResultState;
- EffectState IEffectOutStatus.State { get => State; set => State = value; }
+ EffectState IEffectOutStatus.State { readonly get => State; set => State = value; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectResultState.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectResultState.cs
index bd96c22bf..b3a4bae12 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/EffectResultState.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectResultState.cs
@@ -23,4 +23,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
public Span SpecificData => SpanHelpers.AsSpan(ref _specificDataStart);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectState.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectState.cs
index 911ba6d84..c4d06f122 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/EffectState.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectState.cs
@@ -13,6 +13,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// The effect is disabled.
///
- Disabled = 4
+ Disabled = 4,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/IEffectInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/IEffectInParameter.cs
index bdd1ca45e..703c3e6db 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/IEffectInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/IEffectInParameter.cs
@@ -50,4 +50,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
Span SpecificData { get; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/IEffectOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/IEffectOutStatus.cs
index a5addbcb7..74d132209 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/IEffectOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/IEffectOutStatus.cs
@@ -10,4 +10,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
EffectState State { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolInParameter.cs
index 242e3843c..602508589 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolInParameter.cs
@@ -30,4 +30,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
private unsafe fixed uint _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolOutStatus.cs
index 29a6e261f..a78937d01 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/MemoryPoolOutStatus.cs
@@ -19,4 +19,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
private unsafe fixed uint _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/MixInParameterDirtyOnlyUpdate.cs b/src/Ryujinx.Audio/Renderer/Parameter/MixInParameterDirtyOnlyUpdate.cs
index c0954cda0..733b5ad76 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/MixInParameterDirtyOnlyUpdate.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/MixInParameterDirtyOnlyUpdate.cs
@@ -24,4 +24,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
private unsafe fixed byte _reserved[24];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/MixParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/MixParameter.cs
index 5b9a969a0..2eec04a21 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/MixParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/MixParameter.cs
@@ -41,7 +41,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private ushort _reserved1;
+ private readonly ushort _reserved1;
///
/// The id of the mix.
@@ -61,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private ulong _reserved2;
+ private readonly ulong _reserved2;
///
/// Mix buffer volumes storage.
@@ -81,7 +81,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private uint _reserved3;
+ private readonly uint _reserved3;
[StructLayout(LayoutKind.Sequential, Size = 4 * Constants.MixBufferCountMax * Constants.MixBufferCountMax, Pack = 1)]
private struct MixVolumeArray { }
@@ -92,4 +92,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Used when no splitter id is specified.
public Span MixBufferVolume => SpanHelpers.AsSpan(ref _mixBufferVolumeArray);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceInParameter.cs
index 0f9a3aa3e..806f7fa89 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceInParameter.cs
@@ -18,4 +18,4 @@ namespace Ryujinx.Audio.Renderer.Parameter.Performance
///
private unsafe fixed uint _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceOutStatus.cs
index 64bbe080a..839d6eb6b 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Performance/PerformanceOutStatus.cs
@@ -18,4 +18,4 @@ namespace Ryujinx.Audio.Renderer.Parameter.Performance
///
private unsafe fixed uint _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/RendererInfoOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/RendererInfoOutStatus.cs
index a42ea833f..c97ce2965 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/RendererInfoOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/RendererInfoOutStatus.cs
@@ -16,6 +16,6 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/Unused.
///
- private ulong _reserved;
+ private readonly ulong _reserved;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Sink/CircularBufferParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Sink/CircularBufferParameter.cs
index 7c02d65ff..0d4b276ef 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Sink/CircularBufferParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Sink/CircularBufferParameter.cs
@@ -2,7 +2,6 @@ using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
-
using CpuAddress = System.UInt64;
namespace Ryujinx.Audio.Renderer.Parameter.Sink
@@ -41,7 +40,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
///
/// The target .
///
- /// Only is supported.
+ /// Only is supported.
public SampleFormat SampleFormat;
///
@@ -57,6 +56,6 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
///
/// Reserved/padding.
///
- private ushort _reserved2;
+ private readonly ushort _reserved2;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/Sink/DeviceParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/Sink/DeviceParameter.cs
index abeadaccf..652d02a63 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/Sink/DeviceParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/Sink/DeviceParameter.cs
@@ -19,7 +19,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
///
/// Reserved/padding.
///
- private byte _padding;
+ private readonly byte _padding;
///
/// The total count of channels to output to the device.
@@ -34,7 +34,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
///
/// Reserved/padding.
///
- private byte _reserved;
+ private readonly byte _reserved;
///
/// Set to true if the user controls Surround to Stereo downmixing coefficients.
@@ -55,4 +55,4 @@ namespace Ryujinx.Audio.Renderer.Parameter.Sink
///
public Span DeviceName => SpanHelpers.AsSpan(ref _deviceName);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/SinkInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/SinkInParameter.cs
index 1ee4eb532..3c1ac09c0 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/SinkInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/SinkInParameter.cs
@@ -25,7 +25,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private ushort _reserved1;
+ private readonly ushort _reserved1;
///
/// The node id of the sink.
@@ -50,4 +50,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
public Span SpecificData => SpanHelpers.AsSpan(ref _specificDataStart);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/SinkOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/SinkOutStatus.cs
index 426b861ca..dd0f867b5 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/SinkOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/SinkOutStatus.cs
@@ -16,11 +16,11 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/padding.
///
- private uint _padding;
+ private readonly uint _padding;
///
/// Reserved/padding.
///
private unsafe fixed ulong _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/SplitterDestinationInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/SplitterDestinationInParameter.cs
index 96c43092b..b74b67be0 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/SplitterDestinationInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/SplitterDestinationInParameter.cs
@@ -59,9 +59,9 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Check if the magic is valid.
///
/// Returns true if the magic is valid.
- public bool IsMagicValid()
+ public readonly bool IsMagicValid()
{
return Magic == ValidMagic;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameter.cs
index 0220497de..2567b15a8 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameter.cs
@@ -38,9 +38,9 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Check if the magic is valid.
///
/// Returns true if the magic is valid.
- public bool IsMagicValid()
+ public readonly bool IsMagicValid()
{
return Magic == ValidMagic;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameterHeader.cs b/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameterHeader.cs
index dbae17a9a..10fa866e7 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameterHeader.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/SplitterInParameterHeader.cs
@@ -37,9 +37,9 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Check if the magic is valid.
///
/// Returns true if the magic is valid.
- public bool IsMagicValid()
+ public readonly bool IsMagicValid()
{
return Magic == ValidMagic;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/VoiceChannelResourceInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/VoiceChannelResourceInParameter.cs
index 6a863237d..6cff1a251 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/VoiceChannelResourceInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/VoiceChannelResourceInParameter.cs
@@ -25,4 +25,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
[MarshalAs(UnmanagedType.I1)]
public bool IsUsed;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/VoiceInParameter.cs b/src/Ryujinx.Audio/Renderer/Parameter/VoiceInParameter.cs
index c4b4ba312..86f92442b 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/VoiceInParameter.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/VoiceInParameter.cs
@@ -94,7 +94,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/unused.
///
- private uint _reserved1;
+ private readonly uint _reserved1;
///
/// User state address required by the data source.
@@ -143,7 +143,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/unused.
///
- private ushort _reserved2;
+ private readonly ushort _reserved2;
///
/// Change the behaviour of the voice.
@@ -222,7 +222,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Reserved/unused.
///
- private byte _reserved;
+ private readonly byte _reserved;
///
/// If set to anything other than 0, specifies how many times to loop the wavebuffer.
@@ -260,7 +260,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// The PCM sample type
/// Returns true if the sample offset are in range of the size.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private bool IsSampleOffsetInRangeForPcm() where T : unmanaged
+ private readonly bool IsSampleOffsetInRangeForPcm() where T : unmanaged
{
uint dataTypeSize = (uint)Unsafe.SizeOf();
@@ -273,27 +273,15 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// The target
/// Returns true if the sample offset are in range of the size.
- public bool IsSampleOffsetValid(SampleFormat format)
+ public readonly bool IsSampleOffsetValid(SampleFormat format)
{
- bool result;
-
- switch (format)
+ return format switch
{
- case SampleFormat.PcmInt16:
- result = IsSampleOffsetInRangeForPcm();
- break;
- case SampleFormat.PcmFloat:
- result = IsSampleOffsetInRangeForPcm();
- break;
- case SampleFormat.Adpcm:
- result = AdpcmHelper.GetAdpcmDataSize((int)StartSampleOffset) <= Size &&
- AdpcmHelper.GetAdpcmDataSize((int)EndSampleOffset) <= Size;
- break;
- default:
- throw new NotImplementedException($"{format} not implemented!");
- }
-
- return result;
+ SampleFormat.PcmInt16 => IsSampleOffsetInRangeForPcm(),
+ SampleFormat.PcmFloat => IsSampleOffsetInRangeForPcm(),
+ SampleFormat.Adpcm => AdpcmHelper.GetAdpcmDataSize((int)StartSampleOffset) <= Size && AdpcmHelper.GetAdpcmDataSize((int)EndSampleOffset) <= Size,
+ _ => throw new NotImplementedException($"{format} not implemented!"),
+ };
}
}
@@ -316,7 +304,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Skip pitch and Sample Rate Conversion (SRC).
///
- SkipPitchAndSampleRateConversion = 2
+ SkipPitchAndSampleRateConversion = 2,
}
///
@@ -338,7 +326,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
/// Resample interpolating 1 samples per output sample.
///
- Low
+ Low,
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Parameter/VoiceOutStatus.cs b/src/Ryujinx.Audio/Renderer/Parameter/VoiceOutStatus.cs
index be9d35849..a7c749835 100644
--- a/src/Ryujinx.Audio/Renderer/Parameter/VoiceOutStatus.cs
+++ b/src/Ryujinx.Audio/Renderer/Parameter/VoiceOutStatus.cs
@@ -32,4 +32,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
///
private unsafe fixed byte _reserved[3];
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs b/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs
index 8485fb4c5..7bb8ae5ba 100644
--- a/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs
@@ -19,7 +19,6 @@ using System;
using System.Buffers;
using System.Diagnostics;
using System.Threading;
-
using CpuAddress = System.UInt64;
namespace Ryujinx.Audio.Renderer.Server
@@ -30,19 +29,21 @@ namespace Ryujinx.Audio.Renderer.Server
private AudioRendererRenderingDevice _renderingDevice;
private AudioRendererExecutionMode _executionMode;
- private IWritableEvent _systemEvent;
+ private readonly IWritableEvent _systemEvent;
private MemoryPoolState _dspMemoryPoolState;
- private VoiceContext _voiceContext;
- private MixContext _mixContext;
- private SinkContext _sinkContext;
- private SplitterContext _splitterContext;
- private EffectContext _effectContext;
+ private readonly VoiceContext _voiceContext;
+ private readonly MixContext _mixContext;
+ private readonly SinkContext _sinkContext;
+ private readonly SplitterContext _splitterContext;
+ private readonly EffectContext _effectContext;
private PerformanceManager _performanceManager;
private UpsamplerManager _upsamplerManager;
private bool _isActive;
private BehaviourContext _behaviourContext;
+#pragma warning disable IDE0052 // Remove unread private member
private ulong _totalElapsedTicksUpdating;
private ulong _totalElapsedTicks;
+#pragma warning restore IDE0052
private int _sessionId;
private Memory _memoryPools;
@@ -75,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Server
private ulong _elapsedFrameCount;
private ulong _renderingStartTick;
- private AudioRendererManager _manager;
+ private readonly AudioRendererManager _manager;
private int _disposeState;
@@ -143,12 +144,12 @@ namespace Ryujinx.Audio.Renderer.Server
WorkBufferAllocator workBufferAllocator;
- workBufferMemory.Span.Fill(0);
+ workBufferMemory.Span.Clear();
_workBufferMemoryPin = workBufferMemory.Pin();
workBufferAllocator = new WorkBufferAllocator(workBufferMemory);
- PoolMapper poolMapper = new PoolMapper(processHandle, false);
+ PoolMapper poolMapper = new(processHandle, false);
poolMapper.InitializeSystemPool(ref _dspMemoryPoolState, workBuffer, workBufferSize);
_mixBuffer = workBufferAllocator.Allocate(_sampleCount * (_voiceChannelCountMax + _mixBufferCount), 0x10);
@@ -244,9 +245,9 @@ namespace Ryujinx.Audio.Renderer.Server
foreach (ref MixState mix in mixes.Span)
{
- mix = new MixState(effectProcessingOrderArray.Slice(0, (int)parameter.EffectCount), ref _behaviourContext);
+ mix = new MixState(effectProcessingOrderArray[..(int)parameter.EffectCount], ref _behaviourContext);
- effectProcessingOrderArray = effectProcessingOrderArray.Slice((int)parameter.EffectCount);
+ effectProcessingOrderArray = effectProcessingOrderArray[(int)parameter.EffectCount..];
}
}
@@ -341,26 +342,15 @@ namespace Ryujinx.Audio.Renderer.Server
_elapsedFrameCount = 0;
_voiceDropParameter = 1.0f;
- switch (_behaviourContext.GetCommandProcessingTimeEstimatorVersion())
+ _commandProcessingTimeEstimator = _behaviourContext.GetCommandProcessingTimeEstimatorVersion() switch
{
- case 1:
- _commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount);
- break;
- case 2:
- _commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount);
- break;
- case 3:
- _commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount);
- break;
- case 4:
- _commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount);
- break;
- case 5:
- _commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount);
- break;
- default:
- throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}.");
- }
+ 1 => new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount),
+ 2 => new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount),
+ 3 => new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount),
+ 4 => new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount),
+ 5 => new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount),
+ _ => throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}."),
+ };
return ResultCode.Success;
}
@@ -402,9 +392,9 @@ namespace Ryujinx.Audio.Renderer.Server
{
ulong updateStartTicks = GetSystemTicks();
- output.Span.Fill(0);
+ output.Span.Clear();
- StateUpdater stateUpdater = new StateUpdater(input, output, _processHandle, _behaviourContext);
+ StateUpdater stateUpdater = new(input, output, _processHandle, _behaviourContext);
ResultCode result;
@@ -609,9 +599,9 @@ namespace Ryujinx.Audio.Renderer.Server
_renderingStartTick = 0;
}
- CommandBuffer commandBuffer = new CommandBuffer(commandList, _commandProcessingTimeEstimator);
+ CommandBuffer commandBuffer = new(commandList, _commandProcessingTimeEstimator);
- CommandGenerator commandGenerator = new CommandGenerator(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
+ CommandGenerator commandGenerator = new(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
_voiceContext.Sort();
commandGenerator.GenerateVoices();
@@ -731,7 +721,7 @@ namespace Ryujinx.Audio.Renderer.Server
DepopBuffer = _depopBuffer,
MixBufferCount = GetMixBufferCount(),
SessionId = _sessionId,
- UpsamplerManager = _upsamplerManager
+ UpsamplerManager = _upsamplerManager,
};
}
@@ -742,7 +732,7 @@ namespace Ryujinx.Audio.Renderer.Server
public static ulong GetWorkBufferSize(ref AudioRendererConfiguration parameter)
{
- BehaviourContext behaviourContext = new BehaviourContext();
+ BehaviourContext behaviourContext = new();
behaviourContext.SetUserRevision(parameter.Revision);
@@ -813,6 +803,8 @@ namespace Ryujinx.Audio.Renderer.Server
public void Dispose()
{
+ GC.SuppressFinalize(this);
+
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@@ -828,7 +820,7 @@ namespace Ryujinx.Audio.Renderer.Server
Stop();
}
- PoolMapper mapper = new PoolMapper(_processHandle, false);
+ PoolMapper mapper = new(_processHandle, false);
mapper.Unmap(ref _dspMemoryPoolState);
PoolMapper.ClearUsageState(_memoryPools);
@@ -876,4 +868,4 @@ namespace Ryujinx.Audio.Renderer.Server
return ResultCode.UnsupportedOperation;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs b/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs
index e41d5cc50..0dbbd26c8 100644
--- a/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/AudioRendererManager.cs
@@ -29,7 +29,7 @@ namespace Ryujinx.Audio.Renderer.Server
///
/// The session ids allocation table.
///
- private int[] _sessionIds;
+ private readonly int[] _sessionIds;
///
/// The events linked to each session.
@@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Server
///
/// The sessions instances.
///
- private AudioRenderSystem[] _sessions;
+ private readonly AudioRenderSystem[] _sessions;
///
/// The count of active sessions.
@@ -186,7 +186,7 @@ namespace Ryujinx.Audio.Renderer.Server
_workerThread = new Thread(SendCommands)
{
- Name = "AudioRendererManager.Worker"
+ Name = "AudioRendererManager.Worker",
};
_workerThread.Start();
@@ -317,7 +317,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
int sessionId = AcquireSessionId();
- AudioRenderSystem audioRenderer = new AudioRenderSystem(this, _sessionsSystemEvent[sessionId]);
+ AudioRenderSystem audioRenderer = new(this, _sessionsSystemEvent[sessionId]);
// TODO: Eventually, we should try to use the guest supplied work buffer instead of allocating
// our own. However, it was causing problems on some applications that would unmap the memory
@@ -367,6 +367,8 @@ namespace Ryujinx.Audio.Renderer.Server
public void Dispose()
{
+ GC.SuppressFinalize(this);
+
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
{
Dispose(true);
@@ -402,4 +404,4 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs b/src/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs
index 821947a98..3297b5d9f 100644
--- a/src/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/BehaviourContext.cs
@@ -125,7 +125,7 @@ namespace Ryujinx.Audio.Renderer.Server
///
/// Error storage.
///
- private ErrorInfo[] _errorInfos;
+ private readonly ErrorInfo[] _errorInfos;
///
/// Current position in the array.
@@ -254,7 +254,8 @@ namespace Ryujinx.Audio.Renderer.Server
{
return 0.80f;
}
- else if (CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision4))
+
+ if (CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision4))
{
return 0.75f;
}
@@ -299,10 +300,8 @@ namespace Ryujinx.Audio.Renderer.Server
{
return 2;
}
- else
- {
- return 1;
- }
+
+ return 1;
}
///
@@ -436,7 +435,7 @@ namespace Ryujinx.Audio.Renderer.Server
errorInfos[i] = new ErrorInfo
{
ErrorCode = 0,
- ExtraErrorInfo = 0
+ ExtraErrorInfo = 0,
};
}
}
@@ -450,4 +449,4 @@ namespace Ryujinx.Audio.Renderer.Server
_errorIndex = 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs b/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
index 905cb2054..f4174a913 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandBuffer.cs
@@ -20,7 +20,7 @@ namespace Ryujinx.Audio.Renderer.Server
///
/// The command processing time estimator in use.
///
- private ICommandProcessingTimeEstimator _commandProcessingTimeEstimator;
+ private readonly ICommandProcessingTimeEstimator _commandProcessingTimeEstimator;
///
/// The estimated total processing time.
@@ -61,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateClearMixBuffer(int nodeId)
{
- ClearMixBufferCommand command = new ClearMixBufferCommand(nodeId);
+ ClearMixBufferCommand command = new(nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -79,7 +79,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// Set to true if the voice was playing previously.
public void GenerateDepopPrepare(Memory state, Memory depopBuffer, uint bufferCount, uint bufferOffset, int nodeId, bool wasPlaying)
{
- DepopPrepareCommand command = new DepopPrepareCommand(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
+ DepopPrepareCommand command = new(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -94,7 +94,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GeneratePerformance(ref PerformanceEntryAddresses performanceEntryAddresses, PerformanceCommand.Type type, int nodeId)
{
- PerformanceCommand command = new PerformanceCommand(ref performanceEntryAddresses, type, nodeId);
+ PerformanceCommand command = new(ref performanceEntryAddresses, type, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateVolumeRamp(float previousVolume, float volume, uint bufferIndex, int nodeId)
{
- VolumeRampCommand command = new VolumeRampCommand(previousVolume, volume, bufferIndex, nodeId);
+ VolumeRampCommand command = new(previousVolume, volume, bufferIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -127,7 +127,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateDataSourceVersion2(ref VoiceState voiceState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
- DataSourceVersion2Command command = new DataSourceVersion2Command(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
+ DataSourceVersion2Command command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -144,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GeneratePcmInt16DataSourceVersion1(ref VoiceState voiceState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
- PcmInt16DataSourceCommandVersion1 command = new PcmInt16DataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
+ PcmInt16DataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -161,7 +161,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GeneratePcmFloatDataSourceVersion1(ref VoiceState voiceState, Memory state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
- PcmFloatDataSourceCommandVersion1 command = new PcmFloatDataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
+ PcmFloatDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -177,7 +177,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateAdpcmDataSourceVersion1(ref VoiceState voiceState, Memory state, ushort outputBufferIndex, int nodeId)
{
- AdpcmDataSourceCommandVersion1 command = new AdpcmDataSourceCommandVersion1(ref voiceState, state, outputBufferIndex, nodeId);
+ AdpcmDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -196,7 +196,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateBiquadFilter(int baseIndex, ref BiquadFilterParameter filter, Memory biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
{
- BiquadFilterCommand command = new BiquadFilterCommand(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
+ BiquadFilterCommand command = new(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -215,7 +215,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateGroupedBiquadFilter(int baseIndex, ReadOnlySpan filters, Memory biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan isInitialized, int nodeId)
{
- GroupedBiquadFilterCommand command = new GroupedBiquadFilterCommand(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
+ GroupedBiquadFilterCommand command = new(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -234,7 +234,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateMixRampGrouped(uint mixBufferCount, uint inputBufferIndex, uint outputBufferIndex, Span previousVolume, Span volume, Memory state, int nodeId)
{
- MixRampGroupedCommand command = new MixRampGroupedCommand(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
+ MixRampGroupedCommand command = new(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -253,7 +253,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateMixRamp(float previousVolume, float volume, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory state, int nodeId)
{
- MixRampCommand command = new MixRampCommand(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
+ MixRampCommand command = new(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -270,7 +270,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The target sample rate in use.
public void GenerateDepopForMixBuffersCommand(Memory depopBuffer, uint bufferOffset, uint bufferCount, int nodeId, uint sampleRate)
{
- DepopForMixBuffersCommand command = new DepopForMixBuffersCommand(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
+ DepopForMixBuffersCommand command = new(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -285,7 +285,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateCopyMixBuffer(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
{
- CopyMixBufferCommand command = new CopyMixBufferCommand(inputBufferIndex, outputBufferIndex, nodeId);
+ CopyMixBufferCommand command = new(inputBufferIndex, outputBufferIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -301,7 +301,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The mix volume.
public void GenerateMix(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
{
- MixCommand command = new MixCommand(inputBufferIndex, outputBufferIndex, nodeId, volume);
+ MixCommand command = new(inputBufferIndex, outputBufferIndex, nodeId, volume);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -323,7 +323,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (parameter.IsChannelCountValid())
{
- ReverbCommand command = new ReverbCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
+ ReverbCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -345,7 +345,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (parameter.IsChannelCountValid())
{
- Reverb3dCommand command = new Reverb3dCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
+ Reverb3dCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -368,7 +368,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (parameter.IsChannelCountValid())
{
- DelayCommand command = new DelayCommand(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
+ DelayCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -389,7 +389,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (parameter.IsChannelCountValid())
{
- LimiterCommandVersion1 command = new LimiterCommandVersion1(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
+ LimiterCommandVersion1 command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -411,7 +411,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (parameter.IsChannelCountValid())
{
- LimiterCommandVersion2 command = new LimiterCommandVersion2(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
+ LimiterCommandVersion2 command = new(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -437,7 +437,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (state.SendBufferInfoBase != 0 && state.ReturnBufferInfoBase != 0)
{
- AuxiliaryBufferCommand command = new AuxiliaryBufferCommand(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
+ AuxiliaryBufferCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -461,7 +461,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (sendBufferInfo != 0)
{
- CaptureBufferCommand command = new CaptureBufferCommand(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
+ CaptureBufferCommand command = new(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -473,7 +473,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (parameter.IsChannelCountValid())
{
- CompressorCommand command = new CompressorCommand(bufferOffset, parameter, state, isEnabled, nodeId);
+ CompressorCommand command = new(bufferOffset, parameter, state, isEnabled, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -489,7 +489,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateVolume(float volume, uint bufferOffset, int nodeId)
{
- VolumeCommand command = new VolumeCommand(volume, bufferOffset, nodeId);
+ VolumeCommand command = new(volume, bufferOffset, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -504,7 +504,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateCircularBuffer(uint bufferOffset, CircularBufferSink sink, int nodeId)
{
- CircularBufferSinkCommand command = new CircularBufferSinkCommand(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
+ CircularBufferSinkCommand command = new(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -521,7 +521,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateDownMixSurroundToStereo(uint bufferOffset, Span inputBufferOffset, Span outputBufferOffset, float[] downMixParameter, int nodeId)
{
- DownMixSurroundToStereoCommand command = new DownMixSurroundToStereoCommand(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
+ DownMixSurroundToStereoCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -541,7 +541,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateUpsample(uint bufferOffset, UpsamplerState upsampler, uint inputCount, Span inputBufferOffset, uint bufferCountPerSample, uint sampleCount, uint sampleRate, int nodeId)
{
- UpsampleCommand command = new UpsampleCommand(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
+ UpsampleCommand command = new(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -558,11 +558,11 @@ namespace Ryujinx.Audio.Renderer.Server
/// The node id associated to this command.
public void GenerateDeviceSink(uint bufferOffset, DeviceSink sink, int sessionId, Memory buffer, int nodeId)
{
- DeviceSinkCommand command = new DeviceSinkCommand(bufferOffset, sink, sessionId, buffer, nodeId);
+ DeviceSinkCommand command = new(bufferOffset, sink, sessionId, buffer, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
AddCommand(command);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandGenerator.cs b/src/Ryujinx.Audio/Renderer/Server/CommandGenerator.cs
index afc1e39b7..ae8f699f3 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandGenerator.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandGenerator.cs
@@ -17,14 +17,14 @@ namespace Ryujinx.Audio.Renderer.Server
{
public class CommandGenerator
{
- private CommandBuffer _commandBuffer;
- private RendererSystemContext _rendererContext;
- private VoiceContext _voiceContext;
- private MixContext _mixContext;
- private EffectContext _effectContext;
- private SinkContext _sinkContext;
- private SplitterContext _splitterContext;
- private PerformanceManager _performanceManager;
+ private readonly CommandBuffer _commandBuffer;
+ private readonly RendererSystemContext _rendererContext;
+ private readonly VoiceContext _voiceContext;
+ private readonly MixContext _mixContext;
+ private readonly EffectContext _effectContext;
+ private readonly SinkContext _sinkContext;
+ private readonly SplitterContext _splitterContext;
+ private readonly PerformanceManager _performanceManager;
public CommandGenerator(CommandBuffer commandBuffer, RendererSystemContext rendererContext, VoiceContext voiceContext, MixContext mixContext, EffectContext effectContext, SinkContext sinkContext, SplitterContext splitterContext, PerformanceManager performanceManager)
{
@@ -138,7 +138,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (supportsOptimizedPath && voiceState.BiquadFilters[0].Enable && voiceState.BiquadFilters[1].Enable)
{
- Memory biquadStateRawMemory = SpanMemoryManager.Cast(state).Slice(VoiceUpdateState.BiquadStateOffset, VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount);
+ Memory biquadStateRawMemory = SpanMemoryManager.Cast(state)[..(VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount)];
Memory stateMemory = SpanMemoryManager.Cast(biquadStateRawMemory);
_commandBuffer.GenerateGroupedBiquadFilter(baseIndex, voiceState.BiquadFilters.AsSpan(), stateMemory, bufferOffset, bufferOffset, voiceState.BiquadFilterNeedInitialization, nodeId);
@@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (filter.Enable)
{
- Memory biquadStateRawMemory = SpanMemoryManager.Cast(state).Slice(VoiceUpdateState.BiquadStateOffset, VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount);
+ Memory biquadStateRawMemory = SpanMemoryManager.Cast(state)[..(VoiceUpdateState.BiquadStateSize * Constants.VoiceBiquadFilterCount)];
Memory stateMemory = SpanMemoryManager.Cast(biquadStateRawMemory);
@@ -224,7 +224,7 @@ namespace Ryujinx.Audio.Renderer.Server
bool performanceInitialized = false;
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
if (_performanceManager != null && _performanceManager.IsTargetNodeId(nodeId) && _performanceManager.GetNextEntry(out performanceEntry, dataSourceDetailType, PerformanceEntryType.Voice, nodeId))
{
@@ -371,7 +371,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
int nodeId = sortedState.NodeId;
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
bool performanceInitialized = false;
@@ -502,9 +502,11 @@ namespace Ryujinx.Audio.Renderer.Server
bool needInitialization = effect.Parameter.Status == UsageState.Invalid ||
(effect.Parameter.Status == UsageState.New && !_rendererContext.BehaviourContext.IsBiquadFilterEffectStateClearBugFixed());
- BiquadFilterParameter parameter = new BiquadFilterParameter();
+ BiquadFilterParameter parameter = new()
+ {
+ Enable = true,
+ };
- parameter.Enable = true;
effect.Parameter.Denominator.AsSpan().CopyTo(parameter.Denominator.AsSpan());
effect.Parameter.Numerator.AsSpan().CopyTo(parameter.Numerator.AsSpan());
@@ -623,7 +625,7 @@ namespace Ryujinx.Audio.Renderer.Server
bool isFinalMix = mix.MixId == Constants.FinalMixId;
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
bool performanceInitialized = false;
@@ -789,7 +791,7 @@ namespace Ryujinx.Audio.Renderer.Server
GenerateEffects(ref subMix);
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
int nodeId = subMix.NodeId;
@@ -820,7 +822,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
int nodeId = sortedState.NodeId;
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
bool performanceInitialized = false;
@@ -853,7 +855,7 @@ namespace Ryujinx.Audio.Renderer.Server
GenerateEffects(ref finalMix);
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
int nodeId = finalMix.NodeId;
@@ -901,7 +903,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
int nodeId = _mixContext.GetFinalState().NodeId;
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
bool performanceInitialized = false;
@@ -977,7 +979,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
bool performanceInitialized = false;
- PerformanceEntryAddresses performanceEntry = new PerformanceEntryAddresses();
+ PerformanceEntryAddresses performanceEntry = new();
if (_performanceManager != null && _performanceManager.GetNextEntry(out performanceEntry, PerformanceEntryType.Sink, sink.NodeId))
{
@@ -1025,4 +1027,4 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion1.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion1.cs
index 63dc9ca96..d95e9aa71 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion1.cs
@@ -8,8 +8,8 @@ namespace Ryujinx.Audio.Renderer.Server
///
public class CommandProcessingTimeEstimatorVersion1 : ICommandProcessingTimeEstimator
{
- private uint _sampleCount;
- private uint _bufferCount;
+ private readonly uint _sampleCount;
+ private readonly uint _bufferCount;
public CommandProcessingTimeEstimatorVersion1(uint sampleCount, uint bufferCount)
{
@@ -185,4 +185,4 @@ namespace Ryujinx.Audio.Renderer.Server
return 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs
index d4f28a07d..929aaf383 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs
@@ -9,8 +9,8 @@ namespace Ryujinx.Audio.Renderer.Server
///
public class CommandProcessingTimeEstimatorVersion2 : ICommandProcessingTimeEstimator
{
- private uint _sampleCount;
- private uint _bufferCount;
+ private readonly uint _sampleCount;
+ private readonly uint _bufferCount;
public CommandProcessingTimeEstimatorVersion2(uint sampleCount, uint bufferCount)
{
@@ -189,71 +189,47 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)41636.0f;
- case 2:
- return (uint)97861.0f;
- case 4:
- return (uint)192520.0f;
- case 6:
- return (uint)301760.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)41636.0f,
+ 2 => (uint)97861.0f,
+ 4 => (uint)192520.0f,
+ 6 => (uint)301760.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)578.53f;
- case 2:
- return (uint)663.06f;
- case 4:
- return (uint)703.98f;
- case 6:
- return (uint)760.03f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)578.53f,
+ 2 => (uint)663.06f,
+ 4 => (uint)703.98f,
+ 6 => (uint)760.03f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)8770.3f;
- case 2:
- return (uint)25741.0f;
- case 4:
- return (uint)47551.0f;
- case 6:
- return (uint)81629.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)8770.3f,
+ 2 => (uint)25741.0f,
+ 4 => (uint)47551.0f,
+ 6 => (uint)81629.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)521.28f;
- case 2:
- return (uint)585.4f;
- case 4:
- return (uint)629.88f;
- case 6:
- return (uint)713.57f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)521.28f,
+ 2 => (uint)585.4f,
+ 4 => (uint)629.88f,
+ 6 => (uint)713.57f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public uint Estimate(ReverbCommand command)
@@ -264,71 +240,47 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)97192.0f;
- case 2:
- return (uint)103280.0f;
- case 4:
- return (uint)109580.0f;
- case 6:
- return (uint)115070.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)97192.0f,
+ 2 => (uint)103280.0f,
+ 4 => (uint)109580.0f,
+ 6 => (uint)115070.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)492.01f;
- case 2:
- return (uint)554.46f;
- case 4:
- return (uint)595.86f;
- case 6:
- return (uint)656.62f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)492.01f,
+ 2 => (uint)554.46f,
+ 4 => (uint)595.86f,
+ 6 => (uint)656.62f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)136460.0f;
- case 2:
- return (uint)145750.0f;
- case 4:
- return (uint)154800.0f;
- case 6:
- return (uint)161970.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)136460.0f,
+ 2 => (uint)145750.0f,
+ 4 => (uint)154800.0f,
+ 6 => (uint)161970.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)495.79f;
- case 2:
- return (uint)527.16f;
- case 4:
- return (uint)598.75f;
- case 6:
- return (uint)666.03f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)495.79f,
+ 2 => (uint)527.16f,
+ 4 => (uint)598.75f,
+ 6 => (uint)666.03f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public uint Estimate(Reverb3dCommand command)
@@ -339,70 +291,46 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)138840.0f;
- case 2:
- return (uint)135430.0f;
- case 4:
- return (uint)199180.0f;
- case 6:
- return (uint)247350.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)138840.0f,
+ 2 => (uint)135430.0f,
+ 4 => (uint)199180.0f,
+ 6 => (uint)247350.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)718.7f;
- case 2:
- return (uint)751.3f;
- case 4:
- return (uint)797.46f;
- case 6:
- return (uint)867.43f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)718.7f,
+ 2 => (uint)751.3f,
+ 4 => (uint)797.46f,
+ 6 => (uint)867.43f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)199950.0f;
- case 2:
- return (uint)195200.0f;
- case 4:
- return (uint)290580.0f;
- case 6:
- return (uint)363490.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)199950.0f,
+ 2 => (uint)195200.0f,
+ 4 => (uint)290580.0f,
+ 6 => (uint)363490.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)534.24f;
- case 2:
- return (uint)570.87f;
- case 4:
- return (uint)660.93f;
- case 6:
- return (uint)694.6f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)534.24f,
+ 2 => (uint)570.87f,
+ 4 => (uint)660.93f,
+ 6 => (uint)694.6f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public uint Estimate(AuxiliaryBufferCommand command)
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs
index b79ca1369..8ae4bc059 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs
@@ -12,20 +12,20 @@ namespace Ryujinx.Audio.Renderer.Server
///
public class CommandProcessingTimeEstimatorVersion3 : ICommandProcessingTimeEstimator
{
- protected uint _sampleCount;
- protected uint _bufferCount;
+ protected uint SampleCount;
+ protected uint BufferCount;
public CommandProcessingTimeEstimatorVersion3(uint sampleCount, uint bufferCount)
{
- _sampleCount = sampleCount;
- _bufferCount = bufferCount;
+ SampleCount = sampleCount;
+ BufferCount = bufferCount;
}
public uint Estimate(PerformanceCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)498.17f;
}
@@ -35,24 +35,24 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(ClearMixBufferCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
float costPerBuffer = 440.68f;
float baseCost = 0;
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
costPerBuffer = 266.65f;
}
- return (uint)(baseCost + costPerBuffer * _bufferCount);
+ return (uint)(baseCost + costPerBuffer * BufferCount);
}
public uint Estimate(BiquadFilterCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)4173.2f;
}
@@ -64,9 +64,9 @@ namespace Ryujinx.Audio.Renderer.Server
{
float costPerSample = 6.4434f;
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
costPerSample = 6.708f;
}
@@ -81,14 +81,14 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
- return (uint)(_sampleCount * costPerSample * volumeCount);
+ return (uint)(SampleCount * costPerSample * volumeCount);
}
public uint Estimate(MixRampCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)1968.7f;
}
@@ -103,9 +103,9 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(VolumeRampCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)1425.3f;
}
@@ -115,41 +115,41 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(PcmInt16DataSourceCommandVersion1 command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
float costPerSample = 710.143f;
float baseCost = 7853.286f;
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
costPerSample = 427.52f;
baseCost = 6329.442f;
}
- return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
+ return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
}
public uint Estimate(AdpcmDataSourceCommandVersion1 command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
float costPerSample = 3564.1f;
float baseCost = 9736.702f;
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
costPerSample = 2125.6f;
baseCost = 7913.808f;
}
- return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
+ return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
}
public uint Estimate(DepopForMixBuffersCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)739.64f;
}
@@ -159,9 +159,9 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(CopyMixBufferCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)842.59f;
}
@@ -171,9 +171,9 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(MixCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)1402.8f;
}
@@ -183,231 +183,159 @@ namespace Ryujinx.Audio.Renderer.Server
public virtual uint Estimate(DelayCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)8929.04f;
- case 2:
- return (uint)25500.75f;
- case 4:
- return (uint)47759.62f;
- case 6:
- return (uint)82203.07f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)8929.04f,
+ 2 => (uint)25500.75f,
+ 4 => (uint)47759.62f,
+ 6 => (uint)82203.07f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)1295.20f;
- case 2:
- return (uint)1213.60f;
- case 4:
- return (uint)942.03f;
- case 6:
- return (uint)1001.55f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)1295.20f,
+ 2 => (uint)1213.60f,
+ 4 => (uint)942.03f,
+ 6 => (uint)1001.55f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)11941.05f;
- case 2:
- return (uint)37197.37f;
- case 4:
- return (uint)69749.84f;
- case 6:
- return (uint)120042.40f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)11941.05f,
+ 2 => (uint)37197.37f,
+ 4 => (uint)69749.84f,
+ 6 => (uint)120042.40f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)997.67f;
- case 2:
- return (uint)977.63f;
- case 4:
- return (uint)792.30f;
- case 6:
- return (uint)875.43f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)997.67f,
+ 2 => (uint)977.63f,
+ 4 => (uint)792.30f,
+ 6 => (uint)875.43f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public virtual uint Estimate(ReverbCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)81475.05f;
- case 2:
- return (uint)84975.0f;
- case 4:
- return (uint)91625.15f;
- case 6:
- return (uint)95332.27f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)81475.05f,
+ 2 => (uint)84975.0f,
+ 4 => (uint)91625.15f,
+ 6 => (uint)95332.27f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)536.30f;
- case 2:
- return (uint)588.70f;
- case 4:
- return (uint)643.70f;
- case 6:
- return (uint)706.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)536.30f,
+ 2 => (uint)588.70f,
+ 4 => (uint)643.70f,
+ 6 => (uint)706.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)120174.47f;
- case 2:
- return (uint)25262.22f;
- case 4:
- return (uint)135751.23f;
- case 6:
- return (uint)141129.23f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)120174.47f,
+ 2 => (uint)25262.22f,
+ 4 => (uint)135751.23f,
+ 6 => (uint)141129.23f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)617.64f;
- case 2:
- return (uint)659.54f;
- case 4:
- return (uint)711.43f;
- case 6:
- return (uint)778.07f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)617.64f,
+ 2 => (uint)659.54f,
+ 4 => (uint)711.43f,
+ 6 => (uint)778.07f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public virtual uint Estimate(Reverb3dCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)116754.0f;
- case 2:
- return (uint)125912.05f;
- case 4:
- return (uint)146336.03f;
- case 6:
- return (uint)165812.66f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)116754.0f,
+ 2 => (uint)125912.05f,
+ 4 => (uint)146336.03f,
+ 6 => (uint)165812.66f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)734.0f;
- case 2:
- return (uint)766.62f;
- case 4:
- return (uint)797.46f;
- case 6:
- return (uint)867.43f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)734.0f,
+ 2 => (uint)766.62f,
+ 4 => (uint)797.46f,
+ 6 => (uint)867.43f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)170292.34f;
- case 2:
- return (uint)183875.63f;
- case 4:
- return (uint)214696.19f;
- case 6:
- return (uint)243846.77f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)170292.34f,
+ 2 => (uint)183875.63f,
+ 4 => (uint)214696.19f,
+ 6 => (uint)243846.77f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)508.47f;
- case 2:
- return (uint)582.45f;
- case 4:
- return (uint)626.42f;
- case 6:
- return (uint)682.47f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)508.47f,
+ 2 => (uint)582.45f,
+ 4 => (uint)626.42f,
+ 6 => (uint)682.47f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public uint Estimate(AuxiliaryBufferCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
@@ -427,9 +355,9 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(VolumeCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)1311.1f;
}
@@ -439,12 +367,12 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(CircularBufferSinkCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
float costPerBuffer = 770.26f;
float baseCost = 0f;
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
costPerBuffer = 531.07f;
}
@@ -454,9 +382,9 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(DownMixSurroundToStereoCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)9949.7f;
}
@@ -466,9 +394,9 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(UpsampleCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)312990.0f;
}
@@ -478,12 +406,12 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(DeviceSinkCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
Debug.Assert(command.InputCount == 2 || command.InputCount == 6);
if (command.InputCount == 2)
{
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)8980.0f;
}
@@ -491,7 +419,7 @@ namespace Ryujinx.Audio.Renderer.Server
return (uint)9221.9f;
}
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)9177.9f;
}
@@ -501,27 +429,27 @@ namespace Ryujinx.Audio.Renderer.Server
public uint Estimate(PcmFloatDataSourceCommandVersion1 command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
float costPerSample = 3490.9f;
float baseCost = 10090.9f;
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
costPerSample = 2310.4f;
baseCost = 7845.25f;
}
- return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f))));
+ return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f))));
}
public uint Estimate(DataSourceVersion2Command command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- (float baseCost, float costPerSample) = GetCostByFormat(_sampleCount, command.SampleFormat, command.SrcQuality);
+ (float baseCost, float costPerSample) = GetCostByFormat(SampleCount, command.SampleFormat, command.SrcQuality);
- return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / _sampleCount) * (command.Pitch * 0.000030518f) - 1.0f)));
+ return (uint)(baseCost + (costPerSample * (((command.SampleRate / 200.0f) / SampleCount) * (command.Pitch * 0.000030518f) - 1.0f)));
}
private static (float, float) GetCostByFormat(uint sampleCount, SampleFormat format, SampleRateConversionQuality quality)
@@ -618,124 +546,90 @@ namespace Ryujinx.Audio.Renderer.Server
private uint EstimateLimiterCommandCommon(LimiterParameter parameter, bool enabled)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (enabled)
{
- switch (parameter.ChannelCount)
+ return parameter.ChannelCount switch
{
- case 1:
- return (uint)21392.0f;
- case 2:
- return (uint)26829.0f;
- case 4:
- return (uint)32405.0f;
- case 6:
- return (uint)52219.0f;
- default:
- throw new NotImplementedException($"{parameter.ChannelCount}");
- }
+ 1 => (uint)21392.0f,
+ 2 => (uint)26829.0f,
+ 4 => (uint)32405.0f,
+ 6 => (uint)52219.0f,
+ _ => throw new NotImplementedException($"{parameter.ChannelCount}"),
+ };
}
- else
+
+ return parameter.ChannelCount switch
{
- switch (parameter.ChannelCount)
- {
- case 1:
- return (uint)897.0f;
- case 2:
- return (uint)931.55f;
- case 4:
- return (uint)975.39f;
- case 6:
- return (uint)1016.8f;
- default:
- throw new NotImplementedException($"{parameter.ChannelCount}");
- }
- }
+ 1 => (uint)897.0f,
+ 2 => (uint)931.55f,
+ 4 => (uint)975.39f,
+ 6 => (uint)1016.8f,
+ _ => throw new NotImplementedException($"{parameter.ChannelCount}"),
+ };
}
if (enabled)
{
- switch (parameter.ChannelCount)
+ return parameter.ChannelCount switch
{
- case 1:
- return (uint)30556.0f;
- case 2:
- return (uint)39011.0f;
- case 4:
- return (uint)48270.0f;
- case 6:
- return (uint)76712.0f;
- default:
- throw new NotImplementedException($"{parameter.ChannelCount}");
- }
+ 1 => (uint)30556.0f,
+ 2 => (uint)39011.0f,
+ 4 => (uint)48270.0f,
+ 6 => (uint)76712.0f,
+ _ => throw new NotImplementedException($"{parameter.ChannelCount}"),
+ };
}
- else
+
+ return parameter.ChannelCount switch
{
- switch (parameter.ChannelCount)
- {
- case 1:
- return (uint)874.43f;
- case 2:
- return (uint)921.55f;
- case 4:
- return (uint)945.26f;
- case 6:
- return (uint)992.26f;
- default:
- throw new NotImplementedException($"{parameter.ChannelCount}");
- }
- }
+ 1 => (uint)874.43f,
+ 2 => (uint)921.55f,
+ 4 => (uint)945.26f,
+ 6 => (uint)992.26f,
+ _ => throw new NotImplementedException($"{parameter.ChannelCount}"),
+ };
}
public uint Estimate(LimiterCommandVersion1 command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
}
public uint Estimate(LimiterCommandVersion2 command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
if (!command.Parameter.StatisticsEnabled || !command.IsEffectEnabled)
{
return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled);
}
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)23309.0f;
- case 2:
- return (uint)29954.0f;
- case 4:
- return (uint)35807.0f;
- case 6:
- return (uint)58340.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)23309.0f,
+ 2 => (uint)29954.0f,
+ 4 => (uint)35807.0f,
+ 6 => (uint)58340.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return (uint)33526.0f;
- case 2:
- return (uint)43549.0f;
- case 4:
- return (uint)52190.0f;
- case 6:
- return (uint)85527.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => (uint)33526.0f,
+ 2 => (uint)43549.0f,
+ 4 => (uint)52190.0f,
+ 6 => (uint)85527.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public virtual uint Estimate(GroupedBiquadFilterCommand command)
@@ -753,4 +647,4 @@ namespace Ryujinx.Audio.Renderer.Server
return 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs
index c60d8ebcb..25bc67cd9 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs
@@ -12,9 +12,9 @@ namespace Ryujinx.Audio.Renderer.Server
public override uint Estimate(GroupedBiquadFilterCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
return (uint)7424.5f;
}
@@ -24,9 +24,9 @@ namespace Ryujinx.Audio.Renderer.Server
public override uint Estimate(CaptureBufferCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
@@ -44,4 +44,4 @@ namespace Ryujinx.Audio.Renderer.Server
return (uint)435.2f;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs
index 2ed7e6a5b..7135c1c4f 100644
--- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs
@@ -13,298 +13,202 @@ namespace Ryujinx.Audio.Renderer.Server
public override uint Estimate(DelayCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 8929;
- case 2:
- return 25501;
- case 4:
- return 47760;
- case 6:
- return 82203;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 8929,
+ 2 => 25501,
+ 4 => 47760,
+ 6 => 82203,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)1295.20f;
- case 2:
- return (uint)1213.60f;
- case 4:
- return (uint)942.03f;
- case 6:
- return (uint)1001.6f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)1295.20f,
+ 2 => (uint)1213.60f,
+ 4 => (uint)942.03f,
+ 6 => (uint)1001.6f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 11941;
- case 2:
- return 37197;
- case 4:
- return 69750;
- case 6:
- return 12004;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 11941,
+ 2 => 37197,
+ 4 => 69750,
+ 6 => 12004,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)997.67f;
- case 2:
- return (uint)977.63f;
- case 4:
- return (uint)792.31f;
- case 6:
- return (uint)875.43f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)997.67f,
+ 2 => (uint)977.63f,
+ 4 => (uint)792.31f,
+ 6 => (uint)875.43f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public override uint Estimate(ReverbCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 81475;
- case 2:
- return 84975;
- case 4:
- return 91625;
- case 6:
- return 95332;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 81475,
+ 2 => 84975,
+ 4 => 91625,
+ 6 => 95332,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)536.30f;
- case 2:
- return (uint)588.80f;
- case 4:
- return (uint)643.70f;
- case 6:
- return (uint)706.0f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)536.30f,
+ 2 => (uint)588.80f,
+ 4 => (uint)643.70f,
+ 6 => (uint)706.0f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 120170;
- case 2:
- return 125260;
- case 4:
- return 135750;
- case 6:
- return 141130;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 120170,
+ 2 => 125260,
+ 4 => 135750,
+ 6 => 141130,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)617.64f;
- case 2:
- return (uint)659.54f;
- case 4:
- return (uint)711.44f;
- case 6:
- return (uint)778.07f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)617.64f,
+ 2 => (uint)659.54f,
+ 4 => (uint)711.44f,
+ 6 => (uint)778.07f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public override uint Estimate(Reverb3dCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 116750;
- case 2:
- return 125910;
- case 4:
- return 146340;
- case 6:
- return 165810;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 116750,
+ 2 => 125910,
+ 4 => 146340,
+ 6 => 165810,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return 735;
- case 2:
- return (uint)766.62f;
- case 4:
- return (uint)834.07f;
- case 6:
- return (uint)875.44f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => 735,
+ 2 => (uint)766.62f,
+ 4 => (uint)834.07f,
+ 6 => (uint)875.44f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 170290;
- case 2:
- return 183880;
- case 4:
- return 214700;
- case 6:
- return 243850;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 170290,
+ 2 => 183880,
+ 4 => 214700,
+ 6 => 243850,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)508.47f;
- case 2:
- return (uint)582.45f;
- case 4:
- return (uint)626.42f;
- case 6:
- return (uint)682.47f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)508.47f,
+ 2 => (uint)582.45f,
+ 4 => (uint)626.42f,
+ 6 => (uint)682.47f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
public override uint Estimate(CompressorCommand command)
{
- Debug.Assert(_sampleCount == 160 || _sampleCount == 240);
+ Debug.Assert(SampleCount == 160 || SampleCount == 240);
- if (_sampleCount == 160)
+ if (SampleCount == 160)
{
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 34431;
- case 2:
- return 44253;
- case 4:
- return 63827;
- case 6:
- return 83361;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 34431,
+ 2 => 44253,
+ 4 => 63827,
+ 6 => 83361,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)630.12f;
- case 2:
- return (uint)638.27f;
- case 4:
- return (uint)705.86f;
- case 6:
- return (uint)782.02f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)630.12f,
+ 2 => (uint)638.27f,
+ 4 => (uint)705.86f,
+ 6 => (uint)782.02f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
if (command.Enabled)
{
- switch (command.Parameter.ChannelCount)
+ return command.Parameter.ChannelCount switch
{
- case 1:
- return 51095;
- case 2:
- return 65693;
- case 4:
- return 95383;
- case 6:
- return 124510;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
+ 1 => 51095,
+ 2 => 65693,
+ 4 => 95383,
+ 6 => 124510,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
- else
+
+ return command.Parameter.ChannelCount switch
{
- switch (command.Parameter.ChannelCount)
- {
- case 1:
- return (uint)840.14f;
- case 2:
- return (uint)826.1f;
- case 4:
- return (uint)901.88f;
- case 6:
- return (uint)965.29f;
- default:
- throw new NotImplementedException($"{command.Parameter.ChannelCount}");
- }
- }
+ 1 => (uint)840.14f,
+ 2 => (uint)826.1f,
+ 4 => (uint)901.88f,
+ 6 => (uint)965.29f,
+ _ => throw new NotImplementedException($"{command.Parameter.ChannelCount}"),
+ };
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs
index 164065271..57ca266f4 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs
@@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
{
ulong bufferSize = (ulong)Unsafe.SizeOf() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf();
- bool sendBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize);
+ bool sendBufferUnmapped = !mapper.TryAttachBuffer(out _, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize);
bool returnBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[1], Parameter.ReturnBufferInfoAddress, bufferSize);
BufferUnmapped = sendBufferUnmapped && returnBufferUnmapped;
@@ -82,4 +82,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
UpdateUsageStateForCommandGeneration();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs
index 825b3bf76..a9716db2a 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs
@@ -244,29 +244,19 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
/// The associated to the of this effect.
public PerformanceDetailType GetPerformanceDetailType()
{
- switch (Type)
+ return Type switch
{
- case EffectType.BiquadFilter:
- return PerformanceDetailType.BiquadFilter;
- case EffectType.AuxiliaryBuffer:
- return PerformanceDetailType.Aux;
- case EffectType.Delay:
- return PerformanceDetailType.Delay;
- case EffectType.Reverb:
- return PerformanceDetailType.Reverb;
- case EffectType.Reverb3d:
- return PerformanceDetailType.Reverb3d;
- case EffectType.BufferMix:
- return PerformanceDetailType.Mix;
- case EffectType.Limiter:
- return PerformanceDetailType.Limiter;
- case EffectType.CaptureBuffer:
- return PerformanceDetailType.CaptureBuffer;
- case EffectType.Compressor:
- return PerformanceDetailType.Compressor;
- default:
- throw new NotImplementedException($"{Type}");
- }
+ EffectType.BiquadFilter => PerformanceDetailType.BiquadFilter,
+ EffectType.AuxiliaryBuffer => PerformanceDetailType.Aux,
+ EffectType.Delay => PerformanceDetailType.Delay,
+ EffectType.Reverb => PerformanceDetailType.Reverb,
+ EffectType.Reverb3d => PerformanceDetailType.Reverb3d,
+ EffectType.BufferMix => PerformanceDetailType.Mix,
+ EffectType.Limiter => PerformanceDetailType.Limiter,
+ EffectType.CaptureBuffer => PerformanceDetailType.CaptureBuffer,
+ EffectType.Compressor => PerformanceDetailType.Compressor,
+ _ => throw new NotImplementedException($"{Type}"),
+ };
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs
index de91046dc..b987f7c85 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs
@@ -64,4 +64,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
Parameter.Status = UsageState.Enabled;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs
index 82c0a055a..d6cb9cfa3 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs
@@ -46,4 +46,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
UpdateUsageStateForCommandGeneration();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs
index c445798d4..5be4b4ed5 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs
@@ -79,4 +79,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
UpdateUsageStateForCommandGeneration();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs
index 3f5d70bcf..43cabb7db 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs
@@ -90,4 +90,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
Parameter.Status = UsageState.Enabled;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs
index bfb6528b4..619f31100 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs
@@ -120,4 +120,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs
index 6e17ef3d1..3e2f7326d 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs
@@ -92,4 +92,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
destState = srcState;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs
index 473fddb84..f9d7f4943 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs
@@ -89,4 +89,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
Parameter.ParameterStatus = UsageState.Enabled;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs
index e1543fd17..6fdf8fc23 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs
@@ -92,4 +92,4 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
Parameter.Status = UsageState.Enabled;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs b/src/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs
index 8648aa2ca..da7172244 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs
@@ -23,6 +23,6 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
///
/// The effect is disabled.
///
- Disabled
+ Disabled,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/ICommandProcessingTimeEstimator.cs b/src/Ryujinx.Audio/Renderer/Server/ICommandProcessingTimeEstimator.cs
index 4872ddb3a..27b22363a 100644
--- a/src/Ryujinx.Audio/Renderer/Server/ICommandProcessingTimeEstimator.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/ICommandProcessingTimeEstimator.cs
@@ -37,4 +37,4 @@ namespace Ryujinx.Audio.Renderer.Server
uint Estimate(CaptureBufferCommand command);
uint Estimate(CompressorCommand command);
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/AddressInfo.cs b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/AddressInfo.cs
index 5fd6b2b92..a7ec4cf51 100644
--- a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/AddressInfo.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/AddressInfo.cs
@@ -27,9 +27,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
///
public DspAddress ForceMappedDspAddress;
- private unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
+ private readonly unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
- public unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
+ public readonly unsafe bool HasMemoryPoolState => (IntPtr)_memoryPools != IntPtr.Zero;
///
/// Create an new empty .
@@ -55,7 +55,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
CpuAddress = cpuAddress,
_memoryPools = MemoryPoolState.Null,
Size = size,
- ForceMappedDspAddress = 0
+ ForceMappedDspAddress = 0,
};
}
}
@@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// Check if the is mapped.
///
/// Returns true if the is mapped.
- public bool HasMappedMemoryPool()
+ public readonly bool HasMappedMemoryPool()
{
return HasMemoryPoolState && MemoryPoolState.IsMapped();
}
@@ -115,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
///
/// If true, mark the as used.
/// Returns the DSP address associated to the .
- public DspAddress GetReference(bool markUsed)
+ public readonly DspAddress GetReference(bool markUsed)
{
if (!HasMappedMemoryPool())
{
@@ -130,4 +130,4 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
return MemoryPoolState.Translate(CpuAddress, Size);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs
index 69466bab5..91bd5dbf5 100644
--- a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/MemoryPoolState.cs
@@ -26,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
///
/// located on the DSP side for system use.
///
- Dsp
+ Dsp,
}
///
@@ -69,7 +69,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
CpuAddress = 0,
DspAddress = 0,
Size = 0,
- Location = location
+ Location = location,
};
}
@@ -90,7 +90,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// The .
/// The size.
/// True if the is contained inside the .
- public bool Contains(CpuAddress targetCpuAddress, ulong size)
+ public readonly bool Contains(CpuAddress targetCpuAddress, ulong size)
{
if (CpuAddress <= targetCpuAddress && size + targetCpuAddress <= Size + CpuAddress)
{
@@ -106,7 +106,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// The .
/// The size.
/// the target DSP address.
- public DspAddress Translate(CpuAddress targetCpuAddress, ulong size)
+ public readonly DspAddress Translate(CpuAddress targetCpuAddress, ulong size)
{
if (Contains(targetCpuAddress, size) && IsMapped())
{
@@ -122,9 +122,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// Is the mapped on the DSP?
///
/// Returns true if the is mapped on the DSP.
- public bool IsMapped()
+ public readonly bool IsMapped()
{
return DspAddress != 0;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs
index 4a29ead3e..391b80f8d 100644
--- a/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/MemoryPool/PoolMapper.cs
@@ -40,23 +40,23 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
///
/// unmapping failed.
///
- UnmapError = 3
+ UnmapError = 3,
}
///
/// The handle of the process owning the CPU memory manipulated.
///
- private uint _processHandle;
+ private readonly uint _processHandle;
///
/// The that will be manipulated.
///
- private Memory _memoryPools;
+ private readonly Memory _memoryPools;
///
/// If set to true, this will try to force map memory pool even if their state are considered invalid.
///
- private bool _isForceMapEnabled;
+ private readonly bool _isForceMapEnabled;
///
/// Create a new used for system mapping.
@@ -125,7 +125,8 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
{
return CurrentProcessPseudoHandle;
}
- else if (memoryPool.Location == MemoryPoolState.LocationType.Dsp)
+
+ if (memoryPool.Location == MemoryPoolState.LocationType.Dsp)
{
return _processHandle;
}
@@ -234,13 +235,11 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
return true;
}
- else
- {
- errorInfo.ErrorCode = ResultCode.InvalidAddressInfo;
- errorInfo.ExtraErrorInfo = addressInfo.CpuAddress;
- return _isForceMapEnabled;
- }
+ errorInfo.ErrorCode = ResultCode.InvalidAddressInfo;
+ errorInfo.ExtraErrorInfo = addressInfo.CpuAddress;
+
+ return _isForceMapEnabled;
}
///
diff --git a/src/Ryujinx.Audio/Renderer/Server/Mix/MixContext.cs b/src/Ryujinx.Audio/Renderer/Server/Mix/MixContext.cs
index cda6f737c..8991ceaf9 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Mix/MixContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Mix/MixContext.cs
@@ -206,7 +206,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
{
UpdateDistancesFromFinalMix();
- int[] sortedMixesTemp = _sortedMixes.Slice(0, (int)GetCount()).ToArray();
+ int[] sortedMixesTemp = _sortedMixes[..(int)GetCount()].ToArray();
Array.Sort(sortedMixesTemp, (a, b) =>
{
@@ -248,12 +248,10 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
return isValid;
}
- else
- {
- UpdateMixBufferOffset();
- return true;
- }
+ UpdateMixBufferOffset();
+
+ return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Mix/MixState.cs b/src/Ryujinx.Audio/Renderer/Server/Mix/MixState.cs
index 146e67811..88ae44831 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Mix/MixState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Mix/MixState.cs
@@ -7,7 +7,6 @@ using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-
using static Ryujinx.Audio.Constants;
namespace Ryujinx.Audio.Renderer.Server.Mix
@@ -66,7 +65,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
///
/// The effect processing order storage.
///
- private IntPtr _effectProcessingOrderArrayPointer;
+ private readonly IntPtr _effectProcessingOrderArrayPointer;
///
/// The max element count that can be found in the effect processing order storage.
@@ -120,7 +119,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
///
/// The array used to order effects associated to this mix.
///
- public Span EffectProcessingOrderArray
+ public readonly Span EffectProcessingOrderArray
{
get
{
@@ -175,7 +174,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
///
/// Clear the to its default state.
///
- public void ClearEffectProcessingOrder()
+ public readonly void ClearEffectProcessingOrder()
{
EffectProcessingOrderArray.Fill(-1);
}
@@ -184,7 +183,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
/// Return true if the mix has any destinations.
///
/// True if the mix has any destinations.
- public bool HasAnyDestination()
+ public readonly bool HasAnyDestination()
{
return DestinationMixId != UnusedMixId || DestinationSplitterId != UnusedSplitterId;
}
@@ -310,4 +309,4 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
return isDirty;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs b/src/Ryujinx.Audio/Renderer/Server/Performance/IPerformanceDetailEntry.cs
index dbe59cb0d..ffabf4676 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
/// The type to use.
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 9888a4cc1..a0178187b 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
/// The type to use.
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 21876b4b4..deacd8ccc 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
/// The total count of detailed entries in this frame.
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 22704c0d1..a4024607c 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
///
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 05ecda9b6..f10e2937e 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
///
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 1b8d8668a..d24b96a27 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 fa2d32164..2c407670f 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
///
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 49d4b3ce0..eb96a3141 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
///
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 5fe6bff06..5aeb703c5 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
///
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 a18229686..d6e0ffc8b 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 f996441c0..0a035916c 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.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(performanceBuffer,
- ref parameter);
- case 2:
- return new PerformanceManagerGeneric(performanceBuffer,
- ref parameter);
- default:
- throw new NotImplementedException($"Unknown Performance metrics data format version {version}");
- }
+ 1 => new PerformanceManagerGeneric(performanceBuffer, ref parameter),
+ 2 => new PerformanceManagerGeneric(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 18e77391d..5a70a1bcf 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
///
private const int MaxFrameDetailCount = 100;
- private Memory _buffer;
- private Memory _historyBuffer;
+ private readonly Memory _buffer;
+ private readonly Memory _historyBuffer;
- private Memory CurrentBuffer => _buffer.Slice(0, _frameSize);
- private Memory CurrentBufferData => CurrentBuffer.Slice(Unsafe.SizeOf());
+ private Memory CurrentBuffer => _buffer[.._frameSize];
+ private Memory CurrentBufferData => CurrentBuffer[Unsafe.SizeOf()..];
private ref THeader CurrentHeader => ref MemoryMarshal.Cast(CurrentBuffer.Span)[0];
- private Span Entries => MemoryMarshal.Cast(CurrentBufferData.Span.Slice(0, GetEntriesSize()));
+ private Span Entries => MemoryMarshal.Cast(CurrentBufferData.Span[..GetEntriesSize()]);
private Span EntriesDetail => MemoryMarshal.Cast(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 inputEntries = GetEntriesFromBuffer(_historyBuffer.Span, _indexHistoryRead);
Span inputEntriesDetail = GetEntriesDetailFromBuffer(_historyBuffer.Span, _indexHistoryRead);
- Span targetSpan = performanceOutput.Slice(nextOffset);
+ Span targetSpan = performanceOutput[nextOffset..];
// NOTE: We check for the space for two headers for the final blank header.
int requiredSpace = Unsafe.SizeOf() + Unsafe.SizeOf() * inputHeader.GetEntryCount()
@@ -146,7 +146,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
nextOffset += Unsafe.SizeOf();
- Span outputEntries = MemoryMarshal.Cast(performanceOutput.Slice(nextOffset));
+ Span outputEntries = MemoryMarshal.Cast(performanceOutput[nextOffset..]);
int totalProcessingTime = 0;
@@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
}
}
- Span outputEntriesDetail = MemoryMarshal.Cast(performanceOutput.Slice(nextOffset));
+ Span outputEntriesDetail = MemoryMarshal.Cast(performanceOutput[nextOffset..]);
int effectiveEntryDetailCount = 0;
@@ -198,7 +198,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
if (nextOffset < performanceOutput.Length && (performanceOutput.Length - nextOffset) >= Unsafe.SizeOf())
{
- ref THeader outputHeader = ref MemoryMarshal.Cast(performanceOutput.Slice(nextOffset))[0];
+ ref THeader outputHeader = ref MemoryMarshal.Cast(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.Cast(CurrentBuffer);
- performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
+ performanceEntry = new PerformanceEntryAddresses
+ {
+ BaseMemory = SpanMemoryManager.Cast(CurrentBuffer),
+ EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
+ };
uint baseEntryOffset = (uint)(Unsafe.SizeOf() + Unsafe.SizeOf() * _entryIndex);
@@ -237,9 +239,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
return false;
}
- performanceEntry = new PerformanceEntryAddresses();
- performanceEntry.BaseMemory = SpanMemoryManager.Cast(CurrentBuffer);
- performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
+ performanceEntry = new PerformanceEntryAddresses
+ {
+ BaseMemory = SpanMemoryManager.Cast(CurrentBuffer),
+ EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
+ };
uint baseEntryOffset = (uint)(Unsafe.SizeOf() + GetEntriesSize() + Unsafe.SizeOf() * _entryDetailIndex);
@@ -301,4 +305,4 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/RendererSystemContext.cs b/src/Ryujinx.Audio/Renderer/Server/RendererSystemContext.cs
index 164567806..090850018 100644
--- a/src/Ryujinx.Audio/Renderer/Server/RendererSystemContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/RendererSystemContext.cs
@@ -45,4 +45,4 @@ namespace Ryujinx.Audio.Renderer.Server
///
public Memory DepopBuffer;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Sink/BaseSink.cs b/src/Ryujinx.Audio/Renderer/Server/Sink/BaseSink.cs
index f7b639975..d36c5e260 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Sink/BaseSink.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Sink/BaseSink.cs
@@ -99,4 +99,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
errorInfo = new ErrorInfo();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Sink/CircularBufferSink.cs b/src/Ryujinx.Audio/Renderer/Server/Sink/CircularBufferSink.cs
index 722d8c4b4..097757988 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Sink/CircularBufferSink.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Sink/CircularBufferSink.cs
@@ -106,4 +106,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
base.CleanUp();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Sink/DeviceSink.cs b/src/Ryujinx.Audio/Renderer/Server/Sink/DeviceSink.cs
index de345d3ad..e03fe11d4 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Sink/DeviceSink.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Sink/DeviceSink.cs
@@ -72,4 +72,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
outStatus = new SinkOutStatus();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Sink/SinkContext.cs b/src/Ryujinx.Audio/Renderer/Server/Sink/SinkContext.cs
index b57d39908..951984d8c 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Sink/SinkContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Sink/SinkContext.cs
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
return ref _sinks[id];
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterContext.cs b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterContext.cs
index 91877cdda..e408692ab 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterContext.cs
@@ -101,10 +101,8 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
return size;
}
- else
- {
- return size;
- }
+
+ return size;
}
///
@@ -164,10 +162,10 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
ref SplitterState splitter = ref GetState(parameter.Id);
- splitter.Update(this, ref parameter, input.Slice(Unsafe.SizeOf()));
+ splitter.Update(this, ref parameter, input[Unsafe.SizeOf()..]);
}
- input = input.Slice(0x1C + (int)parameter.DestinationCount * 4);
+ input = input[(0x1C + parameter.DestinationCount * 4)..];
}
}
}
@@ -194,7 +192,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
destination.Update(parameter);
}
- input = input.Slice(Unsafe.SizeOf());
+ input = input[Unsafe.SizeOf()..];
}
}
}
@@ -229,12 +227,10 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
return true;
}
- else
- {
- consumedSize = 0;
- return false;
- }
+ consumedSize = 0;
+
+ return false;
}
///
@@ -300,4 +296,4 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs
index c074e4a72..1faf7921f 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterDestination.cs
@@ -65,7 +65,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
///
/// Get the of the next element or if not present.
///
- public Span Next
+ public readonly Span Next
{
get
{
@@ -138,7 +138,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// Return true if the is used and has a destination.
///
/// True if the is used and has a destination.
- public bool IsConfigured()
+ public readonly bool IsConfigured()
{
return IsUsed && DestinationId != Constants.UnusedMixId;
}
@@ -160,8 +160,8 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
///
public void ClearVolumes()
{
- MixBufferVolume.Fill(0);
- PreviousMixBufferVolume.Fill(0);
+ MixBufferVolume.Clear();
+ PreviousMixBufferVolume.Clear();
}
///
@@ -190,4 +190,4 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterState.cs b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterState.cs
index 15a0c6ba4..e08ee9ea7 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Splitter/SplitterState.cs
@@ -43,7 +43,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
///
/// Span to the first element of the linked list of .
///
- public Span Destinations
+ public readonly Span Destinations
{
get
{
@@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
Id = id;
}
- public Span GetData(int index)
+ public readonly Span GetData(int index)
{
int i = 0;
@@ -95,7 +95,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// Utility function to apply a given to all .
///
/// The action to execute on each elements.
- private void ForEachDestination(SpanAction action)
+ private readonly void ForEachDestination(SpanAction action)
{
Span temp = Destinations;
@@ -183,7 +183,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
///
/// Update the internal state of this instance.
///
- public void UpdateInternalState()
+ public readonly void UpdateInternalState()
{
ForEachDestination((destination, _) => destination[0].UpdateInternalState());
}
@@ -218,4 +218,4 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/StateUpdater.cs b/src/Ryujinx.Audio/Renderer/Server/StateUpdater.cs
index 5cf539c6d..22eebc7cc 100644
--- a/src/Ryujinx.Audio/Renderer/Server/StateUpdater.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/StateUpdater.cs
@@ -22,15 +22,15 @@ namespace Ryujinx.Audio.Renderer.Server
public class StateUpdater
{
private readonly ReadOnlyMemory _inputOrigin;
- private ReadOnlyMemory _outputOrigin;
+ private readonly ReadOnlyMemory _outputOrigin;
private ReadOnlyMemory _input;
private Memory _output;
- private uint _processHandle;
+ private readonly uint _processHandle;
private BehaviourContext _behaviourContext;
private UpdateDataHeader _inputHeader;
- private Memory _outputHeader;
+ private readonly Memory _outputHeader;
private ref UpdateDataHeader OutputHeader => ref _outputHeader.Span[0];
@@ -45,9 +45,9 @@ namespace Ryujinx.Audio.Renderer.Server
_inputHeader = SpanIOHelper.Read(ref _input);
- _outputHeader = SpanMemoryManager.Cast(_output.Slice(0, Unsafe.SizeOf()));
+ _outputHeader = SpanMemoryManager.Cast(_output[..Unsafe.SizeOf()]);
OutputHeader.Initialize(_behaviourContext.UserRevision);
- _output = _output.Slice(Unsafe.SizeOf());
+ _output = _output[Unsafe.SizeOf()..];
}
public ResultCode UpdateBehaviourContext()
@@ -72,7 +72,7 @@ namespace Ryujinx.Audio.Renderer.Server
public ResultCode UpdateMemoryPools(Span memoryPools)
{
- PoolMapper mapper = new PoolMapper(_processHandle, _behaviourContext.IsMemoryPoolForceMappingEnabled());
+ PoolMapper mapper = new(_processHandle, _behaviourContext.IsMemoryPoolForceMappingEnabled());
if (memoryPools.Length * Unsafe.SizeOf() != _inputHeader.MemoryPoolsSize)
{
@@ -136,11 +136,11 @@ namespace Ryujinx.Audio.Renderer.Server
int initialOutputSize = _output.Length;
- ReadOnlySpan parameters = MemoryMarshal.Cast(_input.Slice(0, (int)_inputHeader.VoicesSize).Span);
+ ReadOnlySpan parameters = MemoryMarshal.Cast(_input[..(int)_inputHeader.VoicesSize].Span);
- _input = _input.Slice((int)_inputHeader.VoicesSize);
+ _input = _input[(int)_inputHeader.VoicesSize..];
- PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
+ PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
// First make everything not in use.
for (int i = 0; i < context.GetCount(); i++)
@@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Renderer.Server
}
Memory[] voiceUpdateStatesArray = ArrayPool>.Shared.Rent(Constants.VoiceChannelCountMax);
-
+
Span> voiceUpdateStates = voiceUpdateStatesArray.AsSpan(0, Constants.VoiceChannelCountMax);
// Start processing
@@ -218,42 +218,20 @@ namespace Ryujinx.Audio.Renderer.Server
{
effect.ForceUnmapBuffers(mapper);
- switch (parameter.Type)
+ effect = parameter.Type switch
{
- case EffectType.Invalid:
- effect = new BaseEffect();
- break;
- case EffectType.BufferMix:
- effect = new BufferMixEffect();
- break;
- case EffectType.AuxiliaryBuffer:
- effect = new AuxiliaryBufferEffect();
- break;
- case EffectType.Delay:
- effect = new DelayEffect();
- break;
- case EffectType.Reverb:
- effect = new ReverbEffect();
- break;
- case EffectType.Reverb3d:
- effect = new Reverb3dEffect();
- break;
- case EffectType.BiquadFilter:
- effect = new BiquadFilterEffect();
- break;
- case EffectType.Limiter:
- effect = new LimiterEffect();
- break;
- case EffectType.CaptureBuffer:
- effect = new CaptureBufferEffect();
- break;
- case EffectType.Compressor:
- effect = new CompressorEffect();
- break;
-
- default:
- throw new NotImplementedException($"EffectType {parameter.Type} not implemented!");
- }
+ EffectType.Invalid => new BaseEffect(),
+ EffectType.BufferMix => new BufferMixEffect(),
+ EffectType.AuxiliaryBuffer => new AuxiliaryBufferEffect(),
+ EffectType.Delay => new DelayEffect(),
+ EffectType.Reverb => new ReverbEffect(),
+ EffectType.Reverb3d => new Reverb3dEffect(),
+ EffectType.BiquadFilter => new BiquadFilterEffect(),
+ EffectType.Limiter => new LimiterEffect(),
+ EffectType.CaptureBuffer => new CaptureBufferEffect(),
+ EffectType.Compressor => new CompressorEffect(),
+ _ => throw new NotImplementedException($"EffectType {parameter.Type} not implemented!"),
+ };
}
public ResultCode UpdateEffects(EffectContext context, bool isAudioRendererActive, Memory memoryPools)
@@ -262,10 +240,8 @@ namespace Ryujinx.Audio.Renderer.Server
{
return UpdateEffectsVersion2(context, isAudioRendererActive, memoryPools);
}
- else
- {
- return UpdateEffectsVersion1(context, isAudioRendererActive, memoryPools);
- }
+
+ return UpdateEffectsVersion1(context, isAudioRendererActive, memoryPools);
}
public ResultCode UpdateEffectsVersion2(EffectContext context, bool isAudioRendererActive, Memory memoryPools)
@@ -277,11 +253,11 @@ namespace Ryujinx.Audio.Renderer.Server
int initialOutputSize = _output.Length;
- ReadOnlySpan parameters = MemoryMarshal.Cast(_input.Slice(0, (int)_inputHeader.EffectsSize).Span);
+ ReadOnlySpan parameters = MemoryMarshal.Cast(_input[..(int)_inputHeader.EffectsSize].Span);
- _input = _input.Slice((int)_inputHeader.EffectsSize);
+ _input = _input[(int)_inputHeader.EffectsSize..];
- PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
+ PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
for (int i = 0; i < context.GetCount(); i++)
{
@@ -333,11 +309,11 @@ namespace Ryujinx.Audio.Renderer.Server
int initialOutputSize = _output.Length;
- ReadOnlySpan parameters = MemoryMarshal.Cast(_input.Slice(0, (int)_inputHeader.EffectsSize).Span);
+ ReadOnlySpan parameters = MemoryMarshal.Cast(_input[..(int)_inputHeader.EffectsSize].Span);
- _input = _input.Slice((int)_inputHeader.EffectsSize);
+ _input = _input[(int)_inputHeader.EffectsSize..];
- PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
+ PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
for (int i = 0; i < context.GetCount(); i++)
{
@@ -376,17 +352,15 @@ namespace Ryujinx.Audio.Renderer.Server
{
if (context.Update(_input.Span, out int consumedSize))
{
- _input = _input.Slice(consumedSize);
+ _input = _input[consumedSize..];
return ResultCode.Success;
}
- else
- {
- return ResultCode.InvalidUpdateInfo;
- }
+
+ return ResultCode.InvalidUpdateInfo;
}
- private bool CheckMixParametersValidity(MixContext mixContext, uint mixBufferCount, uint inputMixCount, ReadOnlySpan parameters)
+ private static bool CheckMixParametersValidity(MixContext mixContext, uint mixBufferCount, uint inputMixCount, ReadOnlySpan parameters)
{
uint maxMixStateCount = mixContext.GetCount();
uint totalRequiredMixBufferCount = 0;
@@ -439,12 +413,12 @@ namespace Ryujinx.Audio.Renderer.Server
if (_behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported())
{
- _input = _input.Slice(Unsafe.SizeOf());
+ _input = _input[Unsafe.SizeOf()..];
}
- ReadOnlySpan parameters = MemoryMarshal.Cast(_input.Span.Slice(0, (int)inputMixSize));
+ ReadOnlySpan parameters = MemoryMarshal.Cast(_input.Span[..(int)inputMixSize]);
- _input = _input.Slice((int)inputMixSize);
+ _input = _input[(int)inputMixSize..];
if (CheckMixParametersValidity(mixContext, mixBufferCount, mixCount, parameters))
{
@@ -506,25 +480,18 @@ namespace Ryujinx.Audio.Renderer.Server
{
sink.CleanUp();
- switch (parameter.Type)
+ sink = parameter.Type switch
{
- case SinkType.Invalid:
- sink = new BaseSink();
- break;
- case SinkType.CircularBuffer:
- sink = new CircularBufferSink();
- break;
- case SinkType.Device:
- sink = new DeviceSink();
- break;
- default:
- throw new NotImplementedException($"SinkType {parameter.Type} not implemented!");
- }
+ SinkType.Invalid => new BaseSink(),
+ SinkType.CircularBuffer => new CircularBufferSink(),
+ SinkType.Device => new DeviceSink(),
+ _ => throw new NotImplementedException($"SinkType {parameter.Type} not implemented!"),
+ };
}
public ResultCode UpdateSinks(SinkContext context, Memory memoryPools)
{
- PoolMapper mapper = new PoolMapper(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
+ PoolMapper mapper = new(_processHandle, memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
if (context.GetCount() * Unsafe.SizeOf() != _inputHeader.SinksSize)
{
@@ -533,9 +500,9 @@ namespace Ryujinx.Audio.Renderer.Server
int initialOutputSize = _output.Length;
- ReadOnlySpan parameters = MemoryMarshal.Cast(_input.Slice(0, (int)_inputHeader.SinksSize).Span);
+ ReadOnlySpan parameters = MemoryMarshal.Cast(_input[..(int)_inputHeader.SinksSize].Span);
- _input = _input.Slice((int)_inputHeader.SinksSize);
+ _input = _input[(int)_inputHeader.SinksSize..];
for (int i = 0; i < context.GetCount(); i++)
{
@@ -640,4 +607,4 @@ namespace Ryujinx.Audio.Renderer.Server
return ResultCode.Success;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererExecutionMode.cs b/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererExecutionMode.cs
index 5d82ce0b6..0db61c5e6 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererExecutionMode.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererExecutionMode.cs
@@ -14,6 +14,6 @@ namespace Ryujinx.Audio.Renderer.Server.Types
/// Audio renderer operation needs to be done manually via ExecuteAudioRenderer.
///
/// This is not supported on the DSP and is as such stubbed.
- Manual
+ Manual,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererRenderingDevice.cs b/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererRenderingDevice.cs
index 5ad27b0b1..fd9e231cf 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererRenderingDevice.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Types/AudioRendererRenderingDevice.cs
@@ -19,6 +19,6 @@ namespace Ryujinx.Audio.Renderer.Server.Types
///
/// Only supports .
///
- Cpu
+ Cpu,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Types/PlayState.cs b/src/Ryujinx.Audio/Renderer/Server/Types/PlayState.cs
index 25cc34a8f..46aae05ab 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Types/PlayState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Types/PlayState.cs
@@ -34,6 +34,6 @@ namespace Ryujinx.Audio.Renderer.Server.Types
///
/// The user can resume to the state.
///
- Paused
+ Paused,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerBufferState.cs b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerBufferState.cs
index a45fa8e5b..a3c442a45 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerBufferState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerBufferState.cs
@@ -11,4 +11,4 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
public bool Initialized;
public int Phase;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs
index 0fee00001..dbc2c9b3f 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerManager.cs
@@ -11,22 +11,22 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
///
/// Work buffer for upsampler.
///
- private Memory _upSamplerWorkBuffer;
+ private readonly Memory _upSamplerWorkBuffer;
///
/// Global lock of the object.
///
- private readonly object Lock = new();
+ private readonly object _lock = new();
///
/// The upsamplers instances.
///
- private UpsamplerState[] _upsamplers;
+ private readonly UpsamplerState[] _upsamplers;
///
/// The count of upsamplers.
///
- private uint _count;
+ private readonly uint _count;
///
/// Create a new .
@@ -49,7 +49,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
{
int workBufferOffset = 0;
- lock (Lock)
+ lock (_lock)
{
for (int i = 0; i < _count; i++)
{
@@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
/// The index of the to free.
public void Free(int index)
{
- lock (Lock)
+ lock (_lock)
{
Debug.Assert(_upsamplers[index] != null);
@@ -81,4 +81,4 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerState.cs b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerState.cs
index e508f35b4..39a58c91a 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Upsampler/UpsamplerState.cs
@@ -20,12 +20,12 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
///
/// The index of the . (used to free it)
///
- private int _index;
+ private readonly int _index;
///
/// The .
///
- private UpsamplerManager _manager;
+ private readonly UpsamplerManager _manager;
///
/// The source sample count.
@@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
_manager.Free(_index);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceChannelResource.cs b/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceChannelResource.cs
index 939d92944..e3d5f797d 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceChannelResource.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceChannelResource.cs
@@ -37,4 +37,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
Mix.AsSpan().CopyTo(PreviousMix.AsSpan());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceContext.cs b/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceContext.cs
index 1c57b71be..7ce7143ed 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceContext.cs
@@ -126,7 +126,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
_sortedVoices.Span[i] = i;
}
- int[] sortedVoicesTemp = _sortedVoices.Slice(0, (int)GetCount()).ToArray();
+ int[] sortedVoicesTemp = _sortedVoices[..(int)GetCount()].ToArray();
Array.Sort(sortedVoicesTemp, (a, b) =>
{
@@ -146,4 +146,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
sortedVoicesTemp.AsSpan().CopyTo(_sortedVoices.Span);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceState.cs b/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceState.cs
index 0bf53c544..225f7d31b 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceState.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Voice/VoiceState.cs
@@ -1,5 +1,6 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using Ryujinx.Common.Memory;
@@ -9,6 +10,7 @@ using System.Diagnostics;
using System.Runtime.InteropServices;
using static Ryujinx.Audio.Renderer.Common.BehaviourParameter;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using PlayState = Ryujinx.Audio.Renderer.Server.Types.PlayState;
namespace Ryujinx.Audio.Renderer.Server.Voice
{
@@ -65,12 +67,12 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
///
/// The current voice .
///
- public Types.PlayState PlayState;
+ public PlayState PlayState;
///
/// The previous voice .
///
- public Types.PlayState PreviousPlayState;
+ public PlayState PreviousPlayState;
///
/// The priority of the voice.
@@ -192,7 +194,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
DataSourceStateUnmapped = false;
BufferInfoUnmapped = false;
FlushWaveBufferCount = 0;
- PlayState = Types.PlayState.Stopped;
+ PlayState = PlayState.Stopped;
Priority = Constants.VoiceLowestPriority;
Id = 0;
NodeId = 0;
@@ -202,7 +204,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
Pitch = 0.0f;
Volume = 0.0f;
PreviousVolume = 0.0f;
- BiquadFilters.AsSpan().Fill(new BiquadFilterParameter());
+ BiquadFilters.AsSpan().Clear();
WaveBuffersCount = 0;
WaveBuffersIndex = 0;
MixId = Constants.UnusedMixId;
@@ -233,7 +235,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Check if the voice needs to be skipped.
///
/// Returns true if the voice needs to be skipped.
- public bool ShouldSkip()
+ public readonly bool ShouldSkip()
{
return !InUse || WaveBuffersCount == 0 || DataSourceStateUnmapped || BufferInfoUnmapped || VoiceDropFlag;
}
@@ -242,7 +244,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Return true if the mix has any destinations.
///
/// True if the mix has any destinations.
- public bool HasAnyDestination()
+ public readonly bool HasAnyDestination()
{
return MixId != Constants.UnusedMixId || SplitterId != Constants.UnusedSplitterId;
}
@@ -252,7 +254,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
///
/// The user parameter.
/// Return true, if the server voice information needs to be updated.
- private bool ShouldUpdateParameters(ref VoiceInParameter parameter)
+ private readonly bool ShouldUpdateParameters(ref VoiceInParameter parameter)
{
if (DataSourceStateAddressInfo.CpuAddress == parameter.DataSourceStateAddress)
{
@@ -338,31 +340,31 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Update the internal play state from user play state.
///
/// The target user play state.
- public void UpdatePlayState(PlayState userPlayState)
+ public void UpdatePlayState(Common.PlayState userPlayState)
{
- Types.PlayState oldServerPlayState = PlayState;
+ PlayState oldServerPlayState = PlayState;
PreviousPlayState = oldServerPlayState;
- Types.PlayState newServerPlayState;
+ PlayState newServerPlayState;
switch (userPlayState)
{
case Common.PlayState.Start:
- newServerPlayState = Types.PlayState.Started;
+ newServerPlayState = PlayState.Started;
break;
case Common.PlayState.Stop:
- if (oldServerPlayState == Types.PlayState.Stopped)
+ if (oldServerPlayState == PlayState.Stopped)
{
return;
}
- newServerPlayState = Types.PlayState.Stopping;
+ newServerPlayState = PlayState.Stopping;
break;
case Common.PlayState.Pause:
- newServerPlayState = Types.PlayState.Paused;
+ newServerPlayState = PlayState.Paused;
break;
default:
@@ -434,7 +436,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
for (int i = 0; i < parameter.ChannelCount; i++)
{
- voiceUpdateStates[i].Span[0].IsWaveBufferValid.Fill(false);
+ voiceUpdateStates[i].Span[0].IsWaveBufferValid.Clear();
}
}
@@ -530,7 +532,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
Memory dspSharedState = context.GetUpdateStateForDsp(channelResourceId);
- MemoryMarshal.Cast(dspSharedState.Span).Fill(0);
+ MemoryMarshal.Cast(dspSharedState.Span).Clear();
voiceChannelResource.UpdateState();
}
@@ -579,7 +581,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
switch (PlayState)
{
- case Types.PlayState.Started:
+ case PlayState.Started:
for (int i = 0; i < WaveBuffers.Length; i++)
{
ref WaveBuffer wavebuffer = ref WaveBuffers[i];
@@ -611,7 +613,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
return false;
- case Types.PlayState.Stopping:
+ case PlayState.Stopping:
for (int i = 0; i < WaveBuffers.Length; i++)
{
ref WaveBuffer wavebuffer = ref WaveBuffers[i];
@@ -638,18 +640,18 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
voiceUpdateState.Offset = 0;
voiceUpdateState.PlayedSampleCount = 0;
- voiceUpdateState.Pitch.AsSpan().Fill(0);
+ voiceUpdateState.Pitch.AsSpan().Clear();
voiceUpdateState.Fraction = 0;
- voiceUpdateState.LoopContext = new Dsp.State.AdpcmLoopContext();
+ voiceUpdateState.LoopContext = new AdpcmLoopContext();
}
- PlayState = Types.PlayState.Stopped;
- WasPlaying = PreviousPlayState == Types.PlayState.Started;
+ PlayState = PlayState.Stopped;
+ WasPlaying = PreviousPlayState == PlayState.Started;
return WasPlaying;
- case Types.PlayState.Stopped:
- case Types.PlayState.Paused:
+ case PlayState.Stopped:
+ case PlayState.Paused:
foreach (ref WaveBuffer wavebuffer in WaveBuffers.AsSpan())
{
wavebuffer.BufferAddressInfo.GetReference(true);
@@ -664,7 +666,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
}
}
- WasPlaying = PreviousPlayState == Types.PlayState.Started;
+ WasPlaying = PreviousPlayState == PlayState.Started;
return WasPlaying;
default:
@@ -696,4 +698,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
return UpdateParametersForCommandGeneration(voiceUpdateStates);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Server/Voice/WaveBuffer.cs b/src/Ryujinx.Audio/Renderer/Server/Voice/WaveBuffer.cs
index 4bf7dd280..a9946ba44 100644
--- a/src/Ryujinx.Audio/Renderer/Server/Voice/WaveBuffer.cs
+++ b/src/Ryujinx.Audio/Renderer/Server/Voice/WaveBuffer.cs
@@ -71,10 +71,11 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// A new for use by the .
public Common.WaveBuffer ToCommon(int version)
{
- Common.WaveBuffer waveBuffer = new Common.WaveBuffer();
-
- waveBuffer.Buffer = BufferAddressInfo.GetReference(true);
- waveBuffer.BufferSize = (uint)BufferAddressInfo.Size;
+ Common.WaveBuffer waveBuffer = new()
+ {
+ Buffer = BufferAddressInfo.GetReference(true),
+ BufferSize = (uint)BufferAddressInfo.Size,
+ };
if (ContextAddressInfo.CpuAddress != 0)
{
@@ -101,4 +102,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
return waveBuffer;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/AudioProcessorMemoryManager.cs b/src/Ryujinx.Audio/Renderer/Utils/AudioProcessorMemoryManager.cs
index 973f0672a..8ebf20340 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/AudioProcessorMemoryManager.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/AudioProcessorMemoryManager.cs
@@ -54,4 +54,4 @@ namespace Ryujinx.Audio.Renderer.Utils
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/BitArray.cs b/src/Ryujinx.Audio/Renderer/Utils/BitArray.cs
index 8b1054771..8fd0baeae 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/BitArray.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/BitArray.cs
@@ -11,7 +11,7 @@ namespace Ryujinx.Audio.Renderer.Utils
///
/// The backing storage of the .
///
- private Memory _storage;
+ private readonly Memory _storage;
///
/// Create a new from .
@@ -97,7 +97,7 @@ namespace Ryujinx.Audio.Renderer.Utils
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Reset()
{
- _storage.Span.Fill(0);
+ _storage.Span.Clear();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs b/src/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs
index d49313ea1..bc2313ccf 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs
@@ -2,7 +2,6 @@ using Ryujinx.Audio.Integration;
using System;
using System.IO;
using System.Runtime.InteropServices;
-using System.Text;
namespace Ryujinx.Audio.Renderer.Utils
{
@@ -12,8 +11,8 @@ namespace Ryujinx.Audio.Renderer.Utils
public class FileHardwareDevice : IHardwareDevice
{
private FileStream _stream;
- private uint _channelCount;
- private uint _sampleRate;
+ private readonly uint _channelCount;
+ private readonly uint _sampleRate;
private const int HeaderSize = 44;
@@ -82,6 +81,7 @@ namespace Ryujinx.Audio.Renderer.Utils
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -96,4 +96,4 @@ namespace Ryujinx.Audio.Renderer.Utils
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/Mailbox.cs b/src/Ryujinx.Audio/Renderer/Utils/Mailbox.cs
index 35c71ae36..26907af91 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/Mailbox.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/Mailbox.cs
@@ -9,8 +9,8 @@ namespace Ryujinx.Audio.Renderer.Utils
/// The target unmanaged type used
public class Mailbox : IDisposable where T : unmanaged
{
- private BlockingCollection _messageQueue;
- private BlockingCollection _responseQueue;
+ private readonly BlockingCollection _messageQueue;
+ private readonly BlockingCollection _responseQueue;
public Mailbox()
{
@@ -40,6 +40,7 @@ namespace Ryujinx.Audio.Renderer.Utils
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -52,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Utils
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs b/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs
index 5b513aff3..7a6edab19 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs
@@ -68,4 +68,4 @@ namespace Ryujinx.Audio.Renderer.Utils.Math
return m;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix6x6.cs b/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix6x6.cs
index 415a81fdf..ff0123026 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix6x6.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/Math/Matrix6x6.cs
@@ -94,4 +94,4 @@ namespace Ryujinx.Audio.Renderer.Utils.Math
M66 = m66;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/Math/MatrixHelper.cs b/src/Ryujinx.Audio/Renderer/Utils/Math/MatrixHelper.cs
index 209a81c46..7b4b7ad1d 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/Math/MatrixHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/Math/MatrixHelper.cs
@@ -28,7 +28,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
X = value2.M11 * value1.X + value2.M12 * value1.Y + value2.M13 * value1.Z + value2.M14 * value1.W,
Y = value2.M21 * value1.X + value2.M22 * value1.Y + value2.M23 * value1.Z + value2.M24 * value1.W,
Z = value2.M31 * value1.X + value2.M32 * value1.Y + value2.M33 * value1.Z + value2.M34 * value1.W,
- W = value2.M41 * value1.X + value2.M42 * value1.Y + value2.M43 * value1.Z + value2.M44 * value1.W
+ W = value2.M41 * value1.X + value2.M42 * value1.Y + value2.M43 * value1.Z + value2.M44 * value1.W,
};
}
@@ -42,4 +42,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/Math/Vector6.cs b/src/Ryujinx.Audio/Renderer/Utils/Math/Vector6.cs
index 81bcb6982..303c5e9d0 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/Math/Vector6.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/Math/Vector6.cs
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Utils.Math
return left * new Vector6(right);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/SpanIOHelper.cs b/src/Ryujinx.Audio/Renderer/Utils/SpanIOHelper.cs
index 103fb6a04..4771ae4dd 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/SpanIOHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/SpanIOHelper.cs
@@ -22,12 +22,12 @@ namespace Ryujinx.Audio.Renderer.Utils
if (size > backingMemory.Length)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(backingMemory), backingMemory.Length, null);
}
- MemoryMarshal.Write(backingMemory.Span.Slice(0, size), ref data);
+ MemoryMarshal.Write(backingMemory.Span[..size], ref data);
- backingMemory = backingMemory.Slice(size);
+ backingMemory = backingMemory[size..];
}
///
@@ -42,12 +42,12 @@ namespace Ryujinx.Audio.Renderer.Utils
if (size > backingMemory.Length)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(backingMemory), backingMemory.Length, null);
}
- MemoryMarshal.Write(backingMemory.Slice(0, size), ref data);
+ MemoryMarshal.Write(backingMemory[..size], ref data);
- backingMemory = backingMemory.Slice(size);
+ backingMemory = backingMemory[size..];
}
///
@@ -62,12 +62,12 @@ namespace Ryujinx.Audio.Renderer.Utils
if (size > backingMemory.Length)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(backingMemory), backingMemory.Length, null);
}
- Span result = MemoryMarshal.Cast(backingMemory.Span.Slice(0, size));
+ Span result = MemoryMarshal.Cast(backingMemory.Span[..size]);
- backingMemory = backingMemory.Slice(size);
+ backingMemory = backingMemory[size..];
return result;
}
@@ -84,12 +84,12 @@ namespace Ryujinx.Audio.Renderer.Utils
if (size > backingMemory.Length)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(backingMemory), backingMemory.Length, null);
}
- Span result = MemoryMarshal.Cast(backingMemory.Slice(0, size));
+ Span result = MemoryMarshal.Cast(backingMemory[..size]);
- backingMemory = backingMemory.Slice(size);
+ backingMemory = backingMemory[size..];
return result;
}
@@ -106,12 +106,12 @@ namespace Ryujinx.Audio.Renderer.Utils
if (size > backingMemory.Length)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(backingMemory), backingMemory.Length, null);
}
- T result = MemoryMarshal.Read(backingMemory.Span.Slice(0, size));
+ T result = MemoryMarshal.Read(backingMemory.Span[..size]);
- backingMemory = backingMemory.Slice(size);
+ backingMemory = backingMemory[size..];
return result;
}
@@ -128,12 +128,12 @@ namespace Ryujinx.Audio.Renderer.Utils
if (size > backingMemory.Length)
{
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(backingMemory), backingMemory.Length, null);
}
- T result = MemoryMarshal.Read(backingMemory.Slice(0, size));
+ T result = MemoryMarshal.Read(backingMemory[..size]);
- backingMemory = backingMemory.Slice(size);
+ backingMemory = backingMemory[size..];
return result;
}
@@ -168,4 +168,4 @@ namespace Ryujinx.Audio.Renderer.Utils
return ref GetMemory(memory, id, count).Span[0];
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/SpanMemoryManager.cs b/src/Ryujinx.Audio/Renderer/Utils/SpanMemoryManager.cs
index 2c48da6aa..b6bafbe0f 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/SpanMemoryManager.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/SpanMemoryManager.cs
@@ -19,7 +19,7 @@ namespace Ryujinx.Audio.Renderer.Utils
}
}
- public override Span GetSpan() => new Span(_pointer, _length);
+ public override Span GetSpan() => new(_pointer, _length);
public override MemoryHandle Pin(int elementIndex = 0)
{
@@ -40,4 +40,4 @@ namespace Ryujinx.Audio.Renderer.Utils
return new SpanMemoryManager(MemoryMarshal.Cast(memory.Span)).Memory;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Utils/SplitterHardwareDevice.cs b/src/Ryujinx.Audio/Renderer/Utils/SplitterHardwareDevice.cs
index 183960789..32d50e12f 100644
--- a/src/Ryujinx.Audio/Renderer/Utils/SplitterHardwareDevice.cs
+++ b/src/Ryujinx.Audio/Renderer/Utils/SplitterHardwareDevice.cs
@@ -5,8 +5,8 @@ namespace Ryujinx.Audio.Renderer.Utils
{
public class SplitterHardwareDevice : IHardwareDevice
{
- private IHardwareDevice _baseDevice;
- private IHardwareDevice _secondaryDevice;
+ private readonly IHardwareDevice _baseDevice;
+ private readonly IHardwareDevice _secondaryDevice;
public SplitterHardwareDevice(IHardwareDevice baseDevice, IHardwareDevice secondaryDevice)
{
@@ -43,6 +43,7 @@ namespace Ryujinx.Audio.Renderer.Utils
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -55,4 +56,4 @@ namespace Ryujinx.Audio.Renderer.Utils
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/ResultCode.cs b/src/Ryujinx.Audio/ResultCode.cs
index 1d05ac65e..eab27c16d 100644
--- a/src/Ryujinx.Audio/ResultCode.cs
+++ b/src/Ryujinx.Audio/ResultCode.cs
@@ -19,4 +19,4 @@ namespace Ryujinx.Audio
UnsupportedOperation = (513 << ErrorCodeShift) | ModuleId,
InvalidExecutionContextOperation = (514 << ErrorCodeShift) | ModuleId,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/ClassId.cs b/src/Ryujinx.Graphics.Gpu/ClassId.cs
index 4e475a24d..7c1d1e46b 100644
--- a/src/Ryujinx.Graphics.Gpu/ClassId.cs
+++ b/src/Ryujinx.Graphics.Gpu/ClassId.cs
@@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu
Compute = 0xb1c0,
InlineToMemory = 0xa140,
Dma = 0xb0b5,
- GPFifo = 0xb06f
+ GPFifo = 0xb06f,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Constants.cs b/src/Ryujinx.Graphics.Gpu/Constants.cs
index ff90e61ba..c553d988e 100644
--- a/src/Ryujinx.Graphics.Gpu/Constants.cs
+++ b/src/Ryujinx.Graphics.Gpu/Constants.cs
@@ -90,4 +90,4 @@ namespace Ryujinx.Graphics.Gpu
///
public const ulong MaxUnknownStorageSize = 0x100000;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs
index d8103ac71..67743de37 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs
@@ -1,9 +1,7 @@
using Ryujinx.Graphics.Device;
-using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Engine.Types;
-using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Graphics.Shader;
using System;
@@ -39,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
{ nameof(ComputeClassState.LaunchDma), new RwCallback(LaunchDma, null) },
{ nameof(ComputeClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
- { nameof(ComputeClassState.SendSignalingPcasB), new RwCallback(SendSignalingPcasB, null) }
+ { nameof(ComputeClassState.SendSignalingPcasB), new RwCallback(SendSignalingPcasB, null) },
});
_i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);
@@ -128,12 +126,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
ulong samplerPoolGpuVa = ((ulong)_state.State.SetTexSamplerPoolAOffsetUpper << 32) | _state.State.SetTexSamplerPoolB;
ulong texturePoolGpuVa = ((ulong)_state.State.SetTexHeaderPoolAOffsetUpper << 32) | _state.State.SetTexHeaderPoolB;
- GpuChannelPoolState poolState = new GpuChannelPoolState(
+ GpuChannelPoolState poolState = new(
texturePoolGpuVa,
_state.State.SetTexHeaderPoolCMaximumIndex,
_state.State.SetBindlessTextureConstantBufferSlotSelect);
- GpuChannelComputeState computeState = new GpuChannelComputeState(
+ GpuChannelComputeState computeState = new(
qmd.CtaThreadDimension0,
qmd.CtaThreadDimension1,
qmd.CtaThreadDimension2,
@@ -189,8 +187,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
cs = memoryManager.Physical.ShaderCache.GetComputeShader(_channel, poolState, computeState, shaderGpuVa);
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
-
- info = cs.Shaders[0].Info;
}
_channel.BufferManager.SetComputeBufferBindings(cs.Bindings);
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs
index 73dd31b23..0b192ef6b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs
@@ -98,24 +98,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
///
unsafe struct ComputeClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public fixed uint Reserved114[7];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public uint PmTriggerWfi;
@@ -126,34 +126,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint LineLengthIn;
public uint LineCount;
public uint OffsetOutUpper;
- public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut;
public uint PitchOut;
public uint SetDstBlockSize;
- public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOriginBytesX;
- public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
+ public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY;
- public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
+ public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma;
- public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
- public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
- public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
- public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
- public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
- public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
- public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
+ public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
+ public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
+ public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
+ public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
+ public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
+ public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
+ public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData;
public fixed uint Reserved1B8[9];
public uint SetI2mSemaphoreA;
- public int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
+ public readonly int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
public uint SetI2mSemaphoreB;
public uint SetI2mSemaphoreC;
public fixed uint Reserved1E8[2];
@@ -162,20 +162,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetI2mSpareNoop02;
public uint SetI2mSpareNoop03;
public uint SetValidSpanOverflowAreaA;
- public int SetValidSpanOverflowAreaAAddressUpper => (int)(SetValidSpanOverflowAreaA & 0xFF);
+ public readonly int SetValidSpanOverflowAreaAAddressUpper => (int)(SetValidSpanOverflowAreaA & 0xFF);
public uint SetValidSpanOverflowAreaB;
public uint SetValidSpanOverflowAreaC;
public uint SetCoalesceWaitingPeriodUnit;
public uint PerfmonTransfer;
public uint SetShaderSharedMemoryWindow;
public uint SetSelectMaxwellTextureHeaders;
- public bool SetSelectMaxwellTextureHeadersV => (SetSelectMaxwellTextureHeaders & 0x1) != 0;
+ public readonly bool SetSelectMaxwellTextureHeadersV => (SetSelectMaxwellTextureHeaders & 0x1) != 0;
public uint InvalidateShaderCaches;
- public bool InvalidateShaderCachesInstruction => (InvalidateShaderCaches & 0x1) != 0;
- public bool InvalidateShaderCachesData => (InvalidateShaderCaches & 0x10) != 0;
- public bool InvalidateShaderCachesConstant => (InvalidateShaderCaches & 0x1000) != 0;
- public bool InvalidateShaderCachesLocks => (InvalidateShaderCaches & 0x2) != 0;
- public bool InvalidateShaderCachesFlushData => (InvalidateShaderCaches & 0x4) != 0;
+ public readonly bool InvalidateShaderCachesInstruction => (InvalidateShaderCaches & 0x1) != 0;
+ public readonly bool InvalidateShaderCachesData => (InvalidateShaderCaches & 0x10) != 0;
+ public readonly bool InvalidateShaderCachesConstant => (InvalidateShaderCaches & 0x1000) != 0;
+ public readonly bool InvalidateShaderCachesLocks => (InvalidateShaderCaches & 0x2) != 0;
+ public readonly bool InvalidateShaderCachesFlushData => (InvalidateShaderCaches & 0x4) != 0;
public uint SetReservedSwMethod00;
public uint SetReservedSwMethod01;
public uint SetReservedSwMethod02;
@@ -185,13 +185,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetReservedSwMethod06;
public uint SetReservedSwMethod07;
public uint SetCwdControl;
- public SetCwdControlSmSelection SetCwdControlSmSelection => (SetCwdControlSmSelection)(SetCwdControl & 0x1);
+ public readonly SetCwdControlSmSelection SetCwdControlSmSelection => (SetCwdControlSmSelection)(SetCwdControl & 0x1);
public uint InvalidateTextureHeaderCacheNoWfi;
- public InvalidateCacheLines InvalidateTextureHeaderCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureHeaderCacheNoWfi & 0x1);
- public int InvalidateTextureHeaderCacheNoWfiTag => (int)((InvalidateTextureHeaderCacheNoWfi >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureHeaderCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureHeaderCacheNoWfi & 0x1);
+ public readonly int InvalidateTextureHeaderCacheNoWfiTag => (int)((InvalidateTextureHeaderCacheNoWfi >> 4) & 0x3FFFFF);
public uint SetCwdRefCounter;
- public int SetCwdRefCounterSelect => (int)(SetCwdRefCounter & 0x3F);
- public int SetCwdRefCounterValue => (int)((SetCwdRefCounter >> 8) & 0xFFFF);
+ public readonly int SetCwdRefCounterSelect => (int)(SetCwdRefCounter & 0x3F);
+ public readonly int SetCwdRefCounterValue => (int)((SetCwdRefCounter >> 8) & 0xFFFF);
public uint SetReservedSwMethod08;
public uint SetReservedSwMethod09;
public uint SetReservedSwMethod10;
@@ -201,59 +201,59 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetReservedSwMethod14;
public uint SetReservedSwMethod15;
public uint SetGwcScgType;
- public SetGwcScgTypeScgType SetGwcScgTypeScgType => (SetGwcScgTypeScgType)(SetGwcScgType & 0x1);
+ public readonly SetGwcScgTypeScgType SetGwcScgTypeScgType => (SetGwcScgTypeScgType)(SetGwcScgType & 0x1);
public uint SetScgControl;
- public int SetScgControlCompute1MaxSmCount => (int)(SetScgControl & 0x1FF);
+ public readonly int SetScgControlCompute1MaxSmCount => (int)(SetScgControl & 0x1FF);
public uint InvalidateConstantBufferCacheA;
- public int InvalidateConstantBufferCacheAAddressUpper => (int)(InvalidateConstantBufferCacheA & 0xFF);
+ public readonly int InvalidateConstantBufferCacheAAddressUpper => (int)(InvalidateConstantBufferCacheA & 0xFF);
public uint InvalidateConstantBufferCacheB;
public uint InvalidateConstantBufferCacheC;
- public int InvalidateConstantBufferCacheCByteCount => (int)(InvalidateConstantBufferCacheC & 0x1FFFF);
- public bool InvalidateConstantBufferCacheCThruL2 => (InvalidateConstantBufferCacheC & 0x80000000) != 0;
+ public readonly int InvalidateConstantBufferCacheCByteCount => (int)(InvalidateConstantBufferCacheC & 0x1FFFF);
+ public readonly bool InvalidateConstantBufferCacheCThruL2 => (InvalidateConstantBufferCacheC & 0x80000000) != 0;
public uint SetComputeClassVersion;
- public int SetComputeClassVersionCurrent => (int)(SetComputeClassVersion & 0xFFFF);
- public int SetComputeClassVersionOldestSupported => (int)((SetComputeClassVersion >> 16) & 0xFFFF);
+ public readonly int SetComputeClassVersionCurrent => (int)(SetComputeClassVersion & 0xFFFF);
+ public readonly int SetComputeClassVersionOldestSupported => (int)((SetComputeClassVersion >> 16) & 0xFFFF);
public uint CheckComputeClassVersion;
- public int CheckComputeClassVersionCurrent => (int)(CheckComputeClassVersion & 0xFFFF);
- public int CheckComputeClassVersionOldestSupported => (int)((CheckComputeClassVersion >> 16) & 0xFFFF);
+ public readonly int CheckComputeClassVersionCurrent => (int)(CheckComputeClassVersion & 0xFFFF);
+ public readonly int CheckComputeClassVersionOldestSupported => (int)((CheckComputeClassVersion >> 16) & 0xFFFF);
public uint SetQmdVersion;
- public int SetQmdVersionCurrent => (int)(SetQmdVersion & 0xFFFF);
- public int SetQmdVersionOldestSupported => (int)((SetQmdVersion >> 16) & 0xFFFF);
+ public readonly int SetQmdVersionCurrent => (int)(SetQmdVersion & 0xFFFF);
+ public readonly int SetQmdVersionOldestSupported => (int)((SetQmdVersion >> 16) & 0xFFFF);
public uint SetWfiConfig;
- public bool SetWfiConfigEnableScgTypeWfi => (SetWfiConfig & 0x1) != 0;
+ public readonly bool SetWfiConfigEnableScgTypeWfi => (SetWfiConfig & 0x1) != 0;
public uint CheckQmdVersion;
- public int CheckQmdVersionCurrent => (int)(CheckQmdVersion & 0xFFFF);
- public int CheckQmdVersionOldestSupported => (int)((CheckQmdVersion >> 16) & 0xFFFF);
+ public readonly int CheckQmdVersionCurrent => (int)(CheckQmdVersion & 0xFFFF);
+ public readonly int CheckQmdVersionOldestSupported => (int)((CheckQmdVersion >> 16) & 0xFFFF);
public uint WaitForIdleScgType;
public uint InvalidateSkedCaches;
- public bool InvalidateSkedCachesV => (InvalidateSkedCaches & 0x1) != 0;
+ public readonly bool InvalidateSkedCachesV => (InvalidateSkedCaches & 0x1) != 0;
public uint SetScgRenderEnableControl;
- public bool SetScgRenderEnableControlCompute1UsesRenderEnable => (SetScgRenderEnableControl & 0x1) != 0;
+ public readonly bool SetScgRenderEnableControlCompute1UsesRenderEnable => (SetScgRenderEnableControl & 0x1) != 0;
public fixed uint Reserved2A0[4];
public uint SetCwdSlotCount;
- public int SetCwdSlotCountV => (int)(SetCwdSlotCount & 0xFF);
+ public readonly int SetCwdSlotCountV => (int)(SetCwdSlotCount & 0xFF);
public uint SendPcasA;
public uint SendPcasB;
- public int SendPcasBFrom => (int)(SendPcasB & 0xFFFFFF);
- public int SendPcasBDelta => (int)((SendPcasB >> 24) & 0xFF);
+ public readonly int SendPcasBFrom => (int)(SendPcasB & 0xFFFFFF);
+ public readonly int SendPcasBDelta => (int)((SendPcasB >> 24) & 0xFF);
public uint SendSignalingPcasB;
- public bool SendSignalingPcasBInvalidate => (SendSignalingPcasB & 0x1) != 0;
- public bool SendSignalingPcasBSchedule => (SendSignalingPcasB & 0x2) != 0;
+ public readonly bool SendSignalingPcasBInvalidate => (SendSignalingPcasB & 0x1) != 0;
+ public readonly bool SendSignalingPcasBSchedule => (SendSignalingPcasB & 0x2) != 0;
public fixed uint Reserved2C0[9];
public uint SetShaderLocalMemoryNonThrottledA;
- public int SetShaderLocalMemoryNonThrottledASizeUpper => (int)(SetShaderLocalMemoryNonThrottledA & 0xFF);
+ public readonly int SetShaderLocalMemoryNonThrottledASizeUpper => (int)(SetShaderLocalMemoryNonThrottledA & 0xFF);
public uint SetShaderLocalMemoryNonThrottledB;
public uint SetShaderLocalMemoryNonThrottledC;
- public int SetShaderLocalMemoryNonThrottledCMaxSmCount => (int)(SetShaderLocalMemoryNonThrottledC & 0x1FF);
+ public readonly int SetShaderLocalMemoryNonThrottledCMaxSmCount => (int)(SetShaderLocalMemoryNonThrottledC & 0x1FF);
public uint SetShaderLocalMemoryThrottledA;
- public int SetShaderLocalMemoryThrottledASizeUpper => (int)(SetShaderLocalMemoryThrottledA & 0xFF);
+ public readonly int SetShaderLocalMemoryThrottledASizeUpper => (int)(SetShaderLocalMemoryThrottledA & 0xFF);
public uint SetShaderLocalMemoryThrottledB;
public uint SetShaderLocalMemoryThrottledC;
- public int SetShaderLocalMemoryThrottledCMaxSmCount => (int)(SetShaderLocalMemoryThrottledC & 0x1FF);
+ public readonly int SetShaderLocalMemoryThrottledCMaxSmCount => (int)(SetShaderLocalMemoryThrottledC & 0x1FF);
public fixed uint Reserved2FC[5];
public uint SetSpaVersion;
- public int SetSpaVersionMinor => (int)(SetSpaVersion & 0xFF);
- public int SetSpaVersionMajor => (int)((SetSpaVersion >> 8) & 0xFF);
+ public readonly int SetSpaVersionMinor => (int)(SetSpaVersion & 0xFF);
+ public readonly int SetSpaVersionMajor => (int)((SetSpaVersion >> 8) & 0xFF);
public fixed uint Reserved314[123];
public uint SetFalcon00;
public uint SetFalcon01;
@@ -291,14 +291,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetShaderLocalMemoryWindow;
public fixed uint Reserved780[4];
public uint SetShaderLocalMemoryA;
- public int SetShaderLocalMemoryAAddressUpper => (int)(SetShaderLocalMemoryA & 0xFF);
+ public readonly int SetShaderLocalMemoryAAddressUpper => (int)(SetShaderLocalMemoryA & 0xFF);
public uint SetShaderLocalMemoryB;
public fixed uint Reserved798[383];
public uint SetShaderCacheControl;
- public bool SetShaderCacheControlIcachePrefetchEnable => (SetShaderCacheControl & 0x1) != 0;
+ public readonly bool SetShaderCacheControlIcachePrefetchEnable => (SetShaderCacheControl & 0x1) != 0;
public fixed uint ReservedD98[19];
public uint SetSmTimeoutInterval;
- public int SetSmTimeoutIntervalCounterBit => (int)(SetSmTimeoutInterval & 0x3F);
+ public readonly int SetSmTimeoutIntervalCounterBit => (int)(SetSmTimeoutInterval & 0x3F);
public fixed uint ReservedDE8[87];
public uint SetSpareNoop12;
public uint SetSpareNoop13;
@@ -319,62 +319,62 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetSpareNoop11;
public fixed uint Reserved1070[103];
public uint InvalidateSamplerCacheAll;
- public bool InvalidateSamplerCacheAllV => (InvalidateSamplerCacheAll & 0x1) != 0;
+ public readonly bool InvalidateSamplerCacheAllV => (InvalidateSamplerCacheAll & 0x1) != 0;
public uint InvalidateTextureHeaderCacheAll;
- public bool InvalidateTextureHeaderCacheAllV => (InvalidateTextureHeaderCacheAll & 0x1) != 0;
+ public readonly bool InvalidateTextureHeaderCacheAllV => (InvalidateTextureHeaderCacheAll & 0x1) != 0;
public fixed uint Reserved1214[29];
public uint InvalidateTextureDataCacheNoWfi;
- public InvalidateCacheLines InvalidateTextureDataCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureDataCacheNoWfi & 0x1);
- public int InvalidateTextureDataCacheNoWfiTag => (int)((InvalidateTextureDataCacheNoWfi >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureDataCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureDataCacheNoWfi & 0x1);
+ public readonly int InvalidateTextureDataCacheNoWfiTag => (int)((InvalidateTextureDataCacheNoWfi >> 4) & 0x3FFFFF);
public fixed uint Reserved128C[7];
public uint ActivatePerfSettingsForComputeContext;
- public bool ActivatePerfSettingsForComputeContextAll => (ActivatePerfSettingsForComputeContext & 0x1) != 0;
+ public readonly bool ActivatePerfSettingsForComputeContextAll => (ActivatePerfSettingsForComputeContext & 0x1) != 0;
public fixed uint Reserved12AC[33];
public uint InvalidateSamplerCache;
- public InvalidateCacheLines InvalidateSamplerCacheLines => (InvalidateCacheLines)(InvalidateSamplerCache & 0x1);
- public int InvalidateSamplerCacheTag => (int)((InvalidateSamplerCache >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateSamplerCacheLines => (InvalidateCacheLines)(InvalidateSamplerCache & 0x1);
+ public readonly int InvalidateSamplerCacheTag => (int)((InvalidateSamplerCache >> 4) & 0x3FFFFF);
public uint InvalidateTextureHeaderCache;
- public InvalidateCacheLines InvalidateTextureHeaderCacheLines => (InvalidateCacheLines)(InvalidateTextureHeaderCache & 0x1);
- public int InvalidateTextureHeaderCacheTag => (int)((InvalidateTextureHeaderCache >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureHeaderCacheLines => (InvalidateCacheLines)(InvalidateTextureHeaderCache & 0x1);
+ public readonly int InvalidateTextureHeaderCacheTag => (int)((InvalidateTextureHeaderCache >> 4) & 0x3FFFFF);
public uint InvalidateTextureDataCache;
- public InvalidateCacheLines InvalidateTextureDataCacheLines => (InvalidateCacheLines)(InvalidateTextureDataCache & 0x1);
- public int InvalidateTextureDataCacheTag => (int)((InvalidateTextureDataCache >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureDataCacheLines => (InvalidateCacheLines)(InvalidateTextureDataCache & 0x1);
+ public readonly int InvalidateTextureDataCacheTag => (int)((InvalidateTextureDataCache >> 4) & 0x3FFFFF);
public fixed uint Reserved133C[58];
public uint InvalidateSamplerCacheNoWfi;
- public InvalidateCacheLines InvalidateSamplerCacheNoWfiLines => (InvalidateCacheLines)(InvalidateSamplerCacheNoWfi & 0x1);
- public int InvalidateSamplerCacheNoWfiTag => (int)((InvalidateSamplerCacheNoWfi >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateSamplerCacheNoWfiLines => (InvalidateCacheLines)(InvalidateSamplerCacheNoWfi & 0x1);
+ public readonly int InvalidateSamplerCacheNoWfiTag => (int)((InvalidateSamplerCacheNoWfi >> 4) & 0x3FFFFF);
public fixed uint Reserved1428[64];
public uint SetShaderExceptions;
- public bool SetShaderExceptionsEnable => (SetShaderExceptions & 0x1) != 0;
+ public readonly bool SetShaderExceptionsEnable => (SetShaderExceptions & 0x1) != 0;
public fixed uint Reserved152C[9];
public uint SetRenderEnableA;
- public int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
+ public readonly int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB;
public uint SetRenderEnableC;
- public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
+ public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetTexSamplerPoolA;
- public int SetTexSamplerPoolAOffsetUpper => (int)(SetTexSamplerPoolA & 0xFF);
+ public readonly int SetTexSamplerPoolAOffsetUpper => (int)(SetTexSamplerPoolA & 0xFF);
public uint SetTexSamplerPoolB;
public uint SetTexSamplerPoolC;
- public int SetTexSamplerPoolCMaximumIndex => (int)(SetTexSamplerPoolC & 0xFFFFF);
+ public readonly int SetTexSamplerPoolCMaximumIndex => (int)(SetTexSamplerPoolC & 0xFFFFF);
public fixed uint Reserved1568[3];
public uint SetTexHeaderPoolA;
- public int SetTexHeaderPoolAOffsetUpper => (int)(SetTexHeaderPoolA & 0xFF);
+ public readonly int SetTexHeaderPoolAOffsetUpper => (int)(SetTexHeaderPoolA & 0xFF);
public uint SetTexHeaderPoolB;
public uint SetTexHeaderPoolC;
- public int SetTexHeaderPoolCMaximumIndex => (int)(SetTexHeaderPoolC & 0x3FFFFF);
+ public readonly int SetTexHeaderPoolCMaximumIndex => (int)(SetTexHeaderPoolC & 0x3FFFFF);
public fixed uint Reserved1580[34];
public uint SetProgramRegionA;
- public int SetProgramRegionAAddressUpper => (int)(SetProgramRegionA & 0xFF);
+ public readonly int SetProgramRegionAAddressUpper => (int)(SetProgramRegionA & 0xFF);
public uint SetProgramRegionB;
public fixed uint Reserved1610[34];
public uint InvalidateShaderCachesNoWfi;
- public bool InvalidateShaderCachesNoWfiInstruction => (InvalidateShaderCachesNoWfi & 0x1) != 0;
- public bool InvalidateShaderCachesNoWfiGlobalData => (InvalidateShaderCachesNoWfi & 0x10) != 0;
- public bool InvalidateShaderCachesNoWfiConstant => (InvalidateShaderCachesNoWfi & 0x1000) != 0;
+ public readonly bool InvalidateShaderCachesNoWfiInstruction => (InvalidateShaderCachesNoWfi & 0x1) != 0;
+ public readonly bool InvalidateShaderCachesNoWfiGlobalData => (InvalidateShaderCachesNoWfi & 0x10) != 0;
+ public readonly bool InvalidateShaderCachesNoWfiConstant => (InvalidateShaderCachesNoWfi & 0x1000) != 0;
public fixed uint Reserved169C[170];
public uint SetRenderEnableOverride;
- public SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
+ public readonly SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
public fixed uint Reserved1948[57];
public uint PipeNop;
public uint SetSpare00;
@@ -383,20 +383,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetSpare03;
public fixed uint Reserved1A40[48];
public uint SetReportSemaphoreA;
- public int SetReportSemaphoreAOffsetUpper => (int)(SetReportSemaphoreA & 0xFF);
+ public readonly int SetReportSemaphoreAOffsetUpper => (int)(SetReportSemaphoreA & 0xFF);
public uint SetReportSemaphoreB;
public uint SetReportSemaphoreC;
public uint SetReportSemaphoreD;
- public SetReportSemaphoreDOperation SetReportSemaphoreDOperation => (SetReportSemaphoreDOperation)(SetReportSemaphoreD & 0x3);
- public bool SetReportSemaphoreDAwakenEnable => (SetReportSemaphoreD & 0x100000) != 0;
- public SetReportSemaphoreDStructureSize SetReportSemaphoreDStructureSize => (SetReportSemaphoreDStructureSize)((SetReportSemaphoreD >> 28) & 0x1);
- public bool SetReportSemaphoreDFlushDisable => (SetReportSemaphoreD & 0x4) != 0;
- public bool SetReportSemaphoreDReductionEnable => (SetReportSemaphoreD & 0x8) != 0;
- public SetReportSemaphoreDReductionOp SetReportSemaphoreDReductionOp => (SetReportSemaphoreDReductionOp)((SetReportSemaphoreD >> 9) & 0x7);
- public SetReportSemaphoreDReductionFormat SetReportSemaphoreDReductionFormat => (SetReportSemaphoreDReductionFormat)((SetReportSemaphoreD >> 17) & 0x3);
+ public readonly SetReportSemaphoreDOperation SetReportSemaphoreDOperation => (SetReportSemaphoreDOperation)(SetReportSemaphoreD & 0x3);
+ public readonly bool SetReportSemaphoreDAwakenEnable => (SetReportSemaphoreD & 0x100000) != 0;
+ public readonly SetReportSemaphoreDStructureSize SetReportSemaphoreDStructureSize => (SetReportSemaphoreDStructureSize)((SetReportSemaphoreD >> 28) & 0x1);
+ public readonly bool SetReportSemaphoreDFlushDisable => (SetReportSemaphoreD & 0x4) != 0;
+ public readonly bool SetReportSemaphoreDReductionEnable => (SetReportSemaphoreD & 0x8) != 0;
+ public readonly SetReportSemaphoreDReductionOp SetReportSemaphoreDReductionOp => (SetReportSemaphoreDReductionOp)((SetReportSemaphoreD >> 9) & 0x7);
+ public readonly SetReportSemaphoreDReductionFormat SetReportSemaphoreDReductionFormat => (SetReportSemaphoreDReductionFormat)((SetReportSemaphoreD >> 17) & 0x3);
public fixed uint Reserved1B10[702];
public uint SetBindlessTexture;
- public int SetBindlessTextureConstantBufferSlotSelect => (int)(SetBindlessTexture & 0x7);
+ public readonly int SetBindlessTextureConstantBufferSlotSelect => (int)(SetBindlessTexture & 0x7);
public uint SetTrapHandler;
public fixed uint Reserved2610[843];
public Array8 SetShaderPerformanceCounterValueUpper;
@@ -423,13 +423,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public bool SetShaderPerformanceCounterControlBWindowed(int i) => (SetShaderPerformanceCounterControlB[i] & 0x8) != 0;
public int SetShaderPerformanceCounterControlBFunc(int i) => (int)((SetShaderPerformanceCounterControlB[i] >> 4) & 0xFFFF);
public uint SetShaderPerformanceCounterTrapControl;
- public int SetShaderPerformanceCounterTrapControlMask => (int)(SetShaderPerformanceCounterTrapControl & 0xFF);
+ public readonly int SetShaderPerformanceCounterTrapControlMask => (int)(SetShaderPerformanceCounterTrapControl & 0xFF);
public uint StartShaderPerformanceCounter;
- public int StartShaderPerformanceCounterCounterMask => (int)(StartShaderPerformanceCounter & 0xFF);
+ public readonly int StartShaderPerformanceCounterCounterMask => (int)(StartShaderPerformanceCounter & 0xFF);
public uint StopShaderPerformanceCounter;
- public int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF);
+ public readonly int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF);
public fixed uint Reserved33E8[6];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256 SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs
index 1b20e41c2..4e750ff5d 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs
@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum DependentQmdType
{
Queue,
- Grid
+ Grid,
}
///
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ReleaseMembarType
{
FeNone,
- FeSysmembar
+ FeSysmembar,
}
///
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
L1None,
L1Sysmembar,
- L1Membar
+ L1Membar,
}
///
@@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32NanBehavior
{
Legacy,
- Fp64Compatible
+ Fp64Compatible,
}
///
@@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32F2iNanBehavior
{
PassZero,
- PassIndefinite
+ PassIndefinite,
}
///
@@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ApiVisibleCallLimit
{
_32,
- NoCheck
+ NoCheck,
}
///
@@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum SharedMemoryBankMapping
{
FourBytesPerBank,
- EightBytesPerBank
+ EightBytesPerBank,
}
///
@@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32NarrowInstruction
{
KeepDenorms,
- FlushDenorms
+ FlushDenorms,
}
///
@@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
DirectlyAddressableMemorySize16kb,
DirectlyAddressableMemorySize32kb,
- DirectlyAddressableMemorySize48kb
+ DirectlyAddressableMemorySize48kb,
}
///
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
RedDec,
RedAnd,
RedOr,
- RedXor
+ RedXor,
}
///
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ReductionFormat
{
Unsigned32,
- Signed32
+ Signed32,
}
///
@@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum StructureSize
{
FourWords,
- OneWord
+ OneWord,
}
///
@@ -127,129 +127,129 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
private fixed int _words[64];
- public int OuterPut => BitRange(30, 0);
- public bool OuterOverflow => Bit(31);
- public int OuterGet => BitRange(62, 32);
- public bool OuterStickyOverflow => Bit(63);
- public int InnerGet => BitRange(94, 64);
- public bool InnerOverflow => Bit(95);
- public int InnerPut => BitRange(126, 96);
- public bool InnerStickyOverflow => Bit(127);
- public int QmdReservedAA => BitRange(159, 128);
- public int DependentQmdPointer => BitRange(191, 160);
- public int QmdGroupId => BitRange(197, 192);
- public bool SmGlobalCachingEnable => Bit(198);
- public bool RunCtaInOneSmPartition => Bit(199);
- public bool IsQueue => Bit(200);
- public bool AddToHeadOfQmdGroupLinkedList => Bit(201);
- public bool SemaphoreReleaseEnable0 => Bit(202);
- public bool SemaphoreReleaseEnable1 => Bit(203);
- public bool RequireSchedulingPcas => Bit(204);
- public bool DependentQmdScheduleEnable => Bit(205);
- public DependentQmdType DependentQmdType => (DependentQmdType)BitRange(206, 206);
- public bool DependentQmdFieldCopy => Bit(207);
- public int QmdReservedB => BitRange(223, 208);
- public int CircularQueueSize => BitRange(248, 224);
- public bool QmdReservedC => Bit(249);
- public bool InvalidateTextureHeaderCache => Bit(250);
- public bool InvalidateTextureSamplerCache => Bit(251);
- public bool InvalidateTextureDataCache => Bit(252);
- public bool InvalidateShaderDataCache => Bit(253);
- public bool InvalidateInstructionCache => Bit(254);
- public bool InvalidateShaderConstantCache => Bit(255);
- public int ProgramOffset => BitRange(287, 256);
- public int CircularQueueAddrLower => BitRange(319, 288);
- public int CircularQueueAddrUpper => BitRange(327, 320);
- public int QmdReservedD => BitRange(335, 328);
- public int CircularQueueEntrySize => BitRange(351, 336);
- public int CwdReferenceCountId => BitRange(357, 352);
- public int CwdReferenceCountDeltaMinusOne => BitRange(365, 358);
- public ReleaseMembarType ReleaseMembarType => (ReleaseMembarType)BitRange(366, 366);
- public bool CwdReferenceCountIncrEnable => Bit(367);
- public CwdMembarType CwdMembarType => (CwdMembarType)BitRange(369, 368);
- public bool SequentiallyRunCtas => Bit(370);
- public bool CwdReferenceCountDecrEnable => Bit(371);
- public bool Throttled => Bit(372);
- public Fp32NanBehavior Fp32NanBehavior => (Fp32NanBehavior)BitRange(376, 376);
- public Fp32F2iNanBehavior Fp32F2iNanBehavior => (Fp32F2iNanBehavior)BitRange(377, 377);
- public ApiVisibleCallLimit ApiVisibleCallLimit => (ApiVisibleCallLimit)BitRange(378, 378);
- public SharedMemoryBankMapping SharedMemoryBankMapping => (SharedMemoryBankMapping)BitRange(379, 379);
- public SamplerIndex SamplerIndex => (SamplerIndex)BitRange(382, 382);
- public Fp32NarrowInstruction Fp32NarrowInstruction => (Fp32NarrowInstruction)BitRange(383, 383);
- public int CtaRasterWidth => BitRange(415, 384);
- public int CtaRasterHeight => BitRange(431, 416);
- public int CtaRasterDepth => BitRange(447, 432);
- public int CtaRasterWidthResume => BitRange(479, 448);
- public int CtaRasterHeightResume => BitRange(495, 480);
- public int CtaRasterDepthResume => BitRange(511, 496);
- public int QueueEntriesPerCtaMinusOne => BitRange(518, 512);
- public int CoalesceWaitingPeriod => BitRange(529, 522);
- public int SharedMemorySize => BitRange(561, 544);
- public int QmdReservedG => BitRange(575, 562);
- public int QmdVersion => BitRange(579, 576);
- public int QmdMajorVersion => BitRange(583, 580);
- public int QmdReservedH => BitRange(591, 584);
- public int CtaThreadDimension0 => BitRange(607, 592);
- public int CtaThreadDimension1 => BitRange(623, 608);
- public int CtaThreadDimension2 => BitRange(639, 624);
- public bool ConstantBufferValid(int i) => Bit(640 + i * 1);
- public int QmdReservedI => BitRange(668, 648);
- public L1Configuration L1Configuration => (L1Configuration)BitRange(671, 669);
- public int SmDisableMaskLower => BitRange(703, 672);
- public int SmDisableMaskUpper => BitRange(735, 704);
- public int Release0AddressLower => BitRange(767, 736);
- public int Release0AddressUpper => BitRange(775, 768);
- public int QmdReservedJ => BitRange(783, 776);
- public ReductionOp Release0ReductionOp => (ReductionOp)BitRange(790, 788);
- public bool QmdReservedK => Bit(791);
- public ReductionFormat Release0ReductionFormat => (ReductionFormat)BitRange(793, 792);
- public bool Release0ReductionEnable => Bit(794);
- public StructureSize Release0StructureSize => (StructureSize)BitRange(799, 799);
- public int Release0Payload => BitRange(831, 800);
- public int Release1AddressLower => BitRange(863, 832);
- public int Release1AddressUpper => BitRange(871, 864);
- public int QmdReservedL => BitRange(879, 872);
- public ReductionOp Release1ReductionOp => (ReductionOp)BitRange(886, 884);
- public bool QmdReservedM => Bit(887);
- public ReductionFormat Release1ReductionFormat => (ReductionFormat)BitRange(889, 888);
- public bool Release1ReductionEnable => Bit(890);
- public StructureSize Release1StructureSize => (StructureSize)BitRange(895, 895);
- public int Release1Payload => BitRange(927, 896);
- public int ConstantBufferAddrLower(int i) => BitRange(959 + i * 64, 928 + i * 64);
- public int ConstantBufferAddrUpper(int i) => BitRange(967 + i * 64, 960 + i * 64);
- public int ConstantBufferReservedAddr(int i) => BitRange(973 + i * 64, 968 + i * 64);
- public bool ConstantBufferInvalidate(int i) => Bit(974 + i * 64);
- public int ConstantBufferSize(int i) => BitRange(991 + i * 64, 975 + i * 64);
- public int ShaderLocalMemoryLowSize => BitRange(1463, 1440);
- public int QmdReservedN => BitRange(1466, 1464);
- public int BarrierCount => BitRange(1471, 1467);
- public int ShaderLocalMemoryHighSize => BitRange(1495, 1472);
- public int RegisterCount => BitRange(1503, 1496);
- public int ShaderLocalMemoryCrsSize => BitRange(1527, 1504);
- public int SassVersion => BitRange(1535, 1528);
- public int HwOnlyInnerGet => BitRange(1566, 1536);
- public bool HwOnlyRequireSchedulingPcas => Bit(1567);
- public int HwOnlyInnerPut => BitRange(1598, 1568);
- public bool HwOnlyScgType => Bit(1599);
- public int HwOnlySpanListHeadIndex => BitRange(1629, 1600);
- public bool QmdReservedQ => Bit(1630);
- public bool HwOnlySpanListHeadIndexValid => Bit(1631);
- public int HwOnlySkedNextQmdPointer => BitRange(1663, 1632);
- public int QmdSpareE => BitRange(1695, 1664);
- public int QmdSpareF => BitRange(1727, 1696);
- public int QmdSpareG => BitRange(1759, 1728);
- public int QmdSpareH => BitRange(1791, 1760);
- public int QmdSpareI => BitRange(1823, 1792);
- public int QmdSpareJ => BitRange(1855, 1824);
- public int QmdSpareK => BitRange(1887, 1856);
- public int QmdSpareL => BitRange(1919, 1888);
- public int QmdSpareM => BitRange(1951, 1920);
- public int QmdSpareN => BitRange(1983, 1952);
- public int DebugIdUpper => BitRange(2015, 1984);
- public int DebugIdLower => BitRange(2047, 2016);
+ public readonly int OuterPut => BitRange(30, 0);
+ public readonly bool OuterOverflow => Bit(31);
+ public readonly int OuterGet => BitRange(62, 32);
+ public readonly bool OuterStickyOverflow => Bit(63);
+ public readonly int InnerGet => BitRange(94, 64);
+ public readonly bool InnerOverflow => Bit(95);
+ public readonly int InnerPut => BitRange(126, 96);
+ public readonly bool InnerStickyOverflow => Bit(127);
+ public readonly int QmdReservedAA => BitRange(159, 128);
+ public readonly int DependentQmdPointer => BitRange(191, 160);
+ public readonly int QmdGroupId => BitRange(197, 192);
+ public readonly bool SmGlobalCachingEnable => Bit(198);
+ public readonly bool RunCtaInOneSmPartition => Bit(199);
+ public readonly bool IsQueue => Bit(200);
+ public readonly bool AddToHeadOfQmdGroupLinkedList => Bit(201);
+ public readonly bool SemaphoreReleaseEnable0 => Bit(202);
+ public readonly bool SemaphoreReleaseEnable1 => Bit(203);
+ public readonly bool RequireSchedulingPcas => Bit(204);
+ public readonly bool DependentQmdScheduleEnable => Bit(205);
+ public readonly DependentQmdType DependentQmdType => (DependentQmdType)BitRange(206, 206);
+ public readonly bool DependentQmdFieldCopy => Bit(207);
+ public readonly int QmdReservedB => BitRange(223, 208);
+ public readonly int CircularQueueSize => BitRange(248, 224);
+ public readonly bool QmdReservedC => Bit(249);
+ public readonly bool InvalidateTextureHeaderCache => Bit(250);
+ public readonly bool InvalidateTextureSamplerCache => Bit(251);
+ public readonly bool InvalidateTextureDataCache => Bit(252);
+ public readonly bool InvalidateShaderDataCache => Bit(253);
+ public readonly bool InvalidateInstructionCache => Bit(254);
+ public readonly bool InvalidateShaderConstantCache => Bit(255);
+ public readonly int ProgramOffset => BitRange(287, 256);
+ public readonly int CircularQueueAddrLower => BitRange(319, 288);
+ public readonly int CircularQueueAddrUpper => BitRange(327, 320);
+ public readonly int QmdReservedD => BitRange(335, 328);
+ public readonly int CircularQueueEntrySize => BitRange(351, 336);
+ public readonly int CwdReferenceCountId => BitRange(357, 352);
+ public readonly int CwdReferenceCountDeltaMinusOne => BitRange(365, 358);
+ public readonly ReleaseMembarType ReleaseMembarType => (ReleaseMembarType)BitRange(366, 366);
+ public readonly bool CwdReferenceCountIncrEnable => Bit(367);
+ public readonly CwdMembarType CwdMembarType => (CwdMembarType)BitRange(369, 368);
+ public readonly bool SequentiallyRunCtas => Bit(370);
+ public readonly bool CwdReferenceCountDecrEnable => Bit(371);
+ public readonly bool Throttled => Bit(372);
+ public readonly Fp32NanBehavior Fp32NanBehavior => (Fp32NanBehavior)BitRange(376, 376);
+ public readonly Fp32F2iNanBehavior Fp32F2iNanBehavior => (Fp32F2iNanBehavior)BitRange(377, 377);
+ public readonly ApiVisibleCallLimit ApiVisibleCallLimit => (ApiVisibleCallLimit)BitRange(378, 378);
+ public readonly SharedMemoryBankMapping SharedMemoryBankMapping => (SharedMemoryBankMapping)BitRange(379, 379);
+ public readonly SamplerIndex SamplerIndex => (SamplerIndex)BitRange(382, 382);
+ public readonly Fp32NarrowInstruction Fp32NarrowInstruction => (Fp32NarrowInstruction)BitRange(383, 383);
+ public readonly int CtaRasterWidth => BitRange(415, 384);
+ public readonly int CtaRasterHeight => BitRange(431, 416);
+ public readonly int CtaRasterDepth => BitRange(447, 432);
+ public readonly int CtaRasterWidthResume => BitRange(479, 448);
+ public readonly int CtaRasterHeightResume => BitRange(495, 480);
+ public readonly int CtaRasterDepthResume => BitRange(511, 496);
+ public readonly int QueueEntriesPerCtaMinusOne => BitRange(518, 512);
+ public readonly int CoalesceWaitingPeriod => BitRange(529, 522);
+ public readonly int SharedMemorySize => BitRange(561, 544);
+ public readonly int QmdReservedG => BitRange(575, 562);
+ public readonly int QmdVersion => BitRange(579, 576);
+ public readonly int QmdMajorVersion => BitRange(583, 580);
+ public readonly int QmdReservedH => BitRange(591, 584);
+ public readonly int CtaThreadDimension0 => BitRange(607, 592);
+ public readonly int CtaThreadDimension1 => BitRange(623, 608);
+ public readonly int CtaThreadDimension2 => BitRange(639, 624);
+ public readonly bool ConstantBufferValid(int i) => Bit(640 + i * 1);
+ public readonly int QmdReservedI => BitRange(668, 648);
+ public readonly L1Configuration L1Configuration => (L1Configuration)BitRange(671, 669);
+ public readonly int SmDisableMaskLower => BitRange(703, 672);
+ public readonly int SmDisableMaskUpper => BitRange(735, 704);
+ public readonly int Release0AddressLower => BitRange(767, 736);
+ public readonly int Release0AddressUpper => BitRange(775, 768);
+ public readonly int QmdReservedJ => BitRange(783, 776);
+ public readonly ReductionOp Release0ReductionOp => (ReductionOp)BitRange(790, 788);
+ public readonly bool QmdReservedK => Bit(791);
+ public readonly ReductionFormat Release0ReductionFormat => (ReductionFormat)BitRange(793, 792);
+ public readonly bool Release0ReductionEnable => Bit(794);
+ public readonly StructureSize Release0StructureSize => (StructureSize)BitRange(799, 799);
+ public readonly int Release0Payload => BitRange(831, 800);
+ public readonly int Release1AddressLower => BitRange(863, 832);
+ public readonly int Release1AddressUpper => BitRange(871, 864);
+ public readonly int QmdReservedL => BitRange(879, 872);
+ public readonly ReductionOp Release1ReductionOp => (ReductionOp)BitRange(886, 884);
+ public readonly bool QmdReservedM => Bit(887);
+ public readonly ReductionFormat Release1ReductionFormat => (ReductionFormat)BitRange(889, 888);
+ public readonly bool Release1ReductionEnable => Bit(890);
+ public readonly StructureSize Release1StructureSize => (StructureSize)BitRange(895, 895);
+ public readonly int Release1Payload => BitRange(927, 896);
+ public readonly int ConstantBufferAddrLower(int i) => BitRange(959 + i * 64, 928 + i * 64);
+ public readonly int ConstantBufferAddrUpper(int i) => BitRange(967 + i * 64, 960 + i * 64);
+ public readonly int ConstantBufferReservedAddr(int i) => BitRange(973 + i * 64, 968 + i * 64);
+ public readonly bool ConstantBufferInvalidate(int i) => Bit(974 + i * 64);
+ public readonly int ConstantBufferSize(int i) => BitRange(991 + i * 64, 975 + i * 64);
+ public readonly int ShaderLocalMemoryLowSize => BitRange(1463, 1440);
+ public readonly int QmdReservedN => BitRange(1466, 1464);
+ public readonly int BarrierCount => BitRange(1471, 1467);
+ public readonly int ShaderLocalMemoryHighSize => BitRange(1495, 1472);
+ public readonly int RegisterCount => BitRange(1503, 1496);
+ public readonly int ShaderLocalMemoryCrsSize => BitRange(1527, 1504);
+ public readonly int SassVersion => BitRange(1535, 1528);
+ public readonly int HwOnlyInnerGet => BitRange(1566, 1536);
+ public readonly bool HwOnlyRequireSchedulingPcas => Bit(1567);
+ public readonly int HwOnlyInnerPut => BitRange(1598, 1568);
+ public readonly bool HwOnlyScgType => Bit(1599);
+ public readonly int HwOnlySpanListHeadIndex => BitRange(1629, 1600);
+ public readonly bool QmdReservedQ => Bit(1630);
+ public readonly bool HwOnlySpanListHeadIndexValid => Bit(1631);
+ public readonly int HwOnlySkedNextQmdPointer => BitRange(1663, 1632);
+ public readonly int QmdSpareE => BitRange(1695, 1664);
+ public readonly int QmdSpareF => BitRange(1727, 1696);
+ public readonly int QmdSpareG => BitRange(1759, 1728);
+ public readonly int QmdSpareH => BitRange(1791, 1760);
+ public readonly int QmdSpareI => BitRange(1823, 1792);
+ public readonly int QmdSpareJ => BitRange(1855, 1824);
+ public readonly int QmdSpareK => BitRange(1887, 1856);
+ public readonly int QmdSpareL => BitRange(1919, 1888);
+ public readonly int QmdSpareM => BitRange(1951, 1920);
+ public readonly int QmdSpareN => BitRange(1983, 1952);
+ public readonly int DebugIdUpper => BitRange(2015, 1984);
+ public readonly int DebugIdLower => BitRange(2047, 2016);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private bool Bit(int bit)
+ private readonly bool Bit(int bit)
{
if ((uint)bit >= 64 * 32)
{
@@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private int BitRange(int upper, int lower)
+ private readonly int BitRange(int upper, int lower)
{
if ((uint)lower >= 64 * 32)
{
@@ -272,4 +272,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
return (_words[lower >> 5] >> (lower & 31)) & mask;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs b/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs
index 5581b5cc1..52d7f69f2 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs
@@ -7,6 +7,6 @@
{
False,
True,
- Host
+ Host,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
index fd93cd8ba..e6557780b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
@@ -30,13 +30,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
SrcLinear = 1 << 7,
DstLinear = 1 << 8,
MultiLineEnable = 1 << 9,
- RemapEnable = 1 << 10
+ RemapEnable = 1 << 10,
}
///
/// Texture parameters for copy.
///
- private struct TextureParams
+ private readonly struct TextureParams
{
///
/// Copy region X coordinate.
@@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
_3dEngine = threedEngine;
_state = new DeviceState(new Dictionary
{
- { nameof(DmaClassState.LaunchDma), new RwCallback(LaunchDma, null) }
+ { nameof(DmaClassState.LaunchDma), new RwCallback(LaunchDma, null) },
});
}
@@ -345,8 +345,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
// all be rewritten to use pooled arrays, but that gets complicated with packed data and strides
Span dstSpan = memoryManager.GetSpan(dstGpuVa + (ulong)dstBaseOffset, dstSize).ToArray();
- TextureParams srcParams = new TextureParams(srcRegionX, srcRegionY, srcBaseOffset, srcBpp, srcLinear, srcCalculator);
- TextureParams dstParams = new TextureParams(dstRegionX, dstRegionY, dstBaseOffset, dstBpp, dstLinear, dstCalculator);
+ TextureParams srcParams = new(srcRegionX, srcRegionY, srcBaseOffset, srcBpp, srcLinear, srcCalculator);
+ TextureParams dstParams = new(dstRegionX, dstRegionY, dstBaseOffset, dstBpp, dstLinear, dstCalculator);
// If remapping is enabled, we always copy the components directly, in order.
// If it's enabled, but the mapping is just XYZW, we also copy them in order.
@@ -363,13 +363,26 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
switch (srcBpp)
{
- case 1: Copy(dstSpan, srcSpan, dstParams, srcParams); break;
- case 2: Copy(dstSpan, srcSpan, dstParams, srcParams); break;
- case 4: Copy(dstSpan, srcSpan, dstParams, srcParams); break;
- case 8: Copy(dstSpan, srcSpan, dstParams, srcParams); break;
- case 12: Copy(dstSpan, srcSpan, dstParams, srcParams); break;
- case 16: Copy>(dstSpan, srcSpan, dstParams, srcParams); break;
- default: throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.");
+ case 1:
+ Copy(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 2:
+ Copy(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 4:
+ Copy(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 8:
+ Copy(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 12:
+ Copy(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 16:
+ Copy>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ default:
+ throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.");
}
}
else
@@ -378,11 +391,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
switch (componentSize)
{
- case 1: CopyShuffle(dstSpan, srcSpan, dstParams, srcParams); break;
- case 2: CopyShuffle(dstSpan, srcSpan, dstParams, srcParams); break;
- case 3: CopyShuffle(dstSpan, srcSpan, dstParams, srcParams); break;
- case 4: CopyShuffle(dstSpan, srcSpan, dstParams, srcParams); break;
- default: throw new NotSupportedException($"Unable to copy ${componentSize} component size.");
+ case 1:
+ CopyShuffle(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 2:
+ CopyShuffle(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 3:
+ CopyShuffle(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 4:
+ CopyShuffle(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ default:
+ throw new NotSupportedException($"Unable to copy ${componentSize} component size.");
}
}
@@ -526,28 +548,28 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
0 => _state.State.SetRemapComponentsDstX,
1 => _state.State.SetRemapComponentsDstY,
2 => _state.State.SetRemapComponentsDstZ,
- _ => _state.State.SetRemapComponentsDstW
+ _ => _state.State.SetRemapComponentsDstW,
};
switch (componentsDst)
{
case SetRemapComponentsDst.SrcX:
- Copy(dstSpan.Slice(Unsafe.SizeOf() * i), srcSpan, dst, src);
+ Copy(dstSpan[(Unsafe.SizeOf() * i)..], srcSpan, dst, src);
break;
case SetRemapComponentsDst.SrcY:
- Copy(dstSpan.Slice(Unsafe.SizeOf() * i), srcSpan.Slice(Unsafe.SizeOf()), dst, src);
+ Copy(dstSpan[(Unsafe.SizeOf() * i)..], srcSpan[Unsafe.SizeOf()..], dst, src);
break;
case SetRemapComponentsDst.SrcZ:
- Copy(dstSpan.Slice(Unsafe.SizeOf() * i), srcSpan.Slice(Unsafe.SizeOf() * 2), dst, src);
+ Copy(dstSpan[(Unsafe.SizeOf() * i)..], srcSpan[(Unsafe.SizeOf() * 2)..], dst, src);
break;
case SetRemapComponentsDst.SrcW:
- Copy(dstSpan.Slice(Unsafe.SizeOf() * i), srcSpan.Slice(Unsafe.SizeOf() * 3), dst, src);
+ Copy(dstSpan[(Unsafe.SizeOf() * i)..], srcSpan[(Unsafe.SizeOf() * 3)..], dst, src);
break;
case SetRemapComponentsDst.ConstA:
- Fill(dstSpan.Slice(Unsafe.SizeOf() * i), dst, Unsafe.As(ref _state.State.SetRemapConstA));
+ Fill(dstSpan[(Unsafe.SizeOf() * i)..], dst, Unsafe.As(ref _state.State.SetRemapConstA));
break;
case SetRemapComponentsDst.ConstB:
- Fill(dstSpan.Slice(Unsafe.SizeOf() * i), dst, Unsafe.As(ref _state.State.SetRemapConstB));
+ Fill(dstSpan[(Unsafe.SizeOf() * i)..], dst, Unsafe.As(ref _state.State.SetRemapConstB));
break;
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs
index 6f3b91f2c..d85887368 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs
@@ -179,49 +179,49 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
///
unsafe struct DmaClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public fixed uint Reserved00[64];
public uint Nop;
public fixed uint Reserved104[15];
public uint PmTrigger;
public fixed uint Reserved144[63];
public uint SetSemaphoreA;
- public int SetSemaphoreAUpper => (int)(SetSemaphoreA & 0xFF);
+ public readonly int SetSemaphoreAUpper => (int)(SetSemaphoreA & 0xFF);
public uint SetSemaphoreB;
public uint SetSemaphorePayload;
public fixed uint Reserved24C[2];
public uint SetRenderEnableA;
- public int SetRenderEnableAUpper => (int)(SetRenderEnableA & 0xFF);
+ public readonly int SetRenderEnableAUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB;
public uint SetRenderEnableC;
- public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
+ public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetSrcPhysMode;
- public SetPhysModeTarget SetSrcPhysModeTarget => (SetPhysModeTarget)(SetSrcPhysMode & 0x3);
+ public readonly SetPhysModeTarget SetSrcPhysModeTarget => (SetPhysModeTarget)(SetSrcPhysMode & 0x3);
public uint SetDstPhysMode;
- public SetPhysModeTarget SetDstPhysModeTarget => (SetPhysModeTarget)(SetDstPhysMode & 0x3);
+ public readonly SetPhysModeTarget SetDstPhysModeTarget => (SetPhysModeTarget)(SetDstPhysMode & 0x3);
public fixed uint Reserved268[38];
public uint LaunchDma;
- public LaunchDmaDataTransferType LaunchDmaDataTransferType => (LaunchDmaDataTransferType)(LaunchDma & 0x3);
- public bool LaunchDmaFlushEnable => (LaunchDma & 0x4) != 0;
- public LaunchDmaSemaphoreType LaunchDmaSemaphoreType => (LaunchDmaSemaphoreType)((LaunchDma >> 3) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 5) & 0x3);
- public LaunchDmaMemoryLayout LaunchDmaSrcMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 7) & 0x1);
- public LaunchDmaMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 8) & 0x1);
- public bool LaunchDmaMultiLineEnable => (LaunchDma & 0x200) != 0;
- public bool LaunchDmaRemapEnable => (LaunchDma & 0x400) != 0;
- public bool LaunchDmaForceRmwdisable => (LaunchDma & 0x800) != 0;
- public LaunchDmaType LaunchDmaSrcType => (LaunchDmaType)((LaunchDma >> 12) & 0x1);
- public LaunchDmaType LaunchDmaDstType => (LaunchDmaType)((LaunchDma >> 13) & 0x1);
- public LaunchDmaSemaphoreReduction LaunchDmaSemaphoreReduction => (LaunchDmaSemaphoreReduction)((LaunchDma >> 14) & 0xF);
- public LaunchDmaSemaphoreReductionSign LaunchDmaSemaphoreReductionSign => (LaunchDmaSemaphoreReductionSign)((LaunchDma >> 18) & 0x1);
- public bool LaunchDmaSemaphoreReductionEnable => (LaunchDma & 0x80000) != 0;
- public LaunchDmaBypassL2 LaunchDmaBypassL2 => (LaunchDmaBypassL2)((LaunchDma >> 20) & 0x1);
+ public readonly LaunchDmaDataTransferType LaunchDmaDataTransferType => (LaunchDmaDataTransferType)(LaunchDma & 0x3);
+ public readonly bool LaunchDmaFlushEnable => (LaunchDma & 0x4) != 0;
+ public readonly LaunchDmaSemaphoreType LaunchDmaSemaphoreType => (LaunchDmaSemaphoreType)((LaunchDma >> 3) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 5) & 0x3);
+ public readonly LaunchDmaMemoryLayout LaunchDmaSrcMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 7) & 0x1);
+ public readonly LaunchDmaMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 8) & 0x1);
+ public readonly bool LaunchDmaMultiLineEnable => (LaunchDma & 0x200) != 0;
+ public readonly bool LaunchDmaRemapEnable => (LaunchDma & 0x400) != 0;
+ public readonly bool LaunchDmaForceRmwdisable => (LaunchDma & 0x800) != 0;
+ public readonly LaunchDmaType LaunchDmaSrcType => (LaunchDmaType)((LaunchDma >> 12) & 0x1);
+ public readonly LaunchDmaType LaunchDmaDstType => (LaunchDmaType)((LaunchDma >> 13) & 0x1);
+ public readonly LaunchDmaSemaphoreReduction LaunchDmaSemaphoreReduction => (LaunchDmaSemaphoreReduction)((LaunchDma >> 14) & 0xF);
+ public readonly LaunchDmaSemaphoreReductionSign LaunchDmaSemaphoreReductionSign => (LaunchDmaSemaphoreReductionSign)((LaunchDma >> 18) & 0x1);
+ public readonly bool LaunchDmaSemaphoreReductionEnable => (LaunchDma & 0x80000) != 0;
+ public readonly LaunchDmaBypassL2 LaunchDmaBypassL2 => (LaunchDmaBypassL2)((LaunchDma >> 20) & 0x1);
public fixed uint Reserved304[63];
public uint OffsetInUpper;
- public int OffsetInUpperUpper => (int)(OffsetInUpper & 0xFF);
+ public readonly int OffsetInUpperUpper => (int)(OffsetInUpper & 0xFF);
public uint OffsetInLower;
public uint OffsetOutUpper;
- public int OffsetOutUpperUpper => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperUpper => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOutLower;
public uint PitchIn;
public uint PitchOut;
@@ -231,38 +231,38 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public uint SetRemapConstA;
public uint SetRemapConstB;
public uint SetRemapComponents;
- public SetRemapComponentsDst SetRemapComponentsDstX => (SetRemapComponentsDst)(SetRemapComponents & 0x7);
- public SetRemapComponentsDst SetRemapComponentsDstY => (SetRemapComponentsDst)((SetRemapComponents >> 4) & 0x7);
- public SetRemapComponentsDst SetRemapComponentsDstZ => (SetRemapComponentsDst)((SetRemapComponents >> 8) & 0x7);
- public SetRemapComponentsDst SetRemapComponentsDstW => (SetRemapComponentsDst)((SetRemapComponents >> 12) & 0x7);
- public SetRemapComponentsComponentSize SetRemapComponentsComponentSize => (SetRemapComponentsComponentSize)((SetRemapComponents >> 16) & 0x3);
- public SetRemapComponentsNumComponents SetRemapComponentsNumSrcComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 20) & 0x3);
- public SetRemapComponentsNumComponents SetRemapComponentsNumDstComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 24) & 0x3);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstX => (SetRemapComponentsDst)(SetRemapComponents & 0x7);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstY => (SetRemapComponentsDst)((SetRemapComponents >> 4) & 0x7);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstZ => (SetRemapComponentsDst)((SetRemapComponents >> 8) & 0x7);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstW => (SetRemapComponentsDst)((SetRemapComponents >> 12) & 0x7);
+ public readonly SetRemapComponentsComponentSize SetRemapComponentsComponentSize => (SetRemapComponentsComponentSize)((SetRemapComponents >> 16) & 0x3);
+ public readonly SetRemapComponentsNumComponents SetRemapComponentsNumSrcComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 20) & 0x3);
+ public readonly SetRemapComponentsNumComponents SetRemapComponentsNumDstComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 24) & 0x3);
public uint SetDstBlockSize;
- public SetBlockSizeWidth SetDstBlockSizeWidth => (SetBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetBlockSizeHeight SetDstBlockSizeHeight => (SetBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetBlockSizeDepth SetDstBlockSizeDepth => (SetBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
- public SetBlockSizeGobHeight SetDstBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetDstBlockSize >> 12) & 0xF);
+ public readonly SetBlockSizeWidth SetDstBlockSizeWidth => (SetBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetBlockSizeHeight SetDstBlockSizeHeight => (SetBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetBlockSizeDepth SetDstBlockSizeDepth => (SetBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetBlockSizeGobHeight SetDstBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetDstBlockSize >> 12) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOrigin;
- public int SetDstOriginX => (int)(SetDstOrigin & 0xFFFF);
- public int SetDstOriginY => (int)((SetDstOrigin >> 16) & 0xFFFF);
+ public readonly int SetDstOriginX => (int)(SetDstOrigin & 0xFFFF);
+ public readonly int SetDstOriginY => (int)((SetDstOrigin >> 16) & 0xFFFF);
public uint Reserved724;
public uint SetSrcBlockSize;
- public SetBlockSizeWidth SetSrcBlockSizeWidth => (SetBlockSizeWidth)(SetSrcBlockSize & 0xF);
- public SetBlockSizeHeight SetSrcBlockSizeHeight => (SetBlockSizeHeight)((SetSrcBlockSize >> 4) & 0xF);
- public SetBlockSizeDepth SetSrcBlockSizeDepth => (SetBlockSizeDepth)((SetSrcBlockSize >> 8) & 0xF);
- public SetBlockSizeGobHeight SetSrcBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetSrcBlockSize >> 12) & 0xF);
+ public readonly SetBlockSizeWidth SetSrcBlockSizeWidth => (SetBlockSizeWidth)(SetSrcBlockSize & 0xF);
+ public readonly SetBlockSizeHeight SetSrcBlockSizeHeight => (SetBlockSizeHeight)((SetSrcBlockSize >> 4) & 0xF);
+ public readonly SetBlockSizeDepth SetSrcBlockSizeDepth => (SetBlockSizeDepth)((SetSrcBlockSize >> 8) & 0xF);
+ public readonly SetBlockSizeGobHeight SetSrcBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetSrcBlockSize >> 12) & 0xF);
public uint SetSrcWidth;
public uint SetSrcHeight;
public uint SetSrcDepth;
public uint SetSrcLayer;
public uint SetSrcOrigin;
- public int SetSrcOriginX => (int)(SetSrcOrigin & 0xFFFF);
- public int SetSrcOriginY => (int)((SetSrcOrigin >> 16) & 0xFFFF);
+ public readonly int SetSrcOriginX => (int)(SetSrcOrigin & 0xFFFF);
+ public readonly int SetSrcOriginY => (int)((SetSrcOrigin >> 16) & 0xFFFF);
public fixed uint Reserved740[629];
public uint PmTriggerEnd;
public fixed uint Reserved1118[2490];
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs
index 6873ff40f..8193c4a2c 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
///
struct DmaTexture
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public MemoryLayout MemoryLayout;
public int Width;
public int Height;
@@ -17,4 +17,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public ushort RegionY;
#pragma warning restore CS0649
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs
index d082ee9dd..afa4db5ec 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Grp0SetSubDevMask = 1,
Grp0StoreSubDevMask = 2,
Grp0UseSubDevMask = 3,
- Grp2NonIncMethod = 0
+ Grp2NonIncMethod = Grp0IncMethod,
}
enum SecOp
@@ -20,22 +20,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
ImmdDataMethod = 4,
OneInc = 5,
Reserved6 = 6,
- EndPbSegment = 7
+ EndPbSegment = 7,
}
struct CompressedMethod
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Method;
#pragma warning restore CS0649
- public int MethodAddressOld => (int)((Method >> 2) & 0x7FF);
- public int MethodAddress => (int)(Method & 0xFFF);
- public int SubdeviceMask => (int)((Method >> 4) & 0xFFF);
- public int MethodSubchannel => (int)((Method >> 13) & 0x7);
- public TertOp TertOp => (TertOp)((Method >> 16) & 0x3);
- public int MethodCountOld => (int)((Method >> 18) & 0x7FF);
- public int MethodCount => (int)((Method >> 16) & 0x1FFF);
- public int ImmdData => (int)((Method >> 16) & 0x1FFF);
- public SecOp SecOp => (SecOp)((Method >> 29) & 0x7);
+ public readonly int MethodAddressOld => (int)((Method >> 2) & 0x7FF);
+ public readonly int MethodAddress => (int)(Method & 0xFFF);
+ public readonly int SubdeviceMask => (int)((Method >> 4) & 0xFFF);
+ public readonly int MethodSubchannel => (int)((Method >> 13) & 0x7);
+ public readonly TertOp TertOp => (TertOp)((Method >> 16) & 0x3);
+ public readonly int MethodCountOld => (int)((Method >> 18) & 0x7FF);
+ public readonly int MethodCount => (int)((Method >> 16) & 0x1FFF);
+ public readonly int ImmdData => (int)((Method >> 16) & 0x1FFF);
+ public readonly SecOp SecOp => (SecOp)((Method >> 29) & 0x7);
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs
index 31ba3217d..81e28acf4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs
@@ -36,20 +36,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
struct GPEntry
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Entry0;
#pragma warning restore CS0649
- public Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1);
- public int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF);
- public int Entry0Operand => (int)(Entry0);
-#pragma warning disable CS0649
+ public readonly Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1);
+ public readonly int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF);
+ public readonly int Entry0Operand => (int)(Entry0);
+#pragma warning disable CS0649 // Field is never assigned to
public uint Entry1;
#pragma warning restore CS0649
- public int Entry1GetHi => (int)(Entry1 & 0xFF);
- public Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1);
- public Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1);
- public int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF);
- public Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1);
- public Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF);
+ public readonly int Entry1GetHi => (int)(Entry1 & 0xFF);
+ public readonly Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1);
+ public readonly Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1);
+ public readonly int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF);
+ public readonly Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1);
+ public readonly Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF);
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs
index 7a11c649c..4bdbd1a03 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs
@@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private readonly GPFifoProcessor _parent;
private readonly DeviceState _state;
- private int _previousSubChannel;
private bool _createSyncPending;
private const int MacrosCount = 0x80;
@@ -45,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{ nameof(GPFifoClassState.SetReference), new RwCallback(SetReference, null) },
{ nameof(GPFifoClassState.LoadMmeInstructionRam), new RwCallback(LoadMmeInstructionRam, null) },
{ nameof(GPFifoClassState.LoadMmeStartAddressRam), new RwCallback(LoadMmeStartAddressRam, null) },
- { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) }
+ { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) },
});
_macros = new Macro[MacrosCount];
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs
index ebfe15664..dd6ae1b40 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs
@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Release = 2,
AcqGeq = 4,
AcqAnd = 8,
- Reduction = 16
+ Reduction = 16,
}
///
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredAcquireSwitch
{
Disabled = 0,
- Enabled = 1
+ Enabled = 1,
}
///
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredReleaseWfi
{
En = 0,
- Dis = 1
+ Dis = 1,
}
///
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredReleaseSize
{
SixteenBytes = 0,
- FourBytes = 1
+ FourBytes = 1,
}
///
@@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Or = 4,
Add = 5,
Inc = 6,
- Dec = 7
+ Dec = 7,
}
///
@@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredFormat
{
Signed = 0,
- Unsigned = 1
+ Unsigned = 1,
}
///
@@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum MemOpCTlbInvalidatePdb
{
One = 0,
- All = 1
+ All = 1,
}
///
@@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum MemOpCTlbInvalidateGpc
{
Enable = 0,
- Disable = 1
+ Disable = 1,
}
///
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{
VidMem = 0,
SysMemCoherent = 2,
- SysMemNoncoherent = 3
+ SysMemNoncoherent = 3,
}
///
@@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
L2PeermemInvalidate = 13,
L2SysmemInvalidate = 14,
L2CleanComptags = 15,
- L2FlushDirty = 16
+ L2FlushDirty = 16,
}
///
@@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SyncpointbOperation
{
Wait = 0,
- Incr = 1
+ Incr = 1,
}
///
@@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SyncpointbWaitSwitch
{
Dis = 0,
- En = 1
+ En = 1,
}
///
@@ -132,7 +132,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum WfiScope
{
CurrentScgType = 0,
- All = 1
+ All = 1,
}
///
@@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Nop = 0,
PbdmaTimeslice = 1,
RunlistTimeslice = 2,
- Tsg = 3
+ Tsg = 3,
}
///
@@ -151,44 +151,44 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
///
struct GPFifoClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectNvclass => (int)(SetObject & 0xFFFF);
- public int SetObjectEngine => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectNvclass => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngine => (int)((SetObject >> 16) & 0x1F);
public uint Illegal;
- public int IllegalHandle => (int)(Illegal);
+ public readonly int IllegalHandle => (int)(Illegal);
public uint Nop;
- public int NopHandle => (int)(Nop);
+ public readonly int NopHandle => (int)(Nop);
public uint Reserved0C;
public uint Semaphorea;
- public int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF);
+ public readonly int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF);
public uint Semaphoreb;
- public int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF);
+ public readonly int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF);
public uint Semaphorec;
- public int SemaphorecPayload => (int)(Semaphorec);
+ public readonly int SemaphorecPayload => (int)(Semaphorec);
public uint Semaphored;
- public SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F);
- public SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1);
- public SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1);
- public SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1);
- public SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF);
- public SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1);
+ public readonly SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F);
+ public readonly SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1);
+ public readonly SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1);
+ public readonly SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1);
+ public readonly SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF);
+ public readonly SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1);
public uint NonStallInterrupt;
- public int NonStallInterruptHandle => (int)(NonStallInterrupt);
+ public readonly int NonStallInterruptHandle => (int)(NonStallInterrupt);
public uint FbFlush;
- public int FbFlushHandle => (int)(FbFlush);
+ public readonly int FbFlushHandle => (int)(FbFlush);
public uint Reserved28;
public uint Reserved2C;
public uint MemOpC;
- public int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF);
- public MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1);
- public MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1);
- public MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3);
- public int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF);
+ public readonly int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF);
+ public readonly MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1);
+ public readonly MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1);
+ public readonly MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3);
+ public readonly int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF);
public uint MemOpD;
- public int MemOpDOperandHigh => (int)(MemOpD & 0xFF);
- public MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F);
- public int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF);
+ public readonly int MemOpDOperandHigh => (int)(MemOpD & 0xFF);
+ public readonly MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F);
+ public readonly int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF);
public uint Reserved38;
public uint Reserved3C;
public uint Reserved40;
@@ -196,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint Reserved48;
public uint Reserved4C;
public uint SetReference;
- public int SetReferenceCount => (int)(SetReference);
+ public readonly int SetReferenceCount => (int)(SetReference);
public uint Reserved54;
public uint Reserved58;
public uint Reserved5C;
@@ -205,17 +205,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint Reserved68;
public uint Reserved6C;
public uint Syncpointa;
- public int SyncpointaPayload => (int)(Syncpointa);
+ public readonly int SyncpointaPayload => (int)(Syncpointa);
public uint Syncpointb;
- public SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1);
- public SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1);
- public int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF);
+ public readonly SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1);
+ public readonly SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1);
+ public readonly int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF);
public uint Wfi;
- public WfiScope WfiScope => (WfiScope)(Wfi & 0x1);
+ public readonly WfiScope WfiScope => (WfiScope)(Wfi & 0x1);
public uint CrcCheck;
- public int CrcCheckValue => (int)(CrcCheck);
+ public readonly int CrcCheckValue => (int)(CrcCheck);
public uint Yield;
- public YieldOp YieldOp => (YieldOp)(Yield & 0x3);
+ public readonly YieldOp YieldOp => (YieldOp)(Yield & 0x3);
// TODO: Eventually move this to per-engine state.
public Array31 Reserved84;
public uint NoOperation;
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs
index 09bcdec11..bb5bc21cb 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private enum CommandBufferType
{
Prefetch,
- NoPrefetch
+ NoPrefetch,
}
///
@@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// The memory manager used to fetch the data
/// If true, flushes potential GPU written data before reading the command buffer
/// The fetched data
- private ReadOnlySpan GetWords(MemoryManager memoryManager, bool flush)
+ private readonly ReadOnlySpan GetWords(MemoryManager memoryManager, bool flush)
{
return MemoryMarshal.Cast(memoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, flush));
}
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// The memory manager used to fetch the data
/// If true, flushes potential GPU written data before reading the command buffer
/// The command buffer words
- public ReadOnlySpan Fetch(MemoryManager memoryManager, bool flush)
+ public readonly ReadOnlySpan Fetch(MemoryManager memoryManager, bool flush)
{
return Words ?? GetWords(memoryManager, flush);
}
@@ -85,7 +85,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private readonly ConcurrentQueue _commandBufferQueue;
- private CommandBuffer _currentCommandBuffer;
private GPFifoProcessor _prevChannelProcessor;
private readonly bool _ibEnable;
@@ -129,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Type = CommandBufferType.Prefetch,
Words = commandBuffer,
EntryAddress = ulong.MaxValue,
- EntryCount = (uint)commandBuffer.Length
+ EntryCount = (uint)commandBuffer.Length,
});
}
@@ -156,7 +155,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Type = type,
Words = null,
EntryAddress = startAddress,
- EntryCount = (uint)entry.Entry1Length
+ EntryCount = (uint)entry.Entry1Length,
};
}
@@ -217,7 +216,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
flushCommandBuffer = false;
}
- _currentCommandBuffer = entry;
ReadOnlySpan words = entry.Fetch(entry.Processor.MemoryManager, flushCommandBuffer);
// If we are changing the current channel,
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs
index 3fb3feeea..6ba1bc22e 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs
@@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{
0 => _3dClass,
3 => _2dClass,
- _ => null
+ _ => null,
};
if (state != null)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs
index e1d7e9407..e417b9a0a 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs
@@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
_state = new DeviceState(new Dictionary
{
{ nameof(InlineToMemoryClassState.LaunchDma), new RwCallback(LaunchDma, null) },
- { nameof(InlineToMemoryClassState.LoadInlineData), new RwCallback(LoadInlineData, null) }
+ { nameof(InlineToMemoryClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
});
}
}
@@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
if (!_finished)
{
int copySize = Math.Min(data.Length, _buffer.Length - _offset);
- data.Slice(0, copySize).CopyTo(new Span(_buffer).Slice(_offset, copySize));
+ data[..copySize].CopyTo(new Span(_buffer).Slice(_offset, copySize));
_offset += copySize;
@@ -169,11 +169,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
{
var memoryManager = _channel.MemoryManager;
- var data = MemoryMarshal.Cast(_buffer).Slice(0, _size);
+ var data = MemoryMarshal.Cast(_buffer)[.._size];
if (_isLinear && _lineCount == 1)
{
- memoryManager.WriteTrackedResource(_dstGpuVa, data.Slice(0, _lineLengthIn));
+ memoryManager.WriteTrackedResource(_dstGpuVa, data[.._lineLengthIn]);
_context.AdvanceSequence();
}
else
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs
index f6d9602a6..ec5042fda 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs
@@ -1,5 +1,7 @@
// This file was auto-generated from NVIDIA official Maxwell definitions.
+using Ryujinx.Common.Memory;
+
namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
{
///
@@ -111,24 +113,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
///
unsafe struct InlineToMemoryClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public fixed uint Reserved114[7];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public uint PmTriggerWfi;
@@ -139,34 +141,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint LineLengthIn;
public uint LineCount;
public uint OffsetOutUpper;
- public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut;
public uint PitchOut;
public uint SetDstBlockSize;
- public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOriginBytesX;
- public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
+ public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY;
- public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
+ public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma;
- public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
- public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
- public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
- public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
- public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
- public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
- public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
+ public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
+ public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
+ public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
+ public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
+ public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
+ public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
+ public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData;
public fixed uint Reserved1B8[9];
public uint SetI2mSemaphoreA;
- public int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
+ public readonly int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
public uint SetI2mSemaphoreB;
public uint SetI2mSemaphoreC;
public fixed uint Reserved1E8[2];
@@ -175,7 +177,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint SetI2mSpareNoop02;
public uint SetI2mSpareNoop03;
public fixed uint Reserved200[3200];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256 SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs
index eeef9c67e..43faa788b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs
@@ -10,6 +10,6 @@
BitfieldReplace = 2,
BitfieldExtractLslImm = 3,
BitfieldExtractLslReg = 4,
- ReadImmediate = 5
+ ReadImmediate = 5,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs
index f3e05d38e..c878bd41f 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs
@@ -13,6 +13,6 @@
BitwiseOr = 9,
BitwiseAnd = 10,
BitwiseAndNot = 11,
- BitwiseNotAnd = 12
+ BitwiseNotAnd = 12,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs
index dc3360266..592aa5a68 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs
@@ -12,6 +12,6 @@
MoveAndSend = 4,
FetchAndSetMaddr = 5,
MoveAndSetMaddrThenFetchAndSend = 6,
- MoveAndSetMaddrThenSendHigh = 7
+ MoveAndSetMaddrThenSendHigh = 7,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
index 12a3ac028..65c6aab4a 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
if (_executionEngine == null)
{
- if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code.Slice(Position), context.Capabilities, out _hleFunction))
+ if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code[Position..], context.Capabilities, out _hleFunction))
{
_executionEngine = new MacroHLE(processor, _hleFunction);
}
@@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
if (_executionPending)
{
_executionPending = false;
- _executionEngine?.Execute(code.Slice(Position), state, _argument);
+ _executionEngine?.Execute(code[Position..], state, _argument);
}
}
@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
///
/// GPU virtual address where the command word is located
/// Argument to be pushed
- public void PushArgument(ulong gpuVa, int argument)
+ public readonly void PushArgument(ulong gpuVa, int argument)
{
_executionEngine?.Fifo.Enqueue(new FifoWord(gpuVa, argument));
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs
index 8630bbc42..a4c4dd106 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs
@@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
private const int ColorStructSize = 0x40;
private const int ZetaLayerCountOffset = 0x1230;
- private const int IndirectDataEntrySize = 0x10;
private const int IndirectIndexedDataEntrySize = 0x14;
private readonly GPFifoProcessor _processor;
@@ -262,10 +261,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
for (int i = 0; i < maxDrawCount; i++)
{
var count = FetchParam();
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
var instanceCount = FetchParam();
var firstIndex = FetchParam();
var firstVertex = FetchParam();
var firstInstance = FetchParam();
+#pragma warning restore IDE0059
if (i == 0)
{
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs
index 751867fc7..9e71761b4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs
@@ -11,6 +11,6 @@
DrawArraysInstanced,
DrawElementsInstanced,
DrawElementsIndirect,
- MultiDrawElementsIndirectCount
+ MultiDrawElementsIndirectCount,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
index 719e170fd..5630756cb 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
@@ -46,12 +46,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
private static readonly TableEntry[] _table = new TableEntry[]
{
- new TableEntry(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28),
- new TableEntry(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24),
- new TableEntry(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48),
- new TableEntry(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c),
- new TableEntry(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c),
- new TableEntry(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C)
+ new(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28),
+ new(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24),
+ new(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48),
+ new(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c),
+ new(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c),
+ new(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C),
};
///
@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
{
ref var entry = ref _table[i];
- var hash = XXHash128.ComputeHash(mc.Slice(0, entry.Length));
+ var hash = XXHash128.ComputeHash(mc[..entry.Length]);
if (hash == entry.Hash)
{
if (IsMacroHLESupported(caps, entry.Name))
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs
index df6ee040e..dd60688d6 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs
@@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
///
public Queue Fifo { get; }
- private int[] _gprs;
+ private readonly int[] _gprs;
private int _methAddr;
private int _methIncr;
@@ -291,11 +291,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
return (int)result;
- case AluRegOperation.BitwiseExclusiveOr: return a ^ b;
- case AluRegOperation.BitwiseOr: return a | b;
- case AluRegOperation.BitwiseAnd: return a & b;
- case AluRegOperation.BitwiseAndNot: return a & ~b;
- case AluRegOperation.BitwiseNotAnd: return ~(a & b);
+ case AluRegOperation.BitwiseExclusiveOr:
+ return a ^ b;
+ case AluRegOperation.BitwiseOr:
+ return a | b;
+ case AluRegOperation.BitwiseAnd:
+ return a & b;
+ case AluRegOperation.BitwiseAndNot:
+ return a & ~b;
+ case AluRegOperation.BitwiseNotAnd:
+ return ~(a & b);
}
throw new InvalidOperationException($"Invalid operation \"{aluOp}\" on instruction 0x{_opCode:X8}.");
@@ -380,7 +385,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// Current GPU state
/// Register offset to read
/// GPU register value
- private int Read(IDeviceState state, int reg)
+ private static int Read(IDeviceState state, int reg)
{
return state.Read(reg * 4);
}
@@ -397,4 +402,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
_methAddr += _methIncr;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs
index 4077f74ec..a23bfef12 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
///
class MacroJit : IMacroEE
{
- private readonly MacroJitContext _context = new MacroJitContext();
+ private readonly MacroJitContext _context = new();
///
/// Arguments FIFO.
@@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
{
if (_execute == null)
{
- MacroJitCompiler compiler = new MacroJitCompiler();
+ MacroJitCompiler compiler = new();
_execute = compiler.Compile(code);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs
index f8d839fa0..d9c26c587 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// Delegate of the host compiled code
public MacroExecute Compile(ReadOnlySpan code)
{
- Dictionary labels = new Dictionary();
+ Dictionary labels = new();
int lastTarget = 0;
int i;
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs
index 52c2a11b2..5a71e3f47 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs
@@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
///
/// Arguments FIFO.
///
- public Queue Fifo { get; } = new Queue();
+ public Queue Fifo { get; } = new();
///
/// Fetches a arguments from the arguments FIFO.
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs b/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs
index 44cd82130..0aa6b82af 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
[StructLayout(LayoutKind.Sequential, Size = 1024)]
struct MmeShadowScratch
{
-#pragma warning disable CS0169
+#pragma warning disable CS0169 // The private field is never used
private uint _e0;
#pragma warning restore CS0169
public ref uint this[int index] => ref AsSpan()[index];
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs b/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs
index 060d35cad..ebb0ff33e 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs
@@ -10,4 +10,4 @@ namespace Ryujinx.Graphics.Gpu.Engine
MethodPassthrough = 2,
MethodReplay = 3,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs b/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs
index e1e3085b9..40d9a97df 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs
@@ -65,6 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
{
return format switch
{
+#pragma warning disable IDE0055 // Disable formatting
TextureFormat.R8Unorm => Format.R8Unorm,
TextureFormat.R8Snorm => Format.R8Snorm,
TextureFormat.R8Uint => Format.R8Uint,
@@ -104,7 +105,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
TextureFormat.R10G10B10A2Unorm => Format.R10G10B10A2Unorm,
TextureFormat.R10G10B10A2Uint => Format.R10G10B10A2Uint,
TextureFormat.R11G11B10Float => Format.R11G11B10Float,
- _ => 0
+ _ => 0,
+#pragma warning restore IDE0055
};
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs
index a40b9cc47..0aca39075 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs
@@ -209,14 +209,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
new AdvancedBlendUcode(AdvancedBlendOp.HslHue, AdvancedBlendOverlap.Conjoint, false, GenConjointHslHue),
new AdvancedBlendUcode(AdvancedBlendOp.HslSaturation, AdvancedBlendOverlap.Conjoint, false, GenConjointHslSaturation),
new AdvancedBlendUcode(AdvancedBlendOp.HslColor, AdvancedBlendOverlap.Conjoint, false, GenConjointHslColor),
- new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity)
+ new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity),
};
public static string GenTable()
{
// This can be used to generate the table on AdvancedBlendPreGenTable.
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new();
sb.AppendLine($"private static Dictionary _entries = new()");
sb.AppendLine("{");
@@ -4223,4 +4223,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
return new FixedFunctionAlpha(BlendOp.MaximumGl, BlendFactor.OneGl, BlendFactor.OneGl);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs
index 8072c6af2..b336382d4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs
@@ -54,12 +54,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// True if the function was found, false otherwise
public bool TryGetAdvancedBlend(out AdvancedBlendDescriptor descriptor)
{
- Span currentCode = new Span(_code);
+ Span currentCode = new(_code);
byte codeLength = (byte)_state.State.BlendUcodeSize;
if (currentCode.Length > codeLength)
{
- currentCode = currentCode.Slice(0, codeLength);
+ currentCode = currentCode[..codeLength];
}
Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast(currentCode));
@@ -112,4 +112,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
return true;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
index d35d8abf4..b6cd9def9 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
///
/// Advanced blend function entry.
///
- struct AdvancedBlendEntry
+ readonly struct AdvancedBlendEntry
{
///
/// Advanced blend operation.
@@ -270,4 +270,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
{ new Hash128(0x8652300E32D93050, 0x9460E7B449132371), new AdvancedBlendEntry(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, new[] { new RgbFloat(0.3f, 0.59f, 0.11f) }, new FixedFunctionAlpha(BlendUcodeEnable.EnableRGB, BlendOp.MaximumGl, BlendFactor.OneGl, BlendFactor.OneGl)) },
};
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs
index f06b4bf74..d3e3abbc1 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs
@@ -5,12 +5,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
///
/// Fixed function alpha state used for a advanced blend function.
///
- struct FixedFunctionAlpha
+ readonly struct FixedFunctionAlpha
{
///
/// Fixed function alpha state with alpha blending disabled.
///
- public static FixedFunctionAlpha Disabled => new FixedFunctionAlpha(BlendUcodeEnable.EnableRGBA, default, default, default);
+ public static FixedFunctionAlpha Disabled => new(BlendUcodeEnable.EnableRGBA, default, default, default);
///
/// Individual enable bits for the RGB and alpha components.
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
///
/// Advanced blend microcode state.
///
- struct AdvancedBlendUcode
+ readonly struct AdvancedBlendUcode
{
///
/// Advanced blend operation.
@@ -117,10 +117,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Overlap = overlap;
SrcPreMultiplied = srcPreMultiplied;
- UcodeAssembler asm = new UcodeAssembler();
+ UcodeAssembler asm = new();
Alpha = genFunc(ref asm);
Code = asm.GetCode();
Constants = asm.GetConstants();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs
index f854787e0..8e0209062 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs
@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Max = 3,
Rcp = 4,
Add = 5,
- Sub = 6
+ Sub = 6,
}
///
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
LT = 4,
LE = 5,
GT = 6,
- GE = 7
+ GE = 7,
}
///
@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp1 = 0xa,
Temp2 = 0xb,
PBR = 0xc,
- ConstantRGB = 0xd
+ ConstantRGB = 0xd,
}
///
@@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 4,
Temp1 = 5,
Temp2 = 6,
- PBR = 7
+ PBR = 7,
}
///
@@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 0,
Temp1 = 1,
Temp2 = 2,
- PBR = 3
+ PBR = 3,
}
///
@@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RRR = 2,
GGG = 3,
BBB = 4,
- RToA = 5
+ RToA = 5,
}
///
@@ -99,13 +99,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RGB = 0,
R = 1,
G = 2,
- B = 3
+ B = 3,
}
///
/// Floating-point RGB color values.
///
- struct RgbFloat
+ readonly struct RgbFloat
{
///
/// Red component value.
@@ -139,24 +139,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
///
/// Blend microcode destination operand, including swizzle, write mask and condition code update flag.
///
- struct Dest
+ readonly struct Dest
{
- public static Dest Temp0 => new Dest(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
- public static Dest Temp1 => new Dest(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
- public static Dest Temp2 => new Dest(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
- public static Dest PBR => new Dest(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest Temp0 => new(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest Temp1 => new(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest Temp2 => new(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest PBR => new(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
- public Dest GBR => new Dest(Dst, Swizzle.GBR, WriteMask, WriteCC);
- public Dest RRR => new Dest(Dst, Swizzle.RRR, WriteMask, WriteCC);
- public Dest GGG => new Dest(Dst, Swizzle.GGG, WriteMask, WriteCC);
- public Dest BBB => new Dest(Dst, Swizzle.BBB, WriteMask, WriteCC);
- public Dest RToA => new Dest(Dst, Swizzle.RToA, WriteMask, WriteCC);
+ public Dest GBR => new(Dst, Swizzle.GBR, WriteMask, WriteCC);
+ public Dest RRR => new(Dst, Swizzle.RRR, WriteMask, WriteCC);
+ public Dest GGG => new(Dst, Swizzle.GGG, WriteMask, WriteCC);
+ public Dest BBB => new(Dst, Swizzle.BBB, WriteMask, WriteCC);
+ public Dest RToA => new(Dst, Swizzle.RToA, WriteMask, WriteCC);
- public Dest R => new Dest(Dst, Swizzle, WriteMask.R, WriteCC);
- public Dest G => new Dest(Dst, Swizzle, WriteMask.G, WriteCC);
- public Dest B => new Dest(Dst, Swizzle, WriteMask.B, WriteCC);
+ public Dest R => new(Dst, Swizzle, WriteMask.R, WriteCC);
+ public Dest G => new(Dst, Swizzle, WriteMask.G, WriteCC);
+ public Dest B => new(Dst, Swizzle, WriteMask.B, WriteCC);
- public Dest CC => new Dest(Dst, Swizzle, WriteMask, true);
+ public Dest CC => new(Dst, Swizzle, WriteMask, true);
public OpDst Dst { get; }
public Swizzle Swizzle { get; }
@@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
///
/// Blend microcode operaiton.
///
- struct UcodeOp
+ readonly struct UcodeOp
{
public readonly uint Word;
@@ -292,14 +292,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
_constantIndex = index;
}
- public uint[] GetCode()
+ public readonly uint[] GetCode()
{
return _code?.ToArray();
}
- public RgbFloat[] GetConstants()
+ public readonly RgbFloat[] GetConstants()
{
return _constants;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs
index 5c9366160..e30092cee 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private ulong _ubFollowUpAddress = 0;
private ulong _ubByteCount = 0;
private int _ubIndex = 0;
- private int[] _ubData = new int[UniformDataCacheSize];
+ private readonly int[] _ubData = new int[UniformDataCacheSize];
///
/// Creates a new instance of the constant buffer updater.
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
index 9c4921c8b..d7ee24b19 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
@@ -186,7 +186,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
int firstVertex = (int)_state.State.FirstVertex;
- BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
+ BufferRange br = new(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
_channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
@@ -200,7 +200,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
}
else
{
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
var drawState = _state.State.VertexBufferDrawState;
+#pragma warning restore IDE0059
_context.Renderer.Pipeline.Draw(drawVertexCount, 1, drawFirstVertex, firstInstance);
}
@@ -679,7 +681,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (indexedInline)
{
int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount(_context.Renderer);
- BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
+ BufferRange br = new(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
_channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
}
@@ -809,7 +811,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Span> scissors = stackalloc Rectangle[]
{
- new Rectangle(scissorX, scissorY, scissorW, scissorH)
+ new Rectangle(scissorX, scissorY, scissorW, scissorH),
};
_context.Renderer.Pipeline.SetScissors(scissors);
@@ -821,7 +823,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
var clearColor = _state.State.ClearColors;
- ColorF color = new ColorF(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha);
+ ColorF color = new(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha);
_context.Renderer.Pipeline.ClearRenderTargetColor(index, layer, layerCount, componentMask, color);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs
index 42ec2442e..12099aef9 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs
@@ -60,6 +60,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
/// Index buffer data streamer for inline index buffer updates, such as those used in legacy OpenGL.
///
- public IbStreamer IbStreamer = new IbStreamer();
+ public IbStreamer IbStreamer = new();
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
index 80d8c00b9..022e12f57 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
@@ -1,6 +1,5 @@
using Ryujinx.Common;
using Ryujinx.Graphics.GAL;
-using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Engine.Threed
@@ -17,33 +16,35 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private int _inlineIndexBufferSize;
private int _inlineIndexCount;
private uint[] _buffer;
- private int _bufferOffset;
+#pragma warning disable IDE0051 // Remove unused private member
+ private readonly int _bufferOffset;
+#pragma warning restore IDE0051
///
/// Indicates if any index buffer data has been pushed.
///
- public bool HasInlineIndexData => _inlineIndexCount != 0;
+ public readonly bool HasInlineIndexData => _inlineIndexCount != 0;
///
/// Total numbers of indices that have been pushed.
///
- public int InlineIndexCount => _inlineIndexCount;
+ public readonly int InlineIndexCount => _inlineIndexCount;
///
/// Gets the handle for the host buffer currently holding the inline index buffer data.
///
/// Host buffer handle
- public BufferHandle GetInlineIndexBuffer()
+ public readonly BufferHandle GetInlineIndexBuffer()
{
return _inlineIndexBuffer;
}
///
/// Gets the number of elements on the current inline index buffer,
- /// while also reseting it to zero for the next draw.
+ /// while also resetting it to zero for the next draw.
///
/// Host renderer
- /// Inline index bufffer count
+ /// Inline index buffer count
public int GetAndResetInlineIndexCount(IRenderer renderer)
{
UpdateRemaining(renderer);
@@ -114,10 +115,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Index value to be written
private void PushData(IRenderer renderer, int offset, uint value)
{
- if (_buffer == null)
- {
- _buffer = new uint[BufferCapacity];
- }
+ _buffer ??= new uint[BufferCapacity];
// We upload data in chunks.
// If we are at the start of a chunk, then the buffer might be full,
@@ -155,7 +153,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
int baseOffset = (offset - count) * sizeof(uint);
int length = count * sizeof(uint);
BufferHandle buffer = GetInlineIndexBuffer(renderer, baseOffset, length);
- renderer.SetBufferData(buffer, baseOffset, MemoryMarshal.Cast(_buffer).Slice(0, length));
+ renderer.SetBufferData(buffer, baseOffset, MemoryMarshal.Cast(_buffer)[..length]);
}
///
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs
index d78aa4982..331b1976b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs
@@ -1,8 +1,11 @@
+using System.Diagnostics.CodeAnalysis;
+
namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
///
/// Indirect draw type, which can be indexed or non-indexed, with or without a draw count.
///
+ [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
enum IndirectDrawType
{
///
@@ -33,6 +36,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
/// Draw count flag.
///
- Count = 1 << 1
+ Count = 1 << 1,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs
index cf2e818ce..e575923d9 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs
@@ -36,6 +36,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
/// Default update flags for draw.
///
- UpdateAll = UseControl | UpdateDepthStencil
+ UpdateAll = UseControl | UpdateDepthStencil,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs
index 63a2c841c..0a813ee55 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs
@@ -1,5 +1,4 @@
using Ryujinx.Graphics.GAL;
-using System;
namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
@@ -15,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
Release = 0,
Acquire = 1,
- Counter = 2
+ Counter = 2,
}
///
@@ -37,7 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
ClipperInputPrimitives = 0x1c,
ClipperOutputPrimitives = 0x1d,
FragmentShaderInvocations = 0x1e,
- PrimitivesGenerated = 0x1f
+ PrimitivesGenerated = 0x1f,
}
///
@@ -64,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
TransformFeedbackOffset = 0x1a,
TessControlShaderInvocations = 0x1b,
TessEvaluationShaderInvocations = 0x1d,
- TessEvaluationShaderPrimitives = 0x1f
+ TessEvaluationShaderPrimitives = 0x1f,
}
private readonly GpuContext _context;
@@ -117,8 +116,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
switch (op)
{
- case SemaphoreOperation.Release: ReleaseSemaphore(); break;
- case SemaphoreOperation.Counter: ReportCounter(type); break;
+ case SemaphoreOperation.Release:
+ ReleaseSemaphore();
+ break;
+ case SemaphoreOperation.Counter:
+ ReportCounter(type);
+ break;
}
}
@@ -156,10 +159,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
void resultHandler(object evt, ulong result)
{
- CounterData counterData = new CounterData
+ CounterData counterData = new()
{
Counter = result,
- Timestamp = ticks
+ Timestamp = ticks,
};
if (counter?.Invalid != true)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs
index a8af54970..cbf1573cd 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs
@@ -227,7 +227,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
VertexAttribType.Sint => AttributeType.Sint,
VertexAttribType.Uint => AttributeType.Uint,
- _ => AttributeType.Float
+ _ => AttributeType.Float,
};
if (attributeTypes[location] != value)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
index 92e980ced..34439657e 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
@@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private readonly ShaderProgramInfo[] _currentProgramInfo;
private ShaderSpecializationState _shaderSpecState;
- private SpecializationStateUpdater _currentSpecState;
+ private readonly SpecializationStateUpdater _currentSpecState;
private ProgramPipelineState _pipeline;
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private uint _vbEnableMask;
private bool _prevDrawIndexed;
- private bool _prevDrawIndirect;
+ private readonly bool _prevDrawIndirect;
private IndexType _prevIndexType;
private uint _prevFirstVertex;
private bool _prevTfEnable;
@@ -448,7 +448,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
int samplesInY = msaaMode.SamplesInY();
var scissor = _state.State.ScreenScissorState;
- Size sizeHint = new Size((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1);
+ Size sizeHint = new((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1);
int clipRegionWidth = int.MaxValue;
int clipRegionHeight = int.MaxValue;
@@ -669,7 +669,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
private void UpdateDepthTestState()
{
- DepthTestDescriptor descriptor = new DepthTestDescriptor(
+ DepthTestDescriptor descriptor = new(
_state.State.DepthTestEnable,
_state.State.DepthWriteEnable,
_state.State.DepthTestFunc);
@@ -739,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
height *= scale;
}
- Rectangle region = new Rectangle(x, y, width, height);
+ Rectangle region = new(x, y, width, height);
ViewportSwizzle swizzleX = transform.UnpackSwizzleX();
ViewportSwizzle swizzleY = transform.UnpackSwizzleY();
@@ -751,9 +751,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (transform.ScaleZ < 0)
{
- float temp = depthNear;
- depthNear = depthFar;
- depthFar = temp;
+ (depthFar, depthNear) = (depthNear, depthFar);
}
viewports[index] = new Viewport(region, swizzleX, swizzleY, swizzleZ, swizzleW, depthNear, depthFar);
@@ -845,7 +843,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
backMask = test.FrontMask;
}
- StencilTestDescriptor descriptor = new StencilTestDescriptor(
+ StencilTestDescriptor descriptor = new(
test.Enable,
test.FrontFunc,
test.FrontSFail,
@@ -939,7 +937,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
VertexAttribType.Sint => Format.R32G32B32A32Sint,
VertexAttribType.Uint => Format.R32G32B32A32Uint,
- _ => Format.R32G32B32A32Float
+ _ => Format.R32G32B32A32Float,
};
}
@@ -1017,8 +1015,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
switch (indexBuffer.Type)
{
- case IndexType.UShort: size *= 2; break;
- case IndexType.UInt: size *= 4; break;
+ case IndexType.UShort:
+ size *= 2;
+ break;
+ case IndexType.UInt:
+ size *= 4;
+ break;
}
_channel.BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type);
@@ -1338,7 +1340,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_vtgWritesRtLayer = false;
- ShaderAddresses addresses = new ShaderAddresses();
+ ShaderAddresses addresses = new();
Span addressesSpan = addresses.AsSpan();
ulong baseAddress = _state.State.ShaderBaseAddress.Pack();
@@ -1453,7 +1455,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
// ScaleZ = (Far - Near) / 2
// DepthNear/Far are sorted such as that Near is always less than Far.
depthMode = extents.DepthNear != transform.TranslateZ &&
- extents.DepthFar != transform.TranslateZ
+ extents.DepthFar != transform.TranslateZ
? DepthMode.MinusOneToOne
: DepthMode.ZeroToOne;
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
index 1386071cf..1f6628909 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
@@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ nameof(ThreedClassState.UniformBufferBindTessControl), new RwCallback(ConstantBufferBindTessControl, null) },
{ nameof(ThreedClassState.UniformBufferBindTessEvaluation), new RwCallback(ConstantBufferBindTessEvaluation, null) },
{ nameof(ThreedClassState.UniformBufferBindGeometry), new RwCallback(ConstantBufferBindGeometry, null) },
- { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) }
+ { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) },
});
_i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs
index beda2dbfe..f2997678c 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
TessellationControl,
TessellationEvaluation,
Geometry,
- Fragment
+ Fragment,
}
///
@@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct TessMode
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
@@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the tessellation abstract patch type.
///
/// Abtract patch type
- public TessPatchType UnpackPatchType()
+ public readonly TessPatchType UnpackPatchType()
{
return (TessPatchType)(Packed & 3);
}
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the spacing between tessellated vertices of the patch.
///
/// Spacing between tessellated vertices
- public TessSpacing UnpackSpacing()
+ public readonly TessSpacing UnpackSpacing()
{
return (TessSpacing)((Packed >> 4) & 3);
}
@@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the primitive winding order.
///
/// True if clockwise, false if counter-clockwise
- public bool UnpackCw()
+ public readonly bool UnpackCw()
{
return (Packed & (1 << 8)) != 0;
}
@@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct TfBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public GpuVa Address;
public int Size;
@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct TfState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int BufferIndex;
public int VaryingsCount;
public int Stride;
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct RtColorState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public int WidthOrStride;
public int Height;
@@ -116,7 +116,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct ViewportTransform
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public float ScaleX;
public float ScaleY;
public float ScaleZ;
@@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position X component.
///
/// Swizzle enum value
- public ViewportSwizzle UnpackSwizzleX()
+ public readonly ViewportSwizzle UnpackSwizzleX()
{
return (ViewportSwizzle)(Swizzle & 7);
}
@@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position Y component.
///
/// Swizzle enum value
- public ViewportSwizzle UnpackSwizzleY()
+ public readonly ViewportSwizzle UnpackSwizzleY()
{
return (ViewportSwizzle)((Swizzle >> 4) & 7);
}
@@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position Z component.
///
/// Swizzle enum value
- public ViewportSwizzle UnpackSwizzleZ()
+ public readonly ViewportSwizzle UnpackSwizzleZ()
{
return (ViewportSwizzle)((Swizzle >> 8) & 7);
}
@@ -158,7 +158,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position W component.
///
/// Swizzle enum value
- public ViewportSwizzle UnpackSwizzleW()
+ public readonly ViewportSwizzle UnpackSwizzleW()
{
return (ViewportSwizzle)((Swizzle >> 12) & 7);
}
@@ -169,7 +169,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct ViewportExtents
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ushort X;
public ushort Width;
public ushort Y;
@@ -184,7 +184,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct VertexBufferDrawState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int First;
public int Count;
#pragma warning restore CS0649
@@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct ClearColors
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public float Red;
public float Green;
public float Blue;
@@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct DepthBiasState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 PointEnable;
public Boolean32 LineEnable;
public Boolean32 FillEnable;
@@ -223,7 +223,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Disabled = 0,
EnableRGB = 1,
EnableAlpha = 2,
- EnableRGBA = 3
+ EnableRGBA = 3,
}
///
@@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct ScissorState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public ushort X1;
public ushort X2;
@@ -246,7 +246,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct StencilBackMasks
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int FuncRef;
public int Mask;
public int FuncMask;
@@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct RtDepthStencilState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public ZetaFormat Format;
public MemoryLayout MemoryLayout;
@@ -271,7 +271,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct ScreenScissorState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ushort X;
public ushort Width;
public ushort Y;
@@ -297,7 +297,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Size16 = 0x1b,
Size8 = 0x1d,
Rgb10A2 = 0x30,
- Rg11B10 = 0x31
+ Rg11B10 = 0x31,
}
///
@@ -311,7 +311,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Uint = 4,
Uscaled = 5,
Sscaled = 6,
- Float = 7
+ Float = 7,
}
///
@@ -319,7 +319,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct VertexAttribState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Attribute;
#pragma warning restore CS0649
@@ -327,7 +327,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the index of the vertex buffer this attribute belongs to.
///
/// Vertex buffer index
- public int UnpackBufferIndex()
+ public readonly int UnpackBufferIndex()
{
return (int)(Attribute & 0x1f);
}
@@ -336,7 +336,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the attribute constant flag.
///
/// True if the attribute is constant, false otherwise
- public bool UnpackIsConstant()
+ public readonly bool UnpackIsConstant()
{
return (Attribute & 0x40) != 0;
}
@@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the offset, in bytes, of the attribute on the vertex buffer.
///
/// Attribute offset in bytes
- public int UnpackOffset()
+ public readonly int UnpackOffset()
{
return (int)((Attribute >> 7) & 0x3fff);
}
@@ -354,7 +354,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute format integer.
///
/// Attribute format integer
- public uint UnpackFormat()
+ public readonly uint UnpackFormat()
{
return Attribute & 0x3fe00000;
}
@@ -363,7 +363,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute size.
///
/// Attribute size
- public VertexAttribSize UnpackSize()
+ public readonly VertexAttribSize UnpackSize()
{
return (VertexAttribSize)((Attribute >> 21) & 0x3f);
}
@@ -372,7 +372,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute component type.
///
/// Attribute component type
- public VertexAttribType UnpackType()
+ public readonly VertexAttribType UnpackType()
{
return (VertexAttribType)((Attribute >> 27) & 7);
}
@@ -383,7 +383,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct RtControl
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
@@ -391,7 +391,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the number of active draw buffers.
///
/// Number of active draw buffers
- public int UnpackCount()
+ public readonly int UnpackCount()
{
return (int)(Packed & 0xf);
}
@@ -401,7 +401,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
/// Index of the draw buffer
/// Attachment index
- public int UnpackPermutationIndex(int index)
+ public readonly int UnpackPermutationIndex(int index)
{
return (int)((Packed >> (4 + index * 3)) & 7);
}
@@ -412,7 +412,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct Size3D
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int Width;
public int Height;
public int Depth;
@@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct StencilTestState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public StencilOp FrontSFail;
public StencilOp FrontDpFail;
@@ -443,7 +443,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
enum YControl
{
NegateY = 1 << 0,
- TriangleRastFlip = 1 << 4
+ TriangleRastFlip = 1 << 4,
}
///
@@ -451,7 +451,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct RgbHalf
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint R;
public uint G;
public uint B;
@@ -462,7 +462,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the red color component as a 16-bit float value.
///
/// The component value
- public Half UnpackR()
+ public readonly Half UnpackR()
{
ushort value = (ushort)R;
return Unsafe.As(ref value);
@@ -472,7 +472,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the green color component as a 16-bit float value.
///
/// The component value
- public Half UnpackG()
+ public readonly Half UnpackG()
{
ushort value = (ushort)G;
return Unsafe.As(ref value);
@@ -482,7 +482,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the blue color component as a 16-bit float value.
///
/// The component value
- public Half UnpackB()
+ public readonly Half UnpackB()
{
ushort value = (ushort)B;
return Unsafe.As(ref value);
@@ -498,7 +498,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Always,
ResultNonZero,
Equal,
- NotEqual
+ NotEqual,
}
///
@@ -506,7 +506,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct PoolState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public int MaximumId;
#pragma warning restore CS0649
@@ -517,7 +517,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct StencilBackTestState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 TwoSided;
public StencilOp BackSFail;
public StencilOp BackDpFail;
@@ -531,7 +531,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct PrimitiveRestartState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public int Index;
#pragma warning restore CS0649
@@ -543,7 +543,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct IndexBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public GpuVa EndAddress;
public IndexType Type;
@@ -556,7 +556,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct FaceState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 CullEnable;
public FrontFace FrontFace;
public Face CullFace;
@@ -570,7 +570,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
enum ViewVolumeClipControl
{
ForceDepthRangeZeroToOne = 1 << 0,
- DepthClampDisabled = 1 << 11
+ DepthClampDisabled = 1 << 11,
}
///
@@ -578,7 +578,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct LogicalOpState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public LogicalOp LogicalOp;
#pragma warning restore CS0649
@@ -590,7 +590,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct RtColorMask
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
@@ -598,7 +598,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks red channel enable.
///
/// True to write the new red channel color, false to keep the old value
- public bool UnpackRed()
+ public readonly bool UnpackRed()
{
return (Packed & 0x1) != 0;
}
@@ -607,7 +607,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks green channel enable.
///
/// True to write the new green channel color, false to keep the old value
- public bool UnpackGreen()
+ public readonly bool UnpackGreen()
{
return (Packed & 0x10) != 0;
}
@@ -616,7 +616,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks blue channel enable.
///
/// True to write the new blue channel color, false to keep the old value
- public bool UnpackBlue()
+ public readonly bool UnpackBlue()
{
return (Packed & 0x100) != 0;
}
@@ -625,7 +625,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks alpha channel enable.
///
/// True to write the new alpha channel color, false to keep the old value
- public bool UnpackAlpha()
+ public readonly bool UnpackAlpha()
{
return (Packed & 0x1000) != 0;
}
@@ -636,7 +636,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct VertexBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Control;
public GpuVa Address;
public int Divisor;
@@ -646,7 +646,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Vertex buffer stride, defined as the number of bytes occupied by each vertex in memory.
///
/// Vertex buffer stride
- public int UnpackStride()
+ public readonly int UnpackStride()
{
return (int)(Control & 0xfff);
}
@@ -655,7 +655,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Vertex buffer enable.
///
/// True if the vertex buffer is enabled, false otherwise
- public bool UnpackEnable()
+ public readonly bool UnpackEnable()
{
return (Control & (1 << 12)) != 0;
}
@@ -666,7 +666,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct BlendStateCommon
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha;
public BlendOp ColorOp;
public BlendFactor ColorSrcFactor;
@@ -683,7 +683,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct BlendState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha;
public BlendOp ColorOp;
public BlendFactor ColorSrcFactor;
@@ -700,7 +700,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct ShaderState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Control;
public uint Offset;
public uint Unknown0x8;
@@ -724,7 +724,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Must be ignored for vertex shaders, those are always enabled.
///
/// True if the stage is enabled, false otherwise
- public bool UnpackEnable()
+ public readonly bool UnpackEnable()
{
return (Control & 1) != 0;
}
@@ -735,7 +735,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
///
struct UniformBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int Size;
public GpuVa Address;
public int Offset;
@@ -744,30 +744,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
unsafe struct ThreedClassState : IShadowState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public uint LoadMmeInstructionRamPointer;
public uint LoadMmeInstructionRam;
public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl;
- public SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
+ public readonly SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
public fixed uint Reserved128[2];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public uint PmTriggerWfi;
@@ -778,30 +778,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public uint LineLengthIn;
public uint LineCount;
public uint OffsetOutUpper;
- public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut;
public uint PitchOut;
public uint SetDstBlockSize;
- public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOriginBytesX;
- public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
+ public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY;
- public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
+ public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma;
- public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
- public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
- public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
- public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
- public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
- public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
- public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
+ public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
+ public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
+ public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
+ public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
+ public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
+ public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
+ public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData;
public fixed uint Reserved1B8[22];
public Boolean32 EarlyZForce;
@@ -1042,7 +1042,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public fixed uint Reserved260C[125];
public Array4> TfVaryingLocations;
public fixed uint Reserved2A00[640];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256 SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs
index 2ac84ab50..b33fb7f73 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs
@@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
_channel = channel;
_state = new DeviceState(new Dictionary
{
- { nameof(TwodClassState.PixelsFromMemorySrcY0Int), new RwCallback(PixelsFromMemorySrcY0Int, null) }
+ { nameof(TwodClassState.PixelsFromMemorySrcY0Int), new RwCallback(PixelsFromMemorySrcY0Int, null) },
});
}
@@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// Format of the first texture
/// Format of the second texture
/// True if the data is compatible, false otherwise
- private bool IsDataCompatible(TwodTexture lhs, TwodTexture rhs, FormatInfo lhsFormat, FormatInfo rhsFormat)
+ private static bool IsDataCompatible(TwodTexture lhs, TwodTexture rhs, FormatInfo lhsFormat, FormatInfo rhsFormat)
{
if (lhsFormat.BytesPerPixel != rhsFormat.BytesPerPixel ||
lhs.Height != rhs.Height ||
@@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// Region end x
/// Region end y
/// True if the region covers the full texture, false otherwise
- private bool IsCopyRegionComplete(TwodTexture texture, FormatInfo formatInfo, int x1, int y1, int x2, int y2)
+ private static bool IsCopyRegionComplete(TwodTexture texture, FormatInfo formatInfo, int x1, int y1, int x2, int y2)
{
if (x1 != 0 || y1 != 0 || y2 != texture.Height)
{
@@ -172,7 +172,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
for (int y = 0; y < height; y++)
{
- srcSpan.Slice(offset, lineSize).CopyTo(dstSpan.Slice(offset));
+ srcSpan.Slice(offset, lineSize).CopyTo(dstSpan[offset..]);
offset += stride;
}
@@ -364,13 +364,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
float scale = srcTexture.ScaleFactor;
float dstScale = dstTexture.ScaleFactor;
- Extents2D srcRegion = new Extents2D(
+ Extents2D srcRegion = new(
(int)Math.Ceiling(scale * (srcX1 / srcTexture.Info.SamplesInX)),
(int)Math.Ceiling(scale * (srcY1 / srcTexture.Info.SamplesInY)),
(int)Math.Ceiling(scale * (srcX2 / srcTexture.Info.SamplesInX)),
(int)Math.Ceiling(scale * (srcY2 / srcTexture.Info.SamplesInY)));
- Extents2D dstRegion = new Extents2D(
+ Extents2D dstRegion = new(
(int)Math.Ceiling(dstScale * (dstX1 / dstTexture.Info.SamplesInX)),
(int)Math.Ceiling(dstScale * (dstY1 / dstTexture.Info.SamplesInY)),
(int)Math.Ceiling(dstScale * (dstX2 / dstTexture.Info.SamplesInX)),
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs
index 55e5019fc..edea73273 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs
@@ -486,7 +486,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
///
struct RenderSolidPrimPoint
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetX;
public uint Y;
#pragma warning restore CS0649
@@ -497,30 +497,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
///
unsafe struct TwodClassState : IShadowState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0x1FFFFFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0x1FFFFFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public uint LoadMmeInstructionRamPointer;
public uint LoadMmeInstructionRam;
public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl;
- public SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
+ public readonly SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
public fixed uint Reserved128[2];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public fixed uint Reserved144[3];
@@ -528,54 +528,54 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetInstrumentationMethodData;
public fixed uint Reserved158[37];
public uint SetMmeSwitchState;
- public bool SetMmeSwitchStateValid => (SetMmeSwitchState & 0x1) != 0;
- public int SetMmeSwitchStateSaveMacro => (int)((SetMmeSwitchState >> 4) & 0xFF);
- public int SetMmeSwitchStateRestoreMacro => (int)((SetMmeSwitchState >> 12) & 0xFF);
+ public readonly bool SetMmeSwitchStateValid => (SetMmeSwitchState & 0x1) != 0;
+ public readonly int SetMmeSwitchStateSaveMacro => (int)((SetMmeSwitchState >> 4) & 0xFF);
+ public readonly int SetMmeSwitchStateRestoreMacro => (int)((SetMmeSwitchState >> 12) & 0xFF);
public fixed uint Reserved1F0[4];
public uint SetDstFormat;
- public SetDstFormatV SetDstFormatV => (SetDstFormatV)(SetDstFormat & 0xFF);
+ public readonly SetDstFormatV SetDstFormatV => (SetDstFormatV)(SetDstFormat & 0xFF);
public uint SetDstMemoryLayout;
- public SetDstMemoryLayoutV SetDstMemoryLayoutV => (SetDstMemoryLayoutV)(SetDstMemoryLayout & 0x1);
+ public readonly SetDstMemoryLayoutV SetDstMemoryLayoutV => (SetDstMemoryLayoutV)(SetDstMemoryLayout & 0x1);
public uint SetDstBlockSize;
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0x7);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0x7);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0x7);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0x7);
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstPitch;
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstOffsetUpper;
- public int SetDstOffsetUpperV => (int)(SetDstOffsetUpper & 0xFF);
+ public readonly int SetDstOffsetUpperV => (int)(SetDstOffsetUpper & 0xFF);
public uint SetDstOffsetLower;
public uint FlushAndInvalidateRopMiniCache;
- public bool FlushAndInvalidateRopMiniCacheV => (FlushAndInvalidateRopMiniCache & 0x1) != 0;
+ public readonly bool FlushAndInvalidateRopMiniCacheV => (FlushAndInvalidateRopMiniCache & 0x1) != 0;
public uint SetSpareNoop06;
public uint SetSrcFormat;
- public SetSrcFormatV SetSrcFormatV => (SetSrcFormatV)(SetSrcFormat & 0xFF);
+ public readonly SetSrcFormatV SetSrcFormatV => (SetSrcFormatV)(SetSrcFormat & 0xFF);
public uint SetSrcMemoryLayout;
- public SetSrcMemoryLayoutV SetSrcMemoryLayoutV => (SetSrcMemoryLayoutV)(SetSrcMemoryLayout & 0x1);
+ public readonly SetSrcMemoryLayoutV SetSrcMemoryLayoutV => (SetSrcMemoryLayoutV)(SetSrcMemoryLayout & 0x1);
public uint SetSrcBlockSize;
- public SetSrcBlockSizeHeight SetSrcBlockSizeHeight => (SetSrcBlockSizeHeight)((SetSrcBlockSize >> 4) & 0x7);
- public SetSrcBlockSizeDepth SetSrcBlockSizeDepth => (SetSrcBlockSizeDepth)((SetSrcBlockSize >> 8) & 0x7);
+ public readonly SetSrcBlockSizeHeight SetSrcBlockSizeHeight => (SetSrcBlockSizeHeight)((SetSrcBlockSize >> 4) & 0x7);
+ public readonly SetSrcBlockSizeDepth SetSrcBlockSizeDepth => (SetSrcBlockSizeDepth)((SetSrcBlockSize >> 8) & 0x7);
public uint SetSrcDepth;
public uint TwodInvalidateTextureDataCache;
- public TwodInvalidateTextureDataCacheV TwodInvalidateTextureDataCacheV => (TwodInvalidateTextureDataCacheV)(TwodInvalidateTextureDataCache & 0x3);
+ public readonly TwodInvalidateTextureDataCacheV TwodInvalidateTextureDataCacheV => (TwodInvalidateTextureDataCacheV)(TwodInvalidateTextureDataCache & 0x3);
public uint SetSrcPitch;
public uint SetSrcWidth;
public uint SetSrcHeight;
public uint SetSrcOffsetUpper;
- public int SetSrcOffsetUpperV => (int)(SetSrcOffsetUpper & 0xFF);
+ public readonly int SetSrcOffsetUpperV => (int)(SetSrcOffsetUpper & 0xFF);
public uint SetSrcOffsetLower;
public uint SetPixelsFromMemorySectorPromotion;
- public SetPixelsFromMemorySectorPromotionV SetPixelsFromMemorySectorPromotionV => (SetPixelsFromMemorySectorPromotionV)(SetPixelsFromMemorySectorPromotion & 0x3);
+ public readonly SetPixelsFromMemorySectorPromotionV SetPixelsFromMemorySectorPromotionV => (SetPixelsFromMemorySectorPromotionV)(SetPixelsFromMemorySectorPromotion & 0x3);
public uint SetSpareNoop12;
public uint SetNumProcessingClusters;
- public SetNumProcessingClustersV SetNumProcessingClustersV => (SetNumProcessingClustersV)(SetNumProcessingClusters & 0x1);
+ public readonly SetNumProcessingClustersV SetNumProcessingClustersV => (SetNumProcessingClustersV)(SetNumProcessingClusters & 0x1);
public uint SetRenderEnableA;
- public int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
+ public readonly int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB;
public uint SetRenderEnableC;
- public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
+ public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetSpareNoop08;
public uint SetSpareNoop01;
public uint SetSpareNoop11;
@@ -585,29 +585,29 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetClipWidth;
public uint SetClipHeight;
public uint SetClipEnable;
- public bool SetClipEnableV => (SetClipEnable & 0x1) != 0;
+ public readonly bool SetClipEnableV => (SetClipEnable & 0x1) != 0;
public uint SetColorKeyFormat;
- public SetColorKeyFormatV SetColorKeyFormatV => (SetColorKeyFormatV)(SetColorKeyFormat & 0x7);
+ public readonly SetColorKeyFormatV SetColorKeyFormatV => (SetColorKeyFormatV)(SetColorKeyFormat & 0x7);
public uint SetColorKey;
public uint SetColorKeyEnable;
- public bool SetColorKeyEnableV => (SetColorKeyEnable & 0x1) != 0;
+ public readonly bool SetColorKeyEnableV => (SetColorKeyEnable & 0x1) != 0;
public uint SetRop;
- public int SetRopV => (int)(SetRop & 0xFF);
+ public readonly int SetRopV => (int)(SetRop & 0xFF);
public uint SetBeta1;
public uint SetBeta4;
- public int SetBeta4B => (int)(SetBeta4 & 0xFF);
- public int SetBeta4G => (int)((SetBeta4 >> 8) & 0xFF);
- public int SetBeta4R => (int)((SetBeta4 >> 16) & 0xFF);
- public int SetBeta4A => (int)((SetBeta4 >> 24) & 0xFF);
+ public readonly int SetBeta4B => (int)(SetBeta4 & 0xFF);
+ public readonly int SetBeta4G => (int)((SetBeta4 >> 8) & 0xFF);
+ public readonly int SetBeta4R => (int)((SetBeta4 >> 16) & 0xFF);
+ public readonly int SetBeta4A => (int)((SetBeta4 >> 24) & 0xFF);
public uint SetOperation;
- public SetOperationV SetOperationV => (SetOperationV)(SetOperation & 0x7);
+ public readonly SetOperationV SetOperationV => (SetOperationV)(SetOperation & 0x7);
public uint SetPatternOffset;
- public int SetPatternOffsetX => (int)(SetPatternOffset & 0x3F);
- public int SetPatternOffsetY => (int)((SetPatternOffset >> 8) & 0x3F);
+ public readonly int SetPatternOffsetX => (int)(SetPatternOffset & 0x3F);
+ public readonly int SetPatternOffsetY => (int)((SetPatternOffset >> 8) & 0x3F);
public uint SetPatternSelect;
- public SetPatternSelectV SetPatternSelectV => (SetPatternSelectV)(SetPatternSelect & 0x3);
+ public readonly SetPatternSelectV SetPatternSelectV => (SetPatternSelectV)(SetPatternSelect & 0x3);
public uint SetDstColorRenderToZetaSurface;
- public bool SetDstColorRenderToZetaSurfaceV => (SetDstColorRenderToZetaSurface & 0x1) != 0;
+ public readonly bool SetDstColorRenderToZetaSurfaceV => (SetDstColorRenderToZetaSurface & 0x1) != 0;
public uint SetSpareNoop04;
public uint SetSpareNoop15;
public uint SetSpareNoop13;
@@ -615,18 +615,18 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetSpareNoop14;
public uint SetSpareNoop02;
public uint SetCompression;
- public bool SetCompressionEnable => (SetCompression & 0x1) != 0;
+ public readonly bool SetCompressionEnable => (SetCompression & 0x1) != 0;
public uint SetSpareNoop09;
public uint SetRenderEnableOverride;
- public SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
+ public readonly SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
public uint SetPixelsFromMemoryDirection;
- public SetPixelsFromMemoryDirectionHorizontal SetPixelsFromMemoryDirectionHorizontal => (SetPixelsFromMemoryDirectionHorizontal)(SetPixelsFromMemoryDirection & 0x3);
- public SetPixelsFromMemoryDirectionVertical SetPixelsFromMemoryDirectionVertical => (SetPixelsFromMemoryDirectionVertical)((SetPixelsFromMemoryDirection >> 4) & 0x3);
+ public readonly SetPixelsFromMemoryDirectionHorizontal SetPixelsFromMemoryDirectionHorizontal => (SetPixelsFromMemoryDirectionHorizontal)(SetPixelsFromMemoryDirection & 0x3);
+ public readonly SetPixelsFromMemoryDirectionVertical SetPixelsFromMemoryDirectionVertical => (SetPixelsFromMemoryDirectionVertical)((SetPixelsFromMemoryDirection >> 4) & 0x3);
public uint SetSpareNoop10;
public uint SetMonochromePatternColorFormat;
- public SetMonochromePatternColorFormatV SetMonochromePatternColorFormatV => (SetMonochromePatternColorFormatV)(SetMonochromePatternColorFormat & 0x7);
+ public readonly SetMonochromePatternColorFormatV SetMonochromePatternColorFormatV => (SetMonochromePatternColorFormatV)(SetMonochromePatternColorFormat & 0x7);
public uint SetMonochromePatternFormat;
- public SetMonochromePatternFormatV SetMonochromePatternFormatV => (SetMonochromePatternFormatV)(SetMonochromePatternFormat & 0x1);
+ public readonly SetMonochromePatternFormatV SetMonochromePatternFormatV => (SetMonochromePatternFormatV)(SetMonochromePatternFormat & 0x1);
public uint SetMonochromePatternColor0;
public uint SetMonochromePatternColor1;
public uint SetMonochromePattern0;
@@ -662,52 +662,52 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetRenderSolidPrimColor2;
public uint SetRenderSolidPrimColor3;
public uint SetMmeMemAddressA;
- public int SetMmeMemAddressAUpper => (int)(SetMmeMemAddressA & 0x1FFFFFF);
+ public readonly int SetMmeMemAddressAUpper => (int)(SetMmeMemAddressA & 0x1FFFFFF);
public uint SetMmeMemAddressB;
public uint SetMmeDataRamAddress;
public uint MmeDmaRead;
public uint MmeDmaReadFifoed;
public uint MmeDmaWrite;
public uint MmeDmaReduction;
- public MmeDmaReductionReductionOp MmeDmaReductionReductionOp => (MmeDmaReductionReductionOp)(MmeDmaReduction & 0x7);
- public MmeDmaReductionReductionFormat MmeDmaReductionReductionFormat => (MmeDmaReductionReductionFormat)((MmeDmaReduction >> 4) & 0x3);
- public MmeDmaReductionReductionSize MmeDmaReductionReductionSize => (MmeDmaReductionReductionSize)((MmeDmaReduction >> 8) & 0x1);
+ public readonly MmeDmaReductionReductionOp MmeDmaReductionReductionOp => (MmeDmaReductionReductionOp)(MmeDmaReduction & 0x7);
+ public readonly MmeDmaReductionReductionFormat MmeDmaReductionReductionFormat => (MmeDmaReductionReductionFormat)((MmeDmaReduction >> 4) & 0x3);
+ public readonly MmeDmaReductionReductionSize MmeDmaReductionReductionSize => (MmeDmaReductionReductionSize)((MmeDmaReduction >> 8) & 0x1);
public uint MmeDmaSysmembar;
- public bool MmeDmaSysmembarV => (MmeDmaSysmembar & 0x1) != 0;
+ public readonly bool MmeDmaSysmembarV => (MmeDmaSysmembar & 0x1) != 0;
public uint MmeDmaSync;
public uint SetMmeDataFifoConfig;
- public SetMmeDataFifoConfigFifoSize SetMmeDataFifoConfigFifoSize => (SetMmeDataFifoConfigFifoSize)(SetMmeDataFifoConfig & 0x7);
+ public readonly SetMmeDataFifoConfigFifoSize SetMmeDataFifoConfigFifoSize => (SetMmeDataFifoConfigFifoSize)(SetMmeDataFifoConfig & 0x7);
public fixed uint Reserved578[2];
public uint RenderSolidPrimMode;
- public RenderSolidPrimModeV RenderSolidPrimModeV => (RenderSolidPrimModeV)(RenderSolidPrimMode & 0x7);
+ public readonly RenderSolidPrimModeV RenderSolidPrimModeV => (RenderSolidPrimModeV)(RenderSolidPrimMode & 0x7);
public uint SetRenderSolidPrimColorFormat;
- public SetRenderSolidPrimColorFormatV SetRenderSolidPrimColorFormatV => (SetRenderSolidPrimColorFormatV)(SetRenderSolidPrimColorFormat & 0xFF);
+ public readonly SetRenderSolidPrimColorFormatV SetRenderSolidPrimColorFormatV => (SetRenderSolidPrimColorFormatV)(SetRenderSolidPrimColorFormat & 0xFF);
public uint SetRenderSolidPrimColor;
public uint SetRenderSolidLineTieBreakBits;
- public bool SetRenderSolidLineTieBreakBitsXmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x1) != 0;
- public bool SetRenderSolidLineTieBreakBitsXmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x10) != 0;
- public bool SetRenderSolidLineTieBreakBitsYmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x100) != 0;
- public bool SetRenderSolidLineTieBreakBitsYmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x1000) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsXmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x1) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsXmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x10) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsYmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x100) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsYmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x1000) != 0;
public fixed uint Reserved590[20];
public uint RenderSolidPrimPointXY;
- public int RenderSolidPrimPointXYX => (int)(RenderSolidPrimPointXY & 0xFFFF);
- public int RenderSolidPrimPointXYY => (int)((RenderSolidPrimPointXY >> 16) & 0xFFFF);
+ public readonly int RenderSolidPrimPointXYX => (int)(RenderSolidPrimPointXY & 0xFFFF);
+ public readonly int RenderSolidPrimPointXYY => (int)((RenderSolidPrimPointXY >> 16) & 0xFFFF);
public fixed uint Reserved5E4[7];
public Array64 RenderSolidPrimPoint;
public uint SetPixelsFromCpuDataType;
- public SetPixelsFromCpuDataTypeV SetPixelsFromCpuDataTypeV => (SetPixelsFromCpuDataTypeV)(SetPixelsFromCpuDataType & 0x1);
+ public readonly SetPixelsFromCpuDataTypeV SetPixelsFromCpuDataTypeV => (SetPixelsFromCpuDataTypeV)(SetPixelsFromCpuDataType & 0x1);
public uint SetPixelsFromCpuColorFormat;
- public SetPixelsFromCpuColorFormatV SetPixelsFromCpuColorFormatV => (SetPixelsFromCpuColorFormatV)(SetPixelsFromCpuColorFormat & 0xFF);
+ public readonly SetPixelsFromCpuColorFormatV SetPixelsFromCpuColorFormatV => (SetPixelsFromCpuColorFormatV)(SetPixelsFromCpuColorFormat & 0xFF);
public uint SetPixelsFromCpuIndexFormat;
- public SetPixelsFromCpuIndexFormatV SetPixelsFromCpuIndexFormatV => (SetPixelsFromCpuIndexFormatV)(SetPixelsFromCpuIndexFormat & 0x3);
+ public readonly SetPixelsFromCpuIndexFormatV SetPixelsFromCpuIndexFormatV => (SetPixelsFromCpuIndexFormatV)(SetPixelsFromCpuIndexFormat & 0x3);
public uint SetPixelsFromCpuMonoFormat;
- public SetPixelsFromCpuMonoFormatV SetPixelsFromCpuMonoFormatV => (SetPixelsFromCpuMonoFormatV)(SetPixelsFromCpuMonoFormat & 0x1);
+ public readonly SetPixelsFromCpuMonoFormatV SetPixelsFromCpuMonoFormatV => (SetPixelsFromCpuMonoFormatV)(SetPixelsFromCpuMonoFormat & 0x1);
public uint SetPixelsFromCpuWrap;
- public SetPixelsFromCpuWrapV SetPixelsFromCpuWrapV => (SetPixelsFromCpuWrapV)(SetPixelsFromCpuWrap & 0x3);
+ public readonly SetPixelsFromCpuWrapV SetPixelsFromCpuWrapV => (SetPixelsFromCpuWrapV)(SetPixelsFromCpuWrap & 0x3);
public uint SetPixelsFromCpuColor0;
public uint SetPixelsFromCpuColor1;
public uint SetPixelsFromCpuMonoOpacity;
- public SetPixelsFromCpuMonoOpacityV SetPixelsFromCpuMonoOpacityV => (SetPixelsFromCpuMonoOpacityV)(SetPixelsFromCpuMonoOpacity & 0x1);
+ public readonly SetPixelsFromCpuMonoOpacityV SetPixelsFromCpuMonoOpacityV => (SetPixelsFromCpuMonoOpacityV)(SetPixelsFromCpuMonoOpacity & 0x1);
public fixed uint Reserved820[6];
public uint SetPixelsFromCpuSrcWidth;
public uint SetPixelsFromCpuSrcHeight;
@@ -722,45 +722,45 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint PixelsFromCpuData;
public fixed uint Reserved864[3];
public uint SetBigEndianControl;
- public bool SetBigEndianControlX32Swap1 => (SetBigEndianControl & 0x1) != 0;
- public bool SetBigEndianControlX32Swap4 => (SetBigEndianControl & 0x2) != 0;
- public bool SetBigEndianControlX32Swap8 => (SetBigEndianControl & 0x4) != 0;
- public bool SetBigEndianControlX32Swap16 => (SetBigEndianControl & 0x8) != 0;
- public bool SetBigEndianControlX16Swap1 => (SetBigEndianControl & 0x10) != 0;
- public bool SetBigEndianControlX16Swap4 => (SetBigEndianControl & 0x20) != 0;
- public bool SetBigEndianControlX16Swap8 => (SetBigEndianControl & 0x40) != 0;
- public bool SetBigEndianControlX16Swap16 => (SetBigEndianControl & 0x80) != 0;
- public bool SetBigEndianControlX8Swap1 => (SetBigEndianControl & 0x100) != 0;
- public bool SetBigEndianControlX8Swap4 => (SetBigEndianControl & 0x200) != 0;
- public bool SetBigEndianControlX8Swap8 => (SetBigEndianControl & 0x400) != 0;
- public bool SetBigEndianControlX8Swap16 => (SetBigEndianControl & 0x800) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap1 => (SetBigEndianControl & 0x1000) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap4 => (SetBigEndianControl & 0x2000) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap8 => (SetBigEndianControl & 0x4000) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap16 => (SetBigEndianControl & 0x8000) != 0;
- public bool SetBigEndianControlI1X8LeSwap1 => (SetBigEndianControl & 0x10000) != 0;
- public bool SetBigEndianControlI1X8LeSwap4 => (SetBigEndianControl & 0x20000) != 0;
- public bool SetBigEndianControlI1X8LeSwap8 => (SetBigEndianControl & 0x40000) != 0;
- public bool SetBigEndianControlI1X8LeSwap16 => (SetBigEndianControl & 0x80000) != 0;
- public bool SetBigEndianControlI4Swap1 => (SetBigEndianControl & 0x100000) != 0;
- public bool SetBigEndianControlI4Swap4 => (SetBigEndianControl & 0x200000) != 0;
- public bool SetBigEndianControlI4Swap8 => (SetBigEndianControl & 0x400000) != 0;
- public bool SetBigEndianControlI4Swap16 => (SetBigEndianControl & 0x800000) != 0;
- public bool SetBigEndianControlI8Swap1 => (SetBigEndianControl & 0x1000000) != 0;
- public bool SetBigEndianControlI8Swap4 => (SetBigEndianControl & 0x2000000) != 0;
- public bool SetBigEndianControlI8Swap8 => (SetBigEndianControl & 0x4000000) != 0;
- public bool SetBigEndianControlI8Swap16 => (SetBigEndianControl & 0x8000000) != 0;
- public bool SetBigEndianControlOverride => (SetBigEndianControl & 0x10000000) != 0;
+ public readonly bool SetBigEndianControlX32Swap1 => (SetBigEndianControl & 0x1) != 0;
+ public readonly bool SetBigEndianControlX32Swap4 => (SetBigEndianControl & 0x2) != 0;
+ public readonly bool SetBigEndianControlX32Swap8 => (SetBigEndianControl & 0x4) != 0;
+ public readonly bool SetBigEndianControlX32Swap16 => (SetBigEndianControl & 0x8) != 0;
+ public readonly bool SetBigEndianControlX16Swap1 => (SetBigEndianControl & 0x10) != 0;
+ public readonly bool SetBigEndianControlX16Swap4 => (SetBigEndianControl & 0x20) != 0;
+ public readonly bool SetBigEndianControlX16Swap8 => (SetBigEndianControl & 0x40) != 0;
+ public readonly bool SetBigEndianControlX16Swap16 => (SetBigEndianControl & 0x80) != 0;
+ public readonly bool SetBigEndianControlX8Swap1 => (SetBigEndianControl & 0x100) != 0;
+ public readonly bool SetBigEndianControlX8Swap4 => (SetBigEndianControl & 0x200) != 0;
+ public readonly bool SetBigEndianControlX8Swap8 => (SetBigEndianControl & 0x400) != 0;
+ public readonly bool SetBigEndianControlX8Swap16 => (SetBigEndianControl & 0x800) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap1 => (SetBigEndianControl & 0x1000) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap4 => (SetBigEndianControl & 0x2000) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap8 => (SetBigEndianControl & 0x4000) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap16 => (SetBigEndianControl & 0x8000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap1 => (SetBigEndianControl & 0x10000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap4 => (SetBigEndianControl & 0x20000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap8 => (SetBigEndianControl & 0x40000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap16 => (SetBigEndianControl & 0x80000) != 0;
+ public readonly bool SetBigEndianControlI4Swap1 => (SetBigEndianControl & 0x100000) != 0;
+ public readonly bool SetBigEndianControlI4Swap4 => (SetBigEndianControl & 0x200000) != 0;
+ public readonly bool SetBigEndianControlI4Swap8 => (SetBigEndianControl & 0x400000) != 0;
+ public readonly bool SetBigEndianControlI4Swap16 => (SetBigEndianControl & 0x800000) != 0;
+ public readonly bool SetBigEndianControlI8Swap1 => (SetBigEndianControl & 0x1000000) != 0;
+ public readonly bool SetBigEndianControlI8Swap4 => (SetBigEndianControl & 0x2000000) != 0;
+ public readonly bool SetBigEndianControlI8Swap8 => (SetBigEndianControl & 0x4000000) != 0;
+ public readonly bool SetBigEndianControlI8Swap16 => (SetBigEndianControl & 0x8000000) != 0;
+ public readonly bool SetBigEndianControlOverride => (SetBigEndianControl & 0x10000000) != 0;
public fixed uint Reserved874[3];
public uint SetPixelsFromMemoryBlockShape;
- public SetPixelsFromMemoryBlockShapeV SetPixelsFromMemoryBlockShapeV => (SetPixelsFromMemoryBlockShapeV)(SetPixelsFromMemoryBlockShape & 0x7);
+ public readonly SetPixelsFromMemoryBlockShapeV SetPixelsFromMemoryBlockShapeV => (SetPixelsFromMemoryBlockShapeV)(SetPixelsFromMemoryBlockShape & 0x7);
public uint SetPixelsFromMemoryCorralSize;
- public int SetPixelsFromMemoryCorralSizeV => (int)(SetPixelsFromMemoryCorralSize & 0x3FF);
+ public readonly int SetPixelsFromMemoryCorralSizeV => (int)(SetPixelsFromMemoryCorralSize & 0x3FF);
public uint SetPixelsFromMemorySafeOverlap;
- public bool SetPixelsFromMemorySafeOverlapV => (SetPixelsFromMemorySafeOverlap & 0x1) != 0;
+ public readonly bool SetPixelsFromMemorySafeOverlapV => (SetPixelsFromMemorySafeOverlap & 0x1) != 0;
public uint SetPixelsFromMemorySampleMode;
- public SetPixelsFromMemorySampleModeOrigin SetPixelsFromMemorySampleModeOrigin => (SetPixelsFromMemorySampleModeOrigin)(SetPixelsFromMemorySampleMode & 0x1);
- public SetPixelsFromMemorySampleModeFilter SetPixelsFromMemorySampleModeFilter => (SetPixelsFromMemorySampleModeFilter)((SetPixelsFromMemorySampleMode >> 4) & 0x1);
+ public readonly SetPixelsFromMemorySampleModeOrigin SetPixelsFromMemorySampleModeOrigin => (SetPixelsFromMemorySampleModeOrigin)(SetPixelsFromMemorySampleMode & 0x1);
+ public readonly SetPixelsFromMemorySampleModeFilter SetPixelsFromMemorySampleModeFilter => (SetPixelsFromMemorySampleModeFilter)((SetPixelsFromMemorySampleMode >> 4) & 0x1);
public fixed uint Reserved890[8];
public uint SetPixelsFromMemoryDstX0;
public uint SetPixelsFromMemoryDstY0;
@@ -808,9 +808,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetFalcon31;
public fixed uint Reserved960[291];
public uint MmeDmaWriteMethodBarrier;
- public bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0;
+ public readonly bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0;
public fixed uint ReservedDF0[2436];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256 SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs
index c28da0948..dd6b69000 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
///
struct TwodTexture
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ColorFormat Format;
public Boolean32 LinearLayout;
public MemoryLayout MemoryLayout;
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs
index c982347a1..911ad53b4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs
@@ -3,10 +3,10 @@
///
/// Boolean value, stored as a 32-bits integer in memory.
///
- struct Boolean32
+ readonly struct Boolean32
{
-#pragma warning disable CS0649
- private uint _value;
+#pragma warning disable CS0649 // Field is never assigned to
+ private readonly uint _value;
#pragma warning restore CS0649
public static implicit operator bool(Boolean32 value)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs
index 889b5c8b0..c798384f0 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs
@@ -9,58 +9,58 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
enum ColorFormat
{
R32G32B32A32Float = 0xc0,
- R32G32B32A32Sint = 0xc1,
- R32G32B32A32Uint = 0xc2,
+ R32G32B32A32Sint = 0xc1,
+ R32G32B32A32Uint = 0xc2,
R32G32B32X32Float = 0xc3,
- R32G32B32X32Sint = 0xc4,
- R32G32B32X32Uint = 0xc5,
+ R32G32B32X32Sint = 0xc4,
+ R32G32B32X32Uint = 0xc5,
R16G16B16X16Unorm = 0xc6,
R16G16B16X16Snorm = 0xc7,
- R16G16B16X16Sint = 0xc8,
- R16G16B16X16Uint = 0xc9,
+ R16G16B16X16Sint = 0xc8,
+ R16G16B16X16Uint = 0xc9,
R16G16B16A16Float = 0xca,
- R32G32Float = 0xcb,
- R32G32Sint = 0xcc,
- R32G32Uint = 0xcd,
+ R32G32Float = 0xcb,
+ R32G32Sint = 0xcc,
+ R32G32Uint = 0xcd,
R16G16B16X16Float = 0xce,
- B8G8R8A8Unorm = 0xcf,
- B8G8R8A8Srgb = 0xd0,
- R10G10B10A2Unorm = 0xd1,
- R10G10B10A2Uint = 0xd2,
- R8G8B8A8Unorm = 0xd5,
- R8G8B8A8Srgb = 0xd6,
- R8G8B8X8Snorm = 0xd7,
- R8G8B8X8Sint = 0xd8,
- R8G8B8X8Uint = 0xd9,
- R16G16Unorm = 0xda,
- R16G16Snorm = 0xdb,
- R16G16Sint = 0xdc,
- R16G16Uint = 0xdd,
- R16G16Float = 0xde,
- R11G11B10Float = 0xe0,
- R32Sint = 0xe3,
- R32Uint = 0xe4,
- R32Float = 0xe5,
- B8G8R8X8Unorm = 0xe6,
- B8G8R8X8Srgb = 0xe7,
- B5G6R5Unorm = 0xe8,
- B5G5R5A1Unorm = 0xe9,
- R8G8Unorm = 0xea,
- R8G8Snorm = 0xeb,
- R8G8Sint = 0xec,
- R8G8Uint = 0xed,
- R16Unorm = 0xee,
- R16Snorm = 0xef,
- R16Sint = 0xf0,
- R16Uint = 0xf1,
- R16Float = 0xf2,
- R8Unorm = 0xf3,
- R8Snorm = 0xf4,
- R8Sint = 0xf5,
- R8Uint = 0xf6,
- B5G5R5X1Unorm = 0xf8,
- R8G8B8X8Unorm = 0xf9,
- R8G8B8X8Srgb = 0xfa
+ B8G8R8A8Unorm = 0xcf,
+ B8G8R8A8Srgb = 0xd0,
+ R10G10B10A2Unorm = 0xd1,
+ R10G10B10A2Uint = 0xd2,
+ R8G8B8A8Unorm = 0xd5,
+ R8G8B8A8Srgb = 0xd6,
+ R8G8B8X8Snorm = 0xd7,
+ R8G8B8X8Sint = 0xd8,
+ R8G8B8X8Uint = 0xd9,
+ R16G16Unorm = 0xda,
+ R16G16Snorm = 0xdb,
+ R16G16Sint = 0xdc,
+ R16G16Uint = 0xdd,
+ R16G16Float = 0xde,
+ R11G11B10Float = 0xe0,
+ R32Sint = 0xe3,
+ R32Uint = 0xe4,
+ R32Float = 0xe5,
+ B8G8R8X8Unorm = 0xe6,
+ B8G8R8X8Srgb = 0xe7,
+ B5G6R5Unorm = 0xe8,
+ B5G5R5A1Unorm = 0xe9,
+ R8G8Unorm = 0xea,
+ R8G8Snorm = 0xeb,
+ R8G8Sint = 0xec,
+ R8G8Uint = 0xed,
+ R16Unorm = 0xee,
+ R16Snorm = 0xef,
+ R16Sint = 0xf0,
+ R16Uint = 0xf1,
+ R16Float = 0xf2,
+ R8Unorm = 0xf3,
+ R8Snorm = 0xf4,
+ R8Sint = 0xf5,
+ R8Uint = 0xf6,
+ B5G5R5X1Unorm = 0xf8,
+ R8G8B8X8Unorm = 0xf9,
+ R8G8B8X8Srgb = 0xfa,
}
static class ColorFormatConverter
@@ -74,6 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return format switch
{
+#pragma warning disable IDE0055 // Disable formatting
ColorFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
ColorFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
ColorFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
@@ -127,7 +128,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
ColorFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2, 4),
ColorFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
ColorFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
- _ => FormatInfo.Default
+ _ => FormatInfo.Default,
+#pragma warning restore IDE0055
};
}
@@ -157,9 +159,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
case ColorFormat.R8G8B8X8Unorm:
case ColorFormat.R8G8B8X8Srgb:
return true;
+ default:
+ return false;
}
-
- return false;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs
index 839faac9b..b3b0c41ad 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs
@@ -5,7 +5,7 @@
///
struct GpuVa
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint High;
public uint Low;
#pragma warning restore CS0649
@@ -14,7 +14,7 @@
/// Packs the split address into a 64-bits address value.
///
/// The 64-bits address value
- public ulong Pack()
+ public readonly ulong Pack()
{
return Low | ((ulong)High << 32);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs
index 6da96bd44..5a4253734 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs
@@ -5,31 +5,31 @@
///
struct MemoryLayout
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
- public int UnpackGobBlocksInX()
+ public readonly int UnpackGobBlocksInX()
{
return 1 << (int)(Packed & 0xf);
}
- public int UnpackGobBlocksInY()
+ public readonly int UnpackGobBlocksInY()
{
return 1 << (int)((Packed >> 4) & 0xf);
}
- public int UnpackGobBlocksInZ()
+ public readonly int UnpackGobBlocksInZ()
{
return 1 << (int)((Packed >> 8) & 0xf);
}
- public bool UnpackIsLinear()
+ public readonly bool UnpackIsLinear()
{
return (Packed & 0x1000) != 0;
}
- public bool UnpackIsTarget3D()
+ public readonly bool UnpackIsTarget3D()
{
return (Packed & 0x10000) != 0;
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs
index dae631248..5abbc9235 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs
@@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
LineStripAdjacency,
TrianglesAdjacency,
TriangleStripAdjacency,
- Patches
+ Patches,
}
///
@@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
LineStripAdjacency = 11,
TrianglesAdjacency = 12,
TriangleStripAdjacency = 13,
- Patches = 14
+ Patches = 14,
}
static class PrimitiveTypeConverter
@@ -53,6 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return type switch
{
+#pragma warning disable IDE0055 // Disable formatting
PrimitiveType.Points => PrimitiveTopology.Points,
PrimitiveType.Lines => PrimitiveTopology.Lines,
PrimitiveType.LineLoop => PrimitiveTopology.LineLoop,
@@ -68,7 +69,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
PrimitiveType.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency,
PrimitiveType.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency,
PrimitiveType.Patches => PrimitiveTopology.Patches,
- _ => PrimitiveTopology.Triangles
+ _ => PrimitiveTopology.Triangles,
+#pragma warning restore IDE0055
};
}
@@ -81,6 +83,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return type switch
{
+#pragma warning disable IDE0055 // Disable formatting
PrimitiveTypeOverride.Points => PrimitiveTopology.Points,
PrimitiveTypeOverride.Lines => PrimitiveTopology.Lines,
PrimitiveTypeOverride.LineStrip => PrimitiveTopology.LineStrip,
@@ -92,8 +95,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
PrimitiveTypeOverride.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency,
PrimitiveTypeOverride.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency,
PrimitiveTypeOverride.Patches => PrimitiveTopology.Patches,
- _ => PrimitiveTopology.Triangles
+ _ => PrimitiveTopology.Triangles,
+#pragma warning restore IDE0055
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs
index 839a4d0af..22fe4a92f 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs
@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
///
enum SamplerIndex
{
- Independently = 0,
- ViaHeaderIndex = 1
+ Independently = 0,
+ ViaHeaderIndex = 1,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs
index c457dbf91..e92263df0 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs
@@ -5,14 +5,14 @@
///
struct SbDescriptor
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint AddressLow;
public uint AddressHigh;
public int Size;
public int Padding;
#pragma warning restore CS0649
- public ulong PackAddress()
+ public readonly ulong PackAddress()
{
return AddressLow | ((ulong)AddressHigh << 32);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs
index 1de1621fc..0fa073d7b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs
@@ -8,13 +8,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
///
enum ZetaFormat
{
- D32Float = 0xa,
- D16Unorm = 0x13,
+ D32Float = 0xa,
+ D16Unorm = 0x13,
D24UnormS8Uint = 0x14,
- D24Unorm = 0x15,
+ D24Unorm = 0x15,
S8UintD24Unorm = 0x16,
- S8Uint = 0x17,
- D32FloatS8Uint = 0x19
+ S8Uint = 0x17,
+ D32FloatS8Uint = 0x19,
}
static class ZetaFormatConverter
@@ -28,6 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return format switch
{
+#pragma warning disable IDE0055 // Disable formatting
ZetaFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4, 1),
ZetaFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2, 1),
ZetaFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
@@ -35,7 +36,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
ZetaFormat.S8UintD24Unorm => new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2),
ZetaFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1, 1),
ZetaFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2),
- _ => FormatInfo.Default
+ _ => FormatInfo.Default,
+#pragma warning restore IDE0055
};
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/GpuChannel.cs b/src/Ryujinx.Graphics.Gpu/GpuChannel.cs
index 43fa8484b..8fe643815 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuChannel.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuChannel.cs
@@ -125,6 +125,7 @@ namespace Ryujinx.Graphics.Gpu
///
public void Dispose()
{
+ GC.SuppressFinalize(this);
_context.DeferredActions.Enqueue(Destroy);
}
diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
index 233227b4d..a5fe8f4c1 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu
private bool _pendingSync;
private long _modifiedSequence;
- private ulong _firstTimestamp;
+ private readonly ulong _firstTimestamp;
///
/// Creates a new instance of the GPU emulation context.
@@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.Gpu
/// The current GPU timestamp
public ulong GetTimestamp()
{
- // Guest timestamp will start at 0, instead of host value.
+ // Guest timestamp will start at 0, instead of host value.
ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds) - _firstTimestamp;
if (GraphicsConfig.FastGpuTime)
@@ -406,4 +406,4 @@ namespace Ryujinx.Graphics.Gpu
Renderer.Dispose();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs
index d2f98c7f2..4dfb93381 100644
--- a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs
+++ b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs
@@ -1,5 +1,6 @@
namespace Ryujinx.Graphics.Gpu
{
+#pragma warning disable CA2211 // Non-constant fields should not be visible
///
/// General GPU and graphics configuration.
///
@@ -67,4 +68,5 @@ namespace Ryujinx.Graphics.Gpu
///
public static bool EnableTextureRecompression = false;
}
-}
\ No newline at end of file
+#pragma warning restore CA2211
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
index 2465efb0f..05782605b 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
@@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Image
private HashSet _shortCacheBuilder;
private HashSet _shortCache;
- private Dictionary _shortCacheLookup;
+ private readonly Dictionary _shortCacheLookup;
///
/// Creates a new instance of the automatic deletion cache.
@@ -295,4 +295,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return _textures.GetEnumerator();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
index 9ee649d2d..8a9f37bb0 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Gpu.Image
///
/// A default, generic RGBA8 texture format.
///
- public static FormatInfo Default { get; } = new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
+ public static FormatInfo Default { get; } = new(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
///
/// The format of the texture data.
@@ -57,16 +57,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The number of bytes occupied by a single pixel in memory of the texture data
public FormatInfo(
Format format,
- int blockWidth,
- int blockHeight,
- int bytesPerPixel,
- int components)
+ int blockWidth,
+ int blockHeight,
+ int bytesPerPixel,
+ int components)
{
- Format = format;
- BlockWidth = blockWidth;
- BlockHeight = blockHeight;
+ Format = format;
+ BlockWidth = blockWidth;
+ BlockHeight = blockHeight;
BytesPerPixel = bytesPerPixel;
- Components = components;
+ Components = components;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
index 729016104..ea5e9d002 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
@@ -1,5 +1,6 @@
using Ryujinx.Graphics.GAL;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Gpu.Image
{
@@ -8,6 +9,8 @@ namespace Ryujinx.Graphics.Gpu.Image
///
static class FormatTable
{
+#pragma warning disable IDE0055 // Disable formatting
+ [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
private enum TextureFormat : uint
{
// Formats
@@ -244,6 +247,7 @@ namespace Ryujinx.Graphics.Gpu.Image
A5B5G5R1Unorm = A5B5G5R1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24913
}
+ [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
private enum VertexAttributeFormat : uint
{
// Width
@@ -357,7 +361,7 @@ namespace Ryujinx.Graphics.Gpu.Image
A2B10G10R10Sscaled = (A2B10G10R10 << 21) | (Sscaled << 27), // 0x36000000
}
- private static readonly Dictionary _textureFormats = new Dictionary()
+ private static readonly Dictionary _textureFormats = new()
{
{ TextureFormat.R8Unorm, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) },
{ TextureFormat.R8Snorm, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) },
@@ -464,10 +468,10 @@ namespace Ryujinx.Graphics.Gpu.Image
{ TextureFormat.Astc2D10x10UnormSrgb, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) },
{ TextureFormat.Astc2D12x10UnormSrgb, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) },
{ TextureFormat.Astc2D12x12UnormSrgb, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) },
- { TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) }
+ { TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) },
};
- private static readonly Dictionary _attribFormats = new Dictionary()
+ private static readonly Dictionary _attribFormats = new()
{
{ VertexAttributeFormat.R8Unorm, Format.R8Unorm },
{ VertexAttributeFormat.R8Snorm, Format.R8Snorm },
@@ -547,8 +551,9 @@ namespace Ryujinx.Graphics.Gpu.Image
{ VertexAttributeFormat.A2B10G10R10Snorm, Format.R10G10B10A2Snorm },
{ VertexAttributeFormat.A2B10G10R10Sint, Format.R10G10B10A2Sint },
{ VertexAttributeFormat.A2B10G10R10Uscaled, Format.R10G10B10A2Uscaled },
- { VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled }
+ { VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled },
};
+#pragma warning restore IDE0055
///
/// Try getting the texture format from an encoded format integer from the Maxwell texture descriptor.
@@ -575,4 +580,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return _attribFormats.TryGetValue((VertexAttributeFormat)encoded, out format);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Pool.cs b/src/Ryujinx.Graphics.Gpu/Image/Pool.cs
index 63be151f3..0c3a219de 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Pool.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Pool.cs
@@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Image
DescriptorCache = new T2[count];
Address = address;
- Size = size;
+ Size = size;
_memoryTracking = physicalMemory.BeginGranularTracking(address, size, ResourceKind.Pool);
_memoryTracking.RegisterPreciseAction(address, size, PreciseAction);
@@ -219,4 +219,4 @@ namespace Ryujinx.Graphics.Gpu.Image
_memoryTracking.Dispose();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs b/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs
index e1493f388..d9881f897 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs
@@ -126,4 +126,4 @@ namespace Ryujinx.Graphics.Gpu.Image
_pools.Clear();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs b/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs
index 1f7d9b070..01553e50c 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs
@@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{
Average,
Minimum,
- Maximum
+ Maximum,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs b/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs
index b70ac9eb9..d6a3d975b 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs
@@ -40,16 +40,16 @@ namespace Ryujinx.Graphics.Gpu.Image
AddressMode addressP = descriptor.UnpackAddressP();
CompareMode compareMode = descriptor.UnpackCompareMode();
- CompareOp compareOp = descriptor.UnpackCompareOp();
+ CompareOp compareOp = descriptor.UnpackCompareOp();
- ColorF color = new ColorF(
+ ColorF color = new(
descriptor.BorderColorR,
descriptor.BorderColorG,
descriptor.BorderColorB,
descriptor.BorderColorA);
- float minLod = descriptor.UnpackMinLod();
- float maxLod = descriptor.UnpackMaxLod();
+ float minLod = descriptor.UnpackMinLod();
+ float maxLod = descriptor.UnpackMaxLod();
float mipLodBias = descriptor.UnpackMipLodBias();
float maxRequestedAnisotropy = descriptor.UnpackMaxAnisotropy();
@@ -112,4 +112,4 @@ namespace Ryujinx.Graphics.Gpu.Image
_anisoSampler?.Dispose();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs
index 64a146fb3..e04c31dfa 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs
@@ -43,17 +43,17 @@ namespace Ryujinx.Graphics.Gpu.Image
0.45833334f,
0.46153846f,
0.4642857f,
- 0.46666667f
+ 0.46666667f,
};
private static readonly float[] _maxAnisotropyLut = new float[]
{
- 1, 2, 4, 6, 8, 10, 12, 16
+ 1, 2, 4, 6, 8, 10, 12, 16,
};
private const float Frac8ToF32 = 1.0f / 256.0f;
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Word0;
public uint Word1;
public uint Word2;
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the X axis.
///
/// The texture wrap mode enum
- public AddressMode UnpackAddressU()
+ public readonly AddressMode UnpackAddressU()
{
return (AddressMode)(Word0 & 7);
}
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the Y axis.
///
/// The texture wrap mode enum
- public AddressMode UnpackAddressV()
+ public readonly AddressMode UnpackAddressV()
{
return (AddressMode)((Word0 >> 3) & 7);
}
@@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the Z axis.
///
/// The texture wrap mode enum
- public AddressMode UnpackAddressP()
+ public readonly AddressMode UnpackAddressP()
{
return (AddressMode)((Word0 >> 6) & 7);
}
@@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only relevant for shaders with shadow samplers.
///
/// The depth comparison mode enum
- public CompareMode UnpackCompareMode()
+ public readonly CompareMode UnpackCompareMode()
{
return (CompareMode)((Word0 >> 9) & 1);
}
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only relevant for shaders with shadow samplers.
///
/// The depth comparison operation enum
- public CompareOp UnpackCompareOp()
+ public readonly CompareOp UnpackCompareOp()
{
return (CompareOp)(((Word0 >> 10) & 7) + 1);
}
@@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks and converts the maximum anisotropy value used for texture anisotropic filtering.
///
/// The maximum anisotropy
- public float UnpackMaxAnisotropy()
+ public readonly float UnpackMaxAnisotropy()
{
return _maxAnisotropyLut[(Word0 >> 20) & 7];
}
@@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// that is larger than the texture size.
///
/// The magnification filter
- public MagFilter UnpackMagFilter()
+ public readonly MagFilter UnpackMagFilter()
{
return (MagFilter)(Word1 & 3);
}
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// that is smaller than the texture size.
///
/// The minification filter
- public MinFilter UnpackMinFilter()
+ public readonly MinFilter UnpackMinFilter()
{
SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3);
SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3);
@@ -161,24 +161,30 @@ namespace Ryujinx.Graphics.Gpu.Image
case SamplerMipFilter.None:
switch (minFilter)
{
- case SamplerMinFilter.Nearest: return MinFilter.Nearest;
- case SamplerMinFilter.Linear: return MinFilter.Linear;
+ case SamplerMinFilter.Nearest:
+ return MinFilter.Nearest;
+ case SamplerMinFilter.Linear:
+ return MinFilter.Linear;
}
break;
case SamplerMipFilter.Nearest:
switch (minFilter)
{
- case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapNearest;
- case SamplerMinFilter.Linear: return MinFilter.LinearMipmapNearest;
+ case SamplerMinFilter.Nearest:
+ return MinFilter.NearestMipmapNearest;
+ case SamplerMinFilter.Linear:
+ return MinFilter.LinearMipmapNearest;
}
break;
case SamplerMipFilter.Linear:
switch (minFilter)
{
- case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapLinear;
- case SamplerMinFilter.Linear: return MinFilter.LinearMipmapLinear;
+ case SamplerMinFilter.Nearest:
+ return MinFilter.NearestMipmapLinear;
+ case SamplerMinFilter.Linear:
+ return MinFilter.LinearMipmapLinear;
}
break;
}
@@ -190,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the seamless cubemap flag.
///
/// The seamless cubemap flag
- public bool UnpackSeamlessCubemap()
+ public readonly bool UnpackSeamlessCubemap()
{
return (Word1 & (1 << 9)) != 0;
}
@@ -200,7 +206,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This describes how the final value will be computed from neighbouring pixels.
///
/// The reduction filter
- public ReductionFilter UnpackReductionFilter()
+ public readonly ReductionFilter UnpackReductionFilter()
{
return (ReductionFilter)((Word1 >> 10) & 3);
}
@@ -211,7 +217,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// which mipmap level to use from a given texture.
///
/// The level-of-detail bias value
- public float UnpackMipLodBias()
+ public readonly float UnpackMipLodBias()
{
int fixedValue = (int)(Word1 >> 12) & 0x1fff;
@@ -224,7 +230,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the level-of-detail snap value.
///
/// The level-of-detail snap value
- public float UnpackLodSnap()
+ public readonly float UnpackLodSnap()
{
return _f5ToF32ConversionLut[(Word1 >> 26) & 0x1f];
}
@@ -233,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the minimum level-of-detail value.
///
/// The minimum level-of-detail value
- public float UnpackMinLod()
+ public readonly float UnpackMinLod()
{
return (Word2 & 0xfff) * Frac8ToF32;
}
@@ -242,7 +248,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the maximum level-of-detail value.
///
/// The maximum level-of-detail value
- public float UnpackMaxLod()
+ public readonly float UnpackMaxLod()
{
return ((Word2 >> 12) & 0xfff) * Frac8ToF32;
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs
index 17beb1293..d3009219a 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs
@@ -6,6 +6,6 @@ namespace Ryujinx.Graphics.Gpu.Image
enum SamplerMinFilter
{
Nearest = 1,
- Linear
+ Linear,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs
index 319d41960..b965f0c36 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs
@@ -7,6 +7,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{
None = 1,
Nearest,
- Linear
+ Linear,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs
index eb7222f9c..3efcad760 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs
@@ -159,4 +159,4 @@ namespace Ryujinx.Graphics.Gpu.Image
item?.Dispose();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs
index 3b3350fb5..881c37af4 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return new SamplerPool(context, channel.MemoryManager.Physical, address, maximumId);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
index a7af1aad7..c0d45cbd1 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
@@ -119,7 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Image
private bool _modifiedStale = true;
private ITexture _arrayViewTexture;
- private Target _arrayViewTarget;
+ private Target _arrayViewTarget;
private ITexture _flushHostTexture;
private ITexture _setHostTexture;
@@ -334,7 +334,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The child texture
public Texture CreateView(TextureInfo info, SizeInfo sizeInfo, MultiRange range, int firstLayer, int firstLevel)
{
- Texture texture = new Texture(
+ Texture texture = new(
_context,
_physicalMemory,
info,
@@ -523,7 +523,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (ScaleFactor != scale)
{
- Logger.Debug?.Print(LogClass.Gpu, $"Rescaling {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()} to ({ScaleFactor} to {scale}). ");
+ Logger.Debug?.Print(LogClass.Gpu, $"Rescaling {Info.Width}x{Info.Height} {Info.FormatInfo.Format} to ({ScaleFactor} to {scale}). ");
ScaleFactor = scale;
@@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Gpu.Image
foreach (var view in _views)
{
- Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()}.");
+ Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format}.");
view.ScaleFactor = scale;
TextureCreateInfo viewCreateInfo = TextureCache.GetCreateInfo(view.Info, _context.Capabilities, scale);
@@ -1254,7 +1254,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
FormatInfo formatInfo = TextureCompatibility.ToHostCompatibleFormat(Info, _context.Capabilities);
- TextureCreateInfo createInfo = new TextureCreateInfo(
+ TextureCreateInfo createInfo = new(
Info.Width,
Info.Height,
target == Target.CubemapArray ? 6 : 1,
@@ -1274,7 +1274,7 @@ namespace Ryujinx.Graphics.Gpu.Image
ITexture viewTexture = HostTexture.CreateView(createInfo, 0, 0);
_arrayViewTexture = viewTexture;
- _arrayViewTarget = target;
+ _arrayViewTarget = target;
return viewTexture;
}
@@ -1317,29 +1317,21 @@ namespace Ryujinx.Graphics.Gpu.Image
{
case Target.Texture1D:
case Target.Texture1DArray:
- return target == Target.Texture1D ||
- target == Target.Texture1DArray;
-
+ return target == Target.Texture1D || target == Target.Texture1DArray;
case Target.Texture2D:
case Target.Texture2DArray:
- return target == Target.Texture2D ||
- target == Target.Texture2DArray;
-
+ return target == Target.Texture2D || target == Target.Texture2DArray;
case Target.Cubemap:
case Target.CubemapArray:
- return target == Target.Cubemap ||
- target == Target.CubemapArray;
-
+ return target == Target.Cubemap || target == Target.CubemapArray;
case Target.Texture2DMultisample:
case Target.Texture2DMultisampleArray:
- return target == Target.Texture2DMultisample ||
- target == Target.Texture2DMultisampleArray;
-
+ return target == Target.Texture2DMultisample || target == Target.Texture2DMultisampleArray;
case Target.Texture3D:
return target == Target.Texture3D;
+ default:
+ return false;
}
-
- return false;
}
///
@@ -1398,7 +1390,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Height = info.Height;
CanForceAnisotropy = CanTextureForceAnisotropy();
- _depth = info.GetDepth();
+ _depth = info.GetDepth();
_layers = info.GetLayers();
}
@@ -1714,4 +1706,4 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
index febe508be..606842d6d 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
@@ -50,12 +50,12 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The texture's usage flags, indicating how it is used in the shader
public TextureBindingInfo(Target target, Format format, int binding, int cbufSlot, int handle, TextureUsageFlags flags)
{
- Target = target;
- Format = format;
- Binding = binding;
+ Target = target;
+ Format = format;
+ Binding = binding;
CbufSlot = cbufSlot;
- Handle = handle;
- Flags = flags;
+ Handle = handle;
+ Flags = flags;
}
///
@@ -70,4 +70,4 @@ namespace Ryujinx.Graphics.Gpu.Image
{
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
index b08fb3eb1..e5df17760 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
@@ -93,10 +93,10 @@ namespace Ryujinx.Graphics.Gpu.Image
int stages = isCompute ? 1 : Constants.ShaderStages;
_textureBindings = new TextureBindingInfo[stages][];
- _imageBindings = new TextureBindingInfo[stages][];
+ _imageBindings = new TextureBindingInfo[stages][];
_textureState = new TextureState[InitialTextureStateSize];
- _imageState = new TextureState[InitialImageStateSize];
+ _imageState = new TextureState[InitialImageStateSize];
for (int stage = 0; stage < stages; stage++)
{
@@ -418,6 +418,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
+#pragma warning disable IDE0051 // Remove unused private member
///
/// Counts the total number of texture bindings used by all shader stages.
///
@@ -426,16 +427,17 @@ namespace Ryujinx.Graphics.Gpu.Image
{
int count = 0;
- for (int i = 0; i < _textureBindings.Length; i++)
+ foreach (TextureBindingInfo[] textureInfo in _textureBindings)
{
- if (_textureBindings[i] != null)
+ if (textureInfo != null)
{
- count += _textureBindings[i].Length;
+ count += textureInfo.Length;
}
}
return count;
}
+#pragma warning restore IDE0051
///
/// Ensures that the texture bindings are visible to the host GPU.
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
index bccd3fd72..3f215a4ac 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
private const int OverlapsBufferInitialCapacity = 10;
- private const int OverlapsBufferMaxCapacity = 10000;
+ private const int OverlapsBufferMaxCapacity = 10000;
private readonly GpuContext _context;
private readonly PhysicalMemory _physicalMemory;
@@ -224,7 +224,7 @@ namespace Ryujinx.Graphics.Gpu.Image
for (int i = 0; i < overlapCount; i++)
{
var other = _textureOverlaps[i];
-
+
if (texture != other &&
(texture.IsViewCompatible(other.Info, other.Range, true, other.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible ||
other.IsViewCompatible(texture.Info, texture.Range, true, texture.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible))
@@ -278,7 +278,7 @@ namespace Ryujinx.Graphics.Gpu.Image
width = copyTexture.Width;
}
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
copyTexture.Address.Pack() + offset,
GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, copyTexture.LinearLayout),
copyTexture.Height,
@@ -371,16 +371,16 @@ namespace Ryujinx.Graphics.Gpu.Image
// so the width we get here is the aligned width.
if (isLinear)
{
- width = colorState.WidthOrStride / formatInfo.BytesPerPixel;
+ width = colorState.WidthOrStride / formatInfo.BytesPerPixel;
stride = colorState.WidthOrStride;
}
else
{
- width = colorState.WidthOrStride;
+ width = colorState.WidthOrStride;
stride = 0;
}
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
colorState.Address.Pack(),
GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, isLinear),
colorState.Height,
@@ -449,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Image
FormatInfo formatInfo = dsState.Format.Convert();
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
dsState.Address.Pack(),
GetMinimumWidthInGob(size.Width, sizeHint.Width, formatInfo.BytesPerPixel, false),
size.Height,
@@ -1136,14 +1136,14 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
- int width = info.Width / info.SamplesInX;
+ int width = info.Width / info.SamplesInX;
int height = info.Height / info.SamplesInY;
int depth = info.GetDepth() * info.GetLayers();
if (scale != 1f)
{
- width = (int)MathF.Ceiling(width * scale);
+ width = (int)MathF.Ceiling(width * scale);
height = (int)MathF.Ceiling(height * scale);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
index 9a8d048ed..eafa50b2e 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
@@ -35,7 +35,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Astc10x8,
Astc10x10,
Astc12x10,
- Astc12x12
+ Astc12x12,
}
///
@@ -629,7 +629,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
TextureMatchQuality.Perfect => TextureViewCompatibility.Full,
TextureMatchQuality.FormatAlias => TextureViewCompatibility.FormatAlias,
- _ => TextureViewCompatibility.Incompatible
+ _ => TextureViewCompatibility.Incompatible,
};
}
@@ -783,80 +783,33 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Format class
private static FormatClass GetFormatClass(Format format)
{
- switch (format)
+ return format switch
{
- case Format.Bc1RgbaSrgb:
- case Format.Bc1RgbaUnorm:
- return FormatClass.Bc1Rgba;
- case Format.Bc2Srgb:
- case Format.Bc2Unorm:
- return FormatClass.Bc2;
- case Format.Bc3Srgb:
- case Format.Bc3Unorm:
- return FormatClass.Bc3;
- case Format.Bc4Snorm:
- case Format.Bc4Unorm:
- return FormatClass.Bc4;
- case Format.Bc5Snorm:
- case Format.Bc5Unorm:
- return FormatClass.Bc5;
- case Format.Bc6HSfloat:
- case Format.Bc6HUfloat:
- return FormatClass.Bc6;
- case Format.Bc7Srgb:
- case Format.Bc7Unorm:
- return FormatClass.Bc7;
- case Format.Etc2RgbSrgb:
- case Format.Etc2RgbUnorm:
- return FormatClass.Etc2Rgb;
- case Format.Etc2RgbaSrgb:
- case Format.Etc2RgbaUnorm:
- return FormatClass.Etc2Rgba;
- case Format.Astc4x4Srgb:
- case Format.Astc4x4Unorm:
- return FormatClass.Astc4x4;
- case Format.Astc5x4Srgb:
- case Format.Astc5x4Unorm:
- return FormatClass.Astc5x4;
- case Format.Astc5x5Srgb:
- case Format.Astc5x5Unorm:
- return FormatClass.Astc5x5;
- case Format.Astc6x5Srgb:
- case Format.Astc6x5Unorm:
- return FormatClass.Astc6x5;
- case Format.Astc6x6Srgb:
- case Format.Astc6x6Unorm:
- return FormatClass.Astc6x6;
- case Format.Astc8x5Srgb:
- case Format.Astc8x5Unorm:
- return FormatClass.Astc8x5;
- case Format.Astc8x6Srgb:
- case Format.Astc8x6Unorm:
- return FormatClass.Astc8x6;
- case Format.Astc8x8Srgb:
- case Format.Astc8x8Unorm:
- return FormatClass.Astc8x8;
- case Format.Astc10x5Srgb:
- case Format.Astc10x5Unorm:
- return FormatClass.Astc10x5;
- case Format.Astc10x6Srgb:
- case Format.Astc10x6Unorm:
- return FormatClass.Astc10x6;
- case Format.Astc10x8Srgb:
- case Format.Astc10x8Unorm:
- return FormatClass.Astc10x8;
- case Format.Astc10x10Srgb:
- case Format.Astc10x10Unorm:
- return FormatClass.Astc10x10;
- case Format.Astc12x10Srgb:
- case Format.Astc12x10Unorm:
- return FormatClass.Astc12x10;
- case Format.Astc12x12Srgb:
- case Format.Astc12x12Unorm:
- return FormatClass.Astc12x12;
- }
-
- return FormatClass.Unclassified;
+ Format.Bc1RgbaSrgb or Format.Bc1RgbaUnorm => FormatClass.Bc1Rgba,
+ Format.Bc2Srgb or Format.Bc2Unorm => FormatClass.Bc2,
+ Format.Bc3Srgb or Format.Bc3Unorm => FormatClass.Bc3,
+ Format.Bc4Snorm or Format.Bc4Unorm => FormatClass.Bc4,
+ Format.Bc5Snorm or Format.Bc5Unorm => FormatClass.Bc5,
+ Format.Bc6HSfloat or Format.Bc6HUfloat => FormatClass.Bc6,
+ Format.Bc7Srgb or Format.Bc7Unorm => FormatClass.Bc7,
+ Format.Etc2RgbSrgb or Format.Etc2RgbUnorm => FormatClass.Etc2Rgb,
+ Format.Etc2RgbaSrgb or Format.Etc2RgbaUnorm => FormatClass.Etc2Rgba,
+ Format.Astc4x4Srgb or Format.Astc4x4Unorm => FormatClass.Astc4x4,
+ Format.Astc5x4Srgb or Format.Astc5x4Unorm => FormatClass.Astc5x4,
+ Format.Astc5x5Srgb or Format.Astc5x5Unorm => FormatClass.Astc5x5,
+ Format.Astc6x5Srgb or Format.Astc6x5Unorm => FormatClass.Astc6x5,
+ Format.Astc6x6Srgb or Format.Astc6x6Unorm => FormatClass.Astc6x6,
+ Format.Astc8x5Srgb or Format.Astc8x5Unorm => FormatClass.Astc8x5,
+ Format.Astc8x6Srgb or Format.Astc8x6Unorm => FormatClass.Astc8x6,
+ Format.Astc8x8Srgb or Format.Astc8x8Unorm => FormatClass.Astc8x8,
+ Format.Astc10x5Srgb or Format.Astc10x5Unorm => FormatClass.Astc10x5,
+ Format.Astc10x6Srgb or Format.Astc10x6Unorm => FormatClass.Astc10x6,
+ Format.Astc10x8Srgb or Format.Astc10x8Unorm => FormatClass.Astc10x8,
+ Format.Astc10x10Srgb or Format.Astc10x10Unorm => FormatClass.Astc10x10,
+ Format.Astc12x10Srgb or Format.Astc12x10Unorm => FormatClass.Astc12x10,
+ Format.Astc12x12Srgb or Format.Astc12x12Unorm => FormatClass.Astc12x12,
+ _ => FormatClass.Unclassified,
+ };
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs
index 359069bcf..172d11a83 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs
@@ -7,13 +7,13 @@ namespace Ryujinx.Graphics.Gpu.Image
///
enum TextureComponent
{
- Zero = 0,
- Red = 2,
+ Zero = 0,
+ Red = 2,
Green = 3,
- Blue = 4,
+ Blue = 4,
Alpha = 5,
OneSI = 6,
- OneF = 7
+ OneF = 7,
}
static class TextureComponentConverter
@@ -25,19 +25,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Converted enum
public static SwizzleComponent Convert(this TextureComponent component)
{
- switch (component)
+ return component switch
{
- case TextureComponent.Zero: return SwizzleComponent.Zero;
- case TextureComponent.Red: return SwizzleComponent.Red;
- case TextureComponent.Green: return SwizzleComponent.Green;
- case TextureComponent.Blue: return SwizzleComponent.Blue;
- case TextureComponent.Alpha: return SwizzleComponent.Alpha;
- case TextureComponent.OneSI:
- case TextureComponent.OneF:
- return SwizzleComponent.One;
- }
-
- return SwizzleComponent.Zero;
+ TextureComponent.Zero => SwizzleComponent.Zero,
+ TextureComponent.Red => SwizzleComponent.Red,
+ TextureComponent.Green => SwizzleComponent.Green,
+ TextureComponent.Blue => SwizzleComponent.Blue,
+ TextureComponent.Alpha => SwizzleComponent.Alpha,
+ TextureComponent.OneSI or TextureComponent.OneF => SwizzleComponent.One,
+ _ => SwizzleComponent.Zero,
+ };
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs
index 3e35f8d2c..c82a555ee 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image
///
struct TextureDescriptor : ITextureDescriptor, IEquatable
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Word0;
public uint Word1;
public uint Word2;
@@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks Maxwell texture format integer.
///
/// The texture format integer
- public uint UnpackFormat()
+ public readonly uint UnpackFormat()
{
return Word0 & 0x8007ffff;
}
@@ -33,43 +33,43 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the swizzle component for the texture red color channel.
///
/// The swizzle component
- public TextureComponent UnpackSwizzleR()
+ public readonly TextureComponent UnpackSwizzleR()
{
- return(TextureComponent)((Word0 >> 19) & 7);
+ return (TextureComponent)((Word0 >> 19) & 7);
}
///
/// Unpacks the swizzle component for the texture green color channel.
///
/// The swizzle component
- public TextureComponent UnpackSwizzleG()
+ public readonly TextureComponent UnpackSwizzleG()
{
- return(TextureComponent)((Word0 >> 22) & 7);
+ return (TextureComponent)((Word0 >> 22) & 7);
}
///
/// Unpacks the swizzle component for the texture blue color channel.
///
/// The swizzle component
- public TextureComponent UnpackSwizzleB()
+ public readonly TextureComponent UnpackSwizzleB()
{
- return(TextureComponent)((Word0 >> 25) & 7);
+ return (TextureComponent)((Word0 >> 25) & 7);
}
///
/// Unpacks the swizzle component for the texture alpha color channel.
///
/// The swizzle component
- public TextureComponent UnpackSwizzleA()
+ public readonly TextureComponent UnpackSwizzleA()
{
- return(TextureComponent)((Word0 >> 28) & 7);
+ return (TextureComponent)((Word0 >> 28) & 7);
}
///
/// Unpacks the 40-bits texture GPU virtual address.
///
/// The GPU virtual address
- public ulong UnpackAddress()
+ public readonly ulong UnpackAddress()
{
return Word1 | ((ulong)(Word2 & 0xffff) << 32);
}
@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This defines the texture layout, among other things.
///
/// The texture descriptor type
- public TextureDescriptorType UnpackTextureDescriptorType()
+ public readonly TextureDescriptorType UnpackTextureDescriptorType()
{
return (TextureDescriptorType)((Word2 >> 21) & 7);
}
@@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Always 32-bytes aligned.
///
/// The linear texture stride
- public int UnpackStride()
+ public readonly int UnpackStride()
{
return (int)(Word3 & 0xffff) << 5;
}
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be always 1, ignored by the GPU.
///
/// THe GOB block X size
- public int UnpackGobBlocksInX()
+ public readonly int UnpackGobBlocksInX()
{
return 1 << (int)(Word3 & 7);
}
@@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be always a power of 2, with a maximum value of 32.
///
/// THe GOB block Y size
- public int UnpackGobBlocksInY()
+ public readonly int UnpackGobBlocksInY()
{
return 1 << (int)((Word3 >> 3) & 7);
}
@@ -120,7 +120,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be 1 for any texture target other than 3D textures.
///
/// The GOB block Z size
- public int UnpackGobBlocksInZ()
+ public readonly int UnpackGobBlocksInZ()
{
return 1 << (int)((Word3 >> 6) & 7);
}
@@ -130,7 +130,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only used for sparse textures, should be 1 otherwise.
///
/// The number of GOB blocks per tile
- public int UnpackGobBlocksInTileX()
+ public readonly int UnpackGobBlocksInTileX()
{
return 1 << (int)((Word3 >> 10) & 7);
}
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the number of mipmap levels of the texture.
///
/// The number of mipmap levels
- public int UnpackLevels()
+ public readonly int UnpackLevels()
{
return (int)(Word3 >> 28) + 1;
}
@@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpack the base level texture width size.
///
/// The texture width
- public int UnpackWidth()
+ public readonly int UnpackWidth()
{
return (int)(Word4 & 0xffff) + 1;
}
@@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpack the width of a buffer texture.
///
/// The texture width
- public int UnpackBufferTextureWidth()
+ public readonly int UnpackBufferTextureWidth()
{
return (int)((Word4 & 0xffff) | (Word3 << 16)) + 1;
}
@@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture sRGB format flag.
///
/// True if the texture is sRGB, false otherwise
- public bool UnpackSrgb()
+ public readonly bool UnpackSrgb()
{
return (Word4 & (1 << 22)) != 0;
}
@@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture target.
///
/// The texture target
- public TextureTarget UnpackTextureTarget()
+ public readonly TextureTarget UnpackTextureTarget()
{
return (TextureTarget)((Word4 >> 23) & 0xf);
}
@@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Should be ignored for 1D or buffer textures.
///
/// The texture height or layers count
- public int UnpackHeight()
+ public readonly int UnpackHeight()
{
return (int)(Word5 & 0xffff) + 1;
}
@@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The meaning of this value depends on the texture target.
///
/// The texture depth, layer or faces count
- public int UnpackDepth()
+ public readonly int UnpackDepth()
{
return (int)((Word5 >> 16) & 0x3fff) + 1;
}
@@ -207,7 +207,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// It must be set to false (by the guest driver) for rectangle textures.
///
/// The texture coordinates normalized flag
- public bool UnpackTextureCoordNormalized()
+ public readonly bool UnpackTextureCoordNormalized()
{
return (Word5 & (1 << 31)) != 0;
}
@@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the base mipmap level of the texture.
///
/// The base mipmap level of the texture
- public int UnpackBaseLevel()
+ public readonly int UnpackBaseLevel()
{
return (int)(Word7 & 0xf);
}
@@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Usually equal to Levels minus 1.
///
/// The maximum mipmap level (inclusive) of the texture
- public int UnpackMaxLevelInclusive()
+ public readonly int UnpackMaxLevelInclusive()
{
return (int)((Word7 >> 4) & 0xf);
}
@@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be ignored for non-multisample textures.
///
/// The multisample counts enum
- public TextureMsaaMode UnpackTextureMsaaMode()
+ public readonly TextureMsaaMode UnpackTextureMsaaMode()
{
return (TextureMsaaMode)((Word7 >> 8) & 0xf);
}
@@ -269,5 +269,10 @@ namespace Ryujinx.Graphics.Gpu.Image
{
return Unsafe.As>(ref this).GetHashCode();
}
+
+ public override bool Equals(object obj)
+ {
+ return obj is TextureDescriptor descriptor && Equals(descriptor);
+ }
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs
index 8e7d40bbe..ad0715c58 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs
@@ -11,6 +11,6 @@ namespace Ryujinx.Graphics.Gpu.Image
LinearColorKey,
Linear,
BlockLinear,
- BlockLinearColorKey
+ BlockLinearColorKey,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
index 2fa1e79e5..1b947cd3b 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
@@ -78,11 +78,11 @@ namespace Ryujinx.Graphics.Gpu.Image
private int[] _allOffsets;
private int[] _sliceSizes;
- private bool _is3D;
+ private readonly bool _is3D;
private bool _hasMipViews;
private bool _hasLayerViews;
- private int _layers;
- private int _levels;
+ private readonly int _layers;
+ private readonly int _levels;
private MultiRange TextureRange => Storage.Range;
@@ -96,9 +96,9 @@ namespace Ryujinx.Graphics.Gpu.Image
///
/// Other texture groups that have incompatible overlaps with this one.
///
- private List _incompatibleOverlaps;
+ private readonly List _incompatibleOverlaps;
private bool _incompatibleOverlapsDirty = true;
- private bool _flushIncompatibleOverlaps;
+ private readonly bool _flushIncompatibleOverlaps;
private BufferHandle _flushBuffer;
private bool _flushBufferImported;
@@ -423,7 +423,7 @@ namespace Ryujinx.Graphics.Gpu.Image
int offsetIndex = GetOffsetIndex(info.BaseLayer + layer, info.BaseLevel + level);
int offset = _allOffsets[offsetIndex];
- ReadOnlySpan data = dataSpan.Slice(offset - spanBase);
+ ReadOnlySpan data = dataSpan[(offset - spanBase)..];
SpanOrArray result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
@@ -1500,13 +1500,13 @@ namespace Ryujinx.Graphics.Gpu.Image
{
for (int i = 0; i < _allOffsets.Length; i++)
{
- (int layer, int level) = GetLayerLevelForView(i);
+ (_, int level) = GetLayerLevelForView(i);
MultiRange handleRange = Storage.Range.Slice((ulong)_allOffsets[i], 1);
ulong handleBase = handleRange.GetSubRange(0).Address;
for (int j = 0; j < other._handles.Length; j++)
{
- (int otherLayer, int otherLevel) = other.GetLayerLevelForView(j);
+ (_, int otherLevel) = other.GetLayerLevelForView(j);
MultiRange otherHandleRange = other.Storage.Range.Slice((ulong)other._allOffsets[j], 1);
ulong otherHandleBase = otherHandleRange.GetSubRange(0).Address;
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
index da8dd849d..ef7198e88 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
@@ -22,10 +22,10 @@ namespace Ryujinx.Graphics.Gpu.Image
private const int FlushBalanceMax = 60;
private const int FlushBalanceMin = -10;
- private TextureGroup _group;
+ private readonly TextureGroup _group;
private int _bindCount;
- private int _firstLevel;
- private int _firstLayer;
+ private readonly int _firstLevel;
+ private readonly int _firstLayer;
// Sync state for texture flush.
@@ -463,8 +463,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_group.HasCopyDependencies = true;
other._group.HasCopyDependencies = true;
- TextureDependency dependency = new TextureDependency(this);
- TextureDependency otherDependency = new TextureDependency(other);
+ TextureDependency dependency = new(this);
+ TextureDependency otherDependency = new(other);
dependency.Other = otherDependency;
otherDependency.Other = dependency;
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
index 1994d2263..94d2e0bfc 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
@@ -134,45 +134,45 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Swizzle for the blue color channel
/// Swizzle for the alpha color channel
public TextureInfo(
- ulong gpuAddress,
- int width,
- int height,
- int depthOrLayers,
- int levels,
- int samplesInX,
- int samplesInY,
- int stride,
- bool isLinear,
- int gobBlocksInY,
- int gobBlocksInZ,
- int gobBlocksInTileX,
- Target target,
- FormatInfo formatInfo,
+ ulong gpuAddress,
+ int width,
+ int height,
+ int depthOrLayers,
+ int levels,
+ int samplesInX,
+ int samplesInY,
+ int stride,
+ bool isLinear,
+ int gobBlocksInY,
+ int gobBlocksInZ,
+ int gobBlocksInTileX,
+ Target target,
+ FormatInfo formatInfo,
DepthStencilMode depthStencilMode = DepthStencilMode.Depth,
- SwizzleComponent swizzleR = SwizzleComponent.Red,
- SwizzleComponent swizzleG = SwizzleComponent.Green,
- SwizzleComponent swizzleB = SwizzleComponent.Blue,
- SwizzleComponent swizzleA = SwizzleComponent.Alpha)
+ SwizzleComponent swizzleR = SwizzleComponent.Red,
+ SwizzleComponent swizzleG = SwizzleComponent.Green,
+ SwizzleComponent swizzleB = SwizzleComponent.Blue,
+ SwizzleComponent swizzleA = SwizzleComponent.Alpha)
{
- GpuAddress = gpuAddress;
- Width = width;
- Height = height;
- DepthOrLayers = depthOrLayers;
- Levels = levels;
- SamplesInX = samplesInX;
- SamplesInY = samplesInY;
- Stride = stride;
- IsLinear = isLinear;
- GobBlocksInY = gobBlocksInY;
- GobBlocksInZ = gobBlocksInZ;
+ GpuAddress = gpuAddress;
+ Width = width;
+ Height = height;
+ DepthOrLayers = depthOrLayers;
+ Levels = levels;
+ SamplesInX = samplesInX;
+ SamplesInY = samplesInY;
+ Stride = stride;
+ IsLinear = isLinear;
+ GobBlocksInY = gobBlocksInY;
+ GobBlocksInZ = gobBlocksInZ;
GobBlocksInTileX = gobBlocksInTileX;
- Target = target;
- FormatInfo = formatInfo;
+ Target = target;
+ FormatInfo = formatInfo;
DepthStencilMode = depthStencilMode;
- SwizzleR = swizzleR;
- SwizzleG = swizzleG;
- SwizzleB = swizzleB;
- SwizzleA = swizzleA;
+ SwizzleR = swizzleR;
+ SwizzleG = swizzleG;
+ SwizzleB = swizzleB;
+ SwizzleA = swizzleA;
}
///
@@ -318,17 +318,17 @@ namespace Ryujinx.Graphics.Gpu.Image
// - If the parent format is not compressed, and the view is, the view
// size is calculated as described on the first point, but the width and height
// of the view must be also multiplied by the block width and height.
- int width = Math.Max(1, parent.Info.Width >> firstLevel);
+ int width = Math.Max(1, parent.Info.Width >> firstLevel);
int height = Math.Max(1, parent.Info.Height >> firstLevel);
if (parent.Info.FormatInfo.IsCompressed && !FormatInfo.IsCompressed)
{
- width = BitUtils.DivRoundUp(width, parent.Info.FormatInfo.BlockWidth);
+ width = BitUtils.DivRoundUp(width, parent.Info.FormatInfo.BlockWidth);
height = BitUtils.DivRoundUp(height, parent.Info.FormatInfo.BlockHeight);
}
else if (!parent.Info.FormatInfo.IsCompressed && FormatInfo.IsCompressed)
{
- width *= FormatInfo.BlockWidth;
+ width *= FormatInfo.BlockWidth;
height *= FormatInfo.BlockHeight;
}
@@ -408,4 +408,4 @@ namespace Ryujinx.Graphics.Gpu.Image
SwizzleA);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
index 266f62856..63b9b47c3 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
@@ -41,8 +41,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_context = context;
_channel = channel;
- TexturePoolCache texturePoolCache = new TexturePoolCache(context);
- SamplerPoolCache samplerPoolCache = new SamplerPoolCache(context);
+ TexturePoolCache texturePoolCache = new(context);
+ SamplerPoolCache samplerPoolCache = new(context);
float[] scales = new float[64];
new Span(scales).Fill(1f);
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
///
/// The texture to check
/// True if the scale needs updating, false if the scale is up to date
- private bool ScaleNeedsUpdated(Texture texture)
+ private static bool ScaleNeedsUpdated(Texture texture)
{
return texture != null && !(texture.ScaleMode == TextureScaleMode.Blacklisted || texture.ScaleMode == TextureScaleMode.Undesired) && texture.ScaleFactor != GraphicsConfig.ResScale;
}
@@ -234,7 +234,11 @@ namespace Ryujinx.Graphics.Gpu.Image
void ConsiderTarget(Texture target)
{
- if (target == null) return;
+ if (target == null)
+ {
+ return;
+ }
+
float scale = target.ScaleFactor;
switch (target.ScaleMode)
@@ -445,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Image
///
public void UpdateRenderTargetDepthStencil()
{
- new Span(_rtHostColors).Fill(null);
+ new Span(_rtHostColors).Clear();
_rtHostDs = _rtDepthStencil?.HostTexture;
_context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, _rtHostDs);
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs
index 1351bf242..67835e954 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs
@@ -4,6 +4,6 @@
{
NoMatch,
FormatAlias,
- Perfect
+ Perfect,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs
index 0461888f1..43b83ae18 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Ms2x2 = 2,
Ms4x2 = 4,
Ms2x1 = 5,
- Ms4x4 = 6
+ Ms4x4 = 6,
}
static class TextureMsaaModeConverter
@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 4,
TextureMsaaMode.Ms4x2 => 8,
TextureMsaaMode.Ms4x4 => 16,
- _ => 1
+ _ => 1,
};
}
@@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 2,
TextureMsaaMode.Ms4x2 => 4,
TextureMsaaMode.Ms4x4 => 4,
- _ => 1
+ _ => 1,
};
}
@@ -61,8 +61,8 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 2,
TextureMsaaMode.Ms4x2 => 2,
TextureMsaaMode.Ms4x4 => 4,
- _ => 1
+ _ => 1,
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs
index bade9bbb3..0fdb6cd64 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Image
///
/// A request to dereference a texture from a pool.
///
- private struct DereferenceRequest
+ private readonly struct DereferenceRequest
{
///
/// Whether the dereference is due to a mapping change or not.
@@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
private readonly GpuChannel _channel;
- private readonly ConcurrentQueue _dereferenceQueue = new ConcurrentQueue();
+ private readonly ConcurrentQueue _dereferenceQueue = new();
private TextureDescriptor _defaultDescriptor;
///
@@ -379,10 +379,10 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The texture descriptor
/// Layer size for textures using a sub-range of mipmap levels, otherwise 0
/// The texture information
- private TextureInfo GetInfo(in TextureDescriptor descriptor, out int layerSize)
+ private static TextureInfo GetInfo(in TextureDescriptor descriptor, out int layerSize)
{
int depthOrLayers = descriptor.UnpackDepth();
- int levels = descriptor.UnpackLevels();
+ int levels = descriptor.UnpackLevels();
TextureMsaaMode msaaMode = descriptor.UnpackTextureMsaaMode();
@@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
uint format = descriptor.UnpackFormat();
- bool srgb = descriptor.UnpackSrgb();
+ bool srgb = descriptor.UnpackSrgb();
ulong gpuVa = descriptor.UnpackAddress();
@@ -451,7 +451,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// Linear textures don't support mipmaps, so we don't handle this case here.
if ((minLod != 0 || maxLod + 1 != levels) && target != Target.TextureBuffer && !isLinear)
{
- int depth = TextureInfo.GetDepth(target, depthOrLayers);
+ int depth = TextureInfo.GetDepth(target, depthOrLayers);
int layers = TextureInfo.GetLayers(target, depthOrLayers);
SizeInfo sizeInfo = SizeCalculator.GetBlockLinearTextureSize(
@@ -476,7 +476,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// address if there is a overlapping texture on the cache that can contain the new texture.
gpuVa += (ulong)sizeInfo.GetMipOffset(minLod);
- width = Math.Max(1, width >> minLod);
+ width = Math.Max(1, width >> minLod);
height = Math.Max(1, height >> minLod);
if (target == Target.Texture3D)
@@ -608,4 +608,4 @@ namespace Ryujinx.Graphics.Gpu.Image
base.Dispose();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs
index 0017f4cc5..5da2c439c 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return new TexturePool(context, channel, address, maximumId);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs
index b937f5778..5d8e14db3 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs
@@ -11,6 +11,6 @@
Eligible = 0,
Scaled = 1,
Blacklisted = 2,
- Undesired = 3
+ Undesired = 3,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs
index d7b99a173..fb2a97b0b 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs
@@ -8,11 +8,11 @@ namespace Ryujinx.Graphics.Gpu.Image
[Flags]
enum TextureSearchFlags
{
- None = 0,
- ForSampler = 1 << 1,
- ForCopy = 1 << 2,
- DepthAlias = 1 << 3,
+ None = 0,
+ ForSampler = 1 << 1,
+ ForCopy = 1 << 2,
+ DepthAlias = 1 << 3,
WithUpscale = 1 << 4,
- NoCreate = 1 << 5
+ NoCreate = 1 << 5,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
index 5e0a0721f..b46b42046 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
@@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Texture2DArray,
TextureBuffer,
Texture2DRect,
- CubemapArray
+ CubemapArray,
}
static class TextureTargetConverter
@@ -33,23 +33,34 @@ namespace Ryujinx.Graphics.Gpu.Image
{
switch (target)
{
- case TextureTarget.Texture2D: return Target.Texture2DMultisample;
- case TextureTarget.Texture2DArray: return Target.Texture2DMultisampleArray;
+ case TextureTarget.Texture2D:
+ return Target.Texture2DMultisample;
+ case TextureTarget.Texture2DArray:
+ return Target.Texture2DMultisampleArray;
}
}
else
{
switch (target)
{
- case TextureTarget.Texture1D: return Target.Texture1D;
- case TextureTarget.Texture2D: return Target.Texture2D;
- case TextureTarget.Texture2DRect: return Target.Texture2D;
- case TextureTarget.Texture3D: return Target.Texture3D;
- case TextureTarget.Texture1DArray: return Target.Texture1DArray;
- case TextureTarget.Texture2DArray: return Target.Texture2DArray;
- case TextureTarget.Cubemap: return Target.Cubemap;
- case TextureTarget.CubemapArray: return Target.CubemapArray;
- case TextureTarget.TextureBuffer: return Target.TextureBuffer;
+ case TextureTarget.Texture1D:
+ return Target.Texture1D;
+ case TextureTarget.Texture2D:
+ return Target.Texture2D;
+ case TextureTarget.Texture2DRect:
+ return Target.Texture2D;
+ case TextureTarget.Texture3D:
+ return Target.Texture3D;
+ case TextureTarget.Texture1DArray:
+ return Target.Texture1DArray;
+ case TextureTarget.Texture2DArray:
+ return Target.Texture2DArray;
+ case TextureTarget.Cubemap:
+ return Target.Cubemap;
+ case TextureTarget.CubemapArray:
+ return Target.CubemapArray;
+ case TextureTarget.TextureBuffer:
+ return Target.TextureBuffer;
}
}
@@ -65,17 +76,17 @@ namespace Ryujinx.Graphics.Gpu.Image
{
return target switch
{
- TextureTarget.Texture1D => SamplerType.Texture1D,
- TextureTarget.Texture2D => SamplerType.Texture2D,
- TextureTarget.Texture3D => SamplerType.Texture3D,
- TextureTarget.Cubemap => SamplerType.TextureCube,
+ TextureTarget.Texture1D => SamplerType.Texture1D,
+ TextureTarget.Texture2D => SamplerType.Texture2D,
+ TextureTarget.Texture3D => SamplerType.Texture3D,
+ TextureTarget.Cubemap => SamplerType.TextureCube,
TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array,
TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array,
- TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
- TextureTarget.Texture2DRect => SamplerType.Texture2D,
- TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
- _ => SamplerType.Texture2D
+ TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
+ TextureTarget.Texture2DRect => SamplerType.Texture2D,
+ TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
+ _ => SamplerType.Texture2D,
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs
index dfa688c45..3f3bfdfef 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs
@@ -10,6 +10,6 @@
LayoutIncompatible,
CopyOnly,
FormatAlias,
- Full
+ Full,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index dc5037c56..e27c14a16 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
/// Buffers which this buffer contains, and will inherit tracking handles from
public Buffer(GpuContext context, PhysicalMemory physicalMemory, ulong address, ulong size, IEnumerable 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
///
private void EnsureRangeList()
{
- if (_modifiedRanges == null)
- {
- _modifiedRanges = new BufferModifiedRangeList(_context, this, Flush);
- }
+ _modifiedRanges ??= new BufferModifiedRangeList(_context, this, Flush);
}
///
@@ -326,7 +323,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_syncActionRegistered = true;
}
- Action 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 d513b7adf..a9ea04cef 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 a5a9b75e9..99c571ba5 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
///
/// Dictionary to prune
/// List used to track entries to delete
- private void Prune(Dictionary dictionary, ref List toDelete)
+ private static void Prune(Dictionary dictionary, ref List 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 07429cfe8..4cd3710b9 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 03504b11f..160a9aff7 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 _flushAction;
+ private readonly GpuContext _context;
+ private readonly Buffer _parent;
+ private readonly Action _flushAction;
private List _sources;
private BufferMigration _migrationTarget;
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
index e763a899c..6dcc52cb6 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.
///
/// GPU virtual address where the counter will be written in memory
+ /// The new counter
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 7765e8994..c72fa50e5 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 c7a138c98..6af12de11 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.
///
/// Event with remap actions
- 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 cb95b04a8..d0b4478e1 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;
///
@@ -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 4ceb6bcf4..1585328f0 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 55d697b81..5d2ada566 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 8f0891251..ac334881d 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
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs
index 22b08dd5a..2381991dd 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs
@@ -35,4 +35,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
Cb1Data = cb1Data;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs
index a67182112..0119a6a33 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs
@@ -50,8 +50,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
out byte[] cachedGuestCode)
{
program = null;
- ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(channel.MemoryManager, gpuVa);
+ ShaderCodeAccessor codeAccessor = new(channel.MemoryManager, gpuVa);
bool hasSpecList = _cache.TryFindItem(codeAccessor, out var specList, out cachedGuestCode);
+
return hasSpecList && specList.TryFindForCompute(channel, poolState, computeState, out program);
}
@@ -67,4 +68,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
index 568fe9683..e0f17ba9c 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
/// Operation to add a shader to the cache.
///
- AddShader
+ AddShader,
}
///
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
index 50e37033e..b08c44d67 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
@@ -29,12 +29,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
/// Type of the data
/// Data read
- public void Read(ref T data) where T : unmanaged
+ public readonly void Read(ref T data) where T : unmanaged
{
Span buffer = MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref data, 1));
for (int offset = 0; offset < buffer.Length;)
{
- offset += _activeStream.Read(buffer.Slice(offset));
+ offset += _activeStream.Read(buffer[offset..]);
}
}
@@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Type of the data
/// Data read
/// True if the read was successful, false otherwise
- public bool TryRead(ref T data) where T : unmanaged
+ public readonly bool TryRead(ref T data) where T : unmanaged
{
// Length is unknown on compressed streams.
if (_activeStream == _stream)
@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Type of the data
/// Data read
/// Expected magic value, for validation
- public void ReadWithMagicAndSize(ref T data, uint magic) where T : unmanaged
+ public readonly void ReadWithMagicAndSize(ref T data, uint magic) where T : unmanaged
{
uint actualMagic = 0;
int size = 0;
@@ -84,10 +84,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedInvalidLength);
}
- Span buffer = MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref data, 1)).Slice(0, size);
+ Span buffer = MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref data, 1))[..size];
for (int offset = 0; offset < buffer.Length;)
{
- offset += _activeStream.Read(buffer.Slice(offset));
+ offset += _activeStream.Read(buffer[offset..]);
}
}
@@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
/// Type of the data
/// Data to be written
- public void Write(ref T data) where T : unmanaged
+ public readonly void Write(ref T data) where T : unmanaged
{
Span buffer = MemoryMarshal.Cast(MemoryMarshal.CreateSpan(ref data, 1));
_activeStream.Write(buffer);
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Type of the data
/// Data to write
/// Magic value to write
- public void WriteWithMagicAndSize(ref T data, uint magic) where T : unmanaged
+ public readonly void WriteWithMagicAndSize(ref T data, uint magic) where T : unmanaged
{
int size = Unsafe.SizeOf();
Write(ref magic);
@@ -183,7 +183,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
stream = new DeflateStream(stream, CompressionMode.Decompress, true);
for (int offset = 0; offset < data.Length;)
{
- offset += stream.Read(data.Slice(offset));
+ offset += stream.Read(data[offset..]);
}
stream.Dispose();
break;
@@ -213,4 +213,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
index a46e1ef76..96ddbb513 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
@@ -13,6 +13,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
/// Deflate compression (RFC 1951).
///
- Deflate
+ Deflate,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
index c8a9f7ff2..c4ce0b870 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
@@ -54,4 +54,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return CompressionAlgorithm.Deflate;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
index 537cead0e..7f01aca63 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
@@ -19,7 +19,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private readonly ShaderSpecializationState _newSpecState;
private readonly int _stageIndex;
private readonly bool _isVulkan;
- private readonly ResourceCounts _resourceCounts;
///
/// Creates a new instance of the cached GPU state accessor for shader translation.
@@ -45,7 +44,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_newSpecState = newSpecState;
_stageIndex = stageIndex;
_isVulkan = context.Capabilities.Api == TargetApi.Vulkan;
- _resourceCounts = counts;
}
///
@@ -56,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.InvalidCb1DataLength);
}
- return MemoryMarshal.Cast(_cb1Data.Span.Slice(offset))[0];
+ return MemoryMarshal.Cast(_cb1Data.Span[offset..])[0];
}
///
@@ -68,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
public ReadOnlySpan GetCode(ulong address, int minimumSize)
{
- return MemoryMarshal.Cast(_data.Span.Slice((int)address));
+ return MemoryMarshal.Cast(_data.Span[(int)address..]);
}
///
@@ -94,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
CompareOp.Greater or CompareOp.GreaterGl => AlphaTestOp.Greater,
CompareOp.NotEqual or CompareOp.NotEqualGl => AlphaTestOp.NotEqual,
CompareOp.GreaterOrEqual or CompareOp.GreaterOrEqualGl => AlphaTestOp.GreaterOrEqual,
- _ => AlphaTestOp.Always
+ _ => AlphaTestOp.Always,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
index 01034b495..59d2cfb3f 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
@@ -205,10 +205,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (guestCode == null || cb1Data == null)
{
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
tocFileStream.Seek(Unsafe.SizeOf() + index * Unsafe.SizeOf(), SeekOrigin.Begin);
- TocEntry entry = new TocEntry();
+ TocEntry entry = new();
tocReader.Read(ref entry);
guestCode = new byte[entry.CodeSize];
@@ -261,7 +261,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true);
using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
LoadOrCreateToc(tocFileStream, ref header);
@@ -299,7 +299,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Set to the TOC file header
private void LoadOrCreateToc(Stream tocFileStream, ref TocHeader header)
{
- BinarySerializer reader = new BinarySerializer(tocFileStream);
+ BinarySerializer reader = new(tocFileStream);
if (!reader.TryRead(ref header) || header.Magic != TocMagic || header.Version != VersionPacked)
{
@@ -322,9 +322,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
/// Guest TOC file stream
/// Set to the TOC header
- private void CreateToc(Stream tocFileStream, ref TocHeader header)
+ private static void CreateToc(Stream tocFileStream, ref TocHeader header)
{
- BinarySerializer writer = new BinarySerializer(tocFileStream);
+ BinarySerializer writer = new(tocFileStream);
header.Magic = TocMagic;
header.Version = VersionPacked;
@@ -352,7 +352,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
_toc = new Dictionary>();
- TocEntry entry = new TocEntry();
+ TocEntry entry = new();
int index = 0;
while (tocFileStream.Position < tocFileStream.Length)
@@ -386,7 +386,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
ReadOnlySpan cb1Data,
uint hash)
{
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
dataFileStream.Seek(0, SeekOrigin.End);
uint dataOffset = checked((uint)dataFileStream.Position);
@@ -399,12 +399,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream.Seek(0, SeekOrigin.Begin);
tocWriter.Write(ref header);
- TocEntry entry = new TocEntry()
+ TocEntry entry = new()
{
Offset = dataOffset,
CodeSize = codeSize,
Cb1DataSize = cb1DataSize,
- Hash = hash
+ Hash = hash,
};
tocFileStream.Seek(0, SeekOrigin.End);
@@ -456,4 +456,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return (uint)XXHash128.ComputeHash(data).Low;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
index 267112865..95a0a6bdd 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
@@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
int indexOfSpace = fileName.IndexOf(' ');
if (indexOfSpace >= 0)
{
- fileName = fileName.Substring(0, indexOfSpace);
+ fileName = fileName[..indexOfSpace];
}
return string.Concat(fileName.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
@@ -287,10 +287,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
using var guestTocFileStream = _guestStorage.OpenTocFileStream();
using var guestDataFileStream = _guestStorage.OpenDataFileStream();
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
- BinarySerializer dataReader = new BinarySerializer(dataFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
+ BinarySerializer dataReader = new(dataFileStream);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
if (!tocReader.TryRead(ref header) || header.Magic != TocsMagic)
{
@@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
int programIndex = 0;
- DataEntry entry = new DataEntry();
+ DataEntry entry = new();
while (tocFileStream.Position < tocFileStream.Length && loader.Active)
{
@@ -337,7 +337,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
GuestCodeAndCbData?[] guestShaders = new GuestCodeAndCbData?[isCompute ? 1 : Constants.ShaderStages + 1];
- DataEntryPerStage stageEntry = new DataEntryPerStage();
+ DataEntryPerStage stageEntry = new();
while (stagesBitMask != 0)
{
@@ -389,7 +389,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
hostProgram = context.Renderer.LoadProgramBinary(hostCode, hasFragmentShader, shaderInfo);
}
- CachedShaderProgram program = new CachedShaderProgram(hostProgram, specState, shaders);
+ CachedShaderProgram program = new(hostProgram, specState, shaders);
loader.QueueHostProgram(program, hostCode, programIndex, isCompute);
}
@@ -448,9 +448,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: false);
dataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: false);
- BinarySerializer tempTocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tempTocReader = new(tocFileStream);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
tempTocReader.Read(ref header);
@@ -473,9 +473,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream.Seek(offset, SeekOrigin.Begin);
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
- OffsetAndSize offsetAndSize = new OffsetAndSize();
+ OffsetAndSize offsetAndSize = new();
tocReader.Read(ref offsetAndSize);
if (offsetAndSize.Offset >= (ulong)dataFileStream.Length)
@@ -490,7 +490,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
BinarySerializer.ReadCompressed(dataFileStream, hostCode);
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
- BinarySerializer dataReader = new BinarySerializer(dataFileStream);
+ BinarySerializer dataReader = new(dataFileStream);
dataFileStream.Seek((long)(offsetAndSize.Offset + offsetAndSize.CompressedSize), SeekOrigin.Begin);
@@ -559,27 +559,28 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (tocFileStream.Length == 0)
{
- TocHeader header = new TocHeader();
+ TocHeader header = new();
CreateToc(tocFileStream, ref header, TocsMagic, CodeGenVersion, timestamp);
}
tocFileStream.Seek(0, SeekOrigin.End);
dataFileStream.Seek(0, SeekOrigin.End);
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
- BinarySerializer dataWriter = new BinarySerializer(dataFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
+ BinarySerializer dataWriter = new(dataFileStream);
ulong dataOffset = (ulong)dataFileStream.Position;
tocWriter.Write(ref dataOffset);
- DataEntry entry = new DataEntry();
-
- entry.StagesBitMask = stagesBitMask;
+ DataEntry entry = new()
+ {
+ StagesBitMask = stagesBitMask,
+ };
dataWriter.BeginCompression(DiskCacheCommon.GetCompressionAlgorithm());
dataWriter.Write(ref entry);
- DataEntryPerStage stageEntry = new DataEntryPerStage();
+ DataEntryPerStage stageEntry = new();
for (int index = 0; index < program.Shaders.Length; index++)
{
@@ -665,19 +666,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (tocFileStream.Length == 0)
{
- TocHeader header = new TocHeader();
+ TocHeader header = new();
CreateToc(tocFileStream, ref header, TochMagic, 0, timestamp);
}
tocFileStream.Seek(0, SeekOrigin.End);
dataFileStream.Seek(0, SeekOrigin.End);
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
- BinarySerializer dataWriter = new BinarySerializer(dataFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
+ BinarySerializer dataWriter = new(dataFileStream);
- OffsetAndSize offsetAndSize = new OffsetAndSize();
- offsetAndSize.Offset = (ulong)dataFileStream.Position;
- offsetAndSize.UncompressedSize = (uint)hostCode.Length;
+ OffsetAndSize offsetAndSize = new()
+ {
+ Offset = (ulong)dataFileStream.Position,
+ UncompressedSize = (uint)hostCode.Length,
+ };
long dataStartPosition = dataFileStream.Position;
@@ -714,9 +717,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Magic value to be written
/// Shader codegen version, only valid for the host file
/// File creation timestamp
- private void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
+ private static void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
{
- BinarySerializer writer = new BinarySerializer(tocFileStream);
+ BinarySerializer writer = new(tocFileStream);
header.Magic = magic;
header.FormatVersion = FileFormatVersionPacked;
@@ -741,7 +744,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Shader program info
private static ShaderProgramInfo ReadShaderProgramInfo(ref BinarySerializer dataReader)
{
- DataShaderInfo dataInfo = new DataShaderInfo();
+ DataShaderInfo dataInfo = new();
dataReader.ReadWithMagicAndSize(ref dataInfo, ShdiMagic);
@@ -797,18 +800,19 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return;
}
- DataShaderInfo dataInfo = new DataShaderInfo();
-
- dataInfo.CBuffersCount = (ushort)info.CBuffers.Count;
- dataInfo.SBuffersCount = (ushort)info.SBuffers.Count;
- dataInfo.TexturesCount = (ushort)info.Textures.Count;
- dataInfo.ImagesCount = (ushort)info.Images.Count;
- dataInfo.Stage = info.Stage;
- dataInfo.UsesInstanceId = info.UsesInstanceId;
- dataInfo.UsesDrawParameters = info.UsesDrawParameters;
- dataInfo.UsesRtLayer = info.UsesRtLayer;
- dataInfo.ClipDistancesWritten = info.ClipDistancesWritten;
- dataInfo.FragmentOutputMap = info.FragmentOutputMap;
+ DataShaderInfo dataInfo = new()
+ {
+ CBuffersCount = (ushort)info.CBuffers.Count,
+ SBuffersCount = (ushort)info.SBuffers.Count,
+ TexturesCount = (ushort)info.Textures.Count,
+ ImagesCount = (ushort)info.Images.Count,
+ Stage = info.Stage,
+ UsesInstanceId = info.UsesInstanceId,
+ UsesDrawParameters = info.UsesDrawParameters,
+ UsesRtLayer = info.UsesRtLayer,
+ ClipDistancesWritten = info.ClipDistancesWritten,
+ FragmentOutputMap = info.FragmentOutputMap,
+ };
dataWriter.WriteWithMagicAndSize(ref dataInfo, ShdiMagic);
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
index d6e23302c..9320638ca 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
@@ -45,4 +45,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
Result = result;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
index b3ffa4a73..ba23f70ee 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
///
/// File might be valid, but is incompatible with the current emulator version.
///
- IncompatibleVersion
+ IncompatibleVersion,
}
static class DiskCacheLoadResultExtensions
@@ -65,8 +65,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
DiskCacheLoadResult.FileCorruptedInvalidMagic => "Magic check failed, the cache file is corrupted.",
DiskCacheLoadResult.FileCorruptedInvalidLength => "Length check failed, the cache file is corrupted.",
DiskCacheLoadResult.IncompatibleVersion => "The version of the disk cache is not compatible with this version of the emulator.",
- _ => "Unknown error."
+ _ => "Unknown error.",
};
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
index 959d6e184..f412c62e2 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
@@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
Cb1Data = cb1Data;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
index 8df89824b..8c2108bfa 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
@@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private readonly BlockingCollection _asyncTranslationQueue;
private readonly SortedList _programList;
- private int _backendParallelCompileThreads;
+ private readonly int _backendParallelCompileThreads;
private int _compiledCount;
private int _totalCount;
@@ -201,22 +201,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Graphics shader cache
/// Compute shader cache
/// Disk cache host storage
- /// Cancellation token
/// Function to be called when there is a state change, reporting state, compiled and total shaders count
- public ParallelDiskCacheLoader(
- GpuContext context,
+ /// Cancellation token
+ public ParallelDiskCacheLoader(GpuContext context,
ShaderCacheHashTable graphicsCache,
ComputeShaderCacheHashTable computeCache,
DiskCacheHostStorage hostStorage,
- CancellationToken cancellationToken,
- Action stateChangeCallback)
+ Action stateChangeCallback,
+ CancellationToken cancellationToken)
{
_context = context;
_graphicsCache = graphicsCache;
_computeCache = computeCache;
_hostStorage = hostStorage;
- _cancellationToken = cancellationToken;
_stateChangeCallback = stateChangeCallback;
+ _cancellationToken = cancellationToken;
_validationQueue = new Queue();
_compilationQueue = new ConcurrentQueue();
_asyncTranslationQueue = new BlockingCollection(ThreadCount);
@@ -235,7 +234,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
workThreads[index] = new Thread(ProcessAsyncQueue)
{
- Name = $"GPU.AsyncTranslationThread.{index}"
+ Name = $"GPU.AsyncTranslationThread.{index}",
};
}
@@ -367,7 +366,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
try
{
- AsyncProgramTranslation asyncTranslation = new AsyncProgramTranslation(guestShaders, specState, programIndex, isCompute);
+ AsyncProgramTranslation asyncTranslation = new(guestShaders, specState, programIndex, isCompute);
_asyncTranslationQueue.Add(asyncTranslation, _cancellationToken);
}
catch (OperationCanceledException)
@@ -491,7 +490,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
ShaderSource[] shaderSources = new ShaderSource[compilation.TranslatedStages.Length];
- ShaderInfoBuilder shaderInfoBuilder = new ShaderInfoBuilder(_context, compilation.SpecializationState.TransformFeedbackDescriptors != null);
+ ShaderInfoBuilder shaderInfoBuilder = new(_context, compilation.SpecializationState.TransformFeedbackDescriptors != null);
for (int index = 0; index < compilation.TranslatedStages.Length; index++)
{
@@ -502,7 +501,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
ShaderInfo shaderInfo = shaderInfoBuilder.Build(compilation.SpecializationState.PipelineState, fromCache: true);
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources, shaderInfo);
- CachedShaderProgram program = new CachedShaderProgram(hostProgram, compilation.SpecializationState, compilation.Shaders);
+ CachedShaderProgram program = new(hostProgram, compilation.SpecializationState, compilation.Shaders);
// Vulkan's binary code is the SPIR-V used for compilation, so it is ready immediately. Other APIs get this after compilation.
byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(shaderSources) : null;
@@ -589,12 +588,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// Program index
private void RecompileGraphicsFromGuestCode(GuestCodeAndCbData?[] guestShaders, ShaderSpecializationState specState, int programIndex)
{
- ShaderSpecializationState newSpecState = new ShaderSpecializationState(
+ ShaderSpecializationState newSpecState = new(
ref specState.GraphicsState,
specState.PipelineState,
specState.TransformFeedbackDescriptors);
- ResourceCounts counts = new ResourceCounts();
+ ResourceCounts counts = new();
TranslatorContext[] translatorContexts = new TranslatorContext[Constants.ShaderStages + 1];
TranslatorContext nextStage = null;
@@ -610,7 +609,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
byte[] guestCode = shader.Code;
byte[] cb1Data = shader.Cb1Data;
- DiskCacheGpuAccessor gpuAccessor = new DiskCacheGpuAccessor(_context, guestCode, cb1Data, specState, newSpecState, counts, stageIndex);
+ DiskCacheGpuAccessor gpuAccessor = new(_context, guestCode, cb1Data, specState, newSpecState, counts, stageIndex);
TranslatorContext currentStage = DecodeGraphicsShader(gpuAccessor, api, DefaultFlags, 0);
if (nextStage != null)
@@ -623,7 +622,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
byte[] guestCodeA = guestShaders[0].Value.Code;
byte[] cb1DataA = guestShaders[0].Value.Cb1Data;
- DiskCacheGpuAccessor gpuAccessorA = new DiskCacheGpuAccessor(_context, guestCodeA, cb1DataA, specState, newSpecState, counts, 0);
+ DiskCacheGpuAccessor gpuAccessorA = new(_context, guestCodeA, cb1DataA, specState, newSpecState, counts, 0);
translatorContexts[0] = DecodeGraphicsShader(gpuAccessorA, api, DefaultFlags | TranslationFlags.VertexA, 0);
}
@@ -638,7 +637,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
}
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
- List translatedStages = new List();
+ List translatedStages = new();
TranslatorContext previousStage = null;
@@ -699,9 +698,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private void RecompileComputeFromGuestCode(GuestCodeAndCbData?[] guestShaders, ShaderSpecializationState specState, int programIndex)
{
GuestCodeAndCbData shader = guestShaders[0].Value;
- ResourceCounts counts = new ResourceCounts();
- ShaderSpecializationState newSpecState = new ShaderSpecializationState(ref specState.ComputeState);
- DiskCacheGpuAccessor gpuAccessor = new DiskCacheGpuAccessor(_context, shader.Code, shader.Cb1Data, specState, newSpecState, counts, 0);
+ ResourceCounts counts = new();
+ ShaderSpecializationState newSpecState = new(ref specState.ComputeState);
+ DiskCacheGpuAccessor gpuAccessor = new(_context, shader.Code, shader.Cb1Data, specState, newSpecState, counts, 0);
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, 0);
@@ -721,4 +720,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_stateChangeCallback(ShaderCacheState.Loading, ++_compiledCount, _totalCount);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
index 2dc5c9719..a18b5780e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
@@ -3,7 +3,6 @@ using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Shader.Translation;
-using System;
using System.Collections.Generic;
using System.IO;
@@ -29,10 +28,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
public static ShaderSource[] Unpack(CachedShaderStage[] stages, byte[] code)
{
- using MemoryStream input = new MemoryStream(code);
- using BinaryReader reader = new BinaryReader(input);
+ using MemoryStream input = new(code);
+ using BinaryReader reader = new(input);
- List output = new List();
+ List output = new();
int count = reader.ReadInt32();
@@ -48,4 +47,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return output.ToArray();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
index 5e18e61f2..ca9c883e3 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
CompareOp.Greater or CompareOp.GreaterGl => AlphaTestOp.Greater,
CompareOp.NotEqual or CompareOp.NotEqualGl => AlphaTestOp.NotEqual,
CompareOp.GreaterOrEqual or CompareOp.GreaterOrEqualGl => AlphaTestOp.GreaterOrEqual,
- _ => AlphaTestOp.Always
+ _ => AlphaTestOp.Always,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
index 2dd7c631c..07b7ddc28 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
@@ -4,7 +4,6 @@ using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Shader.Translation;
-using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
@@ -125,7 +124,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
3 => 2, // Geometry
1 => 3, // Tessellation control
2 => 4, // Tessellation evaluation
- _ => 0 // Vertex/Compute
+ _ => 0, // Vertex/Compute
};
}
@@ -188,6 +187,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
return formatInfo.Format switch
{
+#pragma warning disable IDE0055 // Disable formatting
Format.R8Unorm => TextureFormat.R8Unorm,
Format.R8Snorm => TextureFormat.R8Snorm,
Format.R8Uint => TextureFormat.R8Uint,
@@ -228,7 +228,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
Format.R10G10B10A2Unorm => TextureFormat.R10G10B10A2Unorm,
Format.R10G10B10A2Uint => TextureFormat.R10G10B10A2Uint,
Format.R11G11B10Float => TextureFormat.R11G11B10Float,
- _ => TextureFormat.Unknown
+ _ => TextureFormat.Unknown,
+#pragma warning restore IDE0055
};
}
@@ -256,7 +257,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
PrimitiveTopology.Patches => tessellationMode.UnpackPatchType() == TessPatchType.Isolines
? InputTopology.Lines
: InputTopology.Triangles,
- _ => InputTopology.Points
+ _ => InputTopology.Points,
};
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
index 0e8e979c8..cfc4a2ccc 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
@@ -58,4 +58,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
ResourceCounts = new ResourceCounts();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
index b65dd75e3..d8cdbc348 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
@@ -62,4 +62,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
HasUnalignedStorageBuffer = hasUnalignedStorageBuffer;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs
index 5247a096f..544e689ab 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs
@@ -155,4 +155,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
DualSourceBlendEnable = dualSourceBlendEnable;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
index 1e34c5ded..ddb45152e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
@@ -2,6 +2,7 @@ using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
+#pragma warning disable CS0659 // Class overrides Object.Equals(object o) but does not override Object.GetHashCode()
///
/// State used by the .
///
@@ -46,5 +47,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
TexturePoolMaximumId == other.TexturePoolMaximumId &&
TextureBufferIndex == other.TextureBufferIndex;
}
+
+ public override bool Equals(object obj)
+ {
+ return obj is GpuChannelPoolState state && Equals(state);
+ }
}
-}
\ No newline at end of file
+#pragma warning restore CS0659
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs
index 584eefdc6..836b8663a 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs
@@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// Hash of the given data
public static uint CalcHash(ReadOnlySpan data)
{
- HashState state = new HashState();
+ HashState state = new();
state.Initialize();
state.Continue(data);
@@ -50,7 +50,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
{
ulong h = _hash;
- ReadOnlySpan dataAsUlong = MemoryMarshal.Cast(data.Slice(_start));
+ ReadOnlySpan dataAsUlong = MemoryMarshal.Cast(data[_start..]);
for (int i = 0; i < dataAsUlong.Length; i++)
{
@@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
///
/// Data to be hashed
/// Hash of all the data hashed with this
- public uint Finalize(ReadOnlySpan data)
+ public readonly uint Finalize(ReadOnlySpan data)
{
ulong h = _hash;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs
index d7cb3d99e..c8c8dfcb3 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// Partial entries have no items associated with them. They just indicates that the data might be present on
/// the table, and one must keep looking for the full entry on other tables of larger data size.
///
- public bool IsPartial => OwnSize != 0;
+ public readonly bool IsPartial => OwnSize != 0;
///
/// Creates a new partial hash table entry.
@@ -82,11 +82,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// Gets the data for this entry, either full or partial.
///
/// Data sub-region
- public ReadOnlySpan GetData()
+ public readonly ReadOnlySpan GetData()
{
if (OwnSize != 0)
{
- return new ReadOnlySpan(Data).Slice(0, OwnSize);
+ return new ReadOnlySpan(Data)[..OwnSize];
}
return Data;
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
return existingItem;
}
- Entry entry = new Entry(dataHash, data, item);
+ Entry entry = new(dataHash, data, item);
AddToBucket(dataHash, ref entry);
@@ -160,7 +160,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
return false;
}
- Entry entry = new Entry(dataHash, data, item);
+ Entry entry = new(dataHash, data, item);
AddToBucket(dataHash, ref entry);
@@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// True if added, false otherwise
public bool AddPartial(byte[] ownerData, int ownSize)
{
- ReadOnlySpan data = new ReadOnlySpan(ownerData).Slice(0, ownSize);
+ ReadOnlySpan data = new ReadOnlySpan(ownerData)[..ownSize];
return AddPartial(ownerData, HashState.CalcHash(data), ownSize);
}
@@ -189,14 +189,14 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// True if added, false otherwise
public bool AddPartial(byte[] ownerData, uint dataHash, int ownSize)
{
- ReadOnlySpan data = new ReadOnlySpan(ownerData).Slice(0, ownSize);
+ ReadOnlySpan data = new ReadOnlySpan(ownerData)[..ownSize];
if (TryFindItem(dataHash, data, out _))
{
return false;
}
- Entry entry = new Entry(dataHash, ownerData, ownSize);
+ Entry entry = new(dataHash, ownerData, ownSize);
AddToBucket(dataHash, ref entry);
@@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
///
/// Bucket to add the entry into
/// Entry to be added
- private void AddToBucket(ref Bucket bucket, ref Entry entry)
+ private static void AddToBucket(ref Bucket bucket, ref Entry entry)
{
if (bucket.InlineEntry.Data == null)
{
@@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
///
/// A full entry was found, the search was concluded and the item can be retrieved.
///
- FoundFull
+ FoundFull,
}
///
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
index e9a4f6549..341d3114f 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
@@ -149,12 +149,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
}
}
- HashState hashState = new HashState();
+ HashState hashState = new();
hashState.Initialize();
for (int i = 0; i < index; i++)
{
- ReadOnlySpan dataSlice = new ReadOnlySpan(data).Slice(0, _sizeTable[i].Size);
+ ReadOnlySpan dataSlice = new ReadOnlySpan(data)[.._sizeTable[i].Size];
hashState.Continue(dataSlice);
_sizeTable[i].AddPartial(data, hashState.Finalize(dataSlice));
}
@@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// True if the item was found on the table, false otherwise
public bool TryFindItem(IDataAccessor dataAccessor, out T item, out byte[] data)
{
- SmartDataAccessor sda = new SmartDataAccessor(dataAccessor);
+ SmartDataAccessor sda = new(dataAccessor);
item = default;
data = null;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs
index 0632add6c..17853e90a 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
}
else if (_data.Length > length)
{
- return _data.Slice(0, length);
+ return _data[..length];
}
return _data;
@@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
///
/// Data to be hashed
/// Hash of the data
- private uint CalcHashCached(ReadOnlySpan data)
+ private readonly uint CalcHashCached(ReadOnlySpan data)
{
HashState state = default;
bool found = false;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs b/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs
index f495229ff..126e3249c 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs
@@ -25,4 +25,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
///
public int ImagesCount;
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs
index 651dfd263..32d92223f 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
///
struct ShaderAddresses : IEquatable
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ulong VertexA;
public ulong VertexB;
public ulong TessControl;
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
///
/// Shader addresses structure to compare with
/// True if they are equal, false otherwise
- public override bool Equals(object other)
+ public readonly override bool Equals(object other)
{
return other is ShaderAddresses addresses && Equals(addresses);
}
@@ -33,21 +33,21 @@ namespace Ryujinx.Graphics.Gpu.Shader
///
/// Shader addresses structure to compare with
/// True if they are equal, false otherwise
- public bool Equals(ShaderAddresses other)
+ public readonly bool Equals(ShaderAddresses other)
{
- return VertexA == other.VertexA &&
- VertexB == other.VertexB &&
- TessControl == other.TessControl &&
+ return VertexA == other.VertexA &&
+ VertexB == other.VertexB &&
+ TessControl == other.TessControl &&
TessEvaluation == other.TessEvaluation &&
- Geometry == other.Geometry &&
- Fragment == other.Fragment;
+ Geometry == other.Geometry &&
+ Fragment == other.Fragment;
}
///
/// Computes hash code from the addresses.
///
/// Hash code
- public override int GetHashCode()
+ public readonly override int GetHashCode()
{
return HashCode.Combine(VertexA, VertexB, TessControl, TessEvaluation, Geometry, Fragment);
}
@@ -61,4 +61,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return MemoryMarshal.CreateSpan(ref VertexA, Unsafe.SizeOf() / sizeof(ulong));
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 913f6e9ec..97d7a7206 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -11,7 +11,6 @@ using Ryujinx.Graphics.Shader.Translation;
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Shader
@@ -73,7 +72,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
- private Queue _programsToSaveQueue;
+ private readonly Queue _programsToSaveQueue;
private readonly ComputeShaderCacheHashTable _computeShaderCache;
private readonly ShaderCacheHashTable _graphicsShaderCache;
@@ -157,13 +156,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
if (_diskCacheHostStorage.CacheEnabled)
{
- ParallelDiskCacheLoader loader = new ParallelDiskCacheLoader(
+ ParallelDiskCacheLoader loader = new(
_context,
_graphicsShaderCache,
_computeShaderCache,
_diskCacheHostStorage,
- cancellationToken,
- ShaderCacheStateUpdate);
+ ShaderCacheStateUpdate, cancellationToken);
loader.LoadShaders();
@@ -214,9 +212,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
return cpShader;
}
- ShaderSpecializationState specState = new ShaderSpecializationState(ref computeState);
- GpuAccessorState gpuAccessorState = new GpuAccessorState(poolState, computeState, default, specState);
- GpuAccessor gpuAccessor = new GpuAccessor(_context, channel, gpuAccessorState);
+ ShaderSpecializationState specState = new(ref computeState);
+ GpuAccessorState gpuAccessorState = new(poolState, computeState, default, specState);
+ GpuAccessor gpuAccessor = new(_context, channel, gpuAccessorState);
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, gpuVa);
TranslatedShader translatedShader = TranslateShader(_dumper, channel, translatorContext, cachedGuestCode);
@@ -241,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Shader pipeline state to be updated
/// Current graphics state
/// Current GPU channel
- private void UpdatePipelineInfo(
+ private static void UpdatePipelineInfo(
ref ThreedClassState state,
ref ProgramPipelineState pipeline,
GpuChannelGraphicsState graphicsState,
@@ -318,8 +316,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
UpdatePipelineInfo(ref state, ref pipeline, graphicsState, channel);
- ShaderSpecializationState specState = new ShaderSpecializationState(ref graphicsState, ref pipeline, transformFeedbackDescriptors);
- GpuAccessorState gpuAccessorState = new GpuAccessorState(poolState, default, graphicsState, specState, transformFeedbackDescriptors);
+ ShaderSpecializationState specState = new(ref graphicsState, ref pipeline, transformFeedbackDescriptors);
+ GpuAccessorState gpuAccessorState = new(poolState, default, graphicsState, specState, transformFeedbackDescriptors);
ReadOnlySpan addressesSpan = addresses.AsSpan();
@@ -334,7 +332,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (gpuVa != 0)
{
- GpuAccessor gpuAccessor = new GpuAccessor(_context, channel, gpuAccessorState, stageIndex);
+ GpuAccessor gpuAccessor = new(_context, channel, gpuAccessorState, stageIndex);
TranslatorContext currentStage = DecodeGraphicsShader(gpuAccessor, api, DefaultFlags, gpuVa);
if (nextStage != null)
@@ -358,11 +356,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1];
- List shaderSources = new List();
+ List shaderSources = new();
TranslatorContext previousStage = null;
- ShaderInfoBuilder infoBuilder = new ShaderInfoBuilder(_context, transformFeedbackDescriptors != null);
+ ShaderInfoBuilder infoBuilder = new(_context, transformFeedbackDescriptors != null);
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
{
@@ -486,7 +484,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (_diskCacheHostStorage.CacheEnabled)
{
byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(sources) : null;
- ProgramToSave programToSave = new ProgramToSave(program, hostProgram, binaryCode);
+ ProgramToSave programToSave = new(program, hostProgram, binaryCode);
_programsToSaveQueue.Enqueue(programToSave);
}
@@ -670,8 +668,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
pathsB.Prepend(program);
pathsA.Prepend(program);
- CachedShaderStage vertexAStage = new CachedShaderStage(null, codeA, cb1DataA);
- CachedShaderStage vertexBStage = new CachedShaderStage(program.Info, codeB, cb1DataB);
+ CachedShaderStage vertexAStage = new(null, codeA, cb1DataA);
+ CachedShaderStage vertexBStage = new(program.Info, codeB, cb1DataB);
return new TranslatedShaderVertexPair(vertexAStage, vertexBStage, program);
}
@@ -716,7 +714,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderStage.TessellationEvaluation => 2,
ShaderStage.Geometry => 3,
ShaderStage.Fragment => 4,
- _ => 0
+ _ => 0,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs
index e35c06b13..e65a1dec9 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
///
/// Index of the shader stage
/// Guest code, or null if not present
- public byte[] GetByIndex(int stageIndex)
+ public readonly byte[] GetByIndex(int stageIndex)
{
return stageIndex switch
{
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
2 => TessEvaluationCode,
3 => GeometryCode,
4 => FragmentCode,
- _ => VertexBCode
+ _ => VertexBCode,
};
}
}
@@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// ID of the guest code, if found
/// Cached guest code, if found
/// True if found, false otherwise
- public bool TryFind(IDataAccessor dataAccessor, out int id, out byte[] data)
+ public readonly bool TryFind(IDataAccessor dataAccessor, out int id, out byte[] data)
{
return _cache.TryFindItem(dataAccessor, out id, out data);
}
@@ -103,12 +103,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
public int GeometryId;
public int FragmentId;
- public override bool Equals(object obj)
+ public readonly override bool Equals(object obj)
{
return obj is IdTable other && Equals(other);
}
- public bool Equals(IdTable other)
+ public readonly bool Equals(IdTable other)
{
return other.VertexAId == VertexAId &&
other.VertexBId == VertexBId &&
@@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
other.FragmentId == FragmentId;
}
- public override int GetHashCode()
+ public readonly override int GetHashCode()
{
return HashCode.Combine(VertexAId, VertexBId, TessControlId, TessEvaluationId, GeometryId, FragmentId);
}
@@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Program to be added
public void Add(CachedShaderProgram program)
{
- IdTable idTable = new IdTable();
+ IdTable idTable = new();
foreach (var shader in program.Shaders)
{
@@ -222,7 +222,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
out CachedGraphicsGuestCode guestCode)
{
var memoryManager = channel.MemoryManager;
- IdTable idTable = new IdTable();
+ IdTable idTable = new();
guestCode = new CachedGraphicsGuestCode();
program = null;
@@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
return true;
}
- ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(memoryManager, baseAddress);
+ ShaderCodeAccessor codeAccessor = new(memoryManager, baseAddress);
return idCache.TryFind(codeAccessor, out id, out data);
}
@@ -279,4 +279,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs
index b94a6c054..075e3a613 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs
@@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Shader cache is written to disk
Packaging,
/// Shader cache finished loading
- Loaded
+ Loaded,
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
index e896493c5..240a4ce9f 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
@@ -29,4 +29,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return _memoryManager.GetSpanMapped(_baseAddress + (ulong)offset, length);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
index 6ca7daef2..d0765963d 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
@@ -46,4 +46,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs
index 93eeb8d72..80d599e9b 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs
@@ -46,13 +46,13 @@ namespace Ryujinx.Graphics.Gpu.Shader
CurrentDumpIndex++;
- using MemoryStream stream = new MemoryStream(code);
- BinaryReader codeReader = new BinaryReader(stream);
+ using MemoryStream stream = new(code);
+ BinaryReader codeReader = new(stream);
using FileStream fullFile = File.Create(fullPath);
using FileStream codeFile = File.Create(codePath);
- BinaryWriter fullWriter = new BinaryWriter(fullFile);
- BinaryWriter codeWriter = new BinaryWriter(codeFile);
+ BinaryWriter fullWriter = new(fullFile);
+ BinaryWriter codeWriter = new(codeFile);
int headerSize = compute ? 0 : 0x50;
@@ -126,4 +126,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return dir;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs
index 83d92edc3..7356410ca 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderStage.TessellationEvaluation => 2,
ShaderStage.Geometry => 3,
ShaderStage.Fragment => 4,
- _ => 0
+ _ => 0,
});
ResourceStages stages = info.Stage switch
@@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderStage.TessellationEvaluation => ResourceStages.TessellationEvaluation,
ShaderStage.Geometry => ResourceStages.Geometry,
ShaderStage.Fragment => ResourceStages.Fragment,
- _ => ResourceStages.None
+ _ => ResourceStages.None,
};
int uniformsPerStage = (int)_context.Capabilities.MaximumUniformBuffersPerStage;
@@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
usages[index] = new ResourceUsageCollection(_resourceUsages[index].ToArray().AsReadOnly());
}
- ResourceLayout resourceLayout = new ResourceLayout(descriptors.AsReadOnly(), usages.AsReadOnly());
+ ResourceLayout resourceLayout = new(descriptors.AsReadOnly(), usages.AsReadOnly());
if (pipeline.HasValue)
{
@@ -262,7 +262,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ProgramPipelineState? pipeline,
bool tfEnabled)
{
- ShaderInfoBuilder builder = new ShaderInfoBuilder(context, tfEnabled);
+ ShaderInfoBuilder builder = new(context, tfEnabled);
foreach (CachedShaderStage program in programs)
{
@@ -284,11 +284,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Shader information
public static ShaderInfo BuildForCompute(GpuContext context, ShaderProgramInfo info, bool fromCache = false)
{
- ShaderInfoBuilder builder = new ShaderInfoBuilder(context, tfEnabled: false);
+ ShaderInfoBuilder builder = new(context, tfEnabled: false);
builder.AddStageInfo(info);
return builder.Build(null, fromCache);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs
index 7d61332e5..e57e1df1a 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
///
class ShaderSpecializationList : IEnumerable
{
- private readonly List _entries = new List();
+ private readonly List _entries = new();
///
/// Adds a program to the list.
@@ -81,4 +81,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return GetEnumerator();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
index 9b0c8b9b9..775bfb2af 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
EarlyZForce = 1 << 0,
PrimitiveTopology = 1 << 1,
TessellationMode = 1 << 2,
- TransformFeedback = 1 << 3
+ TransformFeedback = 1 << 3,
}
private QueriedStateFlags _queriedState;
@@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
TextureFormat = 1 << 0,
SamplerType = 1 << 1,
- CoordNormalized = 1 << 2
+ CoordNormalized = 1 << 2,
}
///
@@ -440,7 +440,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Texture specialization state
private Box GetOrCreateTextureSpecState(int stageIndex, int handle, int cbufSlot)
{
- TextureKey key = new TextureKey(stageIndex, handle, cbufSlot);
+ TextureKey key = new(stageIndex, handle, cbufSlot);
if (!_textureSpecialization.TryGetValue(key, out Box state))
{
@@ -459,7 +459,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Texture specialization state
private Box GetTextureSpecState(int stageIndex, int handle, int cbufSlot)
{
- TextureKey key = new TextureKey(stageIndex, handle, cbufSlot);
+ TextureKey key = new(stageIndex, handle, cbufSlot);
if (_textureSpecialization.TryGetValue(key, out Box state))
{
@@ -694,7 +694,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Texture descriptor
/// True if the state matches, false otherwise
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private bool MatchesTexture(Box specializationState, in Image.TextureDescriptor descriptor)
+ private static bool MatchesTexture(Box specializationState, in Image.TextureDescriptor descriptor)
{
if (specializationState != null)
{
@@ -756,7 +756,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Shader specialization state
public static ShaderSpecializationState Read(ref BinarySerializer dataReader)
{
- ShaderSpecializationState specState = new ShaderSpecializationState();
+ ShaderSpecializationState specState = new();
dataReader.Read(ref specState._queriedState);
dataReader.Read(ref specState._compute);
@@ -812,7 +812,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
for (int index = 0; index < count; index++)
{
TextureKey textureKey = default;
- Box textureState = new Box();
+ Box textureState = new();
dataReader.ReadWithMagicAndSize(ref textureKey, TexkMagic);
dataReader.ReadWithMagicAndSize(ref textureState.Value, TexsMagic);
@@ -886,4 +886,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
index 5baf2a1a6..1f245881d 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
@@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// Span of varying locations
public ReadOnlySpan AsSpan()
{
- return MemoryMarshal.Cast(VaryingLocations.AsSpan()).Slice(0, Math.Min(128, VaryingCount));
+ return MemoryMarshal.Cast(VaryingLocations.AsSpan())[..Math.Min(128, VaryingCount)];
}
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs
index 426669914..1b4df37e2 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs
@@ -25,6 +25,6 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
///
Force = 1 << 2,
- StrictSyncpoint = Strict | Syncpoint
+ StrictSyncpoint = Strict | Syncpoint,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
index 968de930d..ccec763e3 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
///
/// Array containing all hardware syncpoints.
///
- private Syncpoint[] _syncpoints;
+ private readonly Syncpoint[] _syncpoints;
public SynchronizationManager()
{
@@ -118,26 +118,24 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
timeout = TimeSpan.FromSeconds(1);
}
- using (ManualResetEvent waitEvent = new ManualResetEvent(false))
+ using ManualResetEvent waitEvent = new(false);
+ var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
+
+ if (info == null)
{
- var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
-
- if (info == null)
- {
- return false;
- }
-
- bool signaled = waitEvent.WaitOne(timeout);
-
- if (!signaled && info != null)
- {
- Logger.Error?.Print(LogClass.Gpu, $"Wait on syncpoint {id} for threshold {threshold} took more than {timeout.TotalMilliseconds}ms, resuming execution...");
-
- _syncpoints[id].UnregisterCallback(info);
- }
-
- return !signaled;
+ return false;
}
+
+ bool signaled = waitEvent.WaitOne(timeout);
+
+ if (!signaled && info != null)
+ {
+ Logger.Error?.Print(LogClass.Gpu, $"Wait on syncpoint {id} for threshold {threshold} took more than {timeout.TotalMilliseconds}ms, resuming execution...");
+
+ _syncpoints[id].UnregisterCallback(info);
+ }
+
+ return !signaled;
}
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs
index 39fb83c05..16f4d971b 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
public Syncpoint(uint id)
{
- Id = id;
+ Id = id;
_waiters = new List();
}
@@ -46,10 +46,10 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
}
else
{
- SyncpointWaiterHandle waiterInformation = new SyncpointWaiterHandle
+ SyncpointWaiterHandle waiterInformation = new()
{
Threshold = threshold,
- Callback = callback
+ Callback = callback,
};
_waiters.Add(waiterInformation);
@@ -92,10 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
}
else
{
- if (expiredList == null)
- {
- expiredList = new List();
- }
+ expiredList ??= new List();
expiredList.Add(item);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Window.cs b/src/Ryujinx.Graphics.Gpu/Window.cs
index 06d0fddf4..5da472b3e 100644
--- a/src/Ryujinx.Graphics.Gpu/Window.cs
+++ b/src/Ryujinx.Graphics.Gpu/Window.cs
@@ -68,21 +68,21 @@ namespace Ryujinx.Graphics.Gpu
/// Texture release callback
/// User defined object passed to the release callback, can be used to identify the texture
public PresentationTexture(
- TextureCache cache,
- TextureInfo info,
- MultiRange range,
- ImageCrop crop,
+ TextureCache cache,
+ TextureInfo info,
+ MultiRange range,
+ ImageCrop crop,
Action acquireCallback,
- Action