Enum vulkano::image::ImageDimensions
source · pub enum ImageDimensions {
Dim1d {
width: u32,
array_layers: u32,
},
Dim2d {
width: u32,
height: u32,
array_layers: u32,
cubemap_compatible: bool,
},
Dim3d {
width: u32,
height: u32,
depth: u32,
},
}
Variants
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.
sourcepub fn max_mipmaps(&self) -> u32
pub fn max_mipmaps(&self) -> u32
Returns the maximum number of mipmaps for these image dimensions.
The returned value is always at least superior or equal to 1.
Example
use vulkano::image::ImageDimensions;
let dims = ImageDimensions::Dim2d {
width: 32,
height: 50,
cubemap_compatible: false,
array_layers: 1,
};
assert_eq!(dims.max_mipmaps(), 7);
Panic
May panic if the dimensions are 0.
sourcepub fn mipmap_dimensions(&self, level: u32) -> Option<ImageDimensions>
pub fn mipmap_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_mipmaps()
.
Example
use vulkano::image::ImageDimensions;
let dims = ImageDimensions::Dim2d {
width: 963,
height: 256,
cubemap_compatible: false,
array_layers: 1,
};
assert_eq!(dims.mipmap_dimensions(0), Some(dims));
assert_eq!(dims.mipmap_dimensions(1), Some(ImageDimensions::Dim2d {
width: 512,
height: 128,
cubemap_compatible: false,
array_layers: 1,
}));
assert_eq!(dims.mipmap_dimensions(6), Some(ImageDimensions::Dim2d {
width: 16,
height: 4,
cubemap_compatible: false,
array_layers: 1,
}));
assert_eq!(dims.mipmap_dimensions(9), Some(ImageDimensions::Dim2d {
width: 2,
height: 1,
cubemap_compatible: false,
array_layers: 1,
}));
assert_eq!(dims.mipmap_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
sourceimpl<T> Content for T
impl<T> Content for T
sourcefn ref_from_ptr<'a>(ptr: *mut c_void, size: usize) -> Option<*mut T>
fn ref_from_ptr<'a>(ptr: *mut c_void, size: usize) -> Option<*mut T>
Builds a pointer to this type from a raw pointer.
sourcefn is_size_suitable(size: usize) -> bool
fn is_size_suitable(size: usize) -> bool
Returns true if the size is suitable to store a type like this.
sourcefn indiv_size() -> usize
fn indiv_size() -> usize
Returns the size of an individual element.