using Ryujinx.Graphics.GAL;
using System;
namespace Ryujinx.Graphics.Gpu.Image
{
///
/// Cached sampler entry for sampler pools.
///
class Sampler : IDisposable
{
///
/// Host sampler object.
///
public ISampler HostSampler { get; }
///
/// Creates a new instance of the cached sampler.
///
/// The GPU context the sampler belongs to
/// The Maxwell sampler descriptor
public Sampler(GpuContext context, SamplerDescriptor descriptor)
{
MinFilter minFilter = descriptor.UnpackMinFilter();
MagFilter magFilter = descriptor.UnpackMagFilter();
AddressMode addressU = descriptor.UnpackAddressU();
AddressMode addressV = descriptor.UnpackAddressV();
AddressMode addressP = descriptor.UnpackAddressP();
CompareMode compareMode = descriptor.UnpackCompareMode();
CompareOp compareOp = descriptor.UnpackCompareOp();
ColorF color = new ColorF(0, 0, 0, 0);
float minLod = descriptor.UnpackMinLod();
float maxLod = descriptor.UnpackMaxLod();
float mipLodBias = descriptor.UnpackMipLodBias();
float maxAnisotropy = descriptor.UnpackMaxAnisotropy();
HostSampler = context.Renderer.CreateSampler(new SamplerCreateInfo(
minFilter,
magFilter,
addressU,
addressV,
addressP,
compareMode,
compareOp,
color,
minLod,
maxLod,
mipLodBias,
maxAnisotropy));
}
///
/// Disposes the host sampler object.
///
public void Dispose()
{
HostSampler.Dispose();
}
}
}