pub struct TextureViewDescriptor {
pub format: Option<&'static str>,
pub dimension: Option<&'static str>,
pub base_mip_level: u32,
pub mip_level_count: u32,
pub base_array_layer: u32,
pub array_layer_count: u32,
pub aspect: Option<&'static str>,
}Expand description
Descriptor for GpuTexture.createView(descriptor).
Sub-selects a single cube face / mip / array slice / depth-aspect of a
texture. When you need the full texture as a 2D view (the common case),
just call create_view without a descriptor; the new method accepts an
Option<&TextureViewDescriptor> for callers that need the full
flexibility of the WebGPU spec.
Fields§
§format: Option<&'static str>View format override, or None to use the texture’s own format.
dimension: Option<&'static str>View dimension ("2d", "2d-array", "cube", "cube-array", …).
None means the dimension is inferred from the texture.
base_mip_level: u32Most significant mip level (inclusive). None → 0.
mip_level_count: u32Number of mip levels in the view. 0 → all the way to the top.
base_array_layer: u32First array layer (inclusive). None → 0. Only meaningful for
2d-array / cube / cube-array views.
array_layer_count: u32Number of array layers. 0 → all remaining layers.
aspect: Option<&'static str>Which aspect of the texture to expose. One of:
"all", "depth-only", "stencil-only". None → "all".
Implementations§
Source§impl TextureViewDescriptor
Constructors and view-default resolvers for TextureViewDescriptor.
impl TextureViewDescriptor
Constructors and view-default resolvers for TextureViewDescriptor.
Sourcepub fn full() -> Self
pub fn full() -> Self
Returns a descriptor that selects the full texture as a 2D view.
This is the cheapest view you can make; equivalent to calling
texture.createView() with no argument.
Sourcepub fn mip(level: u32) -> Self
pub fn mip(level: u32) -> Self
Returns a descriptor that selects a single mip level of the texture. Useful when you want to read back a specific mip (e.g. the half-res blur output of a downsampling pass) without exposing the rest.
§Arguments
u32- A 32-bit unsigned integer (u32).
Sourcepub fn depth_only() -> Self
pub fn depth_only() -> Self
Returns a descriptor that selects the depth-only aspect of a
depth-stencil texture. Required when sampling depth in a shader
(textureSample(t, s, uv) where t is a depth texture).