Skip to main content

InstanceData

Trait InstanceData 

Source
pub trait InstanceData: 'static {
    // Required methods
    fn stream(&self) -> InstanceStreamDesc;
    fn write(&mut self, context: &mut InstanceContext<'_>, out: &mut [u8]);
}
Expand description

The per-instance vertex data one family’s draws read.

A family owns its own instance stream: every frame the source packs one record per visible instance into a buffer shaped by Self::stream and binds it at the declared slot. That is what lets a caller’s family carry its own per-instance data – a tint, a transform palette, a material parameter – without sharing a record layout or a buffer with the built-in lit family, and without the built-in family having any privilege over it.

A family that reads no per-instance state passes the unit type.

Required Methods§

Source

fn stream(&self) -> InstanceStreamDesc

Where the family’s stream binds and how wide one record is.

Called once when the family is registered, so it should be constant.

Source

fn write(&mut self, context: &mut InstanceContext<'_>, out: &mut [u8])

Write one record into out, which is exactly stream().array_stride bytes long.

Called once per visible instance per frame, in visible order.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl InstanceData for ()

A family that binds no per-instance stream.

Source§

fn stream(&self) -> InstanceStreamDesc

Source§

fn write(&mut self, _context: &mut InstanceContext<'_>, _out: &mut [u8])

Implementors§