Struct wgpu::Extent3d[][src]

#[repr(C)]
pub struct Extent3d { pub width: u32, pub height: u32, pub depth_or_array_layers: u32, }

Extent of a texture related operation.

Fields

width: u32
height: u32
depth_or_array_layers: u32

Implementations

impl Extent3d[src]

pub fn physical_size(&self, format: TextureFormat) -> Extent3d[src]

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_or_array_layers: 1 }.physical_size(format),
    wgpu::Extent3d { width: 8, height: 8, depth_or_array_layers: 1 }
);
// Doesn't change, already aligned
assert_eq!(
    wgpu::Extent3d { width: 8, height: 8, depth_or_array_layers: 1 }.physical_size(format),
    wgpu::Extent3d { width: 8, height: 8, depth_or_array_layers: 1 }
);
let format = wgpu::TextureFormat::Astc8x5RgbaUnorm; // 8x5 blocks
assert_eq!(
    wgpu::Extent3d { width: 7, height: 7, depth_or_array_layers: 1 }.physical_size(format),
    wgpu::Extent3d { width: 8, height: 10, depth_or_array_layers: 1 }
);

pub fn max_mips(&self) -> u8[src]

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_or_array_layers: 1 }.max_mips(), 1);
assert_eq!(wgpu::Extent3d { width: 60, height: 60, depth_or_array_layers: 1 }.max_mips(), 6);
assert_eq!(wgpu::Extent3d { width: 240, height: 1, depth_or_array_layers: 1 }.max_mips(), 8);

pub fn at_mip_level(&self, level: u8) -> Option<Extent3d>[src]

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_or_array_layers: 1 };

assert_eq!(extent.at_mip_level(0), Some(wgpu::Extent3d { width: 100, height: 60, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(1), Some(wgpu::Extent3d { width: 50, height: 30, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(2), Some(wgpu::Extent3d { width: 25, height: 15, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(3), Some(wgpu::Extent3d { width: 12, height: 7, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(4), Some(wgpu::Extent3d { width: 6, height: 3, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(5), Some(wgpu::Extent3d { width: 3, height: 1, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(6), Some(wgpu::Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }));
assert_eq!(extent.at_mip_level(7), None);

Trait Implementations

impl Clone for Extent3d[src]

pub fn clone(&self) -> Extent3d[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Extent3d[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Default for Extent3d[src]

pub fn default() -> Extent3d[src]

Returns the “default value” for a type. Read more

impl<'de> Deserialize<'de> for Extent3d[src]

pub fn deserialize<__D>(
    __deserializer: __D
) -> Result<Extent3d, <__D as Deserializer<'de>>::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Hash for Extent3d[src]

pub fn hash<__H>(&self, state: &mut __H) where
    __H: Hasher
[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl PartialEq<Extent3d> for Extent3d[src]

pub fn eq(&self, other: &Extent3d) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

pub fn ne(&self, other: &Extent3d) -> bool[src]

This method tests for !=.

impl Serialize for Extent3d[src]

pub fn serialize<__S>(
    &self,
    __serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
    __S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl Copy for Extent3d[src]

impl Eq for Extent3d[src]

impl StructuralEq for Extent3d[src]

impl StructuralPartialEq for Extent3d[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> CallHasher for T where
    T: Hash

pub fn get_hash<H>(&self, hasher: H) -> u64 where
    H: Hasher

impl<T> Downcast<T> for T

pub fn downcast(&self) -> &T

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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]

Performs the conversion.

impl<T> Upcast<T> for T

pub fn upcast(&self) -> Option<&T>

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]