Skip to main content

ShaderStages

Struct ShaderStages 

Source
pub struct ShaderStages(/* private fields */);
Expand description

One or more pipeline stages a bind group layout slot is visible to.

WebGPU’s visibility is a GPUShaderStage bitmask, not a single stage: a uniform block that both the vertex and fragment stages read is the most common binding there is, and naming one stage produces a layout the other stage cannot see. ShaderStage alone cannot carry that, so this newtype holds the combined mask while keeping the variants spelled out rather than written as a raw 0x1 | 0x2.

Build one with |, or from a single stage (which is what the Into impl is for):

use euv_engine::{ShaderStage, ShaderStages};

let both: ShaderStages = ShaderStage::Vertex | ShaderStage::Fragment;
let one: ShaderStages = ShaderStage::Compute.into();
assert!(both.contains(ShaderStage::Vertex));
assert_eq!(one.bits(), 0x4);

Implementations§

Source§

impl ShaderStages

The mask arithmetic behind ShaderStages, kept next to the BitOr impl for ShaderStage that produces one.

Source

pub fn bits(self) -> u32

The raw GPUShaderStage bitmask this mask stands for.

§Returns
  • u32 - The combined bits, ready for the wire.
Source

pub fn is_empty(self) -> bool

Whether this mask names no stage at all.

A bind group layout slot with an empty mask is visible to nothing, which the driver reports as a validation error rather than as a silently unreachable binding.

§Returns
  • bool - true when no stage is named.
Source

pub fn contains(self, stage: ShaderStage) -> bool

Whether one stage is among the stages this mask names.

§Arguments
  • ShaderStage - The stage to test for.
§Returns
  • bool - true when the stage’s bit is set.

Trait Implementations§

Source§

impl BitOr for ShaderStages

Combining two masks, which is what a caller reaches for when the two halves of a layout entry are built independently.

Source§

type Output = ShaderStages

The union of the two masks.

Source§

fn bitor(self, rhs: Self) -> Self::Output

Sets every bit either side names.

§Arguments
  • Self - The right-hand mask.
§Returns
  • Self::Output - The mask naming both sides.
Source§

impl BitOr<ShaderStage> for ShaderStages

Adding a stage to a mask that already names others.

Source§

type Output = ShaderStages

The widened mask.

Source§

fn bitor(self, rhs: ShaderStage) -> Self::Output

Sets one more stage’s bit, leaving the existing bits alone.

§Arguments
  • ShaderStage - The stage to add.
§Returns
  • Self::Output - The mask naming both sides.
Source§

impl Clone for ShaderStages

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ShaderStages

Source§

impl Debug for ShaderStages

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ShaderStages

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ShaderStages

Source§

impl From<ShaderStage> for ShaderStages

Lets a lone stage stand in where a mask is expected, so every single-stage call site keeps reading as one.

Source§

fn from(value: ShaderStage) -> Self

Widens one stage into a mask naming only that stage.

§Arguments
  • ShaderStage - The stage the mask should name.
§Returns
  • ShaderStages - A mask with that stage’s single bit set.
Source§

impl Hash for ShaderStages

Source§

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

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

impl PartialEq for ShaderStages

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ShaderStages

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
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
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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more