diff --git a/vulkano/src/descriptor/descriptor_set/collection.rs b/vulkano/src/descriptor/descriptor_set/collection.rs index d600041538..29577d77b0 100644 --- a/vulkano/src/descriptor/descriptor_set/collection.rs +++ b/vulkano/src/descriptor/descriptor_set/collection.rs @@ -7,10 +7,13 @@ // notice may not be copied, modified, or distributed except // according to those terms. +use std::iter; +use buffer::Buffer; use descriptor::descriptor::DescriptorDesc; use descriptor::descriptor_set::DescriptorSet; use descriptor::descriptor_set::DescriptorSetDesc; use descriptor::descriptor_set::UnsafeDescriptorSet; +use image::Image; /// A collection of descriptor set objects. pub unsafe trait DescriptorSetsCollection { @@ -31,6 +34,12 @@ pub unsafe trait DescriptorSetsCollection { /// /// Returns `None` if out of range. fn descriptor(&self, set: usize, binding: usize) -> Option; + + /// Returns the list of buffers used by this descriptor set. Includes buffer views. + fn buffers_list<'a>(&'a self) -> Box + 'a>; + + /// Returns the list of images used by this descriptor set. Includes image views. + fn images_list<'a>(&'a self) -> Box + 'a>; } unsafe impl DescriptorSetsCollection for () { @@ -53,6 +62,16 @@ unsafe impl DescriptorSetsCollection for () { fn descriptor(&self, set: usize, binding: usize) -> Option { None } + + #[inline] + fn buffers_list<'a>(&'a self) -> Box + 'a> { + Box::new(iter::empty()) + } + + #[inline] + fn images_list<'a>(&'a self) -> Box + 'a> { + Box::new(iter::empty()) + } } unsafe impl DescriptorSetsCollection for T @@ -86,6 +105,16 @@ unsafe impl DescriptorSetsCollection for T _ => None } } + + #[inline] + fn buffers_list<'a>(&'a self) -> Box + 'a> { + DescriptorSet::buffers_list(self) + } + + #[inline] + fn images_list<'a>(&'a self) -> Box + 'a> { + DescriptorSet::images_list(self) + } } macro_rules! impl_collection { @@ -162,6 +191,26 @@ macro_rules! impl_collection { None } + + #[inline] + fn buffers_list<'a>(&'a self) -> Box + 'a> { + let &(first, $(ref $others,)*) = self; + let iter = first.buffers_list(); + $( + let iter = iter.chain($others.buffers_list()); + )* + Box::new(iter) + } + + #[inline] + fn images_list<'a>(&'a self) -> Box + 'a> { + let &(first, $(ref $others,)*) = self; + let iter = first.images_list(); + $( + let iter = iter.chain($others.images_list()); + )* + Box::new(iter) + } } impl_collection!($($others),*); diff --git a/vulkano/src/descriptor/descriptor_set/mod.rs b/vulkano/src/descriptor/descriptor_set/mod.rs index b8884a9f70..66369ab3ea 100644 --- a/vulkano/src/descriptor/descriptor_set/mod.rs +++ b/vulkano/src/descriptor/descriptor_set/mod.rs @@ -35,7 +35,9 @@ //! - The `DescriptorSetsCollection` trait is implemented on collections of types that implement //! `DescriptorSet`. It is what you pass to the draw functions. +use buffer::Buffer; use descriptor::descriptor::DescriptorDesc; +use image::Image; use SafeDeref; pub use self::collection::DescriptorSetsCollection; @@ -65,6 +67,14 @@ mod unsafe_layout; pub unsafe trait DescriptorSet: DescriptorSetDesc { /// Returns the inner `UnsafeDescriptorSet`. fn inner(&self) -> &UnsafeDescriptorSet; + + /// Returns the list of buffers used by this descriptor set. Includes buffer views. + // TODO: meh for boxing + fn buffers_list<'a>(&'a self) -> Box + 'a>; + + /// Returns the list of images used by this descriptor set. Includes image views. + // TODO: meh for boxing + fn images_list<'a>(&'a self) -> Box + 'a>; } unsafe impl DescriptorSet for T where T: SafeDeref, T::Target: DescriptorSet { @@ -72,6 +82,16 @@ unsafe impl DescriptorSet for T where T: SafeDeref, T::Target: DescriptorSet fn inner(&self) -> &UnsafeDescriptorSet { (**self).inner() } + + #[inline] + fn buffers_list<'a>(&'a self) -> Box + 'a> { + (**self).buffers_list() + } + + #[inline] + fn images_list<'a>(&'a self) -> Box + 'a> { + (**self).images_list() + } } /// Trait for objects that describe the layout of the descriptors of a set. diff --git a/vulkano/src/descriptor/descriptor_set/simple.rs b/vulkano/src/descriptor/descriptor_set/simple.rs index d064c83b74..67376e78f2 100644 --- a/vulkano/src/descriptor/descriptor_set/simple.rs +++ b/vulkano/src/descriptor/descriptor_set/simple.rs @@ -24,6 +24,7 @@ use descriptor::descriptor_set::StdDescriptorPool; use descriptor::pipeline_layout::PipelineLayoutAbstract; use device::Device; use device::DeviceOwned; +use image::Image; use image::ImageView; use image::sys::Layout; use sampler::Sampler; @@ -65,6 +66,16 @@ unsafe impl DescriptorSet for SimpleDescriptorSet where P: Descripto fn inner(&self) -> &UnsafeDescriptorSet { self.inner.inner() } + + #[inline] + fn buffers_list<'a>(&'a self) -> Box + 'a> { + unimplemented!() + } + + #[inline] + fn images_list<'a>(&'a self) -> Box + 'a> { + unimplemented!() + } } unsafe impl DescriptorSetDesc for SimpleDescriptorSet where P: DescriptorPool {