mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 07:21:04 +01:00
Rebind with proper dynamic offsets
This commit is contained in:
1 parent
7314eaf636
commit
41d0ce14d6
4 files changed
+63
-11
No files matched your search
@@ -46,6 +46,7 @@ where
|
||||
pub struct BindGroupEntry {
|
||||
expected_layout_id: Option<BindGroupLayoutId>,
|
||||
provided: Option<BindGroupPair>,
|
||||
dynamic_offsets: Vec<BufferAddress>,
|
||||
}
|
||||
|
||||
impl BindGroupEntry {
|
||||
@@ -60,7 +61,7 @@ impl BindGroupEntry {
|
||||
layout_id,
|
||||
ref group_id,
|
||||
}) => {
|
||||
if group_id.value == bind_group_id && offsets.is_empty() {
|
||||
if group_id.value == bind_group_id && offsets == self.dynamic_offsets.as_slice() {
|
||||
assert_eq!(layout_id, bind_group.layout_id);
|
||||
return Provision::Unchanged;
|
||||
}
|
||||
@@ -76,6 +77,9 @@ impl BindGroupEntry {
|
||||
ref_count: bind_group.life_guard.ref_count.clone(),
|
||||
},
|
||||
});
|
||||
//TODO: validate the count of dynamic offsets to match the layout
|
||||
self.dynamic_offsets.clear();
|
||||
self.dynamic_offsets.copy_from_slice(offsets);
|
||||
|
||||
Provision::Changed {
|
||||
was_compatible,
|
||||
@@ -144,7 +148,11 @@ impl Binder {
|
||||
bind_group_id: BindGroupId,
|
||||
bind_group: &BindGroupHandle,
|
||||
offsets: &[BufferAddress],
|
||||
) -> Option<(PipelineLayoutId, impl 'a + Iterator<Item = BindGroupId>)> {
|
||||
) -> Option<(
|
||||
PipelineLayoutId,
|
||||
impl 'a + Iterator<Item = BindGroupId>,
|
||||
impl 'a + Iterator<Item = &'a BufferAddress>,
|
||||
)> {
|
||||
trace!("\tBinding [{}] = group {:?}", index, bind_group_id);
|
||||
match self.entries[index].provide(bind_group_id, bind_group, offsets) {
|
||||
Provision::Unchanged => None,
|
||||
@@ -171,6 +179,9 @@ impl Binder {
|
||||
.iter()
|
||||
.map(|entry| entry.actual_value()),
|
||||
},
|
||||
self.entries[index + 1 ..]
|
||||
.iter()
|
||||
.flat_map(|entry| entry.dynamic_offsets.as_slice())
|
||||
)
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -109,18 +109,21 @@ pub extern "C" fn wgpu_compute_pass_set_bind_group(
|
||||
&*texture_guard,
|
||||
);
|
||||
|
||||
if let Some((pipeline_layout_id, follow_up)) =
|
||||
if let Some((pipeline_layout_id, follow_up_sets, follow_up_offsets)) =
|
||||
pass.binder
|
||||
.provide_entry(index as usize, bind_group_id, bind_group, offsets)
|
||||
{
|
||||
let bind_groups =
|
||||
iter::once(bind_group.raw.raw()).chain(follow_up.map(|bg_id| bind_group_guard[bg_id].raw.raw()));
|
||||
let bind_groups = iter::once(bind_group.raw.raw())
|
||||
.chain(follow_up_sets.map(|bg_id| bind_group_guard[bg_id].raw.raw()));
|
||||
unsafe {
|
||||
pass.raw.bind_compute_descriptor_sets(
|
||||
&pipeline_layout_guard[pipeline_layout_id].raw,
|
||||
index as usize,
|
||||
bind_groups,
|
||||
offsets.iter().map(|&off| off as hal::command::DescriptorSetOffset),
|
||||
offsets
|
||||
.iter()
|
||||
.chain(follow_up_offsets)
|
||||
.map(|&off| off as hal::command::DescriptorSetOffset),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -249,18 +249,21 @@ pub extern "C" fn wgpu_render_pass_set_bind_group(
|
||||
|
||||
pass.trackers.merge_extend(&bind_group.used);
|
||||
|
||||
if let Some((pipeline_layout_id, follow_up)) =
|
||||
if let Some((pipeline_layout_id, follow_up_sets, follow_up_offsets)) =
|
||||
pass.binder
|
||||
.provide_entry(index as usize, bind_group_id, bind_group, offsets)
|
||||
{
|
||||
let bind_groups =
|
||||
iter::once(bind_group.raw.raw()).chain(follow_up.map(|bg_id| bind_group_guard[bg_id].raw.raw()));
|
||||
let bind_groups = iter::once(bind_group.raw.raw())
|
||||
.chain(follow_up_sets.map(|bg_id| bind_group_guard[bg_id].raw.raw()));
|
||||
unsafe {
|
||||
pass.raw.bind_graphics_descriptor_sets(
|
||||
&&pipeline_layout_guard[pipeline_layout_id].raw,
|
||||
index as usize,
|
||||
bind_groups,
|
||||
offsets.iter().map(|&off| off as hal::command::DescriptorSetOffset),
|
||||
offsets
|
||||
.iter()
|
||||
.chain(follow_up_offsets)
|
||||
.map(|&off| off as hal::command::DescriptorSetOffset),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user