mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-06-02 13:18:46 +02:00
ead9a25141
* - WritableRegion: enable wrapping IMemoryOwner<byte> - IVirtualMemoryManager impls of GetWritableRegion() use pooled memory when region is non-contiguous. - IVirtualMemoryManager: add GetReadOnlySequence() and impls - ByteMemoryPool: add new method RentCopy() - ByteMemoryPool: make class static, remove ctor and singleton field from earlier impl * - BytesReadOnlySequenceSegment: move from Ryujinx.Common.Memory to Ryujinx.Memory - BytesReadOnlySequenceSegment: add IsContiguousWith() and Replace() methods - VirtualMemoryManagerBase: - remove generic type parameters, instead use ulong for virtual addresses and nuint for host/physical addresses - implement IWritableBlock - add virtual GetReadOnlySequence() with coalescing of contiguous segments - add virtual GetSpan() - add virtual GetWritableRegion() - add abstract IsMapped() - add virtual MapForeign(ulong, nuint, ulong) - add virtual Read<T>() - add virtual Read(ulong, Span<byte>) - add virtual ReadTracked<T>() - add virtual SignalMemoryTracking() - add virtual Write() - add virtual Write<T>() - add virtual WriteUntracked() - add virtual WriteWithRedundancyCheck() - VirtualMemoryManagerRefCountedBase: remove generic type parameters - AddressSpaceManager: remove redundant methods, add required overrides - HvMemoryManager: remove redundant methods, add required overrides, add overrides for _invalidAccessHandler handling - MemoryManager: remove redundant methods, add required overrides, add overrides for _invalidAccessHandler handling - MemoryManagerHostMapped: remove redundant methods, add required overrides, add overrides for _invalidAccessHandler handling - NativeMemoryManager: add get properties for Pointer and Length - throughout: removed invalid <inheritdoc/> comments * - WritableRegion: enable wrapping IMemoryOwner<byte> - IVirtualMemoryManager impls of GetWritableRegion() use pooled memory when region is non-contiguous. - IVirtualMemoryManager: add GetReadOnlySequence() and impls - ByteMemoryPool: add new method RentCopy() - ByteMemoryPool: make class static, remove ctor and singleton field from earlier impl * add PagedMemoryRange enumerator types, use them in IVirtualMemoryManager implementations to consolidate page-handling logic and add a new capability - the coalescing of pages for consolidating memory copies and segmentation. * new: more tests for PagedMemoryRangeCoalescingEnumerator showing coalescing of contiguous segments * make some struct properties readonly * put braces around `foreach` bodies * encourage inlining of some PagedMemoryRange*Enumerator members * DynamicRingBuffer: - use ByteMemoryPool - make some methods return without locking when size/count argument = 0 - make generic Read<T>()/Write<T>() non-generic because its only usage is as T = byte - change Read(byte[]...) to Read(Span<byte>...) - change Write(byte[]...) to Write(Span<byte>...) * change IAudioRenderer.RequestUpdate() to take a ReadOnlySequence<byte>, enabling zero-copy audio rendering * HipcGenerator: support ReadOnlySequence<byte> as IPC method parameter * change IAudioRenderer/AudioRenderer RequestUpdate* methods to take input as ReadOnlySequence<byte> * MemoryManagerHostTracked: use rented memory when contiguous in `GetWritableRegion()` * rebase cleanup * dotnet format fixes * format and comment fixes * format long parameter list - take 2 * - add support to HipcGenerator for buffers of type `Memory<byte>` - change `AudioRenderer` `RequestUpdate()` and `RequestUpdateAuto()` to use Memory<byte> for output buffers, removing another memory block allocation/copy * SplitterContext `UpdateState()` and `UpdateData()` smooth out advance/rewind logic, only rewind if magic is invalid * DynamicRingBuffer.Write(): change Span<byte> to ReadOnlySpan<byte>
93 lines
3.0 KiB
C#
93 lines
3.0 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Server state for a 3D reverberation effect.
|
|
/// </summary>
|
|
public class Reverb3dEffect : BaseEffect
|
|
{
|
|
/// <summary>
|
|
/// The 3D reverberation parameter.
|
|
/// </summary>
|
|
public Reverb3dParameter Parameter;
|
|
|
|
/// <summary>
|
|
/// The 3D reverberation state.
|
|
/// </summary>
|
|
public Memory<Reverb3dState> 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, in EffectInParameterVersion1 parameter, PoolMapper mapper)
|
|
{
|
|
Update(out updateErrorInfo, in parameter, mapper);
|
|
}
|
|
|
|
public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, in EffectInParameterVersion2 parameter, PoolMapper mapper)
|
|
{
|
|
Update(out updateErrorInfo, in parameter, mapper);
|
|
}
|
|
|
|
public void Update<T>(out BehaviourParameter.ErrorInfo updateErrorInfo, in T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
|
|
{
|
|
Debug.Assert(IsTypeValid(in parameter));
|
|
|
|
ref Reverb3dParameter reverbParameter = ref MemoryMarshal.Cast<byte, Reverb3dParameter>(parameter.SpecificData)[0];
|
|
|
|
updateErrorInfo = new BehaviourParameter.ErrorInfo();
|
|
|
|
if (reverbParameter.IsChannelCountMaxValid())
|
|
{
|
|
UpdateParameterBase(in 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;
|
|
}
|
|
}
|
|
}
|