Skip to content

Commit 47465dd

Browse files
committed
change Device.create_pipeline_layout to return an Arc<PipelineLayout<A>
1 parent 36c998a commit 47465dd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

wgpu-core/src/device/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl Global {
761761
Err(e) => break 'error e,
762762
};
763763

764-
let id = fid.assign(Arc::new(layout));
764+
let id = fid.assign(layout);
765765
api_log!("Device::create_pipeline_layout -> {id:?}");
766766
return (id, None);
767767
};

wgpu-core/src/device/resource.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,7 +2484,8 @@ impl<A: HalApi> Device<A> {
24842484
pub(crate) fn create_pipeline_layout(
24852485
self: &Arc<Self>,
24862486
desc: &binding_model::ResolvedPipelineLayoutDescriptor<A>,
2487-
) -> Result<binding_model::PipelineLayout<A>, binding_model::CreatePipelineLayoutError> {
2487+
) -> Result<Arc<binding_model::PipelineLayout<A>>, binding_model::CreatePipelineLayoutError>
2488+
{
24882489
use crate::binding_model::CreatePipelineLayoutError as Error;
24892490

24902491
self.check_is_valid()?;
@@ -2576,13 +2577,17 @@ impl<A: HalApi> Device<A> {
25762577

25772578
drop(raw_bind_group_layouts);
25782579

2579-
Ok(binding_model::PipelineLayout {
2580+
let layout = binding_model::PipelineLayout {
25802581
raw: Some(raw),
25812582
device: self.clone(),
25822583
label: desc.label.to_string(),
25832584
bind_group_layouts,
25842585
push_constant_ranges: desc.push_constant_ranges.iter().cloned().collect(),
2585-
})
2586+
};
2587+
2588+
let layout = Arc::new(layout);
2589+
2590+
Ok(layout)
25862591
}
25872592

25882593
pub(crate) fn derive_pipeline_layout(
@@ -2628,7 +2633,6 @@ impl<A: HalApi> Device<A> {
26282633
};
26292634

26302635
let layout = self.create_pipeline_layout(&layout_desc)?;
2631-
let layout = Arc::new(layout);
26322636
Ok(layout)
26332637
}
26342638

0 commit comments

Comments
 (0)