using SDL2_gpuCS;
namespace MoonWorks.Graphics;
///
/// All of the information that is used to create a sampler.
///
public struct SamplerCreateInfo
{
///
/// Minification filter mode. Used when the image is downscaled.
///
public Filter MinFilter;
///
/// Magnification filter mode. Used when the image is upscaled.
///
public Filter MagFilter;
///
/// Filter mode applied to mipmap lookups.
///
public SamplerMipmapMode MipmapMode;
///
/// Horizontal addressing mode.
///
public SamplerAddressMode AddressModeU;
///
/// Vertical addressing mode.
///
public SamplerAddressMode AddressModeV;
///
/// Depth addressing mode.
///
public SamplerAddressMode AddressModeW;
///
/// Bias value added to mipmap level of detail calculation.
///
public float MipLodBias;
///
/// Enables anisotropic filtering.
///
public bool AnisotropyEnable;
///
/// Maximum anisotropy value.
///
public float MaxAnisotropy;
public bool CompareEnable;
public CompareOp CompareOp;
///
/// Clamps the LOD value to a specified minimum.
///
public float MinLod;
///
/// Clamps the LOD value to a specified maximum.
///
public float MaxLod;
///
/// If an address mode is set to ClampToBorder, will replace color with this color when samples are outside the [0, 1) range.
///
public BorderColor BorderColor;
public static readonly SamplerCreateInfo AnisotropicClamp = new SamplerCreateInfo
{
MinFilter = Filter.Linear,
MagFilter = Filter.Linear,
MipmapMode = SamplerMipmapMode.Linear,
AddressModeU = SamplerAddressMode.ClampToEdge,
AddressModeV = SamplerAddressMode.ClampToEdge,
AddressModeW = SamplerAddressMode.ClampToEdge,
CompareEnable = false,
AnisotropyEnable = true,
MaxAnisotropy = 4,
MipLodBias = 0f,
MinLod = 0,
MaxLod = 1000 /* VK_LOD_CLAMP_NONE */
};
public static readonly SamplerCreateInfo AnisotropicWrap = new SamplerCreateInfo
{
MinFilter = Filter.Linear,
MagFilter = Filter.Linear,
MipmapMode = SamplerMipmapMode.Linear,
AddressModeU = SamplerAddressMode.Repeat,
AddressModeV = SamplerAddressMode.Repeat,
AddressModeW = SamplerAddressMode.Repeat,
CompareEnable = false,
AnisotropyEnable = true,
MaxAnisotropy = 4,
MipLodBias = 0f,
MinLod = 0,
MaxLod = 1000 /* VK_LOD_CLAMP_NONE */
};
public static readonly SamplerCreateInfo LinearClamp = new SamplerCreateInfo
{
MinFilter = Filter.Linear,
MagFilter = Filter.Linear,
MipmapMode = SamplerMipmapMode.Linear,
AddressModeU = SamplerAddressMode.ClampToEdge,
AddressModeV = SamplerAddressMode.ClampToEdge,
AddressModeW = SamplerAddressMode.ClampToEdge,
CompareEnable = false,
AnisotropyEnable = false,
MipLodBias = 0f,
MinLod = 0,
MaxLod = 1000
};
public static readonly SamplerCreateInfo LinearWrap = new SamplerCreateInfo
{
MinFilter = Filter.Linear,
MagFilter = Filter.Linear,
MipmapMode = SamplerMipmapMode.Linear,
AddressModeU = SamplerAddressMode.Repeat,
AddressModeV = SamplerAddressMode.Repeat,
AddressModeW = SamplerAddressMode.Repeat,
CompareEnable = false,
AnisotropyEnable = false,
MipLodBias = 0f,
MinLod = 0,
MaxLod = 1000
};
public static readonly SamplerCreateInfo PointClamp = new SamplerCreateInfo
{
MinFilter = Filter.Nearest,
MagFilter = Filter.Nearest,
MipmapMode = SamplerMipmapMode.Nearest,
AddressModeU = SamplerAddressMode.ClampToEdge,
AddressModeV = SamplerAddressMode.ClampToEdge,
AddressModeW = SamplerAddressMode.ClampToEdge,
CompareEnable = false,
AnisotropyEnable = false,
MipLodBias = 0f,
MinLod = 0,
MaxLod = 1000
};
public static readonly SamplerCreateInfo PointWrap = new SamplerCreateInfo
{
MinFilter = Filter.Nearest,
MagFilter = Filter.Nearest,
MipmapMode = SamplerMipmapMode.Nearest,
AddressModeU = SamplerAddressMode.Repeat,
AddressModeV = SamplerAddressMode.Repeat,
AddressModeW = SamplerAddressMode.Repeat,
CompareEnable = false,
AnisotropyEnable = false,
MipLodBias = 0f,
MinLod = 0,
MaxLod = 1000
};
public SDL_Gpu.SamplerCreateInfo ToSDL()
{
return new SDL_Gpu.SamplerCreateInfo
{
MinFilter = (SDL_Gpu.Filter) MinFilter,
MagFilter = (SDL_Gpu.Filter) MagFilter,
MipmapMode = (SDL_Gpu.SamplerMipmapMode) MipmapMode,
AddressModeU = (SDL_Gpu.SamplerAddressMode) AddressModeU,
AddressModeV = (SDL_Gpu.SamplerAddressMode) AddressModeV,
AddressModeW = (SDL_Gpu.SamplerAddressMode) AddressModeW,
MipLodBias = MipLodBias,
AnisotropyEnable = Conversions.BoolToByte(AnisotropyEnable),
MaxAnisotropy = MaxAnisotropy,
CompareEnable = Conversions.BoolToByte(CompareEnable),
CompareOp = (SDL_Gpu.CompareOp) CompareOp,
MinLod = MinLod,
MaxLod = MaxLod,
BorderColor = (SDL_Gpu.BorderColor) BorderColor
};
}
}