From 7189c7fa842e5bb6df2918b89d1ac73763261a18 Mon Sep 17 00:00:00 2001 From: Jonathan Steyfkens Date: Sun, 28 Oct 2018 07:47:20 +0000 Subject: [PATCH] Impl DescriptorSetCollection for vec (#1094) --- CHANGELOG.md | 1 + .../descriptor/descriptor_set/collection.rs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96c9b6ae..aaaa68bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Use [google/shaderc](https://github.com/google/shaderc-rs) for shader compilation - Reject generation of rust types for SPIR-V arrays that would have incorrect array stride. - Removed the `Layout` prefix of the descriptions used for a render pass. +- Implemented DescriptorSetCollection for `Vec` which allows easier use of construction them for usage when drawing. # Version 0.10.0 (2018-08-10) diff --git a/vulkano/src/descriptor/descriptor_set/collection.rs b/vulkano/src/descriptor/descriptor_set/collection.rs index c5014bfb..3d23a571 100644 --- a/vulkano/src/descriptor/descriptor_set/collection.rs +++ b/vulkano/src/descriptor/descriptor_set/collection.rs @@ -70,6 +70,28 @@ unsafe impl DescriptorSetsCollection for T } } +unsafe impl DescriptorSetsCollection for Vec + where T: DescriptorSet + Send + Sync + 'static +{ + #[inline] + fn into_vec(self) -> Vec> { + let mut v = Vec::new(); + for o in self { + v.push(Box::new(o) as Box<_>); + } + return v; + } + + #[inline] + fn num_bindings_in_set(&self, set: usize) -> Option { + self.get(set).map(|x| x.num_bindings()) + } + #[inline] + fn descriptor(&self, set: usize, binding: usize) -> Option { + self.get(set).and_then(|x| x.descriptor(binding)) + } +} + macro_rules! impl_collection { ($first:ident $(, $others:ident)+) => ( unsafe impl<$first$(, $others)+> DescriptorSetsCollection for ($first, $($others),+)