wgpu/api/
bind_group_layout.rs

1use crate::*;
2
3/// Handle to a binding group layout.
4///
5/// A `BindGroupLayout` is a handle to the GPU-side layout of a binding group. It can be used to
6/// create a [`BindGroupDescriptor`] object, which in turn can be used to create a [`BindGroup`]
7/// object with [`Device::create_bind_group`]. A series of `BindGroupLayout`s can also be used to
8/// create a [`PipelineLayoutDescriptor`], which can be used to create a [`PipelineLayout`].
9///
10/// It can be created with [`Device::create_bind_group_layout`].
11///
12/// Corresponds to [WebGPU `GPUBindGroupLayout`](
13/// https://gpuweb.github.io/gpuweb/#gpubindgrouplayout).
14#[derive(Debug, Clone)]
15pub struct BindGroupLayout {
16    pub(crate) inner: dispatch::DispatchBindGroupLayout,
17}
18#[cfg(send_sync)]
19static_assertions::assert_impl_all!(BindGroupLayout: Send, Sync);
20
21crate::cmp::impl_eq_ord_hash_proxy!(BindGroupLayout => .inner);
22
23impl BindGroupLayout {
24    #[cfg(custom)]
25    /// Returns custom implementation of BindGroupLayout (if custom backend and is internally T)
26    pub fn as_custom<T: custom::BindGroupLayoutInterface>(&self) -> Option<&T> {
27        self.inner.as_custom()
28    }
29}
30
31/// Describes a [`BindGroupLayout`].
32///
33/// For use with [`Device::create_bind_group_layout`].
34///
35/// Corresponds to [WebGPU `GPUBindGroupLayoutDescriptor`](
36/// https://gpuweb.github.io/gpuweb/#dictdef-gpubindgrouplayoutdescriptor).
37#[derive(Clone, Debug)]
38pub struct BindGroupLayoutDescriptor<'a> {
39    /// Debug label of the bind group layout. This will show up in graphics debuggers for easy identification.
40    pub label: Label<'a>,
41
42    /// Array of entries in this BindGroupLayout
43    pub entries: &'a [BindGroupLayoutEntry],
44}
45static_assertions::assert_impl_all!(BindGroupLayoutDescriptor<'_>: Send, Sync);