Struct vulkano::sampler::Sampler
[−]
[src]
pub struct Sampler { /* fields omitted */ }
Describes how to retrieve data from an image within a shader.
Methods
impl Sampler
[src]
fn simple_repeat_linear(device: Arc<Device>) -> Arc<Sampler>
Shortcut for creating a sampler with linear sampling, linear mipmaps, and with the repeat mode for borders.
Useful for prototyping, but can also be used in real projects.
Panic
- Panics if out of memory or the maximum number of samplers has exceeded.
fn simple_repeat_linear_no_mipmap(device: Arc<Device>) -> Arc<Sampler>
Shortcut for creating a sampler with linear sampling, that only uses the main level of images, and with the repeat mode for borders.
Useful for prototyping, but can also be used in real projects.
Panic
- Panics if out of memory or the maximum number of samplers has exceeded.
fn new(
device: Arc<Device>,
mag_filter: Filter,
min_filter: Filter,
mipmap_mode: MipmapMode,
address_u: SamplerAddressMode,
address_v: SamplerAddressMode,
address_w: SamplerAddressMode,
mip_lod_bias: f32,
max_anisotropy: f32,
min_lod: f32,
max_lod: f32
) -> Result<Arc<Sampler>, SamplerCreationError>
device: Arc<Device>,
mag_filter: Filter,
min_filter: Filter,
mipmap_mode: MipmapMode,
address_u: SamplerAddressMode,
address_v: SamplerAddressMode,
address_w: SamplerAddressMode,
mip_lod_bias: f32,
max_anisotropy: f32,
min_lod: f32,
max_lod: f32
) -> Result<Arc<Sampler>, SamplerCreationError>
Creates a new Sampler
with the given behavior.
mag_filter
and min_filter
define how the implementation should sample from the image
when it is respectively larger and smaller than the original.
mipmap_mode
defines how the implementation should choose which mipmap to use.
address_u
, address_v
and address_w
define how the implementation should behave when
sampling outside of the texture coordinates range [0.0, 1.0]
.
mip_lod_bias
is a value to add to .
max_anisotropy
must be superior or equal to 1.0. If superior to 1.0, the implementation
will use anistropic filtering. Using a value superior to 1.0 requires the
sampler_anisotropy
feature to be enabled when creating the device.
min_lod
and max_lod
are respectively the minimum and maximum mipmap level to use.
max_lod
must always be superior or equal to min_lod
.
Panic
- Panics if multiple
ClampToBorder
values are passed and the border color is different. - Panics if
max_anisotropy < 1.0
. - Panics if
min_lod > max_lod
.
fn compare(
device: Arc<Device>,
mag_filter: Filter,
min_filter: Filter,
mipmap_mode: MipmapMode,
address_u: SamplerAddressMode,
address_v: SamplerAddressMode,
address_w: SamplerAddressMode,
mip_lod_bias: f32,
max_anisotropy: f32,
min_lod: f32,
max_lod: f32,
compare: Compare
) -> Result<Arc<Sampler>, SamplerCreationError>
device: Arc<Device>,
mag_filter: Filter,
min_filter: Filter,
mipmap_mode: MipmapMode,
address_u: SamplerAddressMode,
address_v: SamplerAddressMode,
address_w: SamplerAddressMode,
mip_lod_bias: f32,
max_anisotropy: f32,
min_lod: f32,
max_lod: f32,
compare: Compare
) -> Result<Arc<Sampler>, SamplerCreationError>
Creates a new Sampler
with the given behavior.
Contrary to new
, this creates a sampler that is used to compare depth values.
A sampler like this can only operate on depth or depth-stencil textures. Instead of returning the value of the texture, this sampler will return a value between 0.0 and 1.0 indicating how much the reference value (passed by the shader) compares to the value in the texture.
Note that it doesn't make sense to create a compare-mode sampler with an integer border color, as such a sampler would be unusable.
Panic
Same panic reasons as new
.
fn unnormalized(
device: Arc<Device>,
filter: Filter,
address_u: UnnormalizedSamplerAddressMode,
address_v: UnnormalizedSamplerAddressMode
) -> Result<Arc<Sampler>, SamplerCreationError>
device: Arc<Device>,
filter: Filter,
address_u: UnnormalizedSamplerAddressMode,
address_v: UnnormalizedSamplerAddressMode
) -> Result<Arc<Sampler>, SamplerCreationError>
Creates a sampler with unnormalized coordinates. This means that texture coordinates won't
range between 0.0
and 1.0
but use plain pixel offsets.
Using an unnormalized sampler adds a few restrictions:
- It can only be used with non-array 1D or 2D images.
- It can only be used with images with a single mipmap.
- Projection and offsets can't be used by shaders. Only the first mipmap can be accessed.
Panic
- Panics if multiple
ClampToBorder
values are passed and the border color is different.
fn compare_mode(&self) -> bool
Returns true if the sampler is a compare-mode sampler.
fn is_unnormalized(&self) -> bool
Returns true if the sampler is unnormalized.
fn usable_with_float_formats(&self) -> bool
Returns true if the sampler can be used with floating-point image views. See the
documentation of the sampler
module for more info.
fn usable_with_int_formats(&self) -> bool
Returns true if the sampler can be used with integer image views. See the documentation of
the sampler
module for more info.
fn usable_with_swizzling(&self) -> bool
Returns true if the sampler can be used with image views that have non-identity swizzling.
See the documentation of the sampler
module for more info.
Trait Implementations
impl VulkanObject for Sampler
[src]
type Object = Sampler
The type of the object.
fn internal_object(&self) -> Sampler
Returns a reference to the object.
impl Debug for Sampler
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.