mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-19 03:02:08 +00:00
implement texture get data
This commit is contained in:
parent
704a78c11f
commit
68f6c08287
1 changed files with 29 additions and 1 deletions
|
@ -196,7 +196,35 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public PinnedSpan<byte> GetData(int layer, int level)
|
public PinnedSpan<byte> GetData(int layer, int level)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
|
||||||
|
|
||||||
|
ulong bytesPerRow = (ulong)Info.GetMipStride(level);
|
||||||
|
ulong length = bytesPerRow * (ulong)Info.Height;
|
||||||
|
ulong bytesPerImage = 0;
|
||||||
|
if (MTLTexture.TextureType == MTLTextureType.Type3D)
|
||||||
|
{
|
||||||
|
bytesPerImage = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
var mtlBuffer = _device.NewBuffer(length, MTLResourceOptions.ResourceStorageModeShared);
|
||||||
|
|
||||||
|
blitCommandEncoder.CopyFromTexture(
|
||||||
|
MTLTexture,
|
||||||
|
(ulong)layer,
|
||||||
|
(ulong)level,
|
||||||
|
new MTLOrigin(),
|
||||||
|
new MTLSize { width = MTLTexture.Width, height = MTLTexture.Height, depth = MTLTexture.Depth },
|
||||||
|
mtlBuffer,
|
||||||
|
0,
|
||||||
|
bytesPerRow,
|
||||||
|
bytesPerImage
|
||||||
|
);
|
||||||
|
|
||||||
|
// TODO: Dispose the buffer
|
||||||
|
return new PinnedSpan<byte>(mtlBuffer.Contents.ToPointer(), (int)length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle array formats
|
// TODO: Handle array formats
|
||||||
|
|
Loading…
Reference in a new issue