pub struct Sampler { /* private fields */ }
Expand description
Describes how to retrieve data from a sampled image within a shader.
Examples
A simple sampler for most usages:
use vulkano::sampler::{Sampler, SamplerCreateInfo};
let _sampler = Sampler::new(device.clone(), SamplerCreateInfo::simple_repeat_linear_no_mipmap());
More detailed sampler creation:
use vulkano::sampler::{Filter, Sampler, SamplerAddressMode, SamplerCreateInfo};
let _sampler = Sampler::new(device.clone(), SamplerCreateInfo {
mag_filter: Filter::Linear,
min_filter: Filter::Linear,
address_mode: [SamplerAddressMode::Repeat; 3],
mip_lod_bias: 1.0,
lod: 0.0..=100.0,
..Default::default()
})
.unwrap();
Implementations
sourceimpl Sampler
impl Sampler
sourcepub fn new(
device: Arc<Device>,
create_info: SamplerCreateInfo
) -> Result<Arc<Sampler>, SamplerCreationError>
pub fn new(
device: Arc<Device>,
create_info: SamplerCreateInfo
) -> Result<Arc<Sampler>, SamplerCreationError>
Creates a new Sampler
.
Panics
- Panics if
create_info.anisotropy
isSome
and contains a value less than 1.0. - Panics if
create_info.lod
is empty.
sourcepub unsafe fn from_handle(
device: Arc<Device>,
handle: Sampler,
create_info: SamplerCreateInfo
) -> Arc<Sampler>
pub unsafe fn from_handle(
device: Arc<Device>,
handle: Sampler,
create_info: SamplerCreateInfo
) -> Arc<Sampler>
Creates a new Sampler
from a raw object handle.
Safety
handle
must be a valid Vulkan object handle created fromdevice
.create_info
must match the info used to create the object.
sourcepub fn check_can_sample<I>(
&self,
image_view: &I
) -> Result<(), SamplerImageViewIncompatibleError>where
I: ImageViewAbstract + ?Sized,
pub fn check_can_sample<I>(
&self,
image_view: &I
) -> Result<(), SamplerImageViewIncompatibleError>where
I: ImageViewAbstract + ?Sized,
Checks whether this sampler is compatible with image_view
.
sourcepub fn address_mode(&self) -> [SamplerAddressMode; 3]
pub fn address_mode(&self) -> [SamplerAddressMode; 3]
Returns the address modes for the u, v and w coordinates.
sourcepub fn anisotropy(&self) -> Option<f32>
pub fn anisotropy(&self) -> Option<f32>
Returns the anisotropy mode.
sourcepub fn border_color(&self) -> Option<BorderColor>
pub fn border_color(&self) -> Option<BorderColor>
Returns the border color if one is used by this sampler.
sourcepub fn compare(&self) -> Option<CompareOp>
pub fn compare(&self) -> Option<CompareOp>
Returns the compare operation if the sampler is a compare-mode sampler.
sourcepub fn lod(&self) -> RangeInclusive<f32>
pub fn lod(&self) -> RangeInclusive<f32>
Returns the LOD range.
sourcepub fn mag_filter(&self) -> Filter
pub fn mag_filter(&self) -> Filter
Returns the magnification filter.
sourcepub fn min_filter(&self) -> Filter
pub fn min_filter(&self) -> Filter
Returns the minification filter.
sourcepub fn mip_lod_bias(&self) -> f32
pub fn mip_lod_bias(&self) -> f32
Returns the mip LOD bias.
sourcepub fn mipmap_mode(&self) -> SamplerMipmapMode
pub fn mipmap_mode(&self) -> SamplerMipmapMode
Returns the mipmap mode.
sourcepub fn reduction_mode(&self) -> SamplerReductionMode
pub fn reduction_mode(&self) -> SamplerReductionMode
Returns the reduction mode.
sourcepub fn sampler_ycbcr_conversion(&self) -> Option<&Arc<SamplerYcbcrConversion>>
pub fn sampler_ycbcr_conversion(&self) -> Option<&Arc<SamplerYcbcrConversion>>
Returns a reference to the sampler YCbCr conversion of this sampler, if any.
sourcepub fn unnormalized_coordinates(&self) -> bool
pub fn unnormalized_coordinates(&self) -> bool
Returns true if the sampler uses unnormalized coordinates.