From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:22:00 +0200 Subject: Move solution and projects to src --- .../Server/Effect/AuxiliaryBufferEffect.cs | 85 ------- Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs | 272 --------------------- .../Renderer/Server/Effect/BiquadFilterEffect.cs | 67 ----- .../Renderer/Server/Effect/BufferMixEffect.cs | 49 ---- .../Renderer/Server/Effect/CaptureBufferEffect.cs | 82 ------- .../Renderer/Server/Effect/CompressorEffect.cs | 67 ----- .../Renderer/Server/Effect/DelayEffect.cs | 93 ------- .../Renderer/Server/Effect/EffectContext.cs | 123 ---------- .../Renderer/Server/Effect/LimiterEffect.cs | 95 ------- .../Renderer/Server/Effect/Reverb3dEffect.cs | 92 ------- .../Renderer/Server/Effect/ReverbEffect.cs | 95 ------- Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs | 28 --- 12 files changed, 1148 deletions(-) delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs delete mode 100644 Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs (limited to 'Ryujinx.Audio/Renderer/Server/Effect') diff --git a/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs deleted file mode 100644 index 16406527..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/AuxiliaryBufferEffect.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using static Ryujinx.Audio.Renderer.Dsp.State.AuxiliaryBufferHeader; -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for an auxiliary buffer effect. - /// - public class AuxiliaryBufferEffect : BaseEffect - { - /// - /// The auxiliary buffer parameter. - /// - public AuxiliaryBufferParameter Parameter; - - /// - /// Auxiliary buffer state. - /// - public AuxiliaryBufferAddresses State; - - public override EffectType TargetEffectType => EffectType.AuxiliaryBuffer; - - public override DspAddress GetWorkBuffer(int index) - { - return WorkBuffers[index].GetReference(true); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (BufferUnmapped || parameter.IsNew) - { - ulong bufferSize = (ulong)Unsafe.SizeOf() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf(); - - bool sendBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize); - bool returnBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[1], Parameter.ReturnBufferInfoAddress, bufferSize); - - BufferUnmapped = sendBufferUnmapped && returnBufferUnmapped; - - if (!BufferUnmapped) - { - DspAddress sendDspAddress = WorkBuffers[0].GetReference(false); - DspAddress returnDspAddress = WorkBuffers[1].GetReference(false); - - State.SendBufferInfo = sendDspAddress + (uint)Unsafe.SizeOf(); - State.SendBufferInfoBase = sendDspAddress + (uint)Unsafe.SizeOf(); - - State.ReturnBufferInfo = returnDspAddress + (uint)Unsafe.SizeOf(); - State.ReturnBufferInfoBase = returnDspAddress + (uint)Unsafe.SizeOf(); - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs deleted file mode 100644 index 825b3bf7..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/BaseEffect.cs +++ /dev/null @@ -1,272 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using Ryujinx.Audio.Renderer.Utils; -using System; -using System.Diagnostics; -using static Ryujinx.Audio.Renderer.Common.BehaviourParameter; - -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Base class used as a server state for an effect. - /// - public class BaseEffect - { - /// - /// The of the effect. - /// - public EffectType Type; - - /// - /// Set to true if the effect must be active. - /// - public bool IsEnabled; - - /// - /// Set to true if the internal effect work buffers used wasn't mapped. - /// - public bool BufferUnmapped; - - /// - /// The current state of the effect. - /// - public UsageState UsageState; - - /// - /// The target mix id of the effect. - /// - public int MixId; - - /// - /// Position of the effect while processing effects. - /// - public uint ProcessingOrder; - - /// - /// Array of all the work buffer used by the effect. - /// - protected AddressInfo[] WorkBuffers; - - /// - /// Create a new . - /// - public BaseEffect() - { - Type = TargetEffectType; - UsageState = UsageState.Invalid; - - IsEnabled = false; - BufferUnmapped = false; - MixId = Constants.UnusedMixId; - ProcessingOrder = uint.MaxValue; - - WorkBuffers = new AddressInfo[2]; - - foreach (ref AddressInfo info in WorkBuffers.AsSpan()) - { - info = AddressInfo.Create(); - } - } - - /// - /// The target handled by this . - /// - public virtual EffectType TargetEffectType => EffectType.Invalid; - - /// - /// Check if the sent by the user match the internal . - /// - /// The user parameter. - /// Returns true if the sent by the user matches the internal . - public bool IsTypeValid(ref T parameter) where T : unmanaged, IEffectInParameter - { - return parameter.Type == TargetEffectType; - } - - /// - /// Update the usage state during command generation. - /// - protected void UpdateUsageStateForCommandGeneration() - { - UsageState = IsEnabled ? UsageState.Enabled : UsageState.Disabled; - } - - /// - /// Update the internal common parameters from a user parameter. - /// - /// The user parameter. - protected void UpdateParameterBase(ref T parameter) where T : unmanaged, IEffectInParameter - { - MixId = parameter.MixId; - ProcessingOrder = parameter.ProcessingOrder; - } - - /// - /// Force unmap all the work buffers. - /// - /// The mapper to use. - public void ForceUnmapBuffers(PoolMapper mapper) - { - foreach (ref AddressInfo info in WorkBuffers.AsSpan()) - { - if (info.GetReference(false) != 0) - { - mapper.ForceUnmap(ref info); - } - } - } - - /// - /// Check if the effect needs to be skipped. - /// - /// Returns true if the effect needs to be skipped. - public bool ShouldSkip() - { - return BufferUnmapped; - } - - /// - /// Update the state during command generation. - /// - public virtual void UpdateForCommandGeneration() - { - Debug.Assert(Type == TargetEffectType); - } - - /// - /// Initialize the given result state. - /// - /// The state to initalize - public virtual void InitializeResultState(ref EffectResultState state) { } - - /// - /// Update the result state with . - /// - /// The destination result state - /// The source result state - public virtual void UpdateResultState(ref EffectResultState destState, ref EffectResultState srcState) { } - - /// - /// Update the internal state from a user version 1 parameter. - /// - /// The possible that was generated. - /// The user parameter. - /// The mapper to use. - public virtual void Update(out ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - updateErrorInfo = new ErrorInfo(); - } - - /// - /// Update the internal state from a user version 2 parameter. - /// - /// The possible that was generated. - /// The user parameter. - /// The mapper to use. - public virtual void Update(out ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - updateErrorInfo = new ErrorInfo(); - } - - /// - /// Get the work buffer DSP address at the given index. - /// - /// The index of the work buffer - /// The work buffer DSP address at the given index. - public virtual DspAddress GetWorkBuffer(int index) - { - throw new InvalidOperationException(); - } - - /// - /// Get the first work buffer DSP address. - /// - /// The first work buffer DSP address. - protected DspAddress GetSingleBuffer() - { - if (IsEnabled) - { - return WorkBuffers[0].GetReference(true); - } - - if (UsageState != UsageState.Disabled) - { - DspAddress address = WorkBuffers[0].GetReference(false); - ulong size = WorkBuffers[0].Size; - - if (address != 0 && size != 0) - { - AudioProcessorMemoryManager.InvalidateDataCache(address, size); - } - } - - return 0; - } - - /// - /// Store the output status to the given user output. - /// - /// The given user output. - /// If set to true, the is active. - public void StoreStatus(ref T outStatus, bool isAudioRendererActive) where T : unmanaged, IEffectOutStatus - { - if (isAudioRendererActive) - { - if (UsageState == UsageState.Disabled) - { - outStatus.State = EffectState.Disabled; - } - else - { - outStatus.State = EffectState.Enabled; - } - } - else if (UsageState == UsageState.New) - { - outStatus.State = EffectState.Enabled; - } - else - { - outStatus.State = EffectState.Disabled; - } - } - - /// - /// Get the associated to the of this effect. - /// - /// The associated to the of this effect. - public PerformanceDetailType GetPerformanceDetailType() - { - switch (Type) - { - 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}"); - } - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs deleted file mode 100644 index de91046d..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/BiquadFilterEffect.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a biquad filter effect. - /// - public class BiquadFilterEffect : BaseEffect - { - /// - /// The biquad filter parameter. - /// - public BiquadFilterEffectParameter Parameter; - - /// - /// The biquad filter state. - /// - public Memory State { get; } - - /// - /// Create a new . - /// - public BiquadFilterEffect() - { - Parameter = new BiquadFilterEffectParameter(); - State = new BiquadFilterState[Constants.ChannelCountMax]; - } - - public override EffectType TargetEffectType => EffectType.BiquadFilter; - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs deleted file mode 100644 index 82c0a055..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/BufferMixEffect.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a buffer mix effect. - /// - public class BufferMixEffect : BaseEffect - { - /// - /// The buffer mix parameter. - /// - public BufferMixParameter Parameter; - - public override EffectType TargetEffectType => EffectType.BufferMix; - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs deleted file mode 100644 index c445798d..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/CaptureBufferEffect.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for an capture buffer effect. - /// - public class CaptureBufferEffect : BaseEffect - { - /// - /// The capture buffer parameter. - /// - public AuxiliaryBufferParameter Parameter; - - /// - /// Capture buffer state. - /// - public AuxiliaryBufferAddresses State; - - public override EffectType TargetEffectType => EffectType.CaptureBuffer; - - public override DspAddress GetWorkBuffer(int index) - { - return WorkBuffers[index].GetReference(true); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (BufferUnmapped || parameter.IsNew) - { - ulong bufferSize = (ulong)Unsafe.SizeOf() * Parameter.BufferStorageSize + (ulong)Unsafe.SizeOf(); - - bool sendBufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], Parameter.SendBufferInfoAddress, bufferSize); - - BufferUnmapped = sendBufferUnmapped; - - if (!BufferUnmapped) - { - DspAddress sendDspAddress = WorkBuffers[0].GetReference(false); - - // NOTE: Nintendo directly interact with the CPU side structure in the processing of the DSP command. - State.SendBufferInfo = sendDspAddress; - State.SendBufferInfoBase = sendDspAddress + (ulong)Unsafe.SizeOf(); - State.ReturnBufferInfo = 0; - State.ReturnBufferInfoBase = 0; - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs deleted file mode 100644 index 32162abc..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a compressor effect. - /// - public class CompressorEffect : BaseEffect - { - /// - /// The compressor parameter. - /// - public CompressorParameter Parameter; - - /// - /// The compressor state. - /// - public Memory State { get; } - - /// - /// Create a new . - /// - public CompressorEffect() - { - State = new CompressorState[1]; - } - - public override EffectType TargetEffectType => EffectType.Compressor; - - public override ulong GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - // Nintendo doesn't do anything here but we still require updateErrorInfo to be initialised. - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Debug.Assert(IsTypeValid(ref parameter)); - - UpdateParameterBase(ref parameter); - - Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; - IsEnabled = parameter.IsEnabled; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} diff --git a/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs deleted file mode 100644 index 3f5d70bc..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/DelayEffect.cs +++ /dev/null @@ -1,93 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using DspAddress = System.UInt64; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a delay effect. - /// - public class DelayEffect : BaseEffect - { - /// - /// The delay parameter. - /// - public DelayParameter Parameter; - - /// - /// The delay state. - /// - public Memory State { get; } - - public DelayEffect() - { - State = new DelayState[1]; - } - - public override EffectType TargetEffectType => EffectType.Delay; - - public override DspAddress GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref DelayParameter delayParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (delayParameter.IsChannelCountMaxValid()) - { - UpdateParameterBase(ref parameter); - - UsageState oldParameterStatus = Parameter.Status; - - Parameter = delayParameter; - - if (delayParameter.IsChannelCountValid()) - { - IsEnabled = parameter.IsEnabled; - - if (oldParameterStatus != UsageState.Enabled) - { - Parameter.Status = oldParameterStatus; - } - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.Status = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs b/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs deleted file mode 100644 index bfb6528b..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/EffectContext.cs +++ /dev/null @@ -1,123 +0,0 @@ -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Utils; -using System; -using System.Diagnostics; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Effect context. - /// - public class EffectContext - { - /// - /// Storage for . - /// - private BaseEffect[] _effects; - - /// - /// The total effect count. - /// - private uint _effectCount; - - private EffectResultState[] _resultStatesCpu; - private EffectResultState[] _resultStatesDsp; - - /// - /// Create a new . - /// - public EffectContext() - { - _effects = null; - _effectCount = 0; - } - - /// - /// Initialize the . - /// - /// The total effect count. - /// The total result state count. - public void Initialize(uint effectCount, uint resultStateCount) - { - _effectCount = effectCount; - _effects = new BaseEffect[effectCount]; - - for (int i = 0; i < _effectCount; i++) - { - _effects[i] = new BaseEffect(); - } - - _resultStatesCpu = new EffectResultState[resultStateCount]; - _resultStatesDsp = new EffectResultState[resultStateCount]; - } - - /// - /// Get the total effect count. - /// - /// The total effect count. - public uint GetCount() - { - return _effectCount; - } - - /// - /// Get a reference to a at the given . - /// - /// The index to use. - /// A reference to a at the given . - public ref BaseEffect GetEffect(int index) - { - Debug.Assert(index >= 0 && index < _effectCount); - - return ref _effects[index]; - } - - /// - /// Get a reference to a at the given . - /// - /// The index to use. - /// A reference to a at the given . - /// The returned should only be used when updating the server state. - public ref EffectResultState GetState(int index) - { - Debug.Assert(index >= 0 && index < _resultStatesCpu.Length); - - return ref _resultStatesCpu[index]; - } - - /// - /// Get a reference to a at the given . - /// - /// The index to use. - /// A reference to a at the given . - /// The returned should only be used in the context of processing on the . - public ref EffectResultState GetDspState(int index) - { - Debug.Assert(index >= 0 && index < _resultStatesDsp.Length); - - return ref _resultStatesDsp[index]; - } - - /// - /// Get a memory instance to a at the given . - /// - /// The index to use. - /// A memory instance to a at the given . - /// The returned should only be used in the context of processing on the . - public Memory GetDspStateMemory(int index) - { - return SpanIOHelper.GetMemory(_resultStatesDsp.AsMemory(), index, (uint)_resultStatesDsp.Length); - } - - /// - /// Update internal state during command generation. - /// - public void UpdateResultStateForCommandGeneration() - { - for (int index = 0; index < _resultStatesCpu.Length; index++) - { - _effects[index].UpdateResultState(ref _resultStatesCpu[index], ref _resultStatesDsp[index]); - } - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs deleted file mode 100644 index 6e17ef3d..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/LimiterEffect.cs +++ /dev/null @@ -1,95 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a limiter effect. - /// - public class LimiterEffect : BaseEffect - { - /// - /// The limiter parameter. - /// - public LimiterParameter Parameter; - - /// - /// The limiter state. - /// - public Memory State { get; } - - /// - /// Create a new . - /// - public LimiterEffect() - { - State = new LimiterState[1]; - } - - public override EffectType TargetEffectType => EffectType.Limiter; - - public override ulong GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref LimiterParameter limiterParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - UpdateParameterBase(ref parameter); - - Parameter = limiterParameter; - - IsEnabled = parameter.IsEnabled; - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.Status = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - Parameter.StatisticsReset = false; - } - - public override void InitializeResultState(ref EffectResultState state) - { - ref LimiterStatistics statistics = ref MemoryMarshal.Cast(state.SpecificData)[0]; - - statistics.Reset(); - } - - public override void UpdateResultState(ref EffectResultState destState, ref EffectResultState srcState) - { - destState = srcState; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs deleted file mode 100644 index 473fddb8..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/Reverb3dEffect.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a 3D reverberation effect. - /// - public class Reverb3dEffect : BaseEffect - { - /// - /// The 3D reverberation parameter. - /// - public Reverb3dParameter Parameter; - - /// - /// The 3D reverberation state. - /// - public Memory State { get; } - - public Reverb3dEffect() - { - State = new Reverb3dState[1]; - } - - public override EffectType TargetEffectType => EffectType.Reverb3d; - - public override ulong GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref Reverb3dParameter reverbParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (reverbParameter.IsChannelCountMaxValid()) - { - UpdateParameterBase(ref parameter); - - UsageState oldParameterStatus = Parameter.ParameterStatus; - - Parameter = reverbParameter; - - if (reverbParameter.IsChannelCountValid()) - { - IsEnabled = parameter.IsEnabled; - - if (oldParameterStatus != UsageState.Enabled) - { - Parameter.ParameterStatus = oldParameterStatus; - } - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.ParameterStatus = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.ParameterStatus = UsageState.Enabled; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs deleted file mode 100644 index e1543fd1..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/ReverbEffect.cs +++ /dev/null @@ -1,95 +0,0 @@ -using Ryujinx.Audio.Renderer.Common; -using Ryujinx.Audio.Renderer.Dsp.State; -using Ryujinx.Audio.Renderer.Parameter; -using Ryujinx.Audio.Renderer.Parameter.Effect; -using Ryujinx.Audio.Renderer.Server.MemoryPool; -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// Server state for a reverberation effect. - /// - public class ReverbEffect : BaseEffect - { - /// - /// The reverberation parameter. - /// - public ReverbParameter Parameter; - - /// - /// The reverberation state. - /// - public Memory State { get; } - - /// - /// Create a new . - /// - public ReverbEffect() - { - State = new ReverbState[1]; - } - - public override EffectType TargetEffectType => EffectType.Reverb; - - public override ulong GetWorkBuffer(int index) - { - return GetSingleBuffer(); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) - { - Update(out updateErrorInfo, ref parameter, mapper); - } - - public void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter - { - Debug.Assert(IsTypeValid(ref parameter)); - - ref ReverbParameter reverbParameter = ref MemoryMarshal.Cast(parameter.SpecificData)[0]; - - updateErrorInfo = new BehaviourParameter.ErrorInfo(); - - if (reverbParameter.IsChannelCountMaxValid()) - { - UpdateParameterBase(ref parameter); - - UsageState oldParameterStatus = Parameter.Status; - - Parameter = reverbParameter; - - if (reverbParameter.IsChannelCountValid()) - { - IsEnabled = parameter.IsEnabled; - - if (oldParameterStatus != UsageState.Enabled) - { - Parameter.Status = oldParameterStatus; - } - - if (BufferUnmapped || parameter.IsNew) - { - UsageState = UsageState.New; - Parameter.Status = UsageState.Invalid; - - BufferUnmapped = !mapper.TryAttachBuffer(out updateErrorInfo, ref WorkBuffers[0], parameter.BufferBase, parameter.BufferSize); - } - } - } - } - - public override void UpdateForCommandGeneration() - { - UpdateUsageStateForCommandGeneration(); - - Parameter.Status = UsageState.Enabled; - } - } -} \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs b/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs deleted file mode 100644 index 8648aa2c..00000000 --- a/Ryujinx.Audio/Renderer/Server/Effect/UsageState.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Ryujinx.Audio.Renderer.Server.Effect -{ - /// - /// The usage state of an effect. - /// - public enum UsageState : byte - { - /// - /// The effect is in an invalid state. - /// - Invalid, - - /// - /// The effect is new. - /// - New, - - /// - /// The effect is enabled. - /// - Enabled, - - /// - /// The effect is disabled. - /// - Disabled - } -} \ No newline at end of file -- cgit v1.2.3