change Device.create_pipeline_layout to return an Arc<PipelineLayout<A>

This commit is contained in:
teoxoy 2024-08-05 17:29:39 +02:00 committed by Teodor Tanasoaia
parent 36c998a558
commit 47465ddb1c
2 changed files with 9 additions and 5 deletions

View File

@ -761,7 +761,7 @@ impl Global {
Err(e) => break 'error e, Err(e) => break 'error e,
}; };
let id = fid.assign(Arc::new(layout)); let id = fid.assign(layout);
api_log!("Device::create_pipeline_layout -> {id:?}"); api_log!("Device::create_pipeline_layout -> {id:?}");
return (id, None); return (id, None);
}; };

View File

@ -2484,7 +2484,8 @@ impl<A: HalApi> Device<A> {
pub(crate) fn create_pipeline_layout( pub(crate) fn create_pipeline_layout(
self: &Arc<Self>, self: &Arc<Self>,
desc: &binding_model::ResolvedPipelineLayoutDescriptor<A>, desc: &binding_model::ResolvedPipelineLayoutDescriptor<A>,
) -> Result<binding_model::PipelineLayout<A>, binding_model::CreatePipelineLayoutError> { ) -> Result<Arc<binding_model::PipelineLayout<A>>, binding_model::CreatePipelineLayoutError>
{
use crate::binding_model::CreatePipelineLayoutError as Error; use crate::binding_model::CreatePipelineLayoutError as Error;
self.check_is_valid()?; self.check_is_valid()?;
@ -2576,13 +2577,17 @@ impl<A: HalApi> Device<A> {
drop(raw_bind_group_layouts); drop(raw_bind_group_layouts);
Ok(binding_model::PipelineLayout { let layout = binding_model::PipelineLayout {
raw: Some(raw), raw: Some(raw),
device: self.clone(), device: self.clone(),
label: desc.label.to_string(), label: desc.label.to_string(),
bind_group_layouts, bind_group_layouts,
push_constant_ranges: desc.push_constant_ranges.iter().cloned().collect(), push_constant_ranges: desc.push_constant_ranges.iter().cloned().collect(),
}) };
let layout = Arc::new(layout);
Ok(layout)
} }
pub(crate) fn derive_pipeline_layout( pub(crate) fn derive_pipeline_layout(
@ -2628,7 +2633,6 @@ impl<A: HalApi> Device<A> {
}; };
let layout = self.create_pipeline_layout(&layout_desc)?; let layout = self.create_pipeline_layout(&layout_desc)?;
let layout = Arc::new(layout);
Ok(layout) Ok(layout)
} }