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