2023-07-28 01:51:20 +00:00
|
|
|
using Ryujinx.Graphics.GAL;
|
|
|
|
using SharpMetal.Metal;
|
2024-05-14 18:51:53 +00:00
|
|
|
using System;
|
2024-05-15 13:03:53 +00:00
|
|
|
using System.Runtime.Versioning;
|
2023-07-28 01:51:20 +00:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Metal
|
|
|
|
{
|
2024-03-19 18:05:09 +00:00
|
|
|
[SupportedOSPlatform("macos")]
|
2023-08-03 18:50:49 +00:00
|
|
|
class Sampler : ISampler
|
2023-07-28 01:51:20 +00:00
|
|
|
{
|
2024-03-19 18:05:09 +00:00
|
|
|
private readonly MTLSamplerState _mtlSamplerState;
|
2023-07-28 01:51:20 +00:00
|
|
|
|
2024-03-19 18:05:09 +00:00
|
|
|
public Sampler(MTLDevice device, SamplerCreateInfo info)
|
2023-07-28 01:51:20 +00:00
|
|
|
{
|
2024-03-19 18:05:09 +00:00
|
|
|
(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,
|
2024-05-14 18:51:53 +00:00
|
|
|
MaxAnisotropy = Math.Max((uint)info.MaxAnisotropy, 1),
|
2024-03-19 18:05:09 +00:00
|
|
|
SAddressMode = info.AddressU.Convert(),
|
|
|
|
TAddressMode = info.AddressV.Convert(),
|
2024-06-25 13:25:31 +00:00
|
|
|
RAddressMode = info.AddressP.Convert(),
|
|
|
|
SupportArgumentBuffers = true
|
2024-03-19 18:05:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
_mtlSamplerState = samplerState;
|
|
|
|
}
|
|
|
|
|
2024-05-18 22:54:55 +00:00
|
|
|
public Sampler(MTLSamplerState samplerState)
|
|
|
|
{
|
|
|
|
_mtlSamplerState = samplerState;
|
|
|
|
}
|
|
|
|
|
2024-03-19 18:05:09 +00:00
|
|
|
public MTLSamplerState GetSampler()
|
|
|
|
{
|
|
|
|
return _mtlSamplerState;
|
2023-07-28 01:51:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
2024-05-23 17:15:23 +00:00
|
|
|
_mtlSamplerState.Dispose();
|
2023-07-28 01:51:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|