From 31fca432a7274907c46f6ec254d54e96cb6446c6 Mon Sep 17 00:00:00 2001 From: Mary Date: Tue, 2 Mar 2021 23:50:46 +0100 Subject: Amadeus: Add ARM SIMD fast path (#2069) Add fast paths in the audio renderer for AArch64 in all current fast paths. --- .../Renderer/Dsp/Command/VolumeCommand.cs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs') diff --git a/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs b/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs index b58ae1f8..217d51c9 100644 --- a/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs +++ b/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs @@ -19,6 +19,7 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.X86; namespace Ryujinx.Audio.Renderer.Dsp.Command @@ -89,6 +90,26 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command } } + private void ProcessVolumeAdvSimd(Span outputBuffer, ReadOnlySpan inputBuffer) + { + Vector128 volumeVec = Vector128.Create(Volume); + + ReadOnlySpan> inputVec = MemoryMarshal.Cast>(inputBuffer); + Span> outputVec = MemoryMarshal.Cast>(outputBuffer); + + int sisdStart = inputVec.Length * 4; + + for (int i = 0; i < inputVec.Length; i++) + { + outputVec[i] = AdvSimd.Ceiling(AdvSimd.Multiply(inputVec[i], volumeVec)); + } + + for (int i = sisdStart; i < inputBuffer.Length; i++) + { + outputBuffer[i] = FloatingPointHelper.MultiplyRoundUp(inputBuffer[i], Volume); + } + } + private void ProcessVolume(Span outputBuffer, ReadOnlySpan inputBuffer) { if (Avx.IsSupported) @@ -99,6 +120,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command { ProcessVolumeSse41(outputBuffer, inputBuffer); } + else if (AdvSimd.IsSupported) + { + ProcessVolumeAdvSimd(outputBuffer, inputBuffer); + } else { ProcessVolumeSlowPath(outputBuffer, inputBuffer); -- cgit v1.2.3