From 33a986317b7bda2582fcf50931a845e36d779ea6 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Fri, 28 Jul 2023 23:56:33 -0400 Subject: [PATCH] CopyBuffer to Buffer --- src/Ryujinx.Graphics.Metal/Pipeline.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx.Graphics.Metal/Pipeline.cs b/src/Ryujinx.Graphics.Metal/Pipeline.cs index a0af3c33f..8ea0d1bc7 100644 --- a/src/Ryujinx.Graphics.Metal/Pipeline.cs +++ b/src/Ryujinx.Graphics.Metal/Pipeline.cs @@ -133,7 +133,26 @@ namespace Ryujinx.Graphics.Metal public void CopyBuffer(BufferHandle source, BufferHandle destination, int srcOffset, int dstOffset, int size) { - throw new NotImplementedException(); + MTLBlitCommandEncoder blitCommandEncoder; + + if (CurrentEncoder is MTLBlitCommandEncoder encoder) + { + blitCommandEncoder = encoder; + } + else + { + blitCommandEncoder = BeginBlitPass(); + } + + MTLBuffer sourceBuffer = new(Unsafe.As(ref source)); + MTLBuffer destinationBuffer = new(Unsafe.As(ref destination)); + + blitCommandEncoder.CopyFromBuffer( + sourceBuffer, + (ulong)srcOffset, + destinationBuffer, + (ulong)dstOffset, + (ulong)size); } public void DispatchCompute(int groupsX, int groupsY, int groupsZ)