Struct wgpu_types::TextureDescriptor
source · [−]#[repr(C)]pub struct TextureDescriptor<L> {
pub label: L,
pub size: Extent3d,
pub mip_level_count: u32,
pub sample_count: u32,
pub dimension: TextureDimension,
pub format: TextureFormat,
pub usage: TextureUsages,
}
Expand description
Describes a Texture
.
Corresponds to WebGPU GPUTextureDescriptor
.
Fields
label: L
Debug label of the texture. This will show up in graphics debuggers for easy identification.
size: Extent3d
Size of the texture. All components must be greater than zero. For a regular 1D/2D texture, the unused sizes will be 1. For 2DArray textures, Z is the number of 2D textures in that array.
mip_level_count: u32
Mip count of texture. For a texture with no extra mips, this must be 1.
sample_count: u32
Sample count of texture. If this is not 1, texture must have BindingType::Texture::multisampled
set to true.
dimension: TextureDimension
Dimensions of the texture.
format: TextureFormat
Format of the texture.
usage: TextureUsages
Allowed usages of the texture. If used in other ways, the operation will panic.
Implementations
sourceimpl<L> TextureDescriptor<L>
impl<L> TextureDescriptor<L>
sourcepub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> TextureDescriptor<K>
pub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> TextureDescriptor<K>
sourcepub fn mip_level_size(&self, level: u32) -> Option<Extent3d>
pub fn mip_level_size(&self, level: u32) -> 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 desc = wgpu::TextureDescriptor {
label: (),
size: wgpu::Extent3d { width: 100, height: 60, depth_or_array_layers: 1 },
mip_level_count: 7,
sample_count: 1,
dimension: wgpu::TextureDimension::D3,
format: wgpu::TextureFormat::Rgba8Sint,
usage: wgpu::TextureUsages::empty(),
};
assert_eq!(desc.mip_level_size(0), Some(wgpu::Extent3d { width: 100, height: 60, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(1), Some(wgpu::Extent3d { width: 50, height: 30, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(2), Some(wgpu::Extent3d { width: 25, height: 15, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(3), Some(wgpu::Extent3d { width: 12, height: 7, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(4), Some(wgpu::Extent3d { width: 6, height: 3, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(5), Some(wgpu::Extent3d { width: 3, height: 1, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(6), Some(wgpu::Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }));
assert_eq!(desc.mip_level_size(7), None);
sourcepub fn array_layer_count(&self) -> u32
pub fn array_layer_count(&self) -> u32
Returns the number of array layers.
Trait Implementations
sourceimpl<L: Clone> Clone for TextureDescriptor<L>
impl<L: Clone> Clone for TextureDescriptor<L>
sourcefn clone(&self) -> TextureDescriptor<L>
fn clone(&self) -> TextureDescriptor<L>
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 more
sourceimpl<L: Debug> Debug for TextureDescriptor<L>
impl<L: Debug> Debug for TextureDescriptor<L>
sourceimpl<L: Hash> Hash for TextureDescriptor<L>
impl<L: Hash> Hash for TextureDescriptor<L>
sourceimpl<L: PartialEq> PartialEq<TextureDescriptor<L>> for TextureDescriptor<L>
impl<L: PartialEq> PartialEq<TextureDescriptor<L>> for TextureDescriptor<L>
sourcefn eq(&self, other: &TextureDescriptor<L>) -> bool
fn eq(&self, other: &TextureDescriptor<L>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &TextureDescriptor<L>) -> bool
fn ne(&self, other: &TextureDescriptor<L>) -> bool
This method tests for !=
.
impl<L: Eq> Eq for TextureDescriptor<L>
impl<L> StructuralEq for TextureDescriptor<L>
impl<L> StructuralPartialEq for TextureDescriptor<L>
Auto Trait Implementations
impl<L> RefUnwindSafe for TextureDescriptor<L> where
L: RefUnwindSafe,
impl<L> Send for TextureDescriptor<L> where
L: Send,
impl<L> Sync for TextureDescriptor<L> where
L: Sync,
impl<L> Unpin for TextureDescriptor<L> where
L: Unpin,
impl<L> UnwindSafe for TextureDescriptor<L> where
L: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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