Struct nannou_wgpu::Extent3d [−]
Expand description
Extent of a texture related operation.
Fields
width: u32
height: u32
depth_or_array_layers: u32
Implementations
impl Extent3d
impl Extent3d
pub fn physical_size(&self, format: TextureFormat) -> 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_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 }
);
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 mip_level_size(&self, level: u32, is_3d_texture: bool) -> Extent3d
pub fn mip_level_size(&self, level: u32, is_3d_texture: bool) -> Extent3d
Calculates the extent at a given mip level.
Trait Implementations
impl<'de> Deserialize<'de> for Extent3d
impl<'de> Deserialize<'de> for Extent3d
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Extent3d, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
pub fn deserialize<__D>(
__deserializer: __D
) -> Result<Extent3d, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
pub fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralEq for Extent3d
impl StructuralPartialEq for Extent3d
Auto Trait Implementations
impl RefUnwindSafe for Extent3d
impl UnwindSafe for Extent3d
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.