1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::*;
/// Handle to a pipeline layout.
///
/// A `PipelineLayout` object describes the available binding groups of a pipeline.
/// It can be created with [`Device::create_pipeline_layout`].
///
/// Corresponds to [WebGPU `GPUPipelineLayout`](https://gpuweb.github.io/gpuweb/#gpupipelinelayout).
#[derive(Debug, Clone)]
pub struct PipelineLayout {
pub(crate) inner: dispatch::DispatchPipelineLayout,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(PipelineLayout: Send, Sync);
crate::cmp::impl_eq_ord_hash_proxy!(PipelineLayout => .inner);
impl PipelineLayout {
#[cfg(custom)]
/// Returns custom implementation of PipelineLayout (if custom backend and is internally T)
pub fn as_custom<T: custom::PipelineLayoutInterface>(&self) -> Option<&T> {
self.inner.as_custom()
}
}
#[cfg(wgpu_core)]
impl PipelineLayout {
/// Create a new pipeline layout of wgpu from a wgpu-core pipeline layout.
///
/// # Arguments
///
/// - `core_pipeline_layout` - wgpu-core pipeline layout.
pub fn from_core(
core_pipeline_layout: alloc::sync::Arc<wgc::binding_model::PipelineLayout>,
) -> Self {
Self {
inner: crate::backend::wgpu_core::CorePipelineLayout::from_core(core_pipeline_layout)
.into(),
}
}
/// Returns the underlying wgpu-core pipeline layout if this `PipelineLayout` is on the wgpu-core backend, otherwise `None`.
pub fn as_core(&self) -> Option<alloc::sync::Arc<wgc::binding_model::PipelineLayout>> {
self.inner.as_core_opt().map(|pl| pl.as_core())
}
}
/// Describes a [`PipelineLayout`].
///
/// For use with [`Device::create_pipeline_layout`].
///
/// Corresponds to [WebGPU `GPUPipelineLayoutDescriptor`](
/// https://gpuweb.github.io/gpuweb/#dictdef-gpupipelinelayoutdescriptor).
#[derive(Clone, Debug, Default)]
pub struct PipelineLayoutDescriptor<'a> {
/// Debug label of the pipeline layout. This will show up in graphics debuggers for easy identification.
pub label: Label<'a>,
/// Bind groups that this pipeline uses. The first entry will provide all the bindings for
/// "set = 0", second entry will provide all the bindings for "set = 1" etc.
pub bind_group_layouts: &'a [Option<&'a BindGroupLayout>],
/// The number of bytes of immediate data that are allocated for use
/// in the shader. The `var<immediate>`s in the shader attached to
/// this pipeline must be equal or smaller than this size.
///
/// If this value is non-zero, [`Features::IMMEDIATES`] must be enabled.
pub immediate_size: u32,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(PipelineLayoutDescriptor<'_>: Send, Sync);