Skip to main content

LitVariant

Struct LitVariant 

Source
pub struct LitVariant {
    pub options: Hashed<LitOptions>,
    pub surface: SurfaceKey,
    pub channels: LitVertexChannels,
    pub base_color_texture: bool,
    pub morph: bool,
    pub strip_index_format: Option<IndexFormat>,
}
Expand description

The complete identity of a built-in lit pipeline, and its blueprint.

A family resolves one from an entity’s LitOptions and the facts its draw carries: the mesh’s vertex channels, whether the draw binds a material, whether the mesh morphs, the mesh’s index format and the render target. Two draws that agree on all of it share one compiled pipeline; because the variant is the complete description of the blueprint, the cache key is canonical by construction.

Fields§

§options: Hashed<LitOptions>

The caller’s policy, with its hash computed once. The variant is the cache key, so the stored word is what every per-frame lookup hashes; rewrite the policy through Hashed::update rather than the value itself, so the word follows the change.

§surface: SurfaceKey

The render target the pipeline is built for.

§channels: LitVertexChannels

The per-vertex channels the mesh’s layout carries.

§base_color_texture: bool

Whether the draw binds a material group and so samples a base-color texture.

§morph: bool

Whether the mesh carries morph displacements.

§strip_index_format: Option<IndexFormat>

The strip index format the mesh’s index buffer requires, if any.

Implementations§

Source§

impl LitVariant

Source

fn features(&self, texel_arrays: bool) -> [(&'static str, bool); 17]

The WESL @if features the variant asks for, paired with their state.

Every name appears, so the composed variant never sees a name it does not know. The per-vertex names come from Self::channels, the material one from Self::base_color_texture and the policy ones from Self::options. The per-instance record is not conditional at all, so it contributes no names here: the built-in vertex stream always declares and binds an instance buffer.

texel_arrays is the device’s answer rather than the variant’s, so it is passed in from the caller that read the device.

Source

pub fn needs_joints(&self) -> bool

Whether the variant deforms its vertices by joint matrices and so reads the global group’s array of them.

Source

pub fn needs_morphs(&self) -> bool

Whether the variant reads the global group’s morph arrays: the per-instance weights and the per-mesh displacements.

Source

pub fn needs_metadata(&self) -> bool

Whether the variant reads the global group’s mesh-metadata array: the per-mesh decode parameters and the addressing a morph reads.

Mirrors the shader’s metadata condition, so the layout and the composed variant agree on whether the binding exists. A morph needs the array even when every channel is uncompressed, because the struct also carries the vertex offset and morph count its displacements are addressed by.

Source

pub fn secondary_stream(&self) -> SecondaryStreamWriter

The secondary vertex stream this variant expects.

The stream is described in crate::mesh’s own terms: this variant’s channels are translated into the ones that make up a vertex stream, so packing meshes for this pipeline needs nothing specific to it.

Source

pub fn position_stream(&self) -> PositionStreamWriter

The position vertex stream this variant expects.

The joint indices and weights the variant deforms with belong to this stream rather than one of their own, so a skinned variant’s stream is wider by the joint pair and nothing else changes.

Source

fn assert_device_supports_arrays(&self, device: &Device, texel_arrays: bool)

Reject a variant whose array path the device cannot serve.

The texel path works on every device — a texture read is universal — so forcing it on a device that also has storage buffers is allowed. The reverse is not: a bind-group layout naming a storage buffer is rejected outright by a device without them, so the failure is caught here with the reason rather than left to wgpu’s validation.

A variant that declares no array binding at all — the UI’s, which reads only full-precision vertex attributes — has nothing to serve either way, so it is not asked to pick a path.

§Panics

If the variant reads storage buffers on a device that has none.

Source§

impl LitVariant

Source

pub fn bind_group_layouts(&self, device: &Device) -> LitBindGroupLayouts

Build the bind-group layouts this variant declares, without compiling the pipeline.

The layouts come from the same variant a pipeline is built from, so the two agree: the global group always exists, and the material group only for a variant that samples a base-color texture. The mesh group is always None — the built-in variants bind nothing there.

The array path is the device’s answer rather than the variant’s, so it is read here: a cache is built for one device, which is why the path never enters the variant key.

Source

pub fn vertex_buffer_layouts(&self) -> [Option<VertexBufferLayoutDesc>; 3]

The vertex-buffer declarations the built-in shader expects, in slot order.

The first two slots follow the variant’s channels; the third is always the instance stream, which every built-in variant binds. A slot whose variant declares no attributes is reported as None, so a variant never binds a buffer the shader does not declare.

Source

fn instance_layout(&self) -> VertexBufferLayoutDesc

The instance stream every built-in variant expects.

One record layout serves every variant of a frame — the source uploads a single &[MeshInstance] buffer and binds it at INSTANCE_SLOT for every draw — so the stride is always the whole MeshInstance. The declared attributes mirror the shader’s own input declarations: the model matrix, the base color, the pose bases and the metadata index unconditionally, the alpha cutoff and the hull width under the features that declare them. A pipeline never declares an attribute the shader does not, which the validation layers would otherwise flag on every draw.

Trait Implementations§

Source§

impl Clone for LitVariant

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 Debug for LitVariant

Source§

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

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

impl Eq for LitVariant

Source§

impl Hash for LitVariant

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 LitVariant

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 PipelineDescriptor<RenderPipeline> for LitVariant

Source§

fn create(&self, device: &Device) -> RenderPipeline

Compose this variant’s entry shader and build the pipeline, so a variant compiles through the same PipelineDescriptor mechanism a caller’s own descriptor does.

The entry shader is the built-in lit.wesl, with the options’ own snippets (LitOptions::shader) spliced into it at its marks.

Source§

impl PipelineVariant<RenderPipeline> for LitVariant

Source§

type Descriptor = LitVariant

The blueprint this variant compiles.
Source§

fn descriptor(&self, _device: &Device) -> Self

Build this variant’s blueprint. Called only on a cache miss. Read more
Source§

impl StructuralPartialEq for LitVariant

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
§

impl<T> AsId for T
where T: Hash + Debug,

§

impl<T> AsIdSalt for T
where T: Hash + Debug,

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
§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

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

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more