Fix descriptor set offsets binding on pipeline change

This commit is contained in:
Dzmitry Malyshau
2019-08-30 20:46:48 -04:00
parent 0f26def66f
commit 872bf21a9b
3 changed files with 8 additions and 7 deletions

View File

@@ -22,9 +22,9 @@ pub struct BindGroupPair {
}
#[derive(Debug)]
pub enum LayoutChange {
pub enum LayoutChange<'a> {
Unchanged,
Match(BindGroupId),
Match(BindGroupId, &'a [BufferAddress]),
Mismatch,
}
@@ -105,7 +105,8 @@ impl BindGroupEntry {
Some(BindGroupPair {
layout_id,
ref group_id,
}) if layout_id == bind_group_layout_id => LayoutChange::Match(group_id.value),
}) if layout_id == bind_group_layout_id =>
LayoutChange::Match(group_id.value, &self.dynamic_offsets),
Some(_) | None => LayoutChange::Mismatch,
}
} else {

View File

@@ -263,14 +263,14 @@ pub fn compute_pass_set_pipeline<B: GfxBackend>(
.zip(&pipeline_layout.bind_group_layout_ids)
.enumerate()
{
if let LayoutChange::Match(bg_id) = entry.expect_layout(bgl_id) {
if let LayoutChange::Match(bg_id, offsets) = entry.expect_layout(bgl_id) {
let desc_set = bind_group_guard[bg_id].raw.raw();
unsafe {
pass.raw.bind_compute_descriptor_sets(
&pipeline_layout.raw,
index,
iter::once(desc_set),
&[],
offsets.iter().map(|offset| *offset as u32),
);
}
}

View File

@@ -601,14 +601,14 @@ pub fn render_pass_set_pipeline<B: GfxBackend>(
.zip(&pipeline_layout.bind_group_layout_ids)
.enumerate()
{
if let LayoutChange::Match(bg_id) = entry.expect_layout(bgl_id) {
if let LayoutChange::Match(bg_id, offsets) = entry.expect_layout(bgl_id) {
let desc_set = bind_group_guard[bg_id].raw.raw();
unsafe {
pass.raw.bind_graphics_descriptor_sets(
&pipeline_layout.raw,
index,
iter::once(desc_set),
&[],
offsets.iter().map(|offset| *offset as u32),
);
}
}