Skip to content

Commit

Permalink
Fully support bind group layout deduplication in Pipeline::get_bind_g…
Browse files Browse the repository at this point in the history
…roup_layout
  • Loading branch information
nical committed Oct 3, 2023
1 parent 913eb1a commit 776ed52
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,24 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
None => break binding_model::GetBindGroupLayoutError::InvalidGroupIndex(index),
};

bgl_guard[*id].multi_ref_count.inc();
let layout = &bgl_guard[*id];
layout.multi_ref_count.inc();

if G::ids_are_generated_in_wgpu() {
return (id.0, None);
}

// The ID is provided externally, so we must create a new bind group layout
// with the given ID as a duplicate of the existing one.
let new_layout = BindGroupLayout {
device_id: layout.device_id.clone(),
inner: crate::binding_model::BglOrDuplicate::<A>::Duplicate(*id),
multi_ref_count: crate::MultiRefCount::new(),
};

let fid = hub.bind_group_layouts.prepare(id_in);
let id = fid.assign(new_layout, &mut Token::root());

return (id.0, None);
};

Expand Down

0 comments on commit 776ed52

Please sign in to comment.