wgpu/api/
pipeline_layout.rs

1use std::{sync::Arc, thread};
2
3use crate::*;
4
5/// Handle to a pipeline layout.
6///
7/// A `PipelineLayout` object describes the available binding groups of a pipeline.
8/// It can be created with [`Device::create_pipeline_layout`].
9///
10/// Corresponds to [WebGPU `GPUPipelineLayout`](https://gpuweb.github.io/gpuweb/#gpupipelinelayout).
11#[derive(Debug)]
12pub struct PipelineLayout {
13    pub(crate) context: Arc<C>,
14    pub(crate) data: Box<Data>,
15}
16#[cfg(send_sync)]
17static_assertions::assert_impl_all!(PipelineLayout: Send, Sync);
18
19super::impl_partialeq_eq_hash!(PipelineLayout);
20
21impl Drop for PipelineLayout {
22    fn drop(&mut self) {
23        if !thread::panicking() {
24            self.context.pipeline_layout_drop(self.data.as_ref());
25        }
26    }
27}
28
29/// Describes a [`PipelineLayout`].
30///
31/// For use with [`Device::create_pipeline_layout`].
32///
33/// Corresponds to [WebGPU `GPUPipelineLayoutDescriptor`](
34/// https://gpuweb.github.io/gpuweb/#dictdef-gpupipelinelayoutdescriptor).
35#[derive(Clone, Debug, Default)]
36pub struct PipelineLayoutDescriptor<'a> {
37    /// Debug label of the pipeline layout. This will show up in graphics debuggers for easy identification.
38    pub label: Label<'a>,
39    /// Bind groups that this pipeline uses. The first entry will provide all the bindings for
40    /// "set = 0", second entry will provide all the bindings for "set = 1" etc.
41    pub bind_group_layouts: &'a [&'a BindGroupLayout],
42    /// Set of push constant ranges this pipeline uses. Each shader stage that uses push constants
43    /// must define the range in push constant memory that corresponds to its single `var<push_constant>`
44    /// buffer.
45    ///
46    /// If this array is non-empty, the [`Features::PUSH_CONSTANTS`] must be enabled.
47    pub push_constant_ranges: &'a [PushConstantRange],
48}
49#[cfg(send_sync)]
50static_assertions::assert_impl_all!(PipelineLayoutDescriptor<'_>: Send, Sync);