Shitty Clears + Inline Buffer Improvements?

This commit is contained in:
Isaac Marovitz 2024-05-22 17:21:44 -04:00 committed by Isaac Marovitz
parent 087bf71a13
commit 8feee9c005
11 changed files with 124 additions and 61 deletions

View file

@ -213,17 +213,19 @@ namespace Ryujinx.Graphics.Metal
public unsafe void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data)
{
MTLBuffer mtlBuffer = new(Unsafe.As<BufferHandle, IntPtr>(ref buffer));
var span = new Span<byte>(mtlBuffer.Contents.ToPointer(), (int)mtlBuffer.Length);
data.CopyTo(span[offset..]);
if (mtlBuffer.StorageMode == MTLStorageMode.Managed)
var blitEncoder = _pipeline.GetOrCreateBlitEncoder();
MTLBuffer src = _device.NewBuffer((ulong)data.Length, MTLResourceOptions.ResourceStorageModeManaged);
var span = new Span<byte>(src.Contents.ToPointer(), data.Length);
data.CopyTo(span);
src.DidModifyRange(new NSRange
{
mtlBuffer.DidModifyRange(new NSRange
{
location = (ulong)offset,
length = (ulong)data.Length
});
}
location = 0,
length = (ulong)data.Length
});
MTLBuffer dst = new(Unsafe.As<BufferHandle, IntPtr>(ref buffer));
blitEncoder.CopyFromBuffer(src, 0, dst, (ulong)offset, (ulong)data.Length);
}
public void UpdateCounters()