Struct vulkano::image::sampler::SamplerCreateInfo
source · pub struct SamplerCreateInfo {Show 13 fields
pub mag_filter: Filter,
pub min_filter: Filter,
pub mipmap_mode: SamplerMipmapMode,
pub address_mode: [SamplerAddressMode; 3],
pub mip_lod_bias: f32,
pub anisotropy: Option<f32>,
pub compare: Option<CompareOp>,
pub lod: RangeInclusive<f32>,
pub border_color: BorderColor,
pub unnormalized_coordinates: bool,
pub reduction_mode: SamplerReductionMode,
pub sampler_ycbcr_conversion: Option<Arc<SamplerYcbcrConversion>>,
pub _ne: NonExhaustive,
}
Expand description
Parameters to create a new Sampler
.
Fields§
§mag_filter: Filter
How the sampled value of a single mipmap should be calculated, when magnification is applied (LOD <= 0.0).
The default value is Nearest
.
min_filter: Filter
How the sampled value of a single mipmap should be calculated, when minification is applied (LOD > 0.0).
The default value is Nearest
.
mipmap_mode: SamplerMipmapMode
How the final sampled value should be calculated from the samples of individual mipmaps.
The default value is Nearest
.
address_mode: [SamplerAddressMode; 3]
How out-of-range texture coordinates should be treated, for the u
, v
and w
texture
coordinate indices respectively.
The default value is ClampToEdge
.
mip_lod_bias: f32
The bias value to be added to the base LOD before clamping.
The absolute value of the provided value must not exceed the
max_sampler_lod_bias
limit of the
device.
On portability subset
devices, if mip_lod_bias
is not 0.0
, the
sampler_mip_lod_bias
feature must be enabled on the device.
The default value is 0.0
.
anisotropy: Option<f32>
Whether anisotropic texel filtering is enabled (Some
), and the maximum anisotropy value
to use if it is enabled.
Anisotropic filtering is a special filtering mode that takes into account the differences in scaling between the horizontal and vertical framebuffer axes.
If set to Some
, the sampler_anisotropy
feature must be enabled on the device, the provided maximum value must not exceed the
max_sampler_anisotropy
limit, and
the Cubic
filter must not be used.
The default value is None
.
compare: Option<CompareOp>
Whether depth comparison is enabled (Some
), and the comparison operator to use if it is
enabled.
Depth comparison is an alternative mode for samplers that can be used in combination with
image views specifying the depth aspect. Instead of returning a value that is sampled from
the image directly, a comparison operation is applied between the sampled value and a
reference value that is specified as part of the operation. The result is binary: 1.0 if the
operation returns true
, 0.0 if it returns false
.
If set to Some
, the reduction_mode
must be set to
WeightedAverage
.
On portability subset
devices, if the sampler is going to be used as a mutable sampler (written to descriptor sets
rather than being an immutable part of a descriptor set layout), the
mutable_comparison_samplers
feature must be enabled on the device.
The default value is None
.
lod: RangeInclusive<f32>
The range that LOD values must be clamped to.
If the end of the range is set to LOD_CLAMP_NONE
, it is unbounded.
The default value is 0.0..=0.0
.
border_color: BorderColor
The border color to use if address_mode
is set to
ClampToBorder
.
The default value is FloatTransparentBlack
.
unnormalized_coordinates: bool
Whether unnormalized texture coordinates are enabled.
When a sampler is set to use unnormalized coordinates as input, the texture coordinates are not scaled by the size of the image, and therefore range up to the size of the image rather than 1.0. Enabling this comes with several restrictions:
min_filter
andmag_filter
must be equal.mipmap_mode
must beNearest
.- The
lod
range must be0.0..=0.0
. address_mode
for u and v must be eitherClampToEdge
orClampToBorder
.- Anisotropy and depth comparison must be disabled.
Some restrictions also apply to the image view being sampled:
- The view type must be
Dim1d
orDim2d
. Arrayed types are not allowed. - It must have a single mipmap level.
Finally, restrictions apply to the sampling operations that can be used in a shader:
- Only explicit LOD operations are allowed, implicit LOD operations are not.
- Sampling with projection is not allowed.
- Sampling with an LOD bias is not allowed.
- Sampling with an offset is not allowed.
The default value is false
.
reduction_mode: SamplerReductionMode
How the value sampled from a mipmap should be calculated from the selected
pixels, for the Linear
and Cubic
filters.
The default value is WeightedAverage
.
sampler_ycbcr_conversion: Option<Arc<SamplerYcbcrConversion>>
Adds a sampler YCbCr conversion to the sampler.
If set to Some
, several restrictions apply:
- If the
format
ofconversion
does not supportsampled_image_ycbcr_conversion_separate_reconstruction_filter
, thenmag_filter
andmin_filter
must be equal to thechroma_filter
ofconversion
. address_mode
for u, v and w must beClampToEdge
.- Anisotropy and unnormalized coordinates must be disabled.
- The
reduction_mode
must beWeightedAverage
.
In addition, the sampler must only be used as an immutable sampler within a descriptor set layout, and only in a combined image sampler descriptor.
The default value is None
.
_ne: NonExhaustive
Implementations§
source§impl SamplerCreateInfo
impl SamplerCreateInfo
sourcepub fn simple_repeat_linear() -> Self
pub fn simple_repeat_linear() -> Self
Shortcut for creating a sampler with linear sampling, linear mipmaps, and with the repeat mode for borders.
sourcepub fn simple_repeat_linear_no_mipmap() -> Self
pub fn simple_repeat_linear_no_mipmap() -> Self
Shortcut for creating a sampler with linear sampling, that only uses the main level of images, and with the repeat mode for borders.
Trait Implementations§
source§impl Clone for SamplerCreateInfo
impl Clone for SamplerCreateInfo
source§fn clone(&self) -> SamplerCreateInfo
fn clone(&self) -> SamplerCreateInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more