Impl DescriptorSetCollection for vec (#1094)

This commit is contained in:
Jonathan Steyfkens 2018-10-28 07:47:20 +00:00 committed by Lucas Kent
parent 3fe7fc4495
commit 7189c7fa84
2 changed files with 23 additions and 0 deletions

View File

@ -17,6 +17,7 @@
- Use [google/shaderc](https://github.com/google/shaderc-rs) for shader compilation - 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. - 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. - Removed the `Layout` prefix of the descriptions used for a render pass.
- Implemented DescriptorSetCollection for `Vec<T>` which allows easier use of construction them for usage when drawing.
# Version 0.10.0 (2018-08-10) # Version 0.10.0 (2018-08-10)

View File

@ -70,6 +70,28 @@ unsafe impl<T> DescriptorSetsCollection for T
} }
} }
unsafe impl<T> DescriptorSetsCollection for Vec<T>
where T: DescriptorSet + Send + Sync + 'static
{
#[inline]
fn into_vec(self) -> Vec<Box<DescriptorSet + Send + Sync>> {
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<usize> {
self.get(set).map(|x| x.num_bindings())
}
#[inline]
fn descriptor(&self, set: usize, binding: usize) -> Option<DescriptorDesc> {
self.get(set).and_then(|x| x.descriptor(binding))
}
}
macro_rules! impl_collection { macro_rules! impl_collection {
($first:ident $(, $others:ident)+) => ( ($first:ident $(, $others:ident)+) => (
unsafe impl<$first$(, $others)+> DescriptorSetsCollection for ($first, $($others),+) unsafe impl<$first$(, $others)+> DescriptorSetsCollection for ($first, $($others),+)