pub enum Binding {
    BuiltIn(BuiltIn),
    Location {
        location: u32,
        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

Fields

location: u32
interpolation: Option<Interpolation>
sampling: Option<Sampling>

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

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 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 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 to Perspective interpolation and Center sampling.

  • If ty is an integral scalar or vector, then default to Flat 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

Generate an arbitrary value of Self from the given unstructured data. Read more

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Feeds this value into the given Hasher. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.