BufferUsages

Struct BufferUsages 

#[repr(C)]
pub struct BufferUsages { pub buffer_usages_webgpu: BufferUsagesWebGPU, pub buffer_usages_wgpu: BufferUsagesWGPU, }
Expand description

Different ways that you can use a buffer.

The usages determine what kind of memory the buffer is allocated from and what actions the buffer can partake in.

Specifying only usages the application will actually perform may increase performance. Additionally, on the WebGL backend, there are restrictions on BufferUsages::INDEX; see [DownlevelFlags::UNRESTRICTED_INDEX_BUFFER] for more information.

Corresponds to WebGPU GPUBufferUsageFlags.

Fields§

§buffer_usages_webgpu: BufferUsagesWebGPU§buffer_usages_wgpu: BufferUsagesWGPU

Implementations§

§

impl BufferUsages

pub const MAP_READ: BufferUsages

Allow a buffer to be mapped for reading using Buffer::map_async + Buffer::get_mapped_range. This does not include creating a buffer with [BufferDescriptor::mapped_at_creation] set.

If Features::MAPPABLE_PRIMARY_BUFFERS isn’t enabled, the only other usage a buffer may have is COPY_DST.

pub const MAP_WRITE: BufferUsages

Allow a buffer to be mapped for writing using Buffer::map_async + Buffer::get_mapped_range_mut. This does not include creating a buffer with [BufferDescriptor::mapped_at_creation] set.

If Features::MAPPABLE_PRIMARY_BUFFERS feature isn’t enabled, the only other usage a buffer may have is COPY_SRC.

pub const COPY_SRC: BufferUsages

Allow a buffer to be the source buffer for a CommandEncoder::copy_buffer_to_buffer or CommandEncoder::copy_buffer_to_texture operation.

pub const COPY_DST: BufferUsages

Allow a buffer to be the destination buffer for a CommandEncoder::copy_buffer_to_buffer, CommandEncoder::copy_texture_to_buffer, CommandEncoder::clear_buffer or Queue::write_buffer operation.

pub const INDEX: BufferUsages

Allow a buffer to be the index buffer in a draw operation.

pub const VERTEX: BufferUsages

Allow a buffer to be the vertex buffer in a draw operation.

pub const UNIFORM: BufferUsages

Allow a buffer to be a BufferBindingType::Uniform inside a bind group.

pub const STORAGE: BufferUsages

Allow a buffer to be a BufferBindingType::Storage inside a bind group.

pub const INDIRECT: BufferUsages

Allow a buffer to be the indirect buffer in an indirect draw call.

pub const QUERY_RESOLVE: BufferUsages

Allow a buffer to be the destination buffer for a CommandEncoder::resolve_query_set operation.

pub const BLAS_INPUT: BufferUsages

Allows a buffer to be used as input for a bottom level acceleration structure build

pub const TLAS_INPUT: BufferUsages

Allows a buffer to be used as input for a top level acceleration structure build

pub const fn bits(&self) -> BufferUsagesBits

Gets the set flags as a container holding an array of bits.

pub const fn empty() -> BufferUsages

Returns self with no flags set.

pub const fn all() -> BufferUsages

Returns self with all flags set.

pub const fn contains(self, other: BufferUsages) -> bool

Whether all the bits set in other are all set in self

pub const fn intersects(self, other: BufferUsages) -> bool

Returns whether any bit set in self matched any bit set in other.

pub const fn is_empty(self) -> bool

Returns whether there is no flag set.

pub const fn is_all(self) -> bool

Returns whether the struct has all flags set.

pub const fn union(self, other: BufferUsages) -> BufferUsages

Bitwise or - self | other

pub const fn intersection(self, other: BufferUsages) -> BufferUsages

Bitwise and - self & other

pub const fn difference(self, other: BufferUsages) -> BufferUsages

Bitwise and of the complement of other - self & !other

pub const fn symmetric_difference(self, other: BufferUsages) -> BufferUsages

Bitwise xor - self ^ other

