wgpu/api/
bind_group_layout.rs

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