Amadeus: DSP code generation improvements (#2460)

This improve RyuJIT codegen drastically on the DSP side.
This may reduce CPU usage of the DSP thread quite a lot.
This commit is contained in:
Mary 2021-07-18 13:05:11 +02:00 committed by GitHub
parent 97a2133207
commit b8ad676fb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 319 additions and 265 deletions

View file

@ -65,6 +65,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
IsEffectEnabled = isEnabled;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private uint Read(IVirtualMemoryManager memoryManager, ulong bufferAddress, uint countMax, Span<int> outBuffer, uint count, uint readOffset, uint updateCount)
{
if (countMax == 0 || bufferAddress == 0)
@ -104,6 +105,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return count;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private uint Write(IVirtualMemoryManager memoryManager, ulong outBufferAddress, uint countMax, ReadOnlySpan<int> buffer, uint count, uint writeOffset, uint updateCount)
{
if (countMax == 0 || outBufferAddress == 0)
@ -175,8 +177,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
else
{
ZeroFill(context.MemoryManager, BufferInfo.SendBufferInfo, Unsafe.SizeOf<AuxiliaryBufferInfo>());
ZeroFill(context.MemoryManager, BufferInfo.ReturnBufferInfo, Unsafe.SizeOf<AuxiliaryBufferInfo>());
context.MemoryManager.Fill(BufferInfo.SendBufferInfo, (ulong)Unsafe.SizeOf<AuxiliaryBufferInfo>(), 0);
context.MemoryManager.Fill(BufferInfo.ReturnBufferInfo, (ulong)Unsafe.SizeOf<AuxiliaryBufferInfo>(), 0);
if (InputBufferIndex != OutputBufferIndex)
{
@ -184,22 +186,5 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
private static void ZeroFill(IVirtualMemoryManager memoryManager, ulong address, int size)
{
ulong endAddress = address + (ulong)size;
while (address + 7UL < endAddress)
{
memoryManager.Write(address, 0UL);
address += 8;
}
while (address < endAddress)
{
memoryManager.Write(address, (byte)0);
address++;
}
}
}
}