pub const fn complement(self) -> BufferUsages

Bitwise not - !self

pub fn set(&mut self, other: BufferUsages, set: bool)

Calls Self::insert if set is true and otherwise calls Self::remove.

pub fn insert(&mut self, other: BufferUsages)

Inserts specified flag(s) into self

pub fn remove(&mut self, other: BufferUsages)

Removes specified flag(s) from self

pub fn toggle(&mut self, other: BufferUsages)

Toggles specified flag(s) in self

pub const fn from_bits(bits: BufferUsagesBits) -> Option<BufferUsages>

Takes in [BufferUsagesBits] and returns None if there are invalid bits or otherwise Self with those bits set

pub const fn from_bits_truncate(bits: BufferUsagesBits) -> BufferUsages

Takes in [BufferUsagesBits] and returns Self with only valid bits (all other bits removed)

pub const fn from_bits_retain(bits: BufferUsagesBits) -> BufferUsages

Takes in [BufferUsagesBits] and returns Self with all bits that were set without removing invalid bits

pub fn from_name(name: &str) -> Option<BufferUsages>

Takes in a bitflags flag name (in SCREAMING_SNAKE_CASE) and returns Self if it matches or none if the name does not match the name of any of the flags. Name is capitalisation dependent.

[impl FromStr] can be used to recognize kebab-case names, like are used in the WebGPU spec.

pub fn from_internal_flags( buffer_usages_webgpu: BufferUsagesWebGPU, buffer_usages_wgpu: BufferUsagesWGPU, ) -> BufferUsages

Combines the flags from the internal flags into the entire flags struct

pub const fn iter(&self) -> Iter<BufferUsages>

Returns an iterator over the set flags.

pub const fn iter_names(&self) -> IterNames<BufferUsages>

Returns an iterator over the set flags and their names.

These are bitflags names in SCREAMING_SNAKE_CASE.

Trait Implementations§

§

impl BitAnd for BufferUsages

§

type Output = BufferUsages

The resulting type after applying the & operator.
§

fn bitand(self, other: BufferUsages) -> BufferUsages

Performs the & operation. Read more
§

impl BitAndAssign for BufferUsages

§

fn bitand_assign(&mut self, other: BufferUsages)

Performs the &= operation. Read more
§

impl BitOr for BufferUsages

§

type Output = BufferUsages

The resulting type after applying the | operator.
§

fn bitor(self, other: BufferUsages) -> BufferUsages

Performs the | operation. Read more
§

impl BitOrAssign for BufferUsages

§

fn bitor_assign(&mut self, other: BufferUsages)

Performs the |= operation. Read more
§

impl BitXor for BufferUsages

§

type Output = BufferUsages

The resulting type after applying the ^ operator.
§

fn bitxor(self, other: BufferUsages) -> BufferUsages

Performs the ^ operation. Read more
§

impl BitXorAssign for BufferUsages

§

fn bitxor_assign(&mut self, other: BufferUsages)

Performs the ^= operation. Read more
§

impl Clone for BufferUsages

§

fn clone(&self) -> BufferUsages

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for BufferUsages

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for BufferUsages

Available on crate feature serde only.
§

fn deserialize<D>( deserializer: D, ) -> Result<BufferUsages, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for BufferUsages

§

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

Formats the value using the given formatter. Read more
§

impl Flags for BufferUsages

§

const FLAGS: &'static [Flag<BufferUsages>] = BufferUsages::FLAGS

The set of defined flags.
§

type Bits = BufferUsagesBits

The underlying bits type.
§

fn bits(&self) -> BufferUsagesBits

Get the underlying bits value. Read more
§

fn from_bits_retain(bits: BufferUsagesBits) -> BufferUsages

Convert from a bits value exactly.
§

fn empty() -> BufferUsages

Get a flags value with all bits unset.
§

fn all() -> BufferUsages

Get a flags value with all known bits set.
§

fn all_named() -> Self

Get a flags value with all bits from named flags set. Read more
§

