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 and mag_filter must be equal.
  • mipmap_mode must be Nearest.
  • The lod range must be 0.0..=0.0.
  • address_mode for u and v must be either ClampToEdge or ClampToBorder.
  • Anisotropy and depth comparison must be disabled.

Some restrictions also apply to the image view being sampled:

  • The view type must be Dim1d or Dim2d. 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 of conversion does not support sampled_image_ycbcr_conversion_separate_reconstruction_filter, then mag_filter and min_filter must be equal to the chroma_filter of conversion.
  • address_mode for u, v and w must be ClampToEdge.
  • Anisotropy and unnormalized coordinates must be disabled.
  • The reduction_mode must be WeightedAverage.

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

Shortcut for creating a sampler with linear sampling, linear mipmaps, and with the repeat mode for borders.

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.