Handle Array Format SetData
This commit is contained in:
parent
aae9dc0c2e
commit
f7e97a30af
1 changed files with 17 additions and 15 deletions
|
@ -201,7 +201,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Handle array formats
|
|
||||||
public unsafe void SetData(IMemoryOwner<byte> data)
|
public unsafe void SetData(IMemoryOwner<byte> data)
|
||||||
{
|
{
|
||||||
var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
|
var blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
|
||||||
|
@ -215,14 +214,14 @@ namespace Ryujinx.Graphics.Metal
|
||||||
int height = Info.Height;
|
int height = Info.Height;
|
||||||
int depth = Info.Depth;
|
int depth = Info.Depth;
|
||||||
int levels = Info.GetLevelsClamped();
|
int levels = Info.GetLevelsClamped();
|
||||||
|
int layers = Info.GetLayers();
|
||||||
bool is3D = Info.Target == Target.Texture3D;
|
bool is3D = Info.Target == Target.Texture3D;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
for (int level = 0; level < levels; level++)
|
for (int level = 0; level < levels; level++)
|
||||||
{
|
{
|
||||||
int mipSize = Info.GetMipSize(level);
|
int mipSize = Info.GetMipSize2D(level);
|
||||||
|
|
||||||
int endOffset = offset + mipSize;
|
int endOffset = offset + mipSize;
|
||||||
|
|
||||||
if ((uint)endOffset > (uint)dataSpan.Length)
|
if ((uint)endOffset > (uint)dataSpan.Length)
|
||||||
|
@ -230,19 +229,22 @@ namespace Ryujinx.Graphics.Metal
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitCommandEncoder.CopyFromBuffer(
|
for (int layer = 0; layer < layers; layer++)
|
||||||
mtlBuffer,
|
{
|
||||||
(ulong)offset,
|
blitCommandEncoder.CopyFromBuffer(
|
||||||
(ulong)Info.GetMipStride(level),
|
mtlBuffer,
|
||||||
(ulong)mipSize,
|
(ulong)offset,
|
||||||
new MTLSize { width = (ulong)width, height = (ulong)height, depth = is3D ? (ulong)depth : 1 },
|
(ulong)Info.GetMipStride(level),
|
||||||
_mtlTexture,
|
(ulong)mipSize,
|
||||||
0,
|
new MTLSize { width = (ulong)width, height = (ulong)height, depth = is3D ? (ulong)depth : 1 },
|
||||||
(ulong)level,
|
_mtlTexture,
|
||||||
new MTLOrigin()
|
(ulong)layer,
|
||||||
);
|
(ulong)level,
|
||||||
|
new MTLOrigin()
|
||||||
|
);
|
||||||
|
|
||||||
offset += mipSize;
|
offset += mipSize;
|
||||||
|
}
|
||||||
|
|
||||||
width = Math.Max(1, width >> 1);
|
width = Math.Max(1, width >> 1);
|
||||||
height = Math.Max(1, height >> 1);
|
height = Math.Max(1, height >> 1);
|
||||||
|
|
Loading…
Reference in a new issue