fn known_bits(&self) -> Self::Bits

Get the known bits from a flags value.
§

fn unknown_bits(&self) -> Self::Bits

Get the unknown bits from a flags value.
§

fn contains_unknown_bits(&self) -> bool

This method will return true if any unknown bits are set.
§

fn from_bits(bits: Self::Bits) -> Option<Self>

Convert from a bits value. Read more
§

fn from_bits_truncate(bits: Self::Bits) -> Self

Convert from a bits value, unsetting any unknown bits.
§

fn from_name(name: &str) -> Option<Self>

Get a flags value with the bits of a flag with the given name set. Read more
§

fn iter(&self) -> Iter<Self>

Yield a set of contained flags values. Read more
§

fn iter_names(&self) -> IterNames<Self>

Yield a set of contained named flags values. Read more
§

fn iter_defined_names() -> IterDefinedNames<Self>

Yield a set of all named flags defined by [Self::FLAGS].
§

fn iter_equal_names(&self) -> IterEqualNames<Self>

Get an iterator over all defined names for this flags value. Read more
§

fn is_empty(&self) -> bool

Whether all bits in this flags value are unset.
§

fn is_all(&self) -> bool

Whether all known bits in this flags value are set.
§

fn intersects(&self, other: Self) -> bool
where Self: Sized,

Whether any set bits in other are also set in self.
§

fn contains(&self, other: Self) -> bool
where Self: Sized,

Whether all set bits in other are also set in self.
§

fn truncate(&mut self)
where Self: Sized,

Remove any unknown bits from the flags.
§

fn insert(&mut self, other: Self)
where Self: Sized,

The bitwise or (|) of the bits in self and other.
§

fn remove(&mut self, other: Self)
where Self: Sized,

The intersection of self with the complement of other (&!). Read more
§

fn toggle(&mut self, other: Self)
where Self: Sized,

The bitwise exclusive-or (^) of the bits in self and other.
§

fn set(&mut self, other: Self, value: bool)
where Self: Sized,

Call [Flags::insert] when value is true or [Flags::remove] when value is false.
§

fn clear(&mut self)
where Self: Sized,

Unsets all bits in the flags.
§

fn intersection(self, other: Self) -> Self

The bitwise and (&) of the bits in self and other.
§

fn union(self, other: Self) -> Self

The bitwise or (|) of the bits in self and other.
§

fn difference(self, other: Self) -> Self

The intersection of self with the complement of other (&!). Read more
§

fn symmetric_difference(self, other: Self) -> Self

The bitwise exclusive-or (^) of the bits in self and other.
§

fn complement(self) -> Self

The bitwise negation (!) of the bits in self, truncating the result.
§

impl From<BufferUsagesWGPU> for BufferUsages

§

fn from(buffer_usages_wgpu: BufferUsagesWGPU) -> BufferUsages

Converts to this type from the input type.
§

impl From<BufferUsagesWebGPU> for BufferUsages

§

fn from(buffer_usages_webgpu: BufferUsagesWebGPU) -> BufferUsages

Converts to this type from the input type.
§

impl Hash for BufferUsages

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl Not for BufferUsages

§

type Output = BufferUsages

The resulting type after applying the ! operator.
§

fn not(self) -> BufferUsages

Performs the unary ! operation. Read more
§

impl PartialEq for BufferUsages

§

fn eq(&self, other: &BufferUsages) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for BufferUsages

Available on crate feature serde only.
§

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 Sub for BufferUsages

§

type Output = BufferUsages

The resulting type after applying the - operator.
§

fn sub(self, other: BufferUsages) -> BufferUsages

Performs the - operation. Read more
§

impl Copy for BufferUsages

§

impl Eq for BufferUsages

§

impl StructuralPartialEq for BufferUsages

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> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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,

Source§

impl<T> CommonTraits for T
where T: AsAny + Any + Debug + WasmNotSendSync,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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

§

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

§

impl<T> WasmNotSendSync for T

§

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