mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 19:13:04 +00:00
Delete and Get Data from Buffer
This commit is contained in:
parent
da9a194023
commit
8da7c42cf8
2 changed files with 23 additions and 22 deletions
|
@ -89,22 +89,7 @@ namespace Ryujinx.Graphics.Metal
|
|||
|
||||
public ITexture CreateTexture(TextureCreateInfo info)
|
||||
{
|
||||
MTLTextureDescriptor descriptor = new()
|
||||
{
|
||||
PixelFormat = FormatCapabilities.ConvertToMTLFormat(info.Format),
|
||||
TextureType = info.Target.Convert(),
|
||||
Width = (ulong)info.Width,
|
||||
Height = (ulong)info.Height,
|
||||
MipmapLevelCount = (ulong)info.Levels,
|
||||
SampleCount = (ulong)info.Samples,
|
||||
};
|
||||
|
||||
return CreateTextureView(info);
|
||||
}
|
||||
|
||||
internal Texture CreateTextureView(TextureCreateInfo info)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return new Texture(_device, _pipeline, info);
|
||||
}
|
||||
|
||||
public bool PrepareHostMapping(IntPtr address, ulong size)
|
||||
|
@ -120,12 +105,14 @@ namespace Ryujinx.Graphics.Metal
|
|||
|
||||
public void DeleteBuffer(BufferHandle buffer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
MTLBuffer mtlBuffer = new(Unsafe.As<BufferHandle, IntPtr>(ref buffer));
|
||||
mtlBuffer.SetPurgeableState(MTLPurgeableState.Empty);
|
||||
}
|
||||
|
||||
public PinnedSpan<byte> GetBufferData(BufferHandle buffer, int offset, int size)
|
||||
public unsafe PinnedSpan<byte> GetBufferData(BufferHandle buffer, int offset, int size)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
MTLBuffer mtlBuffer = new(Unsafe.As<BufferHandle, IntPtr>(ref buffer));
|
||||
return new PinnedSpan<byte>(IntPtr.Add(mtlBuffer.Contents, offset).ToPointer(), size);
|
||||
}
|
||||
|
||||
public Capabilities GetCapabilities()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue