diff --git a/Cargo.lock b/Cargo.lock index 1aa64f0f52..c049350524 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -599,6 +599,14 @@ dependencies = [ "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lock_api" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.6" @@ -787,6 +795,16 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot_core" version = "0.3.1" @@ -826,6 +844,20 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parking_lot_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "percent-encoding" version = "1.0.1" @@ -1299,7 +1331,7 @@ dependencies = [ "gfx-hal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rendy-descriptor 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rendy-memory 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1509,6 +1541,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" +"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" @@ -1529,9 +1562,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" +"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" +"checksum parking_lot_core 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a7bbaa05312363e0480e1efee133fff1a09ef4a6406b65e226b9a793c223a32" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" diff --git a/wgpu-native/src/command/bind.rs b/wgpu-native/src/command/bind.rs index 129f6b5c6a..8cc22c9e6f 100644 --- a/wgpu-native/src/command/bind.rs +++ b/wgpu-native/src/command/bind.rs @@ -46,6 +46,7 @@ where pub struct BindGroupEntry { expected_layout_id: Option, provided: Option, + dynamic_offsets: Vec, } 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)> { + ) -> Option<( + PipelineLayoutId, + impl 'a + Iterator, + impl 'a + Iterator, + )> { 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 { diff --git a/wgpu-native/src/command/compute.rs b/wgpu-native/src/command/compute.rs index 5530ea5133..220e374f76 100644 --- a/wgpu-native/src/command/compute.rs +++ b/wgpu-native/src/command/compute.rs @@ -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), ); } }; diff --git a/wgpu-native/src/command/render.rs b/wgpu-native/src/command/render.rs index 1a1d281371..3e95cc3afa 100644 --- a/wgpu-native/src/command/render.rs +++ b/wgpu-native/src/command/render.rs @@ -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), ); } };