mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-28 03:23:05 +00:00
Revise ISampler
This commit is contained in:
parent
b8c60e993a
commit
80340c98d3
6 changed files with 65 additions and 36 deletions
|
@ -4,7 +4,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
class CounterEvent : ICounterEvent
|
class CounterEvent : ICounterEvent
|
||||||
{
|
{
|
||||||
|
|
||||||
public CounterEvent()
|
public CounterEvent()
|
||||||
{
|
{
|
||||||
Invalid = false;
|
Invalid = false;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
Logger.Error?.PrintMsg(LogClass.Gpu, $"Failed to create Library: {StringHelper.String(error.LocalizedDescription)}");
|
Logger.Error?.PrintMsg(LogClass.Gpu, $"Failed to create Library: {StringHelper.String(error.LocalizedDescription)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
BlitShader = new HelperShader(device, library, "vertexBlit", "fragmentBlit");
|
BlitShader = new HelperShader(library, "vertexBlit", "fragmentBlit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
public readonly MTLFunction VertexFunction;
|
public readonly MTLFunction VertexFunction;
|
||||||
public readonly MTLFunction FragmentFunction;
|
public readonly MTLFunction FragmentFunction;
|
||||||
|
|
||||||
public HelperShader(MTLDevice device, MTLLibrary library, string vertex, string fragment)
|
public HelperShader(MTLLibrary library, string vertex, string fragment)
|
||||||
{
|
{
|
||||||
VertexFunction = library.NewFunction(StringHelper.NSString(vertex));
|
VertexFunction = library.NewFunction(StringHelper.NSString(vertex));
|
||||||
FragmentFunction = library.NewFunction(StringHelper.NSString(fragment));
|
FragmentFunction = library.NewFunction(StringHelper.NSString(fragment));
|
||||||
|
|
|
@ -84,25 +84,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public ISampler CreateSampler(SamplerCreateInfo info)
|
public ISampler CreateSampler(SamplerCreateInfo info)
|
||||||
{
|
{
|
||||||
(MTLSamplerMinMagFilter minFilter, MTLSamplerMipFilter mipFilter) = info.MinFilter.Convert();
|
return new Sampler(_device, info);
|
||||||
|
|
||||||
var sampler = _device.NewSamplerState(new MTLSamplerDescriptor
|
|
||||||
{
|
|
||||||
BorderColor = MTLSamplerBorderColor.TransparentBlack,
|
|
||||||
MinFilter = minFilter,
|
|
||||||
MagFilter = info.MagFilter.Convert(),
|
|
||||||
MipFilter = mipFilter,
|
|
||||||
CompareFunction = info.CompareOp.Convert(),
|
|
||||||
LodMinClamp = info.MinLod,
|
|
||||||
LodMaxClamp = info.MaxLod,
|
|
||||||
LodAverage = false,
|
|
||||||
MaxAnisotropy = (uint)info.MaxAnisotropy,
|
|
||||||
SAddressMode = info.AddressU.Convert(),
|
|
||||||
TAddressMode = info.AddressV.Convert(),
|
|
||||||
RAddressMode = info.AddressP.Convert()
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Sampler(sampler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITexture CreateTexture(TextureCreateInfo info)
|
public ITexture CreateTexture(TextureCreateInfo info)
|
||||||
|
|
|
@ -323,7 +323,6 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
|
|
||||||
// TODO: Support topology re-indexing to provide support for TriangleFans
|
// TODO: Support topology re-indexing to provide support for TriangleFans
|
||||||
var primitiveType = _renderEncoderState.Topology.Convert();
|
var primitiveType = _renderEncoderState.Topology.Convert();
|
||||||
|
|
||||||
|
@ -332,26 +331,36 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void DrawIndexedIndirect(BufferRange indirectBuffer)
|
public void DrawIndexedIndirect(BufferRange indirectBuffer)
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirect(BufferRange indirectBuffer)
|
public void DrawIndirect(BufferRange indirectBuffer)
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion)
|
public void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion)
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,15 +446,10 @@ namespace Ryujinx.Graphics.Metal
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetImage(int binding, ITexture texture, Format imageFormat)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetLineParameters(float width, bool smooth)
|
public void SetLineParameters(float width, bool smooth)
|
||||||
{
|
{
|
||||||
// Not supported in Metal
|
// Not supported in Metal
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Wide-line is not supported without private Metal API");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLogicOpState(bool enable, LogicalOp op)
|
public void SetLogicOpState(bool enable, LogicalOp op)
|
||||||
|
@ -493,7 +497,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
Program prg = (Program)program;
|
Program prg = (Program)program;
|
||||||
|
|
||||||
if (prg.VertexFunction == null)
|
if (prg.VertexFunction == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Logger.Error?.PrintMsg(LogClass.Gpu, "Invalid Vertex Function!");
|
Logger.Error?.PrintMsg(LogClass.Gpu, "Invalid Vertex Function!");
|
||||||
return;
|
return;
|
||||||
|
@ -556,7 +560,10 @@ namespace Ryujinx.Graphics.Metal
|
||||||
fixed (MTLScissorRect* pMtlScissorRects = mtlScissorRects)
|
fixed (MTLScissorRect* pMtlScissorRects = mtlScissorRects)
|
||||||
{
|
{
|
||||||
// TODO: Fix this function which currently wont accept pointer as intended
|
// TODO: Fix this function which currently wont accept pointer as intended
|
||||||
// _renderCommandEncoder.SetScissorRects(pMtlScissorRects, regions.Length);
|
if (_currentEncoderType == EncoderType.Render)
|
||||||
|
{
|
||||||
|
// new MTLRenderCommandEncoder(_currentEncoder.Value).SetScissorRects(pMtlScissorRects, (ulong)regions.Length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,6 +628,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
attrib.Format = MTLVertexFormat.Float4;
|
attrib.Format = MTLVertexFormat.Float4;
|
||||||
attrib.BufferIndex = (ulong)vertexAttribs[i].BufferIndex;
|
attrib.BufferIndex = (ulong)vertexAttribs[i].BufferIndex;
|
||||||
attrib.Offset = (ulong)vertexAttribs[i].Offset;
|
attrib.Offset = (ulong)vertexAttribs[i].Offset;
|
||||||
|
_vertexDescriptor.Attributes.SetObject(attrib, (ulong)i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -668,17 +676,26 @@ namespace Ryujinx.Graphics.Metal
|
||||||
fixed (MTLViewport* pMtlViewports = mtlViewports)
|
fixed (MTLViewport* pMtlViewports = mtlViewports)
|
||||||
{
|
{
|
||||||
// TODO: Fix this function which currently wont accept pointer as intended
|
// TODO: Fix this function which currently wont accept pointer as intended
|
||||||
// _renderCommandEncoder.SetViewports(pMtlViewports, viewports.Length);
|
if (_currentEncoderType == EncoderType.Render)
|
||||||
|
{
|
||||||
|
// new MTLRenderCommandEncoder(_currentEncoder.Value).SetViewports(pMtlViewports, (ulong)regions.Length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TextureBarrier()
|
public void TextureBarrier()
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
|
// renderCommandEncoder.MemoryBarrier(MTLBarrierScope.Textures, );
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TextureBarrierTiled()
|
public void TextureBarrierTiled()
|
||||||
{
|
{
|
||||||
|
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
||||||
|
|
||||||
|
// renderCommandEncoder.MemoryBarrier(MTLBarrierScope.Textures, );
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,40 @@
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using SharpMetal.Metal;
|
using SharpMetal.Metal;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Metal
|
namespace Ryujinx.Graphics.Metal
|
||||||
{
|
{
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
class Sampler : ISampler
|
class Sampler : ISampler
|
||||||
{
|
{
|
||||||
// private readonly MTLSamplerState _mtlSamplerState;
|
private readonly MTLSamplerState _mtlSamplerState;
|
||||||
|
|
||||||
public Sampler(MTLSamplerState mtlSamplerState)
|
public Sampler(MTLDevice device, SamplerCreateInfo info)
|
||||||
{
|
{
|
||||||
// _mtlSamplerState = mtlSamplerState;
|
(MTLSamplerMinMagFilter minFilter, MTLSamplerMipFilter mipFilter) = info.MinFilter.Convert();
|
||||||
|
|
||||||
|
var samplerState = device.NewSamplerState(new MTLSamplerDescriptor
|
||||||
|
{
|
||||||
|
BorderColor = MTLSamplerBorderColor.TransparentBlack,
|
||||||
|
MinFilter = minFilter,
|
||||||
|
MagFilter = info.MagFilter.Convert(),
|
||||||
|
MipFilter = mipFilter,
|
||||||
|
CompareFunction = info.CompareOp.Convert(),
|
||||||
|
LodMinClamp = info.MinLod,
|
||||||
|
LodMaxClamp = info.MaxLod,
|
||||||
|
LodAverage = false,
|
||||||
|
MaxAnisotropy = (uint)info.MaxAnisotropy,
|
||||||
|
SAddressMode = info.AddressU.Convert(),
|
||||||
|
TAddressMode = info.AddressV.Convert(),
|
||||||
|
RAddressMode = info.AddressP.Convert()
|
||||||
|
});
|
||||||
|
|
||||||
|
_mtlSamplerState = samplerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MTLSamplerState GetSampler()
|
||||||
|
{
|
||||||
|
return _mtlSamplerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -88,6 +88,12 @@ 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 blitCommandEncoder = _pipeline.GetOrCreateBlitEncoder();
|
||||||
|
|
||||||
|
if (destination is Texture destinationTexture)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +126,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
public ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel)
|
public ITexture CreateView(TextureCreateInfo info, int firstLayer, int firstLevel)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
return this;
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PinnedSpan<byte> GetData()
|
public PinnedSpan<byte> GetData()
|
||||||
|
|
Loading…
Reference in a new issue