From c963b3c80488f88c9d7f44588b6ba45051af3e2d Mon Sep 17 00:00:00 2001 From: Hunter <102537986+HunterBarney@users.noreply.github.com> Date: Mon, 26 Dec 2022 09:11:05 -0500 Subject: Added Generic Math to BitUtils (#3929) * Generic Math Update Updated Several functions in Ryujinx.Common/Utilities/BitUtils to use generic math * Updated BitUtil calls * Removed Whitespace * Switched decrement * Fixed changed method calls. The method calls were originally changed on accident due to me relying too much on intellisense doing stuff for me * Update Ryujinx.Common/Utilities/BitUtils.cs Co-authored-by: gdkchan Co-authored-by: gdkchan --- Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs | 4 ++-- Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'Ryujinx.Audio/Renderer') diff --git a/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs b/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs index 922ce4e3..f35dbec7 100644 --- a/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs +++ b/Ryujinx.Audio/Renderer/Common/WorkBufferAllocator.cs @@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Common if (size != 0) { - ulong alignedOffset = BitUtils.AlignUp(Offset, align); + ulong alignedOffset = BitUtils.AlignUp(Offset, (ulong)align); if (alignedOffset + size <= (ulong)BackingMemory.Length) { @@ -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, align) + (ulong)Unsafe.SizeOf() * count; + return BitUtils.AlignUp(currentSize, (ulong)align) + (ulong)Unsafe.SizeOf() * count; } } } \ No newline at end of file diff --git a/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs b/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs index 5116f7ca..53570243 100644 --- a/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs +++ b/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs @@ -167,7 +167,7 @@ namespace Ryujinx.Audio.Renderer.Server return ResultCode.WorkBufferTooSmall; } - _depopBuffer = workBufferAllocator.Allocate((ulong)BitUtils.AlignUp(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment); + _depopBuffer = workBufferAllocator.Allocate(BitUtils.AlignUp(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment); if (_depopBuffer.IsEmpty) { @@ -772,7 +772,7 @@ namespace Ryujinx.Audio.Renderer.Server size = WorkBufferAllocator.GetTargetSize(size, Constants.TargetSampleCount * (Constants.VoiceChannelCountMax + parameter.MixBufferCount) * (parameter.SinkCount + parameter.SubMixBufferCount), 0x10); // Depop buffer - size = WorkBufferAllocator.GetTargetSize(size, (ulong)BitUtils.AlignUp(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment); + size = WorkBufferAllocator.GetTargetSize(size, BitUtils.AlignUp(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment); // Voice size = WorkBufferAllocator.GetTargetSize(size, parameter.VoiceCount, VoiceState.Alignment); @@ -804,10 +804,10 @@ namespace Ryujinx.Audio.Renderer.Server { ulong performanceMetricsPerFramesSize = PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter, ref behaviourContext) * (parameter.PerformanceMetricFramesCount + 1) + 0xC; - size += BitUtils.AlignUp(performanceMetricsPerFramesSize, Constants.PerformanceMetricsPerFramesSizeAlignment); + size += BitUtils.AlignUp(performanceMetricsPerFramesSize, Constants.PerformanceMetricsPerFramesSizeAlignment); } - return BitUtils.AlignUp(size, Constants.WorkBufferAlignment); + return BitUtils.AlignUp(size, Constants.WorkBufferAlignment); } public ResultCode QuerySystemEvent(out IWritableEvent systemEvent) -- cgit v1.2.3