Delete and Get Data from Buffer

This commit is contained in:
Isaac Marovitz 2023-07-28 11:55:52 -04:00 committed by Isaac Marovitz
parent da9a194023
commit 8da7c42cf8
2 changed files with 23 additions and 22 deletions

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Metal
public int Width => Info.Width;
public int Height => Info.Height;
public Texture(MTLDevice device, Pipeline pipeline, TextureCreateInfo info, int firstLayer, int firstLevel)
public Texture(MTLDevice device, Pipeline pipeline, TextureCreateInfo info)
{
_device = device;
_pipeline = pipeline;
@ -114,9 +114,23 @@ namespace Ryujinx.Graphics.Metal
throw new NotImplementedException();
}
public void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
public unsafe void SetData(SpanOrArray<byte> data, int layer, int level, Rectangle<int> region)
{
throw new NotImplementedException();
// TODO: Figure out bytesPerRow
// For an ordinary or packed pixel format, the stride, in bytes, between rows of source data.
// For a compressed pixel format, the stride is the number of bytes from the beginning of one row of blocks to the beginning of the next.
if (MTLTexture.IsSparse)
ulong bytesPerRow = 0;
var mtlRegion = new MTLRegion
{
origin = new MTLOrigin { x = (ulong)region.X, y = (ulong)region.Y },
size = new MTLSize { width = (ulong)region.Width, height = (ulong)region.Height },
};
fixed (byte* pData = data.Span)
{
MTLTexture.ReplaceRegion(mtlRegion, (ulong)level, (ulong)layer, new IntPtr(pData), bytesPerRow, 0);
}
}
public void SetStorage(BufferRange buffer)