Struct nannou::wgpu::Extent3d [−]
Extent of a texture related operation.
Fields
width: u32
height: u32
depth: u32
Implementations
impl Extent3d
pub fn physical_size(&self, format: TextureFormat) -> Extent3d
Calculates the physical size is backing an texture of the given format and extent. This includes padding to the block width and height of the format.
This is the texture extent that you must upload at when uploading to mipmaps of compressed textures.
let format = wgpu::TextureFormat::Bc1RgbaUnormSrgb; // 4x4 blocks assert_eq!( wgpu::Extent3d { width: 7, height: 7, depth: 1 }.physical_size(format), wgpu::Extent3d { width: 8, height: 8, depth: 1 } ); // Doesn't change, already aligned assert_eq!( wgpu::Extent3d { width: 8, height: 8, depth: 1 }.physical_size(format), wgpu::Extent3d { width: 8, height: 8, depth: 1 } ); let format = wgpu::TextureFormat::Astc8x5RgbaUnorm; // 8x5 blocks assert_eq!( wgpu::Extent3d { width: 7, height: 7, depth: 1 }.physical_size(format), wgpu::Extent3d { width: 8, height: 10, depth: 1 } );
pub fn max_mips(&self) -> u8
Calculates the maximum possible count of mipmaps.
Treats the depth as part of the mipmaps. If calculating for a 2DArray texture, which does not mipmap depth, set depth to 1.
assert_eq!(wgpu::Extent3d { width: 1, height: 1, depth: 1 }.max_mips(), 1); assert_eq!(wgpu::Extent3d { width: 60, height: 60, depth: 1 }.max_mips(), 6); assert_eq!(wgpu::Extent3d { width: 240, height: 1, depth: 1 }.max_mips(), 8);
pub fn at_mip_level(&self, level: u8) -> Option<Extent3d>
Calculates the extent at a given mip level.
If the given mip level is larger than possible, returns None.
Treats the depth as part of the mipmaps. If calculating for a 2DArray texture, which does not mipmap depth, set depth to 1.
let extent = wgpu::Extent3d { width: 100, height: 60, depth: 1 }; assert_eq!(extent.at_mip_level(0), Some(wgpu::Extent3d { width: 100, height: 60, depth: 1 })); assert_eq!(extent.at_mip_level(1), Some(wgpu::Extent3d { width: 50, height: 30, depth: 1 })); assert_eq!(extent.at_mip_level(2), Some(wgpu::Extent3d { width: 25, height: 15, depth: 1 })); assert_eq!(extent.at_mip_level(3), Some(wgpu::Extent3d { width: 12, height: 7, depth: 1 })); assert_eq!(extent.at_mip_level(4), Some(wgpu::Extent3d { width: 6, height: 3, depth: 1 })); assert_eq!(extent.at_mip_level(5), Some(wgpu::Extent3d { width: 3, height: 1, depth: 1 })); assert_eq!(extent.at_mip_level(6), Some(wgpu::Extent3d { width: 1, height: 1, depth: 1 })); assert_eq!(extent.at_mip_level(7), None);
Trait Implementations
impl Clone for Extent3d
pub fn clone(&self) -> Extent3d
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Extent3d
impl Debug for Extent3d
impl Default for Extent3d
impl Eq for Extent3d
impl Hash for Extent3d
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Extent3d> for Extent3d
impl StructuralEq for Extent3d
impl StructuralPartialEq for Extent3d
Auto Trait Implementations
impl RefUnwindSafe for Extent3d
impl Send for Extent3d
impl Sync for Extent3d
impl Unpin for Extent3d
impl UnwindSafe for Extent3d
Blanket Implementations
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: Component + Float,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
[src]
T: Component + Float,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
pub fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
[src]
M: TransformMatrix<Swp, Dwp, T>,
pub fn adapt_into(self) -> D
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CallHasher for T where
T: Hash,
T: Hash,
impl<T, U> ConvertInto<U> for T where
U: ConvertFrom<T>,
[src]
U: ConvertFrom<T>,
pub fn convert_into(self) -> U
[src]
pub fn convert_unclamped_into(self) -> U
[src]
pub fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
[src]
impl<T> Downcast<T> for T
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> NodeId for T where
T: 'static + Copy + Clone + PartialEq<T> + Eq + Hash + Send,
[src]
T: 'static + Copy + Clone + PartialEq<T> + Eq + Hash + Send,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> SetParameter for T
pub fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> Style for T where
T: Any + Debug + PartialEq<T>,
[src]
T: Any + Debug + PartialEq<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Upcast<T> for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,