Trait MewPipeline

Source
pub trait MewPipeline {
    type BindGroupSet;
    type BindGroupLayoutSet<'a>;
    type BindGroupArray<T>;
    type VertexArray<T>;
    type FragmentArray<T>;

    // Required methods
    fn new(pipeline: RenderPipeline) -> Self;
    fn bind_group_layouts<'a>(
        bind_groups: &Self::BindGroupLayoutSet<'a>,
    ) -> Self::BindGroupArray<&'a BindGroupLayout>;
    fn layout_desc<'a>(
        bind_group_layouts: &'a Self::BindGroupArray<&'a BindGroupLayout>,
    ) -> PipelineLayoutDescriptor<'a>;
    fn fragment_targets<'a>(
        surface_fmt: Option<TextureFormat>,
    ) -> Self::FragmentArray<Option<ColorTargetState>>;
    fn pipeline_desc<'a>(
        layout: &'a MewPipelineLayout<Self>,
        shader: &'a ShaderModule,
        vertex_entry: Option<&'a str>,
        fragment_entry: Option<&'a str>,
        fragment_targets: &'a Self::FragmentArray<Option<ColorTargetState>>,
    ) -> RenderPipelineDescriptor<'a>;
}
Expand description

Trait for pipeline wrapper types, to get layouts and descriptors about the inner pipeline.

The number of internal bind groups must be defined in the generic parameter, because associated consts are “uNsTAbLe”, apparently.

Note that there is one function that could not be included in this trait, being get_layouts_from_refs<GETTER>(getter: &GETTER) -> MewPipeline<Self>::BindGroupLayoutSet<'_>.
This sin against all Machines takes in a “getter” that implements AsRef for all its internal bind group types, which is precisely what typemap! does semi-statically.
The render context expects this function so that the wrapper type can extract whatever layouts it requires without needing to dump the whole render context into a generic parameter. So if you’re implementing your own stuff to plug into this library, don’t forget about that function.
I don’t use a hashmap here, because going by type is (probably?) a static function call.

Ideally, avoid using this - it’s horribly designed, so just use the pipeline macro.

Required Associated Types§

Source

type BindGroupSet

A tuple of the pipeline’s internal bind groups (max of 4).

Source

type BindGroupLayoutSet<'a>

A tuple of layouts of each of the pipeline’s internal bind groups.

Source

type BindGroupArray<T>

Source

type VertexArray<T>

Source

type FragmentArray<T>

Required Methods§

Source

fn new(pipeline: RenderPipeline) -> Self

Wrap a pipeline.

Source

fn bind_group_layouts<'a>( bind_groups: &Self::BindGroupLayoutSet<'a>, ) -> Self::BindGroupArray<&'a BindGroupLayout>

Get the BindGroupLayout array to descrive the layout of the internal bind groups.

Source

fn layout_desc<'a>( bind_group_layouts: &'a Self::BindGroupArray<&'a BindGroupLayout>, ) -> PipelineLayoutDescriptor<'a>

Get the PipelineLayoutDescriptor for the pipeline. Requires the output from Self::bind_group_layouts because const fns in traits are “uNsTAbLe”, apparently, and lifetimes exist.

Source

fn fragment_targets<'a>( surface_fmt: Option<TextureFormat>, ) -> Self::FragmentArray<Option<ColorTargetState>>

Source

fn pipeline_desc<'a>( layout: &'a MewPipelineLayout<Self>, shader: &'a ShaderModule, vertex_entry: Option<&'a str>, fragment_entry: Option<&'a str>, fragment_targets: &'a Self::FragmentArray<Option<ColorTargetState>>, ) -> RenderPipelineDescriptor<'a>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§