1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-12 03:52:02 +00:00
Ryujinx/Ryujinx.Graphics.Gpu/Image/Sampler.cs

68 lines
2.1 KiB
C#
Raw Normal View History

2019-10-13 07:02:07 +01:00
using Ryujinx.Graphics.GAL;
using System;
namespace Ryujinx.Graphics.Gpu.Image
{
/// <summary>
/// Cached sampler entry for sampler pools.
/// </summary>
2019-10-13 07:02:07 +01:00
class Sampler : IDisposable
{
/// <summary>
/// Host sampler object.
/// </summary>
2019-10-13 07:02:07 +01:00
public ISampler HostSampler { get; }
/// <summary>
/// Creates a new instance of the cached sampler.
/// </summary>
/// <param name="context">The GPU context the sampler belongs to</param>
/// <param name="descriptor">The Maxwell sampler descriptor</param>
2019-10-13 07:02:07 +01:00
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(
descriptor.BorderColorR,
descriptor.BorderColorG,
descriptor.BorderColorB,
descriptor.BorderColorA);
2019-10-13 07:02:07 +01:00
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));
}
/// <summary>
/// Disposes the host sampler object.
/// </summary>
2019-10-13 07:02:07 +01:00
public void Dispose()
{
HostSampler.Dispose();
}
}
}