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

pub trait EncodeBindableResourceGroup {
    type Encoding;
    fn encode_bindable_resource_group(
        self,
        encoding_context: &mut BindGroupEncodingContext
    ) -> BindGroupEncoding<'_, Self::Encoding>; }

A group of resources that may be used to encode a BindGroup.

See also [RenderingContext::create_bind_group] for details on how a BindGroup is created.

This trait is implemented for any type that implements the Resources trait. The Resources trait may automatically derived (see the documentation for the Resources trait for details).

Example

use web_glitz::buffer::{Buffer, BufferView};
use web_glitz::image::texture_2d::FloatSampledTexture2D;
use web_glitz::pipeline::resources::{EncodeBindableResourceGroup, BindGroupEncodingContext, BindGroupEncoding, BindGroupEncoder};

struct Resources<'a, 'b> {
    uniform_buffer: &'a Buffer<std140::mat4x4>,
    texture: FloatSampledTexture2D<'b>
}

impl<'a, 'b> EncodeBindableResourceGroup for Resources<'a, 'b> {
    type Encoding = (
        BufferView<'a, std140::mat4x4>,
        FloatSampledTexture2D<'b>,
    );

    fn encode_bindable_resource_group(
        self,
        encoding_context: &mut BindGroupEncodingContext
    ) -> BindGroupEncoding<Self::Encoding> {
        BindGroupEncoder::new(encoding_context, Some(2))
            .add_buffer_view(0, self.uniform_buffer.into())
            .add_float_sampled_texture_2d(1, self.texture)
            .finish()
    }
}

Associated Types

Loading content...

Required methods

fn encode_bindable_resource_group(
    self,
    encoding_context: &mut BindGroupEncodingContext
) -> BindGroupEncoding<'_, Self::Encoding>

Encodes a description of the bindings for the resources in the group.

Loading content...

Implementations on Foreign Types

impl EncodeBindableResourceGroup for ()[src]

type Encoding = ()

Loading content...

Implementors

impl<T> EncodeBindableResourceGroup for T where
    T: Resources
[src]

type Encoding = T::Encoding

Loading content...