logo
pub struct SamplerBuilder { /* private fields */ }
Expand description

Used to construct a new Sampler.

Implementations

Creates the Sampler.

How the sampled value of a single mipmap should be calculated, for both magnification and minification.

The default value is Nearest.

How the sampled value of a single mipmap should be calculated, when magnification is applied (LOD <= 0.0).

The default value is Nearest.

How the sampled value of a single mipmap should be calculated, when minification is applied (LOD > 0.0).

The default value is Nearest.

How the final sampled value should be calculated from the samples of individual mipmaps.

The default value is Nearest.

How out-of-range texture coordinates should be treated, for all texture coordinate indices.

The default value is ClampToEdge.

How out-of-range texture coordinates should be treated, for the u coordinate.

The default value is ClampToEdge.

How out-of-range texture coordinates should be treated, for the v coordinate.

The default value is ClampToEdge.

How out-of-range texture coordinates should be treated, for the w coordinate.

The default value is ClampToEdge.

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.

The default value is 0.0.

Sets whether anisotropic texel filtering is enabled (Some) and provides the maximum anisotropy value 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.

Panics
  • Panics if anisotropy is Some and contains a value less than 1.0.

Sets whether depth comparison is enabled (Some) and provides a comparison operator 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.

The default value is None.

The range that LOD values must be clamped to.

The default value is 0.0...

Panics
  • Panics if range is empty.

The minimum value that LOD values must be clamped to. The maximum LOD is left unbounded.

The default value is 0.0...

Panics
  • Panics if min is greater than 1000.0.

The border color to use if address_mode is set to ClampToBorder.

The default value is FloatTransparentBlack.

Sets 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.

Sets 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.

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.

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

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

Builds a pointer to this type from a raw pointer.

Returns true if the size is suitable to store a type like this.

Returns the size of an individual element.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.