pub enum Binding {
BuiltIn(BuiltIn),
Location {
location: u32,
interpolation: Option<Interpolation>,
sampling: Option<Sampling>,
blend_src: Option<u32>,
per_primitive: bool,
},
}Expand description
Describes how an input/output variable is to be bound.
Variants§
BuiltIn(BuiltIn)
Built-in shader variable.
Location
Indexed location.
This is a value passed to a Fragment shader from a Vertex or
Mesh shader.
Values passed from the Vertex stage to the Fragment stage must
have their interpolation defaulted (i.e. not None) by the front end
as appropriate for that language.
For other stages, we permit interpolations even though they’re ignored.
When a front end is parsing a struct type, it usually doesn’t know what
stages will be using it for IO, so it’s easiest if it can apply the
defaults to anything with a Location binding, just in case.
For anything other than floating-point scalars and vectors, the
interpolation must be Flat.
Fields
interpolation: Option<Interpolation>blend_src: Option<u32>Optional blend_src index used for dual source blending.
See https://www.w3.org/TR/WGSL/#attribute-blend_src
per_primitive: boolWhether the binding is a per-primitive binding for use with mesh shaders.
This must be true if this binding is a mesh shader primitive output, or such
an output’s corresponding fragment shader input. It must be false otherwise.
A stage’s outputs must all have unique location numbers, regardless of
whether they are per-primitive; a mesh shader’s per-vertex and per-primitive
outputs share the same location numbering space.
Per-primitive values are not interpolated at all and are not dependent on the vertices or pixel location. For example, it may be used to store a non-interpolated normal vector.
Implementations§
Source§impl Binding
impl Binding
Sourcepub(crate) fn apply_default_interpolation(&mut self, ty: &TypeInner)
pub(crate) fn apply_default_interpolation(&mut self, ty: &TypeInner)
Apply default interpolation (if applicable) for ty to the binding.
This function is a utility front ends may use to satisfy the Naga IR’s
requirement, meant to ensure that input languages’ policies have been
applied appropriately, that all I/O Bindings from the vertex shader to the
fragment shader must have non-None interpolation values.
All the shader languages Naga supports have similar rules: perspective-correct, center-sampled interpolation is the default for any binding that can vary, and an explicit flat qualifier/attribute/what-have-you is required for bindings that cannot.
-
If
bindingis not aLocationbinding, or if itsinterpolationis already set, then this function makes no changes. -
If
tyis a floating-point scalar, vector, or matrix type, then apply the defaultPerspectiveinterpolation andCentersampling. -
If
tyis an integral scalar or vector, make no changes; if the interpolation wasNone, it will remain so, and be rejected by the validator.
For struct types, the bindings are defined on the members, so there is nothing to adjust on the struct itself.
Other non-struct types are not permitted as user-defined IO values, and will be rejected by the validator.
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Binding
impl<'arbitrary> Arbitrary<'arbitrary> for Binding
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§impl<'de> Deserialize<'de> for Binding
impl<'de> Deserialize<'de> for Binding
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Binding
impl StructuralPartialEq for Binding
Auto Trait Implementations§
impl Freeze for Binding
impl RefUnwindSafe for Binding
impl Send for Binding
impl Sync for Binding
impl Unpin for Binding
impl UnwindSafe for Binding
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<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.