mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-21 01:02:01 +00:00
CopyTo Buffer
This commit is contained in:
parent
08126b26b1
commit
7a2ab77b4d
1 changed files with 35 additions and 7 deletions
|
@ -2,6 +2,7 @@ using Ryujinx.Common.Memory;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using SharpMetal.Metal;
|
using SharpMetal.Metal;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
|
@ -100,15 +101,42 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
|
public void CopyTo(ITexture destination, Extents2D srcRegion, Extents2D dstRegion, bool linearFilter)
|
||||||
{
|
{
|
||||||
var samplerDescriptor = new MTLSamplerDescriptor();
|
throw new NotImplementedException();
|
||||||
samplerDescriptor.MinFilter = linearFilter ? MTLSamplerMinMagFilter.Linear : MTLSamplerMinMagFilter.Nearest;
|
|
||||||
samplerDescriptor.MagFilter = linearFilter ? MTLSamplerMinMagFilter.Linear : MTLSamplerMinMagFilter.Nearest;
|
|
||||||
var samplerState = _device.NewSamplerState(samplerDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTo(BufferRange range, int layer, int level, int stride)
|
public void CopyTo(BufferRange range, int layer, int level, int stride)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
MTLBlitCommandEncoder blitCommandEncoder;
|
||||||
|
|
||||||
|
if (_pipeline.CurrentEncoder is MTLBlitCommandEncoder encoder)
|
||||||
|
{
|
||||||
|
blitCommandEncoder = encoder;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blitCommandEncoder = _pipeline.BeginBlitPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong bytesPerRow = (ulong)Info.GetMipStride(level);
|
||||||
|
ulong bytesPerImage = 0;
|
||||||
|
if (MTLTexture.TextureType == MTLTextureType.Type3D)
|
||||||
|
{
|
||||||
|
bytesPerImage = bytesPerRow * (ulong)Info.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
var handle = range.Handle;
|
||||||
|
MTLBuffer mtlBuffer = new(Unsafe.As<BufferHandle, IntPtr>(ref handle));
|
||||||
|
|
||||||
|
blitCommandEncoder.CopyFromTexture(
|
||||||
|
MTLTexture,
|
||||||
|
(ulong)layer,
|
||||||
|
(ulong)level,
|
||||||
|
new MTLOrigin(),
|
||||||
|
new MTLSize { width = MTLTexture.Width, height = MTLTexture.Height, depth = MTLTexture.Depth },
|
||||||
|
mtlBuffer,
|
||||||
|
(ulong)range.Offset,
|
||||||
|
bytesPerRow,
|
||||||
|
bytesPerImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel)
|
public ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel)
|
||||||
|
@ -163,7 +191,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
0,
|
0,
|
||||||
bytesPerRow,
|
bytesPerRow,
|
||||||
bytesPerImage,
|
bytesPerImage,
|
||||||
new MTLSize { width = MTLTexture.Width, height = MTLTexture.Height },
|
new MTLSize { width = MTLTexture.Width, height = MTLTexture.Height, depth = MTLTexture.Depth},
|
||||||
MTLTexture,
|
MTLTexture,
|
||||||
(ulong)layer,
|
(ulong)layer,
|
||||||
(ulong)level,
|
(ulong)level,
|
||||||
|
@ -204,7 +232,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
0,
|
0,
|
||||||
bytesPerRow,
|
bytesPerRow,
|
||||||
bytesPerImage,
|
bytesPerImage,
|
||||||
new MTLSize { width = (ulong)region.Width, height = (ulong)region.Height },
|
new MTLSize { width = (ulong)region.Width, height = (ulong)region.Height, depth = 1 },
|
||||||
MTLTexture,
|
MTLTexture,
|
||||||
(ulong)layer,
|
(ulong)layer,
|
||||||
(ulong)level,
|
(ulong)level,
|
||||||
|
|
Loading…
Reference in a new issue