From a46fb070c23609d32f74e1d3c4fbac5b978a69a6 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Fri, 7 Feb 2025 11:10:18 +0100 Subject: [PATCH] Unify `ResolvedPipelineLayoutDescriptor` into `PipelineLayoutDescriptor` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- wgpu-core/src/binding_model.rs | 35 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index ad5c906e3d..f8c4ca7b0d 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -641,14 +641,23 @@ pub enum PushConstantUploadError { /// A `PipelineLayoutDescriptor` can be used to create a pipeline layout. #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct PipelineLayoutDescriptor<'a> { +#[cfg_attr(feature = "serde", serde(bound = "BGL: Serialize"))] +pub struct PipelineLayoutDescriptor<'a, BGL = BindGroupLayoutId> +where + [BGL]: ToOwned, + <[BGL] as ToOwned>::Owned: std::fmt::Debug, +{ /// 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: Cow<'a, [BindGroupLayoutId]>, + #[cfg_attr( + feature = "serde", + serde(bound(deserialize = "<[BGL] as ToOwned>::Owned: Deserialize<'de>")) + )] + pub bind_group_layouts: Cow<'a, [BGL]>, /// Set of push constant ranges this pipeline uses. Each shader stage that /// uses push constants must define the range in push constant memory that /// corresponds to its single `layout(push_constant)` uniform block. @@ -659,27 +668,7 @@ pub struct PipelineLayoutDescriptor<'a> { pub push_constant_ranges: Cow<'a, [wgt::PushConstantRange]>, } -/// Describes a pipeline layout. -/// -/// A `PipelineLayoutDescriptor` can be used to create a pipeline layout. -#[derive(Debug)] -pub struct ResolvedPipelineLayoutDescriptor<'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: Cow<'a, [Arc]>, - /// Set of push constant ranges this pipeline uses. Each shader stage that - /// uses push constants must define the range in push constant memory that - /// corresponds to its single `layout(push_constant)` uniform block. - /// - /// If this array is non-empty, the - /// [`Features::PUSH_CONSTANTS`](wgt::Features::PUSH_CONSTANTS) feature must - /// be enabled. - pub push_constant_ranges: Cow<'a, [wgt::PushConstantRange]>, -} +pub type ResolvedPipelineLayoutDescriptor<'a> = PipelineLayoutDescriptor<'a, Arc>; #[derive(Debug)] pub struct PipelineLayout {