Struct TextureDescriptor
#[repr(C)]pub struct TextureDescriptor<L, V> {
pub label: L,
pub size: Extent3d,
pub mip_level_count: u32,
pub sample_count: u32,
pub dimension: TextureDimension,
pub format: TextureFormat,
pub usage: TextureUsages,
pub view_formats: V,
}
unstable-wgpu-26
only.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.
view_formats: V
Specifies what view formats will be allowed when calling Texture::create_view
on this texture.
View formats of the same format as the texture are always allowed.
Note: currently, only the srgb-ness is allowed to change. (ex: Rgba8Unorm
texture + Rgba8UnormSrgb
view)
Implementations§
§impl<L, V> TextureDescriptor<L, V>
impl<L, V> TextureDescriptor<L, V>
pub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> TextureDescriptor<K, V>where
V: Clone,
pub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> TextureDescriptor<K, V>where
V: Clone,
Takes a closure and maps the label of the texture descriptor into another.
pub fn map_label_and_view_formats<K, M>(
&self,
l_fun: impl FnOnce(&L) -> K,
v_fun: impl FnOnce(V) -> M,
) -> TextureDescriptor<K, M>where
V: Clone,
pub fn map_label_and_view_formats<K, M>(
&self,
l_fun: impl FnOnce(&L) -> K,
v_fun: impl FnOnce(V) -> M,
) -> TextureDescriptor<K, M>where
V: Clone,
Maps the label and view formats of the texture descriptor into another.
pub 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 = 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(),
view_formats: &[],
};
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);
pub fn compute_render_extent(&self, mip_level: u32) -> Extent3d
pub fn compute_render_extent(&self, mip_level: u32) -> Extent3d
Computes the render extent of this texture.
https://gpuweb.github.io/gpuweb/#abstract-opdef-compute-render-extent
pub fn array_layer_count(&self) -> u32
pub fn array_layer_count(&self) -> u32
Returns the number of array layers.
https://gpuweb.github.io/gpuweb/#abstract-opdef-array-layer-count
Trait Implementations§
§impl<L, V> Clone for TextureDescriptor<L, V>
impl<L, V> Clone for TextureDescriptor<L, V>
§fn clone(&self) -> TextureDescriptor<L, V>
fn clone(&self) -> TextureDescriptor<L, V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl<L, V> Debug for TextureDescriptor<L, V>
impl<L, V> Debug for TextureDescriptor<L, V>
§impl<L, V> Hash for TextureDescriptor<L, V>
impl<L, V> Hash for TextureDescriptor<L, V>
§impl<L, V> PartialEq for TextureDescriptor<L, V>
impl<L, V> PartialEq for TextureDescriptor<L, V>
impl<L, V> Eq for TextureDescriptor<L, V>
impl<L, V> StructuralPartialEq for TextureDescriptor<L, V>
Auto Trait Implementations§
impl<L, V> Freeze for TextureDescriptor<L, V>
impl<L, V> RefUnwindSafe for TextureDescriptor<L, V>where
L: RefUnwindSafe,
V: RefUnwindSafe,
impl<L, V> Send for TextureDescriptor<L, V>
impl<L, V> Sync for TextureDescriptor<L, V>
impl<L, V> Unpin for TextureDescriptor<L, V>
impl<L, V> UnwindSafe for TextureDescriptor<L, V>where
L: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.