pub enum Binding {
BuiltIn(BuiltIn),
Location {
location: u32,
second_blend_source: bool,
interpolation: Option<Interpolation>,
sampling: Option<Sampling>,
},
}
Expand description
Describes how an input/output variable is to be bound.
Variants§
BuiltIn(BuiltIn)
Built-in shader variable.
Location
Indexed location.
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
.
Implementations§
source§impl Binding
impl Binding
sourcepub fn apply_default_interpolation(&mut self, ty: &TypeInner)
pub fn apply_default_interpolation(&mut self, ty: &TypeInner)
Apply the usual default interpolation for ty
to 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 Binding
s 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 everything else either defaults to flat, or requires an explicit flat qualifier/attribute/what-have-you.
If binding
is not a Location
binding, or if its interpolation
is
already set, then make no changes. Otherwise, set binding
’s interpolation
and sampling to reasonable defaults depending on ty
, the type of the value
being interpolated:
-
If
ty
is a floating-point scalar, vector, or matrix type, then default toPerspective
interpolation andCenter
sampling. -
If
ty
is an integral scalar or vector, then default toFlat
interpolation, which has no associated sampling. -
For any other types, make no change. Such types are not permitted as user-defined IO values, and will probably be flagged by the verifier
When structs appear in input or output types, each member ought to have its
own Binding
, so structs are simply covered by the third case.
Trait Implementations§
source§impl PartialEq for Binding
impl PartialEq for Binding
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.