Skip to main content

ClearViews

Struct ClearViews 

Source
pub struct ClearViews {
    views: SmallVec<[Box<dyn DynTextureView>; 1]>,
    mip_level_count: u32,
    array_layer_count: u32,
    aspects: &'static [TextureAspect],
}
Expand description

Views for clearing a 2D texture with render passes. The contained views must be manually destroyed by calling Self::destroy.

This helper encapsulates the indexing logic for clear views (in Self::views), to reduce the chance of doing so incorrectly and failing to properly clear a texture.

Color and depth/stencil textures have a single clear view with wgt::TextureAspect::All. This is true even for combined depth/stencil formats, which clear both aspects simultaneously using a single view. The number of views is (mip level count) * (array layer count).

Multi-planar textures have a clear view per plane. The number of views is (mip level count) * (array layer count) * (plane count).

Fields§

§views: SmallVec<[Box<dyn DynTextureView>; 1]>§mip_level_count: u32§array_layer_count: u32§aspects: &'static [TextureAspect]

Implementations§

Source§

impl ClearViews

Source

pub(crate) fn new<E>( label: Label<'_>, usage: TextureUses, format: TextureFormat, mip_level_count: u32, array_layer_count: u32, create_view: impl FnMut(&TextureViewDescriptor<'_>) -> Result<Box<dyn DynTextureView>, E>, ) -> Result<Self, E>

Creates ClearViews by calling the provided create_view closure with (mip_level, array_layer, aspect) for each clear view of the texture.

Source

fn views( &self, mip_level: u32, array_layer: u32, ) -> impl Iterator<Item = (TextureAspect, &dyn DynTextureView)>

Returns an iterator over the clear view(s) for the given mip level and array layer.

The iterator yields tuples (wgt::TextureAspect, &dyn hal::DynTextureView) of clear views and their associated wgt::TextureAspects.

Source

unsafe fn destroy(&mut self, device: &dyn DynDevice)

Destroys the texture views.

§Safety

The views must not be in use by the device.

Trait Implementations§

Source§

impl Debug for ClearViews

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

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

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,