pub trait MaterialLayout: Send + Sync {
// Required methods
fn register_strategy(&mut self, strategy: &dyn ShadingStrategy);
fn upload(
&mut self,
handle: MaterialHandle,
strategy: &dyn ShadingStrategy,
values: &[MaterialValue],
);
}Expand description
Consumes resolved material values and decides how they are laid out in
memory - as a single array-of-structs blob (see the pack::aos module),
as per-field structure-of-arrays buffers, or otherwise. ShadingStrategy
describes what fields exist and what their values are; MaterialLayout
decides where those values live.
Required Methods§
Sourcefn register_strategy(&mut self, strategy: &dyn ShadingStrategy)
fn register_strategy(&mut self, strategy: &dyn ShadingStrategy)
Prepares this layout to store values for strategy’s fields. Called
once per strategy, before any upload for a material using it.
Sourcefn upload(
&mut self,
handle: MaterialHandle,
strategy: &dyn ShadingStrategy,
values: &[MaterialValue],
)
fn upload( &mut self, handle: MaterialHandle, strategy: &dyn ShadingStrategy, values: &[MaterialValue], )
Writes values (as resolved by strategy.resolve(), in
strategy.fields() order) into this layout’s storage for handle.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".