[][src]Trait web_glitz::pipeline::resources::ResourceBindings

pub trait ResourceBindings {
    type BindGroups: Borrow<[BindGroupDescriptor]> + 'static;
    fn encode(
        self,
        encoding_context: &mut ResourceBindingsEncodingContext
    ) -> ResourceBindingsEncoding<'_, Self::BindGroups>; }

Encodes a description of how a set of resources is bound to a pipeline, such that the pipeline may access these resources during its execution.

Example

use web_glitz::buffer::Buffer;
use web_glitz::image::texture_2d::FloatSampledTexture2D;
use web_glitz::pipeline::resources::{ResourceBindings, ResourceBindingsEncodingContext, ResourceBindingsEncoding, StaticResourceBindingsEncoder, BindGroup, BindGroupDescriptor};

struct Resources<T0, T1> {
    bind_group_0: BindGroup<T0>,
    bind_group_1: BindGroup<T1>,
}

impl<T0, T1> ResourceBindings for &'_ Resources<T0, T1> {
    type BindGroups = [BindGroupDescriptor; 2];

    fn encode(
        self,
        encoding_context: &mut ResourceBindingsEncodingContext
    ) -> ResourceBindingsEncoding<Self::BindGroups> {
        let encoder = StaticResourceBindingsEncoder::new(encoding_context);

        let encoder = encoder.add_bind_group(0, &self.bind_group_0);
        let encoder = encoder.add_bind_group(1, &self.bind_group_1);

        encoder.finish()
    }
}

See also StaticResourceBindingsEncoder.

Note that when multiple bindings of the same type bind to the same slot-index, then only the binding that was added last will be used. However, buffer resources and texture resources belong to distinct bind groups, their slot-indices do not interact.

This trait is automatically implemented for any type that derives the Resources trait.

Associated Types

type BindGroups: Borrow<[BindGroupDescriptor]> + 'static

Type that describes the collection of bindings.

Loading content...

Required methods

fn encode(
    self,
    encoding_context: &mut ResourceBindingsEncodingContext
) -> ResourceBindingsEncoding<'_, Self::BindGroups>

Encodes a description of how this set of resources is bound to a pipeline.

Loading content...

Implementations on Foreign Types

impl ResourceBindings for ()[src]

type BindGroups = [BindGroupDescriptor; 0]

impl<T0, T1, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>)[src]

type BindGroups = [BindGroupDescriptor; 2]

impl<T0, T1, T2, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>)[src]

type BindGroups = [BindGroupDescriptor; 3]

impl<T0, T1, T2, T3, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>)[src]

type BindGroups = [BindGroupDescriptor; 4]

impl<T0, T1, T2, T3, T4, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>)[src]

type BindGroups = [BindGroupDescriptor; 5]

impl<T0, T1, T2, T3, T4, T5, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>)[src]

type BindGroups = [BindGroupDescriptor; 6]

impl<T0, T1, T2, T3, T4, T5, T6, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>)[src]

type BindGroups = [BindGroupDescriptor; 7]

impl<T0, T1, T2, T3, T4, T5, T6, T7, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>)[src]

type BindGroups = [BindGroupDescriptor; 8]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>)[src]

type BindGroups = [BindGroupDescriptor; 9]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>)[src]

type BindGroups = [BindGroupDescriptor; 10]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>, &'_ BindGroup<T10>)[src]

type BindGroups = [BindGroupDescriptor; 11]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>, &'_ BindGroup<T10>, &'_ BindGroup<T11>)[src]

type BindGroups = [BindGroupDescriptor; 12]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>, &'_ BindGroup<T10>, &'_ BindGroup<T11>, &'_ BindGroup<T12>)[src]

type BindGroups = [BindGroupDescriptor; 13]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>, &'_ BindGroup<T10>, &'_ BindGroup<T11>, &'_ BindGroup<T12>, &'_ BindGroup<T13>)[src]

type BindGroups = [BindGroupDescriptor; 14]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>, &'_ BindGroup<T10>, &'_ BindGroup<T11>, &'_ BindGroup<T12>, &'_ BindGroup<T13>, &'_ BindGroup<T14>)[src]

type BindGroups = [BindGroupDescriptor; 15]

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_, '_> ResourceBindings for (&'_ BindGroup<T0>, &'_ BindGroup<T1>, &'_ BindGroup<T2>, &'_ BindGroup<T3>, &'_ BindGroup<T4>, &'_ BindGroup<T5>, &'_ BindGroup<T6>, &'_ BindGroup<T7>, &'_ BindGroup<T8>, &'_ BindGroup<T9>, &'_ BindGroup<T10>, &'_ BindGroup<T11>, &'_ BindGroup<T12>, &'_ BindGroup<T13>, &'_ BindGroup<T14>, &'_ BindGroup<T15>)[src]

type BindGroups = [BindGroupDescriptor; 16]

Loading content...

Implementors

impl<T0, '_> ResourceBindings for &'_ BindGroup<T0>[src]

type BindGroups = [BindGroupDescriptor; 1]

Loading content...