Enum vulkano::image::ImageDimensions
source · [−]pub enum ImageDimensions {
Dim1d {
width: u32,
array_layers: u32,
},
Dim2d {
width: u32,
height: u32,
array_layers: u32,
},
Dim3d {
width: u32,
height: u32,
depth: u32,
},
}
Expand description
The dimensions of an image.
Variants
Dim1d
Dim2d
Dim3d
Implementations
sourceimpl ImageDimensions
impl ImageDimensions
pub fn width(&self) -> u32
pub fn height(&self) -> u32
pub fn width_height(&self) -> [u32; 2]
pub fn depth(&self) -> u32
pub fn width_height_depth(&self) -> [u32; 3]
pub fn array_layers(&self) -> u32
sourcepub fn num_texels(&self) -> u32
pub fn num_texels(&self) -> u32
Returns the total number of texels for an image of these dimensions.
pub fn image_type(&self) -> ImageType
sourcepub fn max_mip_levels(&self) -> u32
pub fn max_mip_levels(&self) -> u32
Returns the maximum number of mipmap levels for these image dimensions.
The returned value is always at least 1.
Example
use vulkano::image::ImageDimensions;
let dims = ImageDimensions::Dim2d {
width: 32,
height: 50,
array_layers: 1,
};
assert_eq!(dims.max_mip_levels(), 6);
sourcepub fn mip_level_dimensions(&self, level: u32) -> Option<ImageDimensions>
pub fn mip_level_dimensions(&self, level: u32) -> Option<ImageDimensions>
Returns the dimensions of the level
th mipmap level. If level
is 0, then the dimensions
are left unchanged.
Returns None
if level
is superior or equal to max_mip_levels()
.
Example
use vulkano::image::ImageDimensions;
let dims = ImageDimensions::Dim2d {
width: 963,
height: 256,
array_layers: 1,
};
assert_eq!(dims.mip_level_dimensions(0), Some(dims));
assert_eq!(dims.mip_level_dimensions(1), Some(ImageDimensions::Dim2d {
width: 481,
height: 128,
array_layers: 1,
}));
assert_eq!(dims.mip_level_dimensions(6), Some(ImageDimensions::Dim2d {
width: 15,
height: 4,
array_layers: 1,
}));
assert_eq!(dims.mip_level_dimensions(9), Some(ImageDimensions::Dim2d {
width: 1,
height: 1,
array_layers: 1,
}));
assert_eq!(dims.mip_level_dimensions(11), None);
Panic
In debug mode, Panics if width
, height
or depth
is equal to 0. In release, returns
an unspecified value.
Trait Implementations
sourceimpl Clone for ImageDimensions
impl Clone for ImageDimensions
sourcefn clone(&self) -> ImageDimensions
fn clone(&self) -> ImageDimensions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for ImageDimensions
impl Debug for ImageDimensions
sourceimpl PartialEq<ImageDimensions> for ImageDimensions
impl PartialEq<ImageDimensions> for ImageDimensions
sourcefn eq(&self, other: &ImageDimensions) -> bool
fn eq(&self, other: &ImageDimensions) -> bool
impl Copy for ImageDimensions
impl Eq for ImageDimensions
impl StructuralEq for ImageDimensions
impl StructuralPartialEq for ImageDimensions
Auto Trait Implementations
impl RefUnwindSafe for ImageDimensions
impl Send for ImageDimensions
impl Sync for ImageDimensions
impl Unpin for ImageDimensions
impl UnwindSafe for ImageDimensions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more