Image and teapot examples now working simultaneously

This commit is contained in:
Pierre Krieger 2016-02-24 13:51:34 +01:00
parent 9822ed35de
commit 5901915ee9
3 changed files with 56 additions and 4 deletions

View File

@ -169,7 +169,7 @@ fn main() {
};
let framebuffers = images.iter().map(|image| {
vulkano::framebuffer::Framebuffer::new(&renderpass, (1244, 699, 1), image.clone() as std::sync::Arc<_>).unwrap()
vulkano::framebuffer::Framebuffer::new(&renderpass, (1244, 699, 1), (image.clone() as std::sync::Arc<_>,)).unwrap()
}).collect::<Vec<_>>();

View File

@ -294,8 +294,10 @@ macro_rules! single_pass_renderpass {
// FIXME: should be stronger-typed
type AttachmentsList = (
Arc<$crate::image::AbstractImageView>
); // FIXME:
$(
Arc<$crate::image::AbstractTypedImageView<$crate::image::Type2d, $crate::formats::$format>>,
)*
);
#[inline]
fn convert_clear_values(&self, val: Self::ClearValues) -> Self::ClearValuesIter {
@ -338,7 +340,7 @@ macro_rules! single_pass_renderpass {
#[inline]
fn convert_attachments_list(&self, l: Self::AttachmentsList) -> Self::AttachmentsIter {
vec![l.clone()/*, l.1.clone()*/].into_iter()
$crate::image::AbstractTypedImageViewsTuple::iter(l)
}
}

View File

@ -17,6 +17,7 @@
use std::mem;
use std::ptr;
use std::sync::Arc;
use std::vec::IntoIter as VecIntoIter;
use command_buffer::CommandBufferPool;
use device::Device;
@ -91,6 +92,50 @@ pub unsafe trait AbstractImageView: Resource + ::VulkanObjectU64 {
fn usage_input_attachment(&self) -> bool;
}
// IMPORTANT: we transmute some Arc<AbstractTypedImageView> into Arc<AbstractImageView>, so
// the signature of AbstractTypedImageView should never require another trait
pub unsafe trait AbstractTypedImageView<Ty, F>: AbstractImageView
where Ty: ImageTypeMarker, F: FormatMarker
{
}
pub unsafe trait AbstractTypedImageViewsTuple {
type Iter: Iterator<Item = Arc<AbstractImageView>>;
fn iter(self) -> Self::Iter;
}
macro_rules! impl_abstract_typed_image_views_tuple {
({$f_ty:ident, $f_m:ident} $({$o_ty:ident, $o_m:ident})*) => (
unsafe impl<$f_ty, $f_m $(, $o_ty, $o_m)*> AbstractTypedImageViewsTuple for
(Arc<AbstractTypedImageView<$f_ty, $f_m>>, $(Arc<AbstractTypedImageView<$o_ty, $o_m>>),*)
{
type Iter = VecIntoIter<Arc<AbstractImageView>>;
#[inline]
#[allow(non_snake_case)]
fn iter(self) -> VecIntoIter<Arc<AbstractImageView>> {
// TODO: Holy shit that transmute is ultra dangerous, but it's the only
// solution to turn that Arc<AbstractTypedImageView> into an
// Arc<AbstractImageView>.
// See https://github.com/rust-lang/rust/issues/5665.
unsafe {
let ($f_ty, $($o_ty,)*) = self;
vec![
mem::transmute($f_ty) $(, mem::transmute($o_ty))*
].into_iter()
}
}
}
impl_abstract_typed_image_views_tuple!($({$o_ty, $o_m})*);
);
() => ();
}
impl_abstract_typed_image_views_tuple!({Aty, Am} {Bty, Bm}); // TODO: finish
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u32)]
pub enum Layout {
@ -771,6 +816,11 @@ unsafe impl<Ty, F, M> AbstractImageView for ImageView<Ty, F, M>
}
}
unsafe impl<Ty, F, M> AbstractTypedImageView<Ty, F> for ImageView<Ty, F, M>
where Ty: ImageTypeMarker, F: FormatMarker, M: MemorySourceChunk
{
}
impl<Ty, F, M> Drop for ImageView<Ty, F, M> where Ty: ImageTypeMarker {
#[inline]
fn drop(&mut self